PR5024303.diff   [plain text]


--- src/Makefile.in.orig	2008-08-06 18:55:57.000000000 -0700
+++ src/Makefile.in	2008-08-06 18:56:04.000000000 -0700
@@ -47,7 +47,7 @@
 
 # glob.c does not have prototypes
 glob.o: glob.c ndir.h
-	$(CC) -c $(CWARNNP) $(CFLAGS) -I. $(DEFS) glob.c
+	$(CC) -c $(CWARNNP) $(CFLAGS) $(DEFS) glob.c
 
 man-config.o man-getopt.o man.o manpath.o to_cat.o: defs.h
 different.o man.o: different.h
--- src/glob.c.orig	2008-08-06 18:41:39.000000000 -0700
+++ src/glob.c	2008-08-06 18:58:17.000000000 -0700
@@ -1,3 +1,27 @@
+#ifdef __APPLE__
+#include <glob.h>
+#include <stdlib.h>
+#include <string.h>
+
+char **
+glob_filename (const char *pathname)
+{
+	char **result = NULL;
+	glob_t g;
+	int i;
+
+	if (glob(pathname, 0, NULL, &g) == 0) {
+		result = malloc((g.gl_pathc + 1) * sizeof(char *));
+		for (i = 0; i < g.gl_pathc; i++) {
+			result[i] = strdup(g.gl_pathv[i]);
+		}
+		result[g.gl_pathc] = NULL;
+		globfree(&g);
+	}
+
+	return result;
+}
+#else
 /* File-name wildcard pattern matching for GNU.
    Copyright (C) 1985, 1988, 1989, 1990, 1991 Free Software Foundation, Inc.
 
@@ -680,3 +704,4 @@
 }
 
 #endif /* TEST */
+#endif