Improve read_line()
One less useless boolean variable.
This commit is contained in:
parent
ec128558a4
commit
412100289e
22
liberty.c
22
liberty.c
@ -3040,23 +3040,19 @@ xstrtoul (unsigned long *out, const char *s, int base)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
read_line (FILE *fp, struct str *s)
|
read_line (FILE *fp, struct str *line)
|
||||||
{
|
{
|
||||||
|
str_reset (line);
|
||||||
|
|
||||||
int c;
|
int c;
|
||||||
bool at_end = true;
|
while ((c = fgetc (fp)) != '\n')
|
||||||
|
|
||||||
str_reset (s);
|
|
||||||
while ((c = fgetc (fp)) != EOF)
|
|
||||||
{
|
{
|
||||||
at_end = false;
|
if (c == EOF)
|
||||||
if (c == '\r')
|
return line->len != 0;
|
||||||
continue;
|
if (c != '\r')
|
||||||
if (c == '\n')
|
str_append_c (line, c);
|
||||||
break;
|
|
||||||
str_append_c (s, c);
|
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
return !at_end;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
|
Loading…
Reference in New Issue
Block a user