diff options
Diffstat (limited to 'm4/builtin.c')
-rw-r--r-- | m4/builtin.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/m4/builtin.c b/m4/builtin.c index 7f9d9578..5228abc7 100644 --- a/m4/builtin.c +++ b/m4/builtin.c @@ -85,3 +85,35 @@ m4_builtin_find_by_func (m4_module *module, m4_builtin_func *func) return 0; } + +/* Print a representation of FUNC to OBS, optionally including the + MODULE it came from. If FLATTEN, output QUOTES around an empty + string instead. */ +void +m4_builtin_print (m4_obstack *obs, const m4_builtin *func, bool flatten, + const m4_string_pair *quotes, m4_module *module) +{ + assert (func); + if (flatten) + { + if (quotes) + { + obstack_grow (obs, quotes->str1, quotes->len1); + obstack_grow (obs, quotes->str2, quotes->len2); + } + module = NULL; + } + else + { + obstack_1grow (obs, '<'); + obstack_grow (obs, func->name, strlen (func->name)); + obstack_1grow (obs, '>'); + } + if (module) + { + const char *text = m4_get_module_name (module); + obstack_1grow (obs, '{'); + obstack_grow (obs, text, strlen (text)); + obstack_1grow (obs, '}'); + } +} |