X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;ds=sidebyside;f=config.c;h=5f9ec2894570d23f8b91327374a4d82dd46cbca3;hb=365c656a70a7345ec58c34831e08740faf5d9cf7;hp=d06fb19d511c29e92aa840c664618ca4a6f73fe6;hpb=9cedd16c62e12521f35b44e10bba80bfe261e69c;p=git.git diff --git a/config.c b/config.c index d06fb19d5..5f9ec2894 100644 --- a/config.c +++ b/config.c @@ -133,23 +133,21 @@ static int get_next_char(void) static char *parse_value(void) { - static char value[1024]; - int quote = 0, comment = 0, len = 0, space = 0; + static struct strbuf value = STRBUF_INIT; + int quote = 0, comment = 0, space = 0; + strbuf_reset(&value); for (;;) { int c = get_next_char(); - if (len >= sizeof(value) - 1) - return NULL; if (c == '\n') { if (quote) return NULL; - value[len] = 0; - return value; + return value.buf; } if (comment) continue; if (isspace(c) && !quote) { - if (len) + if (value.len) space++; continue; } @@ -160,7 +158,7 @@ static char *parse_value(void) } } for (; space; space--) - value[len++] = ' '; + strbuf_addch(&value, ' '); if (c == '\\') { c = get_next_char(); switch (c) { @@ -182,14 +180,14 @@ static char *parse_value(void) default: return NULL; } - value[len++] = c; + strbuf_addch(&value, c); continue; } if (c == '"') { quote = 1-quote; continue; } - value[len++] = c; + strbuf_addch(&value, c); } }