diff options
author | Tom Tromey <tromey@redhat.com> | 2008-09-27 21:40:49 +0000 |
---|---|---|
committer | Tom Tromey <tromey@redhat.com> | 2008-09-27 21:40:49 +0000 |
commit | 2fae03e85bab97b883120cf0f5dbaacad2dd141f (patch) | |
tree | b20a29c9e4d8df98c7d4472fc190e308a568f6fd /gdb/macrocmd.c | |
parent | 5c6ce71d76dc5618b6ebfc967e5c4b99d701ef50 (diff) | |
download | gdb-2fae03e85bab97b883120cf0f5dbaacad2dd141f.zip gdb-2fae03e85bab97b883120cf0f5dbaacad2dd141f.tar.gz gdb-2fae03e85bab97b883120cf0f5dbaacad2dd141f.tar.bz2 |
gdb
* NEWS: Update.
* macrocmd.c (extract_identifier): Add is_parameter argument.
(macro_define_command): Update.
(macro_undef_command): Likewise.
* macroexp.c (stringify): New function.
(find_parameter): Likewise.
(gather_arguments): Add nargs argument. Handle varargs.
(substitute_args): Add is_varargs and va_arg_name arguments.
Handle varargs, splicing, stringification. Use find_parameter.
(expand): Handle varargs.
gdb/doc
* gdb.texinfo (Macros): Remove text about stringification,
varargs, and splicing.
gdb/testsuite
* gdb.base/macscp.exp: Add tests for stringification, splicing,
and varargs.
Diffstat (limited to 'gdb/macrocmd.c')
-rw-r--r-- | gdb/macrocmd.c | 39 |
1 files changed, 29 insertions, 10 deletions
diff --git a/gdb/macrocmd.c b/gdb/macrocmd.c index 8213c0d..c9ab440 100644 --- a/gdb/macrocmd.c +++ b/gdb/macrocmd.c @@ -197,18 +197,37 @@ skip_ws (char **expp) ++*expp; } +/* Try to find the bounds of an identifier. If an identifier is + found, returns a newly allocated string; otherwise returns NULL. + EXPP is a pointer to an input string; it is updated to point to the + text following the identifier. If IS_PARAMETER is true, this + function will also allow "..." forms as used in varargs macro + parameters. */ + static char * -extract_identifier (char **expp) +extract_identifier (char **expp, int is_parameter) { char *result; char *p = *expp; unsigned int len; - if (! *p || ! macro_is_identifier_nondigit (*p)) - return NULL; - for (++p; - *p && (macro_is_identifier_nondigit (*p) || macro_is_digit (*p)); - ++p) - ; + + if (is_parameter && !strncmp (p, "...", 3)) + { + /* Ok. */ + } + else + { + if (! *p || ! macro_is_identifier_nondigit (*p)) + return NULL; + for (++p; + *p && (macro_is_identifier_nondigit (*p) || macro_is_digit (*p)); + ++p) + ; + } + + if (is_parameter && !strncmp (p, "...", 3)) + p += 3; + len = p - *expp; result = (char *) xmalloc (len + 1); memcpy (result, *expp, len); @@ -246,7 +265,7 @@ macro_define_command (char *exp, int from_tty) memset (&new_macro, 0, sizeof (struct macro_definition)); skip_ws (&exp); - name = extract_identifier (&exp); + name = extract_identifier (&exp, 0); if (! name) error (_("Invalid macro name.")); if (*exp == '(') @@ -274,7 +293,7 @@ macro_define_command (char *exp, int from_tty) /* Must update new_macro as well... */ new_macro.argv = (const char * const *) argv; } - argv[new_macro.argc] = extract_identifier (&exp); + argv[new_macro.argc] = extract_identifier (&exp, 1); if (! argv[new_macro.argc]) error (_("Macro is missing an argument.")); ++new_macro.argc; @@ -317,7 +336,7 @@ macro_undef_command (char *exp, int from_tty) error (_("usage: macro undef NAME")); skip_ws (&exp); - name = extract_identifier (&exp); + name = extract_identifier (&exp, 0); if (! name) error (_("Invalid macro name.")); macro_undef (macro_main (macro_user_macros), -1, name); |