* FYI: reformat apropos_command
@ 2011-01-17 16:50 Tom Tromey
0 siblings, 0 replies; only message in thread
From: Tom Tromey @ 2011-01-17 16:50 UTC (permalink / raw)
To: gdb-patches
I am checking this in.
While working elsewhere I noticed that apropos_command is formatted
incorrectly, and also that it leaks memory.
This patch fixes the formatting and removes a bogus (AFAICT) call to
re_compile_fastmap. The next patch will fix the leak and some other
issues.
Built and regtested on x86-64 (compile farm).
Tom
2011-01-17 Tom Tromey <tromey@redhat.com>
* cli/cli-cmds.c (apropos_command): Fix formatting. Don't call
re_compile_fastmap.
diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c
index ae02031..e1d8174 100644
--- a/gdb/cli/cli-cmds.c
+++ b/gdb/cli/cli-cmds.c
@@ -1253,28 +1253,20 @@ show_user (char *args, int from_tty)
void
apropos_command (char *searchstr, int from_tty)
{
- extern struct cmd_list_element *cmdlist; /* This is the main command
- list. */
regex_t pattern;
- char *pattern_fastmap;
char errorbuffer[512];
- pattern_fastmap = xcalloc (256, sizeof (char));
if (searchstr == NULL)
- error (_("REGEXP string is empty"));
+ error (_("REGEXP string is empty"));
- if (regcomp(&pattern,searchstr,REG_ICASE) == 0)
- {
- pattern.fastmap=pattern_fastmap;
- re_compile_fastmap(&pattern);
- apropos_cmd (gdb_stdout,cmdlist,&pattern,"");
- }
+ if (regcomp (&pattern, searchstr, REG_ICASE) == 0)
+ apropos_cmd (gdb_stdout, cmdlist, &pattern, "");
else
{
- regerror(regcomp(&pattern,searchstr,REG_ICASE),NULL,errorbuffer,512);
- error (_("Error in regular expression:%s"),errorbuffer);
+ regerror (regcomp (&pattern, searchstr, REG_ICASE), NULL,
+ errorbuffer, 512);
+ error (_("Error in regular expression: %s"), errorbuffer);
}
- xfree (pattern_fastmap);
}
\f
/* Print a list of files and line numbers which a user may choose from
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2011-01-17 16:20 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-01-17 16:50 FYI: reformat apropos_command Tom Tromey
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).