about summary refs log tree commit diff
path: root/posix
diff options
context:
space:
mode:
Diffstat (limited to 'posix')
-rw-r--r--posix/getopt.c65
-rw-r--r--posix/regex.c21
-rw-r--r--posix/wordexp-test.c19
3 files changed, 51 insertions, 54 deletions
diff --git a/posix/getopt.c b/posix/getopt.c
index 7afe6c4a96..4cbf3614cc 100644
--- a/posix/getopt.c
+++ b/posix/getopt.c
@@ -24,19 +24,19 @@
 /* This tells Alpha OSF/1 not to define a getopt prototype in <stdio.h>.
    Ditto for AIX 3.2 and <stdlib.h>.  */
 #ifndef _NO_PROTO
-#define _NO_PROTO
+# define _NO_PROTO
 #endif
 
 #ifdef HAVE_CONFIG_H
-#include <config.h>
+# include <config.h>
 #endif
 
 #if !defined __STDC__ || !__STDC__
 /* This is a separate conditional since some stdc systems
    reject `defined (const)'.  */
-#ifndef const
-#define const
-#endif
+# ifndef const
+#  define const
+# endif
 #endif
 
 #include <stdio.h>
@@ -51,10 +51,10 @@
 
 #define GETOPT_INTERFACE_VERSION 2
 #if !defined _LIBC && defined __GLIBC__ && __GLIBC__ >= 2
-#include <gnu-versions.h>
-#if _GNU_GETOPT_INTERFACE_VERSION == GETOPT_INTERFACE_VERSION
-#define ELIDE_CODE
-#endif
+# include <gnu-versions.h>
+# if _GNU_GETOPT_INTERFACE_VERSION == GETOPT_INTERFACE_VERSION
+#  define ELIDE_CODE
+# endif
 #endif
 
 #ifndef ELIDE_CODE
@@ -65,26 +65,26 @@
 #ifdef	__GNU_LIBRARY__
 /* Don't include stdlib.h for non-GNU C libraries because some of them
    contain conflicting prototypes for getopt.  */
-#include <stdlib.h>
-#include <unistd.h>
+# include <stdlib.h>
+# include <unistd.h>
 #endif	/* GNU C library.  */
 
 #ifdef VMS
-#include <unixlib.h>
-#if HAVE_STRING_H - 0
-#include <string.h>
-#endif
+# include <unixlib.h>
+# if HAVE_STRING_H - 0
+#  include <string.h>
+# endif
 #endif
 
 #ifndef _
 /* This is for other GNU distributions with internationalized messages.
    When compiling libc, the _ macro is predefined.  */
-#ifdef HAVE_LIBINTL_H
-# include <libintl.h>
-# define _(msgid)	gettext (msgid)
-#else
-# define _(msgid)	(msgid)
-#endif
+# ifdef HAVE_LIBINTL_H
+#  include <libintl.h>
+#  define _(msgid)	gettext (msgid)
+# else
+#  define _(msgid)	(msgid)
+# endif
 #endif
 
 /* This version of `getopt' appears to the caller like standard Unix `getopt'
@@ -194,14 +194,19 @@ static char *posixly_correct;
    because there are many ways it can cause trouble.
    On some systems, it contains special magic macros that don't work
    in GCC.  */
-#include <string.h>
-#define	my_index	strchr
+# include <string.h>
+# define my_index	strchr
 #else
 
 /* Avoid depending on library functions or files
    whose names are inconsistent.  */
 
-char *getenv ();
+#ifndef getenv
+extern char *getenv ();
+#endif
+#ifndef strncmp
+extern int strncmp ();
+#endif
 
 static char *
 my_index (str, chr)
@@ -222,11 +227,11 @@ my_index (str, chr)
 #ifdef __GNUC__
 /* Note that Motorola Delta 68k R3V7 comes with GCC but not stddef.h.
    That was relevant to code that was here before.  */
-#if !defined __STDC__ || !__STDC__
+# if (!defined __STDC__ || !__STDC__) && !defined strlen
 /* gcc with -traditional declares the built-in strlen to return int,
    and has done so at least since version 2.4.5. -- rms.  */
 extern int strlen (const char *);
-#endif /* not __STDC__ */
+# endif /* not __STDC__ */
 #endif /* __GNUC__ */
 
 #endif /* not __GNU_LIBRARY__ */
