summaryrefslogtreecommitdiff
path: root/builtin/help.c
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2013-01-23 06:27:09 (GMT)
committerJunio C Hamano <gitster@pobox.com>2013-01-23 20:58:33 (GMT)
commit4d5c6cefd5c3e37fdf096c955abe9f9ac5938a53 (patch)
treed9118f6715442b0e41ee049c8a78000f5dcca258 /builtin/help.c
parent6bfe19ee168cd47295e9d25b4343ec318fab3790 (diff)
downloadgit-4d5c6cefd5c3e37fdf096c955abe9f9ac5938a53.zip
git-4d5c6cefd5c3e37fdf096c955abe9f9ac5938a53.tar.gz
git-4d5c6cefd5c3e37fdf096c955abe9f9ac5938a53.tar.bz2
help: use parse_config_key for man config
The resulting code ends up about the same length, but it is a little more self-explanatory. It now explicitly documents and checks the pre-condition that the incoming var starts with "man.", and drops the magic offset "4". Signed-off-by: Jeff King <peff@peff.net> Reviewed-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/help.c')
-rw-r--r--builtin/help.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/builtin/help.c b/builtin/help.c
index bd86253..04cb77d 100644
--- a/builtin/help.c
+++ b/builtin/help.c
@@ -237,21 +237,21 @@ static int add_man_viewer_cmd(const char *name,
static int add_man_viewer_info(const char *var, const char *value)
{
- const char *name = var + 4;
- const char *subkey = strrchr(name, '.');
+ const char *name, *subkey;
+ int namelen;
- if (!subkey)
+ if (parse_config_key(var, "man", &name, &namelen, &subkey) < 0 || !name)
return 0;
- if (!strcmp(subkey, ".path")) {
+ if (!strcmp(subkey, "path")) {
if (!value)
return config_error_nonbool(var);
- return add_man_viewer_path(name, subkey - name, value);
+ return add_man_viewer_path(name, namelen, value);
}
- if (!strcmp(subkey, ".cmd")) {
+ if (!strcmp(subkey, "cmd")) {
if (!value)
return config_error_nonbool(var);
- return add_man_viewer_cmd(name, subkey - name, value);
+ return add_man_viewer_cmd(name, namelen, value);
}
return 0;