@@ -531,11 +531,6 @@ void git_config_push_env(const char *spec)
free(key);
}
-static inline int iskeychar(int c)
-{
- return isalnum(c) || c == '-';
-}
-
/*
* Auxiliary function to sanity-check and split the key into the section
* identifier and variable name.
@@ -585,7 +580,7 @@ int git_config_parse_key(const char *key, char **store_key, size_t *baselen_)
dot = 1;
/* Leave the extended basename untouched.. */
if (!dot || i > baselen) {
- if (!iskeychar(c) ||
+ if (!is_config_key_char(c) ||
(i == baselen + 1 && !isalpha(c))) {
error(_("invalid key: %s"), key);
goto out_free_ret_1;
@@ -906,7 +901,7 @@ static int get_value(struct config_source *cs, struct key_value_info *kvi,
c = get_next_char(cs);
if (cs->eof)
break;
- if (!iskeychar(c))
+ if (!is_config_key_char(c))
break;
strbuf_addch(name, tolower(c));
}
@@ -984,7 +979,7 @@ static int get_base_var(struct config_source *cs, struct strbuf *name)
return 0;
if (isspace(c))
return get_extended_base_var(cs, name, c);
- if (!iskeychar(c) && c != '.')
+ if (!is_config_key_char(c) && c != '.')
return -1;
strbuf_addch(name, tolower(c));
}
@@ -340,6 +340,15 @@ int repo_config_set_worktree_gently(struct repository *, const char *, const cha
*/
void repo_config_set(struct repository *, const char *, const char *);
+/**
+ * Is this char a valid char for the section or variable name part of
+ * a config key?
+ */
+static inline int is_config_key_char(int c)
+{
+ return isalnum(c) || c == '-';
+}
+
int git_config_parse_key(const char *, char **, size_t *);
/*
The iskeychar() function in "config.c" checks if a character is valid for the section or variable name part of a config key. In a follow up commit we will want to check outside "config.c" if a string can be a valid variable name of a config key, so will will want to reuse that fonction. Let's then move it from "config.c" to "config.h", and, while at it, let's rename it to is_config_key_char(). Signed-off-by: Christian Couder <chriscool@tuxfamily.org> --- config.c | 11 +++-------- config.h | 9 +++++++++ 2 files changed, 12 insertions(+), 8 deletions(-)