]> diplodocus.org Git - nmh/commitdiff
Hacked m_Eom() to fix test-eom-align.
authorDavid Levine <levinedl@acm.org>
Mon, 31 Jul 2017 00:24:34 +0000 (20:24 -0400)
committerDavid Levine <levinedl@acm.org>
Mon, 31 Jul 2017 00:24:34 +0000 (20:24 -0400)
Makefile.am
sbr/m_getfld.c

index ae7b98c36e85beca8261046e20416033a2e3b84b..4f6627e483868b68a13fa55c42d5920c8e68e567 100644 (file)
@@ -166,9 +166,7 @@ TESTS = \
     test/whom/test-whom \
     test/cleanup ## The "cleanup" test should always be last.
 
     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
 
 
 check_SCRIPTS = test/common.sh
 
index f7a7acb9e17ceb280b4f2bf742a8f2c7e110a764..cc283c2a9248eb27a17a4f81186101ddd67e92a4 100644 (file)
@@ -874,6 +874,7 @@ m_Eom (m_getfld_state_t s)
     int i;
     char text[MAX_DELIMITER_SIZE];
     char *cp;
     int i;
     char text[MAX_DELIMITER_SIZE];
     char *cp;
+    int adjust = 1;
 
     for (i = 0, cp = text; i < s->edelimlen; ++i, ++cp) {
        int c2;
 
     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 = '\0';
            break;
        }
-        *cp = c2;
+       *cp = c2;
     }
 
     if (i != s->edelimlen  ||
     }
 
     if (i != s->edelimlen  ||
@@ -894,11 +895,18 @@ m_Eom (m_getfld_state_t s)
            return 1;
        }
 
            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. */
        /* 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;
     }
 
        return 0;
     }