const struct line_map *map; /* Logical to physical line mappings. */
const cpp_token *prev; /* Previous token. */
const cpp_token *source; /* Source token for spacing. */
- unsigned int line; /* Line currently being written. */
+ fileline line; /* Line currently being written. */
unsigned char printed; /* Nonzero if something output at line. */
} print;
static void account_for_newlines (const unsigned char *, size_t);
static int dump_macro (cpp_reader *, cpp_hashnode *, void *);
-static void print_line (const struct line_map *, unsigned int,
- const char *);
-static void maybe_print_line (const struct line_map *, unsigned int);
+static void print_line (const struct line_map *, fileline, const char *);
+static void maybe_print_line (const struct line_map *, fileline);
/* Callback routines for the parser. Most of these are active only
in specific modes. */
static void cb_line_change (cpp_reader *, const cpp_token *, int);
-static void cb_define (cpp_reader *, unsigned int, cpp_hashnode *);
-static void cb_undef (cpp_reader *, unsigned int, cpp_hashnode *);
-static void cb_include (cpp_reader *, unsigned int, const unsigned char *,
+static void cb_define (cpp_reader *, fileline, cpp_hashnode *);
+static void cb_undef (cpp_reader *, fileline, cpp_hashnode *);
+static void cb_include (cpp_reader *, fileline, const unsigned char *,
const char *, int);
-static void cb_ident (cpp_reader *, unsigned int, const cpp_string *);
-static void cb_def_pragma (cpp_reader *, unsigned int);
+static void cb_ident (cpp_reader *, fileline, const cpp_string *);
+static void cb_def_pragma (cpp_reader *, fileline);
/* Preprocess and output. */
void
/* Initialize the print structure. Setting print.line to -1 here is
a trick to guarantee that the first token of the file will cause
a linemarker to be output by maybe_print_line. */
- print.line = (unsigned int) -1;
+ print.line = (fileline) -1;
print.printed = 0;
print.prev = 0;
print.map = 0;
different line to the current one, output the required newlines or
a line marker, and return 1. Otherwise return 0. */
static void
-maybe_print_line (const struct line_map *map, unsigned int line)
+maybe_print_line (const struct line_map *map, fileline line)
{
/* End the previous line of text. */
if (print.printed)
/* Output a line marker for logical line LINE. Special flags are "1"
or "2" indicating entering or leaving a file. */
static void
-print_line (const struct line_map *map, unsigned int line, const char *special_flags)
+print_line (const struct line_map *map, fileline line, const char *special_flags)
{
/* End any previous line of text. */
if (print.printed)
of the line, and at end of file will be CPP_EOF. */
static void
cb_line_change (cpp_reader *pfile, const cpp_token *token,
- int parsing_args ATTRIBUTE_UNUSED)
+ int parsing_args)
{
- if (token->type == CPP_EOF)
+ if (token->type == CPP_EOF || parsing_args)
return;
maybe_print_line (print.map, token->line);
}
static void
-cb_ident (cpp_reader *pfile ATTRIBUTE_UNUSED, unsigned int line,
+cb_ident (cpp_reader *pfile ATTRIBUTE_UNUSED, fileline line,
const cpp_string *str)
{
maybe_print_line (print.map, line);
}
static void
-cb_define (cpp_reader *pfile, unsigned int line, cpp_hashnode *node)
+cb_define (cpp_reader *pfile, fileline line, cpp_hashnode *node)
{
maybe_print_line (print.map, line);
fputs ("#define ", print.outf);
}
static void
-cb_undef (cpp_reader *pfile ATTRIBUTE_UNUSED, unsigned int line,
+cb_undef (cpp_reader *pfile ATTRIBUTE_UNUSED, fileline line,
cpp_hashnode *node)
{
maybe_print_line (print.map, line);
}
static void
-cb_include (cpp_reader *pfile ATTRIBUTE_UNUSED, unsigned int line,
+cb_include (cpp_reader *pfile ATTRIBUTE_UNUSED, fileline line,
const unsigned char *dir, const char *header, int angle_brackets)
{
maybe_print_line (print.map, line);
if (flag_no_line_commands || flag_no_output)
return;
- /* First time? */
- if (print.map == NULL)
+ if (map != NULL)
{
- /* Avoid printing foo.i when the main file is foo.c. */
- if (!cpp_get_options (parse_in)->preprocessed)
- print_line (map, map->from_line, flags);
- }
- else
- {
- /* Bring current file to correct line when entering a new file. */
- if (map->reason == LC_ENTER)
- maybe_print_line (map - 1, map->from_line - 1);
-
- if (map->reason == LC_ENTER)
- flags = " 1";
- else if (map->reason == LC_LEAVE)
- flags = " 2";
- print_line (map, map->from_line, flags);
+ /* First time? */
+ if (print.map == NULL)
+ {
+ /* Avoid printing foo.i when the main file is foo.c. */
+ if (!cpp_get_options (parse_in)->preprocessed)
+ print_line (map, map->from_line, flags);
+ }
+ else
+ {
+ /* Bring current file to correct line when entering a new file. */
+ if (map->reason == LC_ENTER)
+ maybe_print_line (map - 1, map->from_line - 1);
+
+ if (map->reason == LC_ENTER)
+ flags = " 1";
+ else if (map->reason == LC_LEAVE)
+ flags = " 2";
+ print_line (map, map->from_line, flags);
+ }
}
print.map = map;
/* Copy a #pragma directive to the preprocessed output. */
static void
-cb_def_pragma (cpp_reader *pfile, unsigned int line)
+cb_def_pragma (cpp_reader *pfile, fileline line)
{
maybe_print_line (print.map, line);
fputs ("#pragma ", print.outf);