Re: Problem listing GIT repository with accents
- From
Johannes Sixt <j.sixt@viscovery.net>
- Date
- Feb 1, 2010, 12:48 UTC
- Message-ID
- <4B66CD81.3010005@viscovery.net>
- In-Reply-To
- <20100201121933.GA9995@coredump.intra.peff.net>
Jeff King schrieb:
Show 21 quoted lines
> @@ -209,11 +209,14 @@ static size_t quote_c_style_counted(const char *name, ssize_t maxlen,
> size_t len, count = 0;
> const char *p = name;
>
> + if (maxlen < 0)
> + maxlen = strlen(name);
> +
> for (;;) {
> int ch;
>
> len = next_quote_pos(p, maxlen);
> - if (len == maxlen || !p[len])
> + if (len == maxlen)
> break;
>
> if (!no_dq && p == name)
> @@ -223,6 +226,7 @@ static size_t quote_c_style_counted(const char *name, ssize_t maxlen,
> EMIT('\\');
> p += len;
> ch = (unsigned char)*p++;
> + maxlen -= len + 1;Couldn't you just write
if (0 <= maxlen) maxlen -= len + 1;
to avoid the strlen(), because the rest of the loop is actually OK when maxlen == -1, isn't it?
-- Hannes