mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-12 14:50:19 +02:00
* fports.c (scm_fgets): Return if the last char in a chunk is
newline. When fgets returns a string whose length is `size-1', it is ambiguous whether a whole line was retrieved, so we must check explicitly whether a line terminator is present.
This commit is contained in:
parent
1ea4704837
commit
8122b543c1
2 changed files with 25 additions and 15 deletions
|
@ -1,3 +1,10 @@
|
||||||
|
1997-12-04 Tim Pierce <twp@ppp39.Nantucket.net>
|
||||||
|
|
||||||
|
* fports.c (scm_fgets): Return if the last char in a chunk is
|
||||||
|
newline. When fgets returns a string whose length is `size-1', it
|
||||||
|
is ambiguous whether a whole line was retrieved, so we must check
|
||||||
|
explicitly whether a line terminator is present.
|
||||||
|
|
||||||
1997-12-04 Mikael Djurfeldt <mdj@mdj.nada.kth.se>
|
1997-12-04 Mikael Djurfeldt <mdj@mdj.nada.kth.se>
|
||||||
|
|
||||||
* print.h (SCM_COERCE_OUTPORT): Check that the object is a pair
|
* print.h (SCM_COERCE_OUTPORT): Check that the object is a pair
|
||||||
|
|
|
@ -326,23 +326,26 @@ scm_fgets (port)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
while (1) {
|
while (1)
|
||||||
p = buf + i;
|
{
|
||||||
if (fgets (p, limit - i, f) == NULL) {
|
int chunk_size = limit - i;
|
||||||
if (i)
|
|
||||||
|
p = buf + i;
|
||||||
|
if (fgets (p, chunk_size, f) == NULL) {
|
||||||
|
if (i)
|
||||||
|
return buf;
|
||||||
|
free (buf);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (strlen(p) < chunk_size - 1 || buf[limit-2] == '\n')
|
||||||
return buf;
|
return buf;
|
||||||
free (buf);
|
|
||||||
return NULL;
|
buf = (char *) realloc (buf, sizeof(char) * limit * 2);
|
||||||
|
|
||||||
|
i = limit - 1;
|
||||||
|
limit *= 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strlen(p) < limit - i - 1)
|
|
||||||
return buf;
|
|
||||||
|
|
||||||
buf = (char *) realloc (buf, sizeof(char) * limit * 2);
|
|
||||||
|
|
||||||
i = limit - 1;
|
|
||||||
limit *= 2;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef vms
|
#ifdef vms
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue