OSDN Git Service

* lib/getopt.c: Use __progname==__argv[0] when not compiling for cygwin.
authorcgf <cgf>
Wed, 19 Sep 2001 15:54:11 +0000 (15:54 +0000)
committercgf <cgf>
Wed, 19 Sep 2001 15:54:11 +0000 (15:54 +0000)
* scandir.cc (scandir): Use correct default when compar == NULL.

winsup/cygwin/ChangeLog
winsup/cygwin/lib/getopt.c
winsup/cygwin/scandir.cc

index 3bd86d1..453f3c6 100644 (file)
@@ -1,3 +1,9 @@
+Wed Sep 19 11:52:42 2001  Christopher Faylor <cgf@cygnus.com>
+
+       * lib/getopt.c: Use __progname==__argv[0] when not compiling for cygwin.
+
+       * scandir.cc (scandir): Use correct default when compar == NULL.
+
 Wed Sep 19 17:49:00 2001  Corinna Vinschen <corinna@vinschen.de>
 
        * fhandler_socket.cc (fhandler_socket::fhandler_socket): Revert
index 7049f80..ba13678 100644 (file)
@@ -68,6 +68,9 @@ char    *optarg;              /* argument associated with option */
 __weak_alias(getopt_long,_getopt_long)
 #endif
 
+#ifndef __CYGWIN__
+#define __progname __argv[0]
+#endif
 
 #define IGNORE_FIRST   (*options == '-' || *options == '+')
 #define PRINT_ERROR    ((opterr) && ((*options != ':') \
index b2888e2..52a36ea 100644 (file)
 #include <errno.h>
 #include "cygerrno.h"
 
-extern "C"
-int
+extern "C" int
+alphasort (const struct dirent **a, const struct dirent **b)
+{
+  return strcoll ((*a)->d_name, (*b)->d_name);
+}
+
+extern "C" int
 scandir (const char *dir,
         struct dirent ***namelist,
         int (*select) (const struct dirent *),
@@ -33,6 +38,8 @@ scandir (const char *dir,
 
   int prior_errno = get_errno ();
   set_errno (0);
+  if (!compar)
+    compar = alphasort;
 
   while ((ent = readdir (dirp)))
     {
@@ -91,11 +98,3 @@ scandir (const char *dir,
     *namelist = nl;
   return count;
 }
-
-extern "C"
-int
-alphasort (const struct dirent **a, const struct dirent **b)
-{
-  return strcoll ((*a)->d_name, (*b)->d_name);
-}
-