diff options
Diffstat (limited to 'configfile.c')
-rw-r--r-- | configfile.c | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/configfile.c b/configfile.c index 4908058..fe5f9c5 100644 --- a/configfile.c +++ b/configfile.c | |||
@@ -13,9 +13,9 @@ | |||
13 | int next_char(FILE *f) | 13 | int next_char(FILE *f) |
14 | { | 14 | { |
15 | int c = fgetc(f); | 15 | int c = fgetc(f); |
16 | if (c=='\r') { | 16 | if (c == '\r') { |
17 | c = fgetc(f); | 17 | c = fgetc(f); |
18 | if (c!='\n') { | 18 | if (c != '\n') { |
19 | ungetc(c, f); | 19 | ungetc(c, f); |
20 | c = '\r'; | 20 | c = '\r'; |
21 | } | 21 | } |
@@ -27,7 +27,7 @@ void skip_line(FILE *f) | |||
27 | { | 27 | { |
28 | int c; | 28 | int c; |
29 | 29 | ||
30 | while((c=next_char(f)) && c!='\n' && c!=EOF) | 30 | while((c = next_char(f)) && c != '\n' && c != EOF) |
31 | ; | 31 | ; |
32 | } | 32 | } |
33 | 33 | ||
@@ -36,31 +36,31 @@ int read_config_line(FILE *f, char *line, const char **value, int bufsize) | |||
36 | int i = 0, isname = 0; | 36 | int i = 0, isname = 0; |
37 | 37 | ||
38 | *value = NULL; | 38 | *value = NULL; |
39 | while(i<bufsize-1) { | 39 | while(i < bufsize - 1) { |
40 | int c = next_char(f); | 40 | int c = next_char(f); |
41 | if (!isname && (c=='#' || c==';')) { | 41 | if (!isname && (c == '#' || c == ';')) { |
42 | skip_line(f); | 42 | skip_line(f); |
43 | continue; | 43 | continue; |
44 | } | 44 | } |
45 | if (!isname && isspace(c)) | 45 | if (!isname && isspace(c)) |
46 | continue; | 46 | continue; |
47 | 47 | ||
48 | if (c=='=' && !*value) { | 48 | if (c == '=' && !*value) { |
49 | line[i] = 0; | 49 | line[i] = 0; |
50 | *value = &line[i+1]; | 50 | *value = &line[i + 1]; |
51 | } else if (c=='\n' && !isname) { | 51 | } else if (c == '\n' && !isname) { |
52 | i = 0; | 52 | i = 0; |
53 | continue; | 53 | continue; |
54 | } else if (c=='\n' || c==EOF) { | 54 | } else if (c == '\n' || c == EOF) { |
55 | line[i] = 0; | 55 | line[i] = 0; |
56 | break; | 56 | break; |
57 | } else { | 57 | } else { |
58 | line[i]=c; | 58 | line[i] = c; |
59 | } | 59 | } |
60 | isname = 1; | 60 | isname = 1; |
61 | i++; | 61 | i++; |
62 | } | 62 | } |
63 | line[i+1] = 0; | 63 | line[i + 1] = 0; |
64 | return i; | 64 | return i; |
65 | } | 65 | } |
66 | 66 | ||