]> diplodocus.org Git - nmh/commitdiff
m_getfld.c: Alter Peek() to match Getc()'s structure.
authorRalph Corderoy <ralph@inputplus.co.uk>
Wed, 9 Aug 2017 22:56:27 +0000 (23:56 +0100)
committerRalph Corderoy <ralph@inputplus.co.uk>
Wed, 9 Aug 2017 22:56:27 +0000 (23:56 +0100)
Their logic was equivalent, but written differently, which didn't help
the reader easily see they were the same apart from whether the returned
character was consumed.  Now they're visually similar too.

sbr/m_getfld.c

index 84636a6..6804e58 100644 (file)
@@ -520,10 +520,11 @@ Getc (m_getfld_state_t s) {
  * or EOF on end of file. */
 static int
 Peek (m_getfld_state_t s) {
-    if (s->end - s->readpos < 1  &&  read_more (s) == 0) {
+    if ((s->end - s->readpos < 1 && read_more (s) == 0) ||
+        s->readpos >= s->end)
         return EOF;
-    }
-    return s->readpos < s->end  ?  (unsigned char) *s->readpos  :  EOF;
+
+    return (unsigned char)*s->readpos;
 }
 
 /* If there's room, undo the consumption of one character from msg_buf,