fix for file_read_line

ulab-original
jsorg71 18 years ago
parent 4b802ae8dd
commit e14366665b

@ -91,18 +91,19 @@ file_read_line(struct stream* s, char* text)
{ {
int i; int i;
int skip_to_end; int skip_to_end;
int at_end;
char c; char c;
char* hold; char* hold;
skip_to_end = 0; skip_to_end = 0;
if (!s_check(s)) if (!s_check_rem(s, 1))
{ {
return 1; return 1;
} }
hold = s->p; hold = s->p;
i = 0; i = 0;
in_uint8(s, c); in_uint8(s, c);
while (c != 10 && c != 13 && s_check(s)) while (c != 10 && c != 13)
{ {
if (c == '#' || c == '!') if (c == '#' || c == '!')
{ {
@ -113,15 +114,35 @@ file_read_line(struct stream* s, char* text)
text[i] = c; text[i] = c;
i++; i++;
} }
in_uint8(s, c); if (s_check_rem(s, 1))
{
in_uint8(s, c);
}
else
{
c = 0;
break;
}
} }
if (c == 10 || c == 13) if (c == 10 || c == 13)
{ {
while ((c == 10 || c == 13) && s_check(s)) at_end = 0;
while (c == 10 || c == 13)
{ {
in_uint8(s, c); if (s_check_rem(s, 1))
{
in_uint8(s, c);
}
else
{
at_end = 1;
break;
}
}
if (!at_end)
{
s->p--;
} }
s->p--;
} }
text[i] = 0; text[i] = 0;
if (text[0] == '[') if (text[0] == '[')
@ -129,14 +150,7 @@ file_read_line(struct stream* s, char* text)
s->p = hold; s->p = hold;
return 1; return 1;
} }
if (s_check(s)) return 0;
{
return 0;
}
else
{
return 1;
}
} }
/*****************************************************************************/ /*****************************************************************************/

Loading…
Cancel
Save