From 596f3269b00bc497b2fd82d9ec4bc748fe7b6fab Mon Sep 17 00:00:00 2001 From: Christopher Faylor Date: Wed, 19 Sep 2001 15:54:12 +0000 Subject: [PATCH] * lib/getopt.c: Use __progname==__argv[0] when not compiling for cygwin. * scandir.cc (scandir): Use correct default when compar == NULL. --- winsup/cygwin/ChangeLog | 6 ++++++ winsup/cygwin/lib/getopt.c | 3 +++ winsup/cygwin/scandir.cc | 19 +++++++++---------- 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 3bd86d104..453f3c61b 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,9 @@ +Wed Sep 19 11:52:42 2001 Christopher Faylor + + * 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 * fhandler_socket.cc (fhandler_socket::fhandler_socket): Revert diff --git a/winsup/cygwin/lib/getopt.c b/winsup/cygwin/lib/getopt.c index 7049f8045..ba13678b8 100644 --- a/winsup/cygwin/lib/getopt.c +++ b/winsup/cygwin/lib/getopt.c @@ -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 != ':') \ diff --git a/winsup/cygwin/scandir.cc b/winsup/cygwin/scandir.cc index b2888e23d..52a36eab6 100644 --- a/winsup/cygwin/scandir.cc +++ b/winsup/cygwin/scandir.cc @@ -16,8 +16,13 @@ #include #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); -} -