diff options
| author | seyko <seyko2@gmail.com> | 2015-04-27 16:04:54 +0300 |
|---|---|---|
| committer | seyko <seyko2@gmail.com> | 2015-04-27 16:04:54 +0300 |
| commit | 1351de6ad1bf59630026d86db5b6a94c109d6816 (patch) | |
| tree | c3c42fb39391360b1594f34db3ada819ef23db2f | |
| parent | 2df290073b04de51b699e58dde943afaeb0757dc (diff) | |
| download | tinycc-1351de6ad1bf59630026d86db5b6a94c109d6816.tar.gz tinycc-1351de6ad1bf59630026d86db5b6a94c109d6816.tar.bz2 | |
fixes for "tcc -E -dD"
* print "// #pragma push_macro(XXX)"
* keep output line numbers in sync with source
(don't output \n in printf)
| -rw-r--r-- | tccpp.c | 18 |
1 files changed, 16 insertions, 2 deletions
@@ -1060,7 +1060,7 @@ static void define_print(Sym *s, int is_undef) } if (is_undef) { - fprintf(tcc_state->ppfp, "// #undef %s\n", get_tok_str(s->v, NULL)); + fprintf(tcc_state->ppfp, "// #undef %s", get_tok_str(s->v, NULL)); return; } @@ -1086,7 +1086,6 @@ static void define_print(Sym *s, int is_undef) break; fprintf(tcc_state->ppfp, "%s", get_tok_str(t, &cval)); } - fprintf(tcc_state->ppfp, "\n"); } /* defines handling */ @@ -1468,6 +1467,21 @@ static void pragma_parse(TCCState *s1) table_ident[v - TOK_IDENT]->sym_define = s->d ? s : NULL; else tcc_warning("unbalanced #pragma pop_macro"); + + /* print info when tcc is called with "-E -dD" switches */ + if (s1->dflag && s1->ppfp) { + if (file) { + int c = file->line_num - file->line_ref - 1; + if (c > 0) { + while (c--) + fputs("\n", tcc_state->ppfp); + file->line_ref = file->line_num; + } + } + fprintf(s1->ppfp, "// #pragma %s_macro(\"%s\")", + (t == TOK_push_macro) ? "push" : "pop", + get_tok_str(v, NULL)); + } } else if (tok == TOK_once) { add_cached_include(s1, file->filename, TOK_once); } else { |
