aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorPaul Eggert2017-03-23 08:51:44 -0700
committerPaul Eggert2017-03-23 08:53:21 -0700
commite6d3eaa69871d800eb078580b64f2bc5806a0fcc (patch)
tree8bfe6653b6be56f06adee8e0cfbf2b366b8ac8a6 /lib
parente1392faae5c5cc7805b52efacbb25a71213afdeb (diff)
downloademacs-e6d3eaa69871d800eb078580b64f2bc5806a0fcc.tar.gz
emacs-e6d3eaa69871d800eb078580b64f2bc5806a0fcc.zip
Merge from gnulib
This incorporates: 2017-03-22 getopt: merge from glibc * build-aux/config.sub, lib/getopt.c, lib/getopt.in.h: * lib/getopt1.c, lib/getopt_int.h: Copy from gnulib. * lib/gnulib.mk.in: Regenerate.
Diffstat (limited to 'lib')
-rw-r--r--lib/getopt.c70
-rw-r--r--lib/getopt.in.h41
-rw-r--r--lib/getopt1.c22
-rw-r--r--lib/getopt_int.h22
-rw-r--r--lib/gnulib.mk.in1
5 files changed, 87 insertions, 69 deletions
diff --git a/lib/getopt.c b/lib/getopt.c
index e40ea8d5eaa..7afd0dcabe8 100644
--- a/lib/getopt.c
+++ b/lib/getopt.c
@@ -2,22 +2,22 @@
2 NOTE: getopt is part of the C library, so if you don't know what 2 NOTE: getopt is part of the C library, so if you don't know what
3 "Keep this file name-space clean" means, talk to drepper@gnu.org 3 "Keep this file name-space clean" means, talk to drepper@gnu.org
4 before changing it! 4 before changing it!
5 Copyright (C) 1987-1996, 1998-2004, 2006, 2008-2017 Free Software 5 Copyright (C) 1987-2017 Free Software Foundation, Inc.
6 Foundation, Inc.
7 This file is part of the GNU C Library. 6 This file is part of the GNU C Library.
8 7
9 This program is free software: you can redistribute it and/or modify 8 The GNU C Library is free software; you can redistribute it and/or
10 it under the terms of the GNU General Public License as published by 9 modify it under the terms of the GNU General Public
11 the Free Software Foundation; either version 3 of the License, or 10 License as published by the Free Software Foundation; either
12 (at your option) any later version. 11 version 3 of the License, or (at your option) any later version.
13 12
14 This program is distributed in the hope that it will be useful, 13 The GNU C Library is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of 14 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 GNU General Public License for more details. 16 General Public License for more details.
18 17
19 You should have received a copy of the GNU General Public License 18 You should have received a copy of the GNU General Public
20 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 19 License along with the GNU C Library; if not, see
20 <http://www.gnu.org/licenses/>. */
21 21
22#ifndef _LIBC 22#ifndef _LIBC
23# include <config.h> 23# include <config.h>
@@ -27,8 +27,8 @@
27 27
28#include <stdio.h> 28#include <stdio.h>
29#include <stdlib.h> 29#include <stdlib.h>
30#include <string.h>
31#include <unistd.h> 30#include <unistd.h>
31#include <string.h>
32 32
33#ifdef _LIBC 33#ifdef _LIBC
34# include <libintl.h> 34# include <libintl.h>
@@ -37,7 +37,7 @@
37# define _(msgid) gettext (msgid) 37# define _(msgid) gettext (msgid)
38#endif 38#endif
39 39
40#if defined _LIBC && defined USE_IN_LIBIO 40#if defined _LIBC
41# include <wchar.h> 41# include <wchar.h>
42#endif 42#endif
43 43
@@ -181,7 +181,7 @@ exchange (char **argv, struct _getopt_data *d)
181 { 181 {
182 /* Bottom segment is the short one. */ 182 /* Bottom segment is the short one. */
183 int len = middle - bottom; 183 int len = middle - bottom;
184 register int i; 184 int i;
185 185
186 /* Swap it with the top part of the top segment. */ 186 /* Swap it with the top part of the top segment. */
187 for (i = 0; i < len; i++) 187 for (i = 0; i < len; i++)
@@ -198,7 +198,7 @@ exchange (char **argv, struct _getopt_data *d)
198 { 198 {
199 /* Top segment is the short one. */ 199 /* Top segment is the short one. */
200 int len = top - middle; 200 int len = top - middle;
201 register int i; 201 int i;
202 202
203 /* Swap it with the bottom part of the bottom segment. */ 203 /* Swap it with the bottom part of the bottom segment. */
204 for (i = 0; i < len; i++) 204 for (i = 0; i < len; i++)
@@ -564,11 +564,11 @@ _getopt_internal_r (int argc, char **argv, const char *optstring,
564 first.next = ambig_list; 564 first.next = ambig_list;
565 ambig_list = &first; 565 ambig_list = &first;
566 566
567#if defined _LIBC && defined USE_IN_LIBIO 567#if defined _LIBC
568 char *buf = NULL; 568 char *buf = NULL;
569 size_t buflen = 0; 569 size_t buflen = 0;
570 570
571 FILE *fp = open_memstream (&buf, &buflen); 571 FILE *fp = __open_memstream (&buf, &buflen);
572 if (fp != NULL) 572 if (fp != NULL)
573 { 573 {
574 fprintf (fp, 574 fprintf (fp,
@@ -584,7 +584,7 @@ _getopt_internal_r (int argc, char **argv, const char *optstring,
584 584
585 fputc_unlocked ('\n', fp); 585 fputc_unlocked ('\n', fp);
586 586
587 if (__builtin_expect (fclose (fp) != EOF, 1)) 587 if (__glibc_likely (fclose (fp) != EOF))
588 { 588 {
589 _IO_flockfile (stderr); 589 _IO_flockfile (stderr);
590 590
@@ -642,7 +642,7 @@ _getopt_internal_r (int argc, char **argv, const char *optstring,
642 { 642 {
643 if (print_errors) 643 if (print_errors)
644 { 644 {
645#if defined _LIBC && defined USE_IN_LIBIO 645#if defined _LIBC
646 char *buf; 646 char *buf;
647 int n; 647 int n;
648#endif 648#endif
@@ -650,7 +650,7 @@ _getopt_internal_r (int argc, char **argv, const char *optstring,
650 if (argv[d->optind - 1][1] == '-') 650 if (argv[d->optind - 1][1] == '-')
651 { 651 {
652 /* --option */ 652 /* --option */
653#if defined _LIBC && defined USE_IN_LIBIO 653#if defined _LIBC
654 n = __asprintf (&buf, _("\ 654 n = __asprintf (&buf, _("\
655%s: option '--%s' doesn't allow an argument\n"), 655%s: option '--%s' doesn't allow an argument\n"),
656 argv[0], pfound->name); 656 argv[0], pfound->name);
@@ -663,7 +663,7 @@ _getopt_internal_r (int argc, char **argv, const char *optstring,
663 else 663 else
664 { 664 {
665 /* +option or -option */ 665 /* +option or -option */
666#if defined _LIBC && defined USE_IN_LIBIO 666#if defined _LIBC
667 n = __asprintf (&buf, _("\ 667 n = __asprintf (&buf, _("\
668%s: option '%c%s' doesn't allow an argument\n"), 668%s: option '%c%s' doesn't allow an argument\n"),
669 argv[0], argv[d->optind - 1][0], 669 argv[0], argv[d->optind - 1][0],
@@ -676,7 +676,7 @@ _getopt_internal_r (int argc, char **argv, const char *optstring,
676#endif 676#endif
677 } 677 }
678 678
679#if defined _LIBC && defined USE_IN_LIBIO 679#if defined _LIBC
680 if (n >= 0) 680 if (n >= 0)
681 { 681 {
682 _IO_flockfile (stderr); 682 _IO_flockfile (stderr);
@@ -709,7 +709,7 @@ _getopt_internal_r (int argc, char **argv, const char *optstring,
709 { 709 {
710 if (print_errors) 710 if (print_errors)
711 { 711 {
712#if defined _LIBC && defined USE_IN_LIBIO 712#if defined _LIBC
713 char *buf; 713 char *buf;
714 714
715 if (__asprintf (&buf, _("\ 715 if (__asprintf (&buf, _("\
@@ -760,7 +760,7 @@ _getopt_internal_r (int argc, char **argv, const char *optstring,
760 { 760 {
761 if (print_errors) 761 if (print_errors)
762 { 762 {
763#if defined _LIBC && defined USE_IN_LIBIO 763#if defined _LIBC
764 char *buf; 764 char *buf;
765 int n; 765 int n;
766#endif 766#endif
@@ -768,7 +768,7 @@ _getopt_internal_r (int argc, char **argv, const char *optstring,
768 if (argv[d->optind][1] == '-') 768 if (argv[d->optind][1] == '-')
769 { 769 {
770 /* --option */ 770 /* --option */
771#if defined _LIBC && defined USE_IN_LIBIO 771#if defined _LIBC
772 n = __asprintf (&buf, _("%s: unrecognized option '--%s'\n"), 772 n = __asprintf (&buf, _("%s: unrecognized option '--%s'\n"),
773 argv[0], d->__nextchar); 773 argv[0], d->__nextchar);
774#else 774#else
@@ -779,7 +779,7 @@ _getopt_internal_r (int argc, char **argv, const char *optstring,
779 else 779 else
780 { 780 {
781 /* +option or -option */ 781 /* +option or -option */
782#if defined _LIBC && defined USE_IN_LIBIO 782#if defined _LIBC
783 n = __asprintf (&buf, _("%s: unrecognized option '%c%s'\n"), 783 n = __asprintf (&buf, _("%s: unrecognized option '%c%s'\n"),
784 argv[0], argv[d->optind][0], d->__nextchar); 784 argv[0], argv[d->optind][0], d->__nextchar);
785#else 785#else
@@ -788,7 +788,7 @@ _getopt_internal_r (int argc, char **argv, const char *optstring,
788#endif 788#endif
789 } 789 }
790 790
791#if defined _LIBC && defined USE_IN_LIBIO 791#if defined _LIBC
792 if (n >= 0) 792 if (n >= 0)
793 { 793 {
794 _IO_flockfile (stderr); 794 _IO_flockfile (stderr);
@@ -826,19 +826,19 @@ _getopt_internal_r (int argc, char **argv, const char *optstring,
826 { 826 {
827 if (print_errors) 827 if (print_errors)
828 { 828 {
829#if defined _LIBC && defined USE_IN_LIBIO 829#if defined _LIBC
830 char *buf; 830 char *buf;
831 int n; 831 int n;
832#endif 832#endif
833 833
834#if defined _LIBC && defined USE_IN_LIBIO 834#if defined _LIBC
835 n = __asprintf (&buf, _("%s: invalid option -- '%c'\n"), 835 n = __asprintf (&buf, _("%s: invalid option -- '%c'\n"),
836 argv[0], c); 836 argv[0], c);
837#else 837#else
838 fprintf (stderr, _("%s: invalid option -- '%c'\n"), argv[0], c); 838 fprintf (stderr, _("%s: invalid option -- '%c'\n"), argv[0], c);
839#endif 839#endif
840 840
841#if defined _LIBC && defined USE_IN_LIBIO 841#if defined _LIBC
842 if (n >= 0) 842 if (n >= 0)
843 { 843 {
844 _IO_flockfile (stderr); 844 _IO_flockfile (stderr);
@@ -884,7 +884,7 @@ _getopt_internal_r (int argc, char **argv, const char *optstring,
884 { 884 {
885 if (print_errors) 885 if (print_errors)
886 { 886 {
887#if defined _LIBC && defined USE_IN_LIBIO 887#if defined _LIBC
888 char *buf; 888 char *buf;
889 889
890 if (__asprintf (&buf, 890 if (__asprintf (&buf,
@@ -958,7 +958,7 @@ _getopt_internal_r (int argc, char **argv, const char *optstring,
958 { 958 {
959 if (print_errors) 959 if (print_errors)
960 { 960 {
961#if defined _LIBC && defined USE_IN_LIBIO 961#if defined _LIBC
962 char *buf; 962 char *buf;
963 963
964 if (__asprintf (&buf, _("%s: option '-W %s' is ambiguous\n"), 964 if (__asprintf (&buf, _("%s: option '-W %s' is ambiguous\n"),
@@ -998,7 +998,7 @@ _getopt_internal_r (int argc, char **argv, const char *optstring,
998 { 998 {
999 if (print_errors) 999 if (print_errors)
1000 { 1000 {
1001#if defined _LIBC && defined USE_IN_LIBIO 1001#if defined _LIBC
1002 char *buf; 1002 char *buf;
1003 1003
1004 if (__asprintf (&buf, _("\ 1004 if (__asprintf (&buf, _("\
@@ -1037,7 +1037,7 @@ _getopt_internal_r (int argc, char **argv, const char *optstring,
1037 { 1037 {
1038 if (print_errors) 1038 if (print_errors)
1039 { 1039 {
1040#if defined _LIBC && defined USE_IN_LIBIO 1040#if defined _LIBC
1041 char *buf; 1041 char *buf;
1042 1042
1043 if (__asprintf (&buf, _("\ 1043 if (__asprintf (&buf, _("\
@@ -1112,7 +1112,7 @@ _getopt_internal_r (int argc, char **argv, const char *optstring,
1112 { 1112 {
1113 if (print_errors) 1113 if (print_errors)
1114 { 1114 {
1115#if defined _LIBC && defined USE_IN_LIBIO 1115#if defined _LIBC
1116 char *buf; 1116 char *buf;
1117 1117
1118 if (__asprintf (&buf, _("\ 1118 if (__asprintf (&buf, _("\
diff --git a/lib/getopt.in.h b/lib/getopt.in.h
index 6cbad8e0339..3f57c68a25e 100644
--- a/lib/getopt.in.h
+++ b/lib/getopt.in.h
@@ -1,20 +1,20 @@
1/* Declarations for getopt. 1/* Declarations for getopt.
2 Copyright (C) 1989-1994, 1996-1999, 2001, 2003-2007, 2009-2017 Free Software 2 Copyright (C) 1989-2017 Free Software Foundation, Inc.
3 Foundation, Inc.
4 This file is part of the GNU C Library. 3 This file is part of the GNU C Library.
5 4
6 This program is free software: you can redistribute it and/or modify 5 The GNU C Library is free software; you can redistribute it and/or
7 it under the terms of the GNU General Public License as published by 6 modify it under the terms of the GNU General Public
8 the Free Software Foundation; either version 3 of the License, or 7 License as published by the Free Software Foundation; either
9 (at your option) any later version. 8 version 3 of the License, or (at your option) any later version.
10 9
11 This program is distributed in the hope that it will be useful, 10 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 GNU General Public License for more details. 13 General Public License for more details.
15 14
16 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public
17 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18 18
19#ifndef _@GUARD_PREFIX@_GETOPT_H 19#ifndef _@GUARD_PREFIX@_GETOPT_H
20 20
@@ -238,6 +238,25 @@ struct option
238extern int getopt (int ___argc, char *const *___argv, const char *__shortopts) 238extern int getopt (int ___argc, char *const *___argv, const char *__shortopts)
239 __THROW _GL_ARG_NONNULL ((2, 3)); 239 __THROW _GL_ARG_NONNULL ((2, 3));
240 240
241#ifndef __GETOPT_PREFIX
242# if defined __need_getopt && defined __USE_POSIX2 \
243 && !defined __USE_POSIX_IMPLICITLY && !defined __USE_GNU
244/* The GNU getopt has more functionality than the standard version. The
245 additional functionality can be disable at runtime. This redirection
246 helps to also do this at runtime. */
247# ifdef __REDIRECT
248 extern int __REDIRECT_NTH (getopt, (int ___argc, char *const *___argv,
249 const char *__shortopts),
250 __posix_getopt);
251# else
252extern int __posix_getopt (int ___argc, char *const *___argv,
253 const char *__shortopts)
254 __THROW _GL_ARG_NONNULL ((2, 3));
255# define getopt __posix_getopt
256# endif
257# endif
258#endif
259
241#ifndef __need_getopt 260#ifndef __need_getopt
242extern int getopt_long (int ___argc, char *__getopt_argv_const *___argv, 261extern int getopt_long (int ___argc, char *__getopt_argv_const *___argv,
243 const char *__shortopts, 262 const char *__shortopts,
diff --git a/lib/getopt1.c b/lib/getopt1.c
index 4d2e8cbac33..166b1295333 100644
--- a/lib/getopt1.c
+++ b/lib/getopt1.c
@@ -1,20 +1,20 @@
1/* getopt_long and getopt_long_only entry points for GNU getopt. 1/* getopt_long and getopt_long_only entry points for GNU getopt.
2 Copyright (C) 1987-1994, 1996-1998, 2004, 2006, 2009-2017 Free Software 2 Copyright (C) 1987-2017 Free Software Foundation, Inc.
3 Foundation, Inc.
4 This file is part of the GNU C Library. 3 This file is part of the GNU C Library.
5 4
6 This program is free software: you can redistribute it and/or modify 5 The GNU C Library is free software; you can redistribute it and/or
7 it under the terms of the GNU General Public License as published by 6 modify it under the terms of the GNU General Public
8 the Free Software Foundation; either version 3 of the License, or 7 License as published by the Free Software Foundation; either
9 (at your option) any later version. 8 version 3 of the License, or (at your option) any later version.
10 9
11 This program is distributed in the hope that it will be useful, 10 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 GNU General Public License for more details. 13 General Public License for more details.
15 14
16 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public
17 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18 18
19#ifdef _LIBC 19#ifdef _LIBC
20# include <getopt.h> 20# include <getopt.h>
diff --git a/lib/getopt_int.h b/lib/getopt_int.h
index a7ce0e9cc14..c614fcb65be 100644
--- a/lib/getopt_int.h
+++ b/lib/getopt_int.h
@@ -1,20 +1,20 @@
1/* Internal declarations for getopt. 1/* Internal declarations for getopt.
2 Copyright (C) 1989-1994, 1996-1999, 2001, 2003-2004, 2009-2017 Free Software 2 Copyright (C) 1989-2017 Free Software Foundation, Inc.
3 Foundation, Inc.
4 This file is part of the GNU C Library. 3 This file is part of the GNU C Library.
5 4
6 This program is free software: you can redistribute it and/or modify 5 The GNU C Library is free software; you can redistribute it and/or
7 it under the terms of the GNU General Public License as published by 6 modify it under the terms of the GNU General Public
8 the Free Software Foundation; either version 3 of the License, or 7 License as published by the Free Software Foundation; either
9 (at your option) any later version. 8 version 3 of the License, or (at your option) any later version.
10 9
11 This program is distributed in the hope that it will be useful, 10 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 GNU General Public License for more details. 13 General Public License for more details.
15 14
16 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public
17 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18 18
19#ifndef _GETOPT_INT_H 19#ifndef _GETOPT_INT_H
20#define _GETOPT_INT_H 1 20#define _GETOPT_INT_H 1
diff --git a/lib/gnulib.mk.in b/lib/gnulib.mk.in
index 2c0b689e710..ca95ed7e825 100644
--- a/lib/gnulib.mk.in
+++ b/lib/gnulib.mk.in
@@ -558,7 +558,6 @@ LIBS_GNUSTEP = @LIBS_GNUSTEP@
558LIBS_MAIL = @LIBS_MAIL@ 558LIBS_MAIL = @LIBS_MAIL@
559LIBS_SYSTEM = @LIBS_SYSTEM@ 559LIBS_SYSTEM = @LIBS_SYSTEM@
560LIBS_TERMCAP = @LIBS_TERMCAP@ 560LIBS_TERMCAP = @LIBS_TERMCAP@
561LIBTESTS_LIBDEPS = @LIBTESTS_LIBDEPS@
562LIBTIFF = @LIBTIFF@ 561LIBTIFF = @LIBTIFF@
563LIBXMENU = @LIBXMENU@ 562LIBXMENU = @LIBXMENU@
564LIBXML2_CFLAGS = @LIBXML2_CFLAGS@ 563LIBXML2_CFLAGS = @LIBXML2_CFLAGS@