Commit 128d3731 by Vicent Marti

config_file: Fix compilation

parent 6adcb5f3
...@@ -136,9 +136,6 @@ typedef struct git_config git_config; ...@@ -136,9 +136,6 @@ typedef struct git_config git_config;
/** A specific implementation of a config backend */ /** A specific implementation of a config backend */
typedef struct git_config_backend git_config_backend; typedef struct git_config_backend git_config_backend;
/** Memory representation of a config variable */
typedef struct git_cvar git_cvar;
/** Time in a signature */ /** Time in a signature */
typedef struct git_time { typedef struct git_time {
git_time_t time; /** time in seconds from epoch */ git_time_t time; /** time in seconds from epoch */
......
...@@ -31,17 +31,17 @@ ...@@ -31,17 +31,17 @@
#include <ctype.h> #include <ctype.h>
struct git_cvar { typedef struct cvar_t {
git_cvar *next; struct cvar_t *next;
char *section; char *section;
char *name; char *name;
char *value; char *value;
}; } cvar_t;
typedef struct { typedef struct {
git_cvar *head; struct cvar_t *head;
git_cvar *tail; struct cvar_t *tail;
} git_cvar_list; } cvar_t_list;
#define CVAR_LIST_HEAD(list) ((list)->head) #define CVAR_LIST_HEAD(list) ((list)->head)
...@@ -86,7 +86,7 @@ typedef struct { ...@@ -86,7 +86,7 @@ typedef struct {
typedef struct { typedef struct {
git_config_backend parent; git_config_backend parent;
git_cvar_list var_list; cvar_t_list var_list;
struct { struct {
gitfo_buf buffer; gitfo_buf buffer;
...@@ -101,7 +101,7 @@ typedef struct { ...@@ -101,7 +101,7 @@ typedef struct {
static int config_parse(file_backend *cfg_file); static int config_parse(file_backend *cfg_file);
static int parse_variable(file_backend *cfg, char **var_name, char **var_value); static int parse_variable(file_backend *cfg, char **var_name, char **var_value);
static void cvar_free(git_cvar *var) static void cvar_free(cvar_t *var)
{ {
if (var == NULL) if (var == NULL)
return; return;
...@@ -112,9 +112,9 @@ static void cvar_free(git_cvar *var) ...@@ -112,9 +112,9 @@ static void cvar_free(git_cvar *var)
free(var); free(var);
} }
static void cvar_list_free(git_cvar_list *list) static void cvar_list_free(cvar_t_list *list)
{ {
git_cvar *cur; cvar_t *cur;
while (!CVAR_LIST_EMPTY(list)) { while (!CVAR_LIST_EMPTY(list)) {
cur = CVAR_LIST_HEAD(list); cur = CVAR_LIST_HEAD(list);
...@@ -170,7 +170,7 @@ static int cvar_match_section(const char *local, const char *input) ...@@ -170,7 +170,7 @@ static int cvar_match_section(const char *local, const char *input)
return !strncmp(local_sp + 2, first_dot + 1, comparison_len); return !strncmp(local_sp + 2, first_dot + 1, comparison_len);
} }
static int cvar_match_name(const git_cvar *var, const char *str) static int cvar_match_name(const cvar_t *var, const char *str)
{ {
const char *name_start; const char *name_start;
...@@ -185,9 +185,9 @@ static int cvar_match_name(const git_cvar *var, const char *str) ...@@ -185,9 +185,9 @@ static int cvar_match_name(const git_cvar *var, const char *str)
return !strcasecmp(var->name, name_start); return !strcasecmp(var->name, name_start);
} }
static git_cvar *cvar_list_find(git_cvar_list *list, const char *name) static cvar_t *cvar_list_find(cvar_t_list *list, const char *name)
{ {
git_cvar *iter; cvar_t *iter;
CVAR_LIST_FOREACH (list, iter) { CVAR_LIST_FOREACH (list, iter) {
if (cvar_match_name(iter, name)) if (cvar_match_name(iter, name))
...@@ -270,8 +270,8 @@ static void backend_free(git_config_backend *_backend) ...@@ -270,8 +270,8 @@ static void backend_free(git_config_backend *_backend)
static int file_foreach(git_config_backend *backend, int (*fn)(const char *, void *), void *data) static int file_foreach(git_config_backend *backend, int (*fn)(const char *, void *), void *data)
{ {
int ret; int ret = GIT_SUCCESS;
git_cvar *var; cvar_t *var;
char *normalized; char *normalized;
file_backend *b = (file_backend *)backend; file_backend *b = (file_backend *)backend;
...@@ -291,8 +291,8 @@ static int file_foreach(git_config_backend *backend, int (*fn)(const char *, voi ...@@ -291,8 +291,8 @@ static int file_foreach(git_config_backend *backend, int (*fn)(const char *, voi
static int config_set(git_config_backend *cfg, const char *name, const char *value) static int config_set(git_config_backend *cfg, const char *name, const char *value)
{ {
git_cvar *var = NULL; cvar_t *var = NULL;
git_cvar *existing = NULL; cvar_t *existing = NULL;
int error = GIT_SUCCESS; int error = GIT_SUCCESS;
const char *last_dot; const char *last_dot;
file_backend *b = (file_backend *)cfg; file_backend *b = (file_backend *)cfg;
...@@ -321,11 +321,11 @@ static int config_set(git_config_backend *cfg, const char *name, const char *val ...@@ -321,11 +321,11 @@ static int config_set(git_config_backend *cfg, const char *name, const char *val
return git__throw(GIT_EINVALIDTYPE, "Variables without section aren't allowed"); return git__throw(GIT_EINVALIDTYPE, "Variables without section aren't allowed");
} }
var = git__malloc(sizeof(git_cvar)); var = git__malloc(sizeof(cvar_t));
if (var == NULL) if (var == NULL)
return GIT_ENOMEM; return GIT_ENOMEM;
memset(var, 0x0, sizeof(git_cvar)); memset(var, 0x0, sizeof(cvar_t));
var->section = git__strndup(name, last_dot - name); var->section = git__strndup(name, last_dot - name);
if (var->section == NULL) { if (var->section == NULL) {
...@@ -359,7 +359,7 @@ static int config_set(git_config_backend *cfg, const char *name, const char *val ...@@ -359,7 +359,7 @@ static int config_set(git_config_backend *cfg, const char *name, const char *val
*/ */
static int config_get(git_config_backend *cfg, const char *name, const char **out) static int config_get(git_config_backend *cfg, const char *name, const char **out)
{ {
git_cvar *var; cvar_t *var;
int error = GIT_SUCCESS; int error = GIT_SUCCESS;
file_backend *b = (file_backend *)cfg; file_backend *b = (file_backend *)cfg;
...@@ -641,7 +641,7 @@ static int parse_section_header_ext(const char *line, const char *base_name, cha ...@@ -641,7 +641,7 @@ static int parse_section_header_ext(const char *line, const char *base_name, cha
ret = snprintf(*section_name, total_len, "%s %s", base_name, subsection); ret = snprintf(*section_name, total_len, "%s %s", base_name, subsection);
if (ret >= total_len) { if (ret >= total_len) {
/* If this fails, we've checked the length wrong */ /* If this fails, we've checked the length wrong */
error = git__thow(GIT_ERROR, "Failed to parse ext header. Wrong total lenght calculation"); error = git__throw(GIT_ERROR, "Failed to parse ext header. Wrong total lenght calculation");
goto out; goto out;
} else if (ret < 0) { } else if (ret < 0) {
error = git__throw(GIT_EOSERR, "Failed to parse ext header. OS error: %s", strerror(errno)); error = git__throw(GIT_EOSERR, "Failed to parse ext header. OS error: %s", strerror(errno));
...@@ -725,7 +725,7 @@ error: ...@@ -725,7 +725,7 @@ error:
static int skip_bom(file_backend *cfg) static int skip_bom(file_backend *cfg)
{ {
static const unsigned char *utf8_bom = "\xef\xbb\xbf"; static const char *utf8_bom = "\xef\xbb\xbf";
if (memcmp(cfg->reader.read_ptr, utf8_bom, sizeof(utf8_bom)) == 0) if (memcmp(cfg->reader.read_ptr, utf8_bom, sizeof(utf8_bom)) == 0)
cfg->reader.read_ptr += sizeof(utf8_bom); cfg->reader.read_ptr += sizeof(utf8_bom);
...@@ -802,7 +802,7 @@ static int config_parse(file_backend *cfg_file) ...@@ -802,7 +802,7 @@ static int config_parse(file_backend *cfg_file)
char *current_section = NULL; char *current_section = NULL;
char *var_name; char *var_name;
char *var_value; char *var_value;
git_cvar *var; cvar_t *var;
/* Initialise the reading position */ /* Initialise the reading position */
cfg_file->reader.read_ptr = cfg_file->reader.buffer.data; cfg_file->reader.read_ptr = cfg_file->reader.buffer.data;
...@@ -834,13 +834,13 @@ static int config_parse(file_backend *cfg_file) ...@@ -834,13 +834,13 @@ static int config_parse(file_backend *cfg_file)
if (error < GIT_SUCCESS) if (error < GIT_SUCCESS)
break; break;
var = malloc(sizeof(git_cvar)); var = malloc(sizeof(cvar_t));
if (var == NULL) { if (var == NULL) {
error = GIT_ENOMEM; error = GIT_ENOMEM;
break; break;
} }
memset(var, 0x0, sizeof(git_cvar)); memset(var, 0x0, sizeof(cvar_t));
var->section = git__strdup(current_section); var->section = git__strdup(current_section);
if (var->section == NULL) { if (var->section == NULL) {
...@@ -966,7 +966,7 @@ static int parse_variable(file_backend *cfg, char **var_name, char **var_value) ...@@ -966,7 +966,7 @@ static int parse_variable(file_backend *cfg, char **var_name, char **var_value)
while (isspace(var_end[0])); while (isspace(var_end[0]));
} }
tmp = strndup(line, var_end - line + 1); tmp = git__strndup(line, var_end - line + 1);
if (tmp == NULL) { if (tmp == NULL) {
error = GIT_ENOMEM; error = GIT_ENOMEM;
goto out; goto out;
......
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