pp_input_t *parent;
};
-pp_input_t input;
+static pp_input_t input;
#define CC input.c
static pp_input_t *input_stack;
static pp_conditional_t *conditional_stack;
-token_t pp_token;
+static token_t pp_token;
static bool resolve_escape_sequences = false;
static bool do_print_spaces = true;
static bool do_expansions;
input.bufpos = NULL;
input.had_non_space = false;
input.position.input_name = filename;
- input.position.linenr = 1;
+ input.position.lineno = 1;
/* indicate that we're at a new input */
print_line_directive(&input.position, input_stack != NULL ? "1" : NULL);
if(CC == '\n') { \
next_char(); \
} \
- ++input.position.linenr; \
+ ++input.position.lineno; \
code \
case '\n': \
next_char(); \
- ++input.position.linenr; \
+ ++input.position.lineno; \
code
-#define eat(c_type) do { assert(CC == c_type); next_char(); } while(0)
+#define eat(c_type) (assert(CC == c_type), next_char())
static void maybe_concat_lines(void)
{
static void parse_string_literal(void)
{
- const unsigned start_linenr = input.position.linenr;
+ const unsigned start_linenr = input.position.lineno;
eat('"');
case EOF: {
source_position_t source_position;
source_position.input_name = pp_token.source_position.input_name;
- source_position.linenr = start_linenr;
+ source_position.lineno = start_linenr;
errorf(&source_position, "string has no end");
pp_token.type = TP_ERROR;
return;
static void parse_character_constant(void)
{
- const unsigned start_linenr = input.position.linenr;
+ const unsigned start_linenr = input.position.lineno;
eat('\'');
case EOF: {
source_position_t source_position;
source_position.input_name = pp_token.source_position.input_name;
- source_position.linenr = start_linenr;
+ source_position.lineno = start_linenr;
errorf(&source_position, "EOF while parsing character constant");
pp_token.type = TP_ERROR;
return;
if(do_print_spaces)
counted_spaces++;
- unsigned start_linenr = input.position.linenr;
+ unsigned start_linenr = input.position.lineno;
while(1) {
switch(CC) {
case '/':
case EOF: {
source_position_t source_position;
source_position.input_name = pp_token.source_position.input_name;
- source_position.linenr = start_linenr;
+ source_position.lineno = start_linenr;
errorf(&source_position, "at end of file while looking for comment end");
return;
}
if(CC == '\n') {
next_char();
}
- ++input.position.linenr;
+ ++input.position.lineno;
if (do_print_spaces)
++counted_newlines;
continue;
return;
next_char();
- ++input.position.linenr;
+ ++input.position.lineno;
if (do_print_spaces)
++counted_newlines;
continue;
#define ELSE_CODE(code) \
default: \
- code; \
+ code \
+ return; \
} \
} /* end of while(1) */ \
- break;
#define ELSE(set_type) \
ELSE_CODE( \
pp_token.type = set_type; \
- return; \
)
static void next_preprocessing_token(void)
put_back(CC);
CC = '.';
pp_token.type = '.';
- return;
)
ELSE('.')
case '&':
put_back(CC);
CC = '%';
pp_token.type = '#';
- return;
)
ELSE('#')
ELSE('%')
case '\?': fputs("\\?", out); break;
default:
if(!isprint(*c)) {
- fprintf(out, "\\%03o", *c);
+ fprintf(out, "\\%03o", (unsigned)*c);
break;
}
fputc(*c, out);
static void print_line_directive(const source_position_t *pos, const char *add)
{
- fprintf(out, "# %u ", pos->linenr);
+ fprintf(out, "# %u ", pos->lineno);
print_quoted_string(pos->input_name);
if (add != NULL) {
fputc(' ', out);
pp_definition_t *old_definition = symbol->pp_definition;
if (old_definition != NULL) {
if (!pp_definitions_equal(old_definition, new_definition)) {
- warningf(&input.position, "multiple definition of macro '%Y' (first defined %P)",
- symbol, &old_definition->source_position);
+ warningf(WARN_OTHER, &input.position, "multiple definition of macro '%Y' (first defined %P)", symbol, &old_definition->source_position);
} else {
/* reuse the old definition */
obstack_free(&pp_obstack, new_definition);
next_preprocessing_token();
if(pp_token.type != '\n') {
- warningf(&input.position, "extra tokens at end of #undef directive");
+ warningf(WARN_OTHER, &input.position, "extra tokens at end of #undef directive");
}
/* eat until '\n' */
eat_pp_directive();
}
if (pp_token.type != '\n' && pp_token.type != TP_EOF) {
- warningf(&pp_token.source_position,
- "extra tokens at end of #include directive");
+ warningf(WARN_OTHER, &pp_token.source_position, "extra tokens at end of #include directive");
eat_pp_directive();
}
if (pp_token.type != '\n') {
if (!skip_mode) {
- warningf(&pp_token.source_position, "extra tokens at end of #else");
+ warningf(WARN_OTHER, &pp_token.source_position, "extra tokens at end of #else");
}
eat_pp_directive();
}
if (pp_token.type != '\n') {
if (!skip_mode) {
- warningf(&pp_token.source_position,
- "extra tokens at end of #endif");
+ warningf(WARN_OTHER, &pp_token.source_position, "extra tokens at end of #endif");
}
eat_pp_directive();
}