- /*
- * something went wrong. possibilities are:
- * . hit a newline (error)
- * . got more than namesz chars. (error)
- * . hit the end of the buffer. (loop)
- */
- if (c == '\n') {
- /* We hit the end of the line without seeing ':' to
- * terminate the field name. This is usually (always?)
- * spam. But, blowing up is lame, especially when
- * scan(1)ing a folder with such messages. Pretend such
- * lines are the first of the body (at least mutt also
- * handles it this way). */
-
- /* See if buf can hold this line, since we were assuming
- * we had a buffer of NAMESZ, not bufsz. */
- /* + 1 for the newline */
-
- if (*bufsz < j + 1) {
- /* No, it can't. Oh well, guess we'll blow up. */
- *bufsz = *cp = *buf = 0;
- advise (NULL, "eol encountered in field \"%s\"", name);
- state = FMTERR;
- goto finish;
- }
- memcpy (buf, name, j - 1);
- buf[j - 1] = '\n';
- buf[j] = '\0';
- /* The last character read was '\n'. m.bytes_read (and j)
- include that, but it was not put into the name array
- in the for loop above. So subtract 1. */
- *bufsz = --m.bytes_read; /* == j - 1 */
+ /* Skip next character, which is either the space after
+ the ':' or the first folded whitespace. */
+ {
+ int next_char;
+ if (c == EOF || (next_char = Peek (iob)) == EOF) {
+ *bufsz = *cp = *buf = 0;
+ advise (NULL, "eof encountered in field \"%s\"", name);