Thread (4 messages) flat view 4 messages, 4 authors, 2016-06-15
DORMANTno replies

[PATCH] Correct dir.c to compile on Solaris 9

From: Shawn O. Pearce <hidden>
Date: 2016-06-15 22:43:04
Subsystem: the rest · Maintainer: Linus Torvalds

The compiler on my Solaris 9 system doesn't understand
the array initialization syntax used here in dir.c.

Signed-off-by: Shawn O. Pearce <redacted>
---
 dir.c |   11 +++++------
 1 files changed, 5 insertions(+), 6 deletions(-)
diff --git a/dir.c b/dir.c
index 7426fde..038fd82 100644
--- a/dir.c
+++ b/dir.c
@@ -423,18 +423,17 @@ static int cmp_name(const void *p1, const void *p2)
  */
 static int simple_length(const char *match)
 {
-	const char special[256] = {
-		[0] = 1, ['?'] = 1,
-		['\\'] = 1, ['*'] = 1,
-		['['] = 1
-	};
 	int len = -1;
 
 	for (;;) {
 		unsigned char c = *match++;
 		len++;
-		if (special[c])
+		switch (c) {
+		case 0: case '?':
+		case '\\': case '*':
+		case '[':
 			return len;
+		}
 	}
 }
 
-- 
1.5.1.1.83.g2bfe3
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help