X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=quote.c;h=fc93435727db3b0634c390965258200c61d8b59b;hb=dab76d3aa682a340e886df84da33326368c38633;hp=7a49fcf69671646a0d3ba6de6478cfc6767c31fe;hpb=c9a88deede2e3438a70be7df233678d6a0fece74;p=git.git diff --git a/quote.c b/quote.c index 7a49fcf69..fc9343572 100644 --- a/quote.c +++ b/quote.c @@ -72,7 +72,7 @@ void sq_quote_argv(struct strbuf *dst, const char** argv, size_t maxlen) } } -char *sq_dequote_step(char *arg, char **next) +static char *sq_dequote_step(char *arg, char **next) { char *dst = arg; char *src = arg; @@ -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 { @@ -272,8 +274,8 @@ void write_name_quoted(const char *name, FILE *fp, int terminator) fputc(terminator, fp); } -extern void write_name_quotedpfx(const char *pfx, size_t pfxlen, - const char *name, FILE *fp, int terminator) +void write_name_quotedpfx(const char *pfx, size_t pfxlen, + const char *name, FILE *fp, int terminator) { int needquote = 0;