X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;f=lib%2Fconf-input.c;h=b890295d99742025c5fecbe69c89544770d6c86d;hb=5c21b096ab39ece4c9ad80047144b2fde0c54758;hp=260d9f2a50cdf80d7a9d797d682a5dda78b27063;hpb=0a3c6e75d7bf2f7d79a1e448c343946f689e6ba1;p=libucw.git diff --git a/lib/conf-input.c b/lib/conf-input.c index 260d9f2a..b890295d 100644 --- a/lib/conf-input.c +++ b/lib/conf-input.c @@ -23,13 +23,13 @@ /* Text file parser */ -static const byte *name_parse_fb; +static const char *name_parse_fb; static struct fastbuf *parse_fb; static uns line_num; #define MAX_LINE 4096 -static byte line_buf[MAX_LINE]; -static byte *line = line_buf; +static char line_buf[MAX_LINE]; +static char *line = line_buf; #include "lib/bbuf.h" static bb_t copy_buf; @@ -43,7 +43,7 @@ static uns words; static uns ends_by_brace; // the line is ended by "{" static int -get_line(byte **msg) +get_line(char **msg) { int err = bgets_nodie(parse_fb, line_buf, MAX_LINE); line_num++; @@ -58,7 +58,7 @@ get_line(byte **msg) } static void -append(byte *start, byte *end) +append(char *start, char *end) { uns len = end - start; bb_grow(©_buf, copied + len + 1); @@ -67,14 +67,14 @@ append(byte *start, byte *end) copy_buf.ptr[copied-1] = 0; } -static byte * +static char * get_word(uns is_command_name) { - byte *msg; + char *msg; if (*line == '\'') { line++; while (1) { - byte *start = line; + char *start = line; while (*line && *line != '\'') line++; append(start, line); @@ -82,7 +82,7 @@ get_word(uns is_command_name) break; copy_buf.ptr[copied-1] = '\n'; if (!get_line(&msg)) - return msg ? : (byte*) "Unterminated apostrophe word at the end"; + return msg ? : "Unterminated apostrophe word at the end"; } line++; @@ -90,7 +90,7 @@ get_word(uns is_command_name) line++; uns start_copy = copied; while (1) { - byte *start = line; + char *start = line; uns escape = 0; while (*line) { if (*line == '"' && !escape) @@ -109,11 +109,11 @@ get_word(uns is_command_name) else // merge two lines copied -= 2; if (!get_line(&msg)) - return msg ? : (byte*) "Unterminated quoted word at the end"; + return msg ? : "Unterminated quoted word at the end"; } line++; - byte *tmp = stk_str_unesc(copy_buf.ptr + start_copy); + char *tmp = stk_str_unesc(copy_buf.ptr + start_copy); uns l = strlen(tmp); bb_grow(©_buf, start_copy + l + 1); strcpy(copy_buf.ptr + start_copy, tmp); @@ -121,7 +121,7 @@ get_word(uns is_command_name) } else { // promised that *line is non-null and non-blank - byte *start = line; + char *start = line; while (*line && !Cblank(*line) && *line != '{' && *line != '}' && *line != ';' && (*line != '=' || !is_command_name)) @@ -140,8 +140,8 @@ get_word(uns is_command_name) return NULL; } -static byte * -get_token(uns is_command_name, byte **err) +static char * +get_token(uns is_command_name, char **err) { *err = NULL; while (1) { @@ -159,7 +159,7 @@ get_token(uns is_command_name, byte **err) return NULL; } if (!*line || *line == '#') - msg(L_WARN, "The line %s:%d following a backslash is empty", name_parse_fb ? : (byte*) "", line_num); + msg(L_WARN, "The line %s:%d following a backslash is empty", name_parse_fb ? : "", line_num); } else { split_grow(&word_buf, words+1); uns start = copied; @@ -170,11 +170,11 @@ get_token(uns is_command_name, byte **err) } } -static byte * +static char * split_command(void) { words = copied = ends_by_brace = 0; - byte *msg, *start_word; + char *msg, *start_word; if (!(start_word = get_token(1, &msg))) return msg; if (*start_word == '{') // only one opening brace @@ -194,10 +194,10 @@ split_command(void) /* Parsing multiple files */ -static byte * -parse_fastbuf(const byte *name_fb, struct fastbuf *fb, uns depth) +static char * +parse_fastbuf(const char *name_fb, struct fastbuf *fb, uns depth) { - byte *err; + char *err; name_parse_fb = name_fb; parse_fb = fb; line_num = 0; @@ -210,8 +210,8 @@ parse_fastbuf(const byte *name_fb, struct fastbuf *fb, uns depth) goto error; if (!words) return NULL; - byte *name = copy_buf.ptr + word_buf.ptr[0]; - byte *pars[words-1]; + char *name = copy_buf.ptr + word_buf.ptr[0]; + char *pars[words-1]; for (uns i=1; i