@@ -524,11 +529,11 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
      from the shell indicating it is not an option.  The later information
      is only used when the used in the GNU libc.  */
 #ifdef _LIBC
-#define NONOPTION_P (argv[optind][0] != '-' || argv[optind][1] == '\0'	      \
-		     || (optind < nonoption_flags_len			      \
-			 && __getopt_nonoption_flags[optind] == '1'))
+# define NONOPTION_P (argv[optind][0] != '-' || argv[optind][1] == '\0'	      \
+		      || (optind < nonoption_flags_len			      \
+			  && __getopt_nonoption_flags[optind] == '1'))
 #else
-#define NONOPTION_P (argv[optind][0] != '-' || argv[optind][1] == '\0')
+# define NONOPTION_P (argv[optind][0] != '-' || argv[optind][1] == '\0')
 #endif
 
   if (nextchar == NULL || *nextchar == '\0')
diff --git a/posix/regex.c b/posix/regex.c
index b7fb962d61..e2d31a0427 100644
--- a/posix/regex.c
+++ b/posix/regex.c
@@ -1083,17 +1083,9 @@ static const char *re_error_msgid[] =
 # if defined MATCH_MAY_ALLOCATE
 /* 4400 was enough to cause a crash on Alpha OSF/1,
    whose default stack limit is 2mb.  */
-#  ifdef _LIBC
-long int __re_max_failures = 4000;
-#  else
 long int re_max_failures = 4000;
-#  endif
 # else
-#  ifdef _LIBC
-long int __re_max_failures = 2000;
-#  else
 long int re_max_failures = 2000;
-#  endif
 # endif
 
 union fail_stack_elt
@@ -1116,24 +1108,11 @@ typedef struct
 # if defined MATCH_MAY_ALLOCATE
 /* 4400 was enough to cause a crash on Alpha OSF/1,
    whose default stack limit is 2mb.  */
-#  ifdef _LIBC
-int __re_max_failures = 20000;
-#  else
 int re_max_failures = 20000;
-#  endif
 # else
-#  ifdef _LIBC
-int __re_max_failures = 2000;
-#  else
 int re_max_failures = 2000;
-#  endif
 # endif
 
-#ifdef _LIBC
-weak_alias (__re_max_failures, re_max_failures)
-# define re_max_failures __re_max_failures
-#endif
-
 union fail_stack_elt
 {
   unsigned char *pointer;
diff --git a/posix/wordexp-test.c b/posix/wordexp-test.c
index ba69476e4c..81f93a1577 100644
--- a/posix/wordexp-test.c
+++ b/posix/wordexp-test.c
@@ -150,6 +150,7 @@ struct test_case_struct
   };
 
 static int testit (struct test_case_struct *tc);
+static int tests;
 
 void
 command_line_test (const char *words)
@@ -204,17 +205,28 @@ main (int argc, char *argv[])
     {
       struct test_case_struct ts;
 
+      printf ("Test %d (~root): ", ++tests);
+      fflush (stdout);
+
       ts.retval = 0;
       ts.env = NULL;
       ts.words = "~root";
       ts.flags = 0;
       ts.wordc = 1;
       ts.wordv[0] = pw->pw_dir;
+      ts.ifs = IFS;
 
       if (testit (&ts))
-	++fail;
+	{
+	  printf ("FAILED\n");
+	  ++fail;
+	}
+      else
+	printf ("OK\n");
     }
 
+  puts ("tests completed, now cleaning up");
+
   /* Clean up */
   for (i = 0; globfile[i]; ++i)
     remove (globfile[i]);
@@ -225,6 +237,8 @@ main (int argc, char *argv[])
   chdir (cwd);
   rmdir (tmpdir);
 
+  printf ("tests failed: %d\n", fail);
+
   return fail != 0;
 }
 
@@ -232,7 +246,6 @@ main (int argc, char *argv[])
 static int
 testit (struct test_case_struct *tc)
 {
-  static int test;
   int retval;
   wordexp_t we;
   int bzzzt = 0;
@@ -248,7 +261,7 @@ testit (struct test_case_struct *tc)
   else
     unsetenv ("IFS");
 
-  printf ("Test %d: ", ++test);
+  printf ("Test %d (%s): ", ++tests, tc->words);
   retval = wordexp (tc->words, &we, tc->flags);
 
   if (retval != tc->retval || (retval == 0 && we.we_wordc != tc->wordc))