config: move function normalizing section names into "config.c" The function `git_config_file_normalize_section` is never being used in any file different than "config.c", but it is implemented in "config_file.c". Move it over and make the symbol static.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101
diff --git a/src/config.c b/src/config.c
index 72c1c73..ebff6a2 100644
--- a/src/config.c
+++ b/src/config.c
@@ -1376,6 +1376,30 @@ int git_config_parse_path(git_buf *out, const char *value)
return git_buf_sets(out, value);
}
+static int normalize_section(char *start, char *end)
+{
+ char *scan;
+
+ if (start == end)
+ return GIT_EINVALIDSPEC;
+
+ /* Validate and downcase range */
+ for (scan = start; *scan; ++scan) {
+ if (end && scan >= end)
+ break;
+ if (isalnum(*scan))
+ *scan = (char)git__tolower(*scan);
+ else if (*scan != '-' || scan == start)
+ return GIT_EINVALIDSPEC;
+ }
+
+ if (scan == start)
+ return GIT_EINVALIDSPEC;
+
+ return 0;
+}
+
+
/* Take something the user gave us and make it nice for our hash function */
int git_config__normalize_name(const char *in, char **out)
{
@@ -1393,8 +1417,8 @@ int git_config__normalize_name(const char *in, char **out)
goto invalid;
/* Validate and downcase up to first dot and after last dot */
- if (git_config_file_normalize_section(name, fdot) < 0 ||
- git_config_file_normalize_section(ldot + 1, NULL) < 0)
+ if (normalize_section(name, fdot) < 0 ||
+ normalize_section(ldot + 1, NULL) < 0)
goto invalid;
/* If there is a middle range, make sure it doesn't have newlines */
@@ -1466,8 +1490,7 @@ int git_config_rename_section(
goto cleanup;
if (new_section_name != NULL &&
- (error = git_config_file_normalize_section(
- replace.ptr, strchr(replace.ptr, '.'))) < 0)
+ (error = normalize_section(replace.ptr, strchr(replace.ptr, '.'))) < 0)
{
giterr_set(
GITERR_CONFIG, "invalid config section '%s'", new_section_name);
diff --git a/src/config_file.c b/src/config_file.c
index 26bc200..fb88818 100644
--- a/src/config_file.c
+++ b/src/config_file.c
@@ -107,29 +107,6 @@ static void config_entry_list_free(config_entry_list *list)
};
}
-int git_config_file_normalize_section(char *start, char *end)
-{
- char *scan;
-
- if (start == end)
- return GIT_EINVALIDSPEC;
-
- /* Validate and downcase range */
- for (scan = start; *scan; ++scan) {
- if (end && scan >= end)
- break;
- if (isalnum(*scan))
- *scan = (char)git__tolower(*scan);
- else if (*scan != '-' || scan == start)
- return GIT_EINVALIDSPEC;
- }
-
- if (scan == start)
- return GIT_EINVALIDSPEC;
-
- return 0;
-}
-
static void config_entry_list_append(config_entry_list **list, config_entry_list *entry)
{
if (*list)
diff --git a/src/config_file.h b/src/config_file.h
index 72818e5..6a0984e 100644
--- a/src/config_file.h
+++ b/src/config_file.h
@@ -68,6 +68,4 @@ GIT_INLINE(int) git_config_file_unlock(git_config_backend *cfg, int success)
return cfg->unlock(cfg, success);
}
-extern int git_config_file_normalize_section(char *start, char *end);
-
#endif