Don't know if this was actually causing a problem, or if it was wrong,
but bytes_read was always being incremented even if the later test
showed readpos was to be left unincremented and EOF returned instead.
All tests still pass so any breakage must be subtle!
but EOF is typically 0xffffffff. */
static int
Getc (m_getfld_state_t s) {
but EOF is typically 0xffffffff. */
static int
Getc (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)
- } else {
- ++s->bytes_read;
- return s->readpos < s->end ? (unsigned char) *s->readpos++ : EOF;
- }
+
+ s->bytes_read++;
+ return (unsigned char)*s->readpos++;