Commit 26faa366 by Carlos Martín Nieto

Add build_varname to make a full var name

Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
parent e15afc8e
......@@ -463,10 +463,25 @@ static int config_parse(git_config *cfg_file)
return error;
}
static const char *build_varname(const char *section, const char *name, int len)
{
static char varname[1024]; /* TODO: What's the longest we should allow? */
if(strlen(section) + len + 2 > sizeof(varname))
return NULL;
strcpy(varname, section);
strcat(varname, ".");
strncat(varname, name, len);
return varname;
}
static int parse_variable(git_config *cfg, const char *section_name, const char *line)
{
int error;
int has_value = 1;
const char *varname;
const char *var_end = NULL;
const char *value_start = NULL;
......@@ -492,6 +507,8 @@ static int parse_variable(git_config *cfg, const char *section_name, const char
goto error;
}
varname = build_varname(section_name, line, var_end - line + 1);
return GIT_SUCCESS;
error:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment