Make qsort() in readconf.c more portable
[exim.git] / src / src / readconf.c
index cf5f069e90b418a65a776002b8547e4d5d1ca8a2..8844ca73a874b3168740e614e61827e00afbde01 100644 (file)
@@ -15,6 +15,13 @@ static void fn_smtp_receive_timeout(const uschar * name, const uschar * str);
 static void save_config_line(const uschar* line);
 static void save_config_position(const uschar *file, int line);
 static void print_config(BOOL admin);
+/* glibc seems to define environ as a macro, we can use this to check
+it's existence. And, if we declare environ a 2nd time, it shouldn't
+harm */
+#ifndef environ
+extern char **environ;
+#endif
+
 
 #define CSTATE_STACK_SIZE 10
 
@@ -2708,7 +2715,7 @@ if (type == NULL)
       size_t n;
       for (p = USS environ; *p; p++) ;
       n = p - USS environ;
-      qsort(environ, p - USS environ, sizeof(*p), (__compar_fn_t) string_compare_by_pointer);
+      qsort(environ, p - USS environ, sizeof(*p), string_compare_by_pointer);
 
       for (p = USS environ; *p; p++)
         {