mirror of
https://github.com/Stichting-MINIX-Research-Foundation/pkgsrc-ng.git
synced 2025-09-09 20:40:13 -04:00
40 lines
1.0 KiB
Plaintext
40 lines
1.0 KiB
Plaintext
$NetBSD: patch-ac,v 1.1.1.1 2007/01/29 16:40:58 minskim Exp $
|
|
|
|
4.4BSD's radixsort() is unportable, replace it with slower qsort() for now.
|
|
|
|
--- main.c.orig 2007-01-26 18:24:41.000000000 +0100
|
|
+++ main.c
|
|
@@ -249,6 +249,15 @@ void add_string(char *string)
|
|
strcpy(strings[nr_of_strings-1], string);
|
|
}
|
|
|
|
+/*
|
|
+ * this is for system lacking radixsort() facility for sorting strings effectively
|
|
+ * hopefully gcc optimizes this out otherwise
|
|
+ */
|
|
+int
|
|
+pstrcmp (const void *s1, const void *s2)
|
|
+{
|
|
+ return strcmp (*(u_char **)s1, *(u_char **)s2);
|
|
+}
|
|
|
|
/*
|
|
* main():
|
|
@@ -296,10 +305,16 @@ int main(int argc, char *argv[])
|
|
add_string(s);
|
|
}
|
|
|
|
+#ifdef BSD
|
|
printf ("radixsort...\n");
|
|
i = radixsort((const u_char **)strings, nr_of_strings, NULL, 0);
|
|
if (i)
|
|
printf("radixsort result = %i\n", i);
|
|
+#else
|
|
+ printf ("quicksort...\n");
|
|
+ qsort((void *)strings, nr_of_strings, sizeof (u_char *), pstrcmp);
|
|
+ printf ("quicksort finished.\n");
|
|
+#endif
|
|
|
|
/* for (i=0; i<nr_of_strings; i++)
|
|
printf("strings[%i]: %s", i, strings[i]); */
|