- 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.
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
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}