Mercurial > ~dholland > hg > tradcpp > index.cgi
diff macro.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 | 5922e6ca6b80 |
children | 09cfad6772de |
line wrap: on
line diff
--- a/macro.c Fri Jun 12 02:05:29 2015 -0400 +++ b/macro.c Fri Jun 12 02:14:45 2015 -0400 @@ -602,30 +602,6 @@ } void -macro_define_file(struct place *p) -{ - struct macro *m; - struct expansionitem *ei; - - m = macro_define_common_start(p, "__FILE__", p); - ei = expansionitem_create_file(); - expansionitemarray_add(&m->expansion, ei, NULL); - macro_define_common_end(m); -} - -void -macro_define_line(struct place *p) -{ - struct macro *m; - struct expansionitem *ei; - - m = macro_define_common_start(p, "__LINE__", p); - ei = expansionitem_create_line(); - expansionitemarray_add(&m->expansion, ei, NULL); - macro_define_common_end(m); -} - -void macro_define_params(struct place *p1, const char *macro, struct place *p2, const char *params, struct place *p3, const char *expansion) @@ -640,6 +616,24 @@ } void +macro_define_magic(struct place *p, const char *macro) +{ + struct macro *m; + struct expansionitem *ei; + + m = macro_define_common_start(p, macro, p); + if (!strcmp(macro, "__FILE__")) { + ei = expansionitem_create_file(); + } + else { + assert(!strcmp(macro, "__LINE__")); + ei = expansionitem_create_line(); + } + expansionitemarray_add(&m->expansion, ei, NULL); + macro_define_common_end(m); +} + +void macro_undef(const char *macro) { struct macro *m;