]> diplodocus.org Git - nmh/commitdiff
Removed incorrect increment of read position pointer, which caused
authorDavid Levine <levinedl@acm.org>
Tue, 6 Sep 2016 13:16:15 +0000 (09:16 -0400)
committerDavid Levine <levinedl@acm.org>
Tue, 6 Sep 2016 13:16:15 +0000 (09:16 -0400)
first character of some very short (less than 4 characters) message
bodies to be dropped.  It seems that the message needed to start
with a "From " line to reveal the problem.

docs/pending-release-notes
sbr/m_getfld.c
test/inc/test-inc-scanout

index 37e6f70d810ff17a87c023074962e19696b1d30d..fce0f5c4788fe021d1aeaadd512bc1fe097a65ea 100644 (file)
@@ -77,3 +77,5 @@ BUG FIXES
 - The format scanner no longer subtracts 1 from the width.  This has the
   effect of no longer counting the trailing newline in the output of
   scan(1), inc(1), and the other programs that rely on the format scanner.
+- The first character of some very short (less than 4 characters) message
+  bodies is no longer dropped.
index 9315059d83ead0e4e5f8e6b0fcee27c5910b1fd9..4da2f3eeb34c8fd93fb8e2527b7331a7f5a40d22 100644 (file)
@@ -444,29 +444,21 @@ read_more (m_getfld_state_t s) {
    but EOF is typically 0xffffffff. */
 static int
 Getc (m_getfld_state_t s) {
-    if (s->end - s->readpos < 1) {
-       if (read_more (s) == 0) {
-           /* Pretend that we read a character.  That's what stdio does. */
-           ++s->readpos;
-           return EOF;
-       }
+    if (s->end - s->readpos < 1  &&  read_more (s) == 0) {
+        return EOF;
+    } else {
+        ++s->bytes_read;
+        return s->readpos < s->end  ?  (unsigned char) *s->readpos++  :  EOF;
     }
-
-    ++s->bytes_read;
-    return s->readpos < s->end  ?  (unsigned char) *s->readpos++  :  EOF;
 }
 
 static int
 Peek (m_getfld_state_t s) {
-    if (s->end - s->readpos < 1) {
-       if (read_more (s) == 0) {
-           /* Pretend that we read a character.  That's what stdio does. */
-           ++s->readpos;
-           return EOF;
-       }
+    if (s->end - s->readpos < 1  &&  read_more (s) == 0) {
+        return EOF;
+    } else {
+        return s->readpos < s->end  ?  (unsigned char) *s->readpos  :  EOF;
     }
-
-    return s->readpos < s->end  ?  (unsigned char) *s->readpos  :  EOF;
 }
 
 static int
index a3ec259374031a8d26426ccd477744a58e127228..4dd5a2657a5c27c05d0efebc25d03ea800335853 100755 (executable)
@@ -433,5 +433,65 @@ run_test "inc -width 60 -file $MH_TEST_DIR/msgbox -truncate" \
   25+ 04/15 me@example.com     <<test >>'
 rm -f  "$MH_TEST_DIR/msgbox"
 
+# check inc (m_getfld, actually) of very, very, very short message
+cat >>"$MH_TEST_DIR/msgbox" <<EOF
+From 
+Date: Tue, 6 Sep 2016 08:52:32 -0400
+From: me@example.com
+
+a
+EOF
+
+run_test "inc -width 50 -file $MH_TEST_DIR/msgbox -truncate" \
+'Incorporating new mail into inbox...
+
+  26+ 09/06 me@example.com     <<a >>'
+rm -f  "$MH_TEST_DIR/msgbox"
+
+# check inc (m_getfld, actually) of very, very short message
+cat >>"$MH_TEST_DIR/msgbox" <<EOF
+From 
+Date: Tue, 6 Sep 2016 08:52:32 -0400
+From: me@example.com
+
+ab
+EOF
+
+run_test "inc -width 50 -file $MH_TEST_DIR/msgbox -truncate" \
+'Incorporating new mail into inbox...
+
+  27+ 09/06 me@example.com     <<ab >>'
+rm -f  "$MH_TEST_DIR/msgbox"
+
+# check inc (m_getfld, actually) of very short message
+cat >>"$MH_TEST_DIR/msgbox" <<EOF
+From 
+Date: Tue, 6 Sep 2016 08:52:32 -0400
+From: me@example.com
+
+abc
+EOF
+
+run_test "inc -width 50 -file $MH_TEST_DIR/msgbox -truncate" \
+'Incorporating new mail into inbox...
+
+  28+ 09/06 me@example.com     <<abc >>'
+rm -f  "$MH_TEST_DIR/msgbox"
+
+# check inc (m_getfld, actually) of short message
+cat >>"$MH_TEST_DIR/msgbox" <<EOF
+From 
+Date: Tue, 6 Sep 2016 08:52:32 -0400
+From: me@example.com
+
+abcd
+EOF
+
+run_test "inc -width 50 -file $MH_TEST_DIR/msgbox -truncate" \
+'Incorporating new mail into inbox...
+
+  29+ 09/06 me@example.com     <<abcd >>'
+rm -f  "$MH_TEST_DIR/msgbox"
+
 
 exit ${failed:-0}