diff options
author | Tom Tromey <tromey@redhat.com> | 2011-01-17 16:50:42 +0000 |
---|---|---|
committer | Tom Tromey <tromey@redhat.com> | 2011-01-17 16:50:42 +0000 |
commit | dc92e16124ca764e536f2457635749e5431c4765 (patch) | |
tree | 4435d0e6b715c61188acf0aea2a92112a44515f2 /gdb/cli/cli-cmds.c | |
parent | da17376b704177fc4d8fa038169782e28b1f3b24 (diff) | |
download | gdb-dc92e16124ca764e536f2457635749e5431c4765.zip gdb-dc92e16124ca764e536f2457635749e5431c4765.tar.gz gdb-dc92e16124ca764e536f2457635749e5431c4765.tar.bz2 |
* cli/cli-cmds.c (apropos_command): Free the compiled regex. Use
get_regcomp_error.
* utils.c: Include gdb_regex.h.
(do_regfree_cleanup): New function.
(make_regfree_cleanup): Likewise.
(get_regcomp_error): Likewise.
* gdb_regex.h (make_regfree_cleanup, get_regcomp_error): Declare.
Diffstat (limited to 'gdb/cli/cli-cmds.c')
-rw-r--r-- | gdb/cli/cli-cmds.c | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c index e1d8174..c11b257 100644 --- a/gdb/cli/cli-cmds.c +++ b/gdb/cli/cli-cmds.c @@ -1254,18 +1254,26 @@ void apropos_command (char *searchstr, int from_tty) { regex_t pattern; - char errorbuffer[512]; + int code; if (searchstr == NULL) error (_("REGEXP string is empty")); - if (regcomp (&pattern, searchstr, REG_ICASE) == 0) - apropos_cmd (gdb_stdout, cmdlist, &pattern, ""); + code = regcomp (&pattern, searchstr, REG_ICASE); + if (code == 0) + { + struct cleanup *cleanups; + + cleanups = make_regfree_cleanup (&pattern); + apropos_cmd (gdb_stdout, cmdlist, &pattern, ""); + do_cleanups (cleanups); + } else { - regerror (regcomp (&pattern, searchstr, REG_ICASE), NULL, - errorbuffer, 512); - error (_("Error in regular expression: %s"), errorbuffer); + char *err = get_regcomp_error (code, &pattern); + + make_cleanup (xfree, err); + error (_("Error in regular expression: %s"), err); } } |