From: Ralph Corderoy Date: Wed, 9 Aug 2017 13:49:53 +0000 (+0100) Subject: m_getfld.c: Alter Ungetc() to die if it can't rewind. X-Git-Url: https://diplodocus.org/git/nmh/commitdiff_plain/bc2e83953a3c09e6416e335eb6827aaa483a39f6 m_getfld.c: Alter Ungetc() to die if it can't rewind. It used to return EOF to the caller in this case, but none of the three callers bothered checking. And the other return value of a `peek' of the character that would next be read was also unused. --- diff --git a/sbr/m_getfld.c b/sbr/m_getfld.c index 2458c3e5..08d9eb09 100644 --- a/sbr/m_getfld.c +++ b/sbr/m_getfld.c @@ -525,17 +525,15 @@ Peek (m_getfld_state_t s) { } /* If there's room, undo the consumption of one character from msg_buf, - * rewinding so it's read next. If the previous character isn't - * available because we're at the start of msg_buf then return EOF, else - * return the character that will be read next, a la Peek(). */ -static int + * rewinding so it's read next, else die. */ +static void Ungetc(m_getfld_state_t s) { - if (s->readpos == s->msg_buf) { - return EOF; - } - --s->bytes_read; - return *--s->readpos; + if (s->readpos == s->msg_buf) + adios(NULL, "Ungetc() at start of message buffer."); + + s->readpos--; + s->bytes_read--; }