Mercurial > ~dholland > hg > tradcpp > index.cgi
diff main.c @ 172:3e7e696fe558
Clean up the mess Joerg made of apply_builtin_macros().
author | David A. Holland |
---|---|
date | Fri, 12 Jun 2015 02:14:45 -0400 |
parents | 8cef6d7227a8 |
children | 44ea61019069 |
line wrap: on
line diff
--- a/main.c Fri Jun 12 02:05:29 2015 -0400 +++ b/main.c Fri Jun 12 02:14:45 2015 -0400 @@ -195,14 +195,12 @@ static void -apply_special_macros(unsigned *builtin_counter) +apply_magic_macro(unsigned num, const char *name) { struct place p; - place_setbuiltin(&p, ++(*builtin_counter)); - macro_define_file(&p); - place_setbuiltin(&p, ++(*builtin_counter)); - macro_define_line(&p); + place_setbuiltin(&p, num); + macro_define_magic(&p, name); } static @@ -217,35 +215,38 @@ static void -apply_builtin_macros(unsigned *builtin_counter) +apply_builtin_macros(void) { + unsigned n = 1; + + apply_magic_macro(n++, "__FILE__"); + apply_magic_macro(n++, "__LINE__"); + #ifdef CONFIG_OS - apply_builtin_macro(++(*builtin_counter), CONFIG_OS, "1"); + apply_builtin_macro(n++, CONFIG_OS, "1"); #endif #ifdef CONFIG_OS_2 - apply_builtin_macro(++(*builtin_counter), CONFIG_OS_2, "1"); + apply_builtin_macro(n++, CONFIG_OS_2, "1"); #endif #ifdef CONFIG_CPU - apply_builtin_macro(++(*builtin_counter), CONFIG_CPU, "1"); + apply_builtin_macro(n++, CONFIG_CPU, "1"); #endif #ifdef CONFIG_CPU_2 - apply_builtin_macro(++(*builtin_counter), CONFIG_CPU_2, "1"); + apply_builtin_macro(n++, CONFIG_CPU_2, "1"); #endif #ifdef CONFIG_SIZE - apply_builtin_macro(++(*builtin_counter), CONFIG_SIZE, "1"); + apply_builtin_macro(n++, CONFIG_SIZE, "1"); #endif #ifdef CONFIG_BINFMT - apply_builtin_macro(++(*builtin_counter), CONFIG_BINFMT, "1"); + apply_builtin_macro(n++, CONFIG_BINFMT, "1"); #endif #ifdef CONFIG_COMPILER - apply_builtin_macro(++(*builtin_counter), CONFIG_COMPILER, - VERSION_MAJOR); - apply_builtin_macro(++(*builtin_counter), CONFIG_COMPILER_MINOR, - VERSION_MINOR); - apply_builtin_macro(++(*builtin_counter), "__VERSION__", VERSION_LONG); + apply_builtin_macro(n++, CONFIG_COMPILER, VERSION_MAJOR); + apply_builtin_macro(n++, CONFIG_COMPILER_MINOR, VERSION_MINOR); + apply_builtin_macro(n++, "__VERSION__", VERSION_LONG); #endif } @@ -1043,7 +1044,6 @@ const char *inputfile = NULL; const char *outputfile = NULL; struct place cmdplace; - unsigned builtin_counter; int i; progname = strrchr(argv[0], '/'); @@ -1089,11 +1089,7 @@ mode.output_file = outputfile; loadincludepath(); - - builtin_counter = 0; - apply_special_macros(&builtin_counter); - apply_builtin_macros(&builtin_counter); - + apply_builtin_macros(); apply_commandline_macros(); read_commandline_files(); place_setnowhere(&cmdplace);