X-Git-Url: https://gitweb.ps.run/ps-cgit/blobdiff_plain/23296ad648c0e2a9e3cf40a3de322b10ad25cce3..334aed8ab42b9513af0f4458081abc033d66c535:/configfile.c diff --git a/configfile.c b/configfile.c index 4908058..31fe5c8 100644 --- a/configfile.c +++ b/configfile.c @@ -10,12 +10,12 @@ #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 +23,53 @@ 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; }