From 84f9d71e633da19ef779a505a1fa7aac545d0afc Mon Sep 17 00:00:00 2001 From: Taco Hoekwater Date: Tue, 1 Jul 2008 07:57:24 +0000 Subject: [PATCH] support partial lines git-svn-id: svn+ssh://scm.foundry.supelec.fr/svn/metapost/mplib/trunk@582 b0617d17-b707-0410-b22c-fd2634e05cc4 --- src/texk/web2c/mpdir/mpxout.w | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/texk/web2c/mpdir/mpxout.w b/src/texk/web2c/mpdir/mpxout.w index 64d46f7..ce801d0 100644 --- a/src/texk/web2c/mpdir/mpxout.w +++ b/src/texk/web2c/mpdir/mpxout.w @@ -388,12 +388,13 @@ unsigned bufsize; mpx->bufsize = 1000; @ This function returns NULL on EOF, otherwise it returns |buf|. -TODO: It fails to detect a partial last line (missing newline) @c static char *mpx_getline(MPX mpx, FILE *mpfile) { int c; unsigned loc = 0; + if (feof(mpfile)) + return NULL; if (mpx->buf==NULL) mpx->buf = xmalloc(mpx->bufsize,1); while ((c = getc(mpfile)) != EOF && c != '\n' && c != '\r') { @@ -409,8 +410,6 @@ static char *mpx_getline(MPX mpx, FILE *mpfile) { mpx->bufsize = n; } } - if (c == EOF) - return NULL; mpx->buf[loc] = 0; if (c == '\r') { c = getc(mpfile); -- 2.32.0.93.g670b81a890