Implement -dM preprocessor option as in gcc

There was already support for -dD option but in contrast -dM dumps only `#define` directives w/o actual preprocessor output.

The original -dD output differs from gcc output by additional comment in front of `#define`s so this quirk is left for -dM as well.
This commit is contained in:
Vlad Vissoultchev
2016-04-06 18:57:11 +03:00
parent 0691b7630b
commit e946eb2a41
4 changed files with 14 additions and 8 deletions

View File

@ -1225,6 +1225,8 @@ LIBTCCAPI void tcc_delete(TCCState *s1)
/* close a preprocessor output */
if (s1->ppfp && s1->ppfp != stdout)
fclose(s1->ppfp);
if (s1->dffp && s1->dffp != s1->ppfp)
fclose(s1->dffp);
/* free all sections */
for(i = 1; i < s1->nb_sections; i++)
@ -2175,8 +2177,8 @@ PUB_FUNC int tcc_parse_args(TCCState *s, int argc, char **argv)
s->output_type = TCC_OUTPUT_OBJ;
break;
case TCC_OPTION_d:
if (*optarg == 'D')
s->dflag = 1;
if (*optarg == 'D' || *optarg == 'M')
s->dflag = *optarg;
else {
if (s->warn_unsupported)
goto unsupported_option;