summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJérémie Courrèges-Anglas <jca@wxcvbn.org>2014-03-04 02:52:49 +0100
committerJérémie Courrèges-Anglas <jca@wxcvbn.org>2014-03-04 02:52:49 +0100
commitef423da9227bd6f360a16e1e6c8396d588d67cab (patch)
tree57ab4aff194c47ed80c87199134ec6d79aab04f1 /src
parent05525bcff126d698d3e9f18cb4df97c6fe528237 (diff)
downloadratpoison-ef423da9227bd6f360a16e1e6c8396d588d67cab.zip
Simplify read_shellcmd using sbuf
Diffstat (limited to 'src')
-rw-r--r--src/actions.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/actions.c b/src/actions.c
index a378a0f..e2e0044 100644
--- a/src/actions.c
+++ b/src/actions.c
@@ -1762,10 +1762,12 @@ read_shellcmd (struct argspec *spec, struct sbuf *s, struct cmdarg **arg, const
ret = read_string (spec, s, hist_SHELLCMD, exec_completions, arg);
if (command_name && !s && !ret) {
/* store for command history */
- char *str = xmalloc (strlen(command_name) + strlen((*arg)->string) + 2);
- sprintf (str, "%s %s", command_name, (*arg)->string);
- history_add (hist_COMMAND, str);
- free(str);
+ struct sbuf *buf;
+
+ buf = sbuf_new (0);
+ sbuf_printf (buf, "%s %s", command_name, (*arg)->string);
+ history_add (hist_COMMAND, sbuf_get (buf));
+ sbuf_free (buf);
}
return ret;
}