From: David Levine Date: Tue, 25 Feb 2014 02:18:17 +0000 (-0600) Subject: Fixed m_getfld() to not return EOF indicator, so that files need X-Git-Url: https://diplodocus.org/git/nmh/commitdiff_plain/a0514c9a6f41ea1b0d60553ca578312a9f3bd9ab Fixed m_getfld() to not return EOF indicator, so that files need not end with a newline. --- diff --git a/sbr/m_getfld.c b/sbr/m_getfld.c index 9884ba44..d278e528 100644 --- a/sbr/m_getfld.c +++ b/sbr/m_getfld.c @@ -630,7 +630,7 @@ m_getfld (m_getfld_state_t *gstate, char name[NAMESZ], char *buf, int *bufsz, n = 0; for (finished = 0; ! finished; ) { while (c != '\n' && c != EOF && n++ < max) { - *cp++ = c = Getc (s); + if ((c = Getc (s)) != EOF) { *cp++ = c; } } if (c != EOF) c = Peek (s); diff --git a/test/mhparam/test-mhparam b/test/mhparam/test-mhparam index 96160c0d..cea61a7d 100755 --- a/test/mhparam/test-mhparam +++ b/test/mhparam/test-mhparam @@ -165,4 +165,8 @@ set -e # check for correctness here. mhparam -debug >/dev/null +# check with text file that does not end with newline +printf 'Editor: emacs' >>"$MH" +run_test 'mhparam -nocomponent editor' 'emacs' + exit $failed