X-Git-Url: https://git.cameronkatri.com/cgit.git/blobdiff_plain/20a33548b9a87a6eb23162ee5d137daa46d78613..77b6f833441dda1dd50f5a51a81036b1fde815d5:/configfile.c diff --git a/configfile.c b/configfile.c index 4908058..e039109 100644 --- a/configfile.c +++ b/configfile.c @@ -1,21 +1,20 @@ /* configfile.c: parsing of config files * - * Copyright (C) 2008 Lars Hjemli + * Copyright (C) 2006-2014 cgit Development Team * * Licensed under GNU General Public License v2 * (see COPYING for full license text) */ -#include -#include +#include #include "configfile.h" -int next_char(FILE *f) +static int next_char(FILE *f) { int c = fgetc(f); - if (c=='\r') { + if (c == '\r') { c = fgetc(f); - if (c!='\n') { + if (c != '\n') { ungetc(c, f); c = '\r'; } @@ -23,53 +22,55 @@ int next_char(FILE *f) return c; } -void skip_line(FILE *f) +static void skip_line(FILE *f) { int c; - while((c=next_char(f)) && c!='\n' && c!=EOF) + while ((c = next_char(f)) && c != '\n' && c != EOF) ; } -int read_config_line(FILE *f, char *line, const char **value, int bufsize) +static int read_config_line(FILE *f, struct strbuf *name, struct strbuf *value) { - int i = 0, isname = 0; + int c = next_char(f); - *value = NULL; - while(i 0) - fn(line, value); + while (read_config_line(f, &name, &value)) + fn(name.buf, value.buf); nesting--; fclose(f); + strbuf_release(&name); + strbuf_release(&value); return 0; }