Thread (8 messages) 8 messages, 4 authors, 2016-06-15

Re: Problem listing GIT repository with accents

From: Johannes Sixt <hidden>
Date: 2016-06-15 22:48:09

Jeff King schrieb:
quoted hunk ↗ jump to hunk
@@ -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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help