help: drop prepend function in favor of xstrfmt
This function predates xstrfmt, and its functionality is a subset. Let's just use xstrfmt. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Jeff King committed
Sep 24, 2015 at 17:07 UTC
acd47eec992160d76d5d4a2e98940de3fdc10552
1 file changed
+2
-12
builtin/help.c
+2
-12
@@ -295,16 +295,6 @@ static int is_git_command(const char *s)
295
is_in_cmdlist(&other_cmds, s);
296
}
297
298
-static const char *prepend(const char *prefix, const char *cmd)
299
-{
300
- size_t pre_len = strlen(prefix);
301
- size_t cmd_len = strlen(cmd);
302
- char *p = xmalloc(pre_len + cmd_len + 1);
303
- memcpy(p, prefix, pre_len);
304
- strcpy(p + pre_len, cmd);
305
- return p;
306
-}
307
-
298
static const char *cmd_to_page(const char *git_cmd)
299
{
300
if (!git_cmd)
@@ -312,9 +302,9 @@ static const char *cmd_to_page(const char *git_cmd)
302
else if (starts_with(git_cmd, "git"))
303
return git_cmd;
304
else if (is_git_command(git_cmd))
315
- return prepend("git-", git_cmd);
305
+ return xstrfmt("git-%s", git_cmd);
306
else
317
- return prepend("git", git_cmd);
307
+ return xstrfmt("git%s", git_cmd);
308
}
309
310
static void setup_man_path(void)