diff options
Diffstat (limited to 'posix')
-rw-r--r-- | posix/Makefile | 8 | ||||
-rw-r--r-- | posix/getopt.c | 85 | ||||
-rw-r--r-- | posix/getopt.h | 19 |
3 files changed, 106 insertions, 6 deletions
diff --git a/posix/Makefile b/posix/Makefile index ede637a..1640e3e 100644 --- a/posix/Makefile +++ b/posix/Makefile @@ -118,7 +118,7 @@ endif endif CFLAGS-regex.c = -Wno-strict-prototypes -CFLAGS-getaddrinfo.c = -DRESOLVER +CFLAGS-getaddrinfo.c = -DRESOLVER -fexceptions CFLAGS-pread.c = -fexceptions -fasynchronous-unwind-tables CFLAGS-pread64.c = -fexceptions -fasynchronous-unwind-tables CFLAGS-pwrite.c = -fexceptions -fasynchronous-unwind-tables @@ -132,6 +132,12 @@ CFLAGS-wordexp.c = -fexceptions CFLAGS-sysconf.c = -fexceptions CFLAGS-pathconf.c = -fexceptions CFLAGS-fpathconf.c = -fexceptions +CFLAGS-spawn.c = -fexceptions +CFLAGS-spawnp.c = -fexceptions +CFLAGS-spawni.c = -fexceptions +CFLAGS-pause.c = -fexceptions +CFLAGS-glob.c = -fexceptions +CFLAGS-glob64.c = -fexceptions tstgetopt-ARGS = -a -b -cfoobar --required foobar --optional=bazbug \ --none random --col --color --colour diff --git a/posix/getopt.c b/posix/getopt.c index 289d137..5336410 100644 --- a/posix/getopt.c +++ b/posix/getopt.c @@ -2,7 +2,7 @@ NOTE: getopt is now part of the C library, so if you don't know what "Keep this file name-space clean" means, talk to drepper@gnu.org before changing it! - Copyright (C) 1987,88,89,90,91,92,93,94,95,96,98,99,2000,2001,2002 + Copyright (C) 1987,88,89,90,91,92,93,94,95,96,98,99,2000,2001,2002,2003 Free Software Foundation, Inc. This file is part of the GNU C Library. @@ -692,12 +692,19 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only) if (__asprintf (&buf, _("%s: option `%s' is ambiguous\n"), argv[0], argv[optind]) >= 0) { + _IO_flockfile (stderr); + + int old_flags2 = ((_IO_FILE *) stderr)->_flags2; + ((_IO_FILE *) stderr)->_flags2 |= _IO_FLAGS2_NOTCANCEL; if (_IO_fwide (stderr, 0) > 0) __fwprintf (stderr, L"%s", buf); else fputs (buf, stderr); + ((_IO_FILE *) stderr)->_flags2 = old_flags2; + _IO_funlockfile (stderr); + free (buf); } #else @@ -761,11 +768,20 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only) #if defined _LIBC && defined USE_IN_LIBIO if (n >= 0) { + _IO_flockfile (stderr); + + int old_flags2 = ((_IO_FILE *) stderr)->_flags2; + ((_IO_FILE *) stderr)->_flags2 + |= _IO_FLAGS2_NOTCANCEL; + if (_IO_fwide (stderr, 0) > 0) __fwprintf (stderr, L"%s", buf); else fputs (buf, stderr); + ((_IO_FILE *) stderr)->_flags2 = old_flags2; + _IO_funlockfile (stderr); + free (buf); } #endif @@ -792,11 +808,20 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only) %s: option `%s' requires an argument\n"), argv[0], argv[optind - 1]) >= 0) { + _IO_flockfile (stderr); + + int old_flags2 = ((_IO_FILE *) stderr)->_flags2; + ((_IO_FILE *) stderr)->_flags2 + |= _IO_FLAGS2_NOTCANCEL; + if (_IO_fwide (stderr, 0) > 0) __fwprintf (stderr, L"%s", buf); else fputs (buf, stderr); + ((_IO_FILE *) stderr)->_flags2 = old_flags2; + _IO_funlockfile (stderr); + free (buf); } #else @@ -861,11 +886,19 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only) #if defined _LIBC && defined USE_IN_LIBIO if (n >= 0) { + _IO_flockfile (stderr); + + int old_flags2 = ((_IO_FILE *) stderr)->_flags2; + ((_IO_FILE *) stderr)->_flags2 |= _IO_FLAGS2_NOTCANCEL; + if (_IO_fwide (stderr, 0) > 0) __fwprintf (stderr, L"%s", buf); else fputs (buf, stderr); + ((_IO_FILE *) stderr)->_flags2 = old_flags2; + _IO_funlockfile (stderr); + free (buf); } #endif @@ -919,11 +952,19 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only) #if defined _LIBC && defined USE_IN_LIBIO if (n >= 0) { + _IO_flockfile (stderr); + + int old_flags2 = ((_IO_FILE *) stderr)->_flags2; + ((_IO_FILE *) stderr)->_flags2 |= _IO_FLAGS2_NOTCANCEL; + if (_IO_fwide (stderr, 0) > 0) __fwprintf (stderr, L"%s", buf); else fputs (buf, stderr); + ((_IO_FILE *) stderr)->_flags2 = old_flags2; + _IO_funlockfile (stderr); + free (buf); } #endif @@ -962,11 +1003,19 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only) _("%s: option requires an argument -- %c\n"), argv[0], c) >= 0) { + _IO_flockfile (stderr); + + int old_flags2 = ((_IO_FILE *) stderr)->_flags2; + ((_IO_FILE *) stderr)->_flags2 |= _IO_FLAGS2_NOTCANCEL; + if (_IO_fwide (stderr, 0) > 0) __fwprintf (stderr, L"%s", buf); else fputs (buf, stderr); + ((_IO_FILE *) stderr)->_flags2 = old_flags2; + _IO_funlockfile (stderr); + free (buf); } #else @@ -1025,11 +1074,19 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only) if (__asprintf (&buf, _("%s: option `-W %s' is ambiguous\n"), argv[0], argv[optind]) >= 0) { + _IO_flockfile (stderr); + + int old_flags2 = ((_IO_FILE *) stderr)->_flags2; + ((_IO_FILE *) stderr)->_flags2 |= _IO_FLAGS2_NOTCANCEL; + if (_IO_fwide (stderr, 0) > 0) __fwprintf (stderr, L"%s", buf); else fputs (buf, stderr); + ((_IO_FILE *) stderr)->_flags2 = old_flags2; + _IO_funlockfile (stderr); + free (buf); } #else @@ -1061,11 +1118,20 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only) %s: option `-W %s' doesn't allow an argument\n"), argv[0], pfound->name) >= 0) { + _IO_flockfile (stderr); + + int old_flags2 = ((_IO_FILE *) stderr)->_flags2; + ((_IO_FILE *) stderr)->_flags2 + |= _IO_FLAGS2_NOTCANCEL; + if (_IO_fwide (stderr, 0) > 0) __fwprintf (stderr, L"%s", buf); else fputs (buf, stderr); + ((_IO_FILE *) stderr)->_flags2 = old_flags2; + _IO_funlockfile (stderr); + free (buf); } #else @@ -1094,11 +1160,20 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only) %s: option `%s' requires an argument\n"), argv[0], argv[optind - 1]) >= 0) { + _IO_flockfile (stderr); + + int old_flags2 = ((_IO_FILE *) stderr)->_flags2; + ((_IO_FILE *) stderr)->_flags2 + |= _IO_FLAGS2_NOTCANCEL; + if (_IO_fwide (stderr, 0) > 0) __fwprintf (stderr, L"%s", buf); else fputs (buf, stderr); + ((_IO_FILE *) stderr)->_flags2 = old_flags2; + _IO_funlockfile (stderr); + free (buf); } #else @@ -1160,11 +1235,19 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only) %s: option requires an argument -- %c\n"), argv[0], c) >= 0) { + _IO_flockfile (stderr); + + int old_flags2 = ((_IO_FILE *) stderr)->_flags2; + ((_IO_FILE *) stderr)->_flags2 |= _IO_FLAGS2_NOTCANCEL; + if (_IO_fwide (stderr, 0) > 0) __fwprintf (stderr, L"%s", buf); else fputs (buf, stderr); + ((_IO_FILE *) stderr)->_flags2 = old_flags2; + _IO_funlockfile (stderr); + free (buf); } #else diff --git a/posix/getopt.h b/posix/getopt.h index 4283c35..53cb2ba 100644 --- a/posix/getopt.h +++ b/posix/getopt.h @@ -1,5 +1,5 @@ /* Declarations for getopt. - Copyright (C) 1989-1994, 1996-1999, 2001 Free Software Foundation, Inc. + Copyright (C) 1989-1994, 1996-1999,2001,2003 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -34,6 +34,14 @@ # include <ctype.h> #endif +#ifndef __THROW +# if defined __cplusplus && __GNUC_PREREQ (2,8) +# define __THROW throw () +# else +# define __THROW +# endif +#endif + #ifdef __cplusplus extern "C" { #endif @@ -142,7 +150,8 @@ struct option /* Many other libraries have conflicting prototypes for getopt, with differences in the consts, in stdlib.h. To avoid compilation errors, only prototype getopt for the GNU C library. */ -extern int getopt (int ___argc, char *const *___argv, const char *__shortopts); +extern int getopt (int ___argc, char *const *___argv, const char *__shortopts) + __THROW; # else /* not __GNU_LIBRARY__ */ extern int getopt (); # endif /* __GNU_LIBRARY__ */ @@ -150,10 +159,12 @@ extern int getopt (); # ifndef __need_getopt extern int getopt_long (int ___argc, char *const *___argv, const char *__shortopts, - const struct option *__longopts, int *__longind); + const struct option *__longopts, int *__longind) + __THROW; extern int getopt_long_only (int ___argc, char *const *___argv, const char *__shortopts, - const struct option *__longopts, int *__longind); + const struct option *__longopts, int *__longind) + __THROW; /* Internal only. Users should not call this directly. */ extern int _getopt_internal (int ___argc, char *const *___argv, |