X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=quote.c;h=fc93435727db3b0634c390965258200c61d8b59b;hb=758df17ab07a58e5b0f8effdf2d1b71fe8d79f1d;hp=acb6bf929f3e5807139fa7852f739e6ff5a50722;hpb=630724ca79b1a7893a8d9c04367eae857ff1a7b0;p=git.git diff --git a/quote.c b/quote.c index acb6bf929..fc9343572 100644 --- a/quote.c +++ b/quote.c @@ -213,7 +213,7 @@ static size_t quote_c_style_counted(const char *name, ssize_t maxlen, int ch; len = next_quote_pos(p, maxlen); - if (len == maxlen || !p[len]) + if (len == maxlen || (maxlen < 0 && !p[len])) break; if (!no_dq && p == name) @@ -223,6 +223,8 @@ static size_t quote_c_style_counted(const char *name, ssize_t maxlen, EMIT('\\'); p += len; ch = (unsigned char)*p++; + if (maxlen >= 0) + maxlen -= len + 1; if (sq_lookup[ch] >= ' ') { EMIT(sq_lookup[ch]); } else {