From 210b50a5ac585ae99db277fdae5638772df9c3d9 Mon Sep 17 00:00:00 2001 From: Ralph Corderoy Date: Wed, 9 Aug 2017 23:56:27 +0100 Subject: [PATCH] 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. --- sbr/m_getfld.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) 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, -- 2.56.0