Really fix off by one error.
This commit is contained in:
parent
fa898af791
commit
81b8e5450e
@ -121,10 +121,10 @@ char *rc_getline (FILE *fp)
|
|||||||
p = line + last;
|
p = line + last;
|
||||||
fgets (p, BUFSIZ, fp);
|
fgets (p, BUFSIZ, fp);
|
||||||
last += strlen (p);
|
last += strlen (p);
|
||||||
} while (! feof (fp) && line[last] != '\n');
|
} while (! feof (fp) && line[last - 1] != '\n');
|
||||||
|
|
||||||
/* Trim the trailing newline */
|
/* Trim the trailing newline */
|
||||||
if (line[last] == '\n')
|
if (line[--last] == '\n')
|
||||||
line[last] = '\0';
|
line[last] = '\0';
|
||||||
|
|
||||||
return (line);
|
return (line);
|
||||||
|
Loading…
Reference in New Issue
Block a user