From: David Levine Date: Mon, 31 Jul 2017 00:24:34 +0000 (-0400) Subject: Hacked m_Eom() to fix test-eom-align. X-Git-Url: https://diplodocus.org/git/nmh/commitdiff_plain/29db9a64a1436516c245642bbce2b8ab4cfb673d?ds=sidebyside;hp=278ab4487e14f01d66c6c7c2979ee8a4c645c05d Hacked m_Eom() to fix test-eom-align. --- diff --git a/Makefile.am b/Makefile.am index ae7b98c3..4f6627e4 100644 --- a/Makefile.am +++ b/Makefile.am @@ -166,9 +166,7 @@ TESTS = \ test/whom/test-whom \ test/cleanup ## The "cleanup" test should always be last. -XFAIL_TESTS = \ - test/inc/test-eom-align \ - # +XFAIL_TESTS = check_SCRIPTS = test/common.sh diff --git a/sbr/m_getfld.c b/sbr/m_getfld.c index f7a7acb9..cc283c2a 100644 --- a/sbr/m_getfld.c +++ b/sbr/m_getfld.c @@ -874,6 +874,7 @@ m_Eom (m_getfld_state_t s) int i; char text[MAX_DELIMITER_SIZE]; char *cp; + int adjust = 1; for (i = 0, cp = text; i < s->edelimlen; ++i, ++cp) { int c2; @@ -882,7 +883,7 @@ m_Eom (m_getfld_state_t s) *cp = '\0'; break; } - *cp = c2; + *cp = c2; } if (i != s->edelimlen || @@ -894,11 +895,18 @@ m_Eom (m_getfld_state_t s) return 1; } + if (i != s->edelimlen && ! strncmp(text, s->fdelim, i)) { + /* If all or part of fdelim appeared at the end of the file, + back up even more so that the bytes are included in the + message. */ + adjust = 2; + } + /* Did not find delimiter, so restore the read position. Note that on input, a character had already been read with Getc(). It will be unget by m_getfld () on return. */ - s->readpos -= s->bytes_read - 1; - s->bytes_read = 1; + s->readpos -= s->bytes_read - adjust; + s->bytes_read = adjust; return 0; }