move build_varname above parse_section
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
diff --git a/src/config.c b/src/config.c
index 41c4d3a..8ffbf53 100644
--- a/src/config.c
+++ b/src/config.c
@@ -497,6 +497,34 @@ static inline int config_keychar(int c)
return isalnum(c) || c == '-';
}
+/*
+ * Returns $section.$name, using only name_len chars from the name,
+ * which is useful so we don't have to copy the variable name
+ * twice. The name of the variable is set to lowercase.
+ * Don't forget to free the buffer.
+ */
+static char *build_varname(const char *section, const char *name)
+{
+ char *varname;
+ int section_len, ret;
+ int name_len;
+ size_t total_len;
+
+ name_len = strlen(name);
+ section_len = strlen(section);
+ total_len = section_len + name_len + 2;
+ varname = malloc(total_len);
+ if(varname == NULL)
+ return NULL;
+
+ ret = snprintf(varname, total_len, "%s.%s", section, name);
+ if(ret >= 0){
+ strtolower(varname + section_len + 1);
+ }
+
+ return varname;
+}
+
static char *parse_section_header_ext(char *base_name, git_config *cfg)
{
return base_name;
@@ -685,32 +713,6 @@ static int config_parse(git_config *cfg_file)
return error;
}
-/*
- * Returns $section.$name, using only name_len chars from the name,
- * which is useful so we don't have to copy the variable name
- * twice. The name of the variable is set to lowercase.
- *Don't forget to free the buffer.
- */
-static char *build_varname(const char *section, const char *name, int name_len)
-{
- char *varname;
- int section_len, ret;
- size_t total_len;
-
- section_len = strlen(section);
- total_len = section_len + name_len + 2;
- varname = malloc(total_len);
- if(varname == NULL)
- return NULL;
-
- ret = snprintf(varname, total_len, "%s.%s", section, name);
- if(ret >= 0){
- strtolower(varname + section_len + 1);
- }
-
- return varname;
-}
-
static int parse_variable(git_config *cfg, const char *section_name, const char *line)
{
int error = GIT_SUCCESS;