git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Shawn O. Pearce <spearce@spearce.org>
Date
Apr 15, 2007, 04:33 UTC
Message-ID
<20070415043328.GA17285@spearce.org>

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 <spearce@spearce.org>
---
 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
Next: Johannes Schindelin
Message 1 of 5 in “Correct dir.c to compile on Solaris 9”
  1. Correct dir.c to compile on Solaris 9Shawn O. Pearce, Apr 15, 2007
  2. Johannes SchindelinApr 15, 2007
  3. Josef WeidendorferApr 15, 2007
  4. Robin RosenbergApr 15, 2007
  5. Junio C HamanoApr 15, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.