From: Ralph Corderoy Date: Wed, 9 Aug 2017 22:56:27 +0000 (+0100) Subject: m_getfld.c: Alter Peek() to match Getc()'s structure. X-Git-Url: https://diplodocus.org/git/nmh/commitdiff_plain/210b50a5ac585ae99db277fdae5638772df9c3d9?ds=inline m_getfld.c: Alter Peek() to match Getc()'s structure. 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. --- diff --git a/sbr/m_getfld.c b/sbr/m_getfld.c index 84636a6f..6804e58e 100644 --- a/sbr/m_getfld.c +++ b/sbr/m_getfld.c @@ -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,