diff options
| author | Paul Eggert | 2011-01-08 23:33:50 -0800 |
|---|---|---|
| committer | Paul Eggert | 2011-01-08 23:33:50 -0800 |
| commit | e275c824b0fe255bbb5af98a6c9a21bb8321d6e8 (patch) | |
| tree | 55f731672b2aa769d9807f3d014ffbf33c5a759e | |
| parent | 84bbb1add53329f6059958a9609240aed336258c (diff) | |
| download | emacs-e275c824b0fe255bbb5af98a6c9a21bb8321d6e8.tar.gz emacs-e275c824b0fe255bbb5af98a6c9a21bb8321d6e8.zip | |
Regenerate.
| -rw-r--r-- | ChangeLog | 8 | ||||
| -rw-r--r-- | aclocal.m4 | 3 | ||||
| -rwxr-xr-x | configure | 1164 | ||||
| -rw-r--r-- | lib-src/ChangeLog | 12 | ||||
| -rw-r--r-- | lib-src/getopt.c | 1245 | ||||
| -rw-r--r-- | lib-src/getopt1.c | 177 | ||||
| -rw-r--r-- | lib-src/getopt_int.h | 134 | ||||
| -rw-r--r-- | lib/Makefile.in | 279 | ||||
| -rw-r--r-- | lib/getopt.c | 1192 | ||||
| -rw-r--r-- | lib/getopt.in.h (renamed from lib-src/getopt_.h) | 94 | ||||
| -rw-r--r-- | lib/getopt1.c | 170 | ||||
| -rw-r--r-- | lib/getopt_int.h | 135 | ||||
| -rw-r--r-- | lib/gettext.h | 280 | ||||
| -rw-r--r-- | lib/gnulib.mk | 165 | ||||
| -rw-r--r-- | lib/unistd.in.h | 1378 | ||||
| -rw-r--r-- | m4/getopt.m4 | 345 | ||||
| -rw-r--r-- | m4/gnulib-cache.m4 | 3 | ||||
| -rw-r--r-- | m4/gnulib-comp.m4 | 22 | ||||
| -rw-r--r-- | m4/unistd_h.m4 | 164 | ||||
| -rw-r--r-- | src/config.in | 132 |
20 files changed, 5210 insertions, 1892 deletions
| @@ -1,5 +1,13 @@ | |||
| 1 | 2011-01-09 Paul Eggert <eggert@cs.ucla.edu> | 1 | 2011-01-09 Paul Eggert <eggert@cs.ucla.edu> |
| 2 | 2 | ||
| 3 | Regenerate. | ||
| 4 | * lib/getopt.c, lib/getopt.in.h, lib/getopt1.c, lib/getopt_int.h: | ||
| 5 | * lib/gettext.h, lib/unistd.in.h, m4/unistd_h.m4: | ||
| 6 | New files, copied from gnulib by gnulib-tool. | ||
| 7 | * aclocal.m4, configure, lib/Makefile.in, m4/getopt.m4: | ||
| 8 | * m4/gnulib-cache.m4, m4/gnulib-comp.m4, src/config.in: | ||
| 9 | Regenerate. | ||
| 10 | |||
| 3 | Use gnulib's getopt-gnu module. | 11 | Use gnulib's getopt-gnu module. |
| 4 | * Makefile.in (GNULIB_MODULES): Add getopt-gnu. | 12 | * Makefile.in (GNULIB_MODULES): Add getopt-gnu. |
| 5 | (AUTOCONF_INPUTS): Remove getopt.m4; aclocal.m4 is a good-enough | 13 | (AUTOCONF_INPUTS): Remove getopt.m4; aclocal.m4 is a good-enough |
diff --git a/aclocal.m4 b/aclocal.m4 index 39d41f8c282..fb784f2fcdd 100644 --- a/aclocal.m4 +++ b/aclocal.m4 | |||
| @@ -987,6 +987,7 @@ AC_SUBST([am__untar]) | |||
| 987 | m4_include([m4/00gnulib.m4]) | 987 | m4_include([m4/00gnulib.m4]) |
| 988 | m4_include([m4/c-strtod.m4]) | 988 | m4_include([m4/c-strtod.m4]) |
| 989 | m4_include([m4/extensions.m4]) | 989 | m4_include([m4/extensions.m4]) |
| 990 | m4_include([m4/getopt.m4]) | ||
| 990 | m4_include([m4/gnulib-common.m4]) | 991 | m4_include([m4/gnulib-common.m4]) |
| 991 | m4_include([m4/gnulib-comp.m4]) | 992 | m4_include([m4/gnulib-comp.m4]) |
| 992 | m4_include([m4/include_next.m4]) | 993 | m4_include([m4/include_next.m4]) |
| @@ -995,4 +996,6 @@ m4_include([m4/multiarch.m4]) | |||
| 995 | m4_include([m4/stddef_h.m4]) | 996 | m4_include([m4/stddef_h.m4]) |
| 996 | m4_include([m4/time_h.m4]) | 997 | m4_include([m4/time_h.m4]) |
| 997 | m4_include([m4/time_r.m4]) | 998 | m4_include([m4/time_r.m4]) |
| 999 | m4_include([m4/unistd_h.m4]) | ||
| 1000 | m4_include([m4/warn-on-use.m4]) | ||
| 998 | m4_include([m4/wchar_t.m4]) | 1001 | m4_include([m4/wchar_t.m4]) |
| @@ -601,6 +601,8 @@ ac_includes_default="\ | |||
| 601 | 601 | ||
| 602 | ac_config_libobj_dir=src | 602 | ac_config_libobj_dir=src |
| 603 | ac_header_list= | 603 | ac_header_list= |
| 604 | gl_getopt_required=POSIX | ||
| 605 | gl_getopt_required=POSIX | ||
| 604 | ac_func_list= | 606 | ac_func_list= |
| 605 | ac_subst_vars='gltests_LTLIBOBJS | 607 | ac_subst_vars='gltests_LTLIBOBJS |
| 606 | gltests_LIBOBJS | 608 | gltests_LIBOBJS |
| @@ -667,6 +669,9 @@ LIBS_TERMCAP | |||
| 667 | LIBGNU_LTLIBDEPS | 669 | LIBGNU_LTLIBDEPS |
| 668 | LIBGNU_LIBDEPS | 670 | LIBGNU_LIBDEPS |
| 669 | gltests_WITNESS | 671 | gltests_WITNESS |
| 672 | HAVE_UNISTD_H | ||
| 673 | NEXT_AS_FIRST_DIRECTIVE_UNISTD_H | ||
| 674 | NEXT_UNISTD_H | ||
| 670 | PTHREAD_H_DEFINES_STRUCT_TIMESPEC | 675 | PTHREAD_H_DEFINES_STRUCT_TIMESPEC |
| 671 | SYS_TIME_H_DEFINES_STRUCT_TIMESPEC | 676 | SYS_TIME_H_DEFINES_STRUCT_TIMESPEC |
| 672 | TIME_H_DEFINES_STRUCT_TIMESPEC | 677 | TIME_H_DEFINES_STRUCT_TIMESPEC |
| @@ -674,10 +679,6 @@ NEXT_AS_FIRST_DIRECTIVE_TIME_H | |||
| 674 | NEXT_TIME_H | 679 | NEXT_TIME_H |
| 675 | NEXT_AS_FIRST_DIRECTIVE_STDDEF_H | 680 | NEXT_AS_FIRST_DIRECTIVE_STDDEF_H |
| 676 | NEXT_STDDEF_H | 681 | NEXT_STDDEF_H |
| 677 | PRAGMA_COLUMNS | ||
| 678 | PRAGMA_SYSTEM_HEADER | ||
| 679 | INCLUDE_NEXT_AS_FIRST_DIRECTIVE | ||
| 680 | INCLUDE_NEXT | ||
| 681 | STDDEF_H | 682 | STDDEF_H |
| 682 | HAVE_WCHAR_T | 683 | HAVE_WCHAR_T |
| 683 | REPLACE_NULL | 684 | REPLACE_NULL |
| @@ -695,10 +696,123 @@ GNULIB_TIMEGM | |||
| 695 | GNULIB_STRPTIME | 696 | GNULIB_STRPTIME |
| 696 | GNULIB_NANOSLEEP | 697 | GNULIB_NANOSLEEP |
| 697 | GNULIB_MKTIME | 698 | GNULIB_MKTIME |
| 699 | LTLIBINTL | ||
| 700 | LIBINTL | ||
| 701 | GETOPT_H | ||
| 702 | HAVE_GETOPT_H | ||
| 703 | NEXT_AS_FIRST_DIRECTIVE_GETOPT_H | ||
| 704 | NEXT_GETOPT_H | ||
| 705 | PRAGMA_COLUMNS | ||
| 706 | PRAGMA_SYSTEM_HEADER | ||
| 707 | INCLUDE_NEXT_AS_FIRST_DIRECTIVE | ||
| 708 | INCLUDE_NEXT | ||
| 709 | UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS | ||
| 710 | UNISTD_H_HAVE_WINSOCK2_H | ||
| 711 | REPLACE_WRITE | ||
| 712 | REPLACE_USLEEP | ||
| 713 | REPLACE_UNLINKAT | ||
| 714 | REPLACE_UNLINK | ||
| 715 | REPLACE_TTYNAME_R | ||
| 716 | REPLACE_SYMLINK | ||
| 717 | REPLACE_SLEEP | ||
| 718 | REPLACE_RMDIR | ||
| 719 | REPLACE_READLINK | ||
| 720 | REPLACE_PWRITE | ||
| 721 | REPLACE_PREAD | ||
| 722 | REPLACE_LSEEK | ||
| 723 | REPLACE_LINKAT | ||
| 724 | REPLACE_LINK | ||
| 725 | REPLACE_LCHOWN | ||
| 726 | REPLACE_GETPAGESIZE | ||
| 727 | REPLACE_GETGROUPS | ||
| 728 | REPLACE_GETLOGIN_R | ||
| 729 | REPLACE_GETDOMAINNAME | ||
| 730 | REPLACE_GETCWD | ||
| 731 | REPLACE_FCHOWNAT | ||
| 732 | REPLACE_DUP2 | ||
| 733 | REPLACE_DUP | ||
| 734 | REPLACE_CLOSE | ||
| 735 | REPLACE_CHOWN | ||
| 736 | HAVE_SYS_PARAM_H | ||
| 737 | HAVE_OS_H | ||
| 738 | HAVE_DECL_TTYNAME_R | ||
| 739 | HAVE_DECL_GETUSERSHELL | ||
| 740 | HAVE_DECL_GETPAGESIZE | ||
| 741 | HAVE_DECL_GETLOGIN_R | ||
| 742 | HAVE_DECL_GETDOMAINNAME | ||
| 743 | HAVE_DECL_FCHDIR | ||
| 744 | HAVE_DECL_ENVIRON | ||
| 745 | HAVE_USLEEP | ||
| 746 | HAVE_UNLINKAT | ||
| 747 | HAVE_SYMLINKAT | ||
| 748 | HAVE_SYMLINK | ||
| 749 | HAVE_SLEEP | ||
| 750 | HAVE_READLINKAT | ||
| 751 | HAVE_READLINK | ||
| 752 | HAVE_PWRITE | ||
| 753 | HAVE_PREAD | ||
| 754 | HAVE_PIPE2 | ||
| 755 | HAVE_PIPE | ||
| 756 | HAVE_LINKAT | ||
| 757 | HAVE_LINK | ||
| 758 | HAVE_LCHOWN | ||
| 759 | HAVE_GETPAGESIZE | ||
| 760 | HAVE_GETLOGIN | ||
| 761 | HAVE_GETHOSTNAME | ||
| 762 | HAVE_GETGROUPS | ||
| 763 | HAVE_GETDTABLESIZE | ||
| 764 | HAVE_FTRUNCATE | ||
| 765 | HAVE_FSYNC | ||
| 766 | HAVE_FCHOWNAT | ||
| 767 | HAVE_FCHDIR | ||
| 768 | HAVE_FACCESSAT | ||
| 769 | HAVE_EUIDACCESS | ||
| 770 | HAVE_DUP3 | ||
| 771 | HAVE_DUP2 | ||
| 772 | HAVE_CHOWN | ||
| 773 | GNULIB_WRITE | ||
| 774 | GNULIB_USLEEP | ||
| 775 | GNULIB_UNLINKAT | ||
| 776 | GNULIB_UNLINK | ||
| 777 | GNULIB_UNISTD_H_SIGPIPE | ||
| 778 | GNULIB_UNISTD_H_GETOPT | ||
| 779 | GNULIB_TTYNAME_R | ||
| 780 | GNULIB_SYMLINKAT | ||
| 781 | GNULIB_SYMLINK | ||
| 782 | GNULIB_SLEEP | ||
| 783 | GNULIB_RMDIR | ||
| 784 | GNULIB_READLINKAT | ||
| 785 | GNULIB_READLINK | ||
| 786 | GNULIB_PWRITE | ||
| 787 | GNULIB_PREAD | ||
| 788 | GNULIB_PIPE2 | ||
| 789 | GNULIB_PIPE | ||
| 790 | GNULIB_LSEEK | ||
| 791 | GNULIB_LINKAT | ||
| 792 | GNULIB_LINK | ||
| 793 | GNULIB_LCHOWN | ||
| 794 | GNULIB_GETUSERSHELL | ||
| 795 | GNULIB_GETPAGESIZE | ||
| 796 | GNULIB_GETLOGIN_R | ||
| 797 | GNULIB_GETLOGIN | ||
| 798 | GNULIB_GETHOSTNAME | ||
| 799 | GNULIB_GETGROUPS | ||
| 800 | GNULIB_GETDTABLESIZE | ||
| 801 | GNULIB_GETDOMAINNAME | ||
| 802 | GNULIB_GETCWD | ||
| 803 | GNULIB_FTRUNCATE | ||
| 804 | GNULIB_FSYNC | ||
| 805 | GNULIB_FCHOWNAT | ||
| 806 | GNULIB_FCHDIR | ||
| 807 | GNULIB_FACCESSAT | ||
| 808 | GNULIB_EUIDACCESS | ||
| 809 | GNULIB_ENVIRON | ||
| 810 | GNULIB_DUP3 | ||
| 811 | GNULIB_DUP2 | ||
| 812 | GNULIB_CLOSE | ||
| 813 | GNULIB_CHOWN | ||
| 698 | GL_COND_LIBTOOL_FALSE | 814 | GL_COND_LIBTOOL_FALSE |
| 699 | GL_COND_LIBTOOL_TRUE | 815 | GL_COND_LIBTOOL_TRUE |
| 700 | GETOPTOBJS | ||
| 701 | GETOPT_H | ||
| 702 | GETLOADAVG_LIBS | 816 | GETLOADAVG_LIBS |
| 703 | KMEM_GROUP | 817 | KMEM_GROUP |
| 704 | NEED_SETGID | 818 | NEED_SETGID |
| @@ -2541,6 +2655,8 @@ fi | |||
| 2541 | as_fn_append ac_header_list " stdlib.h" | 2655 | as_fn_append ac_header_list " stdlib.h" |
| 2542 | as_fn_append ac_header_list " unistd.h" | 2656 | as_fn_append ac_header_list " unistd.h" |
| 2543 | as_fn_append ac_header_list " sys/param.h" | 2657 | as_fn_append ac_header_list " sys/param.h" |
| 2658 | gl_getopt_required=GNU | ||
| 2659 | as_fn_append ac_header_list " getopt.h" | ||
| 2544 | as_fn_append ac_func_list " alarm" | 2660 | as_fn_append ac_func_list " alarm" |
| 2545 | as_fn_append ac_header_list " stddef.h" | 2661 | as_fn_append ac_header_list " stddef.h" |
| 2546 | as_fn_append ac_header_list " time.h" | 2662 | as_fn_append ac_header_list " time.h" |
| @@ -5695,6 +5811,9 @@ $as_echo "$ac_cv_safe_to_define___extensions__" >&6; } | |||
| 5695 | # Code from module extensions: | 5811 | # Code from module extensions: |
| 5696 | 5812 | ||
| 5697 | # Code from module ftoastr: | 5813 | # Code from module ftoastr: |
| 5814 | # Code from module getopt-gnu: | ||
| 5815 | # Code from module getopt-posix: | ||
| 5816 | # Code from module gettext-h: | ||
| 5698 | # Code from module include_next: | 5817 | # Code from module include_next: |
| 5699 | # Code from module intprops: | 5818 | # Code from module intprops: |
| 5700 | # Code from module mktime: | 5819 | # Code from module mktime: |
| @@ -5702,6 +5821,7 @@ $as_echo "$ac_cv_safe_to_define___extensions__" >&6; } | |||
| 5702 | # Code from module stddef: | 5821 | # Code from module stddef: |
| 5703 | # Code from module time: | 5822 | # Code from module time: |
| 5704 | # Code from module time_r: | 5823 | # Code from module time_r: |
| 5824 | # Code from module unistd: | ||
| 5705 | # Code from module warn-on-use: | 5825 | # Code from module warn-on-use: |
| 5706 | 5826 | ||
| 5707 | 5827 | ||
| @@ -13382,30 +13502,385 @@ $as_echo "#define HAVE_FSEEKO 1" >>confdefs.h | |||
| 13382 | fi | 13502 | fi |
| 13383 | 13503 | ||
| 13384 | 13504 | ||
| 13385 | # Configure getopt. | 13505 | { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether getpgrp requires zero arguments" >&5 |
| 13386 | # getopt.m4 serial 10 | 13506 | $as_echo_n "checking whether getpgrp requires zero arguments... " >&6; } |
| 13507 | if ${ac_cv_func_getpgrp_void+:} false; then : | ||
| 13508 | $as_echo_n "(cached) " >&6 | ||
| 13509 | else | ||
| 13510 | # Use it with a single arg. | ||
| 13511 | cat confdefs.h - <<_ACEOF >conftest.$ac_ext | ||
| 13512 | /* end confdefs.h. */ | ||
| 13513 | $ac_includes_default | ||
| 13514 | int | ||
| 13515 | main () | ||
| 13516 | { | ||
| 13517 | getpgrp (0); | ||
| 13518 | ; | ||
| 13519 | return 0; | ||
| 13520 | } | ||
| 13521 | _ACEOF | ||
| 13522 | if ac_fn_c_try_compile "$LINENO"; then : | ||
| 13523 | ac_cv_func_getpgrp_void=no | ||
| 13524 | else | ||
| 13525 | ac_cv_func_getpgrp_void=yes | ||
| 13526 | fi | ||
| 13527 | rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext | ||
| 13528 | |||
| 13529 | fi | ||
| 13530 | { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_getpgrp_void" >&5 | ||
| 13531 | $as_echo "$ac_cv_func_getpgrp_void" >&6; } | ||
| 13532 | if test $ac_cv_func_getpgrp_void = yes; then | ||
| 13533 | |||
| 13534 | $as_echo "#define GETPGRP_VOID 1" >>confdefs.h | ||
| 13535 | |||
| 13536 | fi | ||
| 13537 | |||
| 13538 | |||
| 13539 | # Configure gnulib. | ||
| 13540 | |||
| 13387 | 13541 | ||
| 13388 | # The getopt module assume you want GNU getopt, with getopt_long etc, | ||
| 13389 | # rather than vanilla POSIX getopt. This means your your code should | ||
| 13390 | # always include <getopt.h> for the getopt prototypes. | ||
| 13391 | 13542 | ||
| 13392 | 13543 | ||
| 13544 | LIBC_FATAL_STDERR_=1 | ||
| 13545 | export LIBC_FATAL_STDERR_ | ||
| 13546 | |||
| 13547 | |||
| 13548 | { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether strtold conforms to C99" >&5 | ||
| 13549 | $as_echo_n "checking whether strtold conforms to C99... " >&6; } | ||
| 13550 | if ${gl_cv_func_c99_strtold+:} false; then : | ||
| 13551 | $as_echo_n "(cached) " >&6 | ||
| 13552 | else | ||
| 13553 | cat confdefs.h - <<_ACEOF >conftest.$ac_ext | ||
| 13554 | /* end confdefs.h. */ | ||
| 13555 | /* On HP-UX before 11.23, strtold returns a struct instead of | ||
| 13556 | long double. Reject implementations like that, by requiring | ||
| 13557 | compatibility with the C99 prototype. */ | ||
| 13558 | #include <stdlib.h> | ||
| 13559 | static long double (*p) (char const *, char **) = strtold; | ||
| 13560 | static long double | ||
| 13561 | test (char const *nptr, char **endptr) | ||
| 13562 | { | ||
| 13563 | long double r; | ||
| 13564 | r = strtold (nptr, endptr); | ||
| 13565 | return r; | ||
| 13566 | } | ||
| 13567 | int | ||
| 13568 | main () | ||
| 13569 | { | ||
| 13570 | return test ("1.0", NULL) != 1 || p ("1.0", NULL) != 1; | ||
| 13571 | ; | ||
| 13572 | return 0; | ||
| 13573 | } | ||
| 13574 | _ACEOF | ||
| 13575 | if ac_fn_c_try_link "$LINENO"; then : | ||
| 13576 | gl_cv_func_c99_strtold=yes | ||
| 13577 | else | ||
| 13578 | gl_cv_func_c99_strtold=no | ||
| 13579 | fi | ||
| 13580 | rm -f core conftest.err conftest.$ac_objext \ | ||
| 13581 | conftest$ac_exeext conftest.$ac_ext | ||
| 13582 | fi | ||
| 13583 | { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_c99_strtold" >&5 | ||
| 13584 | $as_echo "$gl_cv_func_c99_strtold" >&6; } | ||
| 13585 | if test $gl_cv_func_c99_strtold = yes; then | ||
| 13393 | 13586 | ||
| 13587 | $as_echo "#define HAVE_C99_STRTOLD 1" >>confdefs.h | ||
| 13394 | 13588 | ||
| 13589 | fi | ||
| 13395 | 13590 | ||
| 13396 | 13591 | ||
| 13592 | GNULIB_CHOWN=0; | ||
| 13593 | GNULIB_CLOSE=0; | ||
| 13594 | GNULIB_DUP2=0; | ||
| 13595 | GNULIB_DUP3=0; | ||
| 13596 | GNULIB_ENVIRON=0; | ||
| 13597 | GNULIB_EUIDACCESS=0; | ||
| 13598 | GNULIB_FACCESSAT=0; | ||
| 13599 | GNULIB_FCHDIR=0; | ||
| 13600 | GNULIB_FCHOWNAT=0; | ||
| 13601 | GNULIB_FSYNC=0; | ||
| 13602 | GNULIB_FTRUNCATE=0; | ||
| 13603 | GNULIB_GETCWD=0; | ||
| 13604 | GNULIB_GETDOMAINNAME=0; | ||
| 13605 | GNULIB_GETDTABLESIZE=0; | ||
| 13606 | GNULIB_GETGROUPS=0; | ||
| 13607 | GNULIB_GETHOSTNAME=0; | ||
| 13608 | GNULIB_GETLOGIN=0; | ||
| 13609 | GNULIB_GETLOGIN_R=0; | ||
| 13610 | GNULIB_GETPAGESIZE=0; | ||
| 13611 | GNULIB_GETUSERSHELL=0; | ||
| 13612 | GNULIB_LCHOWN=0; | ||
| 13613 | GNULIB_LINK=0; | ||
| 13614 | GNULIB_LINKAT=0; | ||
| 13615 | GNULIB_LSEEK=0; | ||
| 13616 | GNULIB_PIPE=0; | ||
| 13617 | GNULIB_PIPE2=0; | ||
| 13618 | GNULIB_PREAD=0; | ||
| 13619 | GNULIB_PWRITE=0; | ||
| 13620 | GNULIB_READLINK=0; | ||
| 13621 | GNULIB_READLINKAT=0; | ||
| 13622 | GNULIB_RMDIR=0; | ||
| 13623 | GNULIB_SLEEP=0; | ||
| 13624 | GNULIB_SYMLINK=0; | ||
| 13625 | GNULIB_SYMLINKAT=0; | ||
| 13626 | GNULIB_TTYNAME_R=0; | ||
| 13627 | GNULIB_UNISTD_H_GETOPT=0; | ||
| 13628 | GNULIB_UNISTD_H_SIGPIPE=0; | ||
| 13629 | GNULIB_UNLINK=0; | ||
| 13630 | GNULIB_UNLINKAT=0; | ||
| 13631 | GNULIB_USLEEP=0; | ||
| 13632 | GNULIB_WRITE=0; | ||
| 13633 | HAVE_CHOWN=1; | ||
| 13634 | HAVE_DUP2=1; | ||
| 13635 | HAVE_DUP3=1; | ||
| 13636 | HAVE_EUIDACCESS=1; | ||
| 13637 | HAVE_FACCESSAT=1; | ||
| 13638 | HAVE_FCHDIR=1; | ||
| 13639 | HAVE_FCHOWNAT=1; | ||
| 13640 | HAVE_FSYNC=1; | ||
| 13641 | HAVE_FTRUNCATE=1; | ||
| 13642 | HAVE_GETDTABLESIZE=1; | ||
| 13643 | HAVE_GETGROUPS=1; | ||
| 13644 | HAVE_GETHOSTNAME=1; | ||
| 13645 | HAVE_GETLOGIN=1; | ||
| 13646 | HAVE_GETPAGESIZE=1; | ||
| 13647 | HAVE_LCHOWN=1; | ||
| 13648 | HAVE_LINK=1; | ||
| 13649 | HAVE_LINKAT=1; | ||
| 13650 | HAVE_PIPE=1; | ||
| 13651 | HAVE_PIPE2=1; | ||
| 13652 | HAVE_PREAD=1; | ||
| 13653 | HAVE_PWRITE=1; | ||
| 13654 | HAVE_READLINK=1; | ||
| 13655 | HAVE_READLINKAT=1; | ||
| 13656 | HAVE_SLEEP=1; | ||
| 13657 | HAVE_SYMLINK=1; | ||
| 13658 | HAVE_SYMLINKAT=1; | ||
| 13659 | HAVE_UNLINKAT=1; | ||
| 13660 | HAVE_USLEEP=1; | ||
| 13661 | HAVE_DECL_ENVIRON=1; | ||
| 13662 | HAVE_DECL_FCHDIR=1; | ||
| 13663 | HAVE_DECL_GETDOMAINNAME=1; | ||
| 13664 | HAVE_DECL_GETLOGIN_R=1; | ||
| 13665 | HAVE_DECL_GETPAGESIZE=1; | ||
| 13666 | HAVE_DECL_GETUSERSHELL=1; | ||
| 13667 | HAVE_DECL_TTYNAME_R=1; | ||
| 13668 | HAVE_OS_H=0; | ||
| 13669 | HAVE_SYS_PARAM_H=0; | ||
| 13670 | REPLACE_CHOWN=0; | ||
| 13671 | REPLACE_CLOSE=0; | ||
| 13672 | REPLACE_DUP=0; | ||
| 13673 | REPLACE_DUP2=0; | ||
| 13674 | REPLACE_FCHOWNAT=0; | ||
| 13675 | REPLACE_GETCWD=0; | ||
| 13676 | REPLACE_GETDOMAINNAME=0; | ||
| 13677 | REPLACE_GETLOGIN_R=0; | ||
| 13678 | REPLACE_GETGROUPS=0; | ||
| 13679 | REPLACE_GETPAGESIZE=0; | ||
| 13680 | REPLACE_LCHOWN=0; | ||
| 13681 | REPLACE_LINK=0; | ||
| 13682 | REPLACE_LINKAT=0; | ||
| 13683 | REPLACE_LSEEK=0; | ||
| 13684 | REPLACE_PREAD=0; | ||
| 13685 | REPLACE_PWRITE=0; | ||
| 13686 | REPLACE_READLINK=0; | ||
| 13687 | REPLACE_RMDIR=0; | ||
| 13688 | REPLACE_SLEEP=0; | ||
| 13689 | REPLACE_SYMLINK=0; | ||
| 13690 | REPLACE_TTYNAME_R=0; | ||
| 13691 | REPLACE_UNLINK=0; | ||
| 13692 | REPLACE_UNLINKAT=0; | ||
| 13693 | REPLACE_USLEEP=0; | ||
| 13694 | REPLACE_WRITE=0; | ||
| 13695 | UNISTD_H_HAVE_WINSOCK2_H=0; | ||
| 13696 | UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS=0; | ||
| 13397 | 13697 | ||
| 13398 | 13698 | ||
| 13399 | 13699 | ||
| 13400 | 13700 | ||
| 13701 | { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the preprocessor supports include_next" >&5 | ||
| 13702 | $as_echo_n "checking whether the preprocessor supports include_next... " >&6; } | ||
| 13703 | if ${gl_cv_have_include_next+:} false; then : | ||
| 13704 | $as_echo_n "(cached) " >&6 | ||
| 13705 | else | ||
| 13706 | rm -rf conftestd1a conftestd1b conftestd2 | ||
| 13707 | mkdir conftestd1a conftestd1b conftestd2 | ||
| 13708 | cat <<EOF > conftestd1a/conftest.h | ||
| 13709 | #define DEFINED_IN_CONFTESTD1 | ||
| 13710 | #include_next <conftest.h> | ||
| 13711 | #ifdef DEFINED_IN_CONFTESTD2 | ||
| 13712 | int foo; | ||
| 13713 | #else | ||
| 13714 | #error "include_next doesn't work" | ||
| 13715 | #endif | ||
| 13716 | EOF | ||
| 13717 | cat <<EOF > conftestd1b/conftest.h | ||
| 13718 | #define DEFINED_IN_CONFTESTD1 | ||
| 13719 | #include <stdio.h> | ||
| 13720 | #include_next <conftest.h> | ||
| 13721 | #ifdef DEFINED_IN_CONFTESTD2 | ||
| 13722 | int foo; | ||
| 13723 | #else | ||
| 13724 | #error "include_next doesn't work" | ||
| 13725 | #endif | ||
| 13726 | EOF | ||
| 13727 | cat <<EOF > conftestd2/conftest.h | ||
| 13728 | #ifndef DEFINED_IN_CONFTESTD1 | ||
| 13729 | #error "include_next test doesn't work" | ||
| 13730 | #endif | ||
| 13731 | #define DEFINED_IN_CONFTESTD2 | ||
| 13732 | EOF | ||
| 13733 | gl_save_CPPFLAGS="$CPPFLAGS" | ||
| 13734 | CPPFLAGS="$gl_save_CPPFLAGS -Iconftestd1b -Iconftestd2" | ||
| 13735 | cat confdefs.h - <<_ACEOF >conftest.$ac_ext | ||
| 13736 | /* end confdefs.h. */ | ||
| 13737 | #include <conftest.h> | ||
| 13738 | _ACEOF | ||
| 13739 | if ac_fn_c_try_compile "$LINENO"; then : | ||
| 13740 | gl_cv_have_include_next=yes | ||
| 13741 | else | ||
| 13742 | CPPFLAGS="$gl_save_CPPFLAGS -Iconftestd1a -Iconftestd2" | ||
| 13743 | cat confdefs.h - <<_ACEOF >conftest.$ac_ext | ||
| 13744 | /* end confdefs.h. */ | ||
| 13745 | #include <conftest.h> | ||
| 13746 | _ACEOF | ||
| 13747 | if ac_fn_c_try_compile "$LINENO"; then : | ||
| 13748 | gl_cv_have_include_next=buggy | ||
| 13749 | else | ||
| 13750 | gl_cv_have_include_next=no | ||
| 13751 | fi | ||
| 13752 | rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext | ||
| 13401 | 13753 | ||
| 13402 | # Prerequisites of lib/getopt*. | 13754 | fi |
| 13755 | rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext | ||
| 13756 | CPPFLAGS="$gl_save_CPPFLAGS" | ||
| 13757 | rm -rf conftestd1a conftestd1b conftestd2 | ||
| 13403 | 13758 | ||
| 13759 | fi | ||
| 13760 | { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_have_include_next" >&5 | ||
| 13761 | $as_echo "$gl_cv_have_include_next" >&6; } | ||
| 13762 | PRAGMA_SYSTEM_HEADER= | ||
| 13763 | if test $gl_cv_have_include_next = yes; then | ||
| 13764 | INCLUDE_NEXT=include_next | ||
| 13765 | INCLUDE_NEXT_AS_FIRST_DIRECTIVE=include_next | ||
| 13766 | if test -n "$GCC"; then | ||
| 13767 | PRAGMA_SYSTEM_HEADER='#pragma GCC system_header' | ||
| 13768 | fi | ||
| 13769 | else | ||
| 13770 | if test $gl_cv_have_include_next = buggy; then | ||
| 13771 | INCLUDE_NEXT=include | ||
| 13772 | INCLUDE_NEXT_AS_FIRST_DIRECTIVE=include_next | ||
| 13773 | else | ||
| 13774 | INCLUDE_NEXT=include | ||
| 13775 | INCLUDE_NEXT_AS_FIRST_DIRECTIVE=include | ||
| 13776 | fi | ||
| 13777 | fi | ||
| 13404 | 13778 | ||
| 13405 | 13779 | ||
| 13406 | 13780 | ||
| 13407 | GETOPT_H= | 13781 | { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether system header files limit the line length" >&5 |
| 13408 | for ac_header in getopt.h | 13782 | $as_echo_n "checking whether system header files limit the line length... " >&6; } |
| 13783 | if ${gl_cv_pragma_columns+:} false; then : | ||
| 13784 | $as_echo_n "(cached) " >&6 | ||
| 13785 | else | ||
| 13786 | cat confdefs.h - <<_ACEOF >conftest.$ac_ext | ||
| 13787 | /* end confdefs.h. */ | ||
| 13788 | |||
| 13789 | #ifdef __TANDEM | ||
| 13790 | choke me | ||
| 13791 | #endif | ||
| 13792 | |||
| 13793 | _ACEOF | ||
| 13794 | if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | | ||
| 13795 | $EGREP "choke me" >/dev/null 2>&1; then : | ||
| 13796 | gl_cv_pragma_columns=yes | ||
| 13797 | else | ||
| 13798 | gl_cv_pragma_columns=no | ||
| 13799 | fi | ||
| 13800 | rm -f conftest* | ||
| 13801 | |||
| 13802 | |||
| 13803 | fi | ||
| 13804 | { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_pragma_columns" >&5 | ||
| 13805 | $as_echo "$gl_cv_pragma_columns" >&6; } | ||
| 13806 | if test $gl_cv_pragma_columns = yes; then | ||
| 13807 | PRAGMA_COLUMNS="#pragma COLUMNS 10000" | ||
| 13808 | else | ||
| 13809 | PRAGMA_COLUMNS= | ||
| 13810 | fi | ||
| 13811 | |||
| 13812 | |||
| 13813 | |||
| 13814 | |||
| 13815 | |||
| 13816 | |||
| 13817 | |||
| 13818 | |||
| 13819 | |||
| 13820 | |||
| 13821 | |||
| 13822 | |||
| 13823 | |||
| 13824 | |||
| 13825 | if test $gl_cv_have_include_next = yes; then | ||
| 13826 | gl_cv_next_getopt_h='<'getopt.h'>' | ||
| 13827 | else | ||
| 13828 | { $as_echo "$as_me:${as_lineno-$LINENO}: checking absolute name of <getopt.h>" >&5 | ||
| 13829 | $as_echo_n "checking absolute name of <getopt.h>... " >&6; } | ||
| 13830 | if ${gl_cv_next_getopt_h+:} false; then : | ||
| 13831 | $as_echo_n "(cached) " >&6 | ||
| 13832 | else | ||
| 13833 | |||
| 13834 | if test $ac_cv_header_getopt_h = yes; then | ||
| 13835 | cat confdefs.h - <<_ACEOF >conftest.$ac_ext | ||
| 13836 | /* end confdefs.h. */ | ||
| 13837 | #include <getopt.h> | ||
| 13838 | |||
| 13839 | _ACEOF | ||
| 13840 | case "$host_os" in | ||
| 13841 | aix*) gl_absname_cpp="$ac_cpp -C" ;; | ||
| 13842 | *) gl_absname_cpp="$ac_cpp" ;; | ||
| 13843 | esac | ||
| 13844 | gl_cv_next_getopt_h='"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 | | ||
| 13845 | sed -n '\#/getopt.h#{ | ||
| 13846 | s#.*"\(.*/getopt.h\)".*#\1# | ||
| 13847 | s#^/[^/]#//&# | ||
| 13848 | p | ||
| 13849 | q | ||
| 13850 | }'`'"' | ||
| 13851 | else | ||
| 13852 | gl_cv_next_getopt_h='<'getopt.h'>' | ||
| 13853 | fi | ||
| 13854 | |||
| 13855 | fi | ||
| 13856 | { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_next_getopt_h" >&5 | ||
| 13857 | $as_echo "$gl_cv_next_getopt_h" >&6; } | ||
| 13858 | fi | ||
| 13859 | NEXT_GETOPT_H=$gl_cv_next_getopt_h | ||
| 13860 | |||
| 13861 | if test $gl_cv_have_include_next = yes || test $gl_cv_have_include_next = buggy; then | ||
| 13862 | # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include_next' | ||
| 13863 | gl_next_as_first_directive='<'getopt.h'>' | ||
| 13864 | else | ||
| 13865 | # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include' | ||
| 13866 | gl_next_as_first_directive=$gl_cv_next_getopt_h | ||
| 13867 | fi | ||
| 13868 | NEXT_AS_FIRST_DIRECTIVE_GETOPT_H=$gl_next_as_first_directive | ||
| 13869 | |||
| 13870 | |||
| 13871 | |||
| 13872 | |||
| 13873 | if test $ac_cv_header_getopt_h = yes; then | ||
| 13874 | HAVE_GETOPT_H=1 | ||
| 13875 | else | ||
| 13876 | HAVE_GETOPT_H=0 | ||
| 13877 | fi | ||
| 13878 | |||
| 13879 | |||
| 13880 | gl_replace_getopt= | ||
| 13881 | |||
| 13882 | if test -z "$gl_replace_getopt" && test $gl_getopt_required = GNU; then | ||
| 13883 | for ac_header in getopt.h | ||
| 13409 | do : | 13884 | do : |
| 13410 | ac_fn_c_check_header_mongrel "$LINENO" "getopt.h" "ac_cv_header_getopt_h" "$ac_includes_default" | 13885 | ac_fn_c_check_header_mongrel "$LINENO" "getopt.h" "ac_cv_header_getopt_h" "$ac_includes_default" |
| 13411 | if test "x$ac_cv_header_getopt_h" = xyes; then : | 13886 | if test "x$ac_cv_header_getopt_h" = xyes; then : |
| @@ -13414,12 +13889,14 @@ if test "x$ac_cv_header_getopt_h" = xyes; then : | |||
| 13414 | _ACEOF | 13889 | _ACEOF |
| 13415 | 13890 | ||
| 13416 | else | 13891 | else |
| 13417 | GETOPT_H=getopt.h | 13892 | gl_replace_getopt=yes |
| 13418 | fi | 13893 | fi |
| 13419 | 13894 | ||
| 13420 | done | 13895 | done |
| 13421 | 13896 | ||
| 13422 | if test -z "$GETOPT_H"; then | 13897 | fi |
| 13898 | |||
| 13899 | if test -z "$gl_replace_getopt" && test $gl_getopt_required = GNU; then | ||
| 13423 | for ac_func in getopt_long_only | 13900 | for ac_func in getopt_long_only |
| 13424 | do : | 13901 | do : |
| 13425 | ac_fn_c_check_func "$LINENO" "getopt_long_only" "ac_cv_func_getopt_long_only" | 13902 | ac_fn_c_check_func "$LINENO" "getopt_long_only" "ac_cv_func_getopt_long_only" |
| @@ -13429,74 +13906,303 @@ if test "x$ac_cv_func_getopt_long_only" = xyes; then : | |||
| 13429 | _ACEOF | 13906 | _ACEOF |
| 13430 | 13907 | ||
| 13431 | else | 13908 | else |
| 13432 | GETOPT_H=getopt.h | 13909 | gl_replace_getopt=yes |
| 13433 | fi | 13910 | fi |
| 13434 | done | 13911 | done |
| 13435 | 13912 | ||
| 13436 | fi | 13913 | fi |
| 13437 | 13914 | ||
| 13438 | if test -z "$GETOPT_H"; then | 13915 | if test -z "$gl_replace_getopt"; then |
| 13439 | ac_fn_c_check_decl "$LINENO" "optreset" "ac_cv_have_decl_optreset" "#include <getopt.h> | 13916 | ac_fn_c_check_decl "$LINENO" "optreset" "ac_cv_have_decl_optreset" "#include <getopt.h> |
| 13440 | " | 13917 | " |
| 13441 | if test "x$ac_cv_have_decl_optreset" = xyes; then : | 13918 | if test "x$ac_cv_have_decl_optreset" = xyes; then : |
| 13442 | GETOPT_H=getopt.h | 13919 | ac_have_decl=1 |
| 13920 | else | ||
| 13921 | ac_have_decl=0 | ||
| 13443 | fi | 13922 | fi |
| 13444 | 13923 | ||
| 13445 | fi | 13924 | cat >>confdefs.h <<_ACEOF |
| 13925 | #define HAVE_DECL_OPTRESET $ac_have_decl | ||
| 13926 | _ACEOF | ||
| 13927 | if test $ac_have_decl = 1; then : | ||
| 13446 | 13928 | ||
| 13447 | if test -z "$GETOPT_H"; then | ||
| 13448 | { $as_echo "$as_me:${as_lineno-$LINENO}: checking for working GNU getopt function" >&5 | ||
| 13449 | $as_echo_n "checking for working GNU getopt function... " >&6; } | ||
| 13450 | if ${gl_cv_func_gnu_getopt+:} false; then : | ||
| 13451 | $as_echo_n "(cached) " >&6 | ||
| 13452 | else | 13929 | else |
| 13453 | if test "$cross_compiling" = yes; then : | 13930 | ac_fn_c_check_decl "$LINENO" "getopt_clip" "ac_cv_have_decl_getopt_clip" "#include <getopt.h> |
| 13454 | ac_fn_c_check_decl "$LINENO" "getopt_clip" "ac_cv_have_decl_getopt_clip" "#include <getopt.h> | ||
| 13455 | " | 13931 | " |
| 13456 | if test "x$ac_cv_have_decl_getopt_clip" = xyes; then : | 13932 | if test "x$ac_cv_have_decl_getopt_clip" = xyes; then : |
| 13457 | gl_cv_func_gnu_getopt=no | 13933 | ac_have_decl=1 |
| 13458 | else | 13934 | else |
| 13459 | gl_cv_func_gnu_getopt=yes | 13935 | ac_have_decl=0 |
| 13936 | fi | ||
| 13937 | |||
| 13938 | cat >>confdefs.h <<_ACEOF | ||
| 13939 | #define HAVE_DECL_GETOPT_CLIP $ac_have_decl | ||
| 13940 | _ACEOF | ||
| 13941 | |||
| 13942 | |||
| 13460 | fi | 13943 | fi |
| 13461 | 13944 | ||
| 13945 | fi | ||
| 13946 | |||
| 13947 | if test -z "$gl_replace_getopt"; then | ||
| 13948 | { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether getopt is POSIX compatible" >&5 | ||
| 13949 | $as_echo_n "checking whether getopt is POSIX compatible... " >&6; } | ||
| 13950 | if ${gl_cv_func_getopt_posix+:} false; then : | ||
| 13951 | $as_echo_n "(cached) " >&6 | ||
| 13952 | else | ||
| 13953 | |||
| 13954 | if test "$cross_compiling" = yes; then : | ||
| 13955 | case "$host_os" in | ||
| 13956 | mingw*) gl_cv_func_getopt_posix="guessing no";; | ||
| 13957 | darwin* | aix*) gl_cv_func_getopt_posix="guessing no";; | ||
| 13958 | *) gl_cv_func_getopt_posix="guessing yes";; | ||
| 13959 | esac | ||
| 13960 | |||
| 13961 | else | ||
| 13962 | cat confdefs.h - <<_ACEOF >conftest.$ac_ext | ||
| 13963 | /* end confdefs.h. */ | ||
| 13964 | |||
| 13965 | #include <unistd.h> | ||
| 13966 | #include <stdlib.h> | ||
| 13967 | #include <string.h> | ||
| 13968 | |||
| 13969 | #if !HAVE_DECL_OPTRESET && !HAVE_DECL_GETOPT_CLIP | ||
| 13970 | # define OPTIND_MIN 0 | ||
| 13971 | #else | ||
| 13972 | # define OPTIND_MIN 1 | ||
| 13973 | #endif | ||
| 13974 | |||
| 13975 | int | ||
| 13976 | main () | ||
| 13977 | { | ||
| 13978 | { | ||
| 13979 | int argc = 0; | ||
| 13980 | char *argv[10]; | ||
| 13981 | int c; | ||
| 13982 | |||
| 13983 | argv[argc++] = "program"; | ||
| 13984 | argv[argc++] = "-a"; | ||
| 13985 | argv[argc++] = "foo"; | ||
| 13986 | argv[argc++] = "bar"; | ||
| 13987 | argv[argc] = NULL; | ||
| 13988 | optind = OPTIND_MIN; | ||
| 13989 | opterr = 0; | ||
| 13990 | |||
| 13991 | c = getopt (argc, argv, "ab"); | ||
| 13992 | if (!(c == 'a')) | ||
| 13993 | return 1; | ||
| 13994 | c = getopt (argc, argv, "ab"); | ||
| 13995 | if (!(c == -1)) | ||
| 13996 | return 2; | ||
| 13997 | if (!(optind == 2)) | ||
| 13998 | return 3; | ||
| 13999 | } | ||
| 14000 | /* Some internal state exists at this point. */ | ||
| 14001 | { | ||
| 14002 | int argc = 0; | ||
| 14003 | char *argv[10]; | ||
| 14004 | int c; | ||
| 14005 | |||
| 14006 | argv[argc++] = "program"; | ||
| 14007 | argv[argc++] = "donald"; | ||
| 14008 | argv[argc++] = "-p"; | ||
| 14009 | argv[argc++] = "billy"; | ||
| 14010 | argv[argc++] = "duck"; | ||
| 14011 | argv[argc++] = "-a"; | ||
| 14012 | argv[argc++] = "bar"; | ||
| 14013 | argv[argc] = NULL; | ||
| 14014 | optind = OPTIND_MIN; | ||
| 14015 | opterr = 0; | ||
| 14016 | |||
| 14017 | c = getopt (argc, argv, "+abp:q:"); | ||
| 14018 | if (!(c == -1)) | ||
| 14019 | return 4; | ||
| 14020 | if (!(strcmp (argv[0], "program") == 0)) | ||
| 14021 | return 5; | ||
| 14022 | if (!(strcmp (argv[1], "donald") == 0)) | ||
| 14023 | return 6; | ||
| 14024 | if (!(strcmp (argv[2], "-p") == 0)) | ||
| 14025 | return 7; | ||
| 14026 | if (!(strcmp (argv[3], "billy") == 0)) | ||
| 14027 | return 8; | ||
| 14028 | if (!(strcmp (argv[4], "duck") == 0)) | ||
| 14029 | return 9; | ||
| 14030 | if (!(strcmp (argv[5], "-a") == 0)) | ||
| 14031 | return 10; | ||
| 14032 | if (!(strcmp (argv[6], "bar") == 0)) | ||
| 14033 | return 11; | ||
| 14034 | if (!(optind == 1)) | ||
| 14035 | return 12; | ||
| 14036 | } | ||
| 14037 | /* Detect MacOS 10.5, AIX 7.1 bug. */ | ||
| 14038 | { | ||
| 14039 | char *argv[3] = { "program", "-ab", NULL }; | ||
| 14040 | optind = OPTIND_MIN; | ||
| 14041 | opterr = 0; | ||
| 14042 | if (getopt (2, argv, "ab:") != 'a') | ||
| 14043 | return 13; | ||
| 14044 | if (getopt (2, argv, "ab:") != '?') | ||
| 14045 | return 14; | ||
| 14046 | if (optopt != 'b') | ||
| 14047 | return 15; | ||
| 14048 | if (optind != 2) | ||
| 14049 | return 16; | ||
| 14050 | } | ||
| 14051 | |||
| 14052 | return 0; | ||
| 14053 | } | ||
| 14054 | |||
| 14055 | _ACEOF | ||
| 14056 | if ac_fn_c_try_run "$LINENO"; then : | ||
| 14057 | gl_cv_func_getopt_posix=yes | ||
| 14058 | else | ||
| 14059 | gl_cv_func_getopt_posix=no | ||
| 14060 | fi | ||
| 14061 | rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ | ||
| 14062 | conftest.$ac_objext conftest.beam conftest.$ac_ext | ||
| 14063 | fi | ||
| 14064 | |||
| 14065 | |||
| 14066 | fi | ||
| 14067 | { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_getopt_posix" >&5 | ||
| 14068 | $as_echo "$gl_cv_func_getopt_posix" >&6; } | ||
| 14069 | case "$gl_cv_func_getopt_posix" in | ||
| 14070 | *no) gl_replace_getopt=yes ;; | ||
| 14071 | esac | ||
| 14072 | fi | ||
| 14073 | |||
| 14074 | if test -z "$gl_replace_getopt" && test $gl_getopt_required = GNU; then | ||
| 14075 | { $as_echo "$as_me:${as_lineno-$LINENO}: checking for working GNU getopt function" >&5 | ||
| 14076 | $as_echo_n "checking for working GNU getopt function... " >&6; } | ||
| 14077 | if ${gl_cv_func_getopt_gnu+:} false; then : | ||
| 14078 | $as_echo_n "(cached) " >&6 | ||
| 14079 | else | ||
| 14080 | # Even with POSIXLY_CORRECT, the GNU extension of leading '-' in the | ||
| 14081 | # optstring is necessary for programs like m4 that have POSIX-mandated | ||
| 14082 | # semantics for supporting options interspersed with files. | ||
| 14083 | # Also, since getopt_long is a GNU extension, we require optind=0. | ||
| 14084 | # Bash ties 'set -o posix' to a non-exported POSIXLY_CORRECT; | ||
| 14085 | # so take care to revert to the correct (non-)export state. | ||
| 14086 | gl_awk_probe='BEGIN { if ("POSIXLY_CORRECT" in ENVIRON) print "x" }' | ||
| 14087 | case ${POSIXLY_CORRECT+x}`$AWK "$gl_awk_probe" </dev/null` in | ||
| 14088 | xx) gl_had_POSIXLY_CORRECT=exported ;; | ||
| 14089 | x) gl_had_POSIXLY_CORRECT=yes ;; | ||
| 14090 | *) gl_had_POSIXLY_CORRECT= ;; | ||
| 14091 | esac | ||
| 14092 | POSIXLY_CORRECT=1 | ||
| 14093 | export POSIXLY_CORRECT | ||
| 14094 | if test "$cross_compiling" = yes; then : | ||
| 14095 | case $host_os:$ac_cv_have_decl_optreset in | ||
| 14096 | *-gnu*:* | mingw*:*) gl_cv_func_getopt_gnu=no;; | ||
| 14097 | *:yes) gl_cv_func_getopt_gnu=no;; | ||
| 14098 | *) gl_cv_func_getopt_gnu=yes;; | ||
| 14099 | esac | ||
| 14100 | |||
| 13462 | else | 14101 | else |
| 13463 | cat confdefs.h - <<_ACEOF >conftest.$ac_ext | 14102 | cat confdefs.h - <<_ACEOF >conftest.$ac_ext |
| 13464 | /* end confdefs.h. */ | 14103 | /* end confdefs.h. */ |
| 13465 | #include <getopt.h> | 14104 | #include <getopt.h> |
| 14105 | #include <stddef.h> | ||
| 14106 | #include <string.h> | ||
| 14107 | |||
| 13466 | int | 14108 | int |
| 13467 | main () | 14109 | main () |
| 13468 | { | 14110 | { |
| 13469 | 14111 | ||
| 13470 | char *myargv[3]; | 14112 | int result = 0; |
| 13471 | myargv[0] = "conftest"; | 14113 | /* This code succeeds on glibc 2.8, OpenBSD 4.0, Cygwin, mingw, |
| 13472 | myargv[1] = "-+"; | 14114 | and fails on MacOS X 10.5, AIX 5.2, HP-UX 11, IRIX 6.5, |
| 13473 | myargv[2] = 0; | 14115 | OSF/1 5.1, Solaris 10. */ |
| 13474 | return getopt (2, myargv, "+a") != '?'; | 14116 | { |
| 14117 | char *myargv[3]; | ||
| 14118 | myargv[0] = "conftest"; | ||
| 14119 | myargv[1] = "-+"; | ||
| 14120 | myargv[2] = 0; | ||
| 14121 | opterr = 0; | ||
| 14122 | if (getopt (2, myargv, "+a") != '?') | ||
| 14123 | result |= 1; | ||
| 14124 | } | ||
| 14125 | /* This code succeeds on glibc 2.8, mingw, | ||
| 14126 | and fails on MacOS X 10.5, OpenBSD 4.0, AIX 5.2, HP-UX 11, | ||
| 14127 | IRIX 6.5, OSF/1 5.1, Solaris 10, Cygwin 1.5.x. */ | ||
| 14128 | { | ||
| 14129 | char *argv[] = { "program", "-p", "foo", "bar", NULL }; | ||
| 14130 | |||
| 14131 | optind = 1; | ||
| 14132 | if (getopt (4, argv, "p::") != 'p') | ||
| 14133 | result |= 2; | ||
| 14134 | else if (optarg != NULL) | ||
| 14135 | result |= 4; | ||
| 14136 | else if (getopt (4, argv, "p::") != -1) | ||
| 14137 | result |= 6; | ||
| 14138 | else if (optind != 2) | ||
| 14139 | result |= 8; | ||
| 14140 | } | ||
| 14141 | /* This code succeeds on glibc 2.8 and fails on Cygwin 1.7.0. */ | ||
| 14142 | { | ||
| 14143 | char *argv[] = { "program", "foo", "-p", NULL }; | ||
| 14144 | optind = 0; | ||
| 14145 | if (getopt (3, argv, "-p") != 1) | ||
| 14146 | result |= 16; | ||
| 14147 | else if (getopt (3, argv, "-p") != 'p') | ||
| 14148 | result |= 32; | ||
| 14149 | } | ||
| 14150 | /* This code fails on glibc 2.11. */ | ||
| 14151 | { | ||
| 14152 | char *argv[] = { "program", "-b", "-a", NULL }; | ||
| 14153 | optind = opterr = 0; | ||
| 14154 | if (getopt (3, argv, "+:a:b") != 'b') | ||
| 14155 | result |= 64; | ||
| 14156 | else if (getopt (3, argv, "+:a:b") != ':') | ||
| 14157 | result |= 64; | ||
| 14158 | } | ||
| 14159 | return result; | ||
| 13475 | 14160 | ||
| 13476 | ; | 14161 | ; |
| 13477 | return 0; | 14162 | return 0; |
| 13478 | } | 14163 | } |
| 13479 | _ACEOF | 14164 | _ACEOF |
| 13480 | if ac_fn_c_try_run "$LINENO"; then : | 14165 | if ac_fn_c_try_run "$LINENO"; then : |
| 13481 | gl_cv_func_gnu_getopt=yes | 14166 | gl_cv_func_getopt_gnu=yes |
| 13482 | else | 14167 | else |
| 13483 | gl_cv_func_gnu_getopt=no | 14168 | gl_cv_func_getopt_gnu=no |
| 13484 | fi | 14169 | fi |
| 13485 | rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ | 14170 | rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ |
| 13486 | conftest.$ac_objext conftest.beam conftest.$ac_ext | 14171 | conftest.$ac_objext conftest.beam conftest.$ac_ext |
| 13487 | fi | 14172 | fi |
| 13488 | 14173 | ||
| 14174 | case $gl_had_POSIXLY_CORRECT in | ||
| 14175 | exported) ;; | ||
| 14176 | yes) { POSIXLY_CORRECT=; unset POSIXLY_CORRECT;}; POSIXLY_CORRECT=1 ;; | ||
| 14177 | *) { POSIXLY_CORRECT=; unset POSIXLY_CORRECT;} ;; | ||
| 14178 | esac | ||
| 14179 | |||
| 13489 | fi | 14180 | fi |
| 13490 | { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_gnu_getopt" >&5 | 14181 | { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_getopt_gnu" >&5 |
| 13491 | $as_echo "$gl_cv_func_gnu_getopt" >&6; } | 14182 | $as_echo "$gl_cv_func_getopt_gnu" >&6; } |
| 13492 | if test "$gl_cv_func_gnu_getopt" = "no"; then | 14183 | if test "$gl_cv_func_getopt_gnu" = "no"; then |
| 13493 | GETOPT_H=getopt.h | 14184 | gl_replace_getopt=yes |
| 13494 | fi | 14185 | fi |
| 13495 | fi | 14186 | fi |
| 13496 | 14187 | ||
| 14188 | ac_fn_c_check_decl "$LINENO" "getenv" "ac_cv_have_decl_getenv" "$ac_includes_default" | ||
| 14189 | if test "x$ac_cv_have_decl_getenv" = xyes; then : | ||
| 14190 | ac_have_decl=1 | ||
| 14191 | else | ||
| 14192 | ac_have_decl=0 | ||
| 14193 | fi | ||
| 14194 | |||
| 14195 | cat >>confdefs.h <<_ACEOF | ||
| 14196 | #define HAVE_DECL_GETENV $ac_have_decl | ||
| 14197 | _ACEOF | ||
| 14198 | |||
| 14199 | |||
| 14200 | |||
| 14201 | |||
| 14202 | |||
| 13497 | 14203 | ||
| 14204 | if test -n "$gl_replace_getopt"; then : | ||
| 13498 | 14205 | ||
| 13499 | if test -n "$GETOPT_H"; then : | ||
| 13500 | 14206 | ||
| 13501 | 14207 | ||
| 13502 | GETOPT_H=getopt.h | 14208 | GETOPT_H=getopt.h |
| @@ -13505,98 +14211,34 @@ $as_echo "#define __GETOPT_PREFIX rpl_" >>confdefs.h | |||
| 13505 | 14211 | ||
| 13506 | 14212 | ||
| 13507 | 14213 | ||
| 13508 | : | 14214 | GNULIB_UNISTD_H_GETOPT=1 |
| 13509 | GETOPTOBJS='getopt.o getopt1.o' | ||
| 13510 | 14215 | ||
| 13511 | fi | ||
| 13512 | 14216 | ||
| 13513 | 14217 | ||
| 13514 | 14218 | ||
| 13515 | { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether getpgrp requires zero arguments" >&5 | ||
| 13516 | $as_echo_n "checking whether getpgrp requires zero arguments... " >&6; } | ||
| 13517 | if ${ac_cv_func_getpgrp_void+:} false; then : | ||
| 13518 | $as_echo_n "(cached) " >&6 | ||
| 13519 | else | ||
| 13520 | # Use it with a single arg. | ||
| 13521 | cat confdefs.h - <<_ACEOF >conftest.$ac_ext | ||
| 13522 | /* end confdefs.h. */ | ||
| 13523 | $ac_includes_default | ||
| 13524 | int | ||
| 13525 | main () | ||
| 13526 | { | ||
| 13527 | getpgrp (0); | ||
| 13528 | ; | ||
| 13529 | return 0; | ||
| 13530 | } | ||
| 13531 | _ACEOF | ||
| 13532 | if ac_fn_c_try_compile "$LINENO"; then : | ||
| 13533 | ac_cv_func_getpgrp_void=no | ||
| 13534 | else | ||
| 13535 | ac_cv_func_getpgrp_void=yes | ||
| 13536 | fi | ||
| 13537 | rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext | ||
| 13538 | 14219 | ||
| 13539 | fi | ||
| 13540 | { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_getpgrp_void" >&5 | ||
| 13541 | $as_echo "$ac_cv_func_getpgrp_void" >&6; } | ||
| 13542 | if test $ac_cv_func_getpgrp_void = yes; then | ||
| 13543 | 14220 | ||
| 13544 | $as_echo "#define GETPGRP_VOID 1" >>confdefs.h | ||
| 13545 | 14221 | ||
| 13546 | fi | ||
| 13547 | 14222 | ||
| 14223 | gl_LIBOBJS="$gl_LIBOBJS getopt.$ac_objext" | ||
| 13548 | 14224 | ||
| 13549 | # Configure gnulib. | ||
| 13550 | 14225 | ||
| 13551 | 14226 | ||
| 13552 | 14227 | ||
| 13553 | 14228 | ||
| 13554 | LIBC_FATAL_STDERR_=1 | ||
| 13555 | export LIBC_FATAL_STDERR_ | ||
| 13556 | 14229 | ||
| 13557 | 14230 | ||
| 13558 | { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether strtold conforms to C99" >&5 | ||
| 13559 | $as_echo_n "checking whether strtold conforms to C99... " >&6; } | ||
| 13560 | if ${gl_cv_func_c99_strtold+:} false; then : | ||
| 13561 | $as_echo_n "(cached) " >&6 | ||
| 13562 | else | ||
| 13563 | cat confdefs.h - <<_ACEOF >conftest.$ac_ext | ||
| 13564 | /* end confdefs.h. */ | ||
| 13565 | /* On HP-UX before 11.23, strtold returns a struct instead of | ||
| 13566 | long double. Reject implementations like that, by requiring | ||
| 13567 | compatibility with the C99 prototype. */ | ||
| 13568 | #include <stdlib.h> | ||
| 13569 | static long double (*p) (char const *, char **) = strtold; | ||
| 13570 | static long double | ||
| 13571 | test (char const *nptr, char **endptr) | ||
| 13572 | { | ||
| 13573 | long double r; | ||
| 13574 | r = strtold (nptr, endptr); | ||
| 13575 | return r; | ||
| 13576 | } | ||
| 13577 | int | ||
| 13578 | main () | ||
| 13579 | { | ||
| 13580 | return test ("1.0", NULL) != 1 || p ("1.0", NULL) != 1; | ||
| 13581 | ; | ||
| 13582 | return 0; | ||
| 13583 | } | ||
| 13584 | _ACEOF | ||
| 13585 | if ac_fn_c_try_link "$LINENO"; then : | ||
| 13586 | gl_cv_func_c99_strtold=yes | ||
| 13587 | else | ||
| 13588 | gl_cv_func_c99_strtold=no | ||
| 13589 | fi | ||
| 13590 | rm -f core conftest.err conftest.$ac_objext \ | ||
| 13591 | conftest$ac_exeext conftest.$ac_ext | ||
| 13592 | fi | ||
| 13593 | { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_c99_strtold" >&5 | ||
| 13594 | $as_echo "$gl_cv_func_c99_strtold" >&6; } | ||
| 13595 | if test $gl_cv_func_c99_strtold = yes; then | ||
| 13596 | 14231 | ||
| 13597 | $as_echo "#define HAVE_C99_STRTOLD 1" >>confdefs.h | ||
| 13598 | 14232 | ||
| 13599 | fi | 14233 | gl_LIBOBJS="$gl_LIBOBJS getopt1.$ac_objext" |
| 14234 | |||
| 14235 | |||
| 14236 | |||
| 14237 | |||
| 14238 | |||
| 14239 | |||
| 14240 | fi | ||
| 14241 | |||
| 13600 | 14242 | ||
| 13601 | 14243 | ||
| 13602 | GNULIB_MKTIME=0; | 14244 | GNULIB_MKTIME=0; |
| @@ -13757,120 +14399,6 @@ $as_echo "#define HAVE_WCHAR_T 1" >>confdefs.h | |||
| 13757 | 14399 | ||
| 13758 | 14400 | ||
| 13759 | 14401 | ||
| 13760 | { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the preprocessor supports include_next" >&5 | ||
| 13761 | $as_echo_n "checking whether the preprocessor supports include_next... " >&6; } | ||
| 13762 | if ${gl_cv_have_include_next+:} false; then : | ||
| 13763 | $as_echo_n "(cached) " >&6 | ||
| 13764 | else | ||
| 13765 | rm -rf conftestd1a conftestd1b conftestd2 | ||
| 13766 | mkdir conftestd1a conftestd1b conftestd2 | ||
| 13767 | cat <<EOF > conftestd1a/conftest.h | ||
| 13768 | #define DEFINED_IN_CONFTESTD1 | ||
| 13769 | #include_next <conftest.h> | ||
| 13770 | #ifdef DEFINED_IN_CONFTESTD2 | ||
| 13771 | int foo; | ||
| 13772 | #else | ||
| 13773 | #error "include_next doesn't work" | ||
| 13774 | #endif | ||
| 13775 | EOF | ||
| 13776 | cat <<EOF > conftestd1b/conftest.h | ||
| 13777 | #define DEFINED_IN_CONFTESTD1 | ||
| 13778 | #include <stdio.h> | ||
| 13779 | #include_next <conftest.h> | ||
| 13780 | #ifdef DEFINED_IN_CONFTESTD2 | ||
| 13781 | int foo; | ||
| 13782 | #else | ||
| 13783 | #error "include_next doesn't work" | ||
| 13784 | #endif | ||
| 13785 | EOF | ||
| 13786 | cat <<EOF > conftestd2/conftest.h | ||
| 13787 | #ifndef DEFINED_IN_CONFTESTD1 | ||
| 13788 | #error "include_next test doesn't work" | ||
| 13789 | #endif | ||
| 13790 | #define DEFINED_IN_CONFTESTD2 | ||
| 13791 | EOF | ||
| 13792 | gl_save_CPPFLAGS="$CPPFLAGS" | ||
| 13793 | CPPFLAGS="$gl_save_CPPFLAGS -Iconftestd1b -Iconftestd2" | ||
| 13794 | cat confdefs.h - <<_ACEOF >conftest.$ac_ext | ||
| 13795 | /* end confdefs.h. */ | ||
| 13796 | #include <conftest.h> | ||
| 13797 | _ACEOF | ||
| 13798 | if ac_fn_c_try_compile "$LINENO"; then : | ||
| 13799 | gl_cv_have_include_next=yes | ||
| 13800 | else | ||
| 13801 | CPPFLAGS="$gl_save_CPPFLAGS -Iconftestd1a -Iconftestd2" | ||
| 13802 | cat confdefs.h - <<_ACEOF >conftest.$ac_ext | ||
| 13803 | /* end confdefs.h. */ | ||
| 13804 | #include <conftest.h> | ||
| 13805 | _ACEOF | ||
| 13806 | if ac_fn_c_try_compile "$LINENO"; then : | ||
| 13807 | gl_cv_have_include_next=buggy | ||
| 13808 | else | ||
| 13809 | gl_cv_have_include_next=no | ||
| 13810 | fi | ||
| 13811 | rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext | ||
| 13812 | |||
| 13813 | fi | ||
| 13814 | rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext | ||
| 13815 | CPPFLAGS="$gl_save_CPPFLAGS" | ||
| 13816 | rm -rf conftestd1a conftestd1b conftestd2 | ||
| 13817 | |||
| 13818 | fi | ||
| 13819 | { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_have_include_next" >&5 | ||
| 13820 | $as_echo "$gl_cv_have_include_next" >&6; } | ||
| 13821 | PRAGMA_SYSTEM_HEADER= | ||
| 13822 | if test $gl_cv_have_include_next = yes; then | ||
| 13823 | INCLUDE_NEXT=include_next | ||
| 13824 | INCLUDE_NEXT_AS_FIRST_DIRECTIVE=include_next | ||
| 13825 | if test -n "$GCC"; then | ||
| 13826 | PRAGMA_SYSTEM_HEADER='#pragma GCC system_header' | ||
| 13827 | fi | ||
| 13828 | else | ||
| 13829 | if test $gl_cv_have_include_next = buggy; then | ||
| 13830 | INCLUDE_NEXT=include | ||
| 13831 | INCLUDE_NEXT_AS_FIRST_DIRECTIVE=include_next | ||
| 13832 | else | ||
| 13833 | INCLUDE_NEXT=include | ||
| 13834 | INCLUDE_NEXT_AS_FIRST_DIRECTIVE=include | ||
| 13835 | fi | ||
| 13836 | fi | ||
| 13837 | |||
| 13838 | |||
| 13839 | |||
| 13840 | { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether system header files limit the line length" >&5 | ||
| 13841 | $as_echo_n "checking whether system header files limit the line length... " >&6; } | ||
| 13842 | if ${gl_cv_pragma_columns+:} false; then : | ||
| 13843 | $as_echo_n "(cached) " >&6 | ||
| 13844 | else | ||
| 13845 | cat confdefs.h - <<_ACEOF >conftest.$ac_ext | ||
| 13846 | /* end confdefs.h. */ | ||
| 13847 | |||
| 13848 | #ifdef __TANDEM | ||
| 13849 | choke me | ||
| 13850 | #endif | ||
| 13851 | |||
| 13852 | _ACEOF | ||
| 13853 | if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | | ||
| 13854 | $EGREP "choke me" >/dev/null 2>&1; then : | ||
| 13855 | gl_cv_pragma_columns=yes | ||
| 13856 | else | ||
| 13857 | gl_cv_pragma_columns=no | ||
| 13858 | fi | ||
| 13859 | rm -f conftest* | ||
| 13860 | |||
| 13861 | |||
| 13862 | fi | ||
| 13863 | { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_pragma_columns" >&5 | ||
| 13864 | $as_echo "$gl_cv_pragma_columns" >&6; } | ||
| 13865 | if test $gl_cv_pragma_columns = yes; then | ||
| 13866 | PRAGMA_COLUMNS="#pragma COLUMNS 10000" | ||
| 13867 | else | ||
| 13868 | PRAGMA_COLUMNS= | ||
| 13869 | fi | ||
| 13870 | |||
| 13871 | |||
| 13872 | |||
| 13873 | |||
| 13874 | { $as_echo "$as_me:${as_lineno-$LINENO}: checking for C/C++ restrict keyword" >&5 | 14402 | { $as_echo "$as_me:${as_lineno-$LINENO}: checking for C/C++ restrict keyword" >&5 |
| 13875 | $as_echo_n "checking for C/C++ restrict keyword... " >&6; } | 14403 | $as_echo_n "checking for C/C++ restrict keyword... " >&6; } |
| 13876 | if ${ac_cv_c_restrict+:} false; then : | 14404 | if ${ac_cv_c_restrict+:} false; then : |
| @@ -14119,6 +14647,65 @@ fi | |||
| 14119 | # Code from module extensions: | 14647 | # Code from module extensions: |
| 14120 | # Code from module ftoastr: | 14648 | # Code from module ftoastr: |
| 14121 | 14649 | ||
| 14650 | # Code from module getopt-gnu: | ||
| 14651 | |||
| 14652 | |||
| 14653 | |||
| 14654 | |||
| 14655 | |||
| 14656 | |||
| 14657 | |||
| 14658 | $as_echo "#define GNULIB_TEST_GETOPT_GNU 1" >>confdefs.h | ||
| 14659 | |||
| 14660 | |||
| 14661 | # Code from module getopt-posix: | ||
| 14662 | |||
| 14663 | |||
| 14664 | |||
| 14665 | |||
| 14666 | |||
| 14667 | if test -n "$gl_replace_getopt"; then : | ||
| 14668 | |||
| 14669 | |||
| 14670 | |||
| 14671 | GETOPT_H=getopt.h | ||
| 14672 | |||
| 14673 | $as_echo "#define __GETOPT_PREFIX rpl_" >>confdefs.h | ||
| 14674 | |||
| 14675 | |||
| 14676 | |||
| 14677 | GNULIB_UNISTD_H_GETOPT=1 | ||
| 14678 | |||
| 14679 | |||
| 14680 | |||
| 14681 | |||
| 14682 | |||
| 14683 | |||
| 14684 | |||
| 14685 | |||
| 14686 | gl_LIBOBJS="$gl_LIBOBJS getopt.$ac_objext" | ||
| 14687 | |||
| 14688 | |||
| 14689 | |||
| 14690 | |||
| 14691 | |||
| 14692 | |||
| 14693 | |||
| 14694 | |||
| 14695 | |||
| 14696 | gl_LIBOBJS="$gl_LIBOBJS getopt1.$ac_objext" | ||
| 14697 | |||
| 14698 | |||
| 14699 | |||
| 14700 | |||
| 14701 | |||
| 14702 | |||
| 14703 | fi | ||
| 14704 | |||
| 14705 | |||
| 14706 | # Code from module gettext-h: | ||
| 14707 | |||
| 14708 | |||
| 14122 | # Code from module include_next: | 14709 | # Code from module include_next: |
| 14123 | # Code from module intprops: | 14710 | # Code from module intprops: |
| 14124 | # Code from module mktime: | 14711 | # Code from module mktime: |
| @@ -14562,6 +15149,123 @@ $as_echo "#define GNULIB_TEST_TIME_R 1" >>confdefs.h | |||
| 14562 | 15149 | ||
| 14563 | 15150 | ||
| 14564 | 15151 | ||
| 15152 | # Code from module unistd: | ||
| 15153 | |||
| 15154 | |||
| 15155 | |||
| 15156 | |||
| 15157 | |||
| 15158 | |||
| 15159 | |||
| 15160 | |||
| 15161 | |||
| 15162 | |||
| 15163 | if test $gl_cv_have_include_next = yes; then | ||
| 15164 | gl_cv_next_unistd_h='<'unistd.h'>' | ||
| 15165 | else | ||
| 15166 | { $as_echo "$as_me:${as_lineno-$LINENO}: checking absolute name of <unistd.h>" >&5 | ||
| 15167 | $as_echo_n "checking absolute name of <unistd.h>... " >&6; } | ||
| 15168 | if ${gl_cv_next_unistd_h+:} false; then : | ||
| 15169 | $as_echo_n "(cached) " >&6 | ||
| 15170 | else | ||
| 15171 | |||
| 15172 | if test $ac_cv_header_unistd_h = yes; then | ||
| 15173 | cat confdefs.h - <<_ACEOF >conftest.$ac_ext | ||
| 15174 | /* end confdefs.h. */ | ||
| 15175 | #include <unistd.h> | ||
| 15176 | |||
| 15177 | _ACEOF | ||
| 15178 | case "$host_os" in | ||
| 15179 | aix*) gl_absname_cpp="$ac_cpp -C" ;; | ||
| 15180 | *) gl_absname_cpp="$ac_cpp" ;; | ||
| 15181 | esac | ||
| 15182 | gl_cv_next_unistd_h='"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 | | ||
| 15183 | sed -n '\#/unistd.h#{ | ||
| 15184 | s#.*"\(.*/unistd.h\)".*#\1# | ||
| 15185 | s#^/[^/]#//&# | ||
| 15186 | p | ||
| 15187 | q | ||
| 15188 | }'`'"' | ||
| 15189 | else | ||
| 15190 | gl_cv_next_unistd_h='<'unistd.h'>' | ||
| 15191 | fi | ||
| 15192 | |||
| 15193 | fi | ||
| 15194 | { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_next_unistd_h" >&5 | ||
| 15195 | $as_echo "$gl_cv_next_unistd_h" >&6; } | ||
| 15196 | fi | ||
| 15197 | NEXT_UNISTD_H=$gl_cv_next_unistd_h | ||
| 15198 | |||
| 15199 | if test $gl_cv_have_include_next = yes || test $gl_cv_have_include_next = buggy; then | ||
| 15200 | # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include_next' | ||
| 15201 | gl_next_as_first_directive='<'unistd.h'>' | ||
| 15202 | else | ||
| 15203 | # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include' | ||
| 15204 | gl_next_as_first_directive=$gl_cv_next_unistd_h | ||
| 15205 | fi | ||
| 15206 | NEXT_AS_FIRST_DIRECTIVE_UNISTD_H=$gl_next_as_first_directive | ||
| 15207 | |||
| 15208 | |||
| 15209 | |||
| 15210 | |||
| 15211 | |||
| 15212 | if test $ac_cv_header_unistd_h = yes; then | ||
| 15213 | HAVE_UNISTD_H=1 | ||
| 15214 | else | ||
| 15215 | HAVE_UNISTD_H=0 | ||
| 15216 | fi | ||
| 15217 | |||
| 15218 | |||
| 15219 | |||
| 15220 | for gl_func in chown dup2 dup3 environ euidaccess faccessat fchdir fchownat fsync ftruncate getcwd getdomainname getdtablesize getgroups gethostname getlogin getlogin_r getpagesize getusershell setusershell endusershell lchown link linkat lseek pipe pipe2 pread pwrite readlink readlinkat rmdir sleep symlink symlinkat ttyname_r unlink unlinkat usleep; do | ||
| 15221 | as_gl_Symbol=`$as_echo "gl_cv_have_raw_decl_$gl_func" | $as_tr_sh` | ||
| 15222 | { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $gl_func is declared without a macro" >&5 | ||
| 15223 | $as_echo_n "checking whether $gl_func is declared without a macro... " >&6; } | ||
| 15224 | if eval \${$as_gl_Symbol+:} false; then : | ||
| 15225 | $as_echo_n "(cached) " >&6 | ||
| 15226 | else | ||
| 15227 | cat confdefs.h - <<_ACEOF >conftest.$ac_ext | ||
| 15228 | /* end confdefs.h. */ | ||
| 15229 | #include <unistd.h> | ||
| 15230 | /* Some systems declare various items in the wrong headers. */ | ||
| 15231 | #if !(defined __GLIBC__ && !defined __UCLIBC__) | ||
| 15232 | # include <fcntl.h> | ||
| 15233 | # include <stdio.h> | ||
| 15234 | # include <stdlib.h> | ||
| 15235 | # if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ | ||
| 15236 | # include <io.h> | ||
| 15237 | # endif | ||
| 15238 | #endif | ||
| 15239 | |||
| 15240 | int | ||
| 15241 | main () | ||
| 15242 | { | ||
| 15243 | #undef $gl_func | ||
| 15244 | (void) $gl_func; | ||
| 15245 | ; | ||
| 15246 | return 0; | ||
| 15247 | } | ||
| 15248 | _ACEOF | ||
| 15249 | if ac_fn_c_try_compile "$LINENO"; then : | ||
| 15250 | eval "$as_gl_Symbol=yes" | ||
| 15251 | else | ||
| 15252 | eval "$as_gl_Symbol=no" | ||
| 15253 | fi | ||
| 15254 | rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext | ||
| 15255 | fi | ||
| 15256 | eval ac_res=\$$as_gl_Symbol | ||
| 15257 | { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 | ||
| 15258 | $as_echo "$ac_res" >&6; } | ||
| 15259 | if eval test \"x\$"$as_gl_Symbol"\" = x"yes"; then : | ||
| 15260 | cat >>confdefs.h <<_ACEOF | ||
| 15261 | #define `$as_echo "HAVE_RAW_DECL_$gl_func" | $as_tr_cpp` 1 | ||
| 15262 | _ACEOF | ||
| 15263 | |||
| 15264 | eval ac_cv_have_decl_$gl_func=yes | ||
| 15265 | fi | ||
| 15266 | done | ||
| 15267 | |||
| 15268 | |||
| 14565 | # Code from module warn-on-use: | 15269 | # Code from module warn-on-use: |
| 14566 | # End of code from modules | 15270 | # End of code from modules |
| 14567 | 15271 | ||
diff --git a/lib-src/ChangeLog b/lib-src/ChangeLog index 7da5d2104ee..545b4746b95 100644 --- a/lib-src/ChangeLog +++ b/lib-src/ChangeLog | |||
| @@ -1,3 +1,15 @@ | |||
| 1 | 2011-01-09 Paul Eggert <eggert@cs.ucla.edu> | ||
| 2 | |||
| 3 | Remove unused files. | ||
| 4 | * getopt.c, getopt1.c, getopt_.h, getopt_int.h: Remove. | ||
| 5 | These files are now in ../lib, copied from gnulib. | ||
| 6 | |||
| 7 | Use gnulib's getopt-gnu module. | ||
| 8 | * Makefile.in (mostlyclean): Do not clean getopt.h or getopt.h-t, | ||
| 9 | as these are now done by gnulib. | ||
| 10 | (GETOPT_H, getopt.h, GETOPTOBJS, GETOPTDEPS, getopt.o, getopt1.o): | ||
| 11 | Remove; now done by gnulib. All uses removed. | ||
| 12 | |||
| 1 | 2011-01-08 Paul Eggert <eggert@cs.ucla.edu> | 13 | 2011-01-08 Paul Eggert <eggert@cs.ucla.edu> |
| 2 | 14 | ||
| 3 | Automate syncing from gnulib. | 15 | Automate syncing from gnulib. |
diff --git a/lib-src/getopt.c b/lib-src/getopt.c deleted file mode 100644 index 587c2e0f618..00000000000 --- a/lib-src/getopt.c +++ /dev/null | |||
| @@ -1,1245 +0,0 @@ | |||
| 1 | /* Getopt for GNU. | ||
| 2 | NOTE: getopt is now 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 | ||
| 4 | before changing it! | ||
| 5 | Copyright (C) 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, | ||
| 6 | 1995, 1996, 1998, 1999, 2000, 2001, 2002, 2003, | ||
| 7 | 2004, 2005, 2006, 2007 Free Software Foundation, Inc. | ||
| 8 | This file is part of the GNU C Library. | ||
| 9 | |||
| 10 | This program is free software; you can redistribute it and/or modify | ||
| 11 | it under the terms of the GNU General Public License as published by | ||
| 12 | the Free Software Foundation; either version 3, or (at your option) | ||
| 13 | any later version. | ||
| 14 | |||
| 15 | This program is distributed in the hope that it will be useful, | ||
| 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 18 | GNU General Public License for more details. | ||
| 19 | |||
| 20 | You should have received a copy of the GNU General Public License along | ||
| 21 | with this program; if not, write to the Free Software Foundation, | ||
| 22 | Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ | ||
| 23 | |||
| 24 | /* This tells Alpha OSF/1 not to define a getopt prototype in <stdio.h>. | ||
| 25 | Ditto for AIX 3.2 and <stdlib.h>. */ | ||
| 26 | #ifndef _NO_PROTO | ||
| 27 | # define _NO_PROTO | ||
| 28 | #endif | ||
| 29 | |||
| 30 | #ifdef HAVE_CONFIG_H | ||
| 31 | # include <config.h> | ||
| 32 | #endif | ||
| 33 | |||
| 34 | #include <stdio.h> | ||
| 35 | |||
| 36 | /* This needs to come after some library #include | ||
| 37 | to get __GNU_LIBRARY__ defined. */ | ||
| 38 | #ifdef __GNU_LIBRARY__ | ||
| 39 | /* Don't include stdlib.h for non-GNU C libraries because some of them | ||
| 40 | contain conflicting prototypes for getopt. */ | ||
| 41 | # include <stdlib.h> | ||
| 42 | # include <unistd.h> | ||
| 43 | #endif /* GNU C library. */ | ||
| 44 | |||
| 45 | #include <string.h> | ||
| 46 | |||
| 47 | #ifdef VMS | ||
| 48 | # include <unixlib.h> | ||
| 49 | #endif | ||
| 50 | |||
| 51 | #ifdef _LIBC | ||
| 52 | # include <libintl.h> | ||
| 53 | #else | ||
| 54 | # include "gettext.h" | ||
| 55 | # define _(msgid) gettext (msgid) | ||
| 56 | #endif | ||
| 57 | |||
| 58 | #if defined _LIBC && defined USE_IN_LIBIO | ||
| 59 | # include <wchar.h> | ||
| 60 | #endif | ||
| 61 | |||
| 62 | #ifndef attribute_hidden | ||
| 63 | # define attribute_hidden | ||
| 64 | #endif | ||
| 65 | |||
| 66 | /* Unlike standard Unix `getopt', functions like `getopt_long' | ||
| 67 | let the user intersperse the options with the other arguments. | ||
| 68 | |||
| 69 | As `getopt_long' works, it permutes the elements of ARGV so that, | ||
| 70 | when it is done, all the options precede everything else. Thus | ||
| 71 | all application programs are extended to handle flexible argument order. | ||
| 72 | |||
| 73 | Using `getopt' or setting the environment variable POSIXLY_CORRECT | ||
| 74 | disables permutation. | ||
| 75 | Then the application's behavior is completely standard. | ||
| 76 | |||
| 77 | GNU application programs can use a third alternative mode in which | ||
| 78 | they can distinguish the relative order of options and other arguments. */ | ||
| 79 | |||
| 80 | #include "getopt.h" | ||
| 81 | #include "getopt_int.h" | ||
| 82 | |||
| 83 | /* For communication from `getopt' to the caller. | ||
| 84 | When `getopt' finds an option that takes an argument, | ||
| 85 | the argument value is returned here. | ||
| 86 | Also, when `ordering' is RETURN_IN_ORDER, | ||
| 87 | each non-option ARGV-element is returned here. */ | ||
| 88 | |||
| 89 | char *optarg; | ||
| 90 | |||
| 91 | /* Index in ARGV of the next element to be scanned. | ||
| 92 | This is used for communication to and from the caller | ||
| 93 | and for communication between successive calls to `getopt'. | ||
| 94 | |||
| 95 | On entry to `getopt', zero means this is the first call; initialize. | ||
| 96 | |||
| 97 | When `getopt' returns -1, this is the index of the first of the | ||
| 98 | non-option elements that the caller should itself scan. | ||
| 99 | |||
| 100 | Otherwise, `optind' communicates from one call to the next | ||
| 101 | how much of ARGV has been scanned so far. */ | ||
| 102 | |||
| 103 | /* 1003.2 says this must be 1 before any call. */ | ||
| 104 | int optind = 1; | ||
| 105 | |||
| 106 | /* Callers store zero here to inhibit the error message | ||
| 107 | for unrecognized options. */ | ||
| 108 | |||
| 109 | int opterr = 1; | ||
| 110 | |||
| 111 | /* Set to an option character which was unrecognized. | ||
| 112 | This must be initialized on some systems to avoid linking in the | ||
| 113 | system's own getopt implementation. */ | ||
| 114 | |||
| 115 | int optopt = '?'; | ||
| 116 | |||
| 117 | /* Keep a global copy of all internal members of getopt_data. */ | ||
| 118 | |||
| 119 | static struct _getopt_data getopt_data; | ||
| 120 | |||
| 121 | |||
| 122 | #ifndef __GNU_LIBRARY__ | ||
| 123 | |||
| 124 | /* Avoid depending on library functions or files | ||
| 125 | whose names are inconsistent. */ | ||
| 126 | |||
| 127 | #ifndef getenv | ||
| 128 | extern char *getenv (); | ||
| 129 | #endif | ||
| 130 | |||
| 131 | #endif /* not __GNU_LIBRARY__ */ | ||
| 132 | |||
| 133 | #ifdef _LIBC | ||
| 134 | /* Stored original parameters. | ||
| 135 | XXX This is no good solution. We should rather copy the args so | ||
| 136 | that we can compare them later. But we must not use malloc(3). */ | ||
| 137 | extern int __libc_argc; | ||
| 138 | extern char **__libc_argv; | ||
| 139 | |||
| 140 | /* Bash 2.0 gives us an environment variable containing flags | ||
| 141 | indicating ARGV elements that should not be considered arguments. */ | ||
| 142 | |||
| 143 | # ifdef USE_NONOPTION_FLAGS | ||
| 144 | /* Defined in getopt_init.c */ | ||
| 145 | extern char *__getopt_nonoption_flags; | ||
| 146 | # endif | ||
| 147 | |||
| 148 | # ifdef USE_NONOPTION_FLAGS | ||
| 149 | # define SWAP_FLAGS(ch1, ch2) \ | ||
| 150 | if (d->__nonoption_flags_len > 0) \ | ||
| 151 | { \ | ||
| 152 | char __tmp = __getopt_nonoption_flags[ch1]; \ | ||
| 153 | __getopt_nonoption_flags[ch1] = __getopt_nonoption_flags[ch2]; \ | ||
| 154 | __getopt_nonoption_flags[ch2] = __tmp; \ | ||
| 155 | } | ||
| 156 | # else | ||
| 157 | # define SWAP_FLAGS(ch1, ch2) | ||
| 158 | # endif | ||
| 159 | #else /* !_LIBC */ | ||
| 160 | # define SWAP_FLAGS(ch1, ch2) | ||
| 161 | #endif /* _LIBC */ | ||
| 162 | |||
| 163 | /* Exchange two adjacent subsequences of ARGV. | ||
| 164 | One subsequence is elements [first_nonopt,last_nonopt) | ||
| 165 | which contains all the non-options that have been skipped so far. | ||
| 166 | The other is elements [last_nonopt,optind), which contains all | ||
| 167 | the options processed since those non-options were skipped. | ||
| 168 | |||
| 169 | `first_nonopt' and `last_nonopt' are relocated so that they describe | ||
| 170 | the new indices of the non-options in ARGV after they are moved. */ | ||
| 171 | |||
| 172 | static void | ||
| 173 | exchange (char **argv, struct _getopt_data *d) | ||
| 174 | { | ||
| 175 | int bottom = d->__first_nonopt; | ||
| 176 | int middle = d->__last_nonopt; | ||
| 177 | int top = d->optind; | ||
| 178 | char *tem; | ||
| 179 | |||
| 180 | /* Exchange the shorter segment with the far end of the longer segment. | ||
| 181 | That puts the shorter segment into the right place. | ||
| 182 | It leaves the longer segment in the right place overall, | ||
| 183 | but it consists of two parts that need to be swapped next. */ | ||
| 184 | |||
| 185 | #if defined _LIBC && defined USE_NONOPTION_FLAGS | ||
| 186 | /* First make sure the handling of the `__getopt_nonoption_flags' | ||
| 187 | string can work normally. Our top argument must be in the range | ||
| 188 | of the string. */ | ||
| 189 | if (d->__nonoption_flags_len > 0 && top >= d->__nonoption_flags_max_len) | ||
| 190 | { | ||
| 191 | /* We must extend the array. The user plays games with us and | ||
| 192 | presents new arguments. */ | ||
| 193 | char *new_str = malloc (top + 1); | ||
| 194 | if (new_str == NULL) | ||
| 195 | d->__nonoption_flags_len = d->__nonoption_flags_max_len = 0; | ||
| 196 | else | ||
| 197 | { | ||
| 198 | memset (__mempcpy (new_str, __getopt_nonoption_flags, | ||
| 199 | d->__nonoption_flags_max_len), | ||
| 200 | '\0', top + 1 - d->__nonoption_flags_max_len); | ||
| 201 | d->__nonoption_flags_max_len = top + 1; | ||
| 202 | __getopt_nonoption_flags = new_str; | ||
| 203 | } | ||
| 204 | } | ||
| 205 | #endif | ||
| 206 | |||
| 207 | while (top > middle && middle > bottom) | ||
| 208 | { | ||
| 209 | if (top - middle > middle - bottom) | ||
| 210 | { | ||
| 211 | /* Bottom segment is the short one. */ | ||
| 212 | int len = middle - bottom; | ||
| 213 | register int i; | ||
| 214 | |||
| 215 | /* Swap it with the top part of the top segment. */ | ||
| 216 | for (i = 0; i < len; i++) | ||
| 217 | { | ||
| 218 | tem = argv[bottom + i]; | ||
| 219 | argv[bottom + i] = argv[top - (middle - bottom) + i]; | ||
| 220 | argv[top - (middle - bottom) + i] = tem; | ||
| 221 | SWAP_FLAGS (bottom + i, top - (middle - bottom) + i); | ||
| 222 | } | ||
| 223 | /* Exclude the moved bottom segment from further swapping. */ | ||
| 224 | top -= len; | ||
| 225 | } | ||
| 226 | else | ||
| 227 | { | ||
| 228 | /* Top segment is the short one. */ | ||
| 229 | int len = top - middle; | ||
| 230 | register int i; | ||
| 231 | |||
| 232 | /* Swap it with the bottom part of the bottom segment. */ | ||
| 233 | for (i = 0; i < len; i++) | ||
| 234 | { | ||
| 235 | tem = argv[bottom + i]; | ||
| 236 | argv[bottom + i] = argv[middle + i]; | ||
| 237 | argv[middle + i] = tem; | ||
| 238 | SWAP_FLAGS (bottom + i, middle + i); | ||
| 239 | } | ||
| 240 | /* Exclude the moved top segment from further swapping. */ | ||
| 241 | bottom += len; | ||
| 242 | } | ||
| 243 | } | ||
| 244 | |||
| 245 | /* Update records for the slots the non-options now occupy. */ | ||
| 246 | |||
| 247 | d->__first_nonopt += (d->optind - d->__last_nonopt); | ||
| 248 | d->__last_nonopt = d->optind; | ||
| 249 | } | ||
| 250 | |||
| 251 | /* Initialize the internal data when the first call is made. */ | ||
| 252 | |||
| 253 | static const char * | ||
| 254 | _getopt_initialize (int argc, char **argv, const char *optstring, | ||
| 255 | int posixly_correct, struct _getopt_data *d) | ||
| 256 | { | ||
| 257 | /* Start processing options with ARGV-element 1 (since ARGV-element 0 | ||
| 258 | is the program name); the sequence of previously skipped | ||
| 259 | non-option ARGV-elements is empty. */ | ||
| 260 | |||
| 261 | d->__first_nonopt = d->__last_nonopt = d->optind; | ||
| 262 | |||
| 263 | d->__nextchar = NULL; | ||
| 264 | |||
| 265 | d->__posixly_correct = posixly_correct || !!getenv ("POSIXLY_CORRECT"); | ||
| 266 | |||
| 267 | /* Determine how to handle the ordering of options and nonoptions. */ | ||
| 268 | |||
| 269 | if (optstring[0] == '-') | ||
| 270 | { | ||
| 271 | d->__ordering = RETURN_IN_ORDER; | ||
| 272 | ++optstring; | ||
| 273 | } | ||
| 274 | else if (optstring[0] == '+') | ||
| 275 | { | ||
| 276 | d->__ordering = REQUIRE_ORDER; | ||
| 277 | ++optstring; | ||
| 278 | } | ||
| 279 | else if (d->__posixly_correct) | ||
| 280 | d->__ordering = REQUIRE_ORDER; | ||
| 281 | else | ||
| 282 | d->__ordering = PERMUTE; | ||
| 283 | |||
| 284 | #if defined _LIBC && defined USE_NONOPTION_FLAGS | ||
| 285 | if (!d->__posixly_correct | ||
| 286 | && argc == __libc_argc && argv == __libc_argv) | ||
| 287 | { | ||
| 288 | if (d->__nonoption_flags_max_len == 0) | ||
| 289 | { | ||
| 290 | if (__getopt_nonoption_flags == NULL | ||
| 291 | || __getopt_nonoption_flags[0] == '\0') | ||
| 292 | d->__nonoption_flags_max_len = -1; | ||
| 293 | else | ||
| 294 | { | ||
| 295 | const char *orig_str = __getopt_nonoption_flags; | ||
| 296 | int len = d->__nonoption_flags_max_len = strlen (orig_str); | ||
| 297 | if (d->__nonoption_flags_max_len < argc) | ||
| 298 | d->__nonoption_flags_max_len = argc; | ||
| 299 | __getopt_nonoption_flags = | ||
| 300 | (char *) malloc (d->__nonoption_flags_max_len); | ||
| 301 | if (__getopt_nonoption_flags == NULL) | ||
| 302 | d->__nonoption_flags_max_len = -1; | ||
| 303 | else | ||
| 304 | memset (__mempcpy (__getopt_nonoption_flags, orig_str, len), | ||
| 305 | '\0', d->__nonoption_flags_max_len - len); | ||
| 306 | } | ||
| 307 | } | ||
| 308 | d->__nonoption_flags_len = d->__nonoption_flags_max_len; | ||
| 309 | } | ||
| 310 | else | ||
| 311 | d->__nonoption_flags_len = 0; | ||
| 312 | #endif | ||
| 313 | |||
| 314 | return optstring; | ||
| 315 | } | ||
| 316 | |||
| 317 | /* Scan elements of ARGV (whose length is ARGC) for option characters | ||
| 318 | given in OPTSTRING. | ||
| 319 | |||
| 320 | If an element of ARGV starts with '-', and is not exactly "-" or "--", | ||
| 321 | then it is an option element. The characters of this element | ||
| 322 | (aside from the initial '-') are option characters. If `getopt' | ||
| 323 | is called repeatedly, it returns successively each of the option characters | ||
| 324 | from each of the option elements. | ||
| 325 | |||
| 326 | If `getopt' finds another option character, it returns that character, | ||
| 327 | updating `optind' and `nextchar' so that the next call to `getopt' can | ||
| 328 | resume the scan with the following option character or ARGV-element. | ||
| 329 | |||
| 330 | If there are no more option characters, `getopt' returns -1. | ||
| 331 | Then `optind' is the index in ARGV of the first ARGV-element | ||
| 332 | that is not an option. (The ARGV-elements have been permuted | ||
| 333 | so that those that are not options now come last.) | ||
| 334 | |||
| 335 | OPTSTRING is a string containing the legitimate option characters. | ||
| 336 | If an option character is seen that is not listed in OPTSTRING, | ||
| 337 | return '?' after printing an error message. If you set `opterr' to | ||
| 338 | zero, the error message is suppressed but we still return '?'. | ||
| 339 | |||
| 340 | If a char in OPTSTRING is followed by a colon, that means it wants an arg, | ||
| 341 | so the following text in the same ARGV-element, or the text of the following | ||
| 342 | ARGV-element, is returned in `optarg'. Two colons mean an option that | ||
| 343 | wants an optional arg; if there is text in the current ARGV-element, | ||
| 344 | it is returned in `optarg', otherwise `optarg' is set to zero. | ||
| 345 | |||
| 346 | If OPTSTRING starts with `-' or `+', it requests different methods of | ||
| 347 | handling the non-option ARGV-elements. | ||
| 348 | See the comments about RETURN_IN_ORDER and REQUIRE_ORDER, above. | ||
| 349 | |||
| 350 | Long-named options begin with `--' instead of `-'. | ||
| 351 | Their names may be abbreviated as long as the abbreviation is unique | ||
| 352 | or is an exact match for some defined option. If they have an | ||
| 353 | argument, it follows the option name in the same ARGV-element, separated | ||
| 354 | from the option name by a `=', or else the in next ARGV-element. | ||
| 355 | When `getopt' finds a long-named option, it returns 0 if that option's | ||
| 356 | `flag' field is nonzero, the value of the option's `val' field | ||
| 357 | if the `flag' field is zero. | ||
| 358 | |||
| 359 | LONGOPTS is a vector of `struct option' terminated by an | ||
| 360 | element containing a name which is zero. | ||
| 361 | |||
| 362 | LONGIND returns the index in LONGOPT of the long-named option found. | ||
| 363 | It is only valid when a long-named option has been found by the most | ||
| 364 | recent call. | ||
| 365 | |||
| 366 | If LONG_ONLY is nonzero, '-' as well as '--' can introduce | ||
| 367 | long-named options. | ||
| 368 | |||
| 369 | If POSIXLY_CORRECT is nonzero, behave as if the POSIXLY_CORRECT | ||
| 370 | environment variable were set. */ | ||
| 371 | |||
| 372 | int | ||
| 373 | _getopt_internal_r (int argc, char **argv, const char *optstring, | ||
| 374 | const struct option *longopts, int *longind, | ||
| 375 | int long_only, int posixly_correct, struct _getopt_data *d) | ||
| 376 | { | ||
| 377 | int print_errors = d->opterr; | ||
| 378 | if (optstring[0] == ':') | ||
| 379 | print_errors = 0; | ||
| 380 | |||
| 381 | if (argc < 1) | ||
| 382 | return -1; | ||
| 383 | |||
| 384 | d->optarg = NULL; | ||
| 385 | |||
| 386 | if (d->optind == 0 || !d->__initialized) | ||
| 387 | { | ||
| 388 | if (d->optind == 0) | ||
| 389 | d->optind = 1; /* Don't scan ARGV[0], the program name. */ | ||
| 390 | optstring = _getopt_initialize (argc, argv, optstring, | ||
| 391 | posixly_correct, d); | ||
| 392 | d->__initialized = 1; | ||
| 393 | } | ||
| 394 | |||
| 395 | /* Test whether ARGV[optind] points to a non-option argument. | ||
| 396 | Either it does not have option syntax, or there is an environment flag | ||
| 397 | from the shell indicating it is not an option. The later information | ||
| 398 | is only used when the used in the GNU libc. */ | ||
| 399 | #if defined _LIBC && defined USE_NONOPTION_FLAGS | ||
| 400 | # define NONOPTION_P (argv[d->optind][0] != '-' || argv[d->optind][1] == '\0' \ | ||
| 401 | || (d->optind < d->__nonoption_flags_len \ | ||
| 402 | && __getopt_nonoption_flags[d->optind] == '1')) | ||
| 403 | #else | ||
| 404 | # define NONOPTION_P (argv[d->optind][0] != '-' || argv[d->optind][1] == '\0') | ||
| 405 | #endif | ||
| 406 | |||
| 407 | if (d->__nextchar == NULL || *d->__nextchar == '\0') | ||
| 408 | { | ||
| 409 | /* Advance to the next ARGV-element. */ | ||
| 410 | |||
| 411 | /* Give FIRST_NONOPT & LAST_NONOPT rational values if OPTIND has been | ||
| 412 | moved back by the user (who may also have changed the arguments). */ | ||
| 413 | if (d->__last_nonopt > d->optind) | ||
| 414 | d->__last_nonopt = d->optind; | ||
| 415 | if (d->__first_nonopt > d->optind) | ||
| 416 | d->__first_nonopt = d->optind; | ||
| 417 | |||
| 418 | if (d->__ordering == PERMUTE) | ||
| 419 | { | ||
| 420 | /* If we have just processed some options following some non-options, | ||
| 421 | exchange them so that the options come first. */ | ||
| 422 | |||
| 423 | if (d->__first_nonopt != d->__last_nonopt | ||
| 424 | && d->__last_nonopt != d->optind) | ||
| 425 | exchange ((char **) argv, d); | ||
| 426 | else if (d->__last_nonopt != d->optind) | ||
| 427 | d->__first_nonopt = d->optind; | ||
| 428 | |||
| 429 | /* Skip any additional non-options | ||
| 430 | and extend the range of non-options previously skipped. */ | ||
| 431 | |||
| 432 | while (d->optind < argc && NONOPTION_P) | ||
| 433 | d->optind++; | ||
| 434 | d->__last_nonopt = d->optind; | ||
| 435 | } | ||
| 436 | |||
| 437 | /* The special ARGV-element `--' means premature end of options. | ||
| 438 | Skip it like a null option, | ||
| 439 | then exchange with previous non-options as if it were an option, | ||
| 440 | then skip everything else like a non-option. */ | ||
| 441 | |||
| 442 | if (d->optind != argc && !strcmp (argv[d->optind], "--")) | ||
| 443 | { | ||
| 444 | d->optind++; | ||
| 445 | |||
| 446 | if (d->__first_nonopt != d->__last_nonopt | ||
| 447 | && d->__last_nonopt != d->optind) | ||
| 448 | exchange ((char **) argv, d); | ||
| 449 | else if (d->__first_nonopt == d->__last_nonopt) | ||
| 450 | d->__first_nonopt = d->optind; | ||
| 451 | d->__last_nonopt = argc; | ||
| 452 | |||
| 453 | d->optind = argc; | ||
| 454 | } | ||
| 455 | |||
| 456 | /* If we have done all the ARGV-elements, stop the scan | ||
| 457 | and back over any non-options that we skipped and permuted. */ | ||
| 458 | |||
| 459 | if (d->optind == argc) | ||
| 460 | { | ||
| 461 | /* Set the next-arg-index to point at the non-options | ||
| 462 | that we previously skipped, so the caller will digest them. */ | ||
| 463 | if (d->__first_nonopt != d->__last_nonopt) | ||
| 464 | d->optind = d->__first_nonopt; | ||
| 465 | return -1; | ||
| 466 | } | ||
| 467 | |||
| 468 | /* If we have come to a non-option and did not permute it, | ||
| 469 | either stop the scan or describe it to the caller and pass it by. */ | ||
| 470 | |||
| 471 | if (NONOPTION_P) | ||
| 472 | { | ||
| 473 | if (d->__ordering == REQUIRE_ORDER) | ||
| 474 | return -1; | ||
| 475 | d->optarg = argv[d->optind++]; | ||
| 476 | return 1; | ||
| 477 | } | ||
| 478 | |||
| 479 | /* We have found another option-ARGV-element. | ||
| 480 | Skip the initial punctuation. */ | ||
| 481 | |||
| 482 | d->__nextchar = (argv[d->optind] + 1 | ||
| 483 | + (longopts != NULL && argv[d->optind][1] == '-')); | ||
| 484 | } | ||
| 485 | |||
| 486 | /* Decode the current option-ARGV-element. */ | ||
| 487 | |||
| 488 | /* Check whether the ARGV-element is a long option. | ||
| 489 | |||
| 490 | If long_only and the ARGV-element has the form "-f", where f is | ||
| 491 | a valid short option, don't consider it an abbreviated form of | ||
| 492 | a long option that starts with f. Otherwise there would be no | ||
| 493 | way to give the -f short option. | ||
| 494 | |||
| 495 | On the other hand, if there's a long option "fubar" and | ||
| 496 | the ARGV-element is "-fu", do consider that an abbreviation of | ||
| 497 | the long option, just like "--fu", and not "-f" with arg "u". | ||
| 498 | |||
| 499 | This distinction seems to be the most useful approach. */ | ||
| 500 | |||
| 501 | if (longopts != NULL | ||
| 502 | && (argv[d->optind][1] == '-' | ||
| 503 | || (long_only && (argv[d->optind][2] | ||
| 504 | || !strchr (optstring, argv[d->optind][1]))))) | ||
| 505 | { | ||
| 506 | char *nameend; | ||
| 507 | const struct option *p; | ||
| 508 | const struct option *pfound = NULL; | ||
| 509 | int exact = 0; | ||
| 510 | int ambig = 0; | ||
| 511 | int indfound = -1; | ||
| 512 | int option_index; | ||
| 513 | |||
| 514 | for (nameend = d->__nextchar; *nameend && *nameend != '='; nameend++) | ||
| 515 | /* Do nothing. */ ; | ||
| 516 | |||
| 517 | /* Test all long options for either exact match | ||
| 518 | or abbreviated matches. */ | ||
| 519 | for (p = longopts, option_index = 0; p->name; p++, option_index++) | ||
| 520 | if (!strncmp (p->name, d->__nextchar, nameend - d->__nextchar)) | ||
| 521 | { | ||
| 522 | if ((unsigned int) (nameend - d->__nextchar) | ||
| 523 | == (unsigned int) strlen (p->name)) | ||
| 524 | { | ||
| 525 | /* Exact match found. */ | ||
| 526 | pfound = p; | ||
| 527 | indfound = option_index; | ||
| 528 | exact = 1; | ||
| 529 | break; | ||
| 530 | } | ||
| 531 | else if (pfound == NULL) | ||
| 532 | { | ||
| 533 | /* First nonexact match found. */ | ||
| 534 | pfound = p; | ||
| 535 | indfound = option_index; | ||
| 536 | } | ||
| 537 | else if (long_only | ||
| 538 | || pfound->has_arg != p->has_arg | ||
| 539 | || pfound->flag != p->flag | ||
| 540 | || pfound->val != p->val) | ||
| 541 | /* Second or later nonexact match found. */ | ||
| 542 | ambig = 1; | ||
| 543 | } | ||
| 544 | |||
| 545 | if (ambig && !exact) | ||
| 546 | { | ||
| 547 | if (print_errors) | ||
| 548 | { | ||
| 549 | #if defined _LIBC && defined USE_IN_LIBIO | ||
| 550 | char *buf; | ||
| 551 | |||
| 552 | if (__asprintf (&buf, _("%s: option `%s' is ambiguous\n"), | ||
| 553 | argv[0], argv[d->optind]) >= 0) | ||
| 554 | { | ||
| 555 | _IO_flockfile (stderr); | ||
| 556 | |||
| 557 | int old_flags2 = ((_IO_FILE *) stderr)->_flags2; | ||
| 558 | ((_IO_FILE *) stderr)->_flags2 |= _IO_FLAGS2_NOTCANCEL; | ||
| 559 | |||
| 560 | if (_IO_fwide (stderr, 0) > 0) | ||
| 561 | __fwprintf (stderr, L"%s", buf); | ||
| 562 | else | ||
| 563 | fputs (buf, stderr); | ||
| 564 | |||
| 565 | ((_IO_FILE *) stderr)->_flags2 = old_flags2; | ||
| 566 | _IO_funlockfile (stderr); | ||
| 567 | |||
| 568 | free (buf); | ||
| 569 | } | ||
| 570 | #else | ||
| 571 | fprintf (stderr, _("%s: option `%s' is ambiguous\n"), | ||
| 572 | argv[0], argv[d->optind]); | ||
| 573 | #endif | ||
| 574 | } | ||
| 575 | d->__nextchar += strlen (d->__nextchar); | ||
| 576 | d->optind++; | ||
| 577 | d->optopt = 0; | ||
| 578 | return '?'; | ||
| 579 | } | ||
| 580 | |||
| 581 | if (pfound != NULL) | ||
| 582 | { | ||
| 583 | option_index = indfound; | ||
| 584 | d->optind++; | ||
| 585 | if (*nameend) | ||
| 586 | { | ||
| 587 | /* Don't test has_arg with >, because some C compilers don't | ||
| 588 | allow it to be used on enums. */ | ||
| 589 | if (pfound->has_arg) | ||
| 590 | d->optarg = nameend + 1; | ||
| 591 | else | ||
| 592 | { | ||
| 593 | if (print_errors) | ||
| 594 | { | ||
| 595 | #if defined _LIBC && defined USE_IN_LIBIO | ||
| 596 | char *buf; | ||
| 597 | int n; | ||
| 598 | #endif | ||
| 599 | |||
| 600 | if (argv[d->optind - 1][1] == '-') | ||
| 601 | { | ||
| 602 | /* --option */ | ||
| 603 | #if defined _LIBC && defined USE_IN_LIBIO | ||
| 604 | n = __asprintf (&buf, _("\ | ||
| 605 | %s: option `--%s' doesn't allow an argument\n"), | ||
| 606 | argv[0], pfound->name); | ||
| 607 | #else | ||
| 608 | fprintf (stderr, _("\ | ||
| 609 | %s: option `--%s' doesn't allow an argument\n"), | ||
| 610 | argv[0], pfound->name); | ||
| 611 | #endif | ||
| 612 | } | ||
| 613 | else | ||
| 614 | { | ||
| 615 | /* +option or -option */ | ||
| 616 | #if defined _LIBC && defined USE_IN_LIBIO | ||
| 617 | n = __asprintf (&buf, _("\ | ||
| 618 | %s: option `%c%s' doesn't allow an argument\n"), | ||
| 619 | argv[0], argv[d->optind - 1][0], | ||
| 620 | pfound->name); | ||
| 621 | #else | ||
| 622 | fprintf (stderr, _("\ | ||
| 623 | %s: option `%c%s' doesn't allow an argument\n"), | ||
| 624 | argv[0], argv[d->optind - 1][0], | ||
| 625 | pfound->name); | ||
| 626 | #endif | ||
| 627 | } | ||
| 628 | |||
| 629 | #if defined _LIBC && defined USE_IN_LIBIO | ||
| 630 | if (n >= 0) | ||
| 631 | { | ||
| 632 | _IO_flockfile (stderr); | ||
| 633 | |||
| 634 | int old_flags2 = ((_IO_FILE *) stderr)->_flags2; | ||
| 635 | ((_IO_FILE *) stderr)->_flags2 | ||
| 636 | |= _IO_FLAGS2_NOTCANCEL; | ||
| 637 | |||
| 638 | if (_IO_fwide (stderr, 0) > 0) | ||
| 639 | __fwprintf (stderr, L"%s", buf); | ||
| 640 | else | ||
| 641 | fputs (buf, stderr); | ||
| 642 | |||
| 643 | ((_IO_FILE *) stderr)->_flags2 = old_flags2; | ||
| 644 | _IO_funlockfile (stderr); | ||
| 645 | |||
| 646 | free (buf); | ||
| 647 | } | ||
| 648 | #endif | ||
| 649 | } | ||
| 650 | |||
| 651 | d->__nextchar += strlen (d->__nextchar); | ||
| 652 | |||
| 653 | d->optopt = pfound->val; | ||
| 654 | return '?'; | ||
| 655 | } | ||
| 656 | } | ||
| 657 | else if (pfound->has_arg == 1) | ||
| 658 | { | ||
| 659 | if (d->optind < argc) | ||
| 660 | d->optarg = argv[d->optind++]; | ||
| 661 | else | ||
| 662 | { | ||
| 663 | if (print_errors) | ||
| 664 | { | ||
| 665 | #if defined _LIBC && defined USE_IN_LIBIO | ||
| 666 | char *buf; | ||
| 667 | |||
| 668 | if (__asprintf (&buf, _("\ | ||
| 669 | %s: option `%s' requires an argument\n"), | ||
| 670 | argv[0], argv[d->optind - 1]) >= 0) | ||
| 671 | { | ||
| 672 | _IO_flockfile (stderr); | ||
| 673 | |||
| 674 | int old_flags2 = ((_IO_FILE *) stderr)->_flags2; | ||
| 675 | ((_IO_FILE *) stderr)->_flags2 | ||
| 676 | |= _IO_FLAGS2_NOTCANCEL; | ||
| 677 | |||
| 678 | if (_IO_fwide (stderr, 0) > 0) | ||
| 679 | __fwprintf (stderr, L"%s", buf); | ||
| 680 | else | ||
| 681 | fputs (buf, stderr); | ||
| 682 | |||
| 683 | ((_IO_FILE *) stderr)->_flags2 = old_flags2; | ||
| 684 | _IO_funlockfile (stderr); | ||
| 685 | |||
| 686 | free (buf); | ||
| 687 | } | ||
| 688 | #else | ||
| 689 | fprintf (stderr, | ||
| 690 | _("%s: option `%s' requires an argument\n"), | ||
| 691 | argv[0], argv[d->optind - 1]); | ||
| 692 | #endif | ||
| 693 | } | ||
| 694 | d->__nextchar += strlen (d->__nextchar); | ||
| 695 | d->optopt = pfound->val; | ||
| 696 | return optstring[0] == ':' ? ':' : '?'; | ||
| 697 | } | ||
| 698 | } | ||
| 699 | d->__nextchar += strlen (d->__nextchar); | ||
| 700 | if (longind != NULL) | ||
| 701 | *longind = option_index; | ||
| 702 | if (pfound->flag) | ||
| 703 | { | ||
| 704 | *(pfound->flag) = pfound->val; | ||
| 705 | return 0; | ||
| 706 | } | ||
| 707 | return pfound->val; | ||
| 708 | } | ||
| 709 | |||
| 710 | /* Can't find it as a long option. If this is not getopt_long_only, | ||
| 711 | or the option starts with '--' or is not a valid short | ||
| 712 | option, then it's an error. | ||
| 713 | Otherwise interpret it as a short option. */ | ||
| 714 | if (!long_only || argv[d->optind][1] == '-' | ||
| 715 | || strchr (optstring, *d->__nextchar) == NULL) | ||
| 716 | { | ||
| 717 | if (print_errors) | ||
| 718 | { | ||
| 719 | #if defined _LIBC && defined USE_IN_LIBIO | ||
| 720 | char *buf; | ||
| 721 | int n; | ||
| 722 | #endif | ||
| 723 | |||
| 724 | if (argv[d->optind][1] == '-') | ||
| 725 | { | ||
| 726 | /* --option */ | ||
| 727 | #if defined _LIBC && defined USE_IN_LIBIO | ||
| 728 | n = __asprintf (&buf, _("%s: unrecognized option `--%s'\n"), | ||
| 729 | argv[0], d->__nextchar); | ||
| 730 | #else | ||
| 731 | fprintf (stderr, _("%s: unrecognized option `--%s'\n"), | ||
| 732 | argv[0], d->__nextchar); | ||
| 733 | #endif | ||
| 734 | } | ||
| 735 | else | ||
| 736 | { | ||
| 737 | /* +option or -option */ | ||
| 738 | #if defined _LIBC && defined USE_IN_LIBIO | ||
| 739 | n = __asprintf (&buf, _("%s: unrecognized option `%c%s'\n"), | ||
| 740 | argv[0], argv[d->optind][0], d->__nextchar); | ||
| 741 | #else | ||
| 742 | fprintf (stderr, _("%s: unrecognized option `%c%s'\n"), | ||
| 743 | argv[0], argv[d->optind][0], d->__nextchar); | ||
| 744 | #endif | ||
| 745 | } | ||
| 746 | |||
| 747 | #if defined _LIBC && defined USE_IN_LIBIO | ||
| 748 | if (n >= 0) | ||
| 749 | { | ||
| 750 | _IO_flockfile (stderr); | ||
| 751 | |||
| 752 | int old_flags2 = ((_IO_FILE *) stderr)->_flags2; | ||
| 753 | ((_IO_FILE *) stderr)->_flags2 |= _IO_FLAGS2_NOTCANCEL; | ||
| 754 | |||
| 755 | if (_IO_fwide (stderr, 0) > 0) | ||
| 756 | __fwprintf (stderr, L"%s", buf); | ||
| 757 | else | ||
| 758 | fputs (buf, stderr); | ||
| 759 | |||
| 760 | ((_IO_FILE *) stderr)->_flags2 = old_flags2; | ||
| 761 | _IO_funlockfile (stderr); | ||
| 762 | |||
| 763 | free (buf); | ||
| 764 | } | ||
| 765 | #endif | ||
| 766 | } | ||
| 767 | d->__nextchar = (char *) ""; | ||
| 768 | d->optind++; | ||
| 769 | d->optopt = 0; | ||
| 770 | return '?'; | ||
| 771 | } | ||
| 772 | } | ||
| 773 | |||
| 774 | /* Look at and handle the next short option-character. */ | ||
| 775 | |||
| 776 | { | ||
| 777 | char c = *d->__nextchar++; | ||
| 778 | char *temp = strchr (optstring, c); | ||
| 779 | |||
| 780 | /* Increment `optind' when we start to process its last character. */ | ||
| 781 | if (*d->__nextchar == '\0') | ||
| 782 | ++d->optind; | ||
| 783 | |||
| 784 | if (temp == NULL || c == ':') | ||
| 785 | { | ||
| 786 | if (print_errors) | ||
| 787 | { | ||
| 788 | #if defined _LIBC && defined USE_IN_LIBIO | ||
| 789 | char *buf; | ||
| 790 | int n; | ||
| 791 | #endif | ||
| 792 | |||
| 793 | if (d->__posixly_correct) | ||
| 794 | { | ||
| 795 | /* 1003.2 specifies the format of this message. */ | ||
| 796 | #if defined _LIBC && defined USE_IN_LIBIO | ||
| 797 | n = __asprintf (&buf, _("%s: illegal option -- %c\n"), | ||
| 798 | argv[0], c); | ||
| 799 | #else | ||
| 800 | fprintf (stderr, _("%s: illegal option -- %c\n"), argv[0], c); | ||
| 801 | #endif | ||
| 802 | } | ||
| 803 | else | ||
| 804 | { | ||
| 805 | #if defined _LIBC && defined USE_IN_LIBIO | ||
| 806 | n = __asprintf (&buf, _("%s: invalid option -- %c\n"), | ||
| 807 | argv[0], c); | ||
| 808 | #else | ||
| 809 | fprintf (stderr, _("%s: invalid option -- %c\n"), argv[0], c); | ||
| 810 | #endif | ||
| 811 | } | ||
| 812 | |||
| 813 | #if defined _LIBC && defined USE_IN_LIBIO | ||
| 814 | if (n >= 0) | ||
| 815 | { | ||
| 816 | _IO_flockfile (stderr); | ||
| 817 | |||
| 818 | int old_flags2 = ((_IO_FILE *) stderr)->_flags2; | ||
| 819 | ((_IO_FILE *) stderr)->_flags2 |= _IO_FLAGS2_NOTCANCEL; | ||
| 820 | |||
| 821 | if (_IO_fwide (stderr, 0) > 0) | ||
| 822 | __fwprintf (stderr, L"%s", buf); | ||
| 823 | else | ||
| 824 | fputs (buf, stderr); | ||
| 825 | |||
| 826 | ((_IO_FILE *) stderr)->_flags2 = old_flags2; | ||
| 827 | _IO_funlockfile (stderr); | ||
| 828 | |||
| 829 | free (buf); | ||
| 830 | } | ||
| 831 | #endif | ||
| 832 | } | ||
| 833 | d->optopt = c; | ||
| 834 | return '?'; | ||
| 835 | } | ||
| 836 | /* Convenience. Treat POSIX -W foo same as long option --foo */ | ||
| 837 | if (temp[0] == 'W' && temp[1] == ';') | ||
| 838 | { | ||
| 839 | char *nameend; | ||
| 840 | const struct option *p; | ||
| 841 | const struct option *pfound = NULL; | ||
| 842 | int exact = 0; | ||
| 843 | int ambig = 0; | ||
| 844 | int indfound = 0; | ||
| 845 | int option_index; | ||
| 846 | |||
| 847 | /* This is an option that requires an argument. */ | ||
| 848 | if (*d->__nextchar != '\0') | ||
| 849 | { | ||
| 850 | d->optarg = d->__nextchar; | ||
| 851 | /* If we end this ARGV-element by taking the rest as an arg, | ||
| 852 | we must advance to the next element now. */ | ||
| 853 | d->optind++; | ||
| 854 | } | ||
| 855 | else if (d->optind == argc) | ||
| 856 | { | ||
| 857 | if (print_errors) | ||
| 858 | { | ||
| 859 | /* 1003.2 specifies the format of this message. */ | ||
| 860 | #if defined _LIBC && defined USE_IN_LIBIO | ||
| 861 | char *buf; | ||
| 862 | |||
| 863 | if (__asprintf (&buf, | ||
| 864 | _("%s: option requires an argument -- %c\n"), | ||
| 865 | argv[0], c) >= 0) | ||
| 866 | { | ||
| 867 | _IO_flockfile (stderr); | ||
| 868 | |||
| 869 | int old_flags2 = ((_IO_FILE *) stderr)->_flags2; | ||
| 870 | ((_IO_FILE *) stderr)->_flags2 |= _IO_FLAGS2_NOTCANCEL; | ||
| 871 | |||
| 872 | if (_IO_fwide (stderr, 0) > 0) | ||
| 873 | __fwprintf (stderr, L"%s", buf); | ||
| 874 | else | ||
| 875 | fputs (buf, stderr); | ||
| 876 | |||
| 877 | ((_IO_FILE *) stderr)->_flags2 = old_flags2; | ||
| 878 | _IO_funlockfile (stderr); | ||
| 879 | |||
| 880 | free (buf); | ||
| 881 | } | ||
| 882 | #else | ||
| 883 | fprintf (stderr, _("%s: option requires an argument -- %c\n"), | ||
| 884 | argv[0], c); | ||
| 885 | #endif | ||
| 886 | } | ||
| 887 | d->optopt = c; | ||
| 888 | if (optstring[0] == ':') | ||
| 889 | c = ':'; | ||
| 890 | else | ||
| 891 | c = '?'; | ||
| 892 | return c; | ||
| 893 | } | ||
| 894 | else | ||
| 895 | /* We already incremented `d->optind' once; | ||
| 896 | increment it again when taking next ARGV-elt as argument. */ | ||
| 897 | d->optarg = argv[d->optind++]; | ||
| 898 | |||
| 899 | /* optarg is now the argument, see if it's in the | ||
| 900 | table of longopts. */ | ||
| 901 | |||
| 902 | for (d->__nextchar = nameend = d->optarg; *nameend && *nameend != '='; | ||
| 903 | nameend++) | ||
| 904 | /* Do nothing. */ ; | ||
| 905 | |||
| 906 | /* Test all long options for either exact match | ||
| 907 | or abbreviated matches. */ | ||
| 908 | for (p = longopts, option_index = 0; p->name; p++, option_index++) | ||
| 909 | if (!strncmp (p->name, d->__nextchar, nameend - d->__nextchar)) | ||
| 910 | { | ||
| 911 | if ((unsigned int) (nameend - d->__nextchar) == strlen (p->name)) | ||
| 912 | { | ||
| 913 | /* Exact match found. */ | ||
| 914 | pfound = p; | ||
| 915 | indfound = option_index; | ||
| 916 | exact = 1; | ||
| 917 | break; | ||
| 918 | } | ||
| 919 | else if (pfound == NULL) | ||
| 920 | { | ||
| 921 | /* First nonexact match found. */ | ||
| 922 | pfound = p; | ||
| 923 | indfound = option_index; | ||
| 924 | } | ||
| 925 | else | ||
| 926 | /* Second or later nonexact match found. */ | ||
| 927 | ambig = 1; | ||
| 928 | } | ||
| 929 | if (ambig && !exact) | ||
| 930 | { | ||
| 931 | if (print_errors) | ||
| 932 | { | ||
| 933 | #if defined _LIBC && defined USE_IN_LIBIO | ||
| 934 | char *buf; | ||
| 935 | |||
| 936 | if (__asprintf (&buf, _("%s: option `-W %s' is ambiguous\n"), | ||
| 937 | argv[0], argv[d->optind]) >= 0) | ||
| 938 | { | ||
| 939 | _IO_flockfile (stderr); | ||
| 940 | |||
| 941 | int old_flags2 = ((_IO_FILE *) stderr)->_flags2; | ||
| 942 | ((_IO_FILE *) stderr)->_flags2 |= _IO_FLAGS2_NOTCANCEL; | ||
| 943 | |||
| 944 | if (_IO_fwide (stderr, 0) > 0) | ||
| 945 | __fwprintf (stderr, L"%s", buf); | ||
| 946 | else | ||
| 947 | fputs (buf, stderr); | ||
| 948 | |||
| 949 | ((_IO_FILE *) stderr)->_flags2 = old_flags2; | ||
| 950 | _IO_funlockfile (stderr); | ||
| 951 | |||
| 952 | free (buf); | ||
| 953 | } | ||
| 954 | #else | ||
| 955 | fprintf (stderr, _("%s: option `-W %s' is ambiguous\n"), | ||
| 956 | argv[0], argv[d->optind]); | ||
| 957 | #endif | ||
| 958 | } | ||
| 959 | d->__nextchar += strlen (d->__nextchar); | ||
| 960 | d->optind++; | ||
| 961 | return '?'; | ||
| 962 | } | ||
| 963 | if (pfound != NULL) | ||
| 964 | { | ||
| 965 | option_index = indfound; | ||
| 966 | if (*nameend) | ||
| 967 | { | ||
| 968 | /* Don't test has_arg with >, because some C compilers don't | ||
| 969 | allow it to be used on enums. */ | ||
| 970 | if (pfound->has_arg) | ||
| 971 | d->optarg = nameend + 1; | ||
| 972 | else | ||
| 973 | { | ||
| 974 | if (print_errors) | ||
| 975 | { | ||
| 976 | #if defined _LIBC && defined USE_IN_LIBIO | ||
| 977 | char *buf; | ||
| 978 | |||
| 979 | if (__asprintf (&buf, _("\ | ||
| 980 | %s: option `-W %s' doesn't allow an argument\n"), | ||
| 981 | argv[0], pfound->name) >= 0) | ||
| 982 | { | ||
| 983 | _IO_flockfile (stderr); | ||
| 984 | |||
| 985 | int old_flags2 = ((_IO_FILE *) stderr)->_flags2; | ||
| 986 | ((_IO_FILE *) stderr)->_flags2 | ||
| 987 | |= _IO_FLAGS2_NOTCANCEL; | ||
| 988 | |||
| 989 | if (_IO_fwide (stderr, 0) > 0) | ||
| 990 | __fwprintf (stderr, L"%s", buf); | ||
| 991 | else | ||
| 992 | fputs (buf, stderr); | ||
| 993 | |||
| 994 | ((_IO_FILE *) stderr)->_flags2 = old_flags2; | ||
| 995 | _IO_funlockfile (stderr); | ||
| 996 | |||
| 997 | free (buf); | ||
| 998 | } | ||
| 999 | #else | ||
| 1000 | fprintf (stderr, _("\ | ||
| 1001 | %s: option `-W %s' doesn't allow an argument\n"), | ||
| 1002 | argv[0], pfound->name); | ||
| 1003 | #endif | ||
| 1004 | } | ||
| 1005 | |||
| 1006 | d->__nextchar += strlen (d->__nextchar); | ||
| 1007 | return '?'; | ||
| 1008 | } | ||
| 1009 | } | ||
| 1010 | else if (pfound->has_arg == 1) | ||
| 1011 | { | ||
| 1012 | if (d->optind < argc) | ||
| 1013 | d->optarg = argv[d->optind++]; | ||
| 1014 | else | ||
| 1015 | { | ||
| 1016 | if (print_errors) | ||
| 1017 | { | ||
| 1018 | #if defined _LIBC && defined USE_IN_LIBIO | ||
| 1019 | char *buf; | ||
| 1020 | |||
| 1021 | if (__asprintf (&buf, _("\ | ||
| 1022 | %s: option `%s' requires an argument\n"), | ||
| 1023 | argv[0], argv[d->optind - 1]) >= 0) | ||
| 1024 | { | ||
| 1025 | _IO_flockfile (stderr); | ||
| 1026 | |||
| 1027 | int old_flags2 = ((_IO_FILE *) stderr)->_flags2; | ||
| 1028 | ((_IO_FILE *) stderr)->_flags2 | ||
| 1029 | |= _IO_FLAGS2_NOTCANCEL; | ||
| 1030 | |||
| 1031 | if (_IO_fwide (stderr, 0) > 0) | ||
| 1032 | __fwprintf (stderr, L"%s", buf); | ||
| 1033 | else | ||
| 1034 | fputs (buf, stderr); | ||
| 1035 | |||
| 1036 | ((_IO_FILE *) stderr)->_flags2 = old_flags2; | ||
| 1037 | _IO_funlockfile (stderr); | ||
| 1038 | |||
| 1039 | free (buf); | ||
| 1040 | } | ||
| 1041 | #else | ||
| 1042 | fprintf (stderr, | ||
| 1043 | _("%s: option `%s' requires an argument\n"), | ||
| 1044 | argv[0], argv[d->optind - 1]); | ||
| 1045 | #endif | ||
| 1046 | } | ||
| 1047 | d->__nextchar += strlen (d->__nextchar); | ||
| 1048 | return optstring[0] == ':' ? ':' : '?'; | ||
| 1049 | } | ||
| 1050 | } | ||
| 1051 | d->__nextchar += strlen (d->__nextchar); | ||
| 1052 | if (longind != NULL) | ||
| 1053 | *longind = option_index; | ||
| 1054 | if (pfound->flag) | ||
| 1055 | { | ||
| 1056 | *(pfound->flag) = pfound->val; | ||
| 1057 | return 0; | ||
| 1058 | } | ||
| 1059 | return pfound->val; | ||
| 1060 | } | ||
| 1061 | d->__nextchar = NULL; | ||
| 1062 | return 'W'; /* Let the application handle it. */ | ||
| 1063 | } | ||
| 1064 | if (temp[1] == ':') | ||
| 1065 | { | ||
| 1066 | if (temp[2] == ':') | ||
| 1067 | { | ||
| 1068 | /* This is an option that accepts an argument optionally. */ | ||
| 1069 | if (*d->__nextchar != '\0') | ||
| 1070 | { | ||
| 1071 | d->optarg = d->__nextchar; | ||
| 1072 | d->optind++; | ||
| 1073 | } | ||
| 1074 | else | ||
| 1075 | d->optarg = NULL; | ||
| 1076 | d->__nextchar = NULL; | ||
| 1077 | } | ||
| 1078 | else | ||
| 1079 | { | ||
| 1080 | /* This is an option that requires an argument. */ | ||
| 1081 | if (*d->__nextchar != '\0') | ||
| 1082 | { | ||
| 1083 | d->optarg = d->__nextchar; | ||
| 1084 | /* If we end this ARGV-element by taking the rest as an arg, | ||
| 1085 | we must advance to the next element now. */ | ||
| 1086 | d->optind++; | ||
| 1087 | } | ||
| 1088 | else if (d->optind == argc) | ||
| 1089 | { | ||
| 1090 | if (print_errors) | ||
| 1091 | { | ||
| 1092 | /* 1003.2 specifies the format of this message. */ | ||
| 1093 | #if defined _LIBC && defined USE_IN_LIBIO | ||
| 1094 | char *buf; | ||
| 1095 | |||
| 1096 | if (__asprintf (&buf, _("\ | ||
| 1097 | %s: option requires an argument -- %c\n"), | ||
| 1098 | argv[0], c) >= 0) | ||
| 1099 | { | ||
| 1100 | _IO_flockfile (stderr); | ||
| 1101 | |||
| 1102 | int old_flags2 = ((_IO_FILE *) stderr)->_flags2; | ||
| 1103 | ((_IO_FILE *) stderr)->_flags2 |= _IO_FLAGS2_NOTCANCEL; | ||
| 1104 | |||
| 1105 | if (_IO_fwide (stderr, 0) > 0) | ||
| 1106 | __fwprintf (stderr, L"%s", buf); | ||
| 1107 | else | ||
| 1108 | fputs (buf, stderr); | ||
| 1109 | |||
| 1110 | ((_IO_FILE *) stderr)->_flags2 = old_flags2; | ||
| 1111 | _IO_funlockfile (stderr); | ||
| 1112 | |||
| 1113 | free (buf); | ||
| 1114 | } | ||
| 1115 | #else | ||
| 1116 | fprintf (stderr, | ||
| 1117 | _("%s: option requires an argument -- %c\n"), | ||
| 1118 | argv[0], c); | ||
| 1119 | #endif | ||
| 1120 | } | ||
| 1121 | d->optopt = c; | ||
| 1122 | if (optstring[0] == ':') | ||
| 1123 | c = ':'; | ||
| 1124 | else | ||
| 1125 | c = '?'; | ||
| 1126 | } | ||
| 1127 | else | ||
| 1128 | /* We already incremented `optind' once; | ||
| 1129 | increment it again when taking next ARGV-elt as argument. */ | ||
| 1130 | d->optarg = argv[d->optind++]; | ||
| 1131 | d->__nextchar = NULL; | ||
| 1132 | } | ||
| 1133 | } | ||
| 1134 | return c; | ||
| 1135 | } | ||
| 1136 | } | ||
| 1137 | |||
| 1138 | int | ||
| 1139 | _getopt_internal (int argc, char **argv, const char *optstring, | ||
| 1140 | const struct option *longopts, int *longind, | ||
| 1141 | int long_only, int posixly_correct) | ||
| 1142 | { | ||
| 1143 | int result; | ||
| 1144 | |||
| 1145 | getopt_data.optind = optind; | ||
| 1146 | getopt_data.opterr = opterr; | ||
| 1147 | |||
| 1148 | result = _getopt_internal_r (argc, argv, optstring, longopts, longind, | ||
| 1149 | long_only, posixly_correct, &getopt_data); | ||
| 1150 | |||
| 1151 | optind = getopt_data.optind; | ||
| 1152 | optarg = getopt_data.optarg; | ||
| 1153 | optopt = getopt_data.optopt; | ||
| 1154 | |||
| 1155 | return result; | ||
| 1156 | } | ||
| 1157 | |||
| 1158 | /* glibc gets a LSB-compliant getopt. | ||
| 1159 | Standalone applications get a POSIX-compliant getopt. */ | ||
| 1160 | #if _LIBC | ||
| 1161 | enum { POSIXLY_CORRECT = 0 }; | ||
| 1162 | #else | ||
| 1163 | enum { POSIXLY_CORRECT = 1 }; | ||
| 1164 | #endif | ||
| 1165 | |||
| 1166 | int | ||
| 1167 | getopt (int argc, char *const *argv, const char *optstring) | ||
| 1168 | { | ||
| 1169 | return _getopt_internal (argc, (char **) argv, optstring, NULL, NULL, 0, | ||
| 1170 | POSIXLY_CORRECT); | ||
| 1171 | } | ||
| 1172 | |||
| 1173 | |||
| 1174 | #ifdef TEST | ||
| 1175 | |||
| 1176 | /* Compile with -DTEST to make an executable for use in testing | ||
| 1177 | the above definition of `getopt'. */ | ||
| 1178 | |||
| 1179 | int | ||
| 1180 | main (int argc, char **argv) | ||
| 1181 | { | ||
| 1182 | int c; | ||
| 1183 | int digit_optind = 0; | ||
| 1184 | |||
| 1185 | while (1) | ||
| 1186 | { | ||
| 1187 | int this_option_optind = optind ? optind : 1; | ||
| 1188 | |||
| 1189 | c = getopt (argc, argv, "abc:d:0123456789"); | ||
| 1190 | if (c == -1) | ||
| 1191 | break; | ||
| 1192 | |||
| 1193 | switch (c) | ||
| 1194 | { | ||
| 1195 | case '0': | ||
| 1196 | case '1': | ||
| 1197 | case '2': | ||
| 1198 | case '3': | ||
| 1199 | case '4': | ||
| 1200 | case '5': | ||
| 1201 | case '6': | ||
| 1202 | case '7': | ||
| 1203 | case '8': | ||
| 1204 | case '9': | ||
| 1205 | if (digit_optind != 0 && digit_optind != this_option_optind) | ||
| 1206 | printf ("digits occur in two different argv-elements.\n"); | ||
| 1207 | digit_optind = this_option_optind; | ||
| 1208 | printf ("option %c\n", c); | ||
| 1209 | break; | ||
| 1210 | |||
| 1211 | case 'a': | ||
| 1212 | printf ("option a\n"); | ||
| 1213 | break; | ||
| 1214 | |||
| 1215 | case 'b': | ||
| 1216 | printf ("option b\n"); | ||
| 1217 | break; | ||
| 1218 | |||
| 1219 | case 'c': | ||
| 1220 | printf ("option c with value `%s'\n", optarg); | ||
| 1221 | break; | ||
| 1222 | |||
| 1223 | case '?': | ||
| 1224 | break; | ||
| 1225 | |||
| 1226 | default: | ||
| 1227 | printf ("?? getopt returned character code 0%o ??\n", c); | ||
| 1228 | } | ||
| 1229 | } | ||
| 1230 | |||
| 1231 | if (optind < argc) | ||
| 1232 | { | ||
| 1233 | printf ("non-option ARGV-elements: "); | ||
| 1234 | while (optind < argc) | ||
| 1235 | printf ("%s ", argv[optind++]); | ||
| 1236 | printf ("\n"); | ||
| 1237 | } | ||
| 1238 | |||
| 1239 | exit (0); | ||
| 1240 | } | ||
| 1241 | |||
| 1242 | #endif /* TEST */ | ||
| 1243 | |||
| 1244 | /* arch-tag: 0e6da124-7269-4785-a9de-094c263d20dc | ||
| 1245 | (do not change this comment) */ | ||
diff --git a/lib-src/getopt1.c b/lib-src/getopt1.c deleted file mode 100644 index 25f616250c1..00000000000 --- a/lib-src/getopt1.c +++ /dev/null | |||
| @@ -1,177 +0,0 @@ | |||
| 1 | /* getopt_long and getopt_long_only entry points for GNU getopt. | ||
| 2 | Copyright (C) 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1996, 1997, | ||
| 3 | 1998, 2004, 2005, 2006, 2007 Free Software Foundation, Inc. | ||
| 4 | This file is part of the GNU C Library. | ||
| 5 | |||
| 6 | This program is free software; you can redistribute it and/or modify | ||
| 7 | it under the terms of the GNU General Public License as published by | ||
| 8 | the Free Software Foundation; either version 3, or (at your option) | ||
| 9 | any later version. | ||
| 10 | |||
| 11 | This program is distributed in the hope that it will be useful, | ||
| 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 14 | GNU General Public License for more details. | ||
| 15 | |||
| 16 | You should have received a copy of the GNU General Public License along | ||
| 17 | with this program; if not, write to the Free Software Foundation, | ||
| 18 | Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ | ||
| 19 | |||
| 20 | #ifdef HAVE_CONFIG_H | ||
| 21 | #include <config.h> | ||
| 22 | #endif | ||
| 23 | |||
| 24 | #ifdef _LIBC | ||
| 25 | # include <getopt.h> | ||
| 26 | #else | ||
| 27 | # include "getopt.h" | ||
| 28 | #endif | ||
| 29 | #include "getopt_int.h" | ||
| 30 | |||
| 31 | #include <stdio.h> | ||
| 32 | |||
| 33 | /* This needs to come after some library #include | ||
| 34 | to get __GNU_LIBRARY__ defined. */ | ||
| 35 | #ifdef __GNU_LIBRARY__ | ||
| 36 | #include <stdlib.h> | ||
| 37 | #endif | ||
| 38 | |||
| 39 | #ifndef NULL | ||
| 40 | #define NULL 0 | ||
| 41 | #endif | ||
| 42 | |||
| 43 | int | ||
| 44 | getopt_long (int argc, char *__getopt_argv_const *argv, const char *options, | ||
| 45 | const struct option *long_options, int *opt_index) | ||
| 46 | { | ||
| 47 | return _getopt_internal (argc, (char **) argv, options, long_options, | ||
| 48 | opt_index, 0, 0); | ||
| 49 | } | ||
| 50 | |||
| 51 | int | ||
| 52 | _getopt_long_r (int argc, char **argv, const char *options, | ||
| 53 | const struct option *long_options, int *opt_index, | ||
| 54 | struct _getopt_data *d) | ||
| 55 | { | ||
| 56 | return _getopt_internal_r (argc, argv, options, long_options, opt_index, | ||
| 57 | 0, 0, d); | ||
| 58 | } | ||
| 59 | |||
| 60 | /* Like getopt_long, but '-' as well as '--' can indicate a long option. | ||
| 61 | If an option that starts with '-' (not '--') doesn't match a long option, | ||
| 62 | but does match a short option, it is parsed as a short option | ||
| 63 | instead. */ | ||
| 64 | |||
| 65 | int | ||
| 66 | getopt_long_only (int argc, char *__getopt_argv_const *argv, | ||
| 67 | const char *options, | ||
| 68 | const struct option *long_options, int *opt_index) | ||
| 69 | { | ||
| 70 | return _getopt_internal (argc, (char **) argv, options, long_options, | ||
| 71 | opt_index, 1, 0); | ||
| 72 | } | ||
| 73 | |||
| 74 | int | ||
| 75 | _getopt_long_only_r (int argc, char **argv, const char *options, | ||
| 76 | const struct option *long_options, int *opt_index, | ||
| 77 | struct _getopt_data *d) | ||
| 78 | { | ||
| 79 | return _getopt_internal_r (argc, argv, options, long_options, opt_index, | ||
| 80 | 1, 0, d); | ||
| 81 | } | ||
| 82 | |||
| 83 | |||
| 84 | #ifdef TEST | ||
| 85 | |||
| 86 | #include <stdio.h> | ||
| 87 | |||
| 88 | int | ||
| 89 | main (int argc, char **argv) | ||
| 90 | { | ||
| 91 | int c; | ||
| 92 | int digit_optind = 0; | ||
| 93 | |||
| 94 | while (1) | ||
| 95 | { | ||
| 96 | int this_option_optind = optind ? optind : 1; | ||
| 97 | int option_index = 0; | ||
| 98 | static struct option long_options[] = | ||
| 99 | { | ||
| 100 | {"add", 1, 0, 0}, | ||
| 101 | {"append", 0, 0, 0}, | ||
| 102 | {"delete", 1, 0, 0}, | ||
| 103 | {"verbose", 0, 0, 0}, | ||
| 104 | {"create", 0, 0, 0}, | ||
| 105 | {"file", 1, 0, 0}, | ||
| 106 | {0, 0, 0, 0} | ||
| 107 | }; | ||
| 108 | |||
| 109 | c = getopt_long (argc, argv, "abc:d:0123456789", | ||
| 110 | long_options, &option_index); | ||
| 111 | if (c == -1) | ||
| 112 | break; | ||
| 113 | |||
| 114 | switch (c) | ||
| 115 | { | ||
| 116 | case 0: | ||
| 117 | printf ("option %s", long_options[option_index].name); | ||
| 118 | if (optarg) | ||
| 119 | printf (" with arg %s", optarg); | ||
| 120 | printf ("\n"); | ||
| 121 | break; | ||
| 122 | |||
| 123 | case '0': | ||
| 124 | case '1': | ||
| 125 | case '2': | ||
| 126 | case '3': | ||
| 127 | case '4': | ||
| 128 | case '5': | ||
| 129 | case '6': | ||
| 130 | case '7': | ||
| 131 | case '8': | ||
| 132 | case '9': | ||
| 133 | if (digit_optind != 0 && digit_optind != this_option_optind) | ||
| 134 | printf ("digits occur in two different argv-elements.\n"); | ||
| 135 | digit_optind = this_option_optind; | ||
| 136 | printf ("option %c\n", c); | ||
| 137 | break; | ||
| 138 | |||
| 139 | case 'a': | ||
| 140 | printf ("option a\n"); | ||
| 141 | break; | ||
| 142 | |||
| 143 | case 'b': | ||
| 144 | printf ("option b\n"); | ||
| 145 | break; | ||
| 146 | |||
| 147 | case 'c': | ||
| 148 | printf ("option c with value `%s'\n", optarg); | ||
| 149 | break; | ||
| 150 | |||
| 151 | case 'd': | ||
| 152 | printf ("option d with value `%s'\n", optarg); | ||
| 153 | break; | ||
| 154 | |||
| 155 | case '?': | ||
| 156 | break; | ||
| 157 | |||
| 158 | default: | ||
| 159 | printf ("?? getopt returned character code 0%o ??\n", c); | ||
| 160 | } | ||
| 161 | } | ||
| 162 | |||
| 163 | if (optind < argc) | ||
| 164 | { | ||
| 165 | printf ("non-option ARGV-elements: "); | ||
| 166 | while (optind < argc) | ||
| 167 | printf ("%s ", argv[optind++]); | ||
| 168 | printf ("\n"); | ||
| 169 | } | ||
| 170 | |||
| 171 | exit (0); | ||
| 172 | } | ||
| 173 | |||
| 174 | #endif /* TEST */ | ||
| 175 | |||
| 176 | /* arch-tag: 28a5c558-b0c0-4bff-b5bc-e2e20291d4b6 | ||
| 177 | (do not change this comment) */ | ||
diff --git a/lib-src/getopt_int.h b/lib-src/getopt_int.h deleted file mode 100644 index 049f4762900..00000000000 --- a/lib-src/getopt_int.h +++ /dev/null | |||
| @@ -1,134 +0,0 @@ | |||
| 1 | /* Internal declarations for getopt. | ||
| 2 | Copyright (C) 1989, 1990, 1991, 1992, 1993, 1994, 1996, 1997, 1998, 1999, | ||
| 3 | 2001, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc. | ||
| 4 | This file is part of the GNU C Library. | ||
| 5 | |||
| 6 | This program is free software; you can redistribute it and/or modify | ||
| 7 | it under the terms of the GNU General Public License as published by | ||
| 8 | the Free Software Foundation; either version 3, or (at your option) | ||
| 9 | any later version. | ||
| 10 | |||
| 11 | This program is distributed in the hope that it will be useful, | ||
| 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 14 | GNU General Public License for more details. | ||
| 15 | |||
| 16 | You should have received a copy of the GNU General Public License along | ||
| 17 | with this program; if not, write to the Free Software Foundation, | ||
| 18 | Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ | ||
| 19 | |||
| 20 | #ifndef _GETOPT_INT_H | ||
| 21 | #define _GETOPT_INT_H 1 | ||
| 22 | |||
| 23 | extern int _getopt_internal (int ___argc, char **___argv, | ||
| 24 | const char *__shortopts, | ||
| 25 | const struct option *__longopts, int *__longind, | ||
| 26 | int __long_only, int __posixly_correct); | ||
| 27 | |||
| 28 | |||
| 29 | /* Reentrant versions which can handle parsing multiple argument | ||
| 30 | vectors at the same time. */ | ||
| 31 | |||
| 32 | /* Data type for reentrant functions. */ | ||
| 33 | struct _getopt_data | ||
| 34 | { | ||
| 35 | /* These have exactly the same meaning as the corresponding global | ||
| 36 | variables, except that they are used for the reentrant | ||
| 37 | versions of getopt. */ | ||
| 38 | int optind; | ||
| 39 | int opterr; | ||
| 40 | int optopt; | ||
| 41 | char *optarg; | ||
| 42 | |||
| 43 | /* Internal members. */ | ||
| 44 | |||
| 45 | /* True if the internal members have been initialized. */ | ||
| 46 | int __initialized; | ||
| 47 | |||
| 48 | /* The next char to be scanned in the option-element | ||
| 49 | in which the last option character we returned was found. | ||
| 50 | This allows us to pick up the scan where we left off. | ||
| 51 | |||
| 52 | If this is zero, or a null string, it means resume the scan | ||
| 53 | by advancing to the next ARGV-element. */ | ||
| 54 | char *__nextchar; | ||
| 55 | |||
| 56 | /* Describe how to deal with options that follow non-option ARGV-elements. | ||
| 57 | |||
| 58 | If the caller did not specify anything, | ||
| 59 | the default is REQUIRE_ORDER if the environment variable | ||
| 60 | POSIXLY_CORRECT is defined, PERMUTE otherwise. | ||
| 61 | |||
| 62 | REQUIRE_ORDER means don't recognize them as options; | ||
| 63 | stop option processing when the first non-option is seen. | ||
| 64 | This is what Unix does. | ||
| 65 | This mode of operation is selected by either setting the environment | ||
| 66 | variable POSIXLY_CORRECT, or using `+' as the first character | ||
| 67 | of the list of option characters, or by calling getopt. | ||
| 68 | |||
| 69 | PERMUTE is the default. We permute the contents of ARGV as we | ||
| 70 | scan, so that eventually all the non-options are at the end. | ||
| 71 | This allows options to be given in any order, even with programs | ||
| 72 | that were not written to expect this. | ||
| 73 | |||
| 74 | RETURN_IN_ORDER is an option available to programs that were | ||
| 75 | written to expect options and other ARGV-elements in any order | ||
| 76 | and that care about the ordering of the two. We describe each | ||
| 77 | non-option ARGV-element as if it were the argument of an option | ||
| 78 | with character code 1. Using `-' as the first character of the | ||
| 79 | list of option characters selects this mode of operation. | ||
| 80 | |||
| 81 | The special argument `--' forces an end of option-scanning regardless | ||
| 82 | of the value of `ordering'. In the case of RETURN_IN_ORDER, only | ||
| 83 | `--' can cause `getopt' to return -1 with `optind' != ARGC. */ | ||
| 84 | |||
| 85 | enum | ||
| 86 | { | ||
| 87 | REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER | ||
| 88 | } __ordering; | ||
| 89 | |||
| 90 | /* If the POSIXLY_CORRECT environment variable is set | ||
| 91 | or getopt was called. */ | ||
| 92 | int __posixly_correct; | ||
| 93 | |||
| 94 | |||
| 95 | /* Handle permutation of arguments. */ | ||
| 96 | |||
| 97 | /* Describe the part of ARGV that contains non-options that have | ||
| 98 | been skipped. `first_nonopt' is the index in ARGV of the first | ||
| 99 | of them; `last_nonopt' is the index after the last of them. */ | ||
| 100 | |||
| 101 | int __first_nonopt; | ||
| 102 | int __last_nonopt; | ||
| 103 | |||
| 104 | #if defined _LIBC && defined USE_NONOPTION_FLAGS | ||
| 105 | int __nonoption_flags_max_len; | ||
| 106 | int __nonoption_flags_len; | ||
| 107 | # endif | ||
| 108 | }; | ||
| 109 | |||
| 110 | /* The initializer is necessary to set OPTIND and OPTERR to their | ||
| 111 | default values and to clear the initialization flag. */ | ||
| 112 | #define _GETOPT_DATA_INITIALIZER { 1, 1 } | ||
| 113 | |||
| 114 | extern int _getopt_internal_r (int ___argc, char **___argv, | ||
| 115 | const char *__shortopts, | ||
| 116 | const struct option *__longopts, int *__longind, | ||
| 117 | int __long_only, int __posixly_correct, | ||
| 118 | struct _getopt_data *__data); | ||
| 119 | |||
| 120 | extern int _getopt_long_r (int ___argc, char **___argv, | ||
| 121 | const char *__shortopts, | ||
| 122 | const struct option *__longopts, int *__longind, | ||
| 123 | struct _getopt_data *__data); | ||
| 124 | |||
| 125 | extern int _getopt_long_only_r (int ___argc, char **___argv, | ||
| 126 | const char *__shortopts, | ||
| 127 | const struct option *__longopts, | ||
| 128 | int *__longind, | ||
| 129 | struct _getopt_data *__data); | ||
| 130 | |||
| 131 | #endif /* getopt_int.h */ | ||
| 132 | |||
| 133 | /* arch-tag: 8bfc548f-23d6-46aa-b5b5-2739b0edaf79 | ||
| 134 | (do not change this comment) */ | ||
diff --git a/lib/Makefile.in b/lib/Makefile.in index 40254045808..22aadb78ad7 100644 --- a/lib/Makefile.in +++ b/lib/Makefile.in | |||
| @@ -24,7 +24,7 @@ | |||
| 24 | # the same distribution terms as the rest of that program. | 24 | # the same distribution terms as the rest of that program. |
| 25 | # | 25 | # |
| 26 | # Generated by gnulib-tool. | 26 | # Generated by gnulib-tool. |
| 27 | # Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=. --makefile-name=gnulib.mk --no-libtool --macro-prefix=gl --no-vc-files ftoastr mktime | 27 | # Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=. --makefile-name=gnulib.mk --no-libtool --macro-prefix=gl --no-vc-files ftoastr getopt-gnu mktime |
| 28 | 28 | ||
| 29 | VPATH = @srcdir@ | 29 | VPATH = @srcdir@ |
| 30 | pkgdatadir = $(datadir)/@PACKAGE@ | 30 | pkgdatadir = $(datadir)/@PACKAGE@ |
| @@ -51,13 +51,13 @@ subdir = lib | |||
| 51 | ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 | 51 | ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 |
| 52 | am__aclocal_m4_deps = $(top_srcdir)/m4/00gnulib.m4 \ | 52 | am__aclocal_m4_deps = $(top_srcdir)/m4/00gnulib.m4 \ |
| 53 | $(top_srcdir)/m4/c-strtod.m4 $(top_srcdir)/m4/extensions.m4 \ | 53 | $(top_srcdir)/m4/c-strtod.m4 $(top_srcdir)/m4/extensions.m4 \ |
| 54 | $(top_srcdir)/m4/gnulib-common.m4 \ | 54 | $(top_srcdir)/m4/getopt.m4 $(top_srcdir)/m4/gnulib-common.m4 \ |
| 55 | $(top_srcdir)/m4/gnulib-comp.m4 \ | 55 | $(top_srcdir)/m4/gnulib-comp.m4 \ |
| 56 | $(top_srcdir)/m4/include_next.m4 $(top_srcdir)/m4/mktime.m4 \ | 56 | $(top_srcdir)/m4/include_next.m4 $(top_srcdir)/m4/mktime.m4 \ |
| 57 | $(top_srcdir)/m4/multiarch.m4 $(top_srcdir)/m4/stddef_h.m4 \ | 57 | $(top_srcdir)/m4/multiarch.m4 $(top_srcdir)/m4/stddef_h.m4 \ |
| 58 | $(top_srcdir)/m4/time_h.m4 $(top_srcdir)/m4/time_r.m4 \ | 58 | $(top_srcdir)/m4/time_h.m4 $(top_srcdir)/m4/time_r.m4 \ |
| 59 | $(top_srcdir)/m4/wchar_t.m4 $(top_srcdir)/m4/getopt.m4 \ | 59 | $(top_srcdir)/m4/unistd_h.m4 $(top_srcdir)/m4/warn-on-use.m4 \ |
| 60 | $(top_srcdir)/configure.in | 60 | $(top_srcdir)/m4/wchar_t.m4 $(top_srcdir)/configure.in |
| 61 | am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ | 61 | am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ |
| 62 | $(ACLOCAL_M4) | 62 | $(ACLOCAL_M4) |
| 63 | mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs | 63 | mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs |
| @@ -132,14 +132,54 @@ FREETYPE_LIBS = @FREETYPE_LIBS@ | |||
| 132 | GCONF_CFLAGS = @GCONF_CFLAGS@ | 132 | GCONF_CFLAGS = @GCONF_CFLAGS@ |
| 133 | GCONF_LIBS = @GCONF_LIBS@ | 133 | GCONF_LIBS = @GCONF_LIBS@ |
| 134 | GETLOADAVG_LIBS = @GETLOADAVG_LIBS@ | 134 | GETLOADAVG_LIBS = @GETLOADAVG_LIBS@ |
| 135 | GETOPTOBJS = @GETOPTOBJS@ | ||
| 136 | GETOPT_H = @GETOPT_H@ | 135 | GETOPT_H = @GETOPT_H@ |
| 137 | GMALLOC_OBJ = @GMALLOC_OBJ@ | 136 | GMALLOC_OBJ = @GMALLOC_OBJ@ |
| 137 | GNULIB_CHOWN = @GNULIB_CHOWN@ | ||
| 138 | GNULIB_CLOSE = @GNULIB_CLOSE@ | ||
| 139 | GNULIB_DUP2 = @GNULIB_DUP2@ | ||
| 140 | GNULIB_DUP3 = @GNULIB_DUP3@ | ||
| 141 | GNULIB_ENVIRON = @GNULIB_ENVIRON@ | ||
| 142 | GNULIB_EUIDACCESS = @GNULIB_EUIDACCESS@ | ||
| 143 | GNULIB_FACCESSAT = @GNULIB_FACCESSAT@ | ||
| 144 | GNULIB_FCHDIR = @GNULIB_FCHDIR@ | ||
| 145 | GNULIB_FCHOWNAT = @GNULIB_FCHOWNAT@ | ||
| 146 | GNULIB_FSYNC = @GNULIB_FSYNC@ | ||
| 147 | GNULIB_FTRUNCATE = @GNULIB_FTRUNCATE@ | ||
| 148 | GNULIB_GETCWD = @GNULIB_GETCWD@ | ||
| 149 | GNULIB_GETDOMAINNAME = @GNULIB_GETDOMAINNAME@ | ||
| 150 | GNULIB_GETDTABLESIZE = @GNULIB_GETDTABLESIZE@ | ||
| 151 | GNULIB_GETGROUPS = @GNULIB_GETGROUPS@ | ||
| 152 | GNULIB_GETHOSTNAME = @GNULIB_GETHOSTNAME@ | ||
| 153 | GNULIB_GETLOGIN = @GNULIB_GETLOGIN@ | ||
| 154 | GNULIB_GETLOGIN_R = @GNULIB_GETLOGIN_R@ | ||
| 155 | GNULIB_GETPAGESIZE = @GNULIB_GETPAGESIZE@ | ||
| 156 | GNULIB_GETUSERSHELL = @GNULIB_GETUSERSHELL@ | ||
| 157 | GNULIB_LCHOWN = @GNULIB_LCHOWN@ | ||
| 158 | GNULIB_LINK = @GNULIB_LINK@ | ||
| 159 | GNULIB_LINKAT = @GNULIB_LINKAT@ | ||
| 160 | GNULIB_LSEEK = @GNULIB_LSEEK@ | ||
| 138 | GNULIB_MKTIME = @GNULIB_MKTIME@ | 161 | GNULIB_MKTIME = @GNULIB_MKTIME@ |
| 139 | GNULIB_NANOSLEEP = @GNULIB_NANOSLEEP@ | 162 | GNULIB_NANOSLEEP = @GNULIB_NANOSLEEP@ |
| 163 | GNULIB_PIPE = @GNULIB_PIPE@ | ||
| 164 | GNULIB_PIPE2 = @GNULIB_PIPE2@ | ||
| 165 | GNULIB_PREAD = @GNULIB_PREAD@ | ||
| 166 | GNULIB_PWRITE = @GNULIB_PWRITE@ | ||
| 167 | GNULIB_READLINK = @GNULIB_READLINK@ | ||
| 168 | GNULIB_READLINKAT = @GNULIB_READLINKAT@ | ||
| 169 | GNULIB_RMDIR = @GNULIB_RMDIR@ | ||
| 170 | GNULIB_SLEEP = @GNULIB_SLEEP@ | ||
| 140 | GNULIB_STRPTIME = @GNULIB_STRPTIME@ | 171 | GNULIB_STRPTIME = @GNULIB_STRPTIME@ |
| 172 | GNULIB_SYMLINK = @GNULIB_SYMLINK@ | ||
| 173 | GNULIB_SYMLINKAT = @GNULIB_SYMLINKAT@ | ||
| 141 | GNULIB_TIMEGM = @GNULIB_TIMEGM@ | 174 | GNULIB_TIMEGM = @GNULIB_TIMEGM@ |
| 142 | GNULIB_TIME_R = @GNULIB_TIME_R@ | 175 | GNULIB_TIME_R = @GNULIB_TIME_R@ |
| 176 | GNULIB_TTYNAME_R = @GNULIB_TTYNAME_R@ | ||
| 177 | GNULIB_UNISTD_H_GETOPT = @GNULIB_UNISTD_H_GETOPT@ | ||
| 178 | GNULIB_UNISTD_H_SIGPIPE = @GNULIB_UNISTD_H_SIGPIPE@ | ||
| 179 | GNULIB_UNLINK = @GNULIB_UNLINK@ | ||
| 180 | GNULIB_UNLINKAT = @GNULIB_UNLINKAT@ | ||
| 181 | GNULIB_USLEEP = @GNULIB_USLEEP@ | ||
| 182 | GNULIB_WRITE = @GNULIB_WRITE@ | ||
| 143 | GNU_OBJC_CFLAGS = @GNU_OBJC_CFLAGS@ | 183 | GNU_OBJC_CFLAGS = @GNU_OBJC_CFLAGS@ |
| 144 | GREP = @GREP@ | 184 | GREP = @GREP@ |
| 145 | GTK_CFLAGS = @GTK_CFLAGS@ | 185 | GTK_CFLAGS = @GTK_CFLAGS@ |
| @@ -147,11 +187,50 @@ GTK_LIBS = @GTK_LIBS@ | |||
| 147 | GTK_OBJ = @GTK_OBJ@ | 187 | GTK_OBJ = @GTK_OBJ@ |
| 148 | GZIP_INFO = @GZIP_INFO@ | 188 | GZIP_INFO = @GZIP_INFO@ |
| 149 | GZIP_PROG = @GZIP_PROG@ | 189 | GZIP_PROG = @GZIP_PROG@ |
| 190 | HAVE_CHOWN = @HAVE_CHOWN@ | ||
| 191 | HAVE_DECL_ENVIRON = @HAVE_DECL_ENVIRON@ | ||
| 192 | HAVE_DECL_FCHDIR = @HAVE_DECL_FCHDIR@ | ||
| 193 | HAVE_DECL_GETDOMAINNAME = @HAVE_DECL_GETDOMAINNAME@ | ||
| 194 | HAVE_DECL_GETLOGIN_R = @HAVE_DECL_GETLOGIN_R@ | ||
| 195 | HAVE_DECL_GETPAGESIZE = @HAVE_DECL_GETPAGESIZE@ | ||
| 196 | HAVE_DECL_GETUSERSHELL = @HAVE_DECL_GETUSERSHELL@ | ||
| 150 | HAVE_DECL_LOCALTIME_R = @HAVE_DECL_LOCALTIME_R@ | 197 | HAVE_DECL_LOCALTIME_R = @HAVE_DECL_LOCALTIME_R@ |
| 198 | HAVE_DECL_TTYNAME_R = @HAVE_DECL_TTYNAME_R@ | ||
| 199 | HAVE_DUP2 = @HAVE_DUP2@ | ||
| 200 | HAVE_DUP3 = @HAVE_DUP3@ | ||
| 201 | HAVE_EUIDACCESS = @HAVE_EUIDACCESS@ | ||
| 202 | HAVE_FACCESSAT = @HAVE_FACCESSAT@ | ||
| 203 | HAVE_FCHDIR = @HAVE_FCHDIR@ | ||
| 204 | HAVE_FCHOWNAT = @HAVE_FCHOWNAT@ | ||
| 205 | HAVE_FSYNC = @HAVE_FSYNC@ | ||
| 206 | HAVE_FTRUNCATE = @HAVE_FTRUNCATE@ | ||
| 207 | HAVE_GETDTABLESIZE = @HAVE_GETDTABLESIZE@ | ||
| 208 | HAVE_GETGROUPS = @HAVE_GETGROUPS@ | ||
| 209 | HAVE_GETHOSTNAME = @HAVE_GETHOSTNAME@ | ||
| 210 | HAVE_GETLOGIN = @HAVE_GETLOGIN@ | ||
| 211 | HAVE_GETOPT_H = @HAVE_GETOPT_H@ | ||
| 212 | HAVE_GETPAGESIZE = @HAVE_GETPAGESIZE@ | ||
| 213 | HAVE_LCHOWN = @HAVE_LCHOWN@ | ||
| 214 | HAVE_LINK = @HAVE_LINK@ | ||
| 215 | HAVE_LINKAT = @HAVE_LINKAT@ | ||
| 151 | HAVE_MAKEINFO = @HAVE_MAKEINFO@ | 216 | HAVE_MAKEINFO = @HAVE_MAKEINFO@ |
| 152 | HAVE_NANOSLEEP = @HAVE_NANOSLEEP@ | 217 | HAVE_NANOSLEEP = @HAVE_NANOSLEEP@ |
| 218 | HAVE_OS_H = @HAVE_OS_H@ | ||
| 219 | HAVE_PIPE = @HAVE_PIPE@ | ||
| 220 | HAVE_PIPE2 = @HAVE_PIPE2@ | ||
| 221 | HAVE_PREAD = @HAVE_PREAD@ | ||
| 222 | HAVE_PWRITE = @HAVE_PWRITE@ | ||
| 223 | HAVE_READLINK = @HAVE_READLINK@ | ||
| 224 | HAVE_READLINKAT = @HAVE_READLINKAT@ | ||
| 225 | HAVE_SLEEP = @HAVE_SLEEP@ | ||
| 153 | HAVE_STRPTIME = @HAVE_STRPTIME@ | 226 | HAVE_STRPTIME = @HAVE_STRPTIME@ |
| 227 | HAVE_SYMLINK = @HAVE_SYMLINK@ | ||
| 228 | HAVE_SYMLINKAT = @HAVE_SYMLINKAT@ | ||
| 229 | HAVE_SYS_PARAM_H = @HAVE_SYS_PARAM_H@ | ||
| 154 | HAVE_TIMEGM = @HAVE_TIMEGM@ | 230 | HAVE_TIMEGM = @HAVE_TIMEGM@ |
| 231 | HAVE_UNISTD_H = @HAVE_UNISTD_H@ | ||
| 232 | HAVE_UNLINKAT = @HAVE_UNLINKAT@ | ||
| 233 | HAVE_USLEEP = @HAVE_USLEEP@ | ||
| 155 | HAVE_WCHAR_T = @HAVE_WCHAR_T@ | 234 | HAVE_WCHAR_T = @HAVE_WCHAR_T@ |
| 156 | HAVE_XSERVER = @HAVE_XSERVER@ | 235 | HAVE_XSERVER = @HAVE_XSERVER@ |
| 157 | IMAGEMAGICK_CFLAGS = @IMAGEMAGICK_CFLAGS@ | 236 | IMAGEMAGICK_CFLAGS = @IMAGEMAGICK_CFLAGS@ |
| @@ -181,6 +260,7 @@ LIBGNU_LIBDEPS = @LIBGNU_LIBDEPS@ | |||
| 181 | LIBGNU_LTLIBDEPS = @LIBGNU_LTLIBDEPS@ | 260 | LIBGNU_LTLIBDEPS = @LIBGNU_LTLIBDEPS@ |
| 182 | LIBGPM = @LIBGPM@ | 261 | LIBGPM = @LIBGPM@ |
| 183 | LIBHESIOD = @LIBHESIOD@ | 262 | LIBHESIOD = @LIBHESIOD@ |
| 263 | LIBINTL = @LIBINTL@ | ||
| 184 | LIBJPEG = @LIBJPEG@ | 264 | LIBJPEG = @LIBJPEG@ |
| 185 | LIBOBJS = @LIBOBJS@ | 265 | LIBOBJS = @LIBOBJS@ |
| 186 | LIBOTF_CFLAGS = @LIBOTF_CFLAGS@ | 266 | LIBOTF_CFLAGS = @LIBOTF_CFLAGS@ |
| @@ -206,6 +286,7 @@ LIBX_OTHER = @LIBX_OTHER@ | |||
| 206 | LIB_GCC = @LIB_GCC@ | 286 | LIB_GCC = @LIB_GCC@ |
| 207 | LIB_MATH = @LIB_MATH@ | 287 | LIB_MATH = @LIB_MATH@ |
| 208 | LIB_STANDARD = @LIB_STANDARD@ | 288 | LIB_STANDARD = @LIB_STANDARD@ |
| 289 | LTLIBINTL = @LTLIBINTL@ | ||
| 209 | LTLIBOBJS = @LTLIBOBJS@ | 290 | LTLIBOBJS = @LTLIBOBJS@ |
| 210 | M17N_FLT_CFLAGS = @M17N_FLT_CFLAGS@ | 291 | M17N_FLT_CFLAGS = @M17N_FLT_CFLAGS@ |
| 211 | M17N_FLT_LIBS = @M17N_FLT_LIBS@ | 292 | M17N_FLT_LIBS = @M17N_FLT_LIBS@ |
| @@ -216,10 +297,14 @@ MKDIR_P = @MKDIR_P@ | |||
| 216 | MOUSE_SUPPORT = @MOUSE_SUPPORT@ | 297 | MOUSE_SUPPORT = @MOUSE_SUPPORT@ |
| 217 | M_FILE = @M_FILE@ | 298 | M_FILE = @M_FILE@ |
| 218 | NEED_SETGID = @NEED_SETGID@ | 299 | NEED_SETGID = @NEED_SETGID@ |
| 300 | NEXT_AS_FIRST_DIRECTIVE_GETOPT_H = @NEXT_AS_FIRST_DIRECTIVE_GETOPT_H@ | ||
| 219 | NEXT_AS_FIRST_DIRECTIVE_STDDEF_H = @NEXT_AS_FIRST_DIRECTIVE_STDDEF_H@ | 301 | NEXT_AS_FIRST_DIRECTIVE_STDDEF_H = @NEXT_AS_FIRST_DIRECTIVE_STDDEF_H@ |
| 220 | NEXT_AS_FIRST_DIRECTIVE_TIME_H = @NEXT_AS_FIRST_DIRECTIVE_TIME_H@ | 302 | NEXT_AS_FIRST_DIRECTIVE_TIME_H = @NEXT_AS_FIRST_DIRECTIVE_TIME_H@ |
| 303 | NEXT_AS_FIRST_DIRECTIVE_UNISTD_H = @NEXT_AS_FIRST_DIRECTIVE_UNISTD_H@ | ||
| 304 | NEXT_GETOPT_H = @NEXT_GETOPT_H@ | ||
| 221 | NEXT_STDDEF_H = @NEXT_STDDEF_H@ | 305 | NEXT_STDDEF_H = @NEXT_STDDEF_H@ |
| 222 | NEXT_TIME_H = @NEXT_TIME_H@ | 306 | NEXT_TIME_H = @NEXT_TIME_H@ |
| 307 | NEXT_UNISTD_H = @NEXT_UNISTD_H@ | ||
| 223 | NS_OBJ = @NS_OBJ@ | 308 | NS_OBJ = @NS_OBJ@ |
| 224 | NS_SUPPORT = @NS_SUPPORT@ | 309 | NS_SUPPORT = @NS_SUPPORT@ |
| 225 | OBJEXT = @OBJEXT@ | 310 | OBJEXT = @OBJEXT@ |
| @@ -244,11 +329,36 @@ PROFILING_CFLAGS = @PROFILING_CFLAGS@ | |||
| 244 | PTHREAD_H_DEFINES_STRUCT_TIMESPEC = @PTHREAD_H_DEFINES_STRUCT_TIMESPEC@ | 329 | PTHREAD_H_DEFINES_STRUCT_TIMESPEC = @PTHREAD_H_DEFINES_STRUCT_TIMESPEC@ |
| 245 | RALLOC_OBJ = @RALLOC_OBJ@ | 330 | RALLOC_OBJ = @RALLOC_OBJ@ |
| 246 | RANLIB = @RANLIB@ | 331 | RANLIB = @RANLIB@ |
| 332 | REPLACE_CHOWN = @REPLACE_CHOWN@ | ||
| 333 | REPLACE_CLOSE = @REPLACE_CLOSE@ | ||
| 334 | REPLACE_DUP = @REPLACE_DUP@ | ||
| 335 | REPLACE_DUP2 = @REPLACE_DUP2@ | ||
| 336 | REPLACE_FCHOWNAT = @REPLACE_FCHOWNAT@ | ||
| 337 | REPLACE_GETCWD = @REPLACE_GETCWD@ | ||
| 338 | REPLACE_GETDOMAINNAME = @REPLACE_GETDOMAINNAME@ | ||
| 339 | REPLACE_GETGROUPS = @REPLACE_GETGROUPS@ | ||
| 340 | REPLACE_GETLOGIN_R = @REPLACE_GETLOGIN_R@ | ||
| 341 | REPLACE_GETPAGESIZE = @REPLACE_GETPAGESIZE@ | ||
| 342 | REPLACE_LCHOWN = @REPLACE_LCHOWN@ | ||
| 343 | REPLACE_LINK = @REPLACE_LINK@ | ||
| 344 | REPLACE_LINKAT = @REPLACE_LINKAT@ | ||
| 247 | REPLACE_LOCALTIME_R = @REPLACE_LOCALTIME_R@ | 345 | REPLACE_LOCALTIME_R = @REPLACE_LOCALTIME_R@ |
| 346 | REPLACE_LSEEK = @REPLACE_LSEEK@ | ||
| 248 | REPLACE_MKTIME = @REPLACE_MKTIME@ | 347 | REPLACE_MKTIME = @REPLACE_MKTIME@ |
| 249 | REPLACE_NANOSLEEP = @REPLACE_NANOSLEEP@ | 348 | REPLACE_NANOSLEEP = @REPLACE_NANOSLEEP@ |
| 250 | REPLACE_NULL = @REPLACE_NULL@ | 349 | REPLACE_NULL = @REPLACE_NULL@ |
| 350 | REPLACE_PREAD = @REPLACE_PREAD@ | ||
| 351 | REPLACE_PWRITE = @REPLACE_PWRITE@ | ||
| 352 | REPLACE_READLINK = @REPLACE_READLINK@ | ||
| 353 | REPLACE_RMDIR = @REPLACE_RMDIR@ | ||
| 354 | REPLACE_SLEEP = @REPLACE_SLEEP@ | ||
| 355 | REPLACE_SYMLINK = @REPLACE_SYMLINK@ | ||
| 251 | REPLACE_TIMEGM = @REPLACE_TIMEGM@ | 356 | REPLACE_TIMEGM = @REPLACE_TIMEGM@ |
| 357 | REPLACE_TTYNAME_R = @REPLACE_TTYNAME_R@ | ||
| 358 | REPLACE_UNLINK = @REPLACE_UNLINK@ | ||
| 359 | REPLACE_UNLINKAT = @REPLACE_UNLINKAT@ | ||
| 360 | REPLACE_USLEEP = @REPLACE_USLEEP@ | ||
| 361 | REPLACE_WRITE = @REPLACE_WRITE@ | ||
| 252 | RSVG_CFLAGS = @RSVG_CFLAGS@ | 362 | RSVG_CFLAGS = @RSVG_CFLAGS@ |
| 253 | RSVG_LIBS = @RSVG_LIBS@ | 363 | RSVG_LIBS = @RSVG_LIBS@ |
| 254 | SET_MAKE = @SET_MAKE@ | 364 | SET_MAKE = @SET_MAKE@ |
| @@ -264,6 +374,8 @@ TIME_H_DEFINES_STRUCT_TIMESPEC = @TIME_H_DEFINES_STRUCT_TIMESPEC@ | |||
| 264 | TOOLKIT_LIBW = @TOOLKIT_LIBW@ | 374 | TOOLKIT_LIBW = @TOOLKIT_LIBW@ |
| 265 | TOOLTIP_SUPPORT = @TOOLTIP_SUPPORT@ | 375 | TOOLTIP_SUPPORT = @TOOLTIP_SUPPORT@ |
| 266 | UNEXEC_OBJ = @UNEXEC_OBJ@ | 376 | UNEXEC_OBJ = @UNEXEC_OBJ@ |
| 377 | UNISTD_H_HAVE_WINSOCK2_H = @UNISTD_H_HAVE_WINSOCK2_H@ | ||
| 378 | UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS = @UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS@ | ||
| 267 | VERSION = @VERSION@ | 379 | VERSION = @VERSION@ |
| 268 | VMLIMIT_OBJ = @VMLIMIT_OBJ@ | 380 | VMLIMIT_OBJ = @VMLIMIT_OBJ@ |
| 269 | WIDGET_OBJ = @WIDGET_OBJ@ | 381 | WIDGET_OBJ = @WIDGET_OBJ@ |
| @@ -356,20 +468,22 @@ x_default_search_path = @x_default_search_path@ | |||
| 356 | # statements but through direct file reference. Therefore this snippet must be | 468 | # statements but through direct file reference. Therefore this snippet must be |
| 357 | # present in all Makefile.am that need it. This is ensured by the applicability | 469 | # present in all Makefile.am that need it. This is ensured by the applicability |
| 358 | # 'all' defined above. | 470 | # 'all' defined above. |
| 359 | BUILT_SOURCES = arg-nonnull.h c++defs.h $(STDDEF_H) time.h \ | 471 | BUILT_SOURCES = arg-nonnull.h c++defs.h $(GETOPT_H) $(STDDEF_H) time.h \ |
| 360 | warn-on-use.h | 472 | unistd.h warn-on-use.h |
| 361 | EXTRA_DIST = $(top_srcdir)/./arg-nonnull.h $(top_srcdir)/./c++defs.h \ | 473 | EXTRA_DIST = $(top_srcdir)/./arg-nonnull.h $(top_srcdir)/./c++defs.h \ |
| 362 | intprops.h mktime-internal.h mktime.c stddef.in.h time.in.h \ | 474 | getopt.c getopt.in.h getopt1.c getopt_int.h intprops.h \ |
| 363 | time_r.c $(top_srcdir)/./warn-on-use.h | 475 | mktime-internal.h mktime.c stddef.in.h time.in.h time_r.c \ |
| 476 | unistd.in.h $(top_srcdir)/./warn-on-use.h | ||
| 364 | MOSTLYCLEANFILES = core *.stackdump arg-nonnull.h arg-nonnull.h-t \ | 477 | MOSTLYCLEANFILES = core *.stackdump arg-nonnull.h arg-nonnull.h-t \ |
| 365 | c++defs.h c++defs.h-t stddef.h stddef.h-t time.h time.h-t \ | 478 | c++defs.h c++defs.h-t getopt.h getopt.h-t stddef.h stddef.h-t \ |
| 366 | warn-on-use.h warn-on-use.h-t | 479 | time.h time.h-t unistd.h unistd.h-t warn-on-use.h \ |
| 480 | warn-on-use.h-t | ||
| 367 | noinst_LIBRARIES = libgnu.a | 481 | noinst_LIBRARIES = libgnu.a |
| 368 | DEFAULT_INCLUDES = -I. -I../src -I$(top_srcdir)/src | 482 | DEFAULT_INCLUDES = -I. -I../src -I$(top_srcdir)/src |
| 369 | libgnu_a_SOURCES = ftoastr.h ftoastr.c dtoastr.c ldtoastr.c | 483 | libgnu_a_SOURCES = ftoastr.h ftoastr.c dtoastr.c ldtoastr.c gettext.h |
| 370 | libgnu_a_LIBADD = $(gl_LIBOBJS) | 484 | libgnu_a_LIBADD = $(gl_LIBOBJS) |
| 371 | libgnu_a_DEPENDENCIES = $(gl_LIBOBJS) | 485 | libgnu_a_DEPENDENCIES = $(gl_LIBOBJS) |
| 372 | EXTRA_libgnu_a_SOURCES = mktime.c time_r.c | 486 | EXTRA_libgnu_a_SOURCES = getopt.c getopt1.c mktime.c time_r.c |
| 373 | ARG_NONNULL_H = arg-nonnull.h | 487 | ARG_NONNULL_H = arg-nonnull.h |
| 374 | CXXDEFS_H = c++defs.h | 488 | CXXDEFS_H = c++defs.h |
| 375 | WARN_ON_USE_H = warn-on-use.h | 489 | WARN_ON_USE_H = warn-on-use.h |
| @@ -424,6 +538,8 @@ distclean-compile: | |||
| 424 | 538 | ||
| 425 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dtoastr.Po@am__quote@ | 539 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dtoastr.Po@am__quote@ |
| 426 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ftoastr.Po@am__quote@ | 540 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ftoastr.Po@am__quote@ |
| 541 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getopt.Po@am__quote@ | ||
| 542 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getopt1.Po@am__quote@ | ||
| 427 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ldtoastr.Po@am__quote@ | 543 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ldtoastr.Po@am__quote@ |
| 428 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mktime.Po@am__quote@ | 544 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mktime.Po@am__quote@ |
| 429 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/time_r.Po@am__quote@ | 545 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/time_r.Po@am__quote@ |
| @@ -659,6 +775,21 @@ c++defs.h: $(top_srcdir)/./c++defs.h | |||
| 659 | > $@-t && \ | 775 | > $@-t && \ |
| 660 | mv $@-t $@ | 776 | mv $@-t $@ |
| 661 | 777 | ||
| 778 | # We need the following in order to create <getopt.h> when the system | ||
| 779 | # doesn't have one that works with the given compiler. | ||
| 780 | getopt.h: getopt.in.h $(ARG_NONNULL_H) | ||
| 781 | $(AM_V_GEN)rm -f $@-t $@ && \ | ||
| 782 | { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ | ||
| 783 | sed -e 's|@''HAVE_GETOPT_H''@|$(HAVE_GETOPT_H)|g' \ | ||
| 784 | -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ | ||
| 785 | -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ | ||
| 786 | -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ | ||
| 787 | -e 's|@''NEXT_GETOPT_H''@|$(NEXT_GETOPT_H)|g' \ | ||
| 788 | -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \ | ||
| 789 | < $(srcdir)/getopt.in.h; \ | ||
| 790 | } > $@-t && \ | ||
| 791 | mv -f $@-t $@ | ||
| 792 | |||
| 662 | # We need the following in order to create <stddef.h> when the system | 793 | # We need the following in order to create <stddef.h> when the system |
| 663 | # doesn't have one that works with the given compiler. | 794 | # doesn't have one that works with the given compiler. |
| 664 | stddef.h: stddef.in.h | 795 | stddef.h: stddef.in.h |
| @@ -705,6 +836,128 @@ time.h: time.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) | |||
| 705 | < $(srcdir)/time.in.h; \ | 836 | < $(srcdir)/time.in.h; \ |
| 706 | } > $@-t && \ | 837 | } > $@-t && \ |
| 707 | mv $@-t $@ | 838 | mv $@-t $@ |
| 839 | |||
| 840 | # We need the following in order to create an empty placeholder for | ||
| 841 | # <unistd.h> when the system doesn't have one. | ||
| 842 | unistd.h: unistd.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) | ||
| 843 | $(AM_V_GEN)rm -f $@-t $@ && \ | ||
| 844 | { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ | ||
| 845 | sed -e 's|@''HAVE_UNISTD_H''@|$(HAVE_UNISTD_H)|g' \ | ||
| 846 | -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ | ||
| 847 | -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ | ||
| 848 | -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ | ||
| 849 | -e 's|@''NEXT_UNISTD_H''@|$(NEXT_UNISTD_H)|g' \ | ||
| 850 | -e 's|@''GNULIB_CHOWN''@|$(GNULIB_CHOWN)|g' \ | ||
| 851 | -e 's|@''GNULIB_CLOSE''@|$(GNULIB_CLOSE)|g' \ | ||
| 852 | -e 's|@''GNULIB_DUP2''@|$(GNULIB_DUP2)|g' \ | ||
| 853 | -e 's|@''GNULIB_DUP3''@|$(GNULIB_DUP3)|g' \ | ||
| 854 | -e 's|@''GNULIB_ENVIRON''@|$(GNULIB_ENVIRON)|g' \ | ||
| 855 | -e 's|@''GNULIB_EUIDACCESS''@|$(GNULIB_EUIDACCESS)|g' \ | ||
| 856 | -e 's|@''GNULIB_FACCESSAT''@|$(GNULIB_FACCESSAT)|g' \ | ||
| 857 | -e 's|@''GNULIB_FCHDIR''@|$(GNULIB_FCHDIR)|g' \ | ||
| 858 | -e 's|@''GNULIB_FCHOWNAT''@|$(GNULIB_FCHOWNAT)|g' \ | ||
| 859 | -e 's|@''GNULIB_FSYNC''@|$(GNULIB_FSYNC)|g' \ | ||
| 860 | -e 's|@''GNULIB_FTRUNCATE''@|$(GNULIB_FTRUNCATE)|g' \ | ||
| 861 | -e 's|@''GNULIB_GETCWD''@|$(GNULIB_GETCWD)|g' \ | ||
| 862 | -e 's|@''GNULIB_GETDOMAINNAME''@|$(GNULIB_GETDOMAINNAME)|g' \ | ||
| 863 | -e 's|@''GNULIB_GETDTABLESIZE''@|$(GNULIB_GETDTABLESIZE)|g' \ | ||
| 864 | -e 's|@''GNULIB_GETGROUPS''@|$(GNULIB_GETGROUPS)|g' \ | ||
| 865 | -e 's|@''GNULIB_GETHOSTNAME''@|$(GNULIB_GETHOSTNAME)|g' \ | ||
| 866 | -e 's|@''GNULIB_GETLOGIN''@|$(GNULIB_GETLOGIN)|g' \ | ||
| 867 | -e 's|@''GNULIB_GETLOGIN_R''@|$(GNULIB_GETLOGIN_R)|g' \ | ||
| 868 | -e 's|@''GNULIB_GETPAGESIZE''@|$(GNULIB_GETPAGESIZE)|g' \ | ||
| 869 | -e 's|@''GNULIB_GETUSERSHELL''@|$(GNULIB_GETUSERSHELL)|g' \ | ||
| 870 | -e 's|@''GNULIB_LCHOWN''@|$(GNULIB_LCHOWN)|g' \ | ||
| 871 | -e 's|@''GNULIB_LINK''@|$(GNULIB_LINK)|g' \ | ||
| 872 | -e 's|@''GNULIB_LINKAT''@|$(GNULIB_LINKAT)|g' \ | ||
| 873 | -e 's|@''GNULIB_LSEEK''@|$(GNULIB_LSEEK)|g' \ | ||
| 874 | -e 's|@''GNULIB_PIPE''@|$(GNULIB_PIPE)|g' \ | ||
| 875 | -e 's|@''GNULIB_PIPE2''@|$(GNULIB_PIPE2)|g' \ | ||
| 876 | -e 's|@''GNULIB_PREAD''@|$(GNULIB_PREAD)|g' \ | ||
| 877 | -e 's|@''GNULIB_PWRITE''@|$(GNULIB_PWRITE)|g' \ | ||
| 878 | -e 's|@''GNULIB_READLINK''@|$(GNULIB_READLINK)|g' \ | ||
| 879 | -e 's|@''GNULIB_READLINKAT''@|$(GNULIB_READLINKAT)|g' \ | ||
| 880 | -e 's|@''GNULIB_RMDIR''@|$(GNULIB_RMDIR)|g' \ | ||
| 881 | -e 's|@''GNULIB_SLEEP''@|$(GNULIB_SLEEP)|g' \ | ||
| 882 | -e 's|@''GNULIB_SYMLINK''@|$(GNULIB_SYMLINK)|g' \ | ||
| 883 | -e 's|@''GNULIB_SYMLINKAT''@|$(GNULIB_SYMLINKAT)|g' \ | ||
| 884 | -e 's|@''GNULIB_TTYNAME_R''@|$(GNULIB_TTYNAME_R)|g' \ | ||
| 885 | -e 's|@''GNULIB_UNISTD_H_GETOPT''@|$(GNULIB_UNISTD_H_GETOPT)|g' \ | ||
| 886 | -e 's|@''GNULIB_UNISTD_H_SIGPIPE''@|$(GNULIB_UNISTD_H_SIGPIPE)|g' \ | ||
| 887 | -e 's|@''GNULIB_UNLINK''@|$(GNULIB_UNLINK)|g' \ | ||
| 888 | -e 's|@''GNULIB_UNLINKAT''@|$(GNULIB_UNLINKAT)|g' \ | ||
| 889 | -e 's|@''GNULIB_USLEEP''@|$(GNULIB_USLEEP)|g' \ | ||
| 890 | -e 's|@''GNULIB_WRITE''@|$(GNULIB_WRITE)|g' \ | ||
| 891 | < $(srcdir)/unistd.in.h | \ | ||
| 892 | sed -e 's|@''HAVE_CHOWN''@|$(HAVE_CHOWN)|g' \ | ||
| 893 | -e 's|@''HAVE_DUP2''@|$(HAVE_DUP2)|g' \ | ||
| 894 | -e 's|@''HAVE_DUP3''@|$(HAVE_DUP3)|g' \ | ||
| 895 | -e 's|@''HAVE_EUIDACCESS''@|$(HAVE_EUIDACCESS)|g' \ | ||
| 896 | -e 's|@''HAVE_FACCESSAT''@|$(HAVE_FACCESSAT)|g' \ | ||
| 897 | -e 's|@''HAVE_FCHDIR''@|$(HAVE_FCHDIR)|g' \ | ||
| 898 | -e 's|@''HAVE_FCHOWNAT''@|$(HAVE_FCHOWNAT)|g' \ | ||
| 899 | -e 's|@''HAVE_FSYNC''@|$(HAVE_FSYNC)|g' \ | ||
| 900 | -e 's|@''HAVE_FTRUNCATE''@|$(HAVE_FTRUNCATE)|g' \ | ||
| 901 | -e 's|@''HAVE_GETDTABLESIZE''@|$(HAVE_GETDTABLESIZE)|g' \ | ||
| 902 | -e 's|@''HAVE_GETGROUPS''@|$(HAVE_GETGROUPS)|g' \ | ||
| 903 | -e 's|@''HAVE_GETHOSTNAME''@|$(HAVE_GETHOSTNAME)|g' \ | ||
| 904 | -e 's|@''HAVE_GETLOGIN''@|$(HAVE_GETLOGIN)|g' \ | ||
| 905 | -e 's|@''HAVE_GETPAGESIZE''@|$(HAVE_GETPAGESIZE)|g' \ | ||
| 906 | -e 's|@''HAVE_LCHOWN''@|$(HAVE_LCHOWN)|g' \ | ||
| 907 | -e 's|@''HAVE_LINK''@|$(HAVE_LINK)|g' \ | ||
| 908 | -e 's|@''HAVE_LINKAT''@|$(HAVE_LINKAT)|g' \ | ||
| 909 | -e 's|@''HAVE_PIPE''@|$(HAVE_PIPE)|g' \ | ||
| 910 | -e 's|@''HAVE_PIPE2''@|$(HAVE_PIPE2)|g' \ | ||
| 911 | -e 's|@''HAVE_PREAD''@|$(HAVE_PREAD)|g' \ | ||
| 912 | -e 's|@''HAVE_PWRITE''@|$(HAVE_PWRITE)|g' \ | ||
| 913 | -e 's|@''HAVE_READLINK''@|$(HAVE_READLINK)|g' \ | ||
| 914 | -e 's|@''HAVE_READLINKAT''@|$(HAVE_READLINKAT)|g' \ | ||
| 915 | -e 's|@''HAVE_SLEEP''@|$(HAVE_SLEEP)|g' \ | ||
| 916 | -e 's|@''HAVE_SYMLINK''@|$(HAVE_SYMLINK)|g' \ | ||
| 917 | -e 's|@''HAVE_SYMLINKAT''@|$(HAVE_SYMLINKAT)|g' \ | ||
| 918 | -e 's|@''HAVE_UNLINKAT''@|$(HAVE_UNLINKAT)|g' \ | ||
| 919 | -e 's|@''HAVE_USLEEP''@|$(HAVE_USLEEP)|g' \ | ||
| 920 | -e 's|@''HAVE_DECL_ENVIRON''@|$(HAVE_DECL_ENVIRON)|g' \ | ||
| 921 | -e 's|@''HAVE_DECL_FCHDIR''@|$(HAVE_DECL_FCHDIR)|g' \ | ||
| 922 | -e 's|@''HAVE_DECL_GETDOMAINNAME''@|$(HAVE_DECL_GETDOMAINNAME)|g' \ | ||
| 923 | -e 's|@''HAVE_DECL_GETLOGIN_R''@|$(HAVE_DECL_GETLOGIN_R)|g' \ | ||
| 924 | -e 's|@''HAVE_DECL_GETPAGESIZE''@|$(HAVE_DECL_GETPAGESIZE)|g' \ | ||
| 925 | -e 's|@''HAVE_DECL_GETUSERSHELL''@|$(HAVE_DECL_GETUSERSHELL)|g' \ | ||
| 926 | -e 's|@''HAVE_DECL_TTYNAME_R''@|$(HAVE_DECL_TTYNAME_R)|g' \ | ||
| 927 | -e 's|@''HAVE_OS_H''@|$(HAVE_OS_H)|g' \ | ||
| 928 | -e 's|@''HAVE_SYS_PARAM_H''@|$(HAVE_SYS_PARAM_H)|g' \ | ||
| 929 | -e 's|@''REPLACE_CHOWN''@|$(REPLACE_CHOWN)|g' \ | ||
| 930 | -e 's|@''REPLACE_CLOSE''@|$(REPLACE_CLOSE)|g' \ | ||
| 931 | -e 's|@''REPLACE_DUP''@|$(REPLACE_DUP)|g' \ | ||
| 932 | -e 's|@''REPLACE_DUP2''@|$(REPLACE_DUP2)|g' \ | ||
| 933 | -e 's|@''REPLACE_FCHOWNAT''@|$(REPLACE_FCHOWNAT)|g' \ | ||
| 934 | -e 's|@''REPLACE_GETCWD''@|$(REPLACE_GETCWD)|g' \ | ||
| 935 | -e 's|@''REPLACE_GETDOMAINNAME''@|$(REPLACE_GETDOMAINNAME)|g' \ | ||
| 936 | -e 's|@''REPLACE_GETLOGIN_R''@|$(REPLACE_GETLOGIN_R)|g' \ | ||
| 937 | -e 's|@''REPLACE_GETGROUPS''@|$(REPLACE_GETGROUPS)|g' \ | ||
| 938 | -e 's|@''REPLACE_GETPAGESIZE''@|$(REPLACE_GETPAGESIZE)|g' \ | ||
| 939 | -e 's|@''REPLACE_LCHOWN''@|$(REPLACE_LCHOWN)|g' \ | ||
| 940 | -e 's|@''REPLACE_LINK''@|$(REPLACE_LINK)|g' \ | ||
| 941 | -e 's|@''REPLACE_LINKAT''@|$(REPLACE_LINKAT)|g' \ | ||
| 942 | -e 's|@''REPLACE_LSEEK''@|$(REPLACE_LSEEK)|g' \ | ||
| 943 | -e 's|@''REPLACE_PREAD''@|$(REPLACE_PREAD)|g' \ | ||
| 944 | -e 's|@''REPLACE_PWRITE''@|$(REPLACE_PWRITE)|g' \ | ||
| 945 | -e 's|@''REPLACE_READLINK''@|$(REPLACE_READLINK)|g' \ | ||
| 946 | -e 's|@''REPLACE_RMDIR''@|$(REPLACE_RMDIR)|g' \ | ||
| 947 | -e 's|@''REPLACE_SLEEP''@|$(REPLACE_SLEEP)|g' \ | ||
| 948 | -e 's|@''REPLACE_SYMLINK''@|$(REPLACE_SYMLINK)|g' \ | ||
| 949 | -e 's|@''REPLACE_TTYNAME_R''@|$(REPLACE_TTYNAME_R)|g' \ | ||
| 950 | -e 's|@''REPLACE_UNLINK''@|$(REPLACE_UNLINK)|g' \ | ||
| 951 | -e 's|@''REPLACE_UNLINKAT''@|$(REPLACE_UNLINKAT)|g' \ | ||
| 952 | -e 's|@''REPLACE_USLEEP''@|$(REPLACE_USLEEP)|g' \ | ||
| 953 | -e 's|@''REPLACE_WRITE''@|$(REPLACE_WRITE)|g' \ | ||
| 954 | -e 's|@''UNISTD_H_HAVE_WINSOCK2_H''@|$(UNISTD_H_HAVE_WINSOCK2_H)|g' \ | ||
| 955 | -e 's|@''UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS''@|$(UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS)|g' \ | ||
| 956 | -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \ | ||
| 957 | -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \ | ||
| 958 | -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)'; \ | ||
| 959 | } > $@-t && \ | ||
| 960 | mv $@-t $@ | ||
| 708 | # The warn-on-use.h that gets inserted into generated .h files is the same as | 961 | # The warn-on-use.h that gets inserted into generated .h files is the same as |
| 709 | # build-aux/warn-on-use.h, except that it has the copyright header cut off. | 962 | # build-aux/warn-on-use.h, except that it has the copyright header cut off. |
| 710 | warn-on-use.h: $(top_srcdir)/./warn-on-use.h | 963 | warn-on-use.h: $(top_srcdir)/./warn-on-use.h |
diff --git a/lib/getopt.c b/lib/getopt.c new file mode 100644 index 00000000000..c8b301363f1 --- /dev/null +++ b/lib/getopt.c | |||
| @@ -0,0 +1,1192 @@ | |||
| 1 | /* Getopt for GNU. | ||
| 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 | ||
| 4 | before changing it! | ||
| 5 | Copyright (C) 1987-1996, 1998-2004, 2006, 2008-2011 Free Software | ||
| 6 | Foundation, Inc. | ||
| 7 | This file is part of the GNU C Library. | ||
| 8 | |||
| 9 | This program is free software: you can redistribute it and/or modify | ||
| 10 | it under the terms of the GNU General Public License as published by | ||
| 11 | the Free Software Foundation; either version 3 of the License, or | ||
| 12 | (at your option) any later version. | ||
| 13 | |||
| 14 | This program is distributed in the hope that it will be useful, | ||
| 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 17 | GNU General Public License for more details. | ||
| 18 | |||
| 19 | You should have received a copy of the GNU General Public License | ||
| 20 | along with this program. If not, see <http://www.gnu.org/licenses/>. */ | ||
| 21 | |||
| 22 | #ifndef _LIBC | ||
| 23 | # include <config.h> | ||
| 24 | #endif | ||
| 25 | |||
| 26 | #include "getopt.h" | ||
| 27 | |||
| 28 | #include <stdio.h> | ||
| 29 | #include <stdlib.h> | ||
| 30 | #include <string.h> | ||
| 31 | #include <unistd.h> | ||
| 32 | |||
| 33 | #ifdef _LIBC | ||
| 34 | # include <libintl.h> | ||
| 35 | #else | ||
| 36 | # include "gettext.h" | ||
| 37 | # define _(msgid) gettext (msgid) | ||
| 38 | #endif | ||
| 39 | |||
| 40 | #if defined _LIBC && defined USE_IN_LIBIO | ||
| 41 | # include <wchar.h> | ||
| 42 | #endif | ||
| 43 | |||
| 44 | /* This version of `getopt' appears to the caller like standard Unix `getopt' | ||
| 45 | but it behaves differently for the user, since it allows the user | ||
| 46 | to intersperse the options with the other arguments. | ||
| 47 | |||
| 48 | As `getopt_long' works, it permutes the elements of ARGV so that, | ||
| 49 | when it is done, all the options precede everything else. Thus | ||
| 50 | all application programs are extended to handle flexible argument order. | ||
| 51 | |||
| 52 | Using `getopt' or setting the environment variable POSIXLY_CORRECT | ||
| 53 | disables permutation. | ||
| 54 | Then the behavior is completely standard. | ||
| 55 | |||
| 56 | GNU application programs can use a third alternative mode in which | ||
| 57 | they can distinguish the relative order of options and other arguments. */ | ||
| 58 | |||
| 59 | #include "getopt_int.h" | ||
| 60 | |||
| 61 | /* For communication from `getopt' to the caller. | ||
| 62 | When `getopt' finds an option that takes an argument, | ||
| 63 | the argument value is returned here. | ||
| 64 | Also, when `ordering' is RETURN_IN_ORDER, | ||
| 65 | each non-option ARGV-element is returned here. */ | ||
| 66 | |||
| 67 | char *optarg; | ||
| 68 | |||
| 69 | /* Index in ARGV of the next element to be scanned. | ||
| 70 | This is used for communication to and from the caller | ||
| 71 | and for communication between successive calls to `getopt'. | ||
| 72 | |||
| 73 | On entry to `getopt', zero means this is the first call; initialize. | ||
| 74 | |||
| 75 | When `getopt' returns -1, this is the index of the first of the | ||
| 76 | non-option elements that the caller should itself scan. | ||
| 77 | |||
| 78 | Otherwise, `optind' communicates from one call to the next | ||
| 79 | how much of ARGV has been scanned so far. */ | ||
| 80 | |||
| 81 | /* 1003.2 says this must be 1 before any call. */ | ||
| 82 | int optind = 1; | ||
| 83 | |||
| 84 | /* Callers store zero here to inhibit the error message | ||
| 85 | for unrecognized options. */ | ||
| 86 | |||
| 87 | int opterr = 1; | ||
| 88 | |||
| 89 | /* Set to an option character which was unrecognized. | ||
| 90 | This must be initialized on some systems to avoid linking in the | ||
| 91 | system's own getopt implementation. */ | ||
| 92 | |||
| 93 | int optopt = '?'; | ||
| 94 | |||
| 95 | /* Keep a global copy of all internal members of getopt_data. */ | ||
| 96 | |||
| 97 | static struct _getopt_data getopt_data; | ||
| 98 | |||
| 99 | |||
| 100 | #if defined HAVE_DECL_GETENV && !HAVE_DECL_GETENV | ||
| 101 | extern char *getenv (); | ||
| 102 | #endif | ||
| 103 | |||
| 104 | #ifdef _LIBC | ||
| 105 | /* Stored original parameters. | ||
| 106 | XXX This is no good solution. We should rather copy the args so | ||
| 107 | that we can compare them later. But we must not use malloc(3). */ | ||
| 108 | extern int __libc_argc; | ||
| 109 | extern char **__libc_argv; | ||
| 110 | |||
| 111 | /* Bash 2.0 gives us an environment variable containing flags | ||
| 112 | indicating ARGV elements that should not be considered arguments. */ | ||
| 113 | |||
| 114 | # ifdef USE_NONOPTION_FLAGS | ||
| 115 | /* Defined in getopt_init.c */ | ||
| 116 | extern char *__getopt_nonoption_flags; | ||
| 117 | # endif | ||
| 118 | |||
| 119 | # ifdef USE_NONOPTION_FLAGS | ||
| 120 | # define SWAP_FLAGS(ch1, ch2) \ | ||
| 121 | if (d->__nonoption_flags_len > 0) \ | ||
| 122 | { \ | ||
| 123 | char __tmp = __getopt_nonoption_flags[ch1]; \ | ||
| 124 | __getopt_nonoption_flags[ch1] = __getopt_nonoption_flags[ch2]; \ | ||
| 125 | __getopt_nonoption_flags[ch2] = __tmp; \ | ||
| 126 | } | ||
| 127 | # else | ||
| 128 | # define SWAP_FLAGS(ch1, ch2) | ||
| 129 | # endif | ||
| 130 | #else /* !_LIBC */ | ||
| 131 | # define SWAP_FLAGS(ch1, ch2) | ||
| 132 | #endif /* _LIBC */ | ||
| 133 | |||
| 134 | /* Exchange two adjacent subsequences of ARGV. | ||
| 135 | One subsequence is elements [first_nonopt,last_nonopt) | ||
| 136 | which contains all the non-options that have been skipped so far. | ||
| 137 | The other is elements [last_nonopt,optind), which contains all | ||
| 138 | the options processed since those non-options were skipped. | ||
| 139 | |||
| 140 | `first_nonopt' and `last_nonopt' are relocated so that they describe | ||
| 141 | the new indices of the non-options in ARGV after they are moved. */ | ||
| 142 | |||
| 143 | static void | ||
| 144 | exchange (char **argv, struct _getopt_data *d) | ||
| 145 | { | ||
| 146 | int bottom = d->__first_nonopt; | ||
| 147 | int middle = d->__last_nonopt; | ||
| 148 | int top = d->optind; | ||
| 149 | char *tem; | ||
| 150 | |||
| 151 | /* Exchange the shorter segment with the far end of the longer segment. | ||
| 152 | That puts the shorter segment into the right place. | ||
| 153 | It leaves the longer segment in the right place overall, | ||
| 154 | but it consists of two parts that need to be swapped next. */ | ||
| 155 | |||
| 156 | #if defined _LIBC && defined USE_NONOPTION_FLAGS | ||
| 157 | /* First make sure the handling of the `__getopt_nonoption_flags' | ||
| 158 | string can work normally. Our top argument must be in the range | ||
| 159 | of the string. */ | ||
| 160 | if (d->__nonoption_flags_len > 0 && top >= d->__nonoption_flags_max_len) | ||
| 161 | { | ||
| 162 | /* We must extend the array. The user plays games with us and | ||
| 163 | presents new arguments. */ | ||
| 164 | char *new_str = malloc (top + 1); | ||
| 165 | if (new_str == NULL) | ||
| 166 | d->__nonoption_flags_len = d->__nonoption_flags_max_len = 0; | ||
| 167 | else | ||
| 168 | { | ||
| 169 | memset (__mempcpy (new_str, __getopt_nonoption_flags, | ||
| 170 | d->__nonoption_flags_max_len), | ||
| 171 | '\0', top + 1 - d->__nonoption_flags_max_len); | ||
| 172 | d->__nonoption_flags_max_len = top + 1; | ||
| 173 | __getopt_nonoption_flags = new_str; | ||
| 174 | } | ||
| 175 | } | ||
| 176 | #endif | ||
| 177 | |||
| 178 | while (top > middle && middle > bottom) | ||
| 179 | { | ||
| 180 | if (top - middle > middle - bottom) | ||
| 181 | { | ||
| 182 | /* Bottom segment is the short one. */ | ||
| 183 | int len = middle - bottom; | ||
| 184 | register int i; | ||
| 185 | |||
| 186 | /* Swap it with the top part of the top segment. */ | ||
| 187 | for (i = 0; i < len; i++) | ||
| 188 | { | ||
| 189 | tem = argv[bottom + i]; | ||
| 190 | argv[bottom + i] = argv[top - (middle - bottom) + i]; | ||
| 191 | argv[top - (middle - bottom) + i] = tem; | ||
| 192 | SWAP_FLAGS (bottom + i, top - (middle - bottom) + i); | ||
| 193 | } | ||
| 194 | /* Exclude the moved bottom segment from further swapping. */ | ||
| 195 | top -= len; | ||
| 196 | } | ||
| 197 | else | ||
| 198 | { | ||
| 199 | /* Top segment is the short one. */ | ||
| 200 | int len = top - middle; | ||
| 201 | register int i; | ||
| 202 | |||
| 203 | /* Swap it with the bottom part of the bottom segment. */ | ||
| 204 | for (i = 0; i < len; i++) | ||
| 205 | { | ||
| 206 | tem = argv[bottom + i]; | ||
| 207 | argv[bottom + i] = argv[middle + i]; | ||
| 208 | argv[middle + i] = tem; | ||
| 209 | SWAP_FLAGS (bottom + i, middle + i); | ||
| 210 | } | ||
| 211 | /* Exclude the moved top segment from further swapping. */ | ||
| 212 | bottom += len; | ||
| 213 | } | ||
| 214 | } | ||
| 215 | |||
| 216 | /* Update records for the slots the non-options now occupy. */ | ||
| 217 | |||
| 218 | d->__first_nonopt += (d->optind - d->__last_nonopt); | ||
| 219 | d->__last_nonopt = d->optind; | ||
| 220 | } | ||
| 221 | |||
| 222 | /* Initialize the internal data when the first call is made. */ | ||
| 223 | |||
| 224 | static const char * | ||
| 225 | _getopt_initialize (int argc _GL_UNUSED, | ||
| 226 | char **argv _GL_UNUSED, const char *optstring, | ||
| 227 | struct _getopt_data *d, int posixly_correct) | ||
| 228 | { | ||
| 229 | /* Start processing options with ARGV-element 1 (since ARGV-element 0 | ||
| 230 | is the program name); the sequence of previously skipped | ||
| 231 | non-option ARGV-elements is empty. */ | ||
| 232 | |||
| 233 | d->__first_nonopt = d->__last_nonopt = d->optind; | ||
| 234 | |||
| 235 | d->__nextchar = NULL; | ||
| 236 | |||
| 237 | d->__posixly_correct = posixly_correct || !!getenv ("POSIXLY_CORRECT"); | ||
| 238 | |||
| 239 | /* Determine how to handle the ordering of options and nonoptions. */ | ||
| 240 | |||
| 241 | if (optstring[0] == '-') | ||
| 242 | { | ||
| 243 | d->__ordering = RETURN_IN_ORDER; | ||
| 244 | ++optstring; | ||
| 245 | } | ||
| 246 | else if (optstring[0] == '+') | ||
| 247 | { | ||
| 248 | d->__ordering = REQUIRE_ORDER; | ||
| 249 | ++optstring; | ||
| 250 | } | ||
| 251 | else if (d->__posixly_correct) | ||
| 252 | d->__ordering = REQUIRE_ORDER; | ||
| 253 | else | ||
| 254 | d->__ordering = PERMUTE; | ||
| 255 | |||
| 256 | #if defined _LIBC && defined USE_NONOPTION_FLAGS | ||
| 257 | if (!d->__posixly_correct | ||
| 258 | && argc == __libc_argc && argv == __libc_argv) | ||
| 259 | { | ||
| 260 | if (d->__nonoption_flags_max_len == 0) | ||
| 261 | { | ||
| 262 | if (__getopt_nonoption_flags == NULL | ||
| 263 | || __getopt_nonoption_flags[0] == '\0') | ||
| 264 | d->__nonoption_flags_max_len = -1; | ||
| 265 | else | ||
| 266 | { | ||
| 267 | const char *orig_str = __getopt_nonoption_flags; | ||
| 268 | int len = d->__nonoption_flags_max_len = strlen (orig_str); | ||
| 269 | if (d->__nonoption_flags_max_len < argc) | ||
| 270 | d->__nonoption_flags_max_len = argc; | ||
| 271 | __getopt_nonoption_flags = | ||
| 272 | (char *) malloc (d->__nonoption_flags_max_len); | ||
| 273 | if (__getopt_nonoption_flags == NULL) | ||
| 274 | d->__nonoption_flags_max_len = -1; | ||
| 275 | else | ||
| 276 | memset (__mempcpy (__getopt_nonoption_flags, orig_str, len), | ||
| 277 | '\0', d->__nonoption_flags_max_len - len); | ||
| 278 | } | ||
| 279 | } | ||
| 280 | d->__nonoption_flags_len = d->__nonoption_flags_max_len; | ||
| 281 | } | ||
| 282 | else | ||
| 283 | d->__nonoption_flags_len = 0; | ||
| 284 | #endif | ||
| 285 | |||
| 286 | return optstring; | ||
| 287 | } | ||
| 288 | |||
| 289 | /* Scan elements of ARGV (whose length is ARGC) for option characters | ||
| 290 | given in OPTSTRING. | ||
| 291 | |||
| 292 | If an element of ARGV starts with '-', and is not exactly "-" or "--", | ||
| 293 | then it is an option element. The characters of this element | ||
| 294 | (aside from the initial '-') are option characters. If `getopt' | ||
| 295 | is called repeatedly, it returns successively each of the option characters | ||
| 296 | from each of the option elements. | ||
| 297 | |||
| 298 | If `getopt' finds another option character, it returns that character, | ||
| 299 | updating `optind' and `nextchar' so that the next call to `getopt' can | ||
| 300 | resume the scan with the following option character or ARGV-element. | ||
| 301 | |||
| 302 | If there are no more option characters, `getopt' returns -1. | ||
| 303 | Then `optind' is the index in ARGV of the first ARGV-element | ||
| 304 | that is not an option. (The ARGV-elements have been permuted | ||
| 305 | so that those that are not options now come last.) | ||
| 306 | |||
| 307 | OPTSTRING is a string containing the legitimate option characters. | ||
| 308 | If an option character is seen that is not listed in OPTSTRING, | ||
| 309 | return '?' after printing an error message. If you set `opterr' to | ||
| 310 | zero, the error message is suppressed but we still return '?'. | ||
| 311 | |||
| 312 | If a char in OPTSTRING is followed by a colon, that means it wants an arg, | ||
| 313 | so the following text in the same ARGV-element, or the text of the following | ||
| 314 | ARGV-element, is returned in `optarg'. Two colons mean an option that | ||
| 315 | wants an optional arg; if there is text in the current ARGV-element, | ||
| 316 | it is returned in `optarg', otherwise `optarg' is set to zero. | ||
| 317 | |||
| 318 | If OPTSTRING starts with `-' or `+', it requests different methods of | ||
| 319 | handling the non-option ARGV-elements. | ||
| 320 | See the comments about RETURN_IN_ORDER and REQUIRE_ORDER, above. | ||
| 321 | |||
| 322 | Long-named options begin with `--' instead of `-'. | ||
| 323 | Their names may be abbreviated as long as the abbreviation is unique | ||
| 324 | or is an exact match for some defined option. If they have an | ||
| 325 | argument, it follows the option name in the same ARGV-element, separated | ||
| 326 | from the option name by a `=', or else the in next ARGV-element. | ||
| 327 | When `getopt' finds a long-named option, it returns 0 if that option's | ||
| 328 | `flag' field is nonzero, the value of the option's `val' field | ||
| 329 | if the `flag' field is zero. | ||
| 330 | |||
| 331 | The elements of ARGV aren't really const, because we permute them. | ||
| 332 | But we pretend they're const in the prototype to be compatible | ||
| 333 | with other systems. | ||
| 334 | |||
| 335 | LONGOPTS is a vector of `struct option' terminated by an | ||
| 336 | element containing a name which is zero. | ||
| 337 | |||
| 338 | LONGIND returns the index in LONGOPT of the long-named option found. | ||
| 339 | It is only valid when a long-named option has been found by the most | ||
| 340 | recent call. | ||
| 341 | |||
| 342 | If LONG_ONLY is nonzero, '-' as well as '--' can introduce | ||
| 343 | long-named options. */ | ||
| 344 | |||
| 345 | int | ||
| 346 | _getopt_internal_r (int argc, char **argv, const char *optstring, | ||
| 347 | const struct option *longopts, int *longind, | ||
| 348 | int long_only, struct _getopt_data *d, int posixly_correct) | ||
| 349 | { | ||
| 350 | int print_errors = d->opterr; | ||
| 351 | |||
| 352 | if (argc < 1) | ||
| 353 | return -1; | ||
| 354 | |||
| 355 | d->optarg = NULL; | ||
| 356 | |||
| 357 | if (d->optind == 0 || !d->__initialized) | ||
| 358 | { | ||
| 359 | if (d->optind == 0) | ||
| 360 | d->optind = 1; /* Don't scan ARGV[0], the program name. */ | ||
| 361 | optstring = _getopt_initialize (argc, argv, optstring, d, | ||
| 362 | posixly_correct); | ||
| 363 | d->__initialized = 1; | ||
| 364 | } | ||
| 365 | else if (optstring[0] == '-' || optstring[0] == '+') | ||
| 366 | optstring++; | ||
| 367 | if (optstring[0] == ':') | ||
| 368 | print_errors = 0; | ||
| 369 | |||
| 370 | /* Test whether ARGV[optind] points to a non-option argument. | ||
| 371 | Either it does not have option syntax, or there is an environment flag | ||
| 372 | from the shell indicating it is not an option. The later information | ||
| 373 | is only used when the used in the GNU libc. */ | ||
| 374 | #if defined _LIBC && defined USE_NONOPTION_FLAGS | ||
| 375 | # define NONOPTION_P (argv[d->optind][0] != '-' || argv[d->optind][1] == '\0' \ | ||
| 376 | || (d->optind < d->__nonoption_flags_len \ | ||
| 377 | && __getopt_nonoption_flags[d->optind] == '1')) | ||
| 378 | #else | ||
| 379 | # define NONOPTION_P (argv[d->optind][0] != '-' || argv[d->optind][1] == '\0') | ||
| 380 | #endif | ||
| 381 | |||
| 382 | if (d->__nextchar == NULL || *d->__nextchar == '\0') | ||
| 383 | { | ||
| 384 | /* Advance to the next ARGV-element. */ | ||
| 385 | |||
| 386 | /* Give FIRST_NONOPT & LAST_NONOPT rational values if OPTIND has been | ||
| 387 | moved back by the user (who may also have changed the arguments). */ | ||
| 388 | if (d->__last_nonopt > d->optind) | ||
| 389 | d->__last_nonopt = d->optind; | ||
| 390 | if (d->__first_nonopt > d->optind) | ||
| 391 | d->__first_nonopt = d->optind; | ||
| 392 | |||
| 393 | if (d->__ordering == PERMUTE) | ||
| 394 | { | ||
| 395 | /* If we have just processed some options following some non-options, | ||
| 396 | exchange them so that the options come first. */ | ||
| 397 | |||
| 398 | if (d->__first_nonopt != d->__last_nonopt | ||
| 399 | && d->__last_nonopt != d->optind) | ||
| 400 | exchange ((char **) argv, d); | ||
| 401 | else if (d->__last_nonopt != d->optind) | ||
| 402 | d->__first_nonopt = d->optind; | ||
| 403 | |||
| 404 | /* Skip any additional non-options | ||
| 405 | and extend the range of non-options previously skipped. */ | ||
| 406 | |||
| 407 | while (d->optind < argc && NONOPTION_P) | ||
| 408 | d->optind++; | ||
| 409 | d->__last_nonopt = d->optind; | ||
| 410 | } | ||
| 411 | |||
| 412 | /* The special ARGV-element `--' means premature end of options. | ||
| 413 | Skip it like a null option, | ||
| 414 | then exchange with previous non-options as if it were an option, | ||
| 415 | then skip everything else like a non-option. */ | ||
| 416 | |||
| 417 | if (d->optind != argc && !strcmp (argv[d->optind], "--")) | ||
| 418 | { | ||
| 419 | d->optind++; | ||
| 420 | |||
| 421 | if (d->__first_nonopt != d->__last_nonopt | ||
| 422 | && d->__last_nonopt != d->optind) | ||
| 423 | exchange ((char **) argv, d); | ||
| 424 | else if (d->__first_nonopt == d->__last_nonopt) | ||
| 425 | d->__first_nonopt = d->optind; | ||
| 426 | d->__last_nonopt = argc; | ||
| 427 | |||
| 428 | d->optind = argc; | ||
| 429 | } | ||
| 430 | |||
| 431 | /* If we have done all the ARGV-elements, stop the scan | ||
| 432 | and back over any non-options that we skipped and permuted. */ | ||
| 433 | |||
| 434 | if (d->optind == argc) | ||
| 435 | { | ||
| 436 | /* Set the next-arg-index to point at the non-options | ||
| 437 | that we previously skipped, so the caller will digest them. */ | ||
| 438 | if (d->__first_nonopt != d->__last_nonopt) | ||
| 439 | d->optind = d->__first_nonopt; | ||
| 440 | return -1; | ||
| 441 | } | ||
| 442 | |||
| 443 | /* If we have come to a non-option and did not permute it, | ||
| 444 | either stop the scan or describe it to the caller and pass it by. */ | ||
| 445 | |||
| 446 | if (NONOPTION_P) | ||
| 447 | { | ||
| 448 | if (d->__ordering == REQUIRE_ORDER) | ||
| 449 | return -1; | ||
| 450 | d->optarg = argv[d->optind++]; | ||
| 451 | return 1; | ||
| 452 | } | ||
| 453 | |||
| 454 | /* We have found another option-ARGV-element. | ||
| 455 | Skip the initial punctuation. */ | ||
| 456 | |||
| 457 | d->__nextchar = (argv[d->optind] + 1 | ||
| 458 | + (longopts != NULL && argv[d->optind][1] == '-')); | ||
| 459 | } | ||
| 460 | |||
| 461 | /* Decode the current option-ARGV-element. */ | ||
| 462 | |||
| 463 | /* Check whether the ARGV-element is a long option. | ||
| 464 | |||
| 465 | If long_only and the ARGV-element has the form "-f", where f is | ||
| 466 | a valid short option, don't consider it an abbreviated form of | ||
| 467 | a long option that starts with f. Otherwise there would be no | ||
| 468 | way to give the -f short option. | ||
| 469 | |||
| 470 | On the other hand, if there's a long option "fubar" and | ||
| 471 | the ARGV-element is "-fu", do consider that an abbreviation of | ||
| 472 | the long option, just like "--fu", and not "-f" with arg "u". | ||
| 473 | |||
| 474 | This distinction seems to be the most useful approach. */ | ||
| 475 | |||
| 476 | if (longopts != NULL | ||
| 477 | && (argv[d->optind][1] == '-' | ||
| 478 | || (long_only && (argv[d->optind][2] | ||
| 479 | || !strchr (optstring, argv[d->optind][1]))))) | ||
| 480 | { | ||
| 481 | char *nameend; | ||
| 482 | const struct option *p; | ||
| 483 | const struct option *pfound = NULL; | ||
| 484 | int exact = 0; | ||
| 485 | int ambig = 0; | ||
| 486 | int indfound = -1; | ||
| 487 | int option_index; | ||
| 488 | |||
| 489 | for (nameend = d->__nextchar; *nameend && *nameend != '='; nameend++) | ||
| 490 | /* Do nothing. */ ; | ||
| 491 | |||
| 492 | /* Test all long options for either exact match | ||
| 493 | or abbreviated matches. */ | ||
| 494 | for (p = longopts, option_index = 0; p->name; p++, option_index++) | ||
| 495 | if (!strncmp (p->name, d->__nextchar, nameend - d->__nextchar)) | ||
| 496 | { | ||
| 497 | if ((unsigned int) (nameend - d->__nextchar) | ||
| 498 | == (unsigned int) strlen (p->name)) | ||
| 499 | { | ||
| 500 | /* Exact match found. */ | ||
| 501 | pfound = p; | ||
| 502 | indfound = option_index; | ||
| 503 | exact = 1; | ||
| 504 | break; | ||
| 505 | } | ||
| 506 | else if (pfound == NULL) | ||
| 507 | { | ||
| 508 | /* First nonexact match found. */ | ||
| 509 | pfound = p; | ||
| 510 | indfound = option_index; | ||
| 511 | } | ||
| 512 | else if (long_only | ||
| 513 | || pfound->has_arg != p->has_arg | ||
| 514 | || pfound->flag != p->flag | ||
| 515 | || pfound->val != p->val) | ||
| 516 | /* Second or later nonexact match found. */ | ||
| 517 | ambig = 1; | ||
| 518 | } | ||
| 519 | |||
| 520 | if (ambig && !exact) | ||
| 521 | { | ||
| 522 | if (print_errors) | ||
| 523 | { | ||
| 524 | #if defined _LIBC && defined USE_IN_LIBIO | ||
| 525 | char *buf; | ||
| 526 | |||
| 527 | if (__asprintf (&buf, _("%s: option '%s' is ambiguous\n"), | ||
| 528 | argv[0], argv[d->optind]) >= 0) | ||
| 529 | { | ||
| 530 | _IO_flockfile (stderr); | ||
| 531 | |||
| 532 | int old_flags2 = ((_IO_FILE *) stderr)->_flags2; | ||
| 533 | ((_IO_FILE *) stderr)->_flags2 |= _IO_FLAGS2_NOTCANCEL; | ||
| 534 | |||
| 535 | __fxprintf (NULL, "%s", buf); | ||
| 536 | |||
| 537 | ((_IO_FILE *) stderr)->_flags2 = old_flags2; | ||
| 538 | _IO_funlockfile (stderr); | ||
| 539 | |||
| 540 | free (buf); | ||
| 541 | } | ||
| 542 | #else | ||
| 543 | fprintf (stderr, _("%s: option '%s' is ambiguous\n"), | ||
| 544 | argv[0], argv[d->optind]); | ||
| 545 | #endif | ||
| 546 | } | ||
| 547 | d->__nextchar += strlen (d->__nextchar); | ||
| 548 | d->optind++; | ||
| 549 | d->optopt = 0; | ||
| 550 | return '?'; | ||
| 551 | } | ||
| 552 | |||
| 553 | if (pfound != NULL) | ||
| 554 | { | ||
| 555 | option_index = indfound; | ||
| 556 | d->optind++; | ||
| 557 | if (*nameend) | ||
| 558 | { | ||
| 559 | /* Don't test has_arg with >, because some C compilers don't | ||
| 560 | allow it to be used on enums. */ | ||
| 561 | if (pfound->has_arg) | ||
| 562 | d->optarg = nameend + 1; | ||
| 563 | else | ||
| 564 | { | ||
| 565 | if (print_errors) | ||
| 566 | { | ||
| 567 | #if defined _LIBC && defined USE_IN_LIBIO | ||
| 568 | char *buf; | ||
| 569 | int n; | ||
| 570 | #endif | ||
| 571 | |||
| 572 | if (argv[d->optind - 1][1] == '-') | ||
| 573 | { | ||
| 574 | /* --option */ | ||
| 575 | #if defined _LIBC && defined USE_IN_LIBIO | ||
| 576 | n = __asprintf (&buf, _("\ | ||
| 577 | %s: option '--%s' doesn't allow an argument\n"), | ||
| 578 | argv[0], pfound->name); | ||
| 579 | #else | ||
| 580 | fprintf (stderr, _("\ | ||
| 581 | %s: option '--%s' doesn't allow an argument\n"), | ||
| 582 | argv[0], pfound->name); | ||
| 583 | #endif | ||
| 584 | } | ||
| 585 | else | ||
| 586 | { | ||
| 587 | /* +option or -option */ | ||
| 588 | #if defined _LIBC && defined USE_IN_LIBIO | ||
| 589 | n = __asprintf (&buf, _("\ | ||
| 590 | %s: option '%c%s' doesn't allow an argument\n"), | ||
| 591 | argv[0], argv[d->optind - 1][0], | ||
| 592 | pfound->name); | ||
| 593 | #else | ||
| 594 | fprintf (stderr, _("\ | ||
| 595 | %s: option '%c%s' doesn't allow an argument\n"), | ||
| 596 | argv[0], argv[d->optind - 1][0], | ||
| 597 | pfound->name); | ||
| 598 | #endif | ||
| 599 | } | ||
| 600 | |||
| 601 | #if defined _LIBC && defined USE_IN_LIBIO | ||
| 602 | if (n >= 0) | ||
| 603 | { | ||
| 604 | _IO_flockfile (stderr); | ||
| 605 | |||
| 606 | int old_flags2 = ((_IO_FILE *) stderr)->_flags2; | ||
| 607 | ((_IO_FILE *) stderr)->_flags2 | ||
| 608 | |= _IO_FLAGS2_NOTCANCEL; | ||
| 609 | |||
| 610 | __fxprintf (NULL, "%s", buf); | ||
| 611 | |||
| 612 | ((_IO_FILE *) stderr)->_flags2 = old_flags2; | ||
| 613 | _IO_funlockfile (stderr); | ||
| 614 | |||
| 615 | free (buf); | ||
| 616 | } | ||
| 617 | #endif | ||
| 618 | } | ||
| 619 | |||
| 620 | d->__nextchar += strlen (d->__nextchar); | ||
| 621 | |||
| 622 | d->optopt = pfound->val; | ||
| 623 | return '?'; | ||
| 624 | } | ||
| 625 | } | ||
| 626 | else if (pfound->has_arg == 1) | ||
| 627 | { | ||
| 628 | if (d->optind < argc) | ||
| 629 | d->optarg = argv[d->optind++]; | ||
| 630 | else | ||
| 631 | { | ||
| 632 | if (print_errors) | ||
| 633 | { | ||
| 634 | #if defined _LIBC && defined USE_IN_LIBIO | ||
| 635 | char *buf; | ||
| 636 | |||
| 637 | if (__asprintf (&buf, _("\ | ||
| 638 | %s: option '--%s' requires an argument\n"), | ||
| 639 | argv[0], pfound->name) >= 0) | ||
| 640 | { | ||
| 641 | _IO_flockfile (stderr); | ||
| 642 | |||
| 643 | int old_flags2 = ((_IO_FILE *) stderr)->_flags2; | ||
| 644 | ((_IO_FILE *) stderr)->_flags2 | ||
| 645 | |= _IO_FLAGS2_NOTCANCEL; | ||
| 646 | |||
| 647 | __fxprintf (NULL, "%s", buf); | ||
| 648 | |||
| 649 | ((_IO_FILE *) stderr)->_flags2 = old_flags2; | ||
| 650 | _IO_funlockfile (stderr); | ||
| 651 | |||
| 652 | free (buf); | ||
| 653 | } | ||
| 654 | #else | ||
| 655 | fprintf (stderr, | ||
| 656 | _("%s: option '--%s' requires an argument\n"), | ||
| 657 | argv[0], pfound->name); | ||
| 658 | #endif | ||
| 659 | } | ||
| 660 | d->__nextchar += strlen (d->__nextchar); | ||
| 661 | d->optopt = pfound->val; | ||
| 662 | return optstring[0] == ':' ? ':' : '?'; | ||
| 663 | } | ||
| 664 | } | ||
| 665 | d->__nextchar += strlen (d->__nextchar); | ||
| 666 | if (longind != NULL) | ||
| 667 | *longind = option_index; | ||
| 668 | if (pfound->flag) | ||
| 669 | { | ||
| 670 | *(pfound->flag) = pfound->val; | ||
| 671 | return 0; | ||
| 672 | } | ||
| 673 | return pfound->val; | ||
| 674 | } | ||
| 675 | |||
| 676 | /* Can't find it as a long option. If this is not getopt_long_only, | ||
| 677 | or the option starts with '--' or is not a valid short | ||
| 678 | option, then it's an error. | ||
| 679 | Otherwise interpret it as a short option. */ | ||
| 680 | if (!long_only || argv[d->optind][1] == '-' | ||
| 681 | || strchr (optstring, *d->__nextchar) == NULL) | ||
| 682 | { | ||
| 683 | if (print_errors) | ||
| 684 | { | ||
| 685 | #if defined _LIBC && defined USE_IN_LIBIO | ||
| 686 | char *buf; | ||
| 687 | int n; | ||
| 688 | #endif | ||
| 689 | |||
| 690 | if (argv[d->optind][1] == '-') | ||
| 691 | { | ||
| 692 | /* --option */ | ||
| 693 | #if defined _LIBC && defined USE_IN_LIBIO | ||
| 694 | n = __asprintf (&buf, _("%s: unrecognized option '--%s'\n"), | ||
| 695 | argv[0], d->__nextchar); | ||
| 696 | #else | ||
| 697 | fprintf (stderr, _("%s: unrecognized option '--%s'\n"), | ||
| 698 | argv[0], d->__nextchar); | ||
| 699 | #endif | ||
| 700 | } | ||
| 701 | else | ||
| 702 | { | ||
| 703 | /* +option or -option */ | ||
| 704 | #if defined _LIBC && defined USE_IN_LIBIO | ||
| 705 | n = __asprintf (&buf, _("%s: unrecognized option '%c%s'\n"), | ||
| 706 | argv[0], argv[d->optind][0], d->__nextchar); | ||
| 707 | #else | ||
| 708 | fprintf (stderr, _("%s: unrecognized option '%c%s'\n"), | ||
| 709 | argv[0], argv[d->optind][0], d->__nextchar); | ||
| 710 | #endif | ||
| 711 | } | ||
| 712 | |||
| 713 | #if defined _LIBC && defined USE_IN_LIBIO | ||
| 714 | if (n >= 0) | ||
| 715 | { | ||
| 716 | _IO_flockfile (stderr); | ||
| 717 | |||
| 718 | int old_flags2 = ((_IO_FILE *) stderr)->_flags2; | ||
| 719 | ((_IO_FILE *) stderr)->_flags2 |= _IO_FLAGS2_NOTCANCEL; | ||
| 720 | |||
| 721 | __fxprintf (NULL, "%s", buf); | ||
| 722 | |||
| 723 | ((_IO_FILE *) stderr)->_flags2 = old_flags2; | ||
| 724 | _IO_funlockfile (stderr); | ||
| 725 | |||
| 726 | free (buf); | ||
| 727 | } | ||
| 728 | #endif | ||
| 729 | } | ||
| 730 | d->__nextchar = (char *) ""; | ||
| 731 | d->optind++; | ||
| 732 | d->optopt = 0; | ||
| 733 | return '?'; | ||
| 734 | } | ||
| 735 | } | ||
| 736 | |||
| 737 | /* Look at and handle the next short option-character. */ | ||
| 738 | |||
| 739 | { | ||
| 740 | char c = *d->__nextchar++; | ||
| 741 | const char *temp = strchr (optstring, c); | ||
| 742 | |||
| 743 | /* Increment `optind' when we start to process its last character. */ | ||
| 744 | if (*d->__nextchar == '\0') | ||
| 745 | ++d->optind; | ||
| 746 | |||
| 747 | if (temp == NULL || c == ':' || c == ';') | ||
| 748 | { | ||
| 749 | if (print_errors) | ||
| 750 | { | ||
| 751 | #if defined _LIBC && defined USE_IN_LIBIO | ||
| 752 | char *buf; | ||
| 753 | int n; | ||
| 754 | #endif | ||
| 755 | |||
| 756 | #if defined _LIBC && defined USE_IN_LIBIO | ||
| 757 | n = __asprintf (&buf, _("%s: invalid option -- '%c'\n"), | ||
| 758 | argv[0], c); | ||
| 759 | #else | ||
| 760 | fprintf (stderr, _("%s: invalid option -- '%c'\n"), argv[0], c); | ||
| 761 | #endif | ||
| 762 | |||
| 763 | #if defined _LIBC && defined USE_IN_LIBIO | ||
| 764 | if (n >= 0) | ||
| 765 | { | ||
| 766 | _IO_flockfile (stderr); | ||
| 767 | |||
| 768 | int old_flags2 = ((_IO_FILE *) stderr)->_flags2; | ||
| 769 | ((_IO_FILE *) stderr)->_flags2 |= _IO_FLAGS2_NOTCANCEL; | ||
| 770 | |||
| 771 | __fxprintf (NULL, "%s", buf); | ||
| 772 | |||
| 773 | ((_IO_FILE *) stderr)->_flags2 = old_flags2; | ||
| 774 | _IO_funlockfile (stderr); | ||
| 775 | |||
| 776 | free (buf); | ||
| 777 | } | ||
| 778 | #endif | ||
| 779 | } | ||
| 780 | d->optopt = c; | ||
| 781 | return '?'; | ||
| 782 | } | ||
| 783 | /* Convenience. Treat POSIX -W foo same as long option --foo */ | ||
| 784 | if (temp[0] == 'W' && temp[1] == ';') | ||
| 785 | { | ||
| 786 | char *nameend; | ||
| 787 | const struct option *p; | ||
| 788 | const struct option *pfound = NULL; | ||
| 789 | int exact = 0; | ||
| 790 | int ambig = 0; | ||
| 791 | int indfound = 0; | ||
| 792 | int option_index; | ||
| 793 | |||
| 794 | /* This is an option that requires an argument. */ | ||
| 795 | if (*d->__nextchar != '\0') | ||
| 796 | { | ||
| 797 | d->optarg = d->__nextchar; | ||
| 798 | /* If we end this ARGV-element by taking the rest as an arg, | ||
| 799 | we must advance to the next element now. */ | ||
| 800 | d->optind++; | ||
| 801 | } | ||
| 802 | else if (d->optind == argc) | ||
| 803 | { | ||
| 804 | if (print_errors) | ||
| 805 | { | ||
| 806 | #if defined _LIBC && defined USE_IN_LIBIO | ||
| 807 | char *buf; | ||
| 808 | |||
| 809 | if (__asprintf (&buf, | ||
| 810 | _("%s: option requires an argument -- '%c'\n"), | ||
| 811 | argv[0], c) >= 0) | ||
| 812 | { | ||
| 813 | _IO_flockfile (stderr); | ||
| 814 | |||
| 815 | int old_flags2 = ((_IO_FILE *) stderr)->_flags2; | ||
| 816 | ((_IO_FILE *) stderr)->_flags2 |= _IO_FLAGS2_NOTCANCEL; | ||
| 817 | |||
| 818 | __fxprintf (NULL, "%s", buf); | ||
| 819 | |||
| 820 | ((_IO_FILE *) stderr)->_flags2 = old_flags2; | ||
| 821 | _IO_funlockfile (stderr); | ||
| 822 | |||
| 823 | free (buf); | ||
| 824 | } | ||
| 825 | #else | ||
| 826 | fprintf (stderr, | ||
| 827 | _("%s: option requires an argument -- '%c'\n"), | ||
| 828 | argv[0], c); | ||
| 829 | #endif | ||
| 830 | } | ||
| 831 | d->optopt = c; | ||
| 832 | if (optstring[0] == ':') | ||
| 833 | c = ':'; | ||
| 834 | else | ||
| 835 | c = '?'; | ||
| 836 | return c; | ||
| 837 | } | ||
| 838 | else | ||
| 839 | /* We already incremented `d->optind' once; | ||
| 840 | increment it again when taking next ARGV-elt as argument. */ | ||
| 841 | d->optarg = argv[d->optind++]; | ||
| 842 | |||
| 843 | /* optarg is now the argument, see if it's in the | ||
| 844 | table of longopts. */ | ||
| 845 | |||
| 846 | for (d->__nextchar = nameend = d->optarg; *nameend && *nameend != '='; | ||
| 847 | nameend++) | ||
| 848 | /* Do nothing. */ ; | ||
| 849 | |||
| 850 | /* Test all long options for either exact match | ||
| 851 | or abbreviated matches. */ | ||
| 852 | for (p = longopts, option_index = 0; p->name; p++, option_index++) | ||
| 853 | if (!strncmp (p->name, d->__nextchar, nameend - d->__nextchar)) | ||
| 854 | { | ||
| 855 | if ((unsigned int) (nameend - d->__nextchar) == strlen (p->name)) | ||
| 856 | { | ||
| 857 | /* Exact match found. */ | ||
| 858 | pfound = p; | ||
| 859 | indfound = option_index; | ||
| 860 | exact = 1; | ||
| 861 | break; | ||
| 862 | } | ||
| 863 | else if (pfound == NULL) | ||
| 864 | { | ||
| 865 | /* First nonexact match found. */ | ||
| 866 | pfound = p; | ||
| 867 | indfound = option_index; | ||
| 868 | } | ||
| 869 | else if (long_only | ||
| 870 | || pfound->has_arg != p->has_arg | ||
| 871 | || pfound->flag != p->flag | ||
| 872 | || pfound->val != p->val) | ||
| 873 | /* Second or later nonexact match found. */ | ||
| 874 | ambig = 1; | ||
| 875 | } | ||
| 876 | if (ambig && !exact) | ||
| 877 | { | ||
| 878 | if (print_errors) | ||
| 879 | { | ||
| 880 | #if defined _LIBC && defined USE_IN_LIBIO | ||
| 881 | char *buf; | ||
| 882 | |||
| 883 | if (__asprintf (&buf, _("%s: option '-W %s' is ambiguous\n"), | ||
| 884 | argv[0], d->optarg) >= 0) | ||
| 885 | { | ||
| 886 | _IO_flockfile (stderr); | ||
| 887 | |||
| 888 | int old_flags2 = ((_IO_FILE *) stderr)->_flags2; | ||
| 889 | ((_IO_FILE *) stderr)->_flags2 |= _IO_FLAGS2_NOTCANCEL; | ||
| 890 | |||
| 891 | __fxprintf (NULL, "%s", buf); | ||
| 892 | |||
| 893 | ((_IO_FILE *) stderr)->_flags2 = old_flags2; | ||
| 894 | _IO_funlockfile (stderr); | ||
| 895 | |||
| 896 | free (buf); | ||
| 897 | } | ||
| 898 | #else | ||
| 899 | fprintf (stderr, _("%s: option '-W %s' is ambiguous\n"), | ||
| 900 | argv[0], d->optarg); | ||
| 901 | #endif | ||
| 902 | } | ||
| 903 | d->__nextchar += strlen (d->__nextchar); | ||
| 904 | d->optind++; | ||
| 905 | return '?'; | ||
| 906 | } | ||
| 907 | if (pfound != NULL) | ||
| 908 | { | ||
| 909 | option_index = indfound; | ||
| 910 | if (*nameend) | ||
| 911 | { | ||
| 912 | /* Don't test has_arg with >, because some C compilers don't | ||
| 913 | allow it to be used on enums. */ | ||
| 914 | if (pfound->has_arg) | ||
| 915 | d->optarg = nameend + 1; | ||
| 916 | else | ||
| 917 | { | ||
| 918 | if (print_errors) | ||
| 919 | { | ||
| 920 | #if defined _LIBC && defined USE_IN_LIBIO | ||
| 921 | char *buf; | ||
| 922 | |||
| 923 | if (__asprintf (&buf, _("\ | ||
| 924 | %s: option '-W %s' doesn't allow an argument\n"), | ||
| 925 | argv[0], pfound->name) >= 0) | ||
| 926 | { | ||
| 927 | _IO_flockfile (stderr); | ||
| 928 | |||
| 929 | int old_flags2 = ((_IO_FILE *) stderr)->_flags2; | ||
| 930 | ((_IO_FILE *) stderr)->_flags2 | ||
| 931 | |= _IO_FLAGS2_NOTCANCEL; | ||
| 932 | |||
| 933 | __fxprintf (NULL, "%s", buf); | ||
| 934 | |||
| 935 | ((_IO_FILE *) stderr)->_flags2 = old_flags2; | ||
| 936 | _IO_funlockfile (stderr); | ||
| 937 | |||
| 938 | free (buf); | ||
| 939 | } | ||
| 940 | #else | ||
| 941 | fprintf (stderr, _("\ | ||
| 942 | %s: option '-W %s' doesn't allow an argument\n"), | ||
| 943 | argv[0], pfound->name); | ||
| 944 | #endif | ||
| 945 | } | ||
| 946 | |||
| 947 | d->__nextchar += strlen (d->__nextchar); | ||
| 948 | return '?'; | ||
| 949 | } | ||
| 950 | } | ||
| 951 | else if (pfound->has_arg == 1) | ||
| 952 | { | ||
| 953 | if (d->optind < argc) | ||
| 954 | d->optarg = argv[d->optind++]; | ||
| 955 | else | ||
| 956 | { | ||
| 957 | if (print_errors) | ||
| 958 | { | ||
| 959 | #if defined _LIBC && defined USE_IN_LIBIO | ||
| 960 | char *buf; | ||
| 961 | |||
| 962 | if (__asprintf (&buf, _("\ | ||
| 963 | %s: option '-W %s' requires an argument\n"), | ||
| 964 | argv[0], pfound->name) >= 0) | ||
| 965 | { | ||
| 966 | _IO_flockfile (stderr); | ||
| 967 | |||
| 968 | int old_flags2 = ((_IO_FILE *) stderr)->_flags2; | ||
| 969 | ((_IO_FILE *) stderr)->_flags2 | ||
| 970 | |= _IO_FLAGS2_NOTCANCEL; | ||
| 971 | |||
| 972 | __fxprintf (NULL, "%s", buf); | ||
| 973 | |||
| 974 | ((_IO_FILE *) stderr)->_flags2 = old_flags2; | ||
| 975 | _IO_funlockfile (stderr); | ||
| 976 | |||
| 977 | free (buf); | ||
| 978 | } | ||
| 979 | #else | ||
| 980 | fprintf (stderr, _("\ | ||
| 981 | %s: option '-W %s' requires an argument\n"), | ||
| 982 | argv[0], pfound->name); | ||
| 983 | #endif | ||
| 984 | } | ||
| 985 | d->__nextchar += strlen (d->__nextchar); | ||
| 986 | return optstring[0] == ':' ? ':' : '?'; | ||
| 987 | } | ||
| 988 | } | ||
| 989 | else | ||
| 990 | d->optarg = NULL; | ||
| 991 | d->__nextchar += strlen (d->__nextchar); | ||
| 992 | if (longind != NULL) | ||
| 993 | *longind = option_index; | ||
| 994 | if (pfound->flag) | ||
| 995 | { | ||
| 996 | *(pfound->flag) = pfound->val; | ||
| 997 | return 0; | ||
| 998 | } | ||
| 999 | return pfound->val; | ||
| 1000 | } | ||
| 1001 | d->__nextchar = NULL; | ||
| 1002 | return 'W'; /* Let the application handle it. */ | ||
| 1003 | } | ||
| 1004 | if (temp[1] == ':') | ||
| 1005 | { | ||
| 1006 | if (temp[2] == ':') | ||
| 1007 | { | ||
| 1008 | /* This is an option that accepts an argument optionally. */ | ||
| 1009 | if (*d->__nextchar != '\0') | ||
| 1010 | { | ||
| 1011 | d->optarg = d->__nextchar; | ||
| 1012 | d->optind++; | ||
| 1013 | } | ||
| 1014 | else | ||
| 1015 | d->optarg = NULL; | ||
| 1016 | d->__nextchar = NULL; | ||
| 1017 | } | ||
| 1018 | else | ||
| 1019 | { | ||
| 1020 | /* This is an option that requires an argument. */ | ||
| 1021 | if (*d->__nextchar != '\0') | ||
| 1022 | { | ||
| 1023 | d->optarg = d->__nextchar; | ||
| 1024 | /* If we end this ARGV-element by taking the rest as an arg, | ||
| 1025 | we must advance to the next element now. */ | ||
| 1026 | d->optind++; | ||
| 1027 | } | ||
| 1028 | else if (d->optind == argc) | ||
| 1029 | { | ||
| 1030 | if (print_errors) | ||
| 1031 | { | ||
| 1032 | #if defined _LIBC && defined USE_IN_LIBIO | ||
| 1033 | char *buf; | ||
| 1034 | |||
| 1035 | if (__asprintf (&buf, _("\ | ||
| 1036 | %s: option requires an argument -- '%c'\n"), | ||
| 1037 | argv[0], c) >= 0) | ||
| 1038 | { | ||
| 1039 | _IO_flockfile (stderr); | ||
| 1040 | |||
| 1041 | int old_flags2 = ((_IO_FILE *) stderr)->_flags2; | ||
| 1042 | ((_IO_FILE *) stderr)->_flags2 |= _IO_FLAGS2_NOTCANCEL; | ||
| 1043 | |||
| 1044 | __fxprintf (NULL, "%s", buf); | ||
| 1045 | |||
| 1046 | ((_IO_FILE *) stderr)->_flags2 = old_flags2; | ||
| 1047 | _IO_funlockfile (stderr); | ||
| 1048 | |||
| 1049 | free (buf); | ||
| 1050 | } | ||
| 1051 | #else | ||
| 1052 | fprintf (stderr, | ||
| 1053 | _("%s: option requires an argument -- '%c'\n"), | ||
| 1054 | argv[0], c); | ||
| 1055 | #endif | ||
| 1056 | } | ||
| 1057 | d->optopt = c; | ||
| 1058 | if (optstring[0] == ':') | ||
| 1059 | c = ':'; | ||
| 1060 | else | ||
| 1061 | c = '?'; | ||
| 1062 | } | ||
| 1063 | else | ||
| 1064 | /* We already incremented `optind' once; | ||
| 1065 | increment it again when taking next ARGV-elt as argument. */ | ||
| 1066 | d->optarg = argv[d->optind++]; | ||
| 1067 | d->__nextchar = NULL; | ||
| 1068 | } | ||
| 1069 | } | ||
| 1070 | return c; | ||
| 1071 | } | ||
| 1072 | } | ||
| 1073 | |||
| 1074 | int | ||
| 1075 | _getopt_internal (int argc, char **argv, const char *optstring, | ||
| 1076 | const struct option *longopts, int *longind, int long_only, | ||
| 1077 | int posixly_correct) | ||
| 1078 | { | ||
| 1079 | int result; | ||
| 1080 | |||
| 1081 | getopt_data.optind = optind; | ||
| 1082 | getopt_data.opterr = opterr; | ||
| 1083 | |||
| 1084 | result = _getopt_internal_r (argc, argv, optstring, longopts, | ||
| 1085 | longind, long_only, &getopt_data, | ||
| 1086 | posixly_correct); | ||
| 1087 | |||
| 1088 | optind = getopt_data.optind; | ||
| 1089 | optarg = getopt_data.optarg; | ||
| 1090 | optopt = getopt_data.optopt; | ||
| 1091 | |||
| 1092 | return result; | ||
| 1093 | } | ||
| 1094 | |||
| 1095 | /* glibc gets a LSB-compliant getopt. | ||
| 1096 | Standalone applications get a POSIX-compliant getopt. */ | ||
| 1097 | #if _LIBC | ||
| 1098 | enum { POSIXLY_CORRECT = 0 }; | ||
| 1099 | #else | ||
| 1100 | enum { POSIXLY_CORRECT = 1 }; | ||
| 1101 | #endif | ||
| 1102 | |||
| 1103 | int | ||
| 1104 | getopt (int argc, char *const *argv, const char *optstring) | ||
| 1105 | { | ||
| 1106 | return _getopt_internal (argc, (char **) argv, optstring, | ||
| 1107 | (const struct option *) 0, | ||
| 1108 | (int *) 0, | ||
| 1109 | 0, POSIXLY_CORRECT); | ||
| 1110 | } | ||
| 1111 | |||
| 1112 | #ifdef _LIBC | ||
| 1113 | int | ||
| 1114 | __posix_getopt (int argc, char *const *argv, const char *optstring) | ||
| 1115 | { | ||
| 1116 | return _getopt_internal (argc, argv, optstring, | ||
| 1117 | (const struct option *) 0, | ||
| 1118 | (int *) 0, | ||
| 1119 | 0, 1); | ||
| 1120 | } | ||
| 1121 | #endif | ||
| 1122 | |||
| 1123 | |||
| 1124 | #ifdef TEST | ||
| 1125 | |||
| 1126 | /* Compile with -DTEST to make an executable for use in testing | ||
| 1127 | the above definition of `getopt'. */ | ||
| 1128 | |||
| 1129 | int | ||
| 1130 | main (int argc, char **argv) | ||
| 1131 | { | ||
| 1132 | int c; | ||
| 1133 | int digit_optind = 0; | ||
| 1134 | |||
| 1135 | while (1) | ||
| 1136 | { | ||
| 1137 | int this_option_optind = optind ? optind : 1; | ||
| 1138 | |||
| 1139 | c = getopt (argc, argv, "abc:d:0123456789"); | ||
| 1140 | if (c == -1) | ||
| 1141 | break; | ||
| 1142 | |||
| 1143 | switch (c) | ||
| 1144 | { | ||
| 1145 | case '0': | ||
| 1146 | case '1': | ||
| 1147 | case '2': | ||
| 1148 | case '3': | ||
| 1149 | case '4': | ||
| 1150 | case '5': | ||
| 1151 | case '6': | ||
| 1152 | case '7': | ||
| 1153 | case '8': | ||
| 1154 | case '9': | ||
| 1155 | if (digit_optind != 0 && digit_optind != this_option_optind) | ||
| 1156 | printf ("digits occur in two different argv-elements.\n"); | ||
| 1157 | digit_optind = this_option_optind; | ||
| 1158 | printf ("option %c\n", c); | ||
| 1159 | break; | ||
| 1160 | |||
| 1161 | case 'a': | ||
| 1162 | printf ("option a\n"); | ||
| 1163 | break; | ||
| 1164 | |||
| 1165 | case 'b': | ||
| 1166 | printf ("option b\n"); | ||
| 1167 | break; | ||
| 1168 | |||
| 1169 | case 'c': | ||
| 1170 | printf ("option c with value '%s'\n", optarg); | ||
| 1171 | break; | ||
| 1172 | |||
| 1173 | case '?': | ||
| 1174 | break; | ||
| 1175 | |||
| 1176 | default: | ||
| 1177 | printf ("?? getopt returned character code 0%o ??\n", c); | ||
| 1178 | } | ||
| 1179 | } | ||
| 1180 | |||
| 1181 | if (optind < argc) | ||
| 1182 | { | ||
| 1183 | printf ("non-option ARGV-elements: "); | ||
| 1184 | while (optind < argc) | ||
| 1185 | printf ("%s ", argv[optind++]); | ||
| 1186 | printf ("\n"); | ||
| 1187 | } | ||
| 1188 | |||
| 1189 | exit (0); | ||
| 1190 | } | ||
| 1191 | |||
| 1192 | #endif /* TEST */ | ||
diff --git a/lib-src/getopt_.h b/lib/getopt.in.h index 7cccef3eeea..9b0a9a58bc9 100644 --- a/lib-src/getopt_.h +++ b/lib/getopt.in.h | |||
| @@ -1,40 +1,56 @@ | |||
| 1 | /* Declarations for getopt. | 1 | /* Declarations for getopt. |
| 2 | Copyright (C) 1989, 1990, 1991, 1992, 1993, 1994, 1996, 1997, 1998, 1999, | 2 | Copyright (C) 1989-1994, 1996-1999, 2001, 2003-2007, 2009-2011 Free Software |
| 3 | 2001, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc. | 3 | Foundation, Inc. |
| 4 | This file is part of the GNU C Library. | 4 | This file is part of the GNU C Library. |
| 5 | 5 | ||
| 6 | This program is free software; you can redistribute it and/or modify | 6 | This program is free software: you can redistribute it and/or modify |
| 7 | it under the terms of the GNU General Public License as published by | 7 | it under the terms of the GNU General Public License as published by |
| 8 | the Free Software Foundation; either version 3, or (at your option) | 8 | the Free Software Foundation; either version 3 of the License, or |
| 9 | any later version. | 9 | (at your option) any later version. |
| 10 | 10 | ||
| 11 | This program is distributed in the hope that it will be useful, | 11 | This program is distributed in the hope that it will be useful, |
| 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | GNU General Public License for more details. | 14 | GNU General Public License for more details. |
| 15 | 15 | ||
| 16 | You should have received a copy of the GNU General Public License along | 16 | You should have received a copy of the GNU General Public License |
| 17 | with this program; if not, write to the Free Software Foundation, | 17 | along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
| 18 | Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ | ||
| 19 | 18 | ||
| 20 | #ifndef _GETOPT_H | 19 | #ifndef _GL_GETOPT_H |
| 20 | |||
| 21 | #if __GNUC__ >= 3 | ||
| 22 | @PRAGMA_SYSTEM_HEADER@ | ||
| 23 | #endif | ||
| 24 | @PRAGMA_COLUMNS@ | ||
| 25 | |||
| 26 | /* The include_next requires a split double-inclusion guard. We must | ||
| 27 | also inform the replacement unistd.h to not recursively use | ||
| 28 | <getopt.h>; our definitions will be present soon enough. */ | ||
| 29 | #if @HAVE_GETOPT_H@ | ||
| 30 | # define _GL_SYSTEM_GETOPT | ||
| 31 | # @INCLUDE_NEXT@ @NEXT_GETOPT_H@ | ||
| 32 | # undef _GL_SYSTEM_GETOPT | ||
| 33 | #endif | ||
| 34 | |||
| 35 | #ifndef _GL_GETOPT_H | ||
| 21 | 36 | ||
| 22 | #ifndef __need_getopt | 37 | #ifndef __need_getopt |
| 23 | # define _GETOPT_H 1 | 38 | # define _GL_GETOPT_H 1 |
| 24 | #endif | 39 | #endif |
| 25 | 40 | ||
| 26 | /* Standalone applications should #define __GETOPT_PREFIX to an | 41 | /* Standalone applications should #define __GETOPT_PREFIX to an |
| 27 | identifier that prefixes the external functions and variables | 42 | identifier that prefixes the external functions and variables |
| 28 | defined in this header. When this happens, include the | 43 | defined in this header. When this happens, include the |
| 29 | headers that might declare getopt so that they will not cause | 44 | headers that might declare getopt so that they will not cause |
| 30 | confusion if included after this file. Then systematically rename | 45 | confusion if included after this file (if the system had <getopt.h>, |
| 46 | we have already included it). Then systematically rename | ||
| 31 | identifiers so that they do not collide with the system functions | 47 | identifiers so that they do not collide with the system functions |
| 32 | and variables. Renaming avoids problems with some compilers and | 48 | and variables. Renaming avoids problems with some compilers and |
| 33 | linkers. */ | 49 | linkers. */ |
| 34 | #if defined __GETOPT_PREFIX && !defined __need_getopt | 50 | #if defined __GETOPT_PREFIX && !defined __need_getopt |
| 35 | # include <stdlib.h> | 51 | # if !@HAVE_GETOPT_H@ |
| 36 | # include <stdio.h> | 52 | # include <stdlib.h> |
| 37 | # if HAVE_UNISTD_H | 53 | # include <stdio.h> |
| 38 | # include <unistd.h> | 54 | # include <unistd.h> |
| 39 | # endif | 55 | # endif |
| 40 | # undef __need_getopt | 56 | # undef __need_getopt |
| @@ -45,6 +61,7 @@ | |||
| 45 | # undef opterr | 61 | # undef opterr |
| 46 | # undef optind | 62 | # undef optind |
| 47 | # undef optopt | 63 | # undef optopt |
| 64 | # undef option | ||
| 48 | # define __GETOPT_CONCAT(x, y) x ## y | 65 | # define __GETOPT_CONCAT(x, y) x ## y |
| 49 | # define __GETOPT_XCONCAT(x, y) __GETOPT_CONCAT (x, y) | 66 | # define __GETOPT_XCONCAT(x, y) __GETOPT_CONCAT (x, y) |
| 50 | # define __GETOPT_ID(y) __GETOPT_XCONCAT (__GETOPT_PREFIX, y) | 67 | # define __GETOPT_ID(y) __GETOPT_XCONCAT (__GETOPT_PREFIX, y) |
| @@ -55,6 +72,8 @@ | |||
| 55 | # define opterr __GETOPT_ID (opterr) | 72 | # define opterr __GETOPT_ID (opterr) |
| 56 | # define optind __GETOPT_ID (optind) | 73 | # define optind __GETOPT_ID (optind) |
| 57 | # define optopt __GETOPT_ID (optopt) | 74 | # define optopt __GETOPT_ID (optopt) |
| 75 | # define option __GETOPT_ID (option) | ||
| 76 | # define _getopt_internal __GETOPT_ID (getopt_internal) | ||
| 58 | #endif | 77 | #endif |
| 59 | 78 | ||
| 60 | /* Standalone applications get correct prototypes for getopt_long and | 79 | /* Standalone applications get correct prototypes for getopt_long and |
| @@ -97,13 +116,15 @@ | |||
| 97 | # define __GNUC_PREREQ(maj, min) (0) | 116 | # define __GNUC_PREREQ(maj, min) (0) |
| 98 | # endif | 117 | # endif |
| 99 | # if defined __cplusplus && __GNUC_PREREQ (2,8) | 118 | # if defined __cplusplus && __GNUC_PREREQ (2,8) |
| 100 | # define __THROW throw () | 119 | # define __THROW throw () |
| 101 | # else | 120 | # else |
| 102 | # define __THROW | 121 | # define __THROW |
| 103 | # endif | 122 | # endif |
| 104 | #endif | 123 | #endif |
| 105 | 124 | ||
| 106 | #ifdef __cplusplus | 125 | /* The definition of _GL_ARG_NONNULL is copied here. */ |
| 126 | |||
| 127 | #ifdef __cplusplus | ||
| 107 | extern "C" { | 128 | extern "C" { |
| 108 | #endif | 129 | #endif |
| 109 | 130 | ||
| @@ -145,9 +166,9 @@ extern int optopt; | |||
| 145 | zero. | 166 | zero. |
| 146 | 167 | ||
| 147 | The field `has_arg' is: | 168 | The field `has_arg' is: |
| 148 | no_argument (or 0) if the option does not take an argument, | 169 | no_argument (or 0) if the option does not take an argument, |
| 149 | required_argument (or 1) if the option requires an argument, | 170 | required_argument (or 1) if the option requires an argument, |
| 150 | optional_argument (or 2) if the option takes an optional argument. | 171 | optional_argument (or 2) if the option takes an optional argument. |
| 151 | 172 | ||
| 152 | If the field `flag' is not NULL, it points to a variable that is set | 173 | If the field `flag' is not NULL, it points to a variable that is set |
| 153 | to the value given in the field `val' when the option is found, but | 174 | to the value given in the field `val' when the option is found, but |
| @@ -172,10 +193,10 @@ struct option | |||
| 172 | 193 | ||
| 173 | /* Names for the values of the `has_arg' field of `struct option'. */ | 194 | /* Names for the values of the `has_arg' field of `struct option'. */ |
| 174 | 195 | ||
| 175 | # define no_argument 0 | 196 | # define no_argument 0 |
| 176 | # define required_argument 1 | 197 | # define required_argument 1 |
| 177 | # define optional_argument 2 | 198 | # define optional_argument 2 |
| 178 | #endif /* need getopt */ | 199 | #endif /* need getopt */ |
| 179 | 200 | ||
| 180 | 201 | ||
| 181 | /* Get definitions and prototypes for functions to process the | 202 | /* Get definitions and prototypes for functions to process the |
| @@ -198,26 +219,27 @@ struct option | |||
| 198 | scanning, explicitly telling `getopt' that there are no more | 219 | scanning, explicitly telling `getopt' that there are no more |
| 199 | options. | 220 | options. |
| 200 | 221 | ||
| 201 | If OPTS begins with `--', then non-option arguments are treated as | 222 | If OPTS begins with `-', then non-option arguments are treated as |
| 202 | arguments to the option '\0'. This behavior is specific to the GNU | 223 | arguments to the option '\1'. This behavior is specific to the GNU |
| 203 | `getopt'. */ | 224 | `getopt'. If OPTS begins with `+', or POSIXLY_CORRECT is set in |
| 225 | the environment, then do not permute arguments. */ | ||
| 204 | 226 | ||
| 205 | extern int getopt (int ___argc, char *const *___argv, const char *__shortopts) | 227 | extern int getopt (int ___argc, char *const *___argv, const char *__shortopts) |
| 206 | __THROW; | 228 | __THROW _GL_ARG_NONNULL ((2, 3)); |
| 207 | 229 | ||
| 208 | #ifndef __need_getopt | 230 | #ifndef __need_getopt |
| 209 | extern int getopt_long (int ___argc, char *__getopt_argv_const *___argv, | 231 | extern int getopt_long (int ___argc, char *__getopt_argv_const *___argv, |
| 210 | const char *__shortopts, | 232 | const char *__shortopts, |
| 211 | const struct option *__longopts, int *__longind) | 233 | const struct option *__longopts, int *__longind) |
| 212 | __THROW; | 234 | __THROW _GL_ARG_NONNULL ((2, 3)); |
| 213 | extern int getopt_long_only (int ___argc, char *__getopt_argv_const *___argv, | 235 | extern int getopt_long_only (int ___argc, char *__getopt_argv_const *___argv, |
| 214 | const char *__shortopts, | 236 | const char *__shortopts, |
| 215 | const struct option *__longopts, int *__longind) | 237 | const struct option *__longopts, int *__longind) |
| 216 | __THROW; | 238 | __THROW _GL_ARG_NONNULL ((2, 3)); |
| 217 | 239 | ||
| 218 | #endif | 240 | #endif |
| 219 | 241 | ||
| 220 | #ifdef __cplusplus | 242 | #ifdef __cplusplus |
| 221 | } | 243 | } |
| 222 | #endif | 244 | #endif |
| 223 | 245 | ||
| @@ -225,6 +247,4 @@ extern int getopt_long_only (int ___argc, char *__getopt_argv_const *___argv, | |||
| 225 | #undef __need_getopt | 247 | #undef __need_getopt |
| 226 | 248 | ||
| 227 | #endif /* getopt.h */ | 249 | #endif /* getopt.h */ |
| 228 | 250 | #endif /* getopt.h */ | |
| 229 | /* arch-tag: e36f5607-3ac6-4cdc-9aa7-c26c6525fe9b | ||
| 230 | (do not change this comment) */ | ||
diff --git a/lib/getopt1.c b/lib/getopt1.c new file mode 100644 index 00000000000..36568024cc2 --- /dev/null +++ b/lib/getopt1.c | |||
| @@ -0,0 +1,170 @@ | |||
| 1 | /* getopt_long and getopt_long_only entry points for GNU getopt. | ||
| 2 | Copyright (C) 1987-1994, 1996-1998, 2004, 2006, 2009-2011 Free Software | ||
| 3 | Foundation, Inc. | ||
| 4 | This file is part of the GNU C Library. | ||
| 5 | |||
| 6 | This program is free software: you can redistribute it and/or modify | ||
| 7 | it under the terms of the GNU General Public License as published by | ||
| 8 | the Free Software Foundation; either version 3 of the License, or | ||
| 9 | (at your option) any later version. | ||
| 10 | |||
| 11 | This program is distributed in the hope that it will be useful, | ||
| 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 14 | GNU General Public License for more details. | ||
| 15 | |||
| 16 | You should have received a copy of the GNU General Public License | ||
| 17 | along with this program. If not, see <http://www.gnu.org/licenses/>. */ | ||
| 18 | |||
| 19 | #ifdef _LIBC | ||
| 20 | # include <getopt.h> | ||
| 21 | #else | ||
| 22 | # include <config.h> | ||
| 23 | # include "getopt.h" | ||
| 24 | #endif | ||
| 25 | #include "getopt_int.h" | ||
| 26 | |||
| 27 | #include <stdio.h> | ||
| 28 | |||
| 29 | /* This needs to come after some library #include | ||
| 30 | to get __GNU_LIBRARY__ defined. */ | ||
| 31 | #ifdef __GNU_LIBRARY__ | ||
| 32 | #include <stdlib.h> | ||
| 33 | #endif | ||
| 34 | |||
| 35 | #ifndef NULL | ||
| 36 | #define NULL 0 | ||
| 37 | #endif | ||
| 38 | |||
| 39 | int | ||
| 40 | getopt_long (int argc, char *__getopt_argv_const *argv, const char *options, | ||
| 41 | const struct option *long_options, int *opt_index) | ||
| 42 | { | ||
| 43 | return _getopt_internal (argc, (char **) argv, options, long_options, | ||
| 44 | opt_index, 0, 0); | ||
| 45 | } | ||
| 46 | |||
| 47 | int | ||
| 48 | _getopt_long_r (int argc, char **argv, const char *options, | ||
| 49 | const struct option *long_options, int *opt_index, | ||
| 50 | struct _getopt_data *d) | ||
| 51 | { | ||
| 52 | return _getopt_internal_r (argc, argv, options, long_options, opt_index, | ||
| 53 | 0, d, 0); | ||
| 54 | } | ||
| 55 | |||
| 56 | /* Like getopt_long, but '-' as well as '--' can indicate a long option. | ||
| 57 | If an option that starts with '-' (not '--') doesn't match a long option, | ||
| 58 | but does match a short option, it is parsed as a short option | ||
| 59 | instead. */ | ||
| 60 | |||
| 61 | int | ||
| 62 | getopt_long_only (int argc, char *__getopt_argv_const *argv, | ||
| 63 | const char *options, | ||
| 64 | const struct option *long_options, int *opt_index) | ||
| 65 | { | ||
| 66 | return _getopt_internal (argc, (char **) argv, options, long_options, | ||
| 67 | opt_index, 1, 0); | ||
| 68 | } | ||
| 69 | |||
| 70 | int | ||
| 71 | _getopt_long_only_r (int argc, char **argv, const char *options, | ||
| 72 | const struct option *long_options, int *opt_index, | ||
| 73 | struct _getopt_data *d) | ||
| 74 | { | ||
| 75 | return _getopt_internal_r (argc, argv, options, long_options, opt_index, | ||
| 76 | 1, d, 0); | ||
| 77 | } | ||
| 78 | |||
| 79 | |||
| 80 | #ifdef TEST | ||
| 81 | |||
| 82 | #include <stdio.h> | ||
| 83 | |||
| 84 | int | ||
| 85 | main (int argc, char **argv) | ||
| 86 | { | ||
| 87 | int c; | ||
| 88 | int digit_optind = 0; | ||
| 89 | |||
| 90 | while (1) | ||
| 91 | { | ||
| 92 | int this_option_optind = optind ? optind : 1; | ||
| 93 | int option_index = 0; | ||
| 94 | static const struct option long_options[] = | ||
| 95 | { | ||
| 96 | {"add", 1, 0, 0}, | ||
| 97 | {"append", 0, 0, 0}, | ||
| 98 | {"delete", 1, 0, 0}, | ||
| 99 | {"verbose", 0, 0, 0}, | ||
| 100 | {"create", 0, 0, 0}, | ||
| 101 | {"file", 1, 0, 0}, | ||
| 102 | {0, 0, 0, 0} | ||
| 103 | }; | ||
| 104 | |||
| 105 | c = getopt_long (argc, argv, "abc:d:0123456789", | ||
| 106 | long_options, &option_index); | ||
| 107 | if (c == -1) | ||
| 108 | break; | ||
| 109 | |||
| 110 | switch (c) | ||
| 111 | { | ||
| 112 | case 0: | ||
| 113 | printf ("option %s", long_options[option_index].name); | ||
| 114 | if (optarg) | ||
| 115 | printf (" with arg %s", optarg); | ||
| 116 | printf ("\n"); | ||
| 117 | break; | ||
| 118 | |||
| 119 | case '0': | ||
| 120 | case '1': | ||
| 121 | case '2': | ||
| 122 | case '3': | ||
| 123 | case '4': | ||
| 124 | case '5': | ||
| 125 | case '6': | ||
| 126 | case '7': | ||
| 127 | case '8': | ||
| 128 | case '9': | ||
| 129 | if (digit_optind != 0 && digit_optind != this_option_optind) | ||
| 130 | printf ("digits occur in two different argv-elements.\n"); | ||
| 131 | digit_optind = this_option_optind; | ||
| 132 | printf ("option %c\n", c); | ||
| 133 | break; | ||
| 134 | |||
| 135 | case 'a': | ||
| 136 | printf ("option a\n"); | ||
| 137 | break; | ||
| 138 | |||
| 139 | case 'b': | ||
| 140 | printf ("option b\n"); | ||
| 141 | break; | ||
| 142 | |||
| 143 | case 'c': | ||
| 144 | printf ("option c with value `%s'\n", optarg); | ||
| 145 | break; | ||
| 146 | |||
| 147 | case 'd': | ||
| 148 | printf ("option d with value `%s'\n", optarg); | ||
| 149 | break; | ||
| 150 | |||
| 151 | case '?': | ||
| 152 | break; | ||
| 153 | |||
| 154 | default: | ||
| 155 | printf ("?? getopt returned character code 0%o ??\n", c); | ||
| 156 | } | ||
| 157 | } | ||
| 158 | |||
| 159 | if (optind < argc) | ||
| 160 | { | ||
| 161 | printf ("non-option ARGV-elements: "); | ||
| 162 | while (optind < argc) | ||
| 163 | printf ("%s ", argv[optind++]); | ||
| 164 | printf ("\n"); | ||
| 165 | } | ||
| 166 | |||
| 167 | exit (0); | ||
| 168 | } | ||
| 169 | |||
| 170 | #endif /* TEST */ | ||
diff --git a/lib/getopt_int.h b/lib/getopt_int.h new file mode 100644 index 00000000000..7a01a6aa422 --- /dev/null +++ b/lib/getopt_int.h | |||
| @@ -0,0 +1,135 @@ | |||
| 1 | /* Internal declarations for getopt. | ||
| 2 | Copyright (C) 1989-1994, 1996-1999, 2001, 2003-2004, 2009-2011 Free Software | ||
| 3 | Foundation, Inc. | ||
| 4 | This file is part of the GNU C Library. | ||
| 5 | |||
| 6 | This program is free software: you can redistribute it and/or modify | ||
| 7 | it under the terms of the GNU General Public License as published by | ||
| 8 | the Free Software Foundation; either version 3 of the License, or | ||
| 9 | (at your option) any later version. | ||
| 10 | |||
| 11 | This program is distributed in the hope that it will be useful, | ||
| 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 14 | GNU General Public License for more details. | ||
| 15 | |||
| 16 | You should have received a copy of the GNU General Public License | ||
| 17 | along with this program. If not, see <http://www.gnu.org/licenses/>. */ | ||
| 18 | |||
| 19 | #ifndef _GETOPT_INT_H | ||
| 20 | #define _GETOPT_INT_H 1 | ||
| 21 | |||
| 22 | #include <getopt.h> | ||
| 23 | |||
| 24 | extern int _getopt_internal (int ___argc, char **___argv, | ||
| 25 | const char *__shortopts, | ||
| 26 | const struct option *__longopts, int *__longind, | ||
| 27 | int __long_only, int __posixly_correct); | ||
| 28 | |||
| 29 | |||
| 30 | /* Reentrant versions which can handle parsing multiple argument | ||
| 31 | vectors at the same time. */ | ||
| 32 | |||
| 33 | /* Describe how to deal with options that follow non-option ARGV-elements. | ||
| 34 | |||
| 35 | If the caller did not specify anything, | ||
| 36 | the default is REQUIRE_ORDER if the environment variable | ||
| 37 | POSIXLY_CORRECT is defined, PERMUTE otherwise. | ||
| 38 | |||
| 39 | REQUIRE_ORDER means don't recognize them as options; | ||
| 40 | stop option processing when the first non-option is seen. | ||
| 41 | This is what Unix does. | ||
| 42 | This mode of operation is selected by either setting the environment | ||
| 43 | variable POSIXLY_CORRECT, or using `+' as the first character | ||
| 44 | of the list of option characters, or by calling getopt. | ||
| 45 | |||
| 46 | PERMUTE is the default. We permute the contents of ARGV as we | ||
| 47 | scan, so that eventually all the non-options are at the end. | ||
| 48 | This allows options to be given in any order, even with programs | ||
| 49 | that were not written to expect this. | ||
| 50 | |||
| 51 | RETURN_IN_ORDER is an option available to programs that were | ||
| 52 | written to expect options and other ARGV-elements in any order | ||
| 53 | and that care about the ordering of the two. We describe each | ||
| 54 | non-option ARGV-element as if it were the argument of an option | ||
| 55 | with character code 1. Using `-' as the first character of the | ||
| 56 | list of option characters selects this mode of operation. | ||
| 57 | |||
| 58 | The special argument `--' forces an end of option-scanning regardless | ||
| 59 | of the value of `ordering'. In the case of RETURN_IN_ORDER, only | ||
| 60 | `--' can cause `getopt' to return -1 with `optind' != ARGC. */ | ||
| 61 | |||
| 62 | enum __ord | ||
| 63 | { | ||
| 64 | REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER | ||
| 65 | }; | ||
| 66 | |||
| 67 | /* Data type for reentrant functions. */ | ||
| 68 | struct _getopt_data | ||
| 69 | { | ||
| 70 | /* These have exactly the same meaning as the corresponding global | ||
| 71 | variables, except that they are used for the reentrant | ||
| 72 | versions of getopt. */ | ||
| 73 | int optind; | ||
| 74 | int opterr; | ||
| 75 | int optopt; | ||
| 76 | char *optarg; | ||
| 77 | |||
| 78 | /* Internal members. */ | ||
| 79 | |||
| 80 | /* True if the internal members have been initialized. */ | ||
| 81 | int __initialized; | ||
| 82 | |||
| 83 | /* The next char to be scanned in the option-element | ||
| 84 | in which the last option character we returned was found. | ||
| 85 | This allows us to pick up the scan where we left off. | ||
| 86 | |||
| 87 | If this is zero, or a null string, it means resume the scan | ||
| 88 | by advancing to the next ARGV-element. */ | ||
| 89 | char *__nextchar; | ||
| 90 | |||
| 91 | /* See __ord above. */ | ||
| 92 | enum __ord __ordering; | ||
| 93 | |||
| 94 | /* If the POSIXLY_CORRECT environment variable is set | ||
| 95 | or getopt was called. */ | ||
| 96 | int __posixly_correct; | ||
| 97 | |||
| 98 | |||
| 99 | /* Handle permutation of arguments. */ | ||
| 100 | |||
| 101 | /* Describe the part of ARGV that contains non-options that have | ||
| 102 | been skipped. `first_nonopt' is the index in ARGV of the first | ||
| 103 | of them; `last_nonopt' is the index after the last of them. */ | ||
| 104 | |||
| 105 | int __first_nonopt; | ||
| 106 | int __last_nonopt; | ||
| 107 | |||
| 108 | #if defined _LIBC && defined USE_NONOPTION_FLAGS | ||
| 109 | int __nonoption_flags_max_len; | ||
| 110 | int __nonoption_flags_len; | ||
| 111 | # endif | ||
| 112 | }; | ||
| 113 | |||
| 114 | /* The initializer is necessary to set OPTIND and OPTERR to their | ||
| 115 | default values and to clear the initialization flag. */ | ||
| 116 | #define _GETOPT_DATA_INITIALIZER { 1, 1 } | ||
| 117 | |||
| 118 | extern int _getopt_internal_r (int ___argc, char **___argv, | ||
| 119 | const char *__shortopts, | ||
| 120 | const struct option *__longopts, int *__longind, | ||
| 121 | int __long_only, struct _getopt_data *__data, | ||
| 122 | int __posixly_correct); | ||
| 123 | |||
| 124 | extern int _getopt_long_r (int ___argc, char **___argv, | ||
| 125 | const char *__shortopts, | ||
| 126 | const struct option *__longopts, int *__longind, | ||
| 127 | struct _getopt_data *__data); | ||
| 128 | |||
| 129 | extern int _getopt_long_only_r (int ___argc, char **___argv, | ||
| 130 | const char *__shortopts, | ||
| 131 | const struct option *__longopts, | ||
| 132 | int *__longind, | ||
| 133 | struct _getopt_data *__data); | ||
| 134 | |||
| 135 | #endif /* getopt_int.h */ | ||
diff --git a/lib/gettext.h b/lib/gettext.h new file mode 100644 index 00000000000..eb74aecb9a8 --- /dev/null +++ b/lib/gettext.h | |||
| @@ -0,0 +1,280 @@ | |||
| 1 | /* Convenience header for conditional use of GNU <libintl.h>. | ||
| 2 | Copyright (C) 1995-1998, 2000-2002, 2004-2006, 2009-2011 Free Software | ||
| 3 | Foundation, Inc. | ||
| 4 | |||
| 5 | This program is free software; you can redistribute it and/or modify | ||
| 6 | it under the terms of the GNU General Public License as published by | ||
| 7 | the Free Software Foundation; either version 3, or (at your option) | ||
| 8 | any later version. | ||
| 9 | |||
| 10 | This program is distributed in the hope that it will be useful, | ||
| 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 13 | GNU General Public License for more details. | ||
| 14 | |||
| 15 | You should have received a copy of the GNU General Public License along | ||
| 16 | with this program; if not, write to the Free Software Foundation, | ||
| 17 | Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ | ||
| 18 | |||
| 19 | #ifndef _LIBGETTEXT_H | ||
| 20 | #define _LIBGETTEXT_H 1 | ||
| 21 | |||
| 22 | /* NLS can be disabled through the configure --disable-nls option. */ | ||
| 23 | #if ENABLE_NLS | ||
| 24 | |||
| 25 | /* Get declarations of GNU message catalog functions. */ | ||
| 26 | # include <libintl.h> | ||
| 27 | |||
| 28 | /* You can set the DEFAULT_TEXT_DOMAIN macro to specify the domain used by | ||
| 29 | the gettext() and ngettext() macros. This is an alternative to calling | ||
| 30 | textdomain(), and is useful for libraries. */ | ||
| 31 | # ifdef DEFAULT_TEXT_DOMAIN | ||
| 32 | # undef gettext | ||
| 33 | # define gettext(Msgid) \ | ||
| 34 | dgettext (DEFAULT_TEXT_DOMAIN, Msgid) | ||
| 35 | # undef ngettext | ||
| 36 | # define ngettext(Msgid1, Msgid2, N) \ | ||
| 37 | dngettext (DEFAULT_TEXT_DOMAIN, Msgid1, Msgid2, N) | ||
| 38 | # endif | ||
| 39 | |||
| 40 | #else | ||
| 41 | |||
| 42 | /* Solaris /usr/include/locale.h includes /usr/include/libintl.h, which | ||
| 43 | chokes if dcgettext is defined as a macro. So include it now, to make | ||
| 44 | later inclusions of <locale.h> a NOP. We don't include <libintl.h> | ||
| 45 | as well because people using "gettext.h" will not include <libintl.h>, | ||
| 46 | and also including <libintl.h> would fail on SunOS 4, whereas <locale.h> | ||
| 47 | is OK. */ | ||
| 48 | #if defined(__sun) | ||
| 49 | # include <locale.h> | ||
| 50 | #endif | ||
| 51 | |||
| 52 | /* Many header files from the libstdc++ coming with g++ 3.3 or newer include | ||
| 53 | <libintl.h>, which chokes if dcgettext is defined as a macro. So include | ||
| 54 | it now, to make later inclusions of <libintl.h> a NOP. */ | ||
| 55 | #if defined(__cplusplus) && defined(__GNUG__) && (__GNUC__ >= 3) | ||
| 56 | # include <cstdlib> | ||
| 57 | # if (__GLIBC__ >= 2 && !defined __UCLIBC__) || _GLIBCXX_HAVE_LIBINTL_H | ||
| 58 | # include <libintl.h> | ||
| 59 | # endif | ||
| 60 | #endif | ||
| 61 | |||
| 62 | /* Disabled NLS. | ||
| 63 | The casts to 'const char *' serve the purpose of producing warnings | ||
| 64 | for invalid uses of the value returned from these functions. | ||
| 65 | On pre-ANSI systems without 'const', the config.h file is supposed to | ||
| 66 | contain "#define const". */ | ||
| 67 | # undef gettext | ||
| 68 | # define gettext(Msgid) ((const char *) (Msgid)) | ||
| 69 | # undef dgettext | ||
| 70 | # define dgettext(Domainname, Msgid) ((void) (Domainname), gettext (Msgid)) | ||
| 71 | # undef dcgettext | ||
| 72 | # define dcgettext(Domainname, Msgid, Category) \ | ||
| 73 | ((void) (Category), dgettext (Domainname, Msgid)) | ||
| 74 | # undef ngettext | ||
| 75 | # define ngettext(Msgid1, Msgid2, N) \ | ||
| 76 | ((N) == 1 \ | ||
| 77 | ? ((void) (Msgid2), (const char *) (Msgid1)) \ | ||
| 78 | : ((void) (Msgid1), (const char *) (Msgid2))) | ||
| 79 | # undef dngettext | ||
| 80 | # define dngettext(Domainname, Msgid1, Msgid2, N) \ | ||
| 81 | ((void) (Domainname), ngettext (Msgid1, Msgid2, N)) | ||
| 82 | # undef dcngettext | ||
| 83 | # define dcngettext(Domainname, Msgid1, Msgid2, N, Category) \ | ||
| 84 | ((void) (Category), dngettext (Domainname, Msgid1, Msgid2, N)) | ||
| 85 | # undef textdomain | ||
| 86 | # define textdomain(Domainname) ((const char *) (Domainname)) | ||
| 87 | # undef bindtextdomain | ||
| 88 | # define bindtextdomain(Domainname, Dirname) \ | ||
| 89 | ((void) (Domainname), (const char *) (Dirname)) | ||
| 90 | # undef bind_textdomain_codeset | ||
| 91 | # define bind_textdomain_codeset(Domainname, Codeset) \ | ||
| 92 | ((void) (Domainname), (const char *) (Codeset)) | ||
| 93 | |||
| 94 | #endif | ||
| 95 | |||
| 96 | /* A pseudo function call that serves as a marker for the automated | ||
| 97 | extraction of messages, but does not call gettext(). The run-time | ||
| 98 | translation is done at a different place in the code. | ||
| 99 | The argument, String, should be a literal string. Concatenated strings | ||
| 100 | and other string expressions won't work. | ||
| 101 | The macro's expansion is not parenthesized, so that it is suitable as | ||
| 102 | initializer for static 'char[]' or 'const char[]' variables. */ | ||
| 103 | #define gettext_noop(String) String | ||
| 104 | |||
| 105 | /* The separator between msgctxt and msgid in a .mo file. */ | ||
| 106 | #define GETTEXT_CONTEXT_GLUE "\004" | ||
| 107 | |||
| 108 | /* Pseudo function calls, taking a MSGCTXT and a MSGID instead of just a | ||
| 109 | MSGID. MSGCTXT and MSGID must be string literals. MSGCTXT should be | ||
| 110 | short and rarely need to change. | ||
| 111 | The letter 'p' stands for 'particular' or 'special'. */ | ||
| 112 | #ifdef DEFAULT_TEXT_DOMAIN | ||
| 113 | # define pgettext(Msgctxt, Msgid) \ | ||
| 114 | pgettext_aux (DEFAULT_TEXT_DOMAIN, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, LC_MESSAGES) | ||
| 115 | #else | ||
| 116 | # define pgettext(Msgctxt, Msgid) \ | ||
| 117 | pgettext_aux (NULL, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, LC_MESSAGES) | ||
| 118 | #endif | ||
| 119 | #define dpgettext(Domainname, Msgctxt, Msgid) \ | ||
| 120 | pgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, LC_MESSAGES) | ||
| 121 | #define dcpgettext(Domainname, Msgctxt, Msgid, Category) \ | ||
| 122 | pgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, Category) | ||
| 123 | #ifdef DEFAULT_TEXT_DOMAIN | ||
| 124 | # define npgettext(Msgctxt, Msgid, MsgidPlural, N) \ | ||
| 125 | npgettext_aux (DEFAULT_TEXT_DOMAIN, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, LC_MESSAGES) | ||
| 126 | #else | ||
| 127 | # define npgettext(Msgctxt, Msgid, MsgidPlural, N) \ | ||
| 128 | npgettext_aux (NULL, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, LC_MESSAGES) | ||
| 129 | #endif | ||
| 130 | #define dnpgettext(Domainname, Msgctxt, Msgid, MsgidPlural, N) \ | ||
| 131 | npgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, LC_MESSAGES) | ||
| 132 | #define dcnpgettext(Domainname, Msgctxt, Msgid, MsgidPlural, N, Category) \ | ||
| 133 | npgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, Category) | ||
| 134 | |||
| 135 | #ifdef __GNUC__ | ||
| 136 | __inline | ||
| 137 | #else | ||
| 138 | #ifdef __cplusplus | ||
| 139 | inline | ||
| 140 | #endif | ||
| 141 | #endif | ||
| 142 | static const char * | ||
| 143 | pgettext_aux (const char *domain, | ||
| 144 | const char *msg_ctxt_id, const char *msgid, | ||
| 145 | int category) | ||
| 146 | { | ||
| 147 | const char *translation = dcgettext (domain, msg_ctxt_id, category); | ||
| 148 | if (translation == msg_ctxt_id) | ||
| 149 | return msgid; | ||
| 150 | else | ||
| 151 | return translation; | ||
| 152 | } | ||
| 153 | |||
| 154 | #ifdef __GNUC__ | ||
| 155 | __inline | ||
| 156 | #else | ||
| 157 | #ifdef __cplusplus | ||
| 158 | inline | ||
| 159 | #endif | ||
| 160 | #endif | ||
| 161 | static const char * | ||
| 162 | npgettext_aux (const char *domain, | ||
| 163 | const char *msg_ctxt_id, const char *msgid, | ||
| 164 | const char *msgid_plural, unsigned long int n, | ||
| 165 | int category) | ||
| 166 | { | ||
| 167 | const char *translation = | ||
| 168 | dcngettext (domain, msg_ctxt_id, msgid_plural, n, category); | ||
| 169 | if (translation == msg_ctxt_id || translation == msgid_plural) | ||
| 170 | return (n == 1 ? msgid : msgid_plural); | ||
| 171 | else | ||
| 172 | return translation; | ||
| 173 | } | ||
| 174 | |||
| 175 | /* The same thing extended for non-constant arguments. Here MSGCTXT and MSGID | ||
| 176 | can be arbitrary expressions. But for string literals these macros are | ||
| 177 | less efficient than those above. */ | ||
| 178 | |||
| 179 | #include <string.h> | ||
| 180 | |||
| 181 | #define _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS \ | ||
| 182 | (((__GNUC__ >= 3 || __GNUG__ >= 2) && !__STRICT_ANSI__) \ | ||
| 183 | /* || __STDC_VERSION__ >= 199901L */ ) | ||
| 184 | |||
| 185 | #if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS | ||
| 186 | #include <stdlib.h> | ||
| 187 | #endif | ||
| 188 | |||
| 189 | #define pgettext_expr(Msgctxt, Msgid) \ | ||
| 190 | dcpgettext_expr (NULL, Msgctxt, Msgid, LC_MESSAGES) | ||
| 191 | #define dpgettext_expr(Domainname, Msgctxt, Msgid) \ | ||
| 192 | dcpgettext_expr (Domainname, Msgctxt, Msgid, LC_MESSAGES) | ||
| 193 | |||
| 194 | #ifdef __GNUC__ | ||
| 195 | __inline | ||
| 196 | #else | ||
| 197 | #ifdef __cplusplus | ||
| 198 | inline | ||
| 199 | #endif | ||
| 200 | #endif | ||
| 201 | static const char * | ||
| 202 | dcpgettext_expr (const char *domain, | ||
| 203 | const char *msgctxt, const char *msgid, | ||
| 204 | int category) | ||
| 205 | { | ||
| 206 | size_t msgctxt_len = strlen (msgctxt) + 1; | ||
| 207 | size_t msgid_len = strlen (msgid) + 1; | ||
| 208 | const char *translation; | ||
| 209 | #if _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS | ||
| 210 | char msg_ctxt_id[msgctxt_len + msgid_len]; | ||
| 211 | #else | ||
| 212 | char buf[1024]; | ||
| 213 | char *msg_ctxt_id = | ||
| 214 | (msgctxt_len + msgid_len <= sizeof (buf) | ||
| 215 | ? buf | ||
| 216 | : (char *) malloc (msgctxt_len + msgid_len)); | ||
| 217 | if (msg_ctxt_id != NULL) | ||
| 218 | #endif | ||
| 219 | { | ||
| 220 | memcpy (msg_ctxt_id, msgctxt, msgctxt_len - 1); | ||
| 221 | msg_ctxt_id[msgctxt_len - 1] = '\004'; | ||
| 222 | memcpy (msg_ctxt_id + msgctxt_len, msgid, msgid_len); | ||
| 223 | translation = dcgettext (domain, msg_ctxt_id, category); | ||
| 224 | #if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS | ||
| 225 | if (msg_ctxt_id != buf) | ||
| 226 | free (msg_ctxt_id); | ||
| 227 | #endif | ||
| 228 | if (translation != msg_ctxt_id) | ||
| 229 | return translation; | ||
| 230 | } | ||
| 231 | return msgid; | ||
| 232 | } | ||
| 233 | |||
| 234 | #define npgettext_expr(Msgctxt, Msgid, MsgidPlural, N) \ | ||
| 235 | dcnpgettext_expr (NULL, Msgctxt, Msgid, MsgidPlural, N, LC_MESSAGES) | ||
| 236 | #define dnpgettext_expr(Domainname, Msgctxt, Msgid, MsgidPlural, N) \ | ||
| 237 | dcnpgettext_expr (Domainname, Msgctxt, Msgid, MsgidPlural, N, LC_MESSAGES) | ||
| 238 | |||
| 239 | #ifdef __GNUC__ | ||
| 240 | __inline | ||
| 241 | #else | ||
| 242 | #ifdef __cplusplus | ||
| 243 | inline | ||
| 244 | #endif | ||
| 245 | #endif | ||
| 246 | static const char * | ||
| 247 | dcnpgettext_expr (const char *domain, | ||
| 248 | const char *msgctxt, const char *msgid, | ||
| 249 | const char *msgid_plural, unsigned long int n, | ||
| 250 | int category) | ||
| 251 | { | ||
| 252 | size_t msgctxt_len = strlen (msgctxt) + 1; | ||
| 253 | size_t msgid_len = strlen (msgid) + 1; | ||
| 254 | const char *translation; | ||
| 255 | #if _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS | ||
| 256 | char msg_ctxt_id[msgctxt_len + msgid_len]; | ||
| 257 | #else | ||
| 258 | char buf[1024]; | ||
| 259 | char *msg_ctxt_id = | ||
| 260 | (msgctxt_len + msgid_len <= sizeof (buf) | ||
| 261 | ? buf | ||
| 262 | : (char *) malloc (msgctxt_len + msgid_len)); | ||
| 263 | if (msg_ctxt_id != NULL) | ||
| 264 | #endif | ||
| 265 | { | ||
| 266 | memcpy (msg_ctxt_id, msgctxt, msgctxt_len - 1); | ||
| 267 | msg_ctxt_id[msgctxt_len - 1] = '\004'; | ||
| 268 | memcpy (msg_ctxt_id + msgctxt_len, msgid, msgid_len); | ||
| 269 | translation = dcngettext (domain, msg_ctxt_id, msgid_plural, n, category); | ||
| 270 | #if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS | ||
| 271 | if (msg_ctxt_id != buf) | ||
| 272 | free (msg_ctxt_id); | ||
| 273 | #endif | ||
| 274 | if (!(translation == msg_ctxt_id || translation == msgid_plural)) | ||
| 275 | return translation; | ||
| 276 | } | ||
| 277 | return (n == 1 ? msgid : msgid_plural); | ||
| 278 | } | ||
| 279 | |||
| 280 | #endif /* _LIBGETTEXT_H */ | ||
diff --git a/lib/gnulib.mk b/lib/gnulib.mk index a091e399be1..f7f1aae5ca2 100644 --- a/lib/gnulib.mk +++ b/lib/gnulib.mk | |||
| @@ -9,7 +9,7 @@ | |||
| 9 | # the same distribution terms as the rest of that program. | 9 | # the same distribution terms as the rest of that program. |
| 10 | # | 10 | # |
| 11 | # Generated by gnulib-tool. | 11 | # Generated by gnulib-tool. |
| 12 | # Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=. --makefile-name=gnulib.mk --no-libtool --macro-prefix=gl --no-vc-files ftoastr mktime | 12 | # Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=. --makefile-name=gnulib.mk --no-libtool --macro-prefix=gl --no-vc-files ftoastr getopt-gnu mktime |
| 13 | 13 | ||
| 14 | 14 | ||
| 15 | MOSTLYCLEANFILES += core *.stackdump | 15 | MOSTLYCLEANFILES += core *.stackdump |
| @@ -75,6 +75,38 @@ libgnu_a_SOURCES += ftoastr.h ftoastr.c dtoastr.c ldtoastr.c | |||
| 75 | 75 | ||
| 76 | ## end gnulib module ftoastr | 76 | ## end gnulib module ftoastr |
| 77 | 77 | ||
| 78 | ## begin gnulib module getopt-posix | ||
| 79 | |||
| 80 | BUILT_SOURCES += $(GETOPT_H) | ||
| 81 | |||
| 82 | # We need the following in order to create <getopt.h> when the system | ||
| 83 | # doesn't have one that works with the given compiler. | ||
| 84 | getopt.h: getopt.in.h $(ARG_NONNULL_H) | ||
| 85 | $(AM_V_GEN)rm -f $@-t $@ && \ | ||
| 86 | { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ | ||
| 87 | sed -e 's|@''HAVE_GETOPT_H''@|$(HAVE_GETOPT_H)|g' \ | ||
| 88 | -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ | ||
| 89 | -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ | ||
| 90 | -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ | ||
| 91 | -e 's|@''NEXT_GETOPT_H''@|$(NEXT_GETOPT_H)|g' \ | ||
| 92 | -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \ | ||
| 93 | < $(srcdir)/getopt.in.h; \ | ||
| 94 | } > $@-t && \ | ||
| 95 | mv -f $@-t $@ | ||
| 96 | MOSTLYCLEANFILES += getopt.h getopt.h-t | ||
| 97 | |||
| 98 | EXTRA_DIST += getopt.c getopt.in.h getopt1.c getopt_int.h | ||
| 99 | |||
| 100 | EXTRA_libgnu_a_SOURCES += getopt.c getopt1.c | ||
| 101 | |||
| 102 | ## end gnulib module getopt-posix | ||
| 103 | |||
| 104 | ## begin gnulib module gettext-h | ||
| 105 | |||
| 106 | libgnu_a_SOURCES += gettext.h | ||
| 107 | |||
| 108 | ## end gnulib module gettext-h | ||
| 109 | |||
| 78 | ## begin gnulib module intprops | 110 | ## begin gnulib module intprops |
| 79 | 111 | ||
| 80 | 112 | ||
| @@ -165,6 +197,137 @@ EXTRA_libgnu_a_SOURCES += time_r.c | |||
| 165 | 197 | ||
| 166 | ## end gnulib module time_r | 198 | ## end gnulib module time_r |
| 167 | 199 | ||
| 200 | ## begin gnulib module unistd | ||
| 201 | |||
| 202 | BUILT_SOURCES += unistd.h | ||
| 203 | |||
| 204 | # We need the following in order to create an empty placeholder for | ||
| 205 | # <unistd.h> when the system doesn't have one. | ||
| 206 | unistd.h: unistd.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) | ||
| 207 | $(AM_V_GEN)rm -f $@-t $@ && \ | ||
| 208 | { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ | ||
| 209 | sed -e 's|@''HAVE_UNISTD_H''@|$(HAVE_UNISTD_H)|g' \ | ||
| 210 | -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ | ||
| 211 | -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ | ||
| 212 | -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ | ||
| 213 | -e 's|@''NEXT_UNISTD_H''@|$(NEXT_UNISTD_H)|g' \ | ||
| 214 | -e 's|@''GNULIB_CHOWN''@|$(GNULIB_CHOWN)|g' \ | ||
| 215 | -e 's|@''GNULIB_CLOSE''@|$(GNULIB_CLOSE)|g' \ | ||
| 216 | -e 's|@''GNULIB_DUP2''@|$(GNULIB_DUP2)|g' \ | ||
| 217 | -e 's|@''GNULIB_DUP3''@|$(GNULIB_DUP3)|g' \ | ||
| 218 | -e 's|@''GNULIB_ENVIRON''@|$(GNULIB_ENVIRON)|g' \ | ||
| 219 | -e 's|@''GNULIB_EUIDACCESS''@|$(GNULIB_EUIDACCESS)|g' \ | ||
| 220 | -e 's|@''GNULIB_FACCESSAT''@|$(GNULIB_FACCESSAT)|g' \ | ||
| 221 | -e 's|@''GNULIB_FCHDIR''@|$(GNULIB_FCHDIR)|g' \ | ||
| 222 | -e 's|@''GNULIB_FCHOWNAT''@|$(GNULIB_FCHOWNAT)|g' \ | ||
| 223 | -e 's|@''GNULIB_FSYNC''@|$(GNULIB_FSYNC)|g' \ | ||
| 224 | -e 's|@''GNULIB_FTRUNCATE''@|$(GNULIB_FTRUNCATE)|g' \ | ||
| 225 | -e 's|@''GNULIB_GETCWD''@|$(GNULIB_GETCWD)|g' \ | ||
| 226 | -e 's|@''GNULIB_GETDOMAINNAME''@|$(GNULIB_GETDOMAINNAME)|g' \ | ||
| 227 | -e 's|@''GNULIB_GETDTABLESIZE''@|$(GNULIB_GETDTABLESIZE)|g' \ | ||
| 228 | -e 's|@''GNULIB_GETGROUPS''@|$(GNULIB_GETGROUPS)|g' \ | ||
| 229 | -e 's|@''GNULIB_GETHOSTNAME''@|$(GNULIB_GETHOSTNAME)|g' \ | ||
| 230 | -e 's|@''GNULIB_GETLOGIN''@|$(GNULIB_GETLOGIN)|g' \ | ||
| 231 | -e 's|@''GNULIB_GETLOGIN_R''@|$(GNULIB_GETLOGIN_R)|g' \ | ||
| 232 | -e 's|@''GNULIB_GETPAGESIZE''@|$(GNULIB_GETPAGESIZE)|g' \ | ||
| 233 | -e 's|@''GNULIB_GETUSERSHELL''@|$(GNULIB_GETUSERSHELL)|g' \ | ||
| 234 | -e 's|@''GNULIB_LCHOWN''@|$(GNULIB_LCHOWN)|g' \ | ||
| 235 | -e 's|@''GNULIB_LINK''@|$(GNULIB_LINK)|g' \ | ||
| 236 | -e 's|@''GNULIB_LINKAT''@|$(GNULIB_LINKAT)|g' \ | ||
| 237 | -e 's|@''GNULIB_LSEEK''@|$(GNULIB_LSEEK)|g' \ | ||
| 238 | -e 's|@''GNULIB_PIPE''@|$(GNULIB_PIPE)|g' \ | ||
| 239 | -e 's|@''GNULIB_PIPE2''@|$(GNULIB_PIPE2)|g' \ | ||
| 240 | -e 's|@''GNULIB_PREAD''@|$(GNULIB_PREAD)|g' \ | ||
| 241 | -e 's|@''GNULIB_PWRITE''@|$(GNULIB_PWRITE)|g' \ | ||
| 242 | -e 's|@''GNULIB_READLINK''@|$(GNULIB_READLINK)|g' \ | ||
| 243 | -e 's|@''GNULIB_READLINKAT''@|$(GNULIB_READLINKAT)|g' \ | ||
| 244 | -e 's|@''GNULIB_RMDIR''@|$(GNULIB_RMDIR)|g' \ | ||
| 245 | -e 's|@''GNULIB_SLEEP''@|$(GNULIB_SLEEP)|g' \ | ||
| 246 | -e 's|@''GNULIB_SYMLINK''@|$(GNULIB_SYMLINK)|g' \ | ||
| 247 | -e 's|@''GNULIB_SYMLINKAT''@|$(GNULIB_SYMLINKAT)|g' \ | ||
| 248 | -e 's|@''GNULIB_TTYNAME_R''@|$(GNULIB_TTYNAME_R)|g' \ | ||
| 249 | -e 's|@''GNULIB_UNISTD_H_GETOPT''@|$(GNULIB_UNISTD_H_GETOPT)|g' \ | ||
| 250 | -e 's|@''GNULIB_UNISTD_H_SIGPIPE''@|$(GNULIB_UNISTD_H_SIGPIPE)|g' \ | ||
| 251 | -e 's|@''GNULIB_UNLINK''@|$(GNULIB_UNLINK)|g' \ | ||
| 252 | -e 's|@''GNULIB_UNLINKAT''@|$(GNULIB_UNLINKAT)|g' \ | ||
| 253 | -e 's|@''GNULIB_USLEEP''@|$(GNULIB_USLEEP)|g' \ | ||
| 254 | -e 's|@''GNULIB_WRITE''@|$(GNULIB_WRITE)|g' \ | ||
| 255 | < $(srcdir)/unistd.in.h | \ | ||
| 256 | sed -e 's|@''HAVE_CHOWN''@|$(HAVE_CHOWN)|g' \ | ||
| 257 | -e 's|@''HAVE_DUP2''@|$(HAVE_DUP2)|g' \ | ||
| 258 | -e 's|@''HAVE_DUP3''@|$(HAVE_DUP3)|g' \ | ||
| 259 | -e 's|@''HAVE_EUIDACCESS''@|$(HAVE_EUIDACCESS)|g' \ | ||
| 260 | -e 's|@''HAVE_FACCESSAT''@|$(HAVE_FACCESSAT)|g' \ | ||
| 261 | -e 's|@''HAVE_FCHDIR''@|$(HAVE_FCHDIR)|g' \ | ||
| 262 | -e 's|@''HAVE_FCHOWNAT''@|$(HAVE_FCHOWNAT)|g' \ | ||
| 263 | -e 's|@''HAVE_FSYNC''@|$(HAVE_FSYNC)|g' \ | ||
| 264 | -e 's|@''HAVE_FTRUNCATE''@|$(HAVE_FTRUNCATE)|g' \ | ||
| 265 | -e 's|@''HAVE_GETDTABLESIZE''@|$(HAVE_GETDTABLESIZE)|g' \ | ||
| 266 | -e 's|@''HAVE_GETGROUPS''@|$(HAVE_GETGROUPS)|g' \ | ||
| 267 | -e 's|@''HAVE_GETHOSTNAME''@|$(HAVE_GETHOSTNAME)|g' \ | ||
| 268 | -e 's|@''HAVE_GETLOGIN''@|$(HAVE_GETLOGIN)|g' \ | ||
| 269 | -e 's|@''HAVE_GETPAGESIZE''@|$(HAVE_GETPAGESIZE)|g' \ | ||
| 270 | -e 's|@''HAVE_LCHOWN''@|$(HAVE_LCHOWN)|g' \ | ||
| 271 | -e 's|@''HAVE_LINK''@|$(HAVE_LINK)|g' \ | ||
| 272 | -e 's|@''HAVE_LINKAT''@|$(HAVE_LINKAT)|g' \ | ||
| 273 | -e 's|@''HAVE_PIPE''@|$(HAVE_PIPE)|g' \ | ||
| 274 | -e 's|@''HAVE_PIPE2''@|$(HAVE_PIPE2)|g' \ | ||
| 275 | -e 's|@''HAVE_PREAD''@|$(HAVE_PREAD)|g' \ | ||
| 276 | -e 's|@''HAVE_PWRITE''@|$(HAVE_PWRITE)|g' \ | ||
| 277 | -e 's|@''HAVE_READLINK''@|$(HAVE_READLINK)|g' \ | ||
| 278 | -e 's|@''HAVE_READLINKAT''@|$(HAVE_READLINKAT)|g' \ | ||
| 279 | -e 's|@''HAVE_SLEEP''@|$(HAVE_SLEEP)|g' \ | ||
| 280 | -e 's|@''HAVE_SYMLINK''@|$(HAVE_SYMLINK)|g' \ | ||
| 281 | -e 's|@''HAVE_SYMLINKAT''@|$(HAVE_SYMLINKAT)|g' \ | ||
| 282 | -e 's|@''HAVE_UNLINKAT''@|$(HAVE_UNLINKAT)|g' \ | ||
| 283 | -e 's|@''HAVE_USLEEP''@|$(HAVE_USLEEP)|g' \ | ||
| 284 | -e 's|@''HAVE_DECL_ENVIRON''@|$(HAVE_DECL_ENVIRON)|g' \ | ||
| 285 | -e 's|@''HAVE_DECL_FCHDIR''@|$(HAVE_DECL_FCHDIR)|g' \ | ||
| 286 | -e 's|@''HAVE_DECL_GETDOMAINNAME''@|$(HAVE_DECL_GETDOMAINNAME)|g' \ | ||
| 287 | -e 's|@''HAVE_DECL_GETLOGIN_R''@|$(HAVE_DECL_GETLOGIN_R)|g' \ | ||
| 288 | -e 's|@''HAVE_DECL_GETPAGESIZE''@|$(HAVE_DECL_GETPAGESIZE)|g' \ | ||
| 289 | -e 's|@''HAVE_DECL_GETUSERSHELL''@|$(HAVE_DECL_GETUSERSHELL)|g' \ | ||
| 290 | -e 's|@''HAVE_DECL_TTYNAME_R''@|$(HAVE_DECL_TTYNAME_R)|g' \ | ||
| 291 | -e 's|@''HAVE_OS_H''@|$(HAVE_OS_H)|g' \ | ||
| 292 | -e 's|@''HAVE_SYS_PARAM_H''@|$(HAVE_SYS_PARAM_H)|g' \ | ||
| 293 | -e 's|@''REPLACE_CHOWN''@|$(REPLACE_CHOWN)|g' \ | ||
| 294 | -e 's|@''REPLACE_CLOSE''@|$(REPLACE_CLOSE)|g' \ | ||
| 295 | -e 's|@''REPLACE_DUP''@|$(REPLACE_DUP)|g' \ | ||
| 296 | -e 's|@''REPLACE_DUP2''@|$(REPLACE_DUP2)|g' \ | ||
| 297 | -e 's|@''REPLACE_FCHOWNAT''@|$(REPLACE_FCHOWNAT)|g' \ | ||
| 298 | -e 's|@''REPLACE_GETCWD''@|$(REPLACE_GETCWD)|g' \ | ||
| 299 | -e 's|@''REPLACE_GETDOMAINNAME''@|$(REPLACE_GETDOMAINNAME)|g' \ | ||
| 300 | -e 's|@''REPLACE_GETLOGIN_R''@|$(REPLACE_GETLOGIN_R)|g' \ | ||
| 301 | -e 's|@''REPLACE_GETGROUPS''@|$(REPLACE_GETGROUPS)|g' \ | ||
| 302 | -e 's|@''REPLACE_GETPAGESIZE''@|$(REPLACE_GETPAGESIZE)|g' \ | ||
| 303 | -e 's|@''REPLACE_LCHOWN''@|$(REPLACE_LCHOWN)|g' \ | ||
| 304 | -e 's|@''REPLACE_LINK''@|$(REPLACE_LINK)|g' \ | ||
| 305 | -e 's|@''REPLACE_LINKAT''@|$(REPLACE_LINKAT)|g' \ | ||
| 306 | -e 's|@''REPLACE_LSEEK''@|$(REPLACE_LSEEK)|g' \ | ||
| 307 | -e 's|@''REPLACE_PREAD''@|$(REPLACE_PREAD)|g' \ | ||
| 308 | -e 's|@''REPLACE_PWRITE''@|$(REPLACE_PWRITE)|g' \ | ||
| 309 | -e 's|@''REPLACE_READLINK''@|$(REPLACE_READLINK)|g' \ | ||
| 310 | -e 's|@''REPLACE_RMDIR''@|$(REPLACE_RMDIR)|g' \ | ||
| 311 | -e 's|@''REPLACE_SLEEP''@|$(REPLACE_SLEEP)|g' \ | ||
| 312 | -e 's|@''REPLACE_SYMLINK''@|$(REPLACE_SYMLINK)|g' \ | ||
| 313 | -e 's|@''REPLACE_TTYNAME_R''@|$(REPLACE_TTYNAME_R)|g' \ | ||
| 314 | -e 's|@''REPLACE_UNLINK''@|$(REPLACE_UNLINK)|g' \ | ||
| 315 | -e 's|@''REPLACE_UNLINKAT''@|$(REPLACE_UNLINKAT)|g' \ | ||
| 316 | -e 's|@''REPLACE_USLEEP''@|$(REPLACE_USLEEP)|g' \ | ||
| 317 | -e 's|@''REPLACE_WRITE''@|$(REPLACE_WRITE)|g' \ | ||
| 318 | -e 's|@''UNISTD_H_HAVE_WINSOCK2_H''@|$(UNISTD_H_HAVE_WINSOCK2_H)|g' \ | ||
| 319 | -e 's|@''UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS''@|$(UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS)|g' \ | ||
| 320 | -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \ | ||
| 321 | -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \ | ||
| 322 | -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)'; \ | ||
| 323 | } > $@-t && \ | ||
| 324 | mv $@-t $@ | ||
| 325 | MOSTLYCLEANFILES += unistd.h unistd.h-t | ||
| 326 | |||
| 327 | EXTRA_DIST += unistd.in.h | ||
| 328 | |||
| 329 | ## end gnulib module unistd | ||
| 330 | |||
| 168 | ## begin gnulib module warn-on-use | 331 | ## begin gnulib module warn-on-use |
| 169 | 332 | ||
| 170 | BUILT_SOURCES += warn-on-use.h | 333 | BUILT_SOURCES += warn-on-use.h |
diff --git a/lib/unistd.in.h b/lib/unistd.in.h new file mode 100644 index 00000000000..14d685e0c8f --- /dev/null +++ b/lib/unistd.in.h | |||
| @@ -0,0 +1,1378 @@ | |||
| 1 | /* Substitute for and wrapper around <unistd.h>. | ||
| 2 | Copyright (C) 2003-2011 Free Software Foundation, Inc. | ||
| 3 | |||
| 4 | This program is free software; you can redistribute it and/or modify | ||
| 5 | it under the terms of the GNU General Public License as published by | ||
| 6 | the Free Software Foundation; either version 3, or (at your option) | ||
| 7 | any later version. | ||
| 8 | |||
| 9 | This program is distributed in the hope that it will be useful, | ||
| 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 12 | GNU General Public License for more details. | ||
| 13 | |||
| 14 | You should have received a copy of the GNU General Public License | ||
| 15 | along with this program; if not, write to the Free Software Foundation, | ||
| 16 | Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ | ||
| 17 | |||
| 18 | #if __GNUC__ >= 3 | ||
| 19 | @PRAGMA_SYSTEM_HEADER@ | ||
| 20 | #endif | ||
| 21 | @PRAGMA_COLUMNS@ | ||
| 22 | |||
| 23 | /* Special invocation convention: | ||
| 24 | - On mingw, several headers, including <winsock2.h>, include <unistd.h>, | ||
| 25 | but we need to ensure that both the system <unistd.h> and <winsock2.h> | ||
| 26 | are completely included before we replace gethostname. */ | ||
| 27 | #if @GNULIB_GETHOSTNAME@ && @UNISTD_H_HAVE_WINSOCK2_H@ \ | ||
| 28 | && !defined _GL_WINSOCK2_H_WITNESS && defined _WINSOCK2_H | ||
| 29 | /* <unistd.h> is being indirectly included for the first time from | ||
| 30 | <winsock2.h>; avoid declaring any overrides. */ | ||
| 31 | # if @HAVE_UNISTD_H@ | ||
| 32 | # @INCLUDE_NEXT@ @NEXT_UNISTD_H@ | ||
| 33 | # else | ||
| 34 | # error unexpected; report this to bug-gnulib@gnu.org | ||
| 35 | # endif | ||
| 36 | # define _GL_WINSOCK2_H_WITNESS | ||
| 37 | |||
| 38 | /* Normal invocation. */ | ||
| 39 | #elif !defined _GL_UNISTD_H | ||
| 40 | |||
| 41 | /* The include_next requires a split double-inclusion guard. */ | ||
| 42 | #if @HAVE_UNISTD_H@ | ||
| 43 | # @INCLUDE_NEXT@ @NEXT_UNISTD_H@ | ||
| 44 | #endif | ||
| 45 | |||
| 46 | /* Get all possible declarations of gethostname(). */ | ||
| 47 | #if @GNULIB_GETHOSTNAME@ && @UNISTD_H_HAVE_WINSOCK2_H@ \ | ||
| 48 | && !defined _GL_INCLUDING_WINSOCK2_H | ||
| 49 | # define _GL_INCLUDING_WINSOCK2_H | ||
| 50 | # include <winsock2.h> | ||
| 51 | # undef _GL_INCLUDING_WINSOCK2_H | ||
| 52 | #endif | ||
| 53 | |||
| 54 | #if !defined _GL_UNISTD_H && !defined _GL_INCLUDING_WINSOCK2_H | ||
| 55 | #define _GL_UNISTD_H | ||
| 56 | |||
| 57 | /* NetBSD 5.0 mis-defines NULL. Also get size_t. */ | ||
| 58 | #include <stddef.h> | ||
| 59 | |||
| 60 | /* mingw doesn't define the SEEK_* or *_FILENO macros in <unistd.h>. */ | ||
| 61 | /* Cygwin 1.7.1 declares symlinkat in <stdio.h>, not in <unistd.h>. */ | ||
| 62 | /* But avoid namespace pollution on glibc systems. */ | ||
| 63 | #if (!(defined SEEK_CUR && defined SEEK_END && defined SEEK_SET) \ | ||
| 64 | || ((@GNULIB_SYMLINKAT@ || defined GNULIB_POSIXCHECK) \ | ||
| 65 | && defined __CYGWIN__)) \ | ||
| 66 | && ! defined __GLIBC__ | ||
| 67 | # include <stdio.h> | ||
| 68 | #endif | ||
| 69 | |||
| 70 | /* Cygwin 1.7.1 declares unlinkat in <fcntl.h>, not in <unistd.h>. */ | ||
| 71 | /* But avoid namespace pollution on glibc systems. */ | ||
| 72 | #if (@GNULIB_UNLINKAT@ || defined GNULIB_POSIXCHECK) && defined __CYGWIN__ \ | ||
| 73 | && ! defined __GLIBC__ | ||
| 74 | # include <fcntl.h> | ||
| 75 | #endif | ||
| 76 | |||
| 77 | /* mingw fails to declare _exit in <unistd.h>. */ | ||
| 78 | /* mingw, BeOS, Haiku declare environ in <stdlib.h>, not in <unistd.h>. */ | ||
| 79 | /* Solaris declares getcwd not only in <unistd.h> but also in <stdlib.h>. */ | ||
| 80 | /* But avoid namespace pollution on glibc systems. */ | ||
| 81 | #ifndef __GLIBC__ | ||
| 82 | # include <stdlib.h> | ||
| 83 | #endif | ||
| 84 | |||
| 85 | /* mingw declares getcwd in <io.h>, not in <unistd.h>. */ | ||
| 86 | #if ((@GNULIB_GETCWD@ || defined GNULIB_POSIXCHECK) \ | ||
| 87 | && ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__)) | ||
| 88 | # include <io.h> | ||
| 89 | #endif | ||
| 90 | |||
| 91 | /* AIX and OSF/1 5.1 declare getdomainname in <netdb.h>, not in <unistd.h>. | ||
| 92 | NonStop Kernel declares gethostname in <netdb.h>, not in <unistd.h>. */ | ||
| 93 | /* But avoid namespace pollution on glibc systems. */ | ||
| 94 | #if ((@GNULIB_GETDOMAINNAME@ && (defined _AIX || defined __osf__)) \ | ||
| 95 | || (@GNULIB_GETHOSTNAME@ && defined __TANDEM)) \ | ||
| 96 | && !defined __GLIBC__ | ||
| 97 | # include <netdb.h> | ||
| 98 | #endif | ||
| 99 | |||
| 100 | #if (@GNULIB_WRITE@ || @GNULIB_READLINK@ || @GNULIB_READLINKAT@ \ | ||
| 101 | || @GNULIB_PREAD@ || @GNULIB_PWRITE@ || defined GNULIB_POSIXCHECK) | ||
| 102 | /* Get ssize_t. */ | ||
| 103 | # include <sys/types.h> | ||
| 104 | #endif | ||
| 105 | |||
| 106 | /* Get getopt(), optarg, optind, opterr, optopt. | ||
| 107 | But avoid namespace pollution on glibc systems. */ | ||
| 108 | #if @GNULIB_UNISTD_H_GETOPT@ && !defined __GLIBC__ && !defined _GL_SYSTEM_GETOPT | ||
| 109 | # include <getopt.h> | ||
| 110 | #endif | ||
| 111 | |||
| 112 | /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ | ||
| 113 | |||
| 114 | /* The definition of _GL_ARG_NONNULL is copied here. */ | ||
| 115 | |||
| 116 | /* The definition of _GL_WARN_ON_USE is copied here. */ | ||
| 117 | |||
| 118 | |||
| 119 | #if @GNULIB_GETHOSTNAME@ | ||
| 120 | /* Get all possible declarations of gethostname(). */ | ||
| 121 | # if @UNISTD_H_HAVE_WINSOCK2_H@ | ||
| 122 | # if !defined _GL_SYS_SOCKET_H | ||
| 123 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||
| 124 | # undef socket | ||
| 125 | # define socket socket_used_without_including_sys_socket_h | ||
| 126 | # undef connect | ||
| 127 | # define connect connect_used_without_including_sys_socket_h | ||
| 128 | # undef accept | ||
| 129 | # define accept accept_used_without_including_sys_socket_h | ||
| 130 | # undef bind | ||
| 131 | # define bind bind_used_without_including_sys_socket_h | ||
| 132 | # undef getpeername | ||
| 133 | # define getpeername getpeername_used_without_including_sys_socket_h | ||
| 134 | # undef getsockname | ||
| 135 | # define getsockname getsockname_used_without_including_sys_socket_h | ||
| 136 | # undef getsockopt | ||
| 137 | # define getsockopt getsockopt_used_without_including_sys_socket_h | ||
| 138 | # undef listen | ||
| 139 | # define listen listen_used_without_including_sys_socket_h | ||
| 140 | # undef recv | ||
| 141 | # define recv recv_used_without_including_sys_socket_h | ||
| 142 | # undef send | ||
| 143 | # define send send_used_without_including_sys_socket_h | ||
| 144 | # undef recvfrom | ||
| 145 | # define recvfrom recvfrom_used_without_including_sys_socket_h | ||
| 146 | # undef sendto | ||
| 147 | # define sendto sendto_used_without_including_sys_socket_h | ||
| 148 | # undef setsockopt | ||
| 149 | # define setsockopt setsockopt_used_without_including_sys_socket_h | ||
| 150 | # undef shutdown | ||
| 151 | # define shutdown shutdown_used_without_including_sys_socket_h | ||
| 152 | # else | ||
| 153 | _GL_WARN_ON_USE (socket, | ||
| 154 | "socket() used without including <sys/socket.h>"); | ||
| 155 | _GL_WARN_ON_USE (connect, | ||
| 156 | "connect() used without including <sys/socket.h>"); | ||
| 157 | _GL_WARN_ON_USE (accept, | ||
| 158 | "accept() used without including <sys/socket.h>"); | ||
| 159 | _GL_WARN_ON_USE (bind, | ||
| 160 | "bind() used without including <sys/socket.h>"); | ||
| 161 | _GL_WARN_ON_USE (getpeername, | ||
| 162 | "getpeername() used without including <sys/socket.h>"); | ||
| 163 | _GL_WARN_ON_USE (getsockname, | ||
| 164 | "getsockname() used without including <sys/socket.h>"); | ||
| 165 | _GL_WARN_ON_USE (getsockopt, | ||
| 166 | "getsockopt() used without including <sys/socket.h>"); | ||
| 167 | _GL_WARN_ON_USE (listen, | ||
| 168 | "listen() used without including <sys/socket.h>"); | ||
| 169 | _GL_WARN_ON_USE (recv, | ||
| 170 | "recv() used without including <sys/socket.h>"); | ||
| 171 | _GL_WARN_ON_USE (send, | ||
| 172 | "send() used without including <sys/socket.h>"); | ||
| 173 | _GL_WARN_ON_USE (recvfrom, | ||
| 174 | "recvfrom() used without including <sys/socket.h>"); | ||
| 175 | _GL_WARN_ON_USE (sendto, | ||
| 176 | "sendto() used without including <sys/socket.h>"); | ||
| 177 | _GL_WARN_ON_USE (setsockopt, | ||
| 178 | "setsockopt() used without including <sys/socket.h>"); | ||
| 179 | _GL_WARN_ON_USE (shutdown, | ||
| 180 | "shutdown() used without including <sys/socket.h>"); | ||
| 181 | # endif | ||
| 182 | # endif | ||
| 183 | # if !defined _GL_SYS_SELECT_H | ||
| 184 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||
| 185 | # undef select | ||
| 186 | # define select select_used_without_including_sys_select_h | ||
| 187 | # else | ||
| 188 | _GL_WARN_ON_USE (select, | ||
| 189 | "select() used without including <sys/select.h>"); | ||
| 190 | # endif | ||
| 191 | # endif | ||
| 192 | # endif | ||
| 193 | #endif | ||
| 194 | |||
| 195 | |||
| 196 | /* OS/2 EMX lacks these macros. */ | ||
| 197 | #ifndef STDIN_FILENO | ||
| 198 | # define STDIN_FILENO 0 | ||
| 199 | #endif | ||
| 200 | #ifndef STDOUT_FILENO | ||
| 201 | # define STDOUT_FILENO 1 | ||
| 202 | #endif | ||
| 203 | #ifndef STDERR_FILENO | ||
| 204 | # define STDERR_FILENO 2 | ||
| 205 | #endif | ||
| 206 | |||
| 207 | /* Ensure *_OK macros exist. */ | ||
| 208 | #ifndef F_OK | ||
| 209 | # define F_OK 0 | ||
| 210 | # define X_OK 1 | ||
| 211 | # define W_OK 2 | ||
| 212 | # define R_OK 4 | ||
| 213 | #endif | ||
| 214 | |||
| 215 | |||
| 216 | /* Declare overridden functions. */ | ||
| 217 | |||
| 218 | |||
| 219 | #if defined GNULIB_POSIXCHECK | ||
| 220 | /* The access() function is a security risk. */ | ||
| 221 | _GL_WARN_ON_USE (access, "the access function is a security risk - " | ||
| 222 | "use the gnulib module faccessat instead"); | ||
| 223 | #endif | ||
| 224 | |||
| 225 | |||
| 226 | #if @GNULIB_CHOWN@ | ||
| 227 | /* Change the owner of FILE to UID (if UID is not -1) and the group of FILE | ||
| 228 | to GID (if GID is not -1). Follow symbolic links. | ||
| 229 | Return 0 if successful, otherwise -1 and errno set. | ||
| 230 | See the POSIX:2001 specification | ||
| 231 | <http://www.opengroup.org/susv3xsh/chown.html>. */ | ||
| 232 | # if @REPLACE_CHOWN@ | ||
| 233 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||
| 234 | # undef chown | ||
| 235 | # define chown rpl_chown | ||
| 236 | # endif | ||
| 237 | _GL_FUNCDECL_RPL (chown, int, (const char *file, uid_t uid, gid_t gid) | ||
| 238 | _GL_ARG_NONNULL ((1))); | ||
| 239 | _GL_CXXALIAS_RPL (chown, int, (const char *file, uid_t uid, gid_t gid)); | ||
| 240 | # else | ||
| 241 | # if !@HAVE_CHOWN@ | ||
| 242 | _GL_FUNCDECL_SYS (chown, int, (const char *file, uid_t uid, gid_t gid) | ||
| 243 | _GL_ARG_NONNULL ((1))); | ||
| 244 | # endif | ||
| 245 | _GL_CXXALIAS_SYS (chown, int, (const char *file, uid_t uid, gid_t gid)); | ||
| 246 | # endif | ||
| 247 | _GL_CXXALIASWARN (chown); | ||
| 248 | #elif defined GNULIB_POSIXCHECK | ||
| 249 | # undef chown | ||
| 250 | # if HAVE_RAW_DECL_CHOWN | ||
| 251 | _GL_WARN_ON_USE (chown, "chown fails to follow symlinks on some systems and " | ||
| 252 | "doesn't treat a uid or gid of -1 on some systems - " | ||
| 253 | "use gnulib module chown for portability"); | ||
| 254 | # endif | ||
| 255 | #endif | ||
| 256 | |||
| 257 | |||
| 258 | #if @GNULIB_CLOSE@ | ||
| 259 | # if @REPLACE_CLOSE@ | ||
| 260 | /* Automatically included by modules that need a replacement for close. */ | ||
| 261 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||
| 262 | # undef close | ||
| 263 | # define close rpl_close | ||
| 264 | # endif | ||
| 265 | _GL_FUNCDECL_RPL (close, int, (int fd)); | ||
| 266 | _GL_CXXALIAS_RPL (close, int, (int fd)); | ||
| 267 | # else | ||
| 268 | _GL_CXXALIAS_SYS (close, int, (int fd)); | ||
| 269 | # endif | ||
| 270 | _GL_CXXALIASWARN (close); | ||
| 271 | #elif @UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS@ | ||
| 272 | # undef close | ||
| 273 | # define close close_used_without_requesting_gnulib_module_close | ||
| 274 | #elif defined GNULIB_POSIXCHECK | ||
| 275 | # undef close | ||
| 276 | /* Assume close is always declared. */ | ||
| 277 | _GL_WARN_ON_USE (close, "close does not portably work on sockets - " | ||
| 278 | "use gnulib module close for portability"); | ||
| 279 | #endif | ||
| 280 | |||
| 281 | |||
| 282 | #if @REPLACE_DUP@ | ||
| 283 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||
| 284 | # define dup rpl_dup | ||
| 285 | # endif | ||
| 286 | _GL_FUNCDECL_RPL (dup, int, (int oldfd)); | ||
| 287 | _GL_CXXALIAS_RPL (dup, int, (int oldfd)); | ||
| 288 | #else | ||
| 289 | _GL_CXXALIAS_SYS (dup, int, (int oldfd)); | ||
| 290 | #endif | ||
| 291 | _GL_CXXALIASWARN (dup); | ||
| 292 | |||
| 293 | |||
| 294 | #if @GNULIB_DUP2@ | ||
| 295 | /* Copy the file descriptor OLDFD into file descriptor NEWFD. Do nothing if | ||
| 296 | NEWFD = OLDFD, otherwise close NEWFD first if it is open. | ||
| 297 | Return newfd if successful, otherwise -1 and errno set. | ||
| 298 | See the POSIX:2001 specification | ||
| 299 | <http://www.opengroup.org/susv3xsh/dup2.html>. */ | ||
| 300 | # if @REPLACE_DUP2@ | ||
| 301 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||
| 302 | # define dup2 rpl_dup2 | ||
| 303 | # endif | ||
| 304 | _GL_FUNCDECL_RPL (dup2, int, (int oldfd, int newfd)); | ||
| 305 | _GL_CXXALIAS_RPL (dup2, int, (int oldfd, int newfd)); | ||
| 306 | # else | ||
| 307 | # if !@HAVE_DUP2@ | ||
| 308 | _GL_FUNCDECL_SYS (dup2, int, (int oldfd, int newfd)); | ||
| 309 | # endif | ||
| 310 | _GL_CXXALIAS_SYS (dup2, int, (int oldfd, int newfd)); | ||
| 311 | # endif | ||
| 312 | _GL_CXXALIASWARN (dup2); | ||
| 313 | #elif defined GNULIB_POSIXCHECK | ||
| 314 | # undef dup2 | ||
| 315 | # if HAVE_RAW_DECL_DUP2 | ||
| 316 | _GL_WARN_ON_USE (dup2, "dup2 is unportable - " | ||
| 317 | "use gnulib module dup2 for portability"); | ||
| 318 | # endif | ||
| 319 | #endif | ||
| 320 | |||
| 321 | |||
| 322 | #if @GNULIB_DUP3@ | ||
| 323 | /* Copy the file descriptor OLDFD into file descriptor NEWFD, with the | ||
| 324 | specified flags. | ||
| 325 | The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>) | ||
| 326 | and O_TEXT, O_BINARY (defined in "binary-io.h"). | ||
| 327 | Close NEWFD first if it is open. | ||
| 328 | Return newfd if successful, otherwise -1 and errno set. | ||
| 329 | See the Linux man page at | ||
| 330 | <http://www.kernel.org/doc/man-pages/online/pages/man2/dup3.2.html>. */ | ||
| 331 | # if @HAVE_DUP3@ | ||
| 332 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||
| 333 | # define dup3 rpl_dup3 | ||
| 334 | # endif | ||
| 335 | _GL_FUNCDECL_RPL (dup3, int, (int oldfd, int newfd, int flags)); | ||
| 336 | _GL_CXXALIAS_RPL (dup3, int, (int oldfd, int newfd, int flags)); | ||
| 337 | # else | ||
| 338 | _GL_FUNCDECL_SYS (dup3, int, (int oldfd, int newfd, int flags)); | ||
| 339 | _GL_CXXALIAS_SYS (dup3, int, (int oldfd, int newfd, int flags)); | ||
| 340 | # endif | ||
| 341 | _GL_CXXALIASWARN (dup3); | ||
| 342 | #elif defined GNULIB_POSIXCHECK | ||
| 343 | # undef dup3 | ||
| 344 | # if HAVE_RAW_DECL_DUP3 | ||
| 345 | _GL_WARN_ON_USE (dup3, "dup3 is unportable - " | ||
| 346 | "use gnulib module dup3 for portability"); | ||
| 347 | # endif | ||
| 348 | #endif | ||
| 349 | |||
| 350 | |||
| 351 | #if @GNULIB_ENVIRON@ | ||
| 352 | # if !@HAVE_DECL_ENVIRON@ | ||
| 353 | /* Set of environment variables and values. An array of strings of the form | ||
| 354 | "VARIABLE=VALUE", terminated with a NULL. */ | ||
| 355 | # if defined __APPLE__ && defined __MACH__ | ||
| 356 | # include <crt_externs.h> | ||
| 357 | # define environ (*_NSGetEnviron ()) | ||
| 358 | # else | ||
| 359 | # ifdef __cplusplus | ||
| 360 | extern "C" { | ||
| 361 | # endif | ||
| 362 | extern char **environ; | ||
| 363 | # ifdef __cplusplus | ||
| 364 | } | ||
| 365 | # endif | ||
| 366 | # endif | ||
| 367 | # endif | ||
| 368 | #elif defined GNULIB_POSIXCHECK | ||
| 369 | # if HAVE_RAW_DECL_ENVIRON | ||
| 370 | static inline char *** | ||
| 371 | rpl_environ (void) | ||
| 372 | { | ||
| 373 | return &environ; | ||
| 374 | } | ||
| 375 | _GL_WARN_ON_USE (rpl_environ, "environ is unportable - " | ||
| 376 | "use gnulib module environ for portability"); | ||
| 377 | # undef environ | ||
| 378 | # define environ (*rpl_environ ()) | ||
| 379 | # endif | ||
| 380 | #endif | ||
| 381 | |||
| 382 | |||
| 383 | #if @GNULIB_EUIDACCESS@ | ||
| 384 | /* Like access(), except that it uses the effective user id and group id of | ||
| 385 | the current process. */ | ||
| 386 | # if !@HAVE_EUIDACCESS@ | ||
| 387 | _GL_FUNCDECL_SYS (euidaccess, int, (const char *filename, int mode) | ||
| 388 | _GL_ARG_NONNULL ((1))); | ||
| 389 | # endif | ||
| 390 | _GL_CXXALIAS_SYS (euidaccess, int, (const char *filename, int mode)); | ||
| 391 | _GL_CXXALIASWARN (euidaccess); | ||
| 392 | # if defined GNULIB_POSIXCHECK | ||
| 393 | /* Like access(), this function is a security risk. */ | ||
| 394 | _GL_WARN_ON_USE (euidaccess, "the euidaccess function is a security risk - " | ||
| 395 | "use the gnulib module faccessat instead"); | ||
| 396 | # endif | ||
| 397 | #elif defined GNULIB_POSIXCHECK | ||
| 398 | # undef euidaccess | ||
| 399 | # if HAVE_RAW_DECL_EUIDACCESS | ||
| 400 | _GL_WARN_ON_USE (euidaccess, "euidaccess is unportable - " | ||
| 401 | "use gnulib module euidaccess for portability"); | ||
| 402 | # endif | ||
| 403 | #endif | ||
| 404 | |||
| 405 | |||
| 406 | #if @GNULIB_FACCESSAT@ | ||
| 407 | # if !@HAVE_FACCESSAT@ | ||
| 408 | _GL_FUNCDECL_SYS (faccessat, int, | ||
| 409 | (int fd, char const *file, int mode, int flag) | ||
| 410 | _GL_ARG_NONNULL ((2))); | ||
| 411 | # endif | ||
| 412 | _GL_CXXALIAS_SYS (faccessat, int, | ||
| 413 | (int fd, char const *file, int mode, int flag)); | ||
| 414 | _GL_CXXALIASWARN (faccessat); | ||
| 415 | #elif defined GNULIB_POSIXCHECK | ||
| 416 | # undef faccessat | ||
| 417 | # if HAVE_RAW_DECL_FACCESSAT | ||
| 418 | _GL_WARN_ON_USE (faccessat, "faccessat is not portable - " | ||
| 419 | "use gnulib module faccessat for portability"); | ||
| 420 | # endif | ||
| 421 | #endif | ||
| 422 | |||
| 423 | |||
| 424 | #if @GNULIB_FCHDIR@ | ||
| 425 | /* Change the process' current working directory to the directory on which | ||
| 426 | the given file descriptor is open. | ||
| 427 | Return 0 if successful, otherwise -1 and errno set. | ||
| 428 | See the POSIX:2001 specification | ||
| 429 | <http://www.opengroup.org/susv3xsh/fchdir.html>. */ | ||
| 430 | # if ! @HAVE_FCHDIR@ | ||
| 431 | _GL_FUNCDECL_SYS (fchdir, int, (int /*fd*/)); | ||
| 432 | |||
| 433 | /* Gnulib internal hooks needed to maintain the fchdir metadata. */ | ||
| 434 | _GL_EXTERN_C int _gl_register_fd (int fd, const char *filename) | ||
| 435 | _GL_ARG_NONNULL ((2)); | ||
| 436 | _GL_EXTERN_C void _gl_unregister_fd (int fd); | ||
| 437 | _GL_EXTERN_C int _gl_register_dup (int oldfd, int newfd); | ||
| 438 | _GL_EXTERN_C const char *_gl_directory_name (int fd); | ||
| 439 | |||
| 440 | # else | ||
| 441 | # if !@HAVE_DECL_FCHDIR@ | ||
| 442 | _GL_FUNCDECL_SYS (fchdir, int, (int /*fd*/)); | ||
| 443 | # endif | ||
| 444 | # endif | ||
| 445 | _GL_CXXALIAS_SYS (fchdir, int, (int /*fd*/)); | ||
| 446 | _GL_CXXALIASWARN (fchdir); | ||
| 447 | #elif defined GNULIB_POSIXCHECK | ||
| 448 | # undef fchdir | ||
| 449 | # if HAVE_RAW_DECL_FCHDIR | ||
| 450 | _GL_WARN_ON_USE (fchdir, "fchdir is unportable - " | ||
| 451 | "use gnulib module fchdir for portability"); | ||
| 452 | # endif | ||
| 453 | #endif | ||
| 454 | |||
| 455 | |||
| 456 | #if @GNULIB_FCHOWNAT@ | ||
| 457 | # if @REPLACE_FCHOWNAT@ | ||
| 458 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||
| 459 | # undef fchownat | ||
| 460 | # define fchownat rpl_fchownat | ||
| 461 | # endif | ||
| 462 | _GL_FUNCDECL_RPL (fchownat, int, (int fd, char const *file, | ||
| 463 | uid_t owner, gid_t group, int flag) | ||
| 464 | _GL_ARG_NONNULL ((2))); | ||
| 465 | _GL_CXXALIAS_RPL (fchownat, int, (int fd, char const *file, | ||
| 466 | uid_t owner, gid_t group, int flag)); | ||
| 467 | # else | ||
| 468 | # if !@HAVE_FCHOWNAT@ | ||
| 469 | _GL_FUNCDECL_SYS (fchownat, int, (int fd, char const *file, | ||
| 470 | uid_t owner, gid_t group, int flag) | ||
| 471 | _GL_ARG_NONNULL ((2))); | ||
| 472 | # endif | ||
| 473 | _GL_CXXALIAS_SYS (fchownat, int, (int fd, char const *file, | ||
| 474 | uid_t owner, gid_t group, int flag)); | ||
| 475 | # endif | ||
| 476 | _GL_CXXALIASWARN (fchownat); | ||
| 477 | #elif defined GNULIB_POSIXCHECK | ||
| 478 | # undef fchownat | ||
| 479 | # if HAVE_RAW_DECL_FCHOWNAT | ||
| 480 | _GL_WARN_ON_USE (fchownat, "fchownat is not portable - " | ||
| 481 | "use gnulib module openat for portability"); | ||
| 482 | # endif | ||
| 483 | #endif | ||
| 484 | |||
| 485 | |||
| 486 | #if @GNULIB_FSYNC@ | ||
| 487 | /* Synchronize changes to a file. | ||
| 488 | Return 0 if successful, otherwise -1 and errno set. | ||
| 489 | See POSIX:2001 specification | ||
| 490 | <http://www.opengroup.org/susv3xsh/fsync.html>. */ | ||
| 491 | # if !@HAVE_FSYNC@ | ||
| 492 | _GL_FUNCDECL_SYS (fsync, int, (int fd)); | ||
| 493 | # endif | ||
| 494 | _GL_CXXALIAS_SYS (fsync, int, (int fd)); | ||
| 495 | _GL_CXXALIASWARN (fsync); | ||
| 496 | #elif defined GNULIB_POSIXCHECK | ||
| 497 | # undef fsync | ||
| 498 | # if HAVE_RAW_DECL_FSYNC | ||
| 499 | _GL_WARN_ON_USE (fsync, "fsync is unportable - " | ||
| 500 | "use gnulib module fsync for portability"); | ||
| 501 | # endif | ||
| 502 | #endif | ||
| 503 | |||
| 504 | |||
| 505 | #if @GNULIB_FTRUNCATE@ | ||
| 506 | /* Change the size of the file to which FD is opened to become equal to LENGTH. | ||
| 507 | Return 0 if successful, otherwise -1 and errno set. | ||
| 508 | See the POSIX:2001 specification | ||
| 509 | <http://www.opengroup.org/susv3xsh/ftruncate.html>. */ | ||
| 510 | # if !@HAVE_FTRUNCATE@ | ||
| 511 | _GL_FUNCDECL_SYS (ftruncate, int, (int fd, off_t length)); | ||
| 512 | # endif | ||
| 513 | _GL_CXXALIAS_SYS (ftruncate, int, (int fd, off_t length)); | ||
| 514 | _GL_CXXALIASWARN (ftruncate); | ||
| 515 | #elif defined GNULIB_POSIXCHECK | ||
| 516 | # undef ftruncate | ||
| 517 | # if HAVE_RAW_DECL_FTRUNCATE | ||
| 518 | _GL_WARN_ON_USE (ftruncate, "ftruncate is unportable - " | ||
| 519 | "use gnulib module ftruncate for portability"); | ||
| 520 | # endif | ||
| 521 | #endif | ||
| 522 | |||
| 523 | |||
| 524 | #if @GNULIB_GETCWD@ | ||
| 525 | /* Get the name of the current working directory, and put it in SIZE bytes | ||
| 526 | of BUF. | ||
| 527 | Return BUF if successful, or NULL if the directory couldn't be determined | ||
| 528 | or SIZE was too small. | ||
| 529 | See the POSIX:2001 specification | ||
| 530 | <http://www.opengroup.org/susv3xsh/getcwd.html>. | ||
| 531 | Additionally, the gnulib module 'getcwd' guarantees the following GNU | ||
| 532 | extension: If BUF is NULL, an array is allocated with 'malloc'; the array | ||
| 533 | is SIZE bytes long, unless SIZE == 0, in which case it is as big as | ||
| 534 | necessary. */ | ||
| 535 | # if @REPLACE_GETCWD@ | ||
| 536 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||
| 537 | # define getcwd rpl_getcwd | ||
| 538 | # endif | ||
| 539 | _GL_FUNCDECL_RPL (getcwd, char *, (char *buf, size_t size)); | ||
| 540 | _GL_CXXALIAS_RPL (getcwd, char *, (char *buf, size_t size)); | ||
| 541 | # else | ||
| 542 | /* Need to cast, because on mingw, the second parameter is | ||
| 543 | int size. */ | ||
| 544 | _GL_CXXALIAS_SYS_CAST (getcwd, char *, (char *buf, size_t size)); | ||
| 545 | # endif | ||
| 546 | _GL_CXXALIASWARN (getcwd); | ||
| 547 | #elif defined GNULIB_POSIXCHECK | ||
| 548 | # undef getcwd | ||
| 549 | # if HAVE_RAW_DECL_GETCWD | ||
| 550 | _GL_WARN_ON_USE (getcwd, "getcwd is unportable - " | ||
| 551 | "use gnulib module getcwd for portability"); | ||
| 552 | # endif | ||
| 553 | #endif | ||
| 554 | |||
| 555 | |||
| 556 | #if @GNULIB_GETDOMAINNAME@ | ||
| 557 | /* Return the NIS domain name of the machine. | ||
| 558 | WARNING! The NIS domain name is unrelated to the fully qualified host name | ||
| 559 | of the machine. It is also unrelated to email addresses. | ||
| 560 | WARNING! The NIS domain name is usually the empty string or "(none)" when | ||
| 561 | not using NIS. | ||
| 562 | |||
| 563 | Put up to LEN bytes of the NIS domain name into NAME. | ||
| 564 | Null terminate it if the name is shorter than LEN. | ||
| 565 | If the NIS domain name is longer than LEN, set errno = EINVAL and return -1. | ||
| 566 | Return 0 if successful, otherwise set errno and return -1. */ | ||
| 567 | # if @REPLACE_GETDOMAINNAME@ | ||
| 568 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||
| 569 | # undef getdomainname | ||
| 570 | # define getdomainname rpl_getdomainname | ||
| 571 | # endif | ||
| 572 | _GL_FUNCDECL_RPL (getdomainname, int, (char *name, size_t len) | ||
| 573 | _GL_ARG_NONNULL ((1))); | ||
| 574 | _GL_CXXALIAS_RPL (getdomainname, int, (char *name, size_t len)); | ||
| 575 | # else | ||
| 576 | # if !@HAVE_DECL_GETDOMAINNAME@ | ||
| 577 | _GL_FUNCDECL_SYS (getdomainname, int, (char *name, size_t len) | ||
| 578 | _GL_ARG_NONNULL ((1))); | ||
| 579 | # endif | ||
| 580 | _GL_CXXALIAS_SYS (getdomainname, int, (char *name, size_t len)); | ||
| 581 | # endif | ||
| 582 | _GL_CXXALIASWARN (getdomainname); | ||
| 583 | #elif defined GNULIB_POSIXCHECK | ||
| 584 | # undef getdomainname | ||
| 585 | # if HAVE_RAW_DECL_GETDOMAINNAME | ||
| 586 | _GL_WARN_ON_USE (getdomainname, "getdomainname is unportable - " | ||
| 587 | "use gnulib module getdomainname for portability"); | ||
| 588 | # endif | ||
| 589 | #endif | ||
| 590 | |||
| 591 | |||
| 592 | #if @GNULIB_GETDTABLESIZE@ | ||
| 593 | /* Return the maximum number of file descriptors in the current process. | ||
| 594 | In POSIX, this is same as sysconf (_SC_OPEN_MAX). */ | ||
| 595 | # if !@HAVE_GETDTABLESIZE@ | ||
| 596 | _GL_FUNCDECL_SYS (getdtablesize, int, (void)); | ||
| 597 | # endif | ||
| 598 | _GL_CXXALIAS_SYS (getdtablesize, int, (void)); | ||
| 599 | _GL_CXXALIASWARN (getdtablesize); | ||
| 600 | #elif defined GNULIB_POSIXCHECK | ||
| 601 | # undef getdtablesize | ||
| 602 | # if HAVE_RAW_DECL_GETDTABLESIZE | ||
| 603 | _GL_WARN_ON_USE (getdtablesize, "getdtablesize is unportable - " | ||
| 604 | "use gnulib module getdtablesize for portability"); | ||
| 605 | # endif | ||
| 606 | #endif | ||
| 607 | |||
| 608 | |||
| 609 | #if @GNULIB_GETGROUPS@ | ||
| 610 | /* Return the supplemental groups that the current process belongs to. | ||
| 611 | It is unspecified whether the effective group id is in the list. | ||
| 612 | If N is 0, return the group count; otherwise, N describes how many | ||
| 613 | entries are available in GROUPS. Return -1 and set errno if N is | ||
| 614 | not 0 and not large enough. Fails with ENOSYS on some systems. */ | ||
| 615 | # if @REPLACE_GETGROUPS@ | ||
| 616 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||
| 617 | # undef getgroups | ||
| 618 | # define getgroups rpl_getgroups | ||
| 619 | # endif | ||
| 620 | _GL_FUNCDECL_RPL (getgroups, int, (int n, gid_t *groups)); | ||
| 621 | _GL_CXXALIAS_RPL (getgroups, int, (int n, gid_t *groups)); | ||
| 622 | # else | ||
| 623 | # if !@HAVE_GETGROUPS@ | ||
| 624 | _GL_FUNCDECL_SYS (getgroups, int, (int n, gid_t *groups)); | ||
| 625 | # endif | ||
| 626 | _GL_CXXALIAS_SYS (getgroups, int, (int n, gid_t *groups)); | ||
| 627 | # endif | ||
| 628 | _GL_CXXALIASWARN (getgroups); | ||
| 629 | #elif defined GNULIB_POSIXCHECK | ||
| 630 | # undef getgroups | ||
| 631 | # if HAVE_RAW_DECL_GETGROUPS | ||
| 632 | _GL_WARN_ON_USE (getgroups, "getgroups is unportable - " | ||
| 633 | "use gnulib module getgroups for portability"); | ||
| 634 | # endif | ||
| 635 | #endif | ||
| 636 | |||
| 637 | |||
| 638 | #if @GNULIB_GETHOSTNAME@ | ||
| 639 | /* Return the standard host name of the machine. | ||
| 640 | WARNING! The host name may or may not be fully qualified. | ||
| 641 | |||
| 642 | Put up to LEN bytes of the host name into NAME. | ||
| 643 | Null terminate it if the name is shorter than LEN. | ||
| 644 | If the host name is longer than LEN, set errno = EINVAL and return -1. | ||
| 645 | Return 0 if successful, otherwise set errno and return -1. */ | ||
| 646 | # if @UNISTD_H_HAVE_WINSOCK2_H@ | ||
| 647 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||
| 648 | # undef gethostname | ||
| 649 | # define gethostname rpl_gethostname | ||
| 650 | # endif | ||
| 651 | _GL_FUNCDECL_RPL (gethostname, int, (char *name, size_t len) | ||
| 652 | _GL_ARG_NONNULL ((1))); | ||
| 653 | _GL_CXXALIAS_RPL (gethostname, int, (char *name, size_t len)); | ||
| 654 | # else | ||
| 655 | # if !@HAVE_GETHOSTNAME@ | ||
| 656 | _GL_FUNCDECL_SYS (gethostname, int, (char *name, size_t len) | ||
| 657 | _GL_ARG_NONNULL ((1))); | ||
| 658 | # endif | ||
| 659 | /* Need to cast, because on Solaris 10 and OSF/1 5.1 systems, the second | ||
| 660 | parameter is | ||
| 661 | int len. */ | ||
| 662 | _GL_CXXALIAS_SYS_CAST (gethostname, int, (char *name, size_t len)); | ||
| 663 | # endif | ||
| 664 | _GL_CXXALIASWARN (gethostname); | ||
| 665 | #elif @UNISTD_H_HAVE_WINSOCK2_H@ | ||
| 666 | # undef gethostname | ||
| 667 | # define gethostname gethostname_used_without_requesting_gnulib_module_gethostname | ||
| 668 | #elif defined GNULIB_POSIXCHECK | ||
| 669 | # undef gethostname | ||
| 670 | # if HAVE_RAW_DECL_GETHOSTNAME | ||
| 671 | _GL_WARN_ON_USE (gethostname, "gethostname is unportable - " | ||
| 672 | "use gnulib module gethostname for portability"); | ||
| 673 | # endif | ||
| 674 | #endif | ||
| 675 | |||
| 676 | |||
| 677 | #if @GNULIB_GETLOGIN@ | ||
| 678 | /* Returns the user's login name, or NULL if it cannot be found. Upon error, | ||
| 679 | returns NULL with errno set. | ||
| 680 | |||
| 681 | See <http://www.opengroup.org/susv3xsh/getlogin.html>. | ||
| 682 | |||
| 683 | Most programs don't need to use this function, because the information is | ||
| 684 | available through environment variables: | ||
| 685 | ${LOGNAME-$USER} on Unix platforms, | ||
| 686 | $USERNAME on native Windows platforms. | ||
| 687 | */ | ||
| 688 | # if !@HAVE_GETLOGIN@ | ||
| 689 | _GL_FUNCDECL_SYS (getlogin, char *, (void)); | ||
| 690 | # endif | ||
| 691 | _GL_CXXALIAS_SYS (getlogin, char *, (void)); | ||
| 692 | _GL_CXXALIASWARN (getlogin); | ||
| 693 | #elif defined GNULIB_POSIXCHECK | ||
| 694 | # undef getlogin | ||
| 695 | # if HAVE_RAW_DECL_GETLOGIN | ||
| 696 | _GL_WARN_ON_USE (getlogin, "getlogin is unportable - " | ||
| 697 | "use gnulib module getlogin for portability"); | ||
| 698 | # endif | ||
| 699 | #endif | ||
| 700 | |||
| 701 | |||
| 702 | #if @GNULIB_GETLOGIN_R@ | ||
| 703 | /* Copies the user's login name to NAME. | ||
| 704 | The array pointed to by NAME has room for SIZE bytes. | ||
| 705 | |||
| 706 | Returns 0 if successful. Upon error, an error number is returned, or -1 in | ||
| 707 | the case that the login name cannot be found but no specific error is | ||
| 708 | provided (this case is hopefully rare but is left open by the POSIX spec). | ||
| 709 | |||
| 710 | See <http://www.opengroup.org/susv3xsh/getlogin.html>. | ||
| 711 | |||
| 712 | Most programs don't need to use this function, because the information is | ||
| 713 | available through environment variables: | ||
| 714 | ${LOGNAME-$USER} on Unix platforms, | ||
| 715 | $USERNAME on native Windows platforms. | ||
| 716 | */ | ||
| 717 | # if @REPLACE_GETLOGIN_R@ | ||
| 718 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||
| 719 | # define getlogin_r rpl_getlogin_r | ||
| 720 | # endif | ||
| 721 | _GL_FUNCDECL_RPL (getlogin_r, int, (char *name, size_t size) | ||
| 722 | _GL_ARG_NONNULL ((1))); | ||
| 723 | _GL_CXXALIAS_RPL (getlogin_r, int, (char *name, size_t size)); | ||
| 724 | # else | ||
| 725 | # if !@HAVE_DECL_GETLOGIN_R@ | ||
| 726 | _GL_FUNCDECL_SYS (getlogin_r, int, (char *name, size_t size) | ||
| 727 | _GL_ARG_NONNULL ((1))); | ||
| 728 | # endif | ||
| 729 | /* Need to cast, because on Solaris 10 systems, the second argument is | ||
| 730 | int size. */ | ||
| 731 | _GL_CXXALIAS_SYS_CAST (getlogin_r, int, (char *name, size_t size)); | ||
| 732 | # endif | ||
| 733 | _GL_CXXALIASWARN (getlogin_r); | ||
| 734 | #elif defined GNULIB_POSIXCHECK | ||
| 735 | # undef getlogin_r | ||
| 736 | # if HAVE_RAW_DECL_GETLOGIN_R | ||
| 737 | _GL_WARN_ON_USE (getlogin_r, "getlogin_r is unportable - " | ||
| 738 | "use gnulib module getlogin_r for portability"); | ||
| 739 | # endif | ||
| 740 | #endif | ||
| 741 | |||
| 742 | |||
| 743 | #if @GNULIB_GETPAGESIZE@ | ||
| 744 | # if @REPLACE_GETPAGESIZE@ | ||
| 745 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||
| 746 | # define getpagesize rpl_getpagesize | ||
| 747 | # endif | ||
| 748 | _GL_FUNCDECL_RPL (getpagesize, int, (void)); | ||
| 749 | _GL_CXXALIAS_RPL (getpagesize, int, (void)); | ||
| 750 | # else | ||
| 751 | # if !@HAVE_GETPAGESIZE@ | ||
| 752 | # if !defined getpagesize | ||
| 753 | /* This is for POSIX systems. */ | ||
| 754 | # if !defined _gl_getpagesize && defined _SC_PAGESIZE | ||
| 755 | # if ! (defined __VMS && __VMS_VER < 70000000) | ||
| 756 | # define _gl_getpagesize() sysconf (_SC_PAGESIZE) | ||
| 757 | # endif | ||
| 758 | # endif | ||
| 759 | /* This is for older VMS. */ | ||
| 760 | # if !defined _gl_getpagesize && defined __VMS | ||
| 761 | # ifdef __ALPHA | ||
| 762 | # define _gl_getpagesize() 8192 | ||
| 763 | # else | ||
| 764 | # define _gl_getpagesize() 512 | ||
| 765 | # endif | ||
| 766 | # endif | ||
| 767 | /* This is for BeOS. */ | ||
| 768 | # if !defined _gl_getpagesize && @HAVE_OS_H@ | ||
| 769 | # include <OS.h> | ||
| 770 | # if defined B_PAGE_SIZE | ||
| 771 | # define _gl_getpagesize() B_PAGE_SIZE | ||
| 772 | # endif | ||
| 773 | # endif | ||
| 774 | /* This is for AmigaOS4.0. */ | ||
| 775 | # if !defined _gl_getpagesize && defined __amigaos4__ | ||
| 776 | # define _gl_getpagesize() 2048 | ||
| 777 | # endif | ||
| 778 | /* This is for older Unix systems. */ | ||
| 779 | # if !defined _gl_getpagesize && @HAVE_SYS_PARAM_H@ | ||
| 780 | # include <sys/param.h> | ||
| 781 | # ifdef EXEC_PAGESIZE | ||
| 782 | # define _gl_getpagesize() EXEC_PAGESIZE | ||
| 783 | # else | ||
| 784 | # ifdef NBPG | ||
| 785 | # ifndef CLSIZE | ||
| 786 | # define CLSIZE 1 | ||
| 787 | # endif | ||
| 788 | # define _gl_getpagesize() (NBPG * CLSIZE) | ||
| 789 | # else | ||
| 790 | # ifdef NBPC | ||
| 791 | # define _gl_getpagesize() NBPC | ||
| 792 | # endif | ||
| 793 | # endif | ||
| 794 | # endif | ||
| 795 | # endif | ||
| 796 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||
| 797 | # define getpagesize() _gl_getpagesize () | ||
| 798 | # else | ||
| 799 | static inline int | ||
| 800 | getpagesize () | ||
| 801 | { | ||
| 802 | return _gl_getpagesize (); | ||
| 803 | } | ||
| 804 | # endif | ||
| 805 | # endif | ||
| 806 | # endif | ||
| 807 | /* Need to cast, because on Cygwin 1.5.x systems, the return type is size_t. */ | ||
| 808 | _GL_CXXALIAS_SYS_CAST (getpagesize, int, (void)); | ||
| 809 | # endif | ||
| 810 | # if @HAVE_DECL_GETPAGESIZE@ | ||
| 811 | _GL_CXXALIASWARN (getpagesize); | ||
| 812 | # endif | ||
| 813 | #elif defined GNULIB_POSIXCHECK | ||
| 814 | # undef getpagesize | ||
| 815 | # if HAVE_RAW_DECL_GETPAGESIZE | ||
| 816 | _GL_WARN_ON_USE (getpagesize, "getpagesize is unportable - " | ||
| 817 | "use gnulib module getpagesize for portability"); | ||
| 818 | # endif | ||
| 819 | #endif | ||
| 820 | |||
| 821 | |||
| 822 | #if @GNULIB_GETUSERSHELL@ | ||
| 823 | /* Return the next valid login shell on the system, or NULL when the end of | ||
| 824 | the list has been reached. */ | ||
| 825 | # if !@HAVE_DECL_GETUSERSHELL@ | ||
| 826 | _GL_FUNCDECL_SYS (getusershell, char *, (void)); | ||
| 827 | # endif | ||
| 828 | _GL_CXXALIAS_SYS (getusershell, char *, (void)); | ||
| 829 | _GL_CXXALIASWARN (getusershell); | ||
| 830 | #elif defined GNULIB_POSIXCHECK | ||
| 831 | # undef getusershell | ||
| 832 | # if HAVE_RAW_DECL_GETUSERSHELL | ||
| 833 | _GL_WARN_ON_USE (getusershell, "getusershell is unportable - " | ||
| 834 | "use gnulib module getusershell for portability"); | ||
| 835 | # endif | ||
| 836 | #endif | ||
| 837 | |||
| 838 | #if @GNULIB_GETUSERSHELL@ | ||
| 839 | /* Rewind to pointer that is advanced at each getusershell() call. */ | ||
| 840 | # if !@HAVE_DECL_GETUSERSHELL@ | ||
| 841 | _GL_FUNCDECL_SYS (setusershell, void, (void)); | ||
| 842 | # endif | ||
| 843 | _GL_CXXALIAS_SYS (setusershell, void, (void)); | ||
| 844 | _GL_CXXALIASWARN (setusershell); | ||
| 845 | #elif defined GNULIB_POSIXCHECK | ||
| 846 | # undef setusershell | ||
| 847 | # if HAVE_RAW_DECL_SETUSERSHELL | ||
| 848 | _GL_WARN_ON_USE (setusershell, "setusershell is unportable - " | ||
| 849 | "use gnulib module getusershell for portability"); | ||
| 850 | # endif | ||
| 851 | #endif | ||
| 852 | |||
| 853 | #if @GNULIB_GETUSERSHELL@ | ||
| 854 | /* Free the pointer that is advanced at each getusershell() call and | ||
| 855 | associated resources. */ | ||
| 856 | # if !@HAVE_DECL_GETUSERSHELL@ | ||
| 857 | _GL_FUNCDECL_SYS (endusershell, void, (void)); | ||
| 858 | # endif | ||
| 859 | _GL_CXXALIAS_SYS (endusershell, void, (void)); | ||
| 860 | _GL_CXXALIASWARN (endusershell); | ||
| 861 | #elif defined GNULIB_POSIXCHECK | ||
| 862 | # undef endusershell | ||
| 863 | # if HAVE_RAW_DECL_ENDUSERSHELL | ||
| 864 | _GL_WARN_ON_USE (endusershell, "endusershell is unportable - " | ||
| 865 | "use gnulib module getusershell for portability"); | ||
| 866 | # endif | ||
| 867 | #endif | ||
| 868 | |||
| 869 | |||
| 870 | #if @GNULIB_LCHOWN@ | ||
| 871 | /* Change the owner of FILE to UID (if UID is not -1) and the group of FILE | ||
| 872 | to GID (if GID is not -1). Do not follow symbolic links. | ||
| 873 | Return 0 if successful, otherwise -1 and errno set. | ||
| 874 | See the POSIX:2001 specification | ||
| 875 | <http://www.opengroup.org/susv3xsh/lchown.html>. */ | ||
| 876 | # if @REPLACE_LCHOWN@ | ||
| 877 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||
| 878 | # undef lchown | ||
| 879 | # define lchown rpl_lchown | ||
| 880 | # endif | ||
| 881 | _GL_FUNCDECL_RPL (lchown, int, (char const *file, uid_t owner, gid_t group) | ||
| 882 | _GL_ARG_NONNULL ((1))); | ||
| 883 | _GL_CXXALIAS_RPL (lchown, int, (char const *file, uid_t owner, gid_t group)); | ||
| 884 | # else | ||
| 885 | # if !@HAVE_LCHOWN@ | ||
| 886 | _GL_FUNCDECL_SYS (lchown, int, (char const *file, uid_t owner, gid_t group) | ||
| 887 | _GL_ARG_NONNULL ((1))); | ||
| 888 | # endif | ||
| 889 | _GL_CXXALIAS_SYS (lchown, int, (char const *file, uid_t owner, gid_t group)); | ||
| 890 | # endif | ||
| 891 | _GL_CXXALIASWARN (lchown); | ||
| 892 | #elif defined GNULIB_POSIXCHECK | ||
| 893 | # undef lchown | ||
| 894 | # if HAVE_RAW_DECL_LCHOWN | ||
| 895 | _GL_WARN_ON_USE (lchown, "lchown is unportable to pre-POSIX.1-2001 systems - " | ||
| 896 | "use gnulib module lchown for portability"); | ||
| 897 | # endif | ||
| 898 | #endif | ||
| 899 | |||
| 900 | |||
| 901 | #if @GNULIB_LINK@ | ||
| 902 | /* Create a new hard link for an existing file. | ||
| 903 | Return 0 if successful, otherwise -1 and errno set. | ||
| 904 | See POSIX:2001 specification | ||
| 905 | <http://www.opengroup.org/susv3xsh/link.html>. */ | ||
| 906 | # if @REPLACE_LINK@ | ||
| 907 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||
| 908 | # define link rpl_link | ||
| 909 | # endif | ||
| 910 | _GL_FUNCDECL_RPL (link, int, (const char *path1, const char *path2) | ||
| 911 | _GL_ARG_NONNULL ((1, 2))); | ||
| 912 | _GL_CXXALIAS_RPL (link, int, (const char *path1, const char *path2)); | ||
| 913 | # else | ||
| 914 | # if !@HAVE_LINK@ | ||
| 915 | _GL_FUNCDECL_SYS (link, int, (const char *path1, const char *path2) | ||
| 916 | _GL_ARG_NONNULL ((1, 2))); | ||
| 917 | # endif | ||
| 918 | _GL_CXXALIAS_SYS (link, int, (const char *path1, const char *path2)); | ||
| 919 | # endif | ||
| 920 | _GL_CXXALIASWARN (link); | ||
| 921 | #elif defined GNULIB_POSIXCHECK | ||
| 922 | # undef link | ||
| 923 | # if HAVE_RAW_DECL_LINK | ||
| 924 | _GL_WARN_ON_USE (link, "link is unportable - " | ||
| 925 | "use gnulib module link for portability"); | ||
| 926 | # endif | ||
| 927 | #endif | ||
| 928 | |||
| 929 | |||
| 930 | #if @GNULIB_LINKAT@ | ||
| 931 | /* Create a new hard link for an existing file, relative to two | ||
| 932 | directories. FLAG controls whether symlinks are followed. | ||
| 933 | Return 0 if successful, otherwise -1 and errno set. */ | ||
| 934 | # if @REPLACE_LINKAT@ | ||
| 935 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||
| 936 | # undef linkat | ||
| 937 | # define linkat rpl_linkat | ||
| 938 | # endif | ||
| 939 | _GL_FUNCDECL_RPL (linkat, int, | ||
| 940 | (int fd1, const char *path1, int fd2, const char *path2, | ||
| 941 | int flag) | ||
| 942 | _GL_ARG_NONNULL ((2, 4))); | ||
| 943 | _GL_CXXALIAS_RPL (linkat, int, | ||
| 944 | (int fd1, const char *path1, int fd2, const char *path2, | ||
| 945 | int flag)); | ||
| 946 | # else | ||
| 947 | # if !@HAVE_LINKAT@ | ||
| 948 | _GL_FUNCDECL_SYS (linkat, int, | ||
| 949 | (int fd1, const char *path1, int fd2, const char *path2, | ||
| 950 | int flag) | ||
| 951 | _GL_ARG_NONNULL ((2, 4))); | ||
| 952 | # endif | ||
| 953 | _GL_CXXALIAS_SYS (linkat, int, | ||
| 954 | (int fd1, const char *path1, int fd2, const char *path2, | ||
| 955 | int flag)); | ||
| 956 | # endif | ||
| 957 | _GL_CXXALIASWARN (linkat); | ||
| 958 | #elif defined GNULIB_POSIXCHECK | ||
| 959 | # undef linkat | ||
| 960 | # if HAVE_RAW_DECL_LINKAT | ||
| 961 | _GL_WARN_ON_USE (linkat, "linkat is unportable - " | ||
| 962 | "use gnulib module linkat for portability"); | ||
| 963 | # endif | ||
| 964 | #endif | ||
| 965 | |||
| 966 | |||
| 967 | #if @GNULIB_LSEEK@ | ||
| 968 | /* Set the offset of FD relative to SEEK_SET, SEEK_CUR, or SEEK_END. | ||
| 969 | Return the new offset if successful, otherwise -1 and errno set. | ||
| 970 | See the POSIX:2001 specification | ||
| 971 | <http://www.opengroup.org/susv3xsh/lseek.html>. */ | ||
| 972 | # if @REPLACE_LSEEK@ | ||
| 973 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||
| 974 | # define lseek rpl_lseek | ||
| 975 | # endif | ||
| 976 | _GL_FUNCDECL_RPL (lseek, off_t, (int fd, off_t offset, int whence)); | ||
| 977 | _GL_CXXALIAS_RPL (lseek, off_t, (int fd, off_t offset, int whence)); | ||
| 978 | # else | ||
| 979 | _GL_CXXALIAS_SYS (lseek, off_t, (int fd, off_t offset, int whence)); | ||
| 980 | # endif | ||
| 981 | _GL_CXXALIASWARN (lseek); | ||
| 982 | #elif defined GNULIB_POSIXCHECK | ||
| 983 | # undef lseek | ||
| 984 | # if HAVE_RAW_DECL_LSEEK | ||
| 985 | _GL_WARN_ON_USE (lseek, "lseek does not fail with ESPIPE on pipes on some " | ||
| 986 | "systems - use gnulib module lseek for portability"); | ||
| 987 | # endif | ||
| 988 | #endif | ||
| 989 | |||
| 990 | |||
| 991 | #if @GNULIB_PIPE@ | ||
| 992 | /* Create a pipe, defaulting to O_BINARY mode. | ||
| 993 | Store the read-end as fd[0] and the write-end as fd[1]. | ||
| 994 | Return 0 upon success, or -1 with errno set upon failure. */ | ||
| 995 | # if !@HAVE_PIPE@ | ||
| 996 | _GL_FUNCDECL_SYS (pipe, int, (int fd[2]) _GL_ARG_NONNULL ((1))); | ||
| 997 | # endif | ||
| 998 | _GL_CXXALIAS_SYS (pipe, int, (int fd[2])); | ||
| 999 | _GL_CXXALIASWARN (pipe); | ||
| 1000 | #elif defined GNULIB_POSIXCHECK | ||
| 1001 | # undef pipe | ||
| 1002 | # if HAVE_RAW_DECL_PIPE | ||
| 1003 | _GL_WARN_ON_USE (pipe, "pipe is unportable - " | ||
| 1004 | "use gnulib module pipe-posix for portability"); | ||
| 1005 | # endif | ||
| 1006 | #endif | ||
| 1007 | |||
| 1008 | |||
| 1009 | #if @GNULIB_PIPE2@ | ||
| 1010 | /* Create a pipe, applying the given flags when opening the read-end of the | ||
| 1011 | pipe and the write-end of the pipe. | ||
| 1012 | The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>) | ||
| 1013 | and O_TEXT, O_BINARY (defined in "binary-io.h"). | ||
| 1014 | Store the read-end as fd[0] and the write-end as fd[1]. | ||
| 1015 | Return 0 upon success, or -1 with errno set upon failure. | ||
| 1016 | See also the Linux man page at | ||
| 1017 | <http://www.kernel.org/doc/man-pages/online/pages/man2/pipe2.2.html>. */ | ||
| 1018 | # if @HAVE_PIPE2@ | ||
| 1019 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||
| 1020 | # define pipe2 rpl_pipe2 | ||
| 1021 | # endif | ||
| 1022 | _GL_FUNCDECL_RPL (pipe2, int, (int fd[2], int flags) _GL_ARG_NONNULL ((1))); | ||
| 1023 | _GL_CXXALIAS_RPL (pipe2, int, (int fd[2], int flags)); | ||
| 1024 | # else | ||
| 1025 | _GL_FUNCDECL_SYS (pipe2, int, (int fd[2], int flags) _GL_ARG_NONNULL ((1))); | ||
| 1026 | _GL_CXXALIAS_SYS (pipe2, int, (int fd[2], int flags)); | ||
| 1027 | # endif | ||
| 1028 | _GL_CXXALIASWARN (pipe2); | ||
| 1029 | #elif defined GNULIB_POSIXCHECK | ||
| 1030 | # undef pipe2 | ||
| 1031 | # if HAVE_RAW_DECL_PIPE2 | ||
| 1032 | _GL_WARN_ON_USE (pipe2, "pipe2 is unportable - " | ||
| 1033 | "use gnulib module pipe2 for portability"); | ||
| 1034 | # endif | ||
| 1035 | #endif | ||
| 1036 | |||
| 1037 | |||
| 1038 | #if @GNULIB_PREAD@ | ||
| 1039 | /* Read at most BUFSIZE bytes from FD into BUF, starting at OFFSET. | ||
| 1040 | Return the number of bytes placed into BUF if successful, otherwise | ||
| 1041 | set errno and return -1. 0 indicates EOF. See the POSIX:2001 | ||
| 1042 | specification <http://www.opengroup.org/susv3xsh/pread.html>. */ | ||
| 1043 | # if @REPLACE_PREAD@ | ||
| 1044 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||
| 1045 | # define pread rpl_pread | ||
| 1046 | # endif | ||
| 1047 | _GL_FUNCDECL_RPL (pread, ssize_t, | ||
| 1048 | (int fd, void *buf, size_t bufsize, off_t offset) | ||
| 1049 | _GL_ARG_NONNULL ((2))); | ||
| 1050 | _GL_CXXALIAS_RPL (pread, ssize_t, | ||
| 1051 | (int fd, void *buf, size_t bufsize, off_t offset)); | ||
| 1052 | # else | ||
| 1053 | # if !@HAVE_PREAD@ | ||
| 1054 | _GL_FUNCDECL_SYS (pread, ssize_t, | ||
| 1055 | (int fd, void *buf, size_t bufsize, off_t offset) | ||
| 1056 | _GL_ARG_NONNULL ((2))); | ||
| 1057 | # endif | ||
| 1058 | _GL_CXXALIAS_SYS (pread, ssize_t, | ||
| 1059 | (int fd, void *buf, size_t bufsize, off_t offset)); | ||
| 1060 | # endif | ||
| 1061 | _GL_CXXALIASWARN (pread); | ||
| 1062 | #elif defined GNULIB_POSIXCHECK | ||
| 1063 | # undef pread | ||
| 1064 | # if HAVE_RAW_DECL_PREAD | ||
| 1065 | _GL_WARN_ON_USE (pread, "pread is unportable - " | ||
| 1066 | "use gnulib module pread for portability"); | ||
| 1067 | # endif | ||
| 1068 | #endif | ||
| 1069 | |||
| 1070 | |||
| 1071 | #if @GNULIB_PWRITE@ | ||
| 1072 | /* Write at most BUFSIZE bytes from BUF into FD, starting at OFFSET. | ||
| 1073 | Return the number of bytes written if successful, otherwise | ||
| 1074 | set errno and return -1. 0 indicates nothing written. See the | ||
| 1075 | POSIX:2001 specification | ||
| 1076 | <http://www.opengroup.org/susv3xsh/pwrite.html>. */ | ||
| 1077 | # if @REPLACE_PWRITE@ | ||
| 1078 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||
| 1079 | # define pwrite rpl_pwrite | ||
| 1080 | # endif | ||
| 1081 | _GL_FUNCDECL_RPL (pwrite, ssize_t, | ||
| 1082 | (int fd, const void *buf, size_t bufsize, off_t offset) | ||
| 1083 | _GL_ARG_NONNULL ((2))); | ||
| 1084 | _GL_CXXALIAS_RPL (pwrite, ssize_t, | ||
| 1085 | (int fd, const void *buf, size_t bufsize, off_t offset)); | ||
| 1086 | # else | ||
| 1087 | # if !@HAVE_PWRITE@ | ||
| 1088 | _GL_FUNCDECL_SYS (pwrite, ssize_t, | ||
| 1089 | (int fd, const void *buf, size_t bufsize, off_t offset) | ||
| 1090 | _GL_ARG_NONNULL ((2))); | ||
| 1091 | # endif | ||
| 1092 | _GL_CXXALIAS_SYS (pwrite, ssize_t, | ||
| 1093 | (int fd, const void *buf, size_t bufsize, off_t offset)); | ||
| 1094 | # endif | ||
| 1095 | _GL_CXXALIASWARN (pwrite); | ||
| 1096 | #elif defined GNULIB_POSIXCHECK | ||
| 1097 | # undef pwrite | ||
| 1098 | # if HAVE_RAW_DECL_PWRITE | ||
| 1099 | _GL_WARN_ON_USE (pwrite, "pwrite is unportable - " | ||
| 1100 | "use gnulib module pwrite for portability"); | ||
| 1101 | # endif | ||
| 1102 | #endif | ||
| 1103 | |||
| 1104 | |||
| 1105 | #if @GNULIB_READLINK@ | ||
| 1106 | /* Read the contents of the symbolic link FILE and place the first BUFSIZE | ||
| 1107 | bytes of it into BUF. Return the number of bytes placed into BUF if | ||
| 1108 | successful, otherwise -1 and errno set. | ||
| 1109 | See the POSIX:2001 specification | ||
| 1110 | <http://www.opengroup.org/susv3xsh/readlink.html>. */ | ||
| 1111 | # if @REPLACE_READLINK@ | ||
| 1112 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||
| 1113 | # define readlink rpl_readlink | ||
| 1114 | # endif | ||
| 1115 | _GL_FUNCDECL_RPL (readlink, ssize_t, | ||
| 1116 | (const char *file, char *buf, size_t bufsize) | ||
| 1117 | _GL_ARG_NONNULL ((1, 2))); | ||
| 1118 | _GL_CXXALIAS_RPL (readlink, ssize_t, | ||
| 1119 | (const char *file, char *buf, size_t bufsize)); | ||
| 1120 | # else | ||
| 1121 | # if !@HAVE_READLINK@ | ||
| 1122 | _GL_FUNCDECL_SYS (readlink, ssize_t, | ||
| 1123 | (const char *file, char *buf, size_t bufsize) | ||
| 1124 | _GL_ARG_NONNULL ((1, 2))); | ||
| 1125 | # endif | ||
| 1126 | _GL_CXXALIAS_SYS (readlink, ssize_t, | ||
| 1127 | (const char *file, char *buf, size_t bufsize)); | ||
| 1128 | # endif | ||
| 1129 | _GL_CXXALIASWARN (readlink); | ||
| 1130 | #elif defined GNULIB_POSIXCHECK | ||
| 1131 | # undef readlink | ||
| 1132 | # if HAVE_RAW_DECL_READLINK | ||
| 1133 | _GL_WARN_ON_USE (readlink, "readlink is unportable - " | ||
| 1134 | "use gnulib module readlink for portability"); | ||
| 1135 | # endif | ||
| 1136 | #endif | ||
| 1137 | |||
| 1138 | |||
| 1139 | #if @GNULIB_READLINKAT@ | ||
| 1140 | # if !@HAVE_READLINKAT@ | ||
| 1141 | _GL_FUNCDECL_SYS (readlinkat, ssize_t, | ||
| 1142 | (int fd, char const *file, char *buf, size_t len) | ||
| 1143 | _GL_ARG_NONNULL ((2, 3))); | ||
| 1144 | # endif | ||
| 1145 | _GL_CXXALIAS_SYS (readlinkat, ssize_t, | ||
| 1146 | (int fd, char const *file, char *buf, size_t len)); | ||
| 1147 | _GL_CXXALIASWARN (readlinkat); | ||
| 1148 | #elif defined GNULIB_POSIXCHECK | ||
| 1149 | # undef readlinkat | ||
| 1150 | # if HAVE_RAW_DECL_READLINKAT | ||
| 1151 | _GL_WARN_ON_USE (readlinkat, "readlinkat is not portable - " | ||
| 1152 | "use gnulib module readlinkat for portability"); | ||
| 1153 | # endif | ||
| 1154 | #endif | ||
| 1155 | |||
| 1156 | |||
| 1157 | #if @GNULIB_RMDIR@ | ||
| 1158 | /* Remove the directory DIR. */ | ||
| 1159 | # if @REPLACE_RMDIR@ | ||
| 1160 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||
| 1161 | # define rmdir rpl_rmdir | ||
| 1162 | # endif | ||
| 1163 | _GL_FUNCDECL_RPL (rmdir, int, (char const *name) _GL_ARG_NONNULL ((1))); | ||
| 1164 | _GL_CXXALIAS_RPL (rmdir, int, (char const *name)); | ||
| 1165 | # else | ||
| 1166 | _GL_CXXALIAS_SYS (rmdir, int, (char const *name)); | ||
| 1167 | # endif | ||
| 1168 | _GL_CXXALIASWARN (rmdir); | ||
| 1169 | #elif defined GNULIB_POSIXCHECK | ||
| 1170 | # undef rmdir | ||
| 1171 | # if HAVE_RAW_DECL_RMDIR | ||
| 1172 | _GL_WARN_ON_USE (rmdir, "rmdir is unportable - " | ||
| 1173 | "use gnulib module rmdir for portability"); | ||
| 1174 | # endif | ||
| 1175 | #endif | ||
| 1176 | |||
| 1177 | |||
| 1178 | #if @GNULIB_SLEEP@ | ||
| 1179 | /* Pause the execution of the current thread for N seconds. | ||
| 1180 | Returns the number of seconds left to sleep. | ||
| 1181 | See the POSIX:2001 specification | ||
| 1182 | <http://www.opengroup.org/susv3xsh/sleep.html>. */ | ||
| 1183 | # if @REPLACE_SLEEP@ | ||
| 1184 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||
| 1185 | # undef sleep | ||
| 1186 | # define sleep rpl_sleep | ||
| 1187 | # endif | ||
| 1188 | _GL_FUNCDECL_RPL (sleep, unsigned int, (unsigned int n)); | ||
| 1189 | _GL_CXXALIAS_RPL (sleep, unsigned int, (unsigned int n)); | ||
| 1190 | # else | ||
| 1191 | # if !@HAVE_SLEEP@ | ||
| 1192 | _GL_FUNCDECL_SYS (sleep, unsigned int, (unsigned int n)); | ||
| 1193 | # endif | ||
| 1194 | _GL_CXXALIAS_SYS (sleep, unsigned int, (unsigned int n)); | ||
| 1195 | # endif | ||
| 1196 | _GL_CXXALIASWARN (sleep); | ||
| 1197 | #elif defined GNULIB_POSIXCHECK | ||
| 1198 | # undef sleep | ||
| 1199 | # if HAVE_RAW_DECL_SLEEP | ||
| 1200 | _GL_WARN_ON_USE (sleep, "sleep is unportable - " | ||
| 1201 | "use gnulib module sleep for portability"); | ||
| 1202 | # endif | ||
| 1203 | #endif | ||
| 1204 | |||
| 1205 | |||
| 1206 | #if @GNULIB_SYMLINK@ | ||
| 1207 | # if @REPLACE_SYMLINK@ | ||
| 1208 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||
| 1209 | # undef symlink | ||
| 1210 | # define symlink rpl_symlink | ||
| 1211 | # endif | ||
| 1212 | _GL_FUNCDECL_RPL (symlink, int, (char const *contents, char const *file) | ||
| 1213 | _GL_ARG_NONNULL ((1, 2))); | ||
| 1214 | _GL_CXXALIAS_RPL (symlink, int, (char const *contents, char const *file)); | ||
| 1215 | # else | ||
| 1216 | # if !@HAVE_SYMLINK@ | ||
| 1217 | _GL_FUNCDECL_SYS (symlink, int, (char const *contents, char const *file) | ||
| 1218 | _GL_ARG_NONNULL ((1, 2))); | ||
| 1219 | # endif | ||
| 1220 | _GL_CXXALIAS_SYS (symlink, int, (char const *contents, char const *file)); | ||
| 1221 | # endif | ||
| 1222 | _GL_CXXALIASWARN (symlink); | ||
| 1223 | #elif defined GNULIB_POSIXCHECK | ||
| 1224 | # undef symlink | ||
| 1225 | # if HAVE_RAW_DECL_SYMLINK | ||
| 1226 | _GL_WARN_ON_USE (symlink, "symlink is not portable - " | ||
| 1227 | "use gnulib module symlink for portability"); | ||
| 1228 | # endif | ||
| 1229 | #endif | ||
| 1230 | |||
| 1231 | |||
| 1232 | #if @GNULIB_SYMLINKAT@ | ||
| 1233 | # if !@HAVE_SYMLINKAT@ | ||
| 1234 | _GL_FUNCDECL_SYS (symlinkat, int, | ||
| 1235 | (char const *contents, int fd, char const *file) | ||
| 1236 | _GL_ARG_NONNULL ((1, 3))); | ||
| 1237 | # endif | ||
| 1238 | _GL_CXXALIAS_SYS (symlinkat, int, | ||
| 1239 | (char const *contents, int fd, char const *file)); | ||
| 1240 | _GL_CXXALIASWARN (symlinkat); | ||
| 1241 | #elif defined GNULIB_POSIXCHECK | ||
| 1242 | # undef symlinkat | ||
| 1243 | # if HAVE_RAW_DECL_SYMLINKAT | ||
| 1244 | _GL_WARN_ON_USE (symlinkat, "symlinkat is not portable - " | ||
| 1245 | "use gnulib module symlinkat for portability"); | ||
| 1246 | # endif | ||
| 1247 | #endif | ||
| 1248 | |||
| 1249 | |||
| 1250 | #if @GNULIB_TTYNAME_R@ | ||
| 1251 | /* Store at most BUFLEN characters of the pathname of the terminal FD is | ||
| 1252 | open on in BUF. Return 0 on success, otherwise an error number. */ | ||
| 1253 | # if @REPLACE_TTYNAME_R@ | ||
| 1254 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||
| 1255 | # undef ttyname_r | ||
| 1256 | # define ttyname_r rpl_ttyname_r | ||
| 1257 | # endif | ||
| 1258 | _GL_FUNCDECL_RPL (ttyname_r, int, | ||
| 1259 | (int fd, char *buf, size_t buflen) _GL_ARG_NONNULL ((2))); | ||
| 1260 | _GL_CXXALIAS_RPL (ttyname_r, int, | ||
| 1261 | (int fd, char *buf, size_t buflen)); | ||
| 1262 | # else | ||
| 1263 | # if !@HAVE_DECL_TTYNAME_R@ | ||
| 1264 | _GL_FUNCDECL_SYS (ttyname_r, int, | ||
| 1265 | (int fd, char *buf, size_t buflen) _GL_ARG_NONNULL ((2))); | ||
| 1266 | # endif | ||
| 1267 | _GL_CXXALIAS_SYS (ttyname_r, int, | ||
| 1268 | (int fd, char *buf, size_t buflen)); | ||
| 1269 | # endif | ||
| 1270 | _GL_CXXALIASWARN (ttyname_r); | ||
| 1271 | #elif defined GNULIB_POSIXCHECK | ||
| 1272 | # undef ttyname_r | ||
| 1273 | # if HAVE_RAW_DECL_TTYNAME_R | ||
| 1274 | _GL_WARN_ON_USE (ttyname_r, "ttyname_r is not portable - " | ||
| 1275 | "use gnulib module ttyname_r for portability"); | ||
| 1276 | # endif | ||
| 1277 | #endif | ||
| 1278 | |||
| 1279 | |||
| 1280 | #if @GNULIB_UNLINK@ | ||
| 1281 | # if @REPLACE_UNLINK@ | ||
| 1282 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||
| 1283 | # undef unlink | ||
| 1284 | # define unlink rpl_unlink | ||
| 1285 | # endif | ||
| 1286 | _GL_FUNCDECL_RPL (unlink, int, (char const *file) _GL_ARG_NONNULL ((1))); | ||
| 1287 | _GL_CXXALIAS_RPL (unlink, int, (char const *file)); | ||
| 1288 | # else | ||
| 1289 | _GL_CXXALIAS_SYS (unlink, int, (char const *file)); | ||
| 1290 | # endif | ||
| 1291 | _GL_CXXALIASWARN (unlink); | ||
| 1292 | #elif defined GNULIB_POSIXCHECK | ||
| 1293 | # undef unlink | ||
| 1294 | # if HAVE_RAW_DECL_UNLINK | ||
| 1295 | _GL_WARN_ON_USE (unlink, "unlink is not portable - " | ||
| 1296 | "use gnulib module unlink for portability"); | ||
| 1297 | # endif | ||
| 1298 | #endif | ||
| 1299 | |||
| 1300 | |||
| 1301 | #if @GNULIB_UNLINKAT@ | ||
| 1302 | # if @REPLACE_UNLINKAT@ | ||
| 1303 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||
| 1304 | # undef unlinkat | ||
| 1305 | # define unlinkat rpl_unlinkat | ||
| 1306 | # endif | ||
| 1307 | _GL_FUNCDECL_RPL (unlinkat, int, (int fd, char const *file, int flag) | ||
| 1308 | _GL_ARG_NONNULL ((2))); | ||
| 1309 | _GL_CXXALIAS_RPL (unlinkat, int, (int fd, char const *file, int flag)); | ||
| 1310 | # else | ||
| 1311 | # if !@HAVE_UNLINKAT@ | ||
| 1312 | _GL_FUNCDECL_SYS (unlinkat, int, (int fd, char const *file, int flag) | ||
| 1313 | _GL_ARG_NONNULL ((2))); | ||
| 1314 | # endif | ||
| 1315 | _GL_CXXALIAS_SYS (unlinkat, int, (int fd, char const *file, int flag)); | ||
| 1316 | # endif | ||
| 1317 | _GL_CXXALIASWARN (unlinkat); | ||
| 1318 | #elif defined GNULIB_POSIXCHECK | ||
| 1319 | # undef unlinkat | ||
| 1320 | # if HAVE_RAW_DECL_UNLINKAT | ||
| 1321 | _GL_WARN_ON_USE (unlinkat, "unlinkat is not portable - " | ||
| 1322 | "use gnulib module openat for portability"); | ||
| 1323 | # endif | ||
| 1324 | #endif | ||
| 1325 | |||
| 1326 | |||
| 1327 | #if @GNULIB_USLEEP@ | ||
| 1328 | /* Pause the execution of the current thread for N microseconds. | ||
| 1329 | Returns 0 on completion, or -1 on range error. | ||
| 1330 | See the POSIX:2001 specification | ||
| 1331 | <http://www.opengroup.org/susv3xsh/sleep.html>. */ | ||
| 1332 | # if @REPLACE_USLEEP@ | ||
| 1333 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||
| 1334 | # undef usleep | ||
| 1335 | # define usleep rpl_usleep | ||
| 1336 | # endif | ||
| 1337 | _GL_FUNCDECL_RPL (usleep, int, (useconds_t n)); | ||
| 1338 | _GL_CXXALIAS_RPL (usleep, int, (useconds_t n)); | ||
| 1339 | # else | ||
| 1340 | # if !@HAVE_USLEEP@ | ||
| 1341 | _GL_FUNCDECL_SYS (usleep, int, (useconds_t n)); | ||
| 1342 | # endif | ||
| 1343 | _GL_CXXALIAS_SYS (usleep, int, (useconds_t n)); | ||
| 1344 | # endif | ||
| 1345 | _GL_CXXALIASWARN (usleep); | ||
| 1346 | #elif defined GNULIB_POSIXCHECK | ||
| 1347 | # undef usleep | ||
| 1348 | # if HAVE_RAW_DECL_USLEEP | ||
| 1349 | _GL_WARN_ON_USE (usleep, "usleep is unportable - " | ||
| 1350 | "use gnulib module usleep for portability"); | ||
| 1351 | # endif | ||
| 1352 | #endif | ||
| 1353 | |||
| 1354 | |||
| 1355 | #if @GNULIB_WRITE@ | ||
| 1356 | /* Write up to COUNT bytes starting at BUF to file descriptor FD. | ||
| 1357 | See the POSIX:2001 specification | ||
| 1358 | <http://www.opengroup.org/susv3xsh/write.html>. */ | ||
| 1359 | # if @REPLACE_WRITE@ && @GNULIB_UNISTD_H_SIGPIPE@ | ||
| 1360 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||
| 1361 | # undef write | ||
| 1362 | # define write rpl_write | ||
| 1363 | # endif | ||
| 1364 | _GL_FUNCDECL_RPL (write, ssize_t, (int fd, const void *buf, size_t count) | ||
| 1365 | _GL_ARG_NONNULL ((2))); | ||
| 1366 | _GL_CXXALIAS_RPL (write, ssize_t, (int fd, const void *buf, size_t count)); | ||
| 1367 | # else | ||
| 1368 | /* Need to cast, because on mingw, the third parameter is | ||
| 1369 | unsigned int count | ||
| 1370 | and the return type is 'int'. */ | ||
| 1371 | _GL_CXXALIAS_SYS_CAST (write, ssize_t, (int fd, const void *buf, size_t count)); | ||
| 1372 | # endif | ||
| 1373 | _GL_CXXALIASWARN (write); | ||
| 1374 | #endif | ||
| 1375 | |||
| 1376 | |||
| 1377 | #endif /* _GL_UNISTD_H */ | ||
| 1378 | #endif /* _GL_UNISTD_H */ | ||
diff --git a/m4/getopt.m4 b/m4/getopt.m4 index 75cccacc2f2..793ab789ded 100644 --- a/m4/getopt.m4 +++ b/m4/getopt.m4 | |||
| @@ -1,82 +1,319 @@ | |||
| 1 | # getopt.m4 serial 10 | 1 | # getopt.m4 serial 32 |
| 2 | dnl Copyright (C) 2002,2003,2004,2005,2006,2007 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, |
| 5 | dnl with or without modifications, as long as this notice is preserved. | 5 | dnl with or without modifications, as long as this notice is preserved. |
| 6 | 6 | ||
| 7 | # The getopt module assume you want GNU getopt, with getopt_long etc, | 7 | # Request a POSIX compliant getopt function. |
| 8 | # rather than vanilla POSIX getopt. This means your your code should | 8 | AC_DEFUN([gl_FUNC_GETOPT_POSIX], |
| 9 | # always include <getopt.h> for the getopt prototypes. | 9 | [ |
| 10 | m4_divert_text([DEFAULTS], [gl_getopt_required=POSIX]) | ||
| 11 | AC_REQUIRE([gl_UNISTD_H_DEFAULTS]) | ||
| 12 | gl_GETOPT_IFELSE([ | ||
| 13 | gl_REPLACE_GETOPT | ||
| 14 | ], | ||
| 15 | []) | ||
| 16 | ]) | ||
| 17 | |||
| 18 | # Request a POSIX compliant getopt function with GNU extensions (such as | ||
| 19 | # options with optional arguments) and the functions getopt_long, | ||
| 20 | # getopt_long_only. | ||
| 21 | AC_DEFUN([gl_FUNC_GETOPT_GNU], | ||
| 22 | [ | ||
| 23 | m4_divert_text([INIT_PREPARE], [gl_getopt_required=GNU]) | ||
| 24 | |||
| 25 | AC_REQUIRE([gl_FUNC_GETOPT_POSIX]) | ||
| 26 | ]) | ||
| 10 | 27 | ||
| 11 | AC_DEFUN([gl_GETOPT_SUBSTITUTE], | 28 | # Request the gnulib implementation of the getopt functions unconditionally. |
| 29 | # argp.m4 uses this. | ||
| 30 | AC_DEFUN([gl_REPLACE_GETOPT], | ||
| 12 | [ | 31 | [ |
| 32 | dnl Arrange for getopt.h to be created. | ||
| 33 | gl_GETOPT_SUBSTITUTE_HEADER | ||
| 34 | dnl Arrange for unistd.h to include getopt.h. | ||
| 35 | GNULIB_UNISTD_H_GETOPT=1 | ||
| 36 | dnl Arrange to compile the getopt implementation. | ||
| 13 | AC_LIBOBJ([getopt]) | 37 | AC_LIBOBJ([getopt]) |
| 14 | AC_LIBOBJ([getopt1]) | 38 | AC_LIBOBJ([getopt1]) |
| 15 | gl_GETOPT_SUBSTITUTE_HEADER | ||
| 16 | gl_PREREQ_GETOPT | 39 | gl_PREREQ_GETOPT |
| 17 | ]) | 40 | ]) |
| 18 | 41 | ||
| 19 | AC_DEFUN([gl_GETOPT_SUBSTITUTE_HEADER], | 42 | # emacs' configure.in uses this. |
| 43 | AC_DEFUN([gl_GETOPT_IFELSE], | ||
| 20 | [ | 44 | [ |
| 21 | GETOPT_H=getopt.h | 45 | AC_REQUIRE([gl_GETOPT_CHECK_HEADERS]) |
| 22 | AC_DEFINE([__GETOPT_PREFIX], [[rpl_]], | 46 | AS_IF([test -n "$gl_replace_getopt"], [$1], [$2]) |
| 23 | [Define to rpl_ if the getopt replacement functions and variables | ||
| 24 | should be used.]) | ||
| 25 | AC_SUBST([GETOPT_H]) | ||
| 26 | ]) | 47 | ]) |
| 27 | 48 | ||
| 49 | # Determine whether to replace the entire getopt facility. | ||
| 28 | AC_DEFUN([gl_GETOPT_CHECK_HEADERS], | 50 | AC_DEFUN([gl_GETOPT_CHECK_HEADERS], |
| 29 | [ | 51 | [ |
| 30 | GETOPT_H= | 52 | AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles |
| 31 | AC_CHECK_HEADERS([getopt.h], [], [GETOPT_H=getopt.h]) | 53 | AC_REQUIRE([AC_PROG_AWK]) dnl for awk that supports ENVIRON |
| 32 | if test -z "$GETOPT_H"; then | 54 | |
| 33 | AC_CHECK_FUNCS([getopt_long_only], [], [GETOPT_H=getopt.h]) | 55 | dnl Persuade Solaris <unistd.h> to declare optarg, optind, opterr, optopt. |
| 56 | AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS]) | ||
| 57 | |||
| 58 | gl_CHECK_NEXT_HEADERS([getopt.h]) | ||
| 59 | AC_CHECK_HEADERS_ONCE([getopt.h]) | ||
| 60 | if test $ac_cv_header_getopt_h = yes; then | ||
| 61 | HAVE_GETOPT_H=1 | ||
| 62 | else | ||
| 63 | HAVE_GETOPT_H=0 | ||
| 64 | fi | ||
| 65 | AC_SUBST([HAVE_GETOPT_H]) | ||
| 66 | |||
| 67 | gl_replace_getopt= | ||
| 68 | |||
| 69 | dnl Test whether <getopt.h> is available. | ||
| 70 | if test -z "$gl_replace_getopt" && test $gl_getopt_required = GNU; then | ||
| 71 | AC_CHECK_HEADERS([getopt.h], [], [gl_replace_getopt=yes]) | ||
| 72 | fi | ||
| 73 | |||
| 74 | dnl Test whether the function getopt_long is available. | ||
| 75 | if test -z "$gl_replace_getopt" && test $gl_getopt_required = GNU; then | ||
| 76 | AC_CHECK_FUNCS([getopt_long_only], [], [gl_replace_getopt=yes]) | ||
| 34 | fi | 77 | fi |
| 35 | 78 | ||
| 36 | dnl BSD getopt_long uses an incompatible method to reset option processing, | 79 | dnl BSD getopt_long uses an incompatible method to reset option processing. |
| 37 | dnl and (as of 2004-10-15) mishandles optional option-arguments. | 80 | dnl Existence of the variable, in and of itself, is not a reason to replace |
| 38 | if test -z "$GETOPT_H"; then | 81 | dnl getopt, but knowledge of the variable is needed to determine how to |
| 39 | AC_CHECK_DECL([optreset], [GETOPT_H=getopt.h], [], [#include <getopt.h>]) | 82 | dnl reset and whether a reset reparses the environment. |
| 83 | dnl Solaris supports neither optreset nor optind=0, but keeps no state that | ||
| 84 | dnl needs a reset beyond setting optind=1; detect Solaris by getopt_clip. | ||
| 85 | if test -z "$gl_replace_getopt"; then | ||
| 86 | AC_CHECK_DECLS([optreset], [], | ||
| 87 | [AC_CHECK_DECLS([getopt_clip], [], [], | ||
| 88 | [[#include <getopt.h>]]) | ||
| 89 | ], | ||
| 90 | [[#include <getopt.h>]]) | ||
| 40 | fi | 91 | fi |
| 41 | 92 | ||
| 42 | dnl Solaris 10 getopt doesn't handle `+' as a leading character in an | 93 | dnl mingw's getopt (in libmingwex.a) does weird things when the options |
| 43 | dnl option string (as of 2005-05-05). | 94 | dnl strings starts with '+' and it's not the first call. Some internal state |
| 44 | if test -z "$GETOPT_H"; then | 95 | dnl is left over from earlier calls, and neither setting optind = 0 nor |
| 45 | AC_CACHE_CHECK([for working GNU getopt function], [gl_cv_func_gnu_getopt], | 96 | dnl setting optreset = 1 get rid of this internal state. |
| 46 | [AC_RUN_IFELSE( | 97 | dnl POSIX is silent on optind vs. optreset, so we allow either behavior. |
| 47 | [AC_LANG_PROGRAM([#include <getopt.h>], | 98 | dnl POSIX 2008 does not specify leading '+' behavior, but see |
| 48 | [[ | 99 | dnl http://austingroupbugs.net/view.php?id=191 for a recommendation on |
| 49 | char *myargv[3]; | 100 | dnl the next version of POSIX. For now, we only guarantee leading '+' |
| 50 | myargv[0] = "conftest"; | 101 | dnl behavior with getopt-gnu. |
| 51 | myargv[1] = "-+"; | 102 | if test -z "$gl_replace_getopt"; then |
| 52 | myargv[2] = 0; | 103 | AC_CACHE_CHECK([whether getopt is POSIX compatible], |
| 53 | return getopt (2, myargv, "+a") != '?'; | 104 | [gl_cv_func_getopt_posix], |
| 54 | ]])], | 105 | [ |
| 55 | [gl_cv_func_gnu_getopt=yes], | 106 | dnl This test fails on mingw and succeeds on many other platforms. |
| 56 | [gl_cv_func_gnu_getopt=no], | 107 | AC_RUN_IFELSE([AC_LANG_SOURCE([[ |
| 57 | [dnl cross compiling - pessimistically guess based on decls | 108 | #include <unistd.h> |
| 58 | dnl Solaris 10 getopt doesn't handle `+' as a leading character in an | 109 | #include <stdlib.h> |
| 59 | dnl option string (as of 2005-05-05). | 110 | #include <string.h> |
| 60 | AC_CHECK_DECL([getopt_clip], | 111 | |
| 61 | [gl_cv_func_gnu_getopt=no], [gl_cv_func_gnu_getopt=yes], | 112 | #if !HAVE_DECL_OPTRESET && !HAVE_DECL_GETOPT_CLIP |
| 62 | [#include <getopt.h>])])]) | 113 | # define OPTIND_MIN 0 |
| 63 | if test "$gl_cv_func_gnu_getopt" = "no"; then | 114 | #else |
| 64 | GETOPT_H=getopt.h | 115 | # define OPTIND_MIN 1 |
| 116 | #endif | ||
| 117 | |||
| 118 | int | ||
| 119 | main () | ||
| 120 | { | ||
| 121 | { | ||
| 122 | int argc = 0; | ||
| 123 | char *argv[10]; | ||
| 124 | int c; | ||
| 125 | |||
| 126 | argv[argc++] = "program"; | ||
| 127 | argv[argc++] = "-a"; | ||
| 128 | argv[argc++] = "foo"; | ||
| 129 | argv[argc++] = "bar"; | ||
| 130 | argv[argc] = NULL; | ||
| 131 | optind = OPTIND_MIN; | ||
| 132 | opterr = 0; | ||
| 133 | |||
| 134 | c = getopt (argc, argv, "ab"); | ||
| 135 | if (!(c == 'a')) | ||
| 136 | return 1; | ||
| 137 | c = getopt (argc, argv, "ab"); | ||
| 138 | if (!(c == -1)) | ||
| 139 | return 2; | ||
| 140 | if (!(optind == 2)) | ||
| 141 | return 3; | ||
| 142 | } | ||
| 143 | /* Some internal state exists at this point. */ | ||
| 144 | { | ||
| 145 | int argc = 0; | ||
| 146 | char *argv[10]; | ||
| 147 | int c; | ||
| 148 | |||
| 149 | argv[argc++] = "program"; | ||
| 150 | argv[argc++] = "donald"; | ||
| 151 | argv[argc++] = "-p"; | ||
| 152 | argv[argc++] = "billy"; | ||
| 153 | argv[argc++] = "duck"; | ||
| 154 | argv[argc++] = "-a"; | ||
| 155 | argv[argc++] = "bar"; | ||
| 156 | argv[argc] = NULL; | ||
| 157 | optind = OPTIND_MIN; | ||
| 158 | opterr = 0; | ||
| 159 | |||
| 160 | c = getopt (argc, argv, "+abp:q:"); | ||
| 161 | if (!(c == -1)) | ||
| 162 | return 4; | ||
| 163 | if (!(strcmp (argv[0], "program") == 0)) | ||
| 164 | return 5; | ||
| 165 | if (!(strcmp (argv[1], "donald") == 0)) | ||
| 166 | return 6; | ||
| 167 | if (!(strcmp (argv[2], "-p") == 0)) | ||
| 168 | return 7; | ||
| 169 | if (!(strcmp (argv[3], "billy") == 0)) | ||
| 170 | return 8; | ||
| 171 | if (!(strcmp (argv[4], "duck") == 0)) | ||
| 172 | return 9; | ||
| 173 | if (!(strcmp (argv[5], "-a") == 0)) | ||
| 174 | return 10; | ||
| 175 | if (!(strcmp (argv[6], "bar") == 0)) | ||
| 176 | return 11; | ||
| 177 | if (!(optind == 1)) | ||
| 178 | return 12; | ||
| 179 | } | ||
| 180 | /* Detect MacOS 10.5, AIX 7.1 bug. */ | ||
| 181 | { | ||
| 182 | char *argv[3] = { "program", "-ab", NULL }; | ||
| 183 | optind = OPTIND_MIN; | ||
| 184 | opterr = 0; | ||
| 185 | if (getopt (2, argv, "ab:") != 'a') | ||
| 186 | return 13; | ||
| 187 | if (getopt (2, argv, "ab:") != '?') | ||
| 188 | return 14; | ||
| 189 | if (optopt != 'b') | ||
| 190 | return 15; | ||
| 191 | if (optind != 2) | ||
| 192 | return 16; | ||
| 193 | } | ||
| 194 | |||
| 195 | return 0; | ||
| 196 | } | ||
| 197 | ]])], | ||
| 198 | [gl_cv_func_getopt_posix=yes], [gl_cv_func_getopt_posix=no], | ||
| 199 | [case "$host_os" in | ||
| 200 | mingw*) gl_cv_func_getopt_posix="guessing no";; | ||
| 201 | darwin* | aix*) gl_cv_func_getopt_posix="guessing no";; | ||
| 202 | *) gl_cv_func_getopt_posix="guessing yes";; | ||
| 203 | esac | ||
| 204 | ]) | ||
| 205 | ]) | ||
| 206 | case "$gl_cv_func_getopt_posix" in | ||
| 207 | *no) gl_replace_getopt=yes ;; | ||
| 208 | esac | ||
| 209 | fi | ||
| 210 | |||
| 211 | if test -z "$gl_replace_getopt" && test $gl_getopt_required = GNU; then | ||
| 212 | AC_CACHE_CHECK([for working GNU getopt function], [gl_cv_func_getopt_gnu], | ||
| 213 | [# Even with POSIXLY_CORRECT, the GNU extension of leading '-' in the | ||
| 214 | # optstring is necessary for programs like m4 that have POSIX-mandated | ||
| 215 | # semantics for supporting options interspersed with files. | ||
| 216 | # Also, since getopt_long is a GNU extension, we require optind=0. | ||
| 217 | # Bash ties 'set -o posix' to a non-exported POSIXLY_CORRECT; | ||
| 218 | # so take care to revert to the correct (non-)export state. | ||
| 219 | dnl GNU Coding Standards currently allow awk but not env; besides, env | ||
| 220 | dnl is ambiguous with environment values that contain newlines. | ||
| 221 | gl_awk_probe='BEGIN { if ("POSIXLY_CORRECT" in ENVIRON) print "x" }' | ||
| 222 | case ${POSIXLY_CORRECT+x}`$AWK "$gl_awk_probe" </dev/null` in | ||
| 223 | xx) gl_had_POSIXLY_CORRECT=exported ;; | ||
| 224 | x) gl_had_POSIXLY_CORRECT=yes ;; | ||
| 225 | *) gl_had_POSIXLY_CORRECT= ;; | ||
| 226 | esac | ||
| 227 | POSIXLY_CORRECT=1 | ||
| 228 | export POSIXLY_CORRECT | ||
| 229 | AC_RUN_IFELSE( | ||
| 230 | [AC_LANG_PROGRAM([[#include <getopt.h> | ||
| 231 | #include <stddef.h> | ||
| 232 | #include <string.h> | ||
| 233 | ]], [[ | ||
| 234 | int result = 0; | ||
| 235 | /* This code succeeds on glibc 2.8, OpenBSD 4.0, Cygwin, mingw, | ||
| 236 | and fails on MacOS X 10.5, AIX 5.2, HP-UX 11, IRIX 6.5, | ||
| 237 | OSF/1 5.1, Solaris 10. */ | ||
| 238 | { | ||
| 239 | char *myargv[3]; | ||
| 240 | myargv[0] = "conftest"; | ||
| 241 | myargv[1] = "-+"; | ||
| 242 | myargv[2] = 0; | ||
| 243 | opterr = 0; | ||
| 244 | if (getopt (2, myargv, "+a") != '?') | ||
| 245 | result |= 1; | ||
| 246 | } | ||
| 247 | /* This code succeeds on glibc 2.8, mingw, | ||
| 248 | and fails on MacOS X 10.5, OpenBSD 4.0, AIX 5.2, HP-UX 11, | ||
| 249 | IRIX 6.5, OSF/1 5.1, Solaris 10, Cygwin 1.5.x. */ | ||
| 250 | { | ||
| 251 | char *argv[] = { "program", "-p", "foo", "bar", NULL }; | ||
| 252 | |||
| 253 | optind = 1; | ||
| 254 | if (getopt (4, argv, "p::") != 'p') | ||
| 255 | result |= 2; | ||
| 256 | else if (optarg != NULL) | ||
| 257 | result |= 4; | ||
| 258 | else if (getopt (4, argv, "p::") != -1) | ||
| 259 | result |= 6; | ||
| 260 | else if (optind != 2) | ||
| 261 | result |= 8; | ||
| 262 | } | ||
| 263 | /* This code succeeds on glibc 2.8 and fails on Cygwin 1.7.0. */ | ||
| 264 | { | ||
| 265 | char *argv[] = { "program", "foo", "-p", NULL }; | ||
| 266 | optind = 0; | ||
| 267 | if (getopt (3, argv, "-p") != 1) | ||
| 268 | result |= 16; | ||
| 269 | else if (getopt (3, argv, "-p") != 'p') | ||
| 270 | result |= 32; | ||
| 271 | } | ||
| 272 | /* This code fails on glibc 2.11. */ | ||
| 273 | { | ||
| 274 | char *argv[] = { "program", "-b", "-a", NULL }; | ||
| 275 | optind = opterr = 0; | ||
| 276 | if (getopt (3, argv, "+:a:b") != 'b') | ||
| 277 | result |= 64; | ||
| 278 | else if (getopt (3, argv, "+:a:b") != ':') | ||
| 279 | result |= 64; | ||
| 280 | } | ||
| 281 | return result; | ||
| 282 | ]])], | ||
| 283 | [gl_cv_func_getopt_gnu=yes], | ||
| 284 | [gl_cv_func_getopt_gnu=no], | ||
| 285 | [dnl Cross compiling. Guess based on host and declarations. | ||
| 286 | case $host_os:$ac_cv_have_decl_optreset in | ||
| 287 | *-gnu*:* | mingw*:*) gl_cv_func_getopt_gnu=no;; | ||
| 288 | *:yes) gl_cv_func_getopt_gnu=no;; | ||
| 289 | *) gl_cv_func_getopt_gnu=yes;; | ||
| 290 | esac | ||
| 291 | ]) | ||
| 292 | case $gl_had_POSIXLY_CORRECT in | ||
| 293 | exported) ;; | ||
| 294 | yes) AS_UNSET([POSIXLY_CORRECT]); POSIXLY_CORRECT=1 ;; | ||
| 295 | *) AS_UNSET([POSIXLY_CORRECT]) ;; | ||
| 296 | esac | ||
| 297 | ]) | ||
| 298 | if test "$gl_cv_func_getopt_gnu" = "no"; then | ||
| 299 | gl_replace_getopt=yes | ||
| 65 | fi | 300 | fi |
| 66 | fi | 301 | fi |
| 67 | ]) | 302 | ]) |
| 68 | 303 | ||
| 69 | AC_DEFUN([gl_GETOPT_IFELSE], | 304 | # emacs' configure.in uses this. |
| 305 | AC_DEFUN([gl_GETOPT_SUBSTITUTE_HEADER], | ||
| 70 | [ | 306 | [ |
| 71 | AC_REQUIRE([gl_GETOPT_CHECK_HEADERS]) | 307 | GETOPT_H=getopt.h |
| 72 | AS_IF([test -n "$GETOPT_H"], [$1], [$2]) | 308 | AC_DEFINE([__GETOPT_PREFIX], [[rpl_]], |
| 309 | [Define to rpl_ if the getopt replacement functions and variables | ||
| 310 | should be used.]) | ||
| 311 | AC_SUBST([GETOPT_H]) | ||
| 73 | ]) | 312 | ]) |
| 74 | 313 | ||
| 75 | AC_DEFUN([gl_GETOPT], [gl_GETOPT_IFELSE([gl_GETOPT_SUBSTITUTE])]) | ||
| 76 | |||
| 77 | # Prerequisites of lib/getopt*. | 314 | # Prerequisites of lib/getopt*. |
| 78 | AC_DEFUN([gl_PREREQ_GETOPT], [:]) | 315 | # emacs' configure.in uses this. |
| 79 | 316 | AC_DEFUN([gl_PREREQ_GETOPT], | |
| 80 | ifelse(dnl Do not change this comment | 317 | [ |
| 81 | arch-tag: 6c64a021-551c-4a7f-9c63-cd7e1ce54707 | 318 | AC_CHECK_DECLS_ONCE([getenv]) |
| 82 | )dnl | 319 | ]) |
diff --git a/m4/gnulib-cache.m4 b/m4/gnulib-cache.m4 index fc6e8c76acb..f04d2fdfaa9 100644 --- a/m4/gnulib-cache.m4 +++ b/m4/gnulib-cache.m4 | |||
| @@ -15,12 +15,13 @@ | |||
| 15 | 15 | ||
| 16 | 16 | ||
| 17 | # Specification in the form of a command-line invocation: | 17 | # Specification in the form of a command-line invocation: |
| 18 | # gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=. --makefile-name=gnulib.mk --no-libtool --macro-prefix=gl --no-vc-files ftoastr mktime | 18 | # gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=. --makefile-name=gnulib.mk --no-libtool --macro-prefix=gl --no-vc-files ftoastr getopt-gnu mktime |
| 19 | 19 | ||
| 20 | # Specification in the form of a few gnulib-tool.m4 macro invocations: | 20 | # Specification in the form of a few gnulib-tool.m4 macro invocations: |
| 21 | gl_LOCAL_DIR([]) | 21 | gl_LOCAL_DIR([]) |
| 22 | gl_MODULES([ | 22 | gl_MODULES([ |
| 23 | ftoastr | 23 | ftoastr |
| 24 | getopt-gnu | ||
| 24 | mktime | 25 | mktime |
| 25 | ]) | 26 | ]) |
| 26 | gl_AVOID([]) | 27 | gl_AVOID([]) |
diff --git a/m4/gnulib-comp.m4 b/m4/gnulib-comp.m4 index 7fdec4a503c..fa0a9964073 100644 --- a/m4/gnulib-comp.m4 +++ b/m4/gnulib-comp.m4 | |||
| @@ -31,6 +31,9 @@ AC_DEFUN([gl_EARLY], | |||
| 31 | # Code from module extensions: | 31 | # Code from module extensions: |
| 32 | AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) | 32 | AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) |
| 33 | # Code from module ftoastr: | 33 | # Code from module ftoastr: |
| 34 | # Code from module getopt-gnu: | ||
| 35 | # Code from module getopt-posix: | ||
| 36 | # Code from module gettext-h: | ||
| 34 | # Code from module include_next: | 37 | # Code from module include_next: |
| 35 | # Code from module intprops: | 38 | # Code from module intprops: |
| 36 | # Code from module mktime: | 39 | # Code from module mktime: |
| @@ -38,6 +41,7 @@ AC_DEFUN([gl_EARLY], | |||
| 38 | # Code from module stddef: | 41 | # Code from module stddef: |
| 39 | # Code from module time: | 42 | # Code from module time: |
| 40 | # Code from module time_r: | 43 | # Code from module time_r: |
| 44 | # Code from module unistd: | ||
| 41 | # Code from module warn-on-use: | 45 | # Code from module warn-on-use: |
| 42 | ]) | 46 | ]) |
| 43 | 47 | ||
| @@ -62,6 +66,14 @@ AC_DEFUN([gl_INIT], | |||
| 62 | # Code from module extensions: | 66 | # Code from module extensions: |
| 63 | # Code from module ftoastr: | 67 | # Code from module ftoastr: |
| 64 | AC_REQUIRE([gl_C99_STRTOLD]) | 68 | AC_REQUIRE([gl_C99_STRTOLD]) |
| 69 | # Code from module getopt-gnu: | ||
| 70 | gl_FUNC_GETOPT_GNU | ||
| 71 | gl_MODULE_INDICATOR_FOR_TESTS([getopt-gnu]) | ||
| 72 | # Code from module getopt-posix: | ||
| 73 | gl_FUNC_GETOPT_POSIX | ||
| 74 | # Code from module gettext-h: | ||
| 75 | AC_SUBST([LIBINTL]) | ||
| 76 | AC_SUBST([LTLIBINTL]) | ||
| 65 | # Code from module include_next: | 77 | # Code from module include_next: |
| 66 | # Code from module intprops: | 78 | # Code from module intprops: |
| 67 | # Code from module mktime: | 79 | # Code from module mktime: |
| @@ -76,6 +88,8 @@ AC_DEFUN([gl_INIT], | |||
| 76 | # Code from module time_r: | 88 | # Code from module time_r: |
| 77 | gl_TIME_R | 89 | gl_TIME_R |
| 78 | gl_TIME_MODULE_INDICATOR([time_r]) | 90 | gl_TIME_MODULE_INDICATOR([time_r]) |
| 91 | # Code from module unistd: | ||
| 92 | gl_UNISTD_H | ||
| 79 | # Code from module warn-on-use: | 93 | # Code from module warn-on-use: |
| 80 | # End of code from modules | 94 | # End of code from modules |
| 81 | m4_ifval(gl_LIBSOURCES_LIST, [ | 95 | m4_ifval(gl_LIBSOURCES_LIST, [ |
| @@ -223,6 +237,11 @@ AC_DEFUN([gl_FILE_LIST], [ | |||
| 223 | lib/dtoastr.c | 237 | lib/dtoastr.c |
| 224 | lib/ftoastr.c | 238 | lib/ftoastr.c |
| 225 | lib/ftoastr.h | 239 | lib/ftoastr.h |
| 240 | lib/getopt.c | ||
| 241 | lib/getopt.in.h | ||
| 242 | lib/getopt1.c | ||
| 243 | lib/getopt_int.h | ||
| 244 | lib/gettext.h | ||
| 226 | lib/intprops.h | 245 | lib/intprops.h |
| 227 | lib/ldtoastr.c | 246 | lib/ldtoastr.c |
| 228 | lib/mktime-internal.h | 247 | lib/mktime-internal.h |
| @@ -230,9 +249,11 @@ AC_DEFUN([gl_FILE_LIST], [ | |||
| 230 | lib/stddef.in.h | 249 | lib/stddef.in.h |
| 231 | lib/time.in.h | 250 | lib/time.in.h |
| 232 | lib/time_r.c | 251 | lib/time_r.c |
| 252 | lib/unistd.in.h | ||
| 233 | m4/00gnulib.m4 | 253 | m4/00gnulib.m4 |
| 234 | m4/c-strtod.m4 | 254 | m4/c-strtod.m4 |
| 235 | m4/extensions.m4 | 255 | m4/extensions.m4 |
| 256 | m4/getopt.m4 | ||
| 236 | m4/gnulib-common.m4 | 257 | m4/gnulib-common.m4 |
| 237 | m4/include_next.m4 | 258 | m4/include_next.m4 |
| 238 | m4/mktime.m4 | 259 | m4/mktime.m4 |
| @@ -240,6 +261,7 @@ AC_DEFUN([gl_FILE_LIST], [ | |||
| 240 | m4/stddef_h.m4 | 261 | m4/stddef_h.m4 |
| 241 | m4/time_h.m4 | 262 | m4/time_h.m4 |
| 242 | m4/time_r.m4 | 263 | m4/time_r.m4 |
| 264 | m4/unistd_h.m4 | ||
| 243 | m4/warn-on-use.m4 | 265 | m4/warn-on-use.m4 |
| 244 | m4/wchar_t.m4 | 266 | m4/wchar_t.m4 |
| 245 | ]) | 267 | ]) |
diff --git a/m4/unistd_h.m4 b/m4/unistd_h.m4 new file mode 100644 index 00000000000..ba45e8b7aab --- /dev/null +++ b/m4/unistd_h.m4 | |||
| @@ -0,0 +1,164 @@ | |||
| 1 | # unistd_h.m4 serial 52 | ||
| 2 | dnl Copyright (C) 2006-2011 Free Software Foundation, Inc. | ||
| 3 | dnl This file is free software; the Free Software Foundation | ||
| 4 | dnl gives unlimited permission to copy and/or distribute it, | ||
| 5 | dnl with or without modifications, as long as this notice is preserved. | ||
| 6 | |||
| 7 | dnl Written by Simon Josefsson, Bruno Haible. | ||
| 8 | |||
| 9 | AC_DEFUN([gl_UNISTD_H], | ||
| 10 | [ | ||
| 11 | dnl Use AC_REQUIRE here, so that the default behavior below is expanded | ||
| 12 | dnl once only, before all statements that occur in other macros. | ||
| 13 | AC_REQUIRE([gl_UNISTD_H_DEFAULTS]) | ||
| 14 | AC_REQUIRE([AC_C_INLINE]) | ||
| 15 | |||
| 16 | gl_CHECK_NEXT_HEADERS([unistd.h]) | ||
| 17 | |||
| 18 | AC_CHECK_HEADERS_ONCE([unistd.h]) | ||
| 19 | if test $ac_cv_header_unistd_h = yes; then | ||
| 20 | HAVE_UNISTD_H=1 | ||
| 21 | else | ||
| 22 | HAVE_UNISTD_H=0 | ||
| 23 | fi | ||
| 24 | AC_SUBST([HAVE_UNISTD_H]) | ||
| 25 | |||
| 26 | dnl Check for declarations of anything we want to poison if the | ||
| 27 | dnl corresponding gnulib module is not in use. | ||
| 28 | gl_WARN_ON_USE_PREPARE([[#include <unistd.h> | ||
| 29 | /* Some systems declare various items in the wrong headers. */ | ||
| 30 | #if !(defined __GLIBC__ && !defined __UCLIBC__) | ||
| 31 | # include <fcntl.h> | ||
| 32 | # include <stdio.h> | ||
| 33 | # include <stdlib.h> | ||
| 34 | # if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ | ||
| 35 | # include <io.h> | ||
| 36 | # endif | ||
| 37 | #endif | ||
| 38 | ]], [chown dup2 dup3 environ euidaccess faccessat fchdir fchownat | ||
| 39 | fsync ftruncate getcwd getdomainname getdtablesize getgroups | ||
| 40 | gethostname getlogin getlogin_r getpagesize getusershell setusershell | ||
| 41 | endusershell lchown link linkat lseek pipe pipe2 pread pwrite readlink | ||
| 42 | readlinkat rmdir sleep symlink symlinkat ttyname_r unlink unlinkat | ||
| 43 | usleep]) | ||
| 44 | ]) | ||
| 45 | |||
| 46 | AC_DEFUN([gl_UNISTD_MODULE_INDICATOR], | ||
| 47 | [ | ||
| 48 | dnl Use AC_REQUIRE here, so that the default settings are expanded once only. | ||
| 49 | AC_REQUIRE([gl_UNISTD_H_DEFAULTS]) | ||
| 50 | gl_MODULE_INDICATOR_SET_VARIABLE([$1]) | ||
| 51 | dnl Define it also as a C macro, for the benefit of the unit tests. | ||
| 52 | gl_MODULE_INDICATOR_FOR_TESTS([$1]) | ||
| 53 | ]) | ||
| 54 | |||
| 55 | AC_DEFUN([gl_UNISTD_H_DEFAULTS], | ||
| 56 | [ | ||
| 57 | GNULIB_CHOWN=0; AC_SUBST([GNULIB_CHOWN]) | ||
| 58 | GNULIB_CLOSE=0; AC_SUBST([GNULIB_CLOSE]) | ||
| 59 | GNULIB_DUP2=0; AC_SUBST([GNULIB_DUP2]) | ||
| 60 | GNULIB_DUP3=0; AC_SUBST([GNULIB_DUP3]) | ||
| 61 | GNULIB_ENVIRON=0; AC_SUBST([GNULIB_ENVIRON]) | ||
| 62 | GNULIB_EUIDACCESS=0; AC_SUBST([GNULIB_EUIDACCESS]) | ||
| 63 | GNULIB_FACCESSAT=0; AC_SUBST([GNULIB_FACCESSAT]) | ||
| 64 | GNULIB_FCHDIR=0; AC_SUBST([GNULIB_FCHDIR]) | ||
| 65 | GNULIB_FCHOWNAT=0; AC_SUBST([GNULIB_FCHOWNAT]) | ||
| 66 | GNULIB_FSYNC=0; AC_SUBST([GNULIB_FSYNC]) | ||
| 67 | GNULIB_FTRUNCATE=0; AC_SUBST([GNULIB_FTRUNCATE]) | ||
| 68 | GNULIB_GETCWD=0; AC_SUBST([GNULIB_GETCWD]) | ||
| 69 | GNULIB_GETDOMAINNAME=0; AC_SUBST([GNULIB_GETDOMAINNAME]) | ||
| 70 | GNULIB_GETDTABLESIZE=0; AC_SUBST([GNULIB_GETDTABLESIZE]) | ||
| 71 | GNULIB_GETGROUPS=0; AC_SUBST([GNULIB_GETGROUPS]) | ||
| 72 | GNULIB_GETHOSTNAME=0; AC_SUBST([GNULIB_GETHOSTNAME]) | ||
| 73 | GNULIB_GETLOGIN=0; AC_SUBST([GNULIB_GETLOGIN]) | ||
| 74 | GNULIB_GETLOGIN_R=0; AC_SUBST([GNULIB_GETLOGIN_R]) | ||
| 75 | GNULIB_GETPAGESIZE=0; AC_SUBST([GNULIB_GETPAGESIZE]) | ||
| 76 | GNULIB_GETUSERSHELL=0; AC_SUBST([GNULIB_GETUSERSHELL]) | ||
| 77 | GNULIB_LCHOWN=0; AC_SUBST([GNULIB_LCHOWN]) | ||
| 78 | GNULIB_LINK=0; AC_SUBST([GNULIB_LINK]) | ||
| 79 | GNULIB_LINKAT=0; AC_SUBST([GNULIB_LINKAT]) | ||
| 80 | GNULIB_LSEEK=0; AC_SUBST([GNULIB_LSEEK]) | ||
| 81 | GNULIB_PIPE=0; AC_SUBST([GNULIB_PIPE]) | ||
| 82 | GNULIB_PIPE2=0; AC_SUBST([GNULIB_PIPE2]) | ||
| 83 | GNULIB_PREAD=0; AC_SUBST([GNULIB_PREAD]) | ||
| 84 | GNULIB_PWRITE=0; AC_SUBST([GNULIB_PWRITE]) | ||
| 85 | GNULIB_READLINK=0; AC_SUBST([GNULIB_READLINK]) | ||
| 86 | GNULIB_READLINKAT=0; AC_SUBST([GNULIB_READLINKAT]) | ||
| 87 | GNULIB_RMDIR=0; AC_SUBST([GNULIB_RMDIR]) | ||
| 88 | GNULIB_SLEEP=0; AC_SUBST([GNULIB_SLEEP]) | ||
| 89 | GNULIB_SYMLINK=0; AC_SUBST([GNULIB_SYMLINK]) | ||
| 90 | GNULIB_SYMLINKAT=0; AC_SUBST([GNULIB_SYMLINKAT]) | ||
| 91 | GNULIB_TTYNAME_R=0; AC_SUBST([GNULIB_TTYNAME_R]) | ||
| 92 | GNULIB_UNISTD_H_GETOPT=0; AC_SUBST([GNULIB_UNISTD_H_GETOPT]) | ||
| 93 | GNULIB_UNISTD_H_SIGPIPE=0; AC_SUBST([GNULIB_UNISTD_H_SIGPIPE]) | ||
| 94 | GNULIB_UNLINK=0; AC_SUBST([GNULIB_UNLINK]) | ||
| 95 | GNULIB_UNLINKAT=0; AC_SUBST([GNULIB_UNLINKAT]) | ||
| 96 | GNULIB_USLEEP=0; AC_SUBST([GNULIB_USLEEP]) | ||
| 97 | GNULIB_WRITE=0; AC_SUBST([GNULIB_WRITE]) | ||
| 98 | dnl Assume proper GNU behavior unless another module says otherwise. | ||
| 99 | HAVE_CHOWN=1; AC_SUBST([HAVE_CHOWN]) | ||
| 100 | HAVE_DUP2=1; AC_SUBST([HAVE_DUP2]) | ||
| 101 | HAVE_DUP3=1; AC_SUBST([HAVE_DUP3]) | ||
| 102 | HAVE_EUIDACCESS=1; AC_SUBST([HAVE_EUIDACCESS]) | ||
| 103 | HAVE_FACCESSAT=1; AC_SUBST([HAVE_FACCESSAT]) | ||
| 104 | HAVE_FCHDIR=1; AC_SUBST([HAVE_FCHDIR]) | ||
| 105 | HAVE_FCHOWNAT=1; AC_SUBST([HAVE_FCHOWNAT]) | ||
| 106 | HAVE_FSYNC=1; AC_SUBST([HAVE_FSYNC]) | ||
| 107 | HAVE_FTRUNCATE=1; AC_SUBST([HAVE_FTRUNCATE]) | ||
| 108 | HAVE_GETDTABLESIZE=1; AC_SUBST([HAVE_GETDTABLESIZE]) | ||
| 109 | HAVE_GETGROUPS=1; AC_SUBST([HAVE_GETGROUPS]) | ||
| 110 | HAVE_GETHOSTNAME=1; AC_SUBST([HAVE_GETHOSTNAME]) | ||
| 111 | HAVE_GETLOGIN=1; AC_SUBST([HAVE_GETLOGIN]) | ||
| 112 | HAVE_GETPAGESIZE=1; AC_SUBST([HAVE_GETPAGESIZE]) | ||
| 113 | HAVE_LCHOWN=1; AC_SUBST([HAVE_LCHOWN]) | ||
| 114 | HAVE_LINK=1; AC_SUBST([HAVE_LINK]) | ||
| 115 | HAVE_LINKAT=1; AC_SUBST([HAVE_LINKAT]) | ||
| 116 | HAVE_PIPE=1; AC_SUBST([HAVE_PIPE]) | ||
| 117 | HAVE_PIPE2=1; AC_SUBST([HAVE_PIPE2]) | ||
| 118 | HAVE_PREAD=1; AC_SUBST([HAVE_PREAD]) | ||
| 119 | HAVE_PWRITE=1; AC_SUBST([HAVE_PWRITE]) | ||
| 120 | HAVE_READLINK=1; AC_SUBST([HAVE_READLINK]) | ||
| 121 | HAVE_READLINKAT=1; AC_SUBST([HAVE_READLINKAT]) | ||
| 122 | HAVE_SLEEP=1; AC_SUBST([HAVE_SLEEP]) | ||
| 123 | HAVE_SYMLINK=1; AC_SUBST([HAVE_SYMLINK]) | ||
| 124 | HAVE_SYMLINKAT=1; AC_SUBST([HAVE_SYMLINKAT]) | ||
| 125 | HAVE_UNLINKAT=1; AC_SUBST([HAVE_UNLINKAT]) | ||
| 126 | HAVE_USLEEP=1; AC_SUBST([HAVE_USLEEP]) | ||
| 127 | HAVE_DECL_ENVIRON=1; AC_SUBST([HAVE_DECL_ENVIRON]) | ||
| 128 | HAVE_DECL_FCHDIR=1; AC_SUBST([HAVE_DECL_FCHDIR]) | ||
| 129 | HAVE_DECL_GETDOMAINNAME=1; AC_SUBST([HAVE_DECL_GETDOMAINNAME]) | ||
| 130 | HAVE_DECL_GETLOGIN_R=1; AC_SUBST([HAVE_DECL_GETLOGIN_R]) | ||
| 131 | HAVE_DECL_GETPAGESIZE=1; AC_SUBST([HAVE_DECL_GETPAGESIZE]) | ||
| 132 | HAVE_DECL_GETUSERSHELL=1; AC_SUBST([HAVE_DECL_GETUSERSHELL]) | ||
| 133 | HAVE_DECL_TTYNAME_R=1; AC_SUBST([HAVE_DECL_TTYNAME_R]) | ||
| 134 | HAVE_OS_H=0; AC_SUBST([HAVE_OS_H]) | ||
| 135 | HAVE_SYS_PARAM_H=0; AC_SUBST([HAVE_SYS_PARAM_H]) | ||
| 136 | REPLACE_CHOWN=0; AC_SUBST([REPLACE_CHOWN]) | ||
| 137 | REPLACE_CLOSE=0; AC_SUBST([REPLACE_CLOSE]) | ||
| 138 | REPLACE_DUP=0; AC_SUBST([REPLACE_DUP]) | ||
| 139 | REPLACE_DUP2=0; AC_SUBST([REPLACE_DUP2]) | ||
| 140 | REPLACE_FCHOWNAT=0; AC_SUBST([REPLACE_FCHOWNAT]) | ||
| 141 | REPLACE_GETCWD=0; AC_SUBST([REPLACE_GETCWD]) | ||
| 142 | REPLACE_GETDOMAINNAME=0; AC_SUBST([REPLACE_GETDOMAINNAME]) | ||
| 143 | REPLACE_GETLOGIN_R=0; AC_SUBST([REPLACE_GETLOGIN_R]) | ||
| 144 | REPLACE_GETGROUPS=0; AC_SUBST([REPLACE_GETGROUPS]) | ||
| 145 | REPLACE_GETPAGESIZE=0; AC_SUBST([REPLACE_GETPAGESIZE]) | ||
| 146 | REPLACE_LCHOWN=0; AC_SUBST([REPLACE_LCHOWN]) | ||
| 147 | REPLACE_LINK=0; AC_SUBST([REPLACE_LINK]) | ||
| 148 | REPLACE_LINKAT=0; AC_SUBST([REPLACE_LINKAT]) | ||
| 149 | REPLACE_LSEEK=0; AC_SUBST([REPLACE_LSEEK]) | ||
| 150 | REPLACE_PREAD=0; AC_SUBST([REPLACE_PREAD]) | ||
| 151 | REPLACE_PWRITE=0; AC_SUBST([REPLACE_PWRITE]) | ||
| 152 | REPLACE_READLINK=0; AC_SUBST([REPLACE_READLINK]) | ||
| 153 | REPLACE_RMDIR=0; AC_SUBST([REPLACE_RMDIR]) | ||
| 154 | REPLACE_SLEEP=0; AC_SUBST([REPLACE_SLEEP]) | ||
| 155 | REPLACE_SYMLINK=0; AC_SUBST([REPLACE_SYMLINK]) | ||
| 156 | REPLACE_TTYNAME_R=0; AC_SUBST([REPLACE_TTYNAME_R]) | ||
| 157 | REPLACE_UNLINK=0; AC_SUBST([REPLACE_UNLINK]) | ||
| 158 | REPLACE_UNLINKAT=0; AC_SUBST([REPLACE_UNLINKAT]) | ||
| 159 | REPLACE_USLEEP=0; AC_SUBST([REPLACE_USLEEP]) | ||
| 160 | REPLACE_WRITE=0; AC_SUBST([REPLACE_WRITE]) | ||
| 161 | UNISTD_H_HAVE_WINSOCK2_H=0; AC_SUBST([UNISTD_H_HAVE_WINSOCK2_H]) | ||
| 162 | UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS=0; | ||
| 163 | AC_SUBST([UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS]) | ||
| 164 | ]) | ||
diff --git a/src/config.in b/src/config.in index 89a057fc00e..a1ddc22cb71 100644 --- a/src/config.in +++ b/src/config.in | |||
| @@ -87,6 +87,9 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 87 | /* Define to 1 if gettimeofday accepts only one argument. */ | 87 | /* Define to 1 if gettimeofday accepts only one argument. */ |
| 88 | #undef GETTIMEOFDAY_ONE_ARGUMENT | 88 | #undef GETTIMEOFDAY_ONE_ARGUMENT |
| 89 | 89 | ||
| 90 | /* Define to 1 when the gnulib module getopt-gnu should be tested. */ | ||
| 91 | #undef GNULIB_TEST_GETOPT_GNU | ||
| 92 | |||
| 90 | /* Define to 1 when the gnulib module mktime should be tested. */ | 93 | /* Define to 1 when the gnulib module mktime should be tested. */ |
| 91 | #undef GNULIB_TEST_MKTIME | 94 | #undef GNULIB_TEST_MKTIME |
| 92 | 95 | ||
| @@ -142,10 +145,22 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 142 | /* Define to 1 if you have the `dbus_watch_get_unix_fd' function. */ | 145 | /* Define to 1 if you have the `dbus_watch_get_unix_fd' function. */ |
| 143 | #undef HAVE_DBUS_WATCH_GET_UNIX_FD | 146 | #undef HAVE_DBUS_WATCH_GET_UNIX_FD |
| 144 | 147 | ||
| 148 | /* Define to 1 if you have the declaration of `getenv', and to 0 if you don't. | ||
| 149 | */ | ||
| 150 | #undef HAVE_DECL_GETENV | ||
| 151 | |||
| 152 | /* Define to 1 if you have the declaration of `getopt_clip', and to 0 if you | ||
| 153 | don't. */ | ||
| 154 | #undef HAVE_DECL_GETOPT_CLIP | ||
| 155 | |||
| 145 | /* Define to 1 if you have the declaration of `localtime_r', and to 0 if you | 156 | /* Define to 1 if you have the declaration of `localtime_r', and to 0 if you |
| 146 | don't. */ | 157 | don't. */ |
| 147 | #undef HAVE_DECL_LOCALTIME_R | 158 | #undef HAVE_DECL_LOCALTIME_R |
| 148 | 159 | ||
| 160 | /* Define to 1 if you have the declaration of `optreset', and to 0 if you | ||
| 161 | don't. */ | ||
| 162 | #undef HAVE_DECL_OPTRESET | ||
| 163 | |||
| 149 | /* Define to 1 if you have the declaration of `sys_siglist', and to 0 if you | 164 | /* Define to 1 if you have the declaration of `sys_siglist', and to 0 if you |
| 150 | don't. */ | 165 | don't. */ |
| 151 | #undef HAVE_DECL_SYS_SIGLIST | 166 | #undef HAVE_DECL_SYS_SIGLIST |
| @@ -560,6 +575,123 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 560 | /* Define to 1 if you have the `random' function. */ | 575 | /* Define to 1 if you have the `random' function. */ |
| 561 | #undef HAVE_RANDOM | 576 | #undef HAVE_RANDOM |
| 562 | 577 | ||
| 578 | /* Define to 1 if chown is declared even after undefining macros. */ | ||
| 579 | #undef HAVE_RAW_DECL_CHOWN | ||
| 580 | |||
| 581 | /* Define to 1 if dup2 is declared even after undefining macros. */ | ||
| 582 | #undef HAVE_RAW_DECL_DUP2 | ||
| 583 | |||
| 584 | /* Define to 1 if dup3 is declared even after undefining macros. */ | ||
| 585 | #undef HAVE_RAW_DECL_DUP3 | ||
| 586 | |||
| 587 | /* Define to 1 if endusershell is declared even after undefining macros. */ | ||
| 588 | #undef HAVE_RAW_DECL_ENDUSERSHELL | ||
| 589 | |||
| 590 | /* Define to 1 if environ is declared even after undefining macros. */ | ||
| 591 | #undef HAVE_RAW_DECL_ENVIRON | ||
| 592 | |||
| 593 | /* Define to 1 if euidaccess is declared even after undefining macros. */ | ||
| 594 | #undef HAVE_RAW_DECL_EUIDACCESS | ||
| 595 | |||
| 596 | /* Define to 1 if faccessat is declared even after undefining macros. */ | ||
| 597 | #undef HAVE_RAW_DECL_FACCESSAT | ||
| 598 | |||
| 599 | /* Define to 1 if fchdir is declared even after undefining macros. */ | ||
| 600 | #undef HAVE_RAW_DECL_FCHDIR | ||
| 601 | |||
| 602 | /* Define to 1 if fchownat is declared even after undefining macros. */ | ||
| 603 | #undef HAVE_RAW_DECL_FCHOWNAT | ||
| 604 | |||
| 605 | /* Define to 1 if fsync is declared even after undefining macros. */ | ||
| 606 | #undef HAVE_RAW_DECL_FSYNC | ||
| 607 | |||
| 608 | /* Define to 1 if ftruncate is declared even after undefining macros. */ | ||
| 609 | #undef HAVE_RAW_DECL_FTRUNCATE | ||
| 610 | |||
| 611 | /* Define to 1 if getcwd is declared even after undefining macros. */ | ||
| 612 | #undef HAVE_RAW_DECL_GETCWD | ||
| 613 | |||
| 614 | /* Define to 1 if getdomainname is declared even after undefining macros. */ | ||
| 615 | #undef HAVE_RAW_DECL_GETDOMAINNAME | ||
| 616 | |||
| 617 | /* Define to 1 if getdtablesize is declared even after undefining macros. */ | ||
| 618 | #undef HAVE_RAW_DECL_GETDTABLESIZE | ||
| 619 | |||
| 620 | /* Define to 1 if getgroups is declared even after undefining macros. */ | ||
| 621 | #undef HAVE_RAW_DECL_GETGROUPS | ||
| 622 | |||
| 623 | /* Define to 1 if gethostname is declared even after undefining macros. */ | ||
| 624 | #undef HAVE_RAW_DECL_GETHOSTNAME | ||
| 625 | |||
| 626 | /* Define to 1 if getlogin is declared even after undefining macros. */ | ||
| 627 | #undef HAVE_RAW_DECL_GETLOGIN | ||
| 628 | |||
| 629 | /* Define to 1 if getlogin_r is declared even after undefining macros. */ | ||
| 630 | #undef HAVE_RAW_DECL_GETLOGIN_R | ||
| 631 | |||
| 632 | /* Define to 1 if getpagesize is declared even after undefining macros. */ | ||
| 633 | #undef HAVE_RAW_DECL_GETPAGESIZE | ||
| 634 | |||
| 635 | /* Define to 1 if getusershell is declared even after undefining macros. */ | ||
| 636 | #undef HAVE_RAW_DECL_GETUSERSHELL | ||
| 637 | |||
| 638 | /* Define to 1 if lchown is declared even after undefining macros. */ | ||
| 639 | #undef HAVE_RAW_DECL_LCHOWN | ||
| 640 | |||
| 641 | /* Define to 1 if link is declared even after undefining macros. */ | ||
| 642 | #undef HAVE_RAW_DECL_LINK | ||
| 643 | |||
| 644 | /* Define to 1 if linkat is declared even after undefining macros. */ | ||
| 645 | #undef HAVE_RAW_DECL_LINKAT | ||
| 646 | |||
| 647 | /* Define to 1 if lseek is declared even after undefining macros. */ | ||
| 648 | #undef HAVE_RAW_DECL_LSEEK | ||
| 649 | |||
| 650 | /* Define to 1 if pipe is declared even after undefining macros. */ | ||
| 651 | #undef HAVE_RAW_DECL_PIPE | ||
| 652 | |||
| 653 | /* Define to 1 if pipe2 is declared even after undefining macros. */ | ||
| 654 | #undef HAVE_RAW_DECL_PIPE2 | ||
| 655 | |||
| 656 | /* Define to 1 if pread is declared even after undefining macros. */ | ||
| 657 | #undef HAVE_RAW_DECL_PREAD | ||
| 658 | |||
| 659 | /* Define to 1 if pwrite is declared even after undefining macros. */ | ||
| 660 | #undef HAVE_RAW_DECL_PWRITE | ||
| 661 | |||
| 662 | /* Define to 1 if readlink is declared even after undefining macros. */ | ||
| 663 | #undef HAVE_RAW_DECL_READLINK | ||
| 664 | |||
| 665 | /* Define to 1 if readlinkat is declared even after undefining macros. */ | ||
| 666 | #undef HAVE_RAW_DECL_READLINKAT | ||
| 667 | |||
| 668 | /* Define to 1 if rmdir is declared even after undefining macros. */ | ||
| 669 | #undef HAVE_RAW_DECL_RMDIR | ||
| 670 | |||
| 671 | /* Define to 1 if setusershell is declared even after undefining macros. */ | ||
| 672 | #undef HAVE_RAW_DECL_SETUSERSHELL | ||
| 673 | |||
| 674 | /* Define to 1 if sleep is declared even after undefining macros. */ | ||
| 675 | #undef HAVE_RAW_DECL_SLEEP | ||
| 676 | |||
| 677 | /* Define to 1 if symlink is declared even after undefining macros. */ | ||
| 678 | #undef HAVE_RAW_DECL_SYMLINK | ||
| 679 | |||
| 680 | /* Define to 1 if symlinkat is declared even after undefining macros. */ | ||
| 681 | #undef HAVE_RAW_DECL_SYMLINKAT | ||
| 682 | |||
| 683 | /* Define to 1 if ttyname_r is declared even after undefining macros. */ | ||
| 684 | #undef HAVE_RAW_DECL_TTYNAME_R | ||
| 685 | |||
| 686 | /* Define to 1 if unlink is declared even after undefining macros. */ | ||
| 687 | #undef HAVE_RAW_DECL_UNLINK | ||
| 688 | |||
| 689 | /* Define to 1 if unlinkat is declared even after undefining macros. */ | ||
| 690 | #undef HAVE_RAW_DECL_UNLINKAT | ||
| 691 | |||
| 692 | /* Define to 1 if usleep is declared even after undefining macros. */ | ||
| 693 | #undef HAVE_RAW_DECL_USLEEP | ||
| 694 | |||
| 563 | /* Define to 1 if you have the `recvfrom' function. */ | 695 | /* Define to 1 if you have the `recvfrom' function. */ |
| 564 | #undef HAVE_RECVFROM | 696 | #undef HAVE_RECVFROM |
| 565 | 697 | ||