static int next_char (void) { register int ch; if (start_of_input_line) { start_of_input_line = FALSE; current_line++; } while (1) { if (isp == NULL) return CHAR_EOF; switch (isp->type) { case INPUT_STRING: ch = *isp->u.u_s.string++; if (ch != '\0') return ch; break; case INPUT_FILE: ch = getc (isp->u.u_f.file); if (ch != EOF) { if (ch == '\n') start_of_input_line = TRUE; return ch; } break; case INPUT_MACRO: pop_input (); /* INPUT_MACRO input sources has only one token */ return CHAR_MACRO; default: M4ERROR ((warning_status, 0, "INTERNAL ERROR: Input stack botch in next_char ()")); abort (); } /* End of input source --- pop one level. */ pop_input (); } }
/* * Low level input is done a character at a time. The function * peek_input () is used to look at the next character in the input * stream. At any given time, it reads from the input_block on the top * of the current input stack. */ int peek_input (void) { register int ch; while (1) { if (isp == NULL) return CHAR_EOF; switch (isp->type) { case INPUT_STRING: ch = isp->u.u_s.string[0]; if (ch != '\0') return ch; break; case INPUT_FILE: ch = getc (isp->u.u_f.file); if (ch != EOF) { ungetc (ch, isp->u.u_f.file); return ch; } break; case INPUT_MACRO: return CHAR_MACRO; default: internal_error ("Input stack botch in peek_input ()"); break; } /* End of input source --- pop one level. */ pop_input (); } }
int peek_input (void) { int ch; int (*f)(void); while (1) { if (isp == NULL) return CHAR_EOF; f = isp->funcs->peek_func; if (f != NULL) { if ((ch = (*f)()) != CHAR_RETRY) { return /* (IS_IGNORE(ch)) ? next_char () : */ ch; } } else { MP4HERROR ((warning_status, 0, "INTERNAL ERROR: Input stack botch in peek_input ()")); exit (1); } /* End of input source --- pop one level. */ pop_input (); } }
static int next_char (void) { int ch; int (*f)(void); while (1) { if (isp == NULL) return CHAR_EOF; f = isp->funcs->read_func; if (f != NULL) { while ((ch = (*f)()) != CHAR_RETRY) { /* if (!IS_IGNORE(ch)) */ return ch; } } else { MP4HERROR ((warning_status, 0, "INTERNAL ERROR: Input stack botch in next_char ()")); exit (1); } /* End of input source --- pop one level. */ pop_input (); } }
void input_close(void) { do pop_input (); while (isp); }
void skip_buffer (void) { if (isp == NULL) return; pop_input (); }
int peek_input (void) { register int ch; while (1) { if (isp == NULL) return CHAR_EOF; switch (isp->type) { case INPUT_STRING: ch = isp->u.u_s.string[0]; if (ch != '\0') return ch; break; case INPUT_FILE: ch = getc (isp->u.u_f.file); if (ch != EOF) { ungetc (ch, isp->u.u_f.file); return ch; } break; case INPUT_MACRO: return CHAR_MACRO; default: M4ERROR ((warning_status, 0, "INTERNAL ERROR: Input stack botch in peek_input ()")); abort (); } /* End of input source --- pop one level. */ pop_input (); } }
static int next_char_1 (void) { int ch; while (1) { if (isp == NULL) { current_file = ""; current_line = 0; return CHAR_EOF; } if (input_change) { current_file = isp->file; current_line = isp->line; input_change = false; } switch (isp->type) { case INPUT_STRING: ch = to_uchar (*isp->u.u_s.string++); if (ch != '\0') return ch; break; case INPUT_FILE: if (start_of_input_line) { start_of_input_line = false; current_line = ++isp->line; } /* If stdin is a terminal, calling getc after peek_input already called it would make the user have to hit ^D twice to quit. */ ch = isp->u.u_f.end ? EOF : getc (isp->u.u_f.fp); if (ch != EOF) { if (ch == '\n') start_of_input_line = true; return ch; } break; case INPUT_MACRO: pop_input (); /* INPUT_MACRO input sources has only one token */ return CHAR_MACRO; default: M4ERROR ((warning_status, 0, "INTERNAL ERROR: input stack botch in next_char ()")); abort (); } /* End of input source --- pop one level. */ pop_input (); } }