diff options
| author | Paul Eggert | 2011-07-08 03:02:24 -0700 |
|---|---|---|
| committer | Paul Eggert | 2011-07-08 03:02:24 -0700 |
| commit | 2287ac9896c30303d7f469a3e5cb348fbbbd9e23 (patch) | |
| tree | e2d382dce109ee7a9b51a5cd4f0d0e2641bb6540 | |
| parent | a63e0781250f31d99360209d9053d380d6fe0815 (diff) | |
| parent | 4a621aae149e694c8a53bebcc593d51811f69444 (diff) | |
| download | emacs-2287ac9896c30303d7f469a3e5cb348fbbbd9e23.tar.gz emacs-2287ac9896c30303d7f469a3e5cb348fbbbd9e23.zip | |
Merge from gnulib.
| -rw-r--r-- | ChangeLog | 4 | ||||
| -rw-r--r-- | lib/getopt.c | 11 | ||||
| -rw-r--r-- | lib/unistd.in.h | 141 | ||||
| -rw-r--r-- | m4/getopt.m4 | 83 |
4 files changed, 132 insertions, 107 deletions
| @@ -1,3 +1,7 @@ | |||
| 1 | 2011-07-08 Paul Eggert <eggert@cs.ucla.edu> | ||
| 2 | |||
| 3 | * lib/getopt.c, lib/unistd.in.h, m4/getopt.m4: Merge from gnulib. | ||
| 4 | |||
| 1 | 2011-07-07 Andreas Schwab <schwab@linux-m68k.org> | 5 | 2011-07-07 Andreas Schwab <schwab@linux-m68k.org> |
| 2 | 6 | ||
| 3 | * configure.in (maintainer-mode): Reflect default in help string. | 7 | * configure.in (maintainer-mode): Reflect default in help string. |
diff --git a/lib/getopt.c b/lib/getopt.c index 2af8352ee9c..7c9f7040612 100644 --- a/lib/getopt.c +++ b/lib/getopt.c | |||
| @@ -829,7 +829,7 @@ _getopt_internal_r (int argc, char **argv, const char *optstring, | |||
| 829 | return '?'; | 829 | return '?'; |
| 830 | } | 830 | } |
| 831 | /* Convenience. Treat POSIX -W foo same as long option --foo */ | 831 | /* Convenience. Treat POSIX -W foo same as long option --foo */ |
| 832 | if (temp[0] == 'W' && temp[1] == ';' && longopts) | 832 | if (temp[0] == 'W' && temp[1] == ';') |
| 833 | { | 833 | { |
| 834 | char *nameend; | 834 | char *nameend; |
| 835 | const struct option *p; | 835 | const struct option *p; |
| @@ -839,6 +839,9 @@ _getopt_internal_r (int argc, char **argv, const char *optstring, | |||
| 839 | int indfound = 0; | 839 | int indfound = 0; |
| 840 | int option_index; | 840 | int option_index; |
| 841 | 841 | ||
| 842 | if (longopts == NULL) | ||
| 843 | goto no_longs; | ||
| 844 | |||
| 842 | /* This is an option that requires an argument. */ | 845 | /* This is an option that requires an argument. */ |
| 843 | if (*d->__nextchar != '\0') | 846 | if (*d->__nextchar != '\0') |
| 844 | { | 847 | { |
| @@ -1046,8 +1049,10 @@ _getopt_internal_r (int argc, char **argv, const char *optstring, | |||
| 1046 | } | 1049 | } |
| 1047 | return pfound->val; | 1050 | return pfound->val; |
| 1048 | } | 1051 | } |
| 1049 | d->__nextchar = NULL; | 1052 | |
| 1050 | return 'W'; /* Let the application handle it. */ | 1053 | no_longs: |
| 1054 | d->__nextchar = NULL; | ||
| 1055 | return 'W'; /* Let the application handle it. */ | ||
| 1051 | } | 1056 | } |
| 1052 | if (temp[1] == ':') | 1057 | if (temp[1] == ':') |
| 1053 | { | 1058 | { |
diff --git a/lib/unistd.in.h b/lib/unistd.in.h index fdf0fca54e9..769ecf0d43f 100644 --- a/lib/unistd.in.h +++ b/lib/unistd.in.h | |||
| @@ -117,78 +117,77 @@ | |||
| 117 | /* The definition of _GL_WARN_ON_USE is copied here. */ | 117 | /* The definition of _GL_WARN_ON_USE is copied here. */ |
| 118 | 118 | ||
| 119 | 119 | ||
| 120 | #if @GNULIB_GETHOSTNAME@ | 120 | /* Hide some function declarations from <winsock2.h>. */ |
| 121 | /* Get all possible declarations of gethostname(). */ | 121 | |
| 122 | # if @UNISTD_H_HAVE_WINSOCK2_H@ | 122 | #if @GNULIB_GETHOSTNAME@ && @UNISTD_H_HAVE_WINSOCK2_H@ |
| 123 | # if !defined _@GUARD_PREFIX@_SYS_SOCKET_H | 123 | # if !defined _@GUARD_PREFIX@_SYS_SOCKET_H |
| 124 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | 124 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
| 125 | # undef socket | 125 | # undef socket |
| 126 | # define socket socket_used_without_including_sys_socket_h | 126 | # define socket socket_used_without_including_sys_socket_h |
| 127 | # undef connect | 127 | # undef connect |
| 128 | # define connect connect_used_without_including_sys_socket_h | 128 | # define connect connect_used_without_including_sys_socket_h |
| 129 | # undef accept | 129 | # undef accept |
| 130 | # define accept accept_used_without_including_sys_socket_h | 130 | # define accept accept_used_without_including_sys_socket_h |
| 131 | # undef bind | 131 | # undef bind |
| 132 | # define bind bind_used_without_including_sys_socket_h | 132 | # define bind bind_used_without_including_sys_socket_h |
| 133 | # undef getpeername | 133 | # undef getpeername |
| 134 | # define getpeername getpeername_used_without_including_sys_socket_h | 134 | # define getpeername getpeername_used_without_including_sys_socket_h |
| 135 | # undef getsockname | 135 | # undef getsockname |
| 136 | # define getsockname getsockname_used_without_including_sys_socket_h | 136 | # define getsockname getsockname_used_without_including_sys_socket_h |
| 137 | # undef getsockopt | 137 | # undef getsockopt |
| 138 | # define getsockopt getsockopt_used_without_including_sys_socket_h | 138 | # define getsockopt getsockopt_used_without_including_sys_socket_h |
| 139 | # undef listen | 139 | # undef listen |
| 140 | # define listen listen_used_without_including_sys_socket_h | 140 | # define listen listen_used_without_including_sys_socket_h |
| 141 | # undef recv | 141 | # undef recv |
| 142 | # define recv recv_used_without_including_sys_socket_h | 142 | # define recv recv_used_without_including_sys_socket_h |
| 143 | # undef send | 143 | # undef send |
| 144 | # define send send_used_without_including_sys_socket_h | 144 | # define send send_used_without_including_sys_socket_h |
| 145 | # undef recvfrom | 145 | # undef recvfrom |
| 146 | # define recvfrom recvfrom_used_without_including_sys_socket_h | 146 | # define recvfrom recvfrom_used_without_including_sys_socket_h |
| 147 | # undef sendto | 147 | # undef sendto |
| 148 | # define sendto sendto_used_without_including_sys_socket_h | 148 | # define sendto sendto_used_without_including_sys_socket_h |
| 149 | # undef setsockopt | 149 | # undef setsockopt |
| 150 | # define setsockopt setsockopt_used_without_including_sys_socket_h | 150 | # define setsockopt setsockopt_used_without_including_sys_socket_h |
| 151 | # undef shutdown | 151 | # undef shutdown |
| 152 | # define shutdown shutdown_used_without_including_sys_socket_h | 152 | # define shutdown shutdown_used_without_including_sys_socket_h |
| 153 | # else | 153 | # else |
| 154 | _GL_WARN_ON_USE (socket, | 154 | _GL_WARN_ON_USE (socket, |
| 155 | "socket() used without including <sys/socket.h>"); | 155 | "socket() used without including <sys/socket.h>"); |
| 156 | _GL_WARN_ON_USE (connect, | 156 | _GL_WARN_ON_USE (connect, |
| 157 | "connect() used without including <sys/socket.h>"); | 157 | "connect() used without including <sys/socket.h>"); |
| 158 | _GL_WARN_ON_USE (accept, | 158 | _GL_WARN_ON_USE (accept, |
| 159 | "accept() used without including <sys/socket.h>"); | 159 | "accept() used without including <sys/socket.h>"); |
| 160 | _GL_WARN_ON_USE (bind, | 160 | _GL_WARN_ON_USE (bind, |
| 161 | "bind() used without including <sys/socket.h>"); | 161 | "bind() used without including <sys/socket.h>"); |
| 162 | _GL_WARN_ON_USE (getpeername, | 162 | _GL_WARN_ON_USE (getpeername, |
| 163 | "getpeername() used without including <sys/socket.h>"); | 163 | "getpeername() used without including <sys/socket.h>"); |
| 164 | _GL_WARN_ON_USE (getsockname, | 164 | _GL_WARN_ON_USE (getsockname, |
| 165 | "getsockname() used without including <sys/socket.h>"); | 165 | "getsockname() used without including <sys/socket.h>"); |
| 166 | _GL_WARN_ON_USE (getsockopt, | 166 | _GL_WARN_ON_USE (getsockopt, |
| 167 | "getsockopt() used without including <sys/socket.h>"); | 167 | "getsockopt() used without including <sys/socket.h>"); |
| 168 | _GL_WARN_ON_USE (listen, | 168 | _GL_WARN_ON_USE (listen, |
| 169 | "listen() used without including <sys/socket.h>"); | 169 | "listen() used without including <sys/socket.h>"); |
| 170 | _GL_WARN_ON_USE (recv, | 170 | _GL_WARN_ON_USE (recv, |
| 171 | "recv() used without including <sys/socket.h>"); | 171 | "recv() used without including <sys/socket.h>"); |
| 172 | _GL_WARN_ON_USE (send, | 172 | _GL_WARN_ON_USE (send, |
| 173 | "send() used without including <sys/socket.h>"); | 173 | "send() used without including <sys/socket.h>"); |
| 174 | _GL_WARN_ON_USE (recvfrom, | 174 | _GL_WARN_ON_USE (recvfrom, |
| 175 | "recvfrom() used without including <sys/socket.h>"); | 175 | "recvfrom() used without including <sys/socket.h>"); |
| 176 | _GL_WARN_ON_USE (sendto, | 176 | _GL_WARN_ON_USE (sendto, |
| 177 | "sendto() used without including <sys/socket.h>"); | 177 | "sendto() used without including <sys/socket.h>"); |
| 178 | _GL_WARN_ON_USE (setsockopt, | 178 | _GL_WARN_ON_USE (setsockopt, |
| 179 | "setsockopt() used without including <sys/socket.h>"); | 179 | "setsockopt() used without including <sys/socket.h>"); |
| 180 | _GL_WARN_ON_USE (shutdown, | 180 | _GL_WARN_ON_USE (shutdown, |
| 181 | "shutdown() used without including <sys/socket.h>"); | 181 | "shutdown() used without including <sys/socket.h>"); |
| 182 | # endif | ||
| 183 | # endif | 182 | # endif |
| 184 | # if !defined _@GUARD_PREFIX@_SYS_SELECT_H | 183 | # endif |
| 185 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | 184 | # if !defined _@GUARD_PREFIX@_SYS_SELECT_H |
| 186 | # undef select | 185 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
| 187 | # define select select_used_without_including_sys_select_h | 186 | # undef select |
| 188 | # else | 187 | # define select select_used_without_including_sys_select_h |
| 189 | _GL_WARN_ON_USE (select, | 188 | # else |
| 190 | "select() used without including <sys/select.h>"); | 189 | _GL_WARN_ON_USE (select, |
| 191 | # endif | 190 | "select() used without including <sys/select.h>"); |
| 192 | # endif | 191 | # endif |
| 193 | # endif | 192 | # endif |
| 194 | #endif | 193 | #endif |
diff --git a/m4/getopt.m4 b/m4/getopt.m4 index 4d8450ff907..7e49ddde9f6 100644 --- a/m4/getopt.m4 +++ b/m4/getopt.m4 | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | # getopt.m4 serial 35 | 1 | # getopt.m4 serial 38 |
| 2 | dnl Copyright (C) 2002-2006, 2008-2011 Free Software Foundation, Inc. | 2 | dnl Copyright (C) 2002-2006, 2008-2011 Free Software Foundation, Inc. |
| 3 | dnl This file is free software; the Free Software Foundation | 3 | dnl This file is free software; the Free Software Foundation |
| 4 | dnl gives unlimited permission to copy and/or distribute it, | 4 | dnl gives unlimited permission to copy and/or distribute it, |
| @@ -89,15 +89,15 @@ AC_DEFUN([gl_GETOPT_CHECK_HEADERS], | |||
| 89 | AC_CACHE_CHECK([whether getopt is POSIX compatible], | 89 | AC_CACHE_CHECK([whether getopt is POSIX compatible], |
| 90 | [gl_cv_func_getopt_posix], | 90 | [gl_cv_func_getopt_posix], |
| 91 | [ | 91 | [ |
| 92 | dnl BSD getopt_long uses an incompatible method to reset | 92 | dnl BSD getopt_long uses an incompatible method to reset option |
| 93 | dnl option processing. Existence of the variable, in and of | 93 | dnl processing. Existence of the optreset variable, in and of |
| 94 | dnl itself, is not a reason to replace getopt, but knowledge | 94 | dnl itself, is not a reason to replace getopt, but knowledge |
| 95 | dnl of the variable is needed to determine how to reset and | 95 | dnl of the variable is needed to determine how to reset and |
| 96 | dnl whether a reset reparses the environment. Solaris | 96 | dnl whether a reset reparses the environment. Solaris |
| 97 | dnl supports neither optreset nor optind=0, but keeps no state | 97 | dnl supports neither optreset nor optind=0, but keeps no state |
| 98 | dnl that needs a reset beyond setting optind=1; detect Solaris | 98 | dnl that needs a reset beyond setting optind=1; detect Solaris |
| 99 | dnl by getopt_clip. | 99 | dnl by getopt_clip. |
| 100 | AC_COMPILE_IFELSE( | 100 | AC_LINK_IFELSE( |
| 101 | [AC_LANG_PROGRAM( | 101 | [AC_LANG_PROGRAM( |
| 102 | [[#include <unistd.h>]], | 102 | [[#include <unistd.h>]], |
| 103 | [[int *p = &optreset; return optreset;]])], | 103 | [[int *p = &optreset; return optreset;]])], |
| @@ -121,22 +121,20 @@ int | |||
| 121 | main () | 121 | main () |
| 122 | { | 122 | { |
| 123 | { | 123 | { |
| 124 | int argc = 0; | 124 | static char program[] = "program"; |
| 125 | char *argv[10]; | 125 | static char a[] = "-a"; |
| 126 | static char foo[] = "foo"; | ||
| 127 | static char bar[] = "bar"; | ||
| 128 | char *argv[] = { program, a, foo, bar, NULL }; | ||
| 126 | int c; | 129 | int c; |
| 127 | 130 | ||
| 128 | argv[argc++] = "program"; | ||
| 129 | argv[argc++] = "-a"; | ||
| 130 | argv[argc++] = "foo"; | ||
| 131 | argv[argc++] = "bar"; | ||
| 132 | argv[argc] = NULL; | ||
| 133 | optind = OPTIND_MIN; | 131 | optind = OPTIND_MIN; |
| 134 | opterr = 0; | 132 | opterr = 0; |
| 135 | 133 | ||
| 136 | c = getopt (argc, argv, "ab"); | 134 | c = getopt (4, argv, "ab"); |
| 137 | if (!(c == 'a')) | 135 | if (!(c == 'a')) |
| 138 | return 1; | 136 | return 1; |
| 139 | c = getopt (argc, argv, "ab"); | 137 | c = getopt (4, argv, "ab"); |
| 140 | if (!(c == -1)) | 138 | if (!(c == -1)) |
| 141 | return 2; | 139 | return 2; |
| 142 | if (!(optind == 2)) | 140 | if (!(optind == 2)) |
| @@ -144,22 +142,20 @@ main () | |||
| 144 | } | 142 | } |
| 145 | /* Some internal state exists at this point. */ | 143 | /* Some internal state exists at this point. */ |
| 146 | { | 144 | { |
| 147 | int argc = 0; | 145 | static char program[] = "program"; |
| 148 | char *argv[10]; | 146 | static char donald[] = "donald"; |
| 147 | static char p[] = "-p"; | ||
| 148 | static char billy[] = "billy"; | ||
| 149 | static char duck[] = "duck"; | ||
| 150 | static char a[] = "-a"; | ||
| 151 | static char bar[] = "bar"; | ||
| 152 | char *argv[] = { program, donald, p, billy, duck, a, bar, NULL }; | ||
| 149 | int c; | 153 | int c; |
| 150 | 154 | ||
| 151 | argv[argc++] = "program"; | ||
| 152 | argv[argc++] = "donald"; | ||
| 153 | argv[argc++] = "-p"; | ||
| 154 | argv[argc++] = "billy"; | ||
| 155 | argv[argc++] = "duck"; | ||
| 156 | argv[argc++] = "-a"; | ||
| 157 | argv[argc++] = "bar"; | ||
| 158 | argv[argc] = NULL; | ||
| 159 | optind = OPTIND_MIN; | 155 | optind = OPTIND_MIN; |
| 160 | opterr = 0; | 156 | opterr = 0; |
| 161 | 157 | ||
| 162 | c = getopt (argc, argv, "+abp:q:"); | 158 | c = getopt (7, argv, "+abp:q:"); |
| 163 | if (!(c == -1)) | 159 | if (!(c == -1)) |
| 164 | return 4; | 160 | return 4; |
| 165 | if (!(strcmp (argv[0], "program") == 0)) | 161 | if (!(strcmp (argv[0], "program") == 0)) |
| @@ -181,7 +177,9 @@ main () | |||
| 181 | } | 177 | } |
| 182 | /* Detect MacOS 10.5, AIX 7.1 bug. */ | 178 | /* Detect MacOS 10.5, AIX 7.1 bug. */ |
| 183 | { | 179 | { |
| 184 | char *argv[3] = { "program", "-ab", NULL }; | 180 | static char program[] = "program"; |
| 181 | static char ab[] = "-ab"; | ||
| 182 | char *argv[3] = { program, ab, NULL }; | ||
| 185 | optind = OPTIND_MIN; | 183 | optind = OPTIND_MIN; |
| 186 | opterr = 0; | 184 | opterr = 0; |
| 187 | if (getopt (2, argv, "ab:") != 'a') | 185 | if (getopt (2, argv, "ab:") != 'a') |
| @@ -239,19 +237,22 @@ dnl is ambiguous with environment values that contain newlines. | |||
| 239 | and fails on MacOS X 10.5, AIX 5.2, HP-UX 11, IRIX 6.5, | 237 | and fails on MacOS X 10.5, AIX 5.2, HP-UX 11, IRIX 6.5, |
| 240 | OSF/1 5.1, Solaris 10. */ | 238 | OSF/1 5.1, Solaris 10. */ |
| 241 | { | 239 | { |
| 242 | char *myargv[3]; | 240 | static char conftest[] = "conftest"; |
| 243 | myargv[0] = "conftest"; | 241 | static char plus[] = "-+"; |
| 244 | myargv[1] = "-+"; | 242 | char *argv[3] = { conftest, plus, NULL }; |
| 245 | myargv[2] = 0; | ||
| 246 | opterr = 0; | 243 | opterr = 0; |
| 247 | if (getopt (2, myargv, "+a") != '?') | 244 | if (getopt (2, argv, "+a") != '?') |
| 248 | result |= 1; | 245 | result |= 1; |
| 249 | } | 246 | } |
| 250 | /* This code succeeds on glibc 2.8, mingw, | 247 | /* This code succeeds on glibc 2.8, mingw, |
| 251 | and fails on MacOS X 10.5, OpenBSD 4.0, AIX 5.2, HP-UX 11, | 248 | and fails on MacOS X 10.5, OpenBSD 4.0, AIX 5.2, HP-UX 11, |
| 252 | IRIX 6.5, OSF/1 5.1, Solaris 10, Cygwin 1.5.x. */ | 249 | IRIX 6.5, OSF/1 5.1, Solaris 10, Cygwin 1.5.x. */ |
| 253 | { | 250 | { |
| 254 | char *argv[] = { "program", "-p", "foo", "bar", NULL }; | 251 | static char program[] = "program"; |
| 252 | static char p[] = "-p"; | ||
| 253 | static char foo[] = "foo"; | ||
| 254 | static char bar[] = "bar"; | ||
| 255 | char *argv[] = { program, p, foo, bar, NULL }; | ||
| 255 | 256 | ||
| 256 | optind = 1; | 257 | optind = 1; |
| 257 | if (getopt (4, argv, "p::") != 'p') | 258 | if (getopt (4, argv, "p::") != 'p') |
| @@ -265,7 +266,10 @@ dnl is ambiguous with environment values that contain newlines. | |||
| 265 | } | 266 | } |
| 266 | /* This code succeeds on glibc 2.8 and fails on Cygwin 1.7.0. */ | 267 | /* This code succeeds on glibc 2.8 and fails on Cygwin 1.7.0. */ |
| 267 | { | 268 | { |
| 268 | char *argv[] = { "program", "foo", "-p", NULL }; | 269 | static char program[] = "program"; |
| 270 | static char foo[] = "foo"; | ||
| 271 | static char p[] = "-p"; | ||
| 272 | char *argv[] = { program, foo, p, NULL }; | ||
| 269 | optind = 0; | 273 | optind = 0; |
| 270 | if (getopt (3, argv, "-p") != 1) | 274 | if (getopt (3, argv, "-p") != 1) |
| 271 | result |= 16; | 275 | result |= 16; |
| @@ -274,13 +278,26 @@ dnl is ambiguous with environment values that contain newlines. | |||
| 274 | } | 278 | } |
| 275 | /* This code fails on glibc 2.11. */ | 279 | /* This code fails on glibc 2.11. */ |
| 276 | { | 280 | { |
| 277 | char *argv[] = { "program", "-b", "-a", NULL }; | 281 | static char program[] = "program"; |
| 282 | static char b[] = "-b"; | ||
| 283 | static char a[] = "-a"; | ||
| 284 | char *argv[] = { program, b, a, NULL }; | ||
| 278 | optind = opterr = 0; | 285 | optind = opterr = 0; |
| 279 | if (getopt (3, argv, "+:a:b") != 'b') | 286 | if (getopt (3, argv, "+:a:b") != 'b') |
| 280 | result |= 64; | 287 | result |= 64; |
| 281 | else if (getopt (3, argv, "+:a:b") != ':') | 288 | else if (getopt (3, argv, "+:a:b") != ':') |
| 282 | result |= 64; | 289 | result |= 64; |
| 283 | } | 290 | } |
| 291 | /* This code dumps core on glibc 2.14. */ | ||
| 292 | { | ||
| 293 | static char program[] = "program"; | ||
| 294 | static char w[] = "-W"; | ||
| 295 | static char dummy[] = "dummy"; | ||
| 296 | char *argv[] = { program, w, dummy, NULL }; | ||
| 297 | optind = opterr = 1; | ||
| 298 | if (getopt (3, argv, "W;") != 'W') | ||
| 299 | result |= 128; | ||
| 300 | } | ||
| 284 | return result; | 301 | return result; |
| 285 | ]])], | 302 | ]])], |
| 286 | [gl_cv_func_getopt_gnu=yes], | 303 | [gl_cv_func_getopt_gnu=yes], |