diff options
Diffstat (limited to 'gcc/cppmain.c')
-rw-r--r-- | gcc/cppmain.c | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/gcc/cppmain.c b/gcc/cppmain.c index 0edc3d2..7ebc1ad 100644 --- a/gcc/cppmain.c +++ b/gcc/cppmain.c @@ -43,7 +43,7 @@ static void setup_callbacks PARAMS ((cpp_reader *)); /* General output routines. */ static void scan_translation_unit PARAMS ((cpp_reader *)); static void scan_translation_unit_trad PARAMS ((cpp_reader *)); -static void check_multiline_token PARAMS ((const cpp_string *)); +static void account_for_newlines PARAMS ((const uchar *, size_t)); static int dump_macro PARAMS ((cpp_reader *, cpp_hashnode *, void *)); static void print_line PARAMS ((const struct line_map *, unsigned int, @@ -208,19 +208,18 @@ scan_translation_unit (pfile) cpp_output_token (token, print.outf); if (token->type == CPP_COMMENT) - check_multiline_token (&token->val.str); + account_for_newlines (token->val.str.text, token->val.str.len); } } -/* Adjust print.line for newlines embedded in tokens. */ +/* Adjust print.line for newlines embedded in output. */ static void -check_multiline_token (str) - const cpp_string *str; +account_for_newlines (str, len) + const uchar *str; + size_t len; { - unsigned int i; - - for (i = 0; i < str->len; i++) - if (str->text[i] == '\n') + while (len--) + if (*str++ == '\n') print.line++; } @@ -239,6 +238,8 @@ scan_translation_unit_trad (pfile) maybe_print_line (print.map, pfile->out.first_line); fwrite (pfile->out.base, 1, len, print.outf); print.printed = 1; + if (!CPP_OPTION (pfile, discard_comments)) + account_for_newlines (pfile->out.base, len); } } |