| 木村 巌 on Sat, 27 Jan 2001 04:29:49 +0900 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
| lisGEN() in src/language/es.c |
Hi all,
I found that there's no chance to break a loop like this when eof is
reached:
while (1) {
a = lisGEN (f);
outbeaut (a);
}
because fgets() blocks in lisGEN(). So here is a patch:
iwao@kagemaru:~/Lang/C/Pari/pari/src/language {1037}$ cvs -z 3 diff -u es.c
Index: es.c
===================================================================
RCS file: /home/megrez/cvsroot/pari/src/language/es.c,v
retrieving revision 1.28
diff -u -r1.28 es.c
--- es.c 2000/09/25 15:42:43 1.28
+++ es.c 2001/01/26 19:16:02
@@ -125,8 +125,7 @@
long size = 512, n = size;
char *buf = gpmalloc(n), *s = buf;
- for(;;)
- if (fgets(s, n, fi))
+ for(;fgets(s, n, fi);)
{
if (s[strlen(s)-1] == '\n')
{
@@ -136,6 +135,10 @@
buf = gprealloc(buf, size<<1, size);
s = buf + (size-1); n = size+1; size <<= 1;
}
+ if (feof (fi))
+ return NULL;
+ else
+ err (talker, "failed reading from file");
}
We can break a loop when lisGEN(f) == NULL.
BTW, where is flisseq()? This is documented in users.dvi but
I can't find it.
;# Iwao KIMURA ;#
;# Faculty. Math, Dept. of Sciece ;#
;# Toyama University ;#