+ m->last_file_position = ftello (iob);
+ } else {
+ off_t position = ftello (iob);
+
+ /* Compare current file position with last file position. If
+ different, then caller must have called ftell(), so adjust
+ by the same amounmt. */
+ if (position - m->last_file_position != 0) {
+ size_t num_read;
+
+ /* Opportunity for optimization here: don't reread if the
+ new position had already been read into the buffer,
+ just move m->readpos to it. */
+ fseeko (iob, 0, SEEK_SET);
+ do {
+ num_read = fread (m->msg_buf, 1, MSG_INPUT_SIZE, iob);
+ position -= num_read;
+ } while (position > 0);
+ m->readpos = m->msg_buf + position + num_read;
+ m->end = m->msg_buf + num_read;
+
+ m->last_file_position = position;
+ }
+
+ fseeko (iob, position, SEEK_SET);