static void
enter_getfld (m_getfld_state_t *gstate, FILE *iob) {
m_getfld_state_t s;
- off_t pos = ftello (iob);
+ off_t pos;
if (! *gstate) {
m_getfld_state_init (gstate, iob);
readpos shift code being currently unused. */
s->iob = iob;
- if (s->track_filepos && (pos != 0 || s->last_internal_pos != 0)) {
+ if (!s->track_filepos)
+ return;
+
+ pos = ftello(iob);
+ if (pos != 0 || s->last_internal_pos != 0) {
if (s->last_internal_pos == 0) {
s->total_bytes_read = pos;
} else {
but EOF is typically 0xffffffff. */
static int
Getc (m_getfld_state_t s) {
- if (s->end - s->readpos < 1) {
- if (read_more (s) == 0) {
- /* Pretend that we read a character. That's what stdio does. */
- ++s->readpos;
- return EOF;
- }
+ if (s->end - s->readpos < 1 && read_more (s) == 0) {
+ return EOF;
+ } else {
+ ++s->bytes_read;
+ return s->readpos < s->end ? (unsigned char) *s->readpos++ : EOF;
}
-
- ++s->bytes_read;
- return s->readpos < s->end ? (unsigned char) *s->readpos++ : EOF;
}
static int
Peek (m_getfld_state_t s) {
- if (s->end - s->readpos < 1) {
- if (read_more (s) == 0) {
- /* Pretend that we read a character. That's what stdio does. */
- ++s->readpos;
- return EOF;
- }
+ if (s->end - s->readpos < 1 && read_more (s) == 0) {
+ return EOF;
+ } else {
+ return s->readpos < s->end ? (unsigned char) *s->readpos : EOF;
}
-
- return s->readpos < s->end ? (unsigned char) *s->readpos : EOF;
}
static int