This module is necessary because of the rework that will be done in
the "change directory" logic on GDB/gdbserver in the next commit.
We will have a way to "cd" to a directory also on gdbserver, but in
order to do that uniformly, there must be a way to do tilde expansion
on directories provided by the user. Currently, GDB uses
"tilde_expand" from readline to do that, but gdbserver doesn't link
against readline and therefore cannot use this function. The solution
is to use "glob" instead, which can perform tilde expansion as a GNU
extension. Therefore, we need gnulib's version of "glob".
gdb/ChangeLog:
yyyy-mm-dd Sergio Durigan Junior <***@redhat.com>
* gnulib/aclocal.m4: Regenerate.
* gnulib/config.in: Likewise.
* gnulib/configure: Likewise.
* gnulib/import/Makefile.am: Likewise.
* gnulib/import/Makefile.in: Likewise.
* gnulib/import/closedir.c: New file.
* gnulib/import/dirent-private.h: Likewise.
* gnulib/import/filename.h: Likewise.
* gnulib/import/getlogin_r.c: Likewise.
* gnulib/import/glob-libc.h: Likewise.
* gnulib/import/glob.c: Likewise.
* gnulib/import/glob.in.h: Likewise.
* gnulib/import/m4/closedir.m4: Likewise.
* gnulib/import/m4/d-type.m4: Likewise.
* gnulib/import/m4/getlogin_r.m4: Likewise.
* gnulib/import/m4/glob.m4: Likewise.
* gnulib/import/m4/gnulib-cache.m4: Regenerate.
* gnulib/import/m4/gnulib-comp.m4: Likewise.
* gnulib/import/m4/mempcpy.m4: New file.
* gnulib/import/m4/opendir.m4: Likewise.
* gnulib/import/m4/readdir.m4: Likewise.
* gnulib/import/mempcpy.c: Likewise.
* gnulib/import/opendir.c: Likewise.
* gnulib/import/readdir.c: Likewise.
* gnulib/update-gnulib.sh (IMPORTED_GNULIB_MODULES): Add glob.
---
gdb/gnulib/aclocal.m4 | 7 +
gdb/gnulib/config.in | 51 +
gdb/gnulib/configure | 523 +++++++++-
gdb/gnulib/import/Makefile.am | 83 +-
gdb/gnulib/import/Makefile.in | 93 +-
gdb/gnulib/import/closedir.c | 71 ++
gdb/gnulib/import/dirent-private.h | 40 +
gdb/gnulib/import/filename.h | 54 +
gdb/gnulib/import/getlogin_r.c | 87 ++
gdb/gnulib/import/glob-libc.h | 212 ++++
gdb/gnulib/import/glob.c | 1808 ++++++++++++++++++++++++++++++++++
gdb/gnulib/import/glob.in.h | 93 ++
gdb/gnulib/import/m4/closedir.m4 | 30 +
gdb/gnulib/import/m4/d-type.m4 | 32 +
gdb/gnulib/import/m4/getlogin_r.m4 | 88 ++
gdb/gnulib/import/m4/glob.m4 | 76 ++
gdb/gnulib/import/m4/gnulib-cache.m4 | 3 +-
gdb/gnulib/import/m4/gnulib-comp.m4 | 58 ++
gdb/gnulib/import/m4/mempcpy.m4 | 26 +
gdb/gnulib/import/m4/opendir.m4 | 31 +
gdb/gnulib/import/m4/readdir.m4 | 15 +
gdb/gnulib/import/mempcpy.c | 28 +
gdb/gnulib/import/opendir.c | 169 ++++
gdb/gnulib/import/readdir.c | 98 ++
gdb/gnulib/update-gnulib.sh | 1 +
25 files changed, 3743 insertions(+), 34 deletions(-)
create mode 100644 gdb/gnulib/import/closedir.c
create mode 100644 gdb/gnulib/import/dirent-private.h
create mode 100644 gdb/gnulib/import/filename.h
create mode 100644 gdb/gnulib/import/getlogin_r.c
create mode 100644 gdb/gnulib/import/glob-libc.h
create mode 100644 gdb/gnulib/import/glob.c
create mode 100644 gdb/gnulib/import/glob.in.h
create mode 100644 gdb/gnulib/import/m4/closedir.m4
create mode 100644 gdb/gnulib/import/m4/d-type.m4
create mode 100644 gdb/gnulib/import/m4/getlogin_r.m4
create mode 100644 gdb/gnulib/import/m4/glob.m4
create mode 100644 gdb/gnulib/import/m4/mempcpy.m4
create mode 100644 gdb/gnulib/import/m4/opendir.m4
create mode 100644 gdb/gnulib/import/m4/readdir.m4
create mode 100644 gdb/gnulib/import/mempcpy.c
create mode 100644 gdb/gnulib/import/opendir.c
create mode 100644 gdb/gnulib/import/readdir.c
diff --git a/gdb/gnulib/aclocal.m4 b/gdb/gnulib/aclocal.m4
index a4ce6a6b47..e9e0be9d71 100644
--- a/gdb/gnulib/aclocal.m4
+++ b/gdb/gnulib/aclocal.m4
@@ -1016,8 +1016,10 @@ m4_include([import/m4/00gnulib.m4])
m4_include([import/m4/absolute-header.m4])
m4_include([import/m4/alloca.m4])
m4_include([import/m4/canonicalize.m4])
+m4_include([import/m4/closedir.m4])
m4_include([import/m4/codeset.m4])
m4_include([import/m4/configmake.m4])
+m4_include([import/m4/d-type.m4])
m4_include([import/m4/dirent_h.m4])
m4_include([import/m4/dirfd.m4])
m4_include([import/m4/dirname.m4])
@@ -1036,8 +1038,10 @@ m4_include([import/m4/fnmatch.m4])
m4_include([import/m4/fpieee.m4])
m4_include([import/m4/frexp.m4])
m4_include([import/m4/frexpl.m4])
+m4_include([import/m4/getlogin_r.m4])
m4_include([import/m4/gettimeofday.m4])
m4_include([import/m4/glibc21.m4])
+m4_include([import/m4/glob.m4])
m4_include([import/m4/gnulib-common.m4])
m4_include([import/m4/gnulib-comp.m4])
m4_include([import/m4/hard-locale.m4])
@@ -1063,12 +1067,15 @@ m4_include([import/m4/mbsrtowcs.m4])
m4_include([import/m4/mbstate_t.m4])
m4_include([import/m4/memchr.m4])
m4_include([import/m4/memmem.m4])
+m4_include([import/m4/mempcpy.m4])
m4_include([import/m4/mmap-anon.m4])
m4_include([import/m4/multiarch.m4])
m4_include([import/m4/nocrash.m4])
m4_include([import/m4/off_t.m4])
+m4_include([import/m4/opendir.m4])
m4_include([import/m4/pathmax.m4])
m4_include([import/m4/rawmemchr.m4])
+m4_include([import/m4/readdir.m4])
m4_include([import/m4/readlink.m4])
m4_include([import/m4/rename.m4])
m4_include([import/m4/rmdir.m4])
diff --git a/gdb/gnulib/config.in b/gdb/gnulib/config.in
index 6061520f0a..b78df1a46f 100644
--- a/gdb/gnulib/config.in
+++ b/gdb/gnulib/config.in
@@ -92,6 +92,9 @@
/* Define to 1 when the gnulib module chdir should be tested. */
#undef GNULIB_TEST_CHDIR
+/* Define to 1 when the gnulib module closedir should be tested. */
+#undef GNULIB_TEST_CLOSEDIR
+
/* Define to 1 when the gnulib module dirfd should be tested. */
#undef GNULIB_TEST_DIRFD
@@ -104,6 +107,9 @@
/* Define to 1 when the gnulib module frexpl should be tested. */
#undef GNULIB_TEST_FREXPL
+/* Define to 1 when the gnulib module getlogin_r should be tested. */
+#undef GNULIB_TEST_GETLOGIN_R
+
/* Define to 1 when the gnulib module gettimeofday should be tested. */
#undef GNULIB_TEST_GETTIMEOFDAY
@@ -128,9 +134,18 @@
/* Define to 1 when the gnulib module memmem should be tested. */
#undef GNULIB_TEST_MEMMEM
+/* Define to 1 when the gnulib module mempcpy should be tested. */
+#undef GNULIB_TEST_MEMPCPY
+
+/* Define to 1 when the gnulib module opendir should be tested. */
+#undef GNULIB_TEST_OPENDIR
+
/* Define to 1 when the gnulib module rawmemchr should be tested. */
#undef GNULIB_TEST_RAWMEMCHR
+/* Define to 1 when the gnulib module readdir should be tested. */
+#undef GNULIB_TEST_READDIR
+
/* Define to 1 when the gnulib module readlink should be tested. */
#undef GNULIB_TEST_READLINK
@@ -178,6 +193,9 @@
/* Define to 1 if you have the `canonicalize_file_name' function. */
#undef HAVE_CANONICALIZE_FILE_NAME
+/* Define to 1 if you have the `closedir' function. */
+#undef HAVE_CLOSEDIR
+
/* Define to 1 if you have the declaration of `alarm', and to 0 if you don't.
*/
#undef HAVE_DECL_ALARM
@@ -190,6 +208,14 @@
don't. */
#undef HAVE_DECL_GETC_UNLOCKED
+/* Define to 1 if you have the declaration of `getlogin', and to 0 if you
+ don't. */
+#undef HAVE_DECL_GETLOGIN
+
+/* Define to 1 if you have the declaration of `getlogin_r', and to 0 if you
+ don't. */
+#undef HAVE_DECL_GETLOGIN_R
+
/* Define to 1 if you have the declaration of `isblank', and to 0 if you
don't. */
#undef HAVE_DECL_ISBLANK
@@ -244,12 +270,24 @@
/* Define if the frexpl() function is available. */
#undef HAVE_FREXPL
+/* Define to 1 if you have the `fstatat' function. */
+#undef HAVE_FSTATAT
+
/* Define to 1 if you have the `getcwd' function. */
#undef HAVE_GETCWD
+/* Define to 1 if you have the `getlogin_r' function. */
+#undef HAVE_GETLOGIN_R
+
+/* Define to 1 if you have the `getpwnam_r' function. */
+#undef HAVE_GETPWNAM_R
+
/* Define to 1 if you have the `gettimeofday' function. */
#undef HAVE_GETTIMEOFDAY
+/* Define to 1 if you have the <glob.h> header file. */
+#undef HAVE_GLOB_H
+
/* Define to 1 if you have the <inttypes.h> header file. */
#undef HAVE_INTTYPES_H
@@ -317,6 +355,9 @@
/* Define to 1 if you have the `mprotect' function. */
#undef HAVE_MPROTECT
+/* Define to 1 if you have the `opendir' function. */
+#undef HAVE_OPENDIR
+
/* Define to 1 if you have the `rawmemchr' function. */
#undef HAVE_RAWMEMCHR
@@ -1137,6 +1178,9 @@
/* Define to 1 if _Exit is declared even after undefining macros. */
#undef HAVE_RAW_DECL__EXIT
+/* Define to 1 if you have the `readdir' function. */
+#undef HAVE_READDIR
+
/* Define to 1 if you have the `readlink' function. */
#undef HAVE_READLINK
@@ -1182,12 +1226,19 @@
/* Define to 1 if you have the `strtok_r' function. */
#undef HAVE_STRTOK_R
+/* Define if there is a member named d_type in the struct describing directory
+ headers. */
+#undef HAVE_STRUCT_DIRENT_D_TYPE
+
/* Define to 1 if you have the `symlink' function. */
#undef HAVE_SYMLINK
/* Define to 1 if you have the <sys/bitypes.h> header file. */
#undef HAVE_SYS_BITYPES_H
+/* Define to 1 if you have the <sys/cdefs.h> header file. */
+#undef HAVE_SYS_CDEFS_H
+
/* Define to 1 if you have the <sys/inttypes.h> header file. */
#undef HAVE_SYS_INTTYPES_H
diff --git a/gdb/gnulib/configure b/gdb/gnulib/configure
index 2a0dfc2d66..7d72e22bbd 100644
--- a/gdb/gnulib/configure
+++ b/gdb/gnulib/configure
@@ -1078,6 +1078,10 @@ GL_GENERATE_LIMITS_H_TRUE
LIMITS_H
NEXT_AS_FIRST_DIRECTIVE_LIMITS_H
NEXT_LIMITS_H
+HAVE_SYS_CDEFS_H
+GL_GENERATE_GLOB_H_FALSE
+GL_GENERATE_GLOB_H_TRUE
+GLOB_H
HAVE_WINSOCK2_H
NEXT_AS_FIRST_DIRECTIVE_SYS_TIME_H
NEXT_SYS_TIME_H
@@ -1372,6 +1376,9 @@ PRAGMA_COLUMNS
PRAGMA_SYSTEM_HEADER
INCLUDE_NEXT_AS_FIRST_DIRECTIVE
INCLUDE_NEXT
+pkglibexecdir
+runstatedir
+lispdir
REPLACE_FDOPENDIR
REPLACE_DIRFD
REPLACE_CLOSEDIR
@@ -1393,9 +1400,6 @@ GNULIB_CLOSEDIR
GNULIB_REWINDDIR
GNULIB_READDIR
GNULIB_OPENDIR
-pkglibexecdir
-runstatedir
-lispdir
UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS
UNISTD_H_HAVE_WINSOCK2_H
REPLACE_WRITE
@@ -3318,9 +3322,13 @@ as_fn_append ac_func_list " wmemcpy"
as_fn_append ac_func_list " wmempcpy"
as_fn_append ac_header_list " wctype.h"
gl_fnmatch_required=GNU
+as_fn_append ac_func_list " getlogin_r"
as_fn_append ac_header_list " sys/time.h"
as_fn_append ac_header_list " sys/socket.h"
as_fn_append ac_func_list " gettimeofday"
+as_fn_append ac_header_list " sys/cdefs.h"
+as_fn_append ac_func_list " fstatat"
+as_fn_append ac_func_list " getpwnam_r"
as_fn_append ac_header_list " limits.h"
as_fn_append ac_header_list " wchar.h"
as_fn_append ac_header_list " stdint.h"
@@ -5306,7 +5314,9 @@ fi
# Code from module alloca-opt:
# Code from module canonicalize-lgpl:
# Code from module chdir:
+ # Code from module closedir:
# Code from module configmake:
+ # Code from module d-type:
# Code from module dirent:
# Code from module dirfd:
# Code from module dirname-lgpl:
@@ -5316,6 +5326,7 @@ fi
# Code from module errno:
# Code from module extensions:
# Code from module extern-inline:
+ # Code from module filename:
# Code from module flexmember:
# Code from module float:
# Code from module fnmatch:
@@ -5325,7 +5336,9 @@ fi
# Code from module fpucw:
# Code from module frexp:
# Code from module frexpl:
+ # Code from module getlogin_r:
# Code from module gettimeofday:
+ # Code from module glob:
# Code from module hard-locale:
# Code from module include_next:
# Code from module inttypes:
@@ -5346,10 +5359,13 @@ fi
# Code from module memchr:
# Code from module memmem:
# Code from module memmem-simple:
+ # Code from module mempcpy:
# Code from module multiarch:
# Code from module nocrash:
+ # Code from module opendir:
# Code from module pathmax:
# Code from module rawmemchr:
+ # Code from module readdir:
# Code from module readlink:
# Code from module rename:
# Code from module rmdir:
@@ -7663,6 +7679,30 @@ $as_echo "#define HAVE_SAME_LONG_DOUBLE_AS_DOUBLE 1" >>confdefs.h
fi
+ac_fn_c_check_decl "$LINENO" "getlogin_r" "ac_cv_have_decl_getlogin_r" "$ac_includes_default"
+if test "x$ac_cv_have_decl_getlogin_r" = x""yes; then :
+ ac_have_decl=1
+else
+ ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_GETLOGIN_R $ac_have_decl
+_ACEOF
+
+
+
+ac_fn_c_check_decl "$LINENO" "getlogin" "ac_cv_have_decl_getlogin" "$ac_includes_default"
+if test "x$ac_cv_have_decl_getlogin" = x""yes; then :
+ ac_have_decl=1
+else
+ ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_GETLOGIN $ac_have_decl
+_ACEOF
+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for C/C++ restrict keyword" >&5
$as_echo_n "checking for C/C++ restrict keyword... " >&6; }
if test "${ac_cv_c_restrict+set}" = set; then :
@@ -7979,6 +8019,12 @@ fi
+
+
+
+
+
+
if test $gl_cv_have_include_next = yes; then
gl_cv_next_limits_h='<'limits.h'>'
else
@@ -12669,6 +12715,56 @@ $as_echo "#define GNULIB_TEST_CHDIR 1" >>confdefs.h
+
+
+ for ac_func in closedir
+do :
+ ac_fn_c_check_func "$LINENO" "closedir" "ac_cv_func_closedir"
+if test "x$ac_cv_func_closedir" = x""yes; then :
+ cat >>confdefs.h <<_ACEOF
+#define HAVE_CLOSEDIR 1
+_ACEOF
+
+fi
+done
+
+ if test $ac_cv_func_closedir = no; then
+ HAVE_CLOSEDIR=0
+ fi
+
+ case $host_os,$HAVE_CLOSEDIR in
+ os2*,1)
+ REPLACE_CLOSEDIR=1;;
+ esac
+
+ if test $HAVE_CLOSEDIR = 0 || test $REPLACE_CLOSEDIR = 1; then
+
+
+
+
+
+
+
+
+ gl_LIBOBJS="$gl_LIBOBJS closedir.$ac_objext"
+
+ fi
+
+
+
+
+
+ GNULIB_CLOSEDIR=1
+
+
+
+
+
+$as_echo "#define GNULIB_TEST_CLOSEDIR 1" >>confdefs.h
+
+
+
+
if test "x$datarootdir" = x; then
datarootdir='${datadir}'
@@ -12709,6 +12805,44 @@ $as_echo "#define GNULIB_TEST_CHDIR 1" >>confdefs.h
pkglibexecdir='${libexecdir}/${PACKAGE}'
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for d_type member in directory struct" >&5
+$as_echo_n "checking for d_type member in directory struct... " >&6; }
+if test "${gl_cv_struct_dirent_d_type+set}" = set; then :
+ $as_echo_n "(cached) " >&6
+else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+#include <sys/types.h>
+#include <dirent.h>
+
+int
+main ()
+{
+struct dirent dp; dp.d_type = 0;
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+ gl_cv_struct_dirent_d_type=yes
+else
+ gl_cv_struct_dirent_d_type=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_struct_dirent_d_type" >&5
+$as_echo "$gl_cv_struct_dirent_d_type" >&6; }
+ if test $gl_cv_struct_dirent_d_type = yes; then
+
+$as_echo "#define HAVE_STRUCT_DIRENT_D_TYPE 1" >>confdefs.h
+
+ fi
+
+
@@ -13982,6 +14116,114 @@ $as_echo "#define GNULIB_TEST_FREXPL 1" >>confdefs.h
+ if test $ac_cv_have_decl_getlogin_r = no; then
+ HAVE_DECL_GETLOGIN_R=0
+ fi
+
+
+ if test $ac_cv_func_getlogin_r = no; then
+ HAVE_GETLOGIN_R=0
+ else
+ HAVE_GETLOGIN_R=1
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether getlogin_r works with small buffers" >&5
+$as_echo_n "checking whether getlogin_r works with small buffers... " >&6; }
+if test "${gl_cv_func_getlogin_r_works+set}" = set; then :
+ $as_echo_n "(cached) " >&6
+else
+
+ case "$host_os" in
+ # Guess no on OSF/1.
+ osf*) gl_cv_func_getlogin_r_works="guessing no" ;;
+ # Guess yes otherwise.
+ *) gl_cv_func_getlogin_r_works="guessing yes" ;;
+ esac
+ if test "$cross_compiling" = yes; then :
+ :
+else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+#include <stddef.h>
+#include <unistd.h>
+#if !HAVE_DECL_GETLOGIN_R
+extern
+# ifdef __cplusplus
+"C"
+# endif
+int getlogin_r (char *, size_t);
+#endif
+int
+main (void)
+{
+ int result = 0;
+ char buf[100];
+
+ if (getlogin_r (buf, 0) == 0)
+ result |= 16;
+ if (getlogin_r (buf, 1) == 0)
+ result |= 17;
+ return result;
+}
+_ACEOF
+if ac_fn_c_try_run "$LINENO"; then :
+ gl_cv_func_getlogin_r_works=yes
+else
+ case $? in
+ 16 | 17) gl_cv_func_getlogin_r_works=no ;;
+ esac
+
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+ conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_getlogin_r_works" >&5
+$as_echo "$gl_cv_func_getlogin_r_works" >&6; }
+ case "$gl_cv_func_getlogin_r_works" in
+ *yes) ;;
+ *) REPLACE_GETLOGIN_R=1 ;;
+ esac
+ fi
+
+ if test $HAVE_GETLOGIN_R = 0 || test $REPLACE_GETLOGIN_R = 1; then
+
+
+
+
+
+
+
+
+ gl_LIBOBJS="$gl_LIBOBJS getlogin_r.$ac_objext"
+
+
+
+
+ fi
+
+
+
+
+
+ GNULIB_GETLOGIN_R=1
+
+
+
+
+
+$as_echo "#define GNULIB_TEST_GETLOGIN_R 1" >>confdefs.h
+
+
+
+
+
+
+
+
+
gl_gettimeofday_timezone=void
if test $ac_cv_func_gettimeofday != yes; then
HAVE_GETTIMEOFDAY=0
@@ -14177,6 +14419,131 @@ $as_echo "#define GNULIB_TEST_GETTIMEOFDAY 1" >>confdefs.h
+ GLOB_H=
+ for ac_header in glob.h
+do :
+ ac_fn_c_check_header_mongrel "$LINENO" "glob.h" "ac_cv_header_glob_h" "$ac_includes_default"
+if test "x$ac_cv_header_glob_h" = x""yes; then :
+ cat >>confdefs.h <<_ACEOF
+#define HAVE_GLOB_H 1
+_ACEOF
+
+else
+ GLOB_H=glob.h
+fi
+
+done
+
+
+ if test -z "$GLOB_H"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU glob interface version 1" >&5
+$as_echo_n "checking for GNU glob interface version 1... " >&6; }
+if test "${gl_cv_gnu_glob_interface_version_1+set}" = set; then :
+ $as_echo_n "(cached) " >&6
+else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#include <gnu-versions.h>
+char a[_GNU_GLOB_INTERFACE_VERSION == 1 ? 1 : -1];
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+ gl_cv_gnu_glob_interface_version_1=yes
+else
+ gl_cv_gnu_glob_interface_version_1=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_gnu_glob_interface_version_1" >&5
+$as_echo "$gl_cv_gnu_glob_interface_version_1" >&6; }
+
+ if test "$gl_cv_gnu_glob_interface_version_1" = "no"; then
+ GLOB_H=glob.h
+ fi
+ fi
+
+ if test -z "$GLOB_H"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether glob lists broken symlinks" >&5
+$as_echo_n "checking whether glob lists broken symlinks... " >&6; }
+if test "${gl_cv_glob_lists_symlinks+set}" = set; then :
+ $as_echo_n "(cached) " >&6
+else
+ if ln -s conf-doesntexist conf$$-globtest 2>/dev/null; then
+ gl_cv_glob_lists_symlinks=maybe
+ else
+ # If we can't make a symlink, then we cannot test this issue. Be
+ # pessimistic about this.
+ gl_cv_glob_lists_symlinks=no
+ fi
+
+ if test $gl_cv_glob_lists_symlinks = maybe; then
+ if test "$cross_compiling" = yes; then :
+ gl_cv_glob_lists_symlinks=no
+else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+#include <stddef.h>
+#include <glob.h>
+int
+main ()
+{
+glob_t found;
+if (glob ("conf*-globtest", 0, NULL, &found) == GLOB_NOMATCH) return 1;
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_run "$LINENO"; then :
+ gl_cv_glob_lists_symlinks=yes
+else
+ gl_cv_glob_lists_symlinks=no
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+ conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+
+ fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_glob_lists_symlinks" >&5
+$as_echo "$gl_cv_glob_lists_symlinks" >&6; }
+
+ if test $gl_cv_glob_lists_symlinks = no; then
+ GLOB_H=glob.h
+ fi
+ fi
+
+ rm -f conf$$-globtest
+
+
+ if test -n "$GLOB_H"; then
+ GL_GENERATE_GLOB_H_TRUE=
+ GL_GENERATE_GLOB_H_FALSE='#'
+else
+ GL_GENERATE_GLOB_H_TRUE='#'
+ GL_GENERATE_GLOB_H_FALSE=
+fi
+
+
+ if test -n "$GLOB_H"; then
+
+
+
+
+
+
+
+
+ gl_LIBOBJS="$gl_LIBOBJS glob.$ac_objext"
+
+
+ if test $ac_cv_header_sys_cdefs_h = yes; then
+ HAVE_SYS_CDEFS_H=1
+ else
+ HAVE_SYS_CDEFS_H=0
+ fi
+
+
+ fi
:
@@ -16665,6 +17032,107 @@ $as_echo "#define GNULIB_TEST_MEMMEM 1" >>confdefs.h
+ for ac_func in mempcpy
+do :
+ ac_fn_c_check_func "$LINENO" "mempcpy" "ac_cv_func_mempcpy"
+if test "x$ac_cv_func_mempcpy" = x""yes; then :
+ cat >>confdefs.h <<_ACEOF
+#define HAVE_MEMPCPY 1
+_ACEOF
+
+fi
+done
+
+ if test $ac_cv_func_mempcpy = no; then
+ HAVE_MEMPCPY=0
+ fi
+
+ if test $HAVE_MEMPCPY = 0; then
+
+
+
+
+
+
+
+
+ gl_LIBOBJS="$gl_LIBOBJS mempcpy.$ac_objext"
+
+
+ :
+
+ fi
+
+
+
+
+
+ GNULIB_MEMPCPY=1
+
+
+
+
+
+$as_echo "#define GNULIB_TEST_MEMPCPY 1" >>confdefs.h
+
+
+
+
+
+
+
+ for ac_func in opendir
+do :
+ ac_fn_c_check_func "$LINENO" "opendir" "ac_cv_func_opendir"
+if test "x$ac_cv_func_opendir" = x""yes; then :
+ cat >>confdefs.h <<_ACEOF
+#define HAVE_OPENDIR 1
+_ACEOF
+
+fi
+done
+
+ if test $ac_cv_func_opendir = no; then
+ HAVE_OPENDIR=0
+ fi
+
+ case $host_os,$HAVE_OPENDIR in
+ os2*,1)
+ REPLACE_OPENDIR=1;;
+ esac
+
+ if test $HAVE_OPENDIR = 0 || test $REPLACE_OPENDIR = 1; then
+
+
+
+
+
+
+
+
+ gl_LIBOBJS="$gl_LIBOBJS opendir.$ac_objext"
+
+ fi
+
+
+
+
+
+ GNULIB_OPENDIR=1
+
+
+
+
+
+$as_echo "#define GNULIB_TEST_OPENDIR 1" >>confdefs.h
+
+
+
+
+
+
+
+
for ac_func in rawmemchr
@@ -16713,6 +17181,51 @@ $as_echo "#define GNULIB_TEST_RAWMEMCHR 1" >>confdefs.h
+ for ac_func in readdir
+do :
+ ac_fn_c_check_func "$LINENO" "readdir" "ac_cv_func_readdir"
+if test "x$ac_cv_func_readdir" = x""yes; then :
+ cat >>confdefs.h <<_ACEOF
+#define HAVE_READDIR 1
+_ACEOF
+
+fi
+done
+
+ if test $ac_cv_func_readdir = no; then
+ HAVE_READDIR=0
+ fi
+
+ if test $HAVE_READDIR = 0; then
+
+
+
+
+
+
+
+
+ gl_LIBOBJS="$gl_LIBOBJS readdir.$ac_objext"
+
+ fi
+
+
+
+
+
+ GNULIB_READDIR=1
+
+
+
+
+
+$as_echo "#define GNULIB_TEST_READDIR 1" >>confdefs.h
+
+
+
+
+
+
if test $ac_cv_func_readlink = no; then
HAVE_READLINK=0
else
@@ -20526,6 +21039,10 @@ if test -z "${GL_GENERATE_FNMATCH_H_TRUE}" && test -z "${GL_GENERATE_FNMATCH_H_F
as_fn_error "conditional \"GL_GENERATE_FNMATCH_H\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5
fi
+if test -z "${GL_GENERATE_GLOB_H_TRUE}" && test -z "${GL_GENERATE_GLOB_H_FALSE}"; then
+ as_fn_error "conditional \"GL_GENERATE_GLOB_H\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
if test -z "${GL_GENERATE_LIMITS_H_TRUE}" && test -z "${GL_GENERATE_LIMITS_H_FALSE}"; then
as_fn_error "conditional \"GL_GENERATE_LIMITS_H\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5
diff --git a/gdb/gnulib/import/Makefile.am b/gdb/gnulib/import/Makefile.am
index 26f249d16a..defa7b34ca 100644
--- a/gdb/gnulib/import/Makefile.am
+++ b/gdb/gnulib/import/Makefile.am
@@ -21,7 +21,7 @@
# the same distribution terms as the rest of that program.
#
# Generated by gnulib-tool.
-# Reproduce by: gnulib-tool --import --lib=libgnu --source-base=import --m4-base=import/m4 --doc-base=doc --tests-base=tests --aux-dir=import/extra --no-conditional-dependencies --no-libtool --macro-prefix=gl --no-vc-files alloca canonicalize-lgpl dirent dirfd errno fnmatch-gnu frexpl inttypes limits-h lstat memchr memmem pathmax rawmemchr readlink rename setenv signal-h strchrnul strstr strtok_r sys_stat unistd unsetenv update-copyright wchar wctype-h
+# Reproduce by: gnulib-tool --import --lib=libgnu --source-base=import --m4-base=import/m4 --doc-base=doc --tests-base=tests --aux-dir=import/extra --no-conditional-dependencies --no-libtool --macro-prefix=gl --no-vc-files alloca canonicalize-lgpl dirent dirfd errno fnmatch-gnu frexpl glob inttypes limits-h lstat memchr memmem pathmax rawmemchr readlink rename setenv signal-h strchrnul strstr strtok_r sys_stat unistd unsetenv update-copyright wchar wctype-h
AUTOMAKE_OPTIONS = 1.9.6 gnits
@@ -101,6 +101,15 @@ EXTRA_libgnu_a_SOURCES += canonicalize-lgpl.c
## end gnulib module canonicalize-lgpl
+## begin gnulib module closedir
+
+
+EXTRA_DIST += closedir.c dirent-private.h
+
+EXTRA_libgnu_a_SOURCES += closedir.c
+
+## end gnulib module closedir
+
## begin gnulib module configmake
# Listed in the same order as the GNU makefile conventions, and
@@ -252,6 +261,13 @@ EXTRA_DIST += errno.in.h
## end gnulib module errno
+## begin gnulib module filename
+
+
+EXTRA_DIST += filename.h
+
+## end gnulib module filename
+
## begin gnulib module flexmember
@@ -341,6 +357,15 @@ EXTRA_libgnu_a_SOURCES += frexp.c frexpl.c
## end gnulib module frexpl
+## begin gnulib module getlogin_r
+
+
+EXTRA_DIST += getlogin_r.c
+
+EXTRA_libgnu_a_SOURCES += getlogin_r.c
+
+## end gnulib module getlogin_r
+
## begin gnulib module gettimeofday
@@ -350,6 +375,35 @@ EXTRA_libgnu_a_SOURCES += gettimeofday.c
## end gnulib module gettimeofday
+## begin gnulib module glob
+
+BUILT_SOURCES += $(GLOB_H)
+
+# We need the following in order to create <glob.h> when the system
+# doesn't have one that works with the given compiler.
+if GL_GENERATE_GLOB_H
+glob.h: glob.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
+ $(AM_V_GEN)rm -f $@-t $@ && \
+ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
+ sed -e 's|@''HAVE_SYS_CDEFS_H''@|$(HAVE_SYS_CDEFS_H)|g' \
+ -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
+ -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
+ -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
+ < $(srcdir)/glob.in.h; \
+ } > $@-t && \
+ mv -f $@-t $@
+else
+glob.h: $(top_builddir)/config.status
+ rm -f $@
+endif
+MOSTLYCLEANFILES += glob.h glob.h-t
+
+EXTRA_DIST += glob-libc.h glob.c glob.in.h
+
+EXTRA_libgnu_a_SOURCES += glob.c
+
+## end gnulib module glob
+
## begin gnulib module hard-locale
libgnu_a_SOURCES += hard-locale.c
@@ -878,6 +932,24 @@ EXTRA_libgnu_a_SOURCES += memmem.c
## end gnulib module memmem-simple
+## begin gnulib module mempcpy
+
+
+EXTRA_DIST += mempcpy.c
+
+EXTRA_libgnu_a_SOURCES += mempcpy.c
+
+## end gnulib module mempcpy
+
+## begin gnulib module opendir
+
+
+EXTRA_DIST += dirent-private.h opendir.c
+
+EXTRA_libgnu_a_SOURCES += opendir.c
+
+## end gnulib module opendir
+
## begin gnulib module pathmax
@@ -894,6 +966,15 @@ EXTRA_libgnu_a_SOURCES += rawmemchr.c
## end gnulib module rawmemchr
+## begin gnulib module readdir
+
+
+EXTRA_DIST += dirent-private.h readdir.c
+
+EXTRA_libgnu_a_SOURCES += readdir.c
+
+## end gnulib module readdir
+
## begin gnulib module readlink
diff --git a/gdb/gnulib/import/Makefile.in b/gdb/gnulib/import/Makefile.in
index ca7a73d970..d02fcfb9f9 100644
--- a/gdb/gnulib/import/Makefile.in
+++ b/gdb/gnulib/import/Makefile.in
@@ -36,7 +36,7 @@
# the same distribution terms as the rest of that program.
#
# Generated by gnulib-tool.
-# Reproduce by: gnulib-tool --import --lib=libgnu --source-base=import --m4-base=import/m4 --doc-base=doc --tests-base=tests --aux-dir=import/extra --no-conditional-dependencies --no-libtool --macro-prefix=gl --no-vc-files alloca canonicalize-lgpl dirent dirfd errno fnmatch-gnu frexpl inttypes limits-h lstat memchr memmem pathmax rawmemchr readlink rename setenv signal-h strchrnul strstr strtok_r sys_stat unistd unsetenv update-copyright wchar wctype-h
+# Reproduce by: gnulib-tool --import --lib=libgnu --source-base=import --m4-base=import/m4 --doc-base=doc --tests-base=tests --aux-dir=import/extra --no-conditional-dependencies --no-libtool --macro-prefix=gl --no-vc-files alloca canonicalize-lgpl dirent dirfd errno fnmatch-gnu frexpl glob inttypes limits-h lstat memchr memmem pathmax rawmemchr readlink rename setenv signal-h strchrnul strstr strtok_r sys_stat unistd unsetenv update-copyright wchar wctype-h
@@ -67,8 +67,10 @@ am__aclocal_m4_deps = $(top_srcdir)/import/m4/00gnulib.m4 \
$(top_srcdir)/import/m4/absolute-header.m4 \
$(top_srcdir)/import/m4/alloca.m4 \
$(top_srcdir)/import/m4/canonicalize.m4 \
+ $(top_srcdir)/import/m4/closedir.m4 \
$(top_srcdir)/import/m4/codeset.m4 \
$(top_srcdir)/import/m4/configmake.m4 \
+ $(top_srcdir)/import/m4/d-type.m4 \
$(top_srcdir)/import/m4/dirent_h.m4 \
$(top_srcdir)/import/m4/dirfd.m4 \
$(top_srcdir)/import/m4/dirname.m4 \
@@ -87,8 +89,10 @@ am__aclocal_m4_deps = $(top_srcdir)/import/m4/00gnulib.m4 \
$(top_srcdir)/import/m4/fpieee.m4 \
$(top_srcdir)/import/m4/frexp.m4 \
$(top_srcdir)/import/m4/frexpl.m4 \
+ $(top_srcdir)/import/m4/getlogin_r.m4 \
$(top_srcdir)/import/m4/gettimeofday.m4 \
$(top_srcdir)/import/m4/glibc21.m4 \
+ $(top_srcdir)/import/m4/glob.m4 \
$(top_srcdir)/import/m4/gnulib-common.m4 \
$(top_srcdir)/import/m4/gnulib-comp.m4 \
$(top_srcdir)/import/m4/hard-locale.m4 \
@@ -114,12 +118,15 @@ am__aclocal_m4_deps = $(top_srcdir)/import/m4/00gnulib.m4 \
$(top_srcdir)/import/m4/mbstate_t.m4 \
$(top_srcdir)/import/m4/memchr.m4 \
$(top_srcdir)/import/m4/memmem.m4 \
+ $(top_srcdir)/import/m4/mempcpy.m4 \
$(top_srcdir)/import/m4/mmap-anon.m4 \
$(top_srcdir)/import/m4/multiarch.m4 \
$(top_srcdir)/import/m4/nocrash.m4 \
$(top_srcdir)/import/m4/off_t.m4 \
+ $(top_srcdir)/import/m4/opendir.m4 \
$(top_srcdir)/import/m4/pathmax.m4 \
$(top_srcdir)/import/m4/rawmemchr.m4 \
+ $(top_srcdir)/import/m4/readdir.m4 \
$(top_srcdir)/import/m4/readlink.m4 \
$(top_srcdir)/import/m4/rename.m4 \
$(top_srcdir)/import/m4/rmdir.m4 \
@@ -256,6 +263,7 @@ FNMATCH_H = @FNMATCH_H@
FREXPL_LIBM = @FREXPL_LIBM@
FREXP_LIBM = @FREXP_LIBM@
GLIBC21 = @GLIBC21@
+GLOB_H = @GLOB_H@
GNULIB_ACOSF = @GNULIB_ACOSF@
GNULIB_ACOSL = @GNULIB_ACOSL@
GNULIB_ALPHASORT = @GNULIB_ALPHASORT@
@@ -856,6 +864,7 @@ HAVE_STRVERSCMP = @HAVE_STRVERSCMP@
HAVE_SYMLINK = @HAVE_SYMLINK@
HAVE_SYMLINKAT = @HAVE_SYMLINKAT@
HAVE_SYS_BITYPES_H = @HAVE_SYS_BITYPES_H@
+HAVE_SYS_CDEFS_H = @HAVE_SYS_CDEFS_H@
HAVE_SYS_INTTYPES_H = @HAVE_SYS_INTTYPES_H@
HAVE_SYS_LOADAVG_H = @HAVE_SYS_LOADAVG_H@
HAVE_SYS_PARAM_H = @HAVE_SYS_PARAM_H@
@@ -1281,17 +1290,20 @@ noinst_HEADERS =
noinst_LIBRARIES = libgnu.a
noinst_LTLIBRARIES =
EXTRA_DIST = m4/gnulib-cache.m4 alloca.c alloca.in.h \
- canonicalize-lgpl.c dirent.in.h dirfd.c dirname.h dosname.h \
- errno.in.h flexmember.h float.c float.in.h itold.c fnmatch.c \
- fnmatch.in.h fnmatch_loop.c fpucw.h frexp.c frexp.c frexpl.c \
- gettimeofday.c hard-locale.h inttypes.in.h float+.h isnan.c \
- isnand-nolibm.h isnand.c float+.h isnan.c isnanl-nolibm.h \
- isnanl.c limits.in.h config.charset ref-add.sin ref-del.sin \
- lstat.c malloc.c malloca.h malloca.valgrind math.in.h \
- mbrtowc.c mbsinit.c mbsrtowcs-impl.h mbsrtowcs-state.c \
- mbsrtowcs.c memchr.c memchr.valgrind memmem.c str-two-way.h \
- pathmax.h rawmemchr.c rawmemchr.valgrind readlink.c rename.c \
- rmdir.c same-inode.h setenv.c signal.in.h \
+ canonicalize-lgpl.c closedir.c dirent-private.h dirent.in.h \
+ dirfd.c dirname.h dosname.h errno.in.h filename.h flexmember.h \
+ float.c float.in.h itold.c fnmatch.c fnmatch.in.h \
+ fnmatch_loop.c fpucw.h frexp.c frexp.c frexpl.c getlogin_r.c \
+ gettimeofday.c glob-libc.h glob.c glob.in.h hard-locale.h \
+ inttypes.in.h float+.h isnan.c isnand-nolibm.h isnand.c \
+ float+.h isnan.c isnanl-nolibm.h isnanl.c limits.in.h \
+ config.charset ref-add.sin ref-del.sin lstat.c malloc.c \
+ malloca.h malloca.valgrind math.in.h mbrtowc.c mbsinit.c \
+ mbsrtowcs-impl.h mbsrtowcs-state.c mbsrtowcs.c memchr.c \
+ memchr.valgrind memmem.c str-two-way.h mempcpy.c \
+ dirent-private.h opendir.c pathmax.h rawmemchr.c \
+ rawmemchr.valgrind dirent-private.h readdir.c readlink.c \
+ rename.c rmdir.c same-inode.h setenv.c signal.in.h \
$(top_srcdir)/import/extra/snippet/_Noreturn.h \
$(top_srcdir)/import/extra/snippet/arg-nonnull.h \
$(top_srcdir)/import/extra/snippet/c++defs.h \
@@ -1313,21 +1325,22 @@ EXTRA_DIST = m4/gnulib-cache.m4 alloca.c alloca.in.h \
# present in all Makefile.am that need it. This is ensured by the applicability
# 'all' defined above.
BUILT_SOURCES = $(ALLOCA_H) configmake.h dirent.h $(ERRNO_H) \
- $(FLOAT_H) $(FNMATCH_H) inttypes.h $(LIMITS_H) math.h signal.h \
- arg-nonnull.h c++defs.h warn-on-use.h $(STDBOOL_H) $(STDDEF_H) \
- $(STDINT_H) stdio.h stdlib.h string.h sys/stat.h sys/time.h \
- sys/types.h time.h unistd.h wchar.h wctype.h
+ $(FLOAT_H) $(FNMATCH_H) $(GLOB_H) inttypes.h $(LIMITS_H) \
+ math.h signal.h arg-nonnull.h c++defs.h warn-on-use.h \
+ $(STDBOOL_H) $(STDDEF_H) $(STDINT_H) stdio.h stdlib.h string.h \
+ sys/stat.h sys/time.h sys/types.h time.h unistd.h wchar.h \
+ wctype.h
SUFFIXES = .sed .sin
MOSTLYCLEANFILES = core *.stackdump alloca.h alloca.h-t dirent.h \
dirent.h-t errno.h errno.h-t float.h float.h-t fnmatch.h \
- fnmatch.h-t inttypes.h inttypes.h-t limits.h limits.h-t math.h \
- math.h-t signal.h signal.h-t arg-nonnull.h arg-nonnull.h-t \
- c++defs.h c++defs.h-t warn-on-use.h warn-on-use.h-t stdbool.h \
- stdbool.h-t stddef.h stddef.h-t stdint.h stdint.h-t stdio.h \
- stdio.h-t stdlib.h stdlib.h-t string.h string.h-t sys/stat.h \
- sys/stat.h-t sys/time.h sys/time.h-t sys/types.h sys/types.h-t \
- time.h time.h-t unistd.h unistd.h-t wchar.h wchar.h-t wctype.h \
- wctype.h-t
+ fnmatch.h-t glob.h glob.h-t inttypes.h inttypes.h-t limits.h \
+ limits.h-t math.h math.h-t signal.h signal.h-t arg-nonnull.h \
+ arg-nonnull.h-t c++defs.h c++defs.h-t warn-on-use.h \
+ warn-on-use.h-t stdbool.h stdbool.h-t stddef.h stddef.h-t \
+ stdint.h stdint.h-t stdio.h stdio.h-t stdlib.h stdlib.h-t \
+ string.h string.h-t sys/stat.h sys/stat.h-t sys/time.h \
+ sys/time.h-t sys/types.h sys/types.h-t time.h time.h-t \
+ unistd.h unistd.h-t wchar.h wchar.h-t wctype.h wctype.h-t
MOSTLYCLEANDIRS = sys
CLEANFILES = configmake.h configmake.h-t charset.alias ref-add.sed \
ref-del.sed
@@ -1340,11 +1353,12 @@ libgnu_a_SOURCES = dirname-lgpl.c basename-lgpl.c stripslash.c \
strnlen1.h strnlen1.c unistd.c wctype-h.c
libgnu_a_LIBADD = $(gl_LIBOBJS) @ALLOCA@
libgnu_a_DEPENDENCIES = $(gl_LIBOBJS) @ALLOCA@
-EXTRA_libgnu_a_SOURCES = alloca.c canonicalize-lgpl.c dirfd.c float.c \
- itold.c fnmatch.c fnmatch_loop.c frexp.c frexp.c frexpl.c \
- gettimeofday.c isnan.c isnand.c isnan.c isnanl.c lstat.c \
- malloc.c mbrtowc.c mbsinit.c mbsrtowcs-state.c mbsrtowcs.c \
- memchr.c memmem.c rawmemchr.c readlink.c rename.c rmdir.c \
+EXTRA_libgnu_a_SOURCES = alloca.c canonicalize-lgpl.c closedir.c \
+ dirfd.c float.c itold.c fnmatch.c fnmatch_loop.c frexp.c \
+ frexp.c frexpl.c getlogin_r.c gettimeofday.c glob.c isnan.c \
+ isnand.c isnan.c isnanl.c lstat.c malloc.c mbrtowc.c mbsinit.c \
+ mbsrtowcs-state.c mbsrtowcs.c memchr.c memmem.c mempcpy.c \
+ opendir.c rawmemchr.c readdir.c readlink.c rename.c rmdir.c \
setenv.c stat.c strchrnul.c strstr.c strtok_r.c unsetenv.c
# Use this preprocessor expression to decide whether #include_next works.
@@ -1423,6 +1437,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @***@./$(DEPDIR)/***@am__quote@
@AMDEP_TRUE@@am__include@ @***@./$(DEPDIR)/basename-***@am__quote@
@AMDEP_TRUE@@am__include@ @***@./$(DEPDIR)/canonicalize-***@am__quote@
+@AMDEP_TRUE@@am__include@ @***@./$(DEPDIR)/***@am__quote@
@AMDEP_TRUE@@am__include@ @***@./$(DEPDIR)/***@am__quote@
@AMDEP_TRUE@@am__include@ @***@./$(DEPDIR)/dirname-***@am__quote@
@AMDEP_TRUE@@am__include@ @***@./$(DEPDIR)/***@am__quote@
@@ -1430,7 +1445,9 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @***@./$(DEPDIR)/***@am__quote@
@AMDEP_TRUE@@am__include@ @***@./$(DEPDIR)/***@am__quote@
@AMDEP_TRUE@@am__include@ @***@./$(DEPDIR)/***@am__quote@
+@AMDEP_TRUE@@am__include@ @***@./$(DEPDIR)/***@am__quote@
@AMDEP_TRUE@@am__include@ @***@./$(DEPDIR)/***@am__quote@
+@AMDEP_TRUE@@am__include@ @***@./$(DEPDIR)/***@am__quote@
@AMDEP_TRUE@@am__include@ @***@./$(DEPDIR)/hard-***@am__quote@
@AMDEP_TRUE@@am__include@ @***@./$(DEPDIR)/***@am__quote@
@AMDEP_TRUE@@am__include@ @***@./$(DEPDIR)/***@am__quote@
@@ -1447,7 +1464,10 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @***@./$(DEPDIR)/***@am__quote@
@AMDEP_TRUE@@am__include@ @***@./$(DEPDIR)/***@am__quote@
@AMDEP_TRUE@@am__include@ @***@./$(DEPDIR)/***@am__quote@
+@AMDEP_TRUE@@am__include@ @***@./$(DEPDIR)/***@am__quote@
+@AMDEP_TRUE@@am__include@ @***@./$(DEPDIR)/***@am__quote@
@AMDEP_TRUE@@am__include@ @***@./$(DEPDIR)/***@am__quote@
+@AMDEP_TRUE@@am__include@ @***@./$(DEPDIR)/***@am__quote@
@AMDEP_TRUE@@am__include@ @***@./$(DEPDIR)/***@am__quote@
@AMDEP_TRUE@@am__include@ @***@./$(DEPDIR)/***@am__quote@
@AMDEP_TRUE@@am__include@ @***@./$(DEPDIR)/***@am__quote@
@@ -1936,6 +1956,21 @@ dirent.h: dirent.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H
@***@fnmatch.h: $(top_builddir)/config.status
@GL_GENERATE_FNMATCH_H_FALSE@ rm -f $@
+# We need the following in order to create <glob.h> when the system
+# doesn't have one that works with the given compiler.
+@***@glob.h: glob.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
+@GL_GENERATE_GLOB_H_TRUE@ $(AM_V_GEN)rm -f $@-t $@ && \
+@GL_GENERATE_GLOB_H_TRUE@ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
+@GL_GENERATE_GLOB_H_TRUE@ sed -e 's|@''HAVE_SYS_CDEFS_H''@|$(HAVE_SYS_CDEFS_H)|g' \
+@GL_GENERATE_GLOB_H_TRUE@ -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
+@GL_GENERATE_GLOB_H_TRUE@ -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
+@GL_GENERATE_GLOB_H_TRUE@ -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
+@GL_GENERATE_GLOB_H_TRUE@ < $(srcdir)/glob.in.h; \
+@GL_GENERATE_GLOB_H_TRUE@ } > $@-t && \
+@GL_GENERATE_GLOB_H_TRUE@ mv -f $@-t $@
+@***@glob.h: $(top_builddir)/config.status
+@GL_GENERATE_GLOB_H_FALSE@ rm -f $@
+
# We need the following in order to create <inttypes.h> when the system
# doesn't have one that works with the given compiler.
inttypes.h: inttypes.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(WARN_ON_USE_H) $(ARG_NONNULL_H)
diff --git a/gdb/gnulib/import/closedir.c b/gdb/gnulib/import/closedir.c
new file mode 100644
index 0000000000..30d1290351
--- /dev/null
+++ b/gdb/gnulib/import/closedir.c
@@ -0,0 +1,71 @@
+/* Stop reading the entries of a directory.
+ Copyright (C) 2006-2016 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include <config.h>
+
+/* Specification. */
+#include <dirent.h>
+
+#if REPLACE_FCHDIR
+# include <unistd.h>
+#endif
+
+#if HAVE_CLOSEDIR
+
+/* Override closedir(), to keep track of the open file descriptors.
+ Needed because there is a function dirfd(). */
+
+#else
+
+# include <stdlib.h>
+
+# include "dirent-private.h"
+
+#endif
+
+int
+closedir (DIR *dirp)
+{
+# if REPLACE_FCHDIR || REPLACE_DIRFD
+ int fd = dirfd (dirp);
+# endif
+ int retval;
+
+#if HAVE_CLOSEDIR
+# undef closedir
+
+ retval = closedir (dirp);
+
+# ifdef __KLIBC__
+ if (!retval)
+ _gl_unregister_dirp_fd (fd);
+# endif
+#else
+
+ if (dirp->current != INVALID_HANDLE_VALUE)
+ FindClose (dirp->current);
+ free (dirp);
+
+ retval = 0;
+
+#endif
+
+#if REPLACE_FCHDIR
+ if (retval >= 0)
+ _gl_unregister_fd (fd);
+#endif
+ return retval;
+}
diff --git a/gdb/gnulib/import/dirent-private.h b/gdb/gnulib/import/dirent-private.h
new file mode 100644
index 0000000000..9b200f30da
--- /dev/null
+++ b/gdb/gnulib/import/dirent-private.h
@@ -0,0 +1,40 @@
+/* Private details of the DIR type.
+ Copyright (C) 2011-2016 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#ifndef _DIRENT_PRIVATE_H
+#define _DIRENT_PRIVATE_H 1
+
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+
+struct gl_directory
+{
+ /* Status, or error code to produce in next readdir() call.
+ -2 means the end of the directory is already reached,
+ -1 means the entry was already filled by FindFirstFile,
+ 0 means the entry needs to be filled using FindNextFile.
+ A positive value is an error code. */
+ int status;
+ /* Handle, reading the directory, at current position. */
+ HANDLE current;
+ /* Found directory entry. */
+ WIN32_FIND_DATA entry;
+ /* Argument to pass to FindFirstFile. It consists of the absolutized
+ directory name, followed by a directory separator and the wildcards. */
+ char dir_name_mask[1];
+};
+
+#endif /* _DIRENT_PRIVATE_H */
diff --git a/gdb/gnulib/import/filename.h b/gdb/gnulib/import/filename.h
new file mode 100644
index 0000000000..7d2c31a8c3
--- /dev/null
+++ b/gdb/gnulib/import/filename.h
@@ -0,0 +1,54 @@
+/* Basic filename support macros.
+ Copyright (C) 2001-2004, 2007-2016 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#ifndef _FILENAME_H
+#define _FILENAME_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/* Pathname support.
+ ISSLASH(C) tests whether C is a directory separator character.
+ IS_ABSOLUTE_PATH(P) tests whether P is an absolute path. If it is not,
+ it may be concatenated to a directory pathname.
+ IS_PATH_WITH_DIR(P) tests whether P contains a directory specification.
+ */
+#if defined _WIN32 || defined __WIN32__ || defined __CYGWIN__ || defined __EMX__ || defined __DJGPP__
+ /* Native Windows, Cygwin, OS/2, DOS */
+# define ISSLASH(C) ((C) == '/' || (C) == '\\')
+# define HAS_DEVICE(P) \
+ ((((P)[0] >= 'A' && (P)[0] <= 'Z') || ((P)[0] >= 'a' && (P)[0] <= 'z')) \
+ && (P)[1] == ':')
+# define IS_ABSOLUTE_PATH(P) (ISSLASH ((P)[0]) || HAS_DEVICE (P))
+# define IS_PATH_WITH_DIR(P) \
+ (strchr (P, '/') != NULL || strchr (P, '\\') != NULL || HAS_DEVICE (P))
+# define FILE_SYSTEM_PREFIX_LEN(P) (HAS_DEVICE (P) ? 2 : 0)
+#else
+ /* Unix */
+# define ISSLASH(C) ((C) == '/')
+# define IS_ABSOLUTE_PATH(P) ISSLASH ((P)[0])
+# define IS_PATH_WITH_DIR(P) (strchr (P, '/') != NULL)
+# define FILE_SYSTEM_PREFIX_LEN(P) 0
+#endif
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _FILENAME_H */
diff --git a/gdb/gnulib/import/getlogin_r.c b/gdb/gnulib/import/getlogin_r.c
new file mode 100644
index 0000000000..2bafb55fb1
--- /dev/null
+++ b/gdb/gnulib/import/getlogin_r.c
@@ -0,0 +1,87 @@
+/* Provide a working getlogin_r for systems which lack it.
+
+ Copyright (C) 2005-2007, 2010-2016 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, see <http://www.gnu.org/licenses/>. */
+
+/* Written by Paul Eggert, Derek Price, and Bruno Haible. */
+
+#include <config.h>
+
+/* Specification. */
+#include <unistd.h>
+
+#include <errno.h>
+#include <string.h>
+
+#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
+# define WIN32_LEAN_AND_MEAN
+# include <windows.h>
+#else
+# if !HAVE_DECL_GETLOGIN
+extern char *getlogin (void);
+# endif
+#endif
+
+/* See unistd.in.h for documentation. */
+int
+getlogin_r (char *name, size_t size)
+{
+#undef getlogin_r
+#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
+ /* Native Windows platform. */
+ DWORD sz;
+
+ /* When size > 0x7fff, the doc says that GetUserName will fail.
+ Actually, on Windows XP SP3, it succeeds. But let's be safe,
+ for the sake of older Windows versions. */
+ if (size > 0x7fff)
+ size = 0x7fff;
+ sz = size;
+ if (!GetUserName (name, &sz))
+ {
+ if (GetLastError () == ERROR_INSUFFICIENT_BUFFER)
+ /* In this case, the doc says that sz contains the required size, but
+ actually, on Windows XP SP3, it contains 2 * the required size. */
+ return ERANGE;
+ else
+ return ENOENT;
+ }
+ return 0;
+#elif HAVE_GETLOGIN_R
+ /* Platform with a getlogin_r() function. */
+ int ret = getlogin_r (name, size);
+
+ if (ret == 0 && memchr (name, '\0', size) == NULL)
+ /* name contains a truncated result. */
+ return ERANGE;
+ return ret;
+#else
+ /* Platform with a getlogin() function. */
+ char *n;
+ size_t nlen;
+
+ errno = 0;
+ n = getlogin ();
+ if (!n)
+ /* ENOENT is a reasonable errno value if getlogin returns NULL. */
+ return (errno != 0 ? errno : ENOENT);
+
+ nlen = strlen (n);
+ if (size <= nlen)
+ return ERANGE;
+ memcpy (name, n, nlen + 1);
+ return 0;
+#endif
+}
diff --git a/gdb/gnulib/import/glob-libc.h b/gdb/gnulib/import/glob-libc.h
new file mode 100644
index 0000000000..6256077f70
--- /dev/null
+++ b/gdb/gnulib/import/glob-libc.h
@@ -0,0 +1,212 @@
+/* Copyright (C) 1991-1992, 1995-1998, 2000-2001, 2004-2007, 2009-2016 Free
+ Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#ifndef _GLOB_H
+#define _GLOB_H 1
+
+#ifndef __GLOB_GNULIB
+# include <sys/cdefs.h>
+#endif
+
+/* GCC 2.95 and later have "__restrict"; C99 compilers have
+ "restrict", and "configure" may have defined "restrict".
+ Other compilers use __restrict, __restrict__, and _Restrict, and
+ 'configure' might #define 'restrict' to those words, so pick a
+ different name. */
+#ifndef _Restrict_
+# if 199901L <= __STDC_VERSION__
+# define _Restrict_ restrict
+# elif 2 < __GNUC__ || (2 == __GNUC__ && 95 <= __GNUC_MINOR__)
+# define _Restrict_ __restrict
+# else
+# define _Restrict_
+# endif
+#endif
+
+__BEGIN_DECLS
+
+/* We need 'size_t' for the following definitions. */
+#ifndef __size_t
+# if defined __GNUC__ && __GNUC__ >= 2
+typedef __SIZE_TYPE__ __size_t;
+# ifdef __USE_XOPEN
+typedef __SIZE_TYPE__ size_t;
+# endif
+# else
+# include <stddef.h>
+# ifndef __size_t
+# define __size_t size_t
+# endif
+# endif
+#else
+/* The GNU CC stddef.h version defines __size_t as empty. We need a real
+ definition. */
+# undef __size_t
+# define __size_t size_t
+#endif
+
+/* Bits set in the FLAGS argument to 'glob'. */
+#define GLOB_ERR (1 << 0)/* Return on read errors. */
+#define GLOB_MARK (1 << 1)/* Append a slash to each name. */
+#define GLOB_NOSORT (1 << 2)/* Don't sort the names. */
+#define GLOB_DOOFFS (1 << 3)/* Insert PGLOB->gl_offs NULLs. */
+#define GLOB_NOCHECK (1 << 4)/* If nothing matches, return the pattern. */
+#define GLOB_APPEND (1 << 5)/* Append to results of a previous call. */
+#define GLOB_NOESCAPE (1 << 6)/* Backslashes don't quote metacharacters. */
+#define GLOB_PERIOD (1 << 7)/* Leading '.' can be matched by metachars. */
+
+#if !defined __USE_POSIX2 || defined __USE_BSD || defined __USE_GNU
+# define GLOB_MAGCHAR (1 << 8)/* Set in gl_flags if any metachars seen. */
+# define GLOB_ALTDIRFUNC (1 << 9)/* Use gl_opendir et al functions. */
+# define GLOB_BRACE (1 << 10)/* Expand "{a,b}" to "a" "b". */
+# define GLOB_NOMAGIC (1 << 11)/* If no magic chars, return the pattern. */
+# define GLOB_TILDE (1 << 12)/* Expand ~user and ~ to home directories. */
+# define GLOB_ONLYDIR (1 << 13)/* Match only directories. */
+# define GLOB_TILDE_CHECK (1 << 14)/* Like GLOB_TILDE but return an error
+ if the user name is not available. */
+# define __GLOB_FLAGS (GLOB_ERR|GLOB_MARK|GLOB_NOSORT|GLOB_DOOFFS| \
+ GLOB_NOESCAPE|GLOB_NOCHECK|GLOB_APPEND| \
+ GLOB_PERIOD|GLOB_ALTDIRFUNC|GLOB_BRACE| \
+ GLOB_NOMAGIC|GLOB_TILDE|GLOB_ONLYDIR|GLOB_TILDE_CHECK)
+#else
+# define __GLOB_FLAGS (GLOB_ERR|GLOB_MARK|GLOB_NOSORT|GLOB_DOOFFS| \
+ GLOB_NOESCAPE|GLOB_NOCHECK|GLOB_APPEND| \
+ GLOB_PERIOD)
+#endif
+
+/* Error returns from 'glob'. */
+#define GLOB_NOSPACE 1 /* Ran out of memory. */
+#define GLOB_ABORTED 2 /* Read error. */
+#define GLOB_NOMATCH 3 /* No matches found. */
+#define GLOB_NOSYS 4 /* Not implemented. */
+#ifdef __USE_GNU
+/* Previous versions of this file defined GLOB_ABEND instead of
+ GLOB_ABORTED. Provide a compatibility definition here. */
+# define GLOB_ABEND GLOB_ABORTED
+#endif
+
+/* Structure describing a globbing run. */
+#ifdef __USE_GNU
+struct stat;
+#endif
+typedef struct
+ {
+ __size_t gl_pathc; /* Count of paths matched by the pattern. */
+ char **gl_pathv; /* List of matched pathnames. */
+ __size_t gl_offs; /* Slots to reserve in 'gl_pathv'. */
+ int gl_flags; /* Set to FLAGS, maybe | GLOB_MAGCHAR. */
+
+ /* If the GLOB_ALTDIRFUNC flag is set, the following functions
+ are used instead of the normal file access functions. */
+ void (*gl_closedir) (void *);
+#ifdef __USE_GNU
+ struct dirent *(*gl_readdir) (void *);
+#else
+ void *(*gl_readdir) (void *);
+#endif
+ void *(*gl_opendir) (const char *);
+#ifdef __USE_GNU
+ int (*gl_lstat) (const char *_Restrict_, struct stat *_Restrict_);
+ int (*gl_stat) (const char *_Restrict_, struct stat *_Restrict_);
+#else
+ int (*gl_lstat) (const char *_Restrict_, void *_Restrict_);
+ int (*gl_stat) (const char *_Restrict_, void *_Restrict_);
+#endif
+ } glob_t;
+
+#if defined __USE_LARGEFILE64 && !defined __GLOB_GNULIB
+# ifdef __USE_GNU
+struct stat64;
+# endif
+typedef struct
+ {
+ __size_t gl_pathc;
+ char **gl_pathv;
+ __size_t gl_offs;
+ int gl_flags;
+
+ /* If the GLOB_ALTDIRFUNC flag is set, the following functions
+ are used instead of the normal file access functions. */
+ void (*gl_closedir) (void *);
+# ifdef __USE_GNU
+ struct dirent64 *(*gl_readdir) (void *);
+# else
+ void *(*gl_readdir) (void *);
+# endif
+ void *(*gl_opendir) (const char *);
+# ifdef __USE_GNU
+ int (*gl_lstat) (const char *_Restrict_, struct stat64 *_Restrict_);
+ int (*gl_stat) (const char *_Restrict_, struct stat64 *_Restrict_);
+# else
+ int (*gl_lstat) (const char *_Restrict_, void *_Restrict_);
+ int (*gl_stat) (const char *_Restrict_, void *_Restrict_);
+# endif
+ } glob64_t;
+#endif
+
+#if __USE_FILE_OFFSET64 && __GNUC__ < 2 && !defined __GLOB_GNULIB
+# define glob glob64
+# define globfree globfree64
+#endif
+
+/* Do glob searching for PATTERN, placing results in PGLOB.
+ The bits defined above may be set in FLAGS.
+ If a directory cannot be opened or read and ERRFUNC is not nil,
+ it is called with the pathname that caused the error, and the
+ 'errno' value from the failing call; if it returns non-zero
+ 'glob' returns GLOB_ABEND; if it returns zero, the error is ignored.
+ If memory cannot be allocated for PGLOB, GLOB_NOSPACE is returned.
+ Otherwise, 'glob' returns zero. */
+#if !defined __USE_FILE_OFFSET64 || __GNUC__ < 2 || defined __GLOB_GNULIB
+extern int glob (const char *_Restrict_ __pattern, int __flags,
+ int (*__errfunc) (const char *, int),
+ glob_t *_Restrict_ __pglob) __THROW _GL_ARG_NONNULL ((1, 4));
+
+/* Free storage allocated in PGLOB by a previous 'glob' call. */
+extern void globfree (glob_t *__pglob) __THROW _GL_ARG_NONNULL ((1));
+#else
+extern int __REDIRECT_NTH (glob, (const char *_Restrict_ __pattern,
+ int __flags,
+ int (*__errfunc) (const char *, int),
+ glob_t *_Restrict_ __pglob), glob64);
+
+extern void __REDIRECT_NTH (globfree, (glob_t *__pglob), globfree64);
+#endif
+
+#if defined __USE_LARGEFILE64 && !defined __GLOB_GNULIB
+extern int glob64 (const char *_Restrict_ __pattern, int __flags,
+ int (*__errfunc) (const char *, int),
+ glob64_t *_Restrict_ __pglob)
+ __THROW _GL_ARG_NONNULL ((1, 4));
+
+extern void globfree64 (glob64_t *__pglob) __THROW _GL_ARG_NONNULL ((1));
+#endif
+
+
+#ifdef __USE_GNU
+/* Return nonzero if PATTERN contains any metacharacters.
+ Metacharacters can be quoted with backslashes if QUOTE is nonzero.
+
+ This function is not part of the interface specified by POSIX.2
+ but several programs want to use it. */
+extern int glob_pattern_p (const char *__pattern, int __quote)
+ __THROW _GL_ARG_NONNULL ((1));
+#endif
+
+__END_DECLS
+
+#endif /* glob.h */
diff --git a/gdb/gnulib/import/glob.c b/gdb/gnulib/import/glob.c
new file mode 100644
index 0000000000..4b04b902e5
--- /dev/null
+++ b/gdb/gnulib/import/glob.c
@@ -0,0 +1,1808 @@
+/* Copyright (C) 1991-2016 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public
+ License as published by the Free Software Foundation; either
+ version 3 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef _LIBC
+/* Don't use __attribute__ __nonnull__ in this compilation unit. Otherwise gcc
+ optimizes away the pattern == NULL || pglob == NULL tests below. */
+# define _GL_ARG_NONNULL(params)
+# include <config.h>
+#endif
+
+#include <glob.h>
+
+#include <errno.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <stdbool.h>
+#include <stddef.h>
+#include <stdint.h>
+
+/* Outcomment the following line for production quality code. */
+/* #define NDEBUG 1 */
+#include <assert.h>
+
+#include <stdio.h> /* Needed on stupid SunOS for assert. */
+
+#ifndef GLOB_ONLY_P
+
+#include <unistd.h>
+#if !defined POSIX && defined _POSIX_VERSION
+# define POSIX
+#endif
+
+#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
+# define WINDOWS32
+#endif
+
+#ifndef WINDOWS32
+# include <pwd.h>
+#endif
+
+#include <errno.h>
+#ifndef __set_errno
+# define __set_errno(val) errno = (val)
+#endif
+
+#include <dirent.h>
+#include <stdlib.h>
+#include <string.h>
+#include <alloca.h>
+
+#ifdef _LIBC
+# undef strdup
+# define strdup(str) __strdup (str)
+# define sysconf(id) __sysconf (id)
+# define closedir(dir) __closedir (dir)
+# define opendir(name) __opendir (name)
+# define readdir(str) __readdir64 (str)
+# define getpwnam_r(name, bufp, buf, len, res) \
+ __getpwnam_r (name, bufp, buf, len, res)
+# ifndef __stat64
+# define __stat64(fname, buf) __xstat64 (_STAT_VER, fname, buf)
+# endif
+# define struct_stat64 struct stat64
+#else /* !_LIBC */
+# define __getlogin_r(buf, len) getlogin_r (buf, len)
+# define __stat64(fname, buf) stat (fname, buf)
+# define __fxstatat64(_, d, f, st, flag) fstatat (d, f, st, flag)
+# define struct_stat64 struct stat
+# ifndef __MVS__
+# define __alloca alloca
+# endif
+# define __readdir readdir
+# define __glob_pattern_p glob_pattern_p
+# define COMPILE_GLOB64
+#endif /* _LIBC */
+
+#include <fnmatch.h>
+
+#include "flexmember.h"
+
+#ifdef _SC_GETPW_R_SIZE_MAX
+# define GETPW_R_SIZE_MAX() sysconf (_SC_GETPW_R_SIZE_MAX)
+#else
+# define GETPW_R_SIZE_MAX() (-1)
+#endif
+#ifdef _SC_LOGIN_NAME_MAX
+# define GET_LOGIN_NAME_MAX() sysconf (_SC_LOGIN_NAME_MAX)
+#else
+# define GET_LOGIN_NAME_MAX() (-1)
+#endif
+
+static const char *next_brace_sub (const char *begin, int flags) __THROWNL;
+
+/* A representation of a directory entry which does not depend on the
+ layout of struct dirent, or the size of ino_t. */
+struct readdir_result
+{
+ const char *name;
+# if defined _DIRENT_HAVE_D_TYPE || defined HAVE_STRUCT_DIRENT_D_TYPE
+ uint8_t type;
+# endif
+ bool skip_entry;
+};
+
+# if defined _DIRENT_HAVE_D_TYPE || defined HAVE_STRUCT_DIRENT_D_TYPE
+/* Initializer based on the d_type member of struct dirent. */
+# define D_TYPE_TO_RESULT(source) (source)->d_type,
+
+/* True if the directory entry D might be a symbolic link. */
+static bool
+readdir_result_might_be_symlink (struct readdir_result d)
+{
+ return d.type == DT_UNKNOWN || d.type == DT_LNK;
+}
+
+/* True if the directory entry D might be a directory. */
+static bool
+readdir_result_might_be_dir (struct readdir_result d)
+{
+ return d.type == DT_DIR || readdir_result_might_be_symlink (d);
+}
+# else /* defined _DIRENT_HAVE_D_TYPE || defined HAVE_STRUCT_DIRENT_D_TYPE */
+# define D_TYPE_TO_RESULT(source)
+
+/* If we do not have type information, symbolic links and directories
+ are always a possibility. */
+
+static bool
+readdir_result_might_be_symlink (struct readdir_result d)
+{
+ return true;
+}
+
+static bool
+readdir_result_might_be_dir (struct readdir_result d)
+{
+ return true;
+}
+
+# endif /* defined _DIRENT_HAVE_D_TYPE || defined HAVE_STRUCT_DIRENT_D_TYPE */
+
+# if (defined POSIX || defined WINDOWS32) && !defined __GNU_LIBRARY__
+/* Initializer for skip_entry. POSIX does not require that the d_ino
+ field be present, and some systems do not provide it. */
+# define D_INO_TO_RESULT(source) false,
+# else
+# define D_INO_TO_RESULT(source) (source)->d_ino == 0,
+# endif
+
+/* Construct an initializer for a struct readdir_result object from a
+ struct dirent *. No copy of the name is made. */
+#define READDIR_RESULT_INITIALIZER(source) \
+ { \
+ source->d_name, \
+ D_TYPE_TO_RESULT (source) \
+ D_INO_TO_RESULT (source) \
+ }
+
+#endif /* !defined GLOB_ONLY_P */
+
+/* Call gl_readdir on STREAM. This macro can be overridden to reduce
+ type safety if an old interface version needs to be supported. */
+#ifndef GL_READDIR
+# define GL_READDIR(pglob, stream) ((pglob)->gl_readdir (stream))
+#endif
+
+/* Extract name and type from directory entry. No copy of the name is
+ made. If SOURCE is NULL, result name is NULL. Keep in sync with
+ convert_dirent64 below. */
+static struct readdir_result
+convert_dirent (const struct dirent *source)
+{
+ if (source == NULL)
+ {
+ struct readdir_result result = { NULL, };
+ return result;
+ }
+ struct readdir_result result = READDIR_RESULT_INITIALIZER (source);
+ return result;
+}
+
+#ifndef COMPILE_GLOB64
+/* Like convert_dirent, but works on struct dirent64 instead. Keep in
+ sync with convert_dirent above. */
+static struct readdir_result
+convert_dirent64 (const struct dirent64 *source)
+{
+ if (source == NULL)
+ {
+ struct readdir_result result = { NULL, };
+ return result;
+ }
+ struct readdir_result result = READDIR_RESULT_INITIALIZER (source);
+ return result;
+}
+#endif
+
+
+#ifndef attribute_hidden
+# define attribute_hidden
+#endif
+
+#ifndef __attribute_noinline__
+# if __GNUC__ < 3 || (__GNUC__ == 3 && __GNUC_MINOR__ < 1)
+# define __attribute_noinline__ /* Ignore */
+#else
+# define __attribute_noinline__ __attribute__ ((__noinline__))
+# endif
+#endif
+
+#if ! defined __builtin_expect && __GNUC__ < 3
+# define __builtin_expect(expr, expected) (expr)
+#endif
+
+#ifndef __glibc_unlikely
+# define __glibc_unlikely(expr) __builtin_expect (expr, 0)
+#endif
+
+#ifndef _LIBC
+/* The results of opendir() in this file are not used with dirfd and fchdir,
+ and we do not leak fds to any single-threaded code that could use stdio,
+ therefore save some unnecessary recursion in fchdir.c and opendir_safer.c.
+ FIXME - if the kernel ever adds support for multi-thread safety for
+ avoiding standard fds, then we should use opendir_safer. */
+# ifdef GNULIB_defined_opendir
+# undef opendir
+# endif
+# ifdef GNULIB_defined_closedir
+# undef closedir
+# endif
+
+/* Just use malloc. */
+# define __libc_use_alloca(n) false
+# define alloca_account(len, avar) ((void) (len), (void) (avar), (void *) 0)
+# define extend_alloca_account(buf, len, newlen, avar) \
+ ((void) (buf), (void) (len), (void) (newlen), (void) (avar), (void *) 0)
+#endif
+
+#ifndef __has_builtin
+# define __has_builtin(x) 0
+#endif
+
+/* Set *R = A + B. Return true if the answer is mathematically
+ incorrect due to overflow; in this case, *R is the low order
+ bits of the correct answer.. */
+
+static bool
+size_add_wrapv (size_t a, size_t b, size_t *r)
+{
+#if 5 <= __GNUC__ || __has_builtin (__builtin_add_overflow)
+ return __builtin_add_overflow (a, b, r);
+#else
+ *r = a + b;
+ return *r < a;
+#endif
+}
+
+static bool
+glob_use_alloca (size_t alloca_used, size_t len)
+{
+ size_t size;
+ return (!size_add_wrapv (alloca_used, len, &size)
+ && __libc_use_alloca (size));
+}
+
+static int glob_in_dir (const char *pattern, const char *directory,
+ int flags, int (*errfunc) (const char *, int),
+ glob_t *pglob, size_t alloca_used);
+extern int __glob_pattern_type (const char *pattern, int quote)
+ attribute_hidden;
+
+#ifndef GLOB_ONLY_P
+static int prefix_array (const char *prefix, char **array, size_t n) __THROWNL;
+static int collated_compare (const void *, const void *) __THROWNL;
+
+
+/* Find the end of the sub-pattern in a brace expression. */
+static const char *
+next_brace_sub (const char *cp, int flags)
+{
+ size_t depth = 0;
+ while (*cp != '\0')
+ if ((flags & GLOB_NOESCAPE) == 0 && *cp == '\\')
+ {
+ if (*++cp == '\0')
+ break;
+ ++cp;
+ }
+ else
+ {
+ if ((*cp == '}' && depth-- == 0) || (*cp == ',' && depth == 0))
+ break;
+
+ if (*cp++ == '{')
+ depth++;
+ }
+
+ return *cp != '\0' ? cp : NULL;
+}
+
+#endif /* !defined GLOB_ONLY_P */
+
+/* Do glob searching for PATTERN, placing results in PGLOB.
+ The bits defined above may be set in FLAGS.
+ If a directory cannot be opened or read and ERRFUNC is not nil,
+ it is called with the pathname that caused the error, and the
+ 'errno' value from the failing call; if it returns non-zero
+ 'glob' returns GLOB_ABORTED; if it returns zero, the error is ignored.
+ If memory cannot be allocated for PGLOB, GLOB_NOSPACE is returned.
+ Otherwise, 'glob' returns zero. */
+int
+#ifdef GLOB_ATTRIBUTE
+GLOB_ATTRIBUTE
+#endif
+glob (const char *pattern, int flags, int (*errfunc) (const char *, int),
+ glob_t *pglob)
+{
+ const char *filename;
+ char *dirname = NULL;
+ size_t dirlen;
+ int status;
+ size_t oldcount;
+ int meta;
+ int dirname_modified;
+ int malloc_dirname = 0;
+ glob_t dirs;
+ int retval = 0;
+ size_t alloca_used = 0;
+
+ if (pattern == NULL || pglob == NULL || (flags & ~__GLOB_FLAGS) != 0)
+ {
+ __set_errno (EINVAL);
+ return -1;
+ }
+
+ /* POSIX requires all slashes to be matched. This means that with
+ a trailing slash we must match only directories. */
+ if (pattern[0] && pattern[strlen (pattern) - 1] == '/')
+ flags |= GLOB_ONLYDIR;
+
+ if (!(flags & GLOB_DOOFFS))
+ /* Have to do this so 'globfree' knows where to start freeing. It
+ also makes all the code that uses gl_offs simpler. */
+ pglob->gl_offs = 0;
+
+ if (flags & GLOB_BRACE)
+ {
+ const char *begin;
+
+ if (flags & GLOB_NOESCAPE)
+ begin = strchr (pattern, '{');
+ else
+ {
+ begin = pattern;
+ while (1)
+ {
+ if (*begin == '\0')
+ {
+ begin = NULL;
+ break;
+ }
+
+ if (*begin == '\\' && begin[1] != '\0')
+ ++begin;
+ else if (*begin == '{')
+ break;
+
+ ++begin;
+ }
+ }
+
+ if (begin != NULL)
+ {
+ /* Allocate working buffer large enough for our work. Note that
+ we have at least an opening and closing brace. */
+ size_t firstc;
+ char *alt_start;
+ const char *p;
+ const char *next;
+ const char *rest;
+ size_t rest_len;
+ char *onealt;
+ size_t pattern_len = strlen (pattern) - 1;
+ int alloca_onealt = glob_use_alloca (alloca_used, pattern_len);
+ if (alloca_onealt)
+ onealt = alloca_account (pattern_len, alloca_used);
+ else
+ {
+ onealt = malloc (pattern_len);
+ if (onealt == NULL)
+ {
+ if (!(flags & GLOB_APPEND))
+ {
+ pglob->gl_pathc = 0;
+ pglob->gl_pathv = NULL;
+ }
+ return GLOB_NOSPACE;
+ }
+ }
+
+ /* We know the prefix for all sub-patterns. */
+ alt_start = mempcpy (onealt, pattern, begin - pattern);
+
+ /* Find the first sub-pattern and at the same time find the
+ rest after the closing brace. */
+ next = next_brace_sub (begin + 1, flags);
+ if (next == NULL)
+ {
+ /* It is an invalid expression. */
+ illegal_brace:
+ if (__glibc_unlikely (!alloca_onealt))
+ free (onealt);
+ return glob (pattern, flags & ~GLOB_BRACE, errfunc, pglob);
+ }
+
+ /* Now find the end of the whole brace expression. */
+ rest = next;
+ while (*rest != '}')
+ {
+ rest = next_brace_sub (rest + 1, flags);
+ if (rest == NULL)
+ /* It is an illegal expression. */
+ goto illegal_brace;
+ }
+ /* Please note that we now can be sure the brace expression
+ is well-formed. */
+ rest_len = strlen (++rest) + 1;
+
+ /* We have a brace expression. BEGIN points to the opening {,
+ NEXT points past the terminator of the first element, and END
+ points past the final }. We will accumulate result names from
+ recursive runs for each brace alternative in the buffer using
+ GLOB_APPEND. */
+
+ if (!(flags & GLOB_APPEND))
+ {
+ /* This call is to set a new vector, so clear out the
+ vector so we can append to it. */
+ pglob->gl_pathc = 0;
+ pglob->gl_pathv = NULL;
+ }
+ firstc = pglob->gl_pathc;
+
+ p = begin + 1;
+ while (1)
+ {
+ int result;
+
+ /* Construct the new glob expression. */
+ mempcpy (mempcpy (alt_start, p, next - p), rest, rest_len);
+
+ result = glob (onealt,
+ ((flags & ~(GLOB_NOCHECK | GLOB_NOMAGIC))
+ | GLOB_APPEND), errfunc, pglob);
+
+ /* If we got an error, return it. */
+ if (result && result != GLOB_NOMATCH)
+ {
+ if (__glibc_unlikely (!alloca_onealt))
+ free (onealt);
+ if (!(flags & GLOB_APPEND))
+ {
+ globfree (pglob);
+ pglob->gl_pathc = 0;
+ }
+ return result;
+ }
+
+ if (*next == '}')
+ /* We saw the last entry. */
+ break;
+
+ p = next + 1;
+ next = next_brace_sub (p, flags);
+ assert (next != NULL);
+ }
+
+ if (__glibc_unlikely (!alloca_onealt))
+ free (onealt);
+
+ if (pglob->gl_pathc != firstc)
+ /* We found some entries. */
+ return 0;
+ else if (!(flags & (GLOB_NOCHECK|GLOB_NOMAGIC)))
+ return GLOB_NOMATCH;
+ }
+ }
+
+ if (!(flags & GLOB_APPEND))
+ {
+ pglob->gl_pathc = 0;
+ if (!(flags & GLOB_DOOFFS))
+ pglob->gl_pathv = NULL;
+ else
+ {
+ size_t i;
+
+ if (pglob->gl_offs >= SIZE_MAX / sizeof (char *))
+ return GLOB_NOSPACE;
+
+ pglob->gl_pathv = malloc ((pglob->gl_offs + 1) * sizeof (char *));
+ if (pglob->gl_pathv == NULL)
+ return GLOB_NOSPACE;
+
+ for (i = 0; i <= pglob->gl_offs; ++i)
+ pglob->gl_pathv[i] = NULL;
+ }
+ }
+
+ oldcount = pglob->gl_pathc + pglob->gl_offs;
+
+ /* Find the filename. */
+ filename = strrchr (pattern, '/');
+#if defined __MSDOS__ || defined WINDOWS32
+ /* The case of "d:pattern". Since ':' is not allowed in
+ file names, we can safely assume that wherever it
+ happens in pattern, it signals the filename part. This
+ is so we could some day support patterns like "[a-z]:foo". */
+ if (filename == NULL)
+ filename = strchr (pattern, ':');
+#endif /* __MSDOS__ || WINDOWS32 */
+ dirname_modified = 0;
+ if (filename == NULL)
+ {
+ /* This can mean two things: a simple name or "~name". The latter
+ case is nothing but a notation for a directory. */
+ if ((flags & (GLOB_TILDE|GLOB_TILDE_CHECK)) && pattern[0] == '~')
+ {
+ dirname = (char *) pattern;
+ dirlen = strlen (pattern);
+
+ /* Set FILENAME to NULL as a special flag. This is ugly but
+ other solutions would require much more code. We test for
+ this special case below. */
+ filename = NULL;
+ }
+ else
+ {
+ if (__glibc_unlikely (pattern[0] == '\0'))
+ {
+ dirs.gl_pathv = NULL;
+ goto no_matches;
+ }
+
+ filename = pattern;
+#ifdef _AMIGA
+ dirname = (char *) "";
+#else
+ dirname = (char *) ".";
+#endif
+ dirlen = 0;
+ }
+ }
+ else if (filename == pattern
+ || (filename == pattern + 1 && pattern[0] == '\\'
+ && (flags & GLOB_NOESCAPE) == 0))
+ {
+ /* "/pattern" or "\\/pattern". */
+ dirname = (char *) "/";
+ dirlen = 1;
+ ++filename;
+ }
+ else
+ {
+ char *newp;
+ dirlen = filename - pattern;
+#if defined __MSDOS__ || defined WINDOWS32
+ if (*filename == ':'
+ || (filename > pattern + 1 && filename[-1] == ':'))
+ {
+ char *drive_spec;
+
+ ++dirlen;
+ drive_spec = __alloca (dirlen + 1);
+ *((char *) mempcpy (drive_spec, pattern, dirlen)) = '\0';
+ /* For now, disallow wildcards in the drive spec, to
+ prevent infinite recursion in glob. */
+ if (__glob_pattern_p (drive_spec, !(flags & GLOB_NOESCAPE)))
+ return GLOB_NOMATCH;
+ /* If this is "d:pattern", we need to copy ':' to DIRNAME
+ as well. If it's "d:/pattern", don't remove the slash
+ from "d:/", since "d:" and "d:/" are not the same.*/
+ }
+#endif
+ if (glob_use_alloca (alloca_used, dirlen + 1))
+ newp = alloca_account (dirlen + 1, alloca_used);
+ else
+ {
+ newp = malloc (dirlen + 1);
+ if (newp == NULL)
+ return GLOB_NOSPACE;
+ malloc_dirname = 1;
+ }
+ *((char *) mempcpy (newp, pattern, dirlen)) = '\0';
+ dirname = newp;
+ ++filename;
+
+ if (filename[0] == '\0'
+#if defined __MSDOS__ || defined WINDOWS32
+ && dirname[dirlen - 1] != ':'
+ && (dirlen < 3 || dirname[dirlen - 2] != ':'
+ || dirname[dirlen - 1] != '/')
+#endif
+ && dirlen > 1)
+ /* "pattern/". Expand "pattern", appending slashes. */
+ {
+ int orig_flags = flags;
+ int val;
+ if (!(flags & GLOB_NOESCAPE) && dirname[dirlen - 1] == '\\')
+ {
+ /* "pattern\\/". Remove the final backslash if it hasn't
+ been quoted. */
+ char *p = (char *) &dirname[dirlen - 1];
+
+ while (p > dirname && p[-1] == '\\') --p;
+ if ((&dirname[dirlen] - p) & 1)
+ {
+ *(char *) &dirname[--dirlen] = '\0';
+ flags &= ~(GLOB_NOCHECK | GLOB_NOMAGIC);
+ }
+ }
+ val = glob (dirname, flags | GLOB_MARK, errfunc, pglob);
+ if (val == 0)
+ pglob->gl_flags = ((pglob->gl_flags & ~GLOB_MARK)
+ | (flags & GLOB_MARK));
+ else if (val == GLOB_NOMATCH && flags != orig_flags)
+ {
+ /* Make sure globfree (&dirs); is a nop. */
+ dirs.gl_pathv = NULL;
+ flags = orig_flags;
+ oldcount = pglob->gl_pathc + pglob->gl_offs;
+ goto no_matches;
+ }
+ retval = val;
+ goto out;
+ }
+ }
+
+ if ((flags & (GLOB_TILDE|GLOB_TILDE_CHECK)) && dirname[0] == '~')
+ {
+ if (dirname[1] == '\0' || dirname[1] == '/'
+ || (!(flags & GLOB_NOESCAPE) && dirname[1] == '\\'
+ && (dirname[2] == '\0' || dirname[2] == '/')))
+ {
+ /* Look up home directory. */
+ char *home_dir = getenv ("HOME");
+ int malloc_home_dir = 0;
+# ifdef _AMIGA
+ if (home_dir == NULL || home_dir[0] == '\0')
+ home_dir = "SYS:";
+# else
+# ifdef WINDOWS32
+ /* Windows NT defines HOMEDRIVE and HOMEPATH. But give preference
+ to HOME, because the user can change HOME. */
+ if (home_dir == NULL || home_dir[0] == '\0')
+ {
+ const char *home_drive = getenv ("HOMEDRIVE");
+ const char *home_path = getenv ("HOMEPATH");
+
+ if (home_drive != NULL && home_path != NULL)
+ {
+ size_t home_drive_len = strlen (home_drive);
+ size_t home_path_len = strlen (home_path);
+ char *mem = alloca (home_drive_len + home_path_len + 1);
+
+ memcpy (mem, home_drive, home_drive_len);
+ memcpy (mem + home_drive_len, home_path, home_path_len + 1);
+ home_dir = mem;
+ }
+ else
+ home_dir = "c:/users/default"; /* poor default */
+ }
+# else
+ if (home_dir == NULL || home_dir[0] == '\0')
+ {
+ int success;
+ char *name;
+ int malloc_name = 0;
+ size_t buflen = GET_LOGIN_NAME_MAX () + 1;
+
+ if (buflen == 0)
+ /* 'sysconf' does not support _SC_LOGIN_NAME_MAX. Try
+ a moderate value. */
+ buflen = 20;
+ if (glob_use_alloca (alloca_used, buflen))
+ name = alloca_account (buflen, alloca_used);
+ else
+ {
+ name = malloc (buflen);
+ if (name == NULL)
+ {
+ retval = GLOB_NOSPACE;
+ goto out;
+ }
+ malloc_name = 1;
+ }
+
+ success = __getlogin_r (name, buflen) == 0;
+ if (success)
+ {
+ struct passwd *p;
+# if defined HAVE_GETPWNAM_R || defined _LIBC
+ long int pwbuflenmax = GETPW_R_SIZE_MAX ();
+ size_t pwbuflen = pwbuflenmax;
+ char *pwtmpbuf;
+ struct passwd pwbuf;
+ char *malloc_pwtmpbuf = NULL;
+ int save = errno;
+
+# ifndef _LIBC
+ if (! (0 < pwbuflenmax && pwbuflenmax <= SIZE_MAX))
+ /* Perhaps 'sysconf' does not support _SC_GETPW_R_SIZE_MAX.
+ Try a moderate value. */
+ pwbuflen = 1024;
+# endif
+ if (glob_use_alloca (alloca_used, pwbuflen))
+ pwtmpbuf = alloca_account (pwbuflen, alloca_used);
+ else
+ {
+ pwtmpbuf = malloc (pwbuflen);
+ if (pwtmpbuf == NULL)
+ {
+ retval = GLOB_NOSPACE;
+ goto out;
+ }
+ malloc_pwtmpbuf = pwtmpbuf;
+ }
+
+ while (getpwnam_r (name, &pwbuf, pwtmpbuf, pwbuflen, &p)
+ != 0)
+ {
+ size_t newlen;
+ bool v;
+ if (errno != ERANGE)
+ {
+ p = NULL;
+ break;
+ }
+ v = size_add_wrapv (pwbuflen, pwbuflen, &newlen);
+ if (!v && malloc_pwtmpbuf == NULL
+ && glob_use_alloca (alloca_used, newlen))
+ pwtmpbuf = extend_alloca_account (pwtmpbuf, pwbuflen,
+ newlen, alloca_used);
+ else
+ {
+ char *newp = (v ? NULL
+ : realloc (malloc_pwtmpbuf, newlen));
+ if (newp == NULL)
+ {
+ free (malloc_pwtmpbuf);
+ retval = GLOB_NOSPACE;
+ goto out;
+ }
+ malloc_pwtmpbuf = pwtmpbuf = newp;
+ }
+ pwbuflen = newlen;
+ __set_errno (save);
+ }
+# else
+ p = getpwnam (name);
+# endif
+ if (__glibc_unlikely (malloc_name))
+ free (name);
+ if (p != NULL)
+ {
+ if (malloc_pwtmpbuf == NULL)
+ home_dir = p->pw_dir;
+ else
+ {
+ size_t home_dir_len = strlen (p->pw_dir) + 1;
+ if (glob_use_alloca (alloca_used, home_dir_len))
+ home_dir = alloca_account (home_dir_len,
+ alloca_used);
+ else
+ {
+ home_dir = malloc (home_dir_len);
+ if (home_dir == NULL)
+ {
+ free (pwtmpbuf);
+ retval = GLOB_NOSPACE;
+ goto out;
+ }
+ malloc_home_dir = 1;
+ }
+ memcpy (home_dir, p->pw_dir, home_dir_len);
+
+ free (pwtmpbuf);
+ }
+ }
+ }
+ }
+ if (home_dir == NULL || home_dir[0] == '\0')
+ {
+ if (flags & GLOB_TILDE_CHECK)
+ {
+ if (__glibc_unlikely (malloc_home_dir))
+ free (home_dir);
+ retval = GLOB_NOMATCH;
+ goto out;
+ }
+ else
+ home_dir = (char *) "~"; /* No luck. */
+ }
+# endif /* WINDOWS32 */
+# endif
+ /* Now construct the full directory. */
+ if (dirname[1] == '\0')
+ {
+ if (__glibc_unlikely (malloc_dirname))
+ free (dirname);
+
+ dirname = home_dir;
+ dirlen = strlen (dirname);
+ malloc_dirname = malloc_home_dir;
+ }
+ else
+ {
+ char *newp;
+ size_t home_len = strlen (home_dir);
+ int use_alloca = glob_use_alloca (alloca_used, home_len + dirlen);
+ if (use_alloca)
+ newp = alloca_account (home_len + dirlen, alloca_used);
+ else
+ {
+ newp = malloc (home_len + dirlen);
+ if (newp == NULL)
+ {
+ if (__glibc_unlikely (malloc_home_dir))
+ free (home_dir);
+ retval = GLOB_NOSPACE;
+ goto out;
+ }
+ }
+
+ mempcpy (mempcpy (newp, home_dir, home_len),
+ &dirname[1], dirlen);
+
+ if (__glibc_unlikely (malloc_dirname))
+ free (dirname);
+
+ dirname = newp;
+ dirlen += home_len - 1;
+ malloc_dirname = !use_alloca;
+ }
+ dirname_modified = 1;
+ }
+# if !defined _AMIGA && !defined WINDOWS32
+ else
+ {
+ char *end_name = strchr (dirname, '/');
+ char *user_name;
+ int malloc_user_name = 0;
+ char *unescape = NULL;
+
+ if (!(flags & GLOB_NOESCAPE))
+ {
+ if (end_name == NULL)
+ {
+ unescape = strchr (dirname, '\\');
+ if (unescape)
+ end_name = strchr (unescape, '\0');
+ }
+ else
+ unescape = memchr (dirname, '\\', end_name - dirname);
+ }
+ if (end_name == NULL)
+ user_name = dirname + 1;
+ else
+ {
+ char *newp;
+ if (glob_use_alloca (alloca_used, end_name - dirname))
+ newp = alloca_account (end_name - dirname, alloca_used);
+ else
+ {
+ newp = malloc (end_name - dirname);
+ if (newp == NULL)
+ {
+ retval = GLOB_NOSPACE;
+ goto out;
+ }
+ malloc_user_name = 1;
+ }
+ if (unescape != NULL)
+ {
+ char *p = mempcpy (newp, dirname + 1,
+ unescape - dirname - 1);
+ char *q = unescape;
+ while (*q != '\0')
+ {
+ if (*q == '\\')
+ {
+ if (q[1] == '\0')
+ {
+ /* "~fo\\o\\" unescape to user_name "foo\\",
+ but "~fo\\o\\/" unescape to user_name
+ "foo". */
+ if (filename == NULL)
+ *p++ = '\\';
+ break;
+ }
+ ++q;
+ }
+ *p++ = *q++;
+ }
+ *p = '\0';
+ }
+ else
+ *((char *) mempcpy (newp, dirname + 1, end_name - dirname))
+ = '\0';
+ user_name = newp;
+ }
+
+ /* Look up specific user's home directory. */
+ {
+ struct passwd *p;
+# if defined HAVE_GETPWNAM_R || defined _LIBC
+ long int buflenmax = GETPW_R_SIZE_MAX ();
+ size_t buflen = buflenmax;
+ char *pwtmpbuf;
+ char *malloc_pwtmpbuf = NULL;
+ struct passwd pwbuf;
+ int save = errno;
+
+# ifndef _LIBC
+ if (! (0 <= buflenmax && buflenmax <= SIZE_MAX))
+ /* Perhaps 'sysconf' does not support _SC_GETPW_R_SIZE_MAX. Try a
+ moderate value. */
+ buflen = 1024;
+# endif
+ if (glob_use_alloca (alloca_used, buflen))
+ pwtmpbuf = alloca_account (buflen, alloca_used);
+ else
+ {
+ pwtmpbuf = malloc (buflen);
+ if (pwtmpbuf == NULL)
+ {
+ nomem_getpw:
+ if (__glibc_unlikely (malloc_user_name))
+ free (user_name);
+ retval = GLOB_NOSPACE;
+ goto out;
+ }
+ malloc_pwtmpbuf = pwtmpbuf;
+ }
+
+ while (getpwnam_r (user_name, &pwbuf, pwtmpbuf, buflen, &p) != 0)
+ {
+ size_t newlen;
+ bool v;
+ if (errno != ERANGE)
+ {
+ p = NULL;
+ break;
+ }
+ v = size_add_wrapv (buflen, buflen, &newlen);
+ if (!v && malloc_pwtmpbuf == NULL
+ && glob_use_alloca (alloca_used, newlen))
+ pwtmpbuf = extend_alloca_account (pwtmpbuf, buflen,
+ newlen, alloca_used);
+ else
+ {
+ char *newp = v ? NULL : realloc (malloc_pwtmpbuf, newlen);
+ if (newp == NULL)
+ {
+ free (malloc_pwtmpbuf);
+ goto nomem_getpw;
+ }
+ malloc_pwtmpbuf = pwtmpbuf = newp;
+ }
+ __set_errno (save);
+ }
+# else
+ p = getpwnam (user_name);
+# endif
+
+ if (__glibc_unlikely (malloc_user_name))
+ free (user_name);
+
+ /* If we found a home directory use this. */
+ if (p != NULL)
+ {
+ size_t home_len = strlen (p->pw_dir);
+ size_t rest_len = end_name == NULL ? 0 : strlen (end_name);
+
+ if (__glibc_unlikely (malloc_dirname))
+ free (dirname);
+ malloc_dirname = 0;
+
+ if (glob_use_alloca (alloca_used, home_len + rest_len + 1))
+ dirname = alloca_account (home_len + rest_len + 1,
+ alloca_used);
+ else
+ {
+ dirname = malloc (home_len + rest_len + 1);
+ if (dirname == NULL)
+ {
+ free (malloc_pwtmpbuf);
+ retval = GLOB_NOSPACE;
+ goto out;
+ }
+ malloc_dirname = 1;
+ }
+ *((char *) mempcpy (mempcpy (dirname, p->pw_dir, home_len),
+ end_name, rest_len)) = '\0';
+
+ dirlen = home_len + rest_len;
+ dirname_modified = 1;
+
+ free (malloc_pwtmpbuf);
+ }
+ else
+ {
+ free (malloc_pwtmpbuf);
+
+ if (flags & GLOB_TILDE_CHECK)
+ /* We have to regard it as an error if we cannot find the
+ home directory. */
+ return GLOB_NOMATCH;
+ }
+ }
+ }
+# endif /* Not Amiga && not WINDOWS32. */
+ }
+
+ /* Now test whether we looked for "~" or "~NAME". In this case we
+ can give the answer now. */
+ if (filename == NULL)
+ {
+ struct stat st;
+ struct_stat64 st64;
+
+ /* Return the directory if we don't check for error or if it exists. */
+ if ((flags & GLOB_NOCHECK)
+ || (((__builtin_expect (flags & GLOB_ALTDIRFUNC, 0))
+ ? ((*pglob->gl_stat) (dirname, &st) == 0
+ && S_ISDIR (st.st_mode))
+ : (__stat64 (dirname, &st64) == 0 && S_ISDIR (st64.st_mode)))))
+ {
+ size_t newcount = pglob->gl_pathc + pglob->gl_offs;
+ char **new_gl_pathv;
+
+ if (newcount > SIZE_MAX / sizeof (char *) - 2)
+ {
+ nospace:
+ free (pglob->gl_pathv);
+ pglob->gl_pathv = NULL;
+ pglob->gl_pathc = 0;
+ return GLOB_NOSPACE;
+ }
+
+ new_gl_pathv = realloc (pglob->gl_pathv,
+ (newcount + 2) * sizeof (char *));
+ if (new_gl_pathv == NULL)
+ goto nospace;
+ pglob->gl_pathv = new_gl_pathv;
+
+ if (flags & GLOB_MARK)
+ {
+ char *p;
+ pglob->gl_pathv[newcount] = malloc (dirlen + 2);
+ if (pglob->gl_pathv[newcount] == NULL)
+ goto nospace;
+ p = mempcpy (pglob->gl_pathv[newcount], dirname, dirlen);
+ p[0] = '/';
+ p[1] = '\0';
+ }
+ else
+ {
+ pglob->gl_pathv[newcount] = strdup (dirname);
+ if (pglob->gl_pathv[newcount] == NULL)
+ goto nospace;
+ }
+ pglob->gl_pathv[++newcount] = NULL;
+ ++pglob->gl_pathc;
+ pglob->gl_flags = flags;
+
+ return 0;
+ }
+
+ /* Not found. */
+ return GLOB_NOMATCH;
+ }
+
+ meta = __glob_pattern_type (dirname, !(flags & GLOB_NOESCAPE));
+ /* meta is 1 if correct glob pattern containing metacharacters.
+ If meta has bit (1 << 2) set, it means there was an unterminated
+ [ which we handle the same, using fnmatch. Broken unterminated
+ pattern bracket expressions ought to be rare enough that it is
+ not worth special casing them, fnmatch will do the right thing. */
+ if (meta & 5)
+ {
+ /* The directory name contains metacharacters, so we
+ have to glob for the directory, and then glob for
+ the pattern in each directory found. */
+ size_t i;
+
+ if (!(flags & GLOB_NOESCAPE) && dirlen > 0 && dirname[dirlen - 1] == '\\')
+ {
+ /* "foo\\/bar". Remove the final backslash from dirname
+ if it has not been quoted. */
+ char *p = (char *) &dirname[dirlen - 1];
+
+ while (p > dirname && p[-1] == '\\') --p;
+ if ((&dirname[dirlen] - p) & 1)
+ *(char *) &dirname[--dirlen] = '\0';
+ }
+
+ if (__glibc_unlikely ((flags & GLOB_ALTDIRFUNC) != 0))
+ {
+ /* Use the alternative access functions also in the recursive
+ call. */
+ dirs.gl_opendir = pglob->gl_opendir;
+ dirs.gl_readdir = pglob->gl_readdir;
+ dirs.gl_closedir = pglob->gl_closedir;
+ dirs.gl_stat = pglob->gl_stat;
+ dirs.gl_lstat = pglob->gl_lstat;
+ }
+
+ status = glob (dirname,
+ ((flags & (GLOB_ERR | GLOB_NOESCAPE
+ | GLOB_ALTDIRFUNC))
+ | GLOB_NOSORT | GLOB_ONLYDIR),
+ errfunc, &dirs);
+ if (status != 0)
+ {
+ if ((flags & GLOB_NOCHECK) == 0 || status != GLOB_NOMATCH)
+ return status;
+ goto no_matches;
+ }
+
+ /* We have successfully globbed the preceding directory name.
+ For each name we found, call glob_in_dir on it and FILENAME,
+ appending the results to PGLOB. */
+ for (i = 0; i < dirs.gl_pathc; ++i)
+ {
+ size_t old_pathc;
+
+#ifdef SHELL
+ {
+ /* Make globbing interruptible in the bash shell. */
+ extern int interrupt_state;
+
+ if (interrupt_state)
+ {
+ globfree (&dirs);
+ return GLOB_ABORTED;
+ }
+ }
+#endif /* SHELL. */
+
+ old_pathc = pglob->gl_pathc;
+ status = glob_in_dir (filename, dirs.gl_pathv[i],
+ ((flags | GLOB_APPEND)
+ & ~(GLOB_NOCHECK | GLOB_NOMAGIC)),
+ errfunc, pglob, alloca_used);
+ if (status == GLOB_NOMATCH)
+ /* No matches in this directory. Try the next. */
+ continue;
+
+ if (status != 0)
+ {
+ globfree (&dirs);
+ globfree (pglob);
+ pglob->gl_pathc = 0;
+ return status;
+ }
+
+ /* Stick the directory on the front of each name. */
+ if (prefix_array (dirs.gl_pathv[i],
+ &pglob->gl_pathv[old_pathc + pglob->gl_offs],
+ pglob->gl_pathc - old_pathc))
+ {
+ globfree (&dirs);
+ globfree (pglob);
+ pglob->gl_pathc = 0;
+ return GLOB_NOSPACE;
+ }
+ }
+
+ flags |= GLOB_MAGCHAR;
+
+ /* We have ignored the GLOB_NOCHECK flag in the 'glob_in_dir' calls.
+ But if we have not found any matching entry and the GLOB_NOCHECK
+ flag was set we must return the input pattern itself. */
+ if (pglob->gl_pathc + pglob->gl_offs == oldcount)
+ {
+ no_matches:
+ /* No matches. */
+ if (flags & GLOB_NOCHECK)
+ {
+ size_t newcount = pglob->gl_pathc + pglob->gl_offs;
+ char **new_gl_pathv;
+
+ if (newcount > SIZE_MAX / sizeof (char *) - 2)
+ {
+ nospace2:
+ globfree (&dirs);
+ return GLOB_NOSPACE;
+ }
+
+ new_gl_pathv = realloc (pglob->gl_pathv,
+ (newcount + 2) * sizeof (char *));
+ if (new_gl_pathv == NULL)
+ goto nospace2;
+ pglob->gl_pathv = new_gl_pathv;
+
+ pglob->gl_pathv[newcount] = strdup (pattern);
+ if (pglob->gl_pathv[newcount] == NULL)
+ {
+ globfree (&dirs);
+ globfree (pglob);
+ pglob->gl_pathc = 0;
+ return GLOB_NOSPACE;
+ }
+
+ ++pglob->gl_pathc;
+ ++newcount;
+
+ pglob->gl_pathv[newcount] = NULL;
+ pglob->gl_flags = flags;
+ }
+ else
+ {
+ globfree (&dirs);
+ return GLOB_NOMATCH;
+ }
+ }
+
+ globfree (&dirs);
+ }
+ else
+ {
+ size_t old_pathc = pglob->gl_pathc;
+ int orig_flags = flags;
+
+ if (meta & 2)
+ {
+ char *p = strchr (dirname, '\\'), *q;
+ /* We need to unescape the dirname string. It is certainly
+ allocated by alloca, as otherwise filename would be NULL
+ or dirname wouldn't contain backslashes. */
+ q = p;
+ do
+ {
+ if (*p == '\\')
+ {
+ *q = *++p;
+ --dirlen;
+ }
+ else
+ *q = *p;
+ ++q;
+ }
+ while (*p++ != '\0');
+ dirname_modified = 1;
+ }
+ if (dirname_modified)
+ flags &= ~(GLOB_NOCHECK | GLOB_NOMAGIC);
+ status = glob_in_dir (filename, dirname, flags, errfunc, pglob,
+ alloca_used);
+ if (status != 0)
+ {
+ if (status == GLOB_NOMATCH && flags != orig_flags
+ && pglob->gl_pathc + pglob->gl_offs == oldcount)
+ {
+ /* Make sure globfree (&dirs); is a nop. */
+ dirs.gl_pathv = NULL;
+ flags = orig_flags;
+ goto no_matches;
+ }
+ return status;
+ }
+
+ if (dirlen > 0)
+ {
+ /* Stick the directory on the front of each name. */
+ if (prefix_array (dirname,
+ &pglob->gl_pathv[old_pathc + pglob->gl_offs],
+ pglob->gl_pathc - old_pathc))
+ {
+ globfree (pglob);
+ pglob->gl_pathc = 0;
+ return GLOB_NOSPACE;
+ }
+ }
+ }
+
+ if (flags & GLOB_MARK)
+ {
+ /* Append slashes to directory names. */
+ size_t i;
+ struct stat st;
+ struct_stat64 st64;
+
+ for (i = oldcount; i < pglob->gl_pathc + pglob->gl_offs; ++i)
+ if ((__builtin_expect (flags & GLOB_ALTDIRFUNC, 0)
+ ? ((*pglob->gl_stat) (pglob->gl_pathv[i], &st) == 0
+ && S_ISDIR (st.st_mode))
+ : (__stat64 (pglob->gl_pathv[i], &st64) == 0
+ && S_ISDIR (st64.st_mode))))
+ {
+ size_t len = strlen (pglob->gl_pathv[i]) + 2;
+ char *new = realloc (pglob->gl_pathv[i], len);
+ if (new == NULL)
+ {
+ globfree (pglob);
+ pglob->gl_pathc = 0;
+ return GLOB_NOSPACE;
+ }
+ strcpy (&new[len - 2], "/");
+ pglob->gl_pathv[i] = new;
+ }
+ }
+
+ if (!(flags & GLOB_NOSORT))
+ {
+ /* Sort the vector. */
+ qsort (&pglob->gl_pathv[oldcount],
+ pglob->gl_pathc + pglob->gl_offs - oldcount,
+ sizeof (char *), collated_compare);
+ }
+
+ out:
+ if (__glibc_unlikely (malloc_dirname))
+ free (dirname);
+
+ return retval;
+}
+#if defined _LIBC && !defined glob
+libc_hidden_def (glob)
+#endif
+
+
+#ifndef GLOB_ONLY_P
+
+/* Free storage allocated in PGLOB by a previous 'glob' call. */
+void
+globfree (glob_t *pglob)
+{
+ if (pglob->gl_pathv != NULL)
+ {
+ size_t i;
+ for (i = 0; i < pglob->gl_pathc; ++i)
+ free (pglob->gl_pathv[pglob->gl_offs + i]);
+ free (pglob->gl_pathv);
+ pglob->gl_pathv = NULL;
+ }
+}
+#if defined _LIBC && !defined globfree
+libc_hidden_def (globfree)
+#endif
+
+
+/* Do a collated comparison of A and B. */
+static int
+collated_compare (const void *a, const void *b)
+{
+ char *const *ps1 = a; char *s1 = *ps1;
+ char *const *ps2 = b; char *s2 = *ps2;
+
+ if (s1 == s2)
+ return 0;
+ if (s1 == NULL)
+ return 1;
+ if (s2 == NULL)
+ return -1;
+ return strcoll (s1, s2);
+}
+
+
+/* Prepend DIRNAME to each of N members of ARRAY, replacing ARRAY's
+ elements in place. Return nonzero if out of memory, zero if successful.
+ A slash is inserted between DIRNAME and each elt of ARRAY,
+ unless DIRNAME is just "/". Each old element of ARRAY is freed. */
+static int
+prefix_array (const char *dirname, char **array, size_t n)
+{
+ size_t i;
+ size_t dirlen = strlen (dirname);
+#if defined __MSDOS__ || defined WINDOWS32
+ int sep_char = '/';
+# define DIRSEP_CHAR sep_char
+#else
+# define DIRSEP_CHAR '/'
+#endif
+
+ if (dirlen == 1 && dirname[0] == '/')
+ /* DIRNAME is just "/", so normal prepending would get us "//foo".
+ We want "/foo" instead, so don't prepend any chars from DIRNAME. */
+ dirlen = 0;
+#if defined __MSDOS__ || defined WINDOWS32
+ else if (dirlen > 1)
+ {
+ if (dirname[dirlen - 1] == '/' && dirname[dirlen - 2] == ':')
+ /* DIRNAME is "d:/". Don't prepend the slash from DIRNAME. */
+ --dirlen;
+ else if (dirname[dirlen - 1] == ':')
+ {
+ /* DIRNAME is "d:". Use ':' instead of '/'. */
+ --dirlen;
+ sep_char = ':';
+ }
+ }
+#endif
+
+ for (i = 0; i < n; ++i)
+ {
+ size_t eltlen = strlen (array[i]) + 1;
+ char *new = malloc (dirlen + 1 + eltlen);
+ if (new == NULL)
+ {
+ while (i > 0)
+ free (array[--i]);
+ return 1;
+ }
+
+ {
+ char *endp = mempcpy (new, dirname, dirlen);
+ *endp++ = DIRSEP_CHAR;
+ mempcpy (endp, array[i], eltlen);
+ }
+ free (array[i]);
+ array[i] = new;
+ }
+
+ return 0;
+}
+
+
+/* We must not compile this function twice. */
+#ifndef NO_GLOB_PATTERN_P
+int
+__glob_pattern_type (const char *pattern, int quote)
+{
+ const char *p;
+ int ret = 0;
+
+ for (p = pattern; *p != '\0'; ++p)
+ switch (*p)
+ {
+ case '?':
+ case '*':
+ return 1;
+
+ case '\\':
+ if (quote)
+ {
+ if (p[1] != '\0')
+ ++p;
+ ret |= 2;
+ }
+ break;
+
+ case '[':
+ ret |= 4;
+ break;
+
+ case ']':
+ if (ret & 4)
+ return 1;
+ break;
+ }
+
+ return ret;
+}
+
+/* Return nonzero if PATTERN contains any metacharacters.
+ Metacharacters can be quoted with backslashes if QUOTE is nonzero. */
+int
+__glob_pattern_p (const char *pattern, int quote)
+{
+ return __glob_pattern_type (pattern, quote) == 1;
+}
+# ifdef _LIBC
+weak_alias (__glob_pattern_p, glob_pattern_p)
+# endif
+#endif
+
+
+/* We put this in a separate function mainly to allow the memory
+ allocated with alloca to be recycled. */
+static int
+__attribute_noinline__
+link_exists2_p (const char *dir, size_t dirlen, const char *fname,
+ glob_t *pglob
+# if !defined _LIBC && !HAVE_FSTATAT
+ , int flags
+# endif
+ )
+{
+ size_t fnamelen = strlen (fname);
+ char *fullname = __alloca (dirlen + 1 + fnamelen + 1);
+ struct stat st;
+
+ mempcpy (mempcpy (mempcpy (fullname, dir, dirlen), "/", 1),
+ fname, fnamelen + 1);
+
+# if !defined _LIBC && !HAVE_FSTATAT
+ if (__builtin_expect ((flags & GLOB_ALTDIRFUNC) == 0, 1))
+ {
+ struct_stat64 st64;
+ return __stat64 (fullname, &st64) == 0;
+ }
+# endif
+ return (*pglob->gl_stat) (fullname, &st) == 0;
+}
+
+/* Return true if DIR/FNAME exists. */
+static int
+link_exists_p (int dfd, const char *dir, size_t dirlen, const char *fname,
+ glob_t *pglob, int flags)
+{
+# if defined _LIBC || HAVE_FSTATAT
+ if (__builtin_expect (flags & GLOB_ALTDIRFUNC, 0))
+ return link_exists2_p (dir, dirlen, fname, pglob);
+ else
+ {
+ /* dfd cannot be -1 here, because dirfd never returns -1 on
+ glibc, or on hosts that have fstatat. */
+ struct_stat64 st64;
+ return __fxstatat64 (_STAT_VER, dfd, fname, &st64, 0) == 0;
+ }
+# else
+ return link_exists2_p (dir, dirlen, fname, pglob, flags);
+# endif
+}
+#endif /* !defined GLOB_ONLY_P */
+
+
+/* Like 'glob', but PATTERN is a final pathname component,
+ and matches are searched for in DIRECTORY.
+ The GLOB_NOSORT bit in FLAGS is ignored. No sorting is ever done.
+ The GLOB_APPEND flag is assumed to be set (always appends). */
+static int
+glob_in_dir (const char *pattern, const char *directory, int flags,
+ int (*errfunc) (const char *, int),
+ glob_t *pglob, size_t alloca_used)
+{
+ size_t dirlen = strlen (directory);
+ void *stream = NULL;
+ struct globnames
+ {
+ struct globnames *next;
+ size_t count;
+ char *name[64];
+ };
+ struct globnames init_names;
+ struct globnames *names = &init_names;
+ struct globnames *names_alloca = &init_names;
+ size_t nfound = 0;
+ size_t cur = 0;
+ int meta;
+ int save;
+ int result;
+
+ alloca_used += sizeof (init_names);
+
+ init_names.next = NULL;
+ init_names.count = sizeof init_names.name / sizeof init_names.name[0];
+
+ meta = __glob_pattern_type (pattern, !(flags & GLOB_NOESCAPE));
+ if (meta == 0 && (flags & (GLOB_NOCHECK|GLOB_NOMAGIC)))
+ {
+ /* We need not do any tests. The PATTERN contains no meta
+ characters and we must not return an error therefore the
+ result will always contain exactly one name. */
+ flags |= GLOB_NOCHECK;
+ }
+ else if (meta == 0)
+ {
+ /* Since we use the normal file functions we can also use stat()
+ to verify the file is there. */
+ union
+ {
+ struct stat st;
+ struct_stat64 st64;
+ } ust;
+ size_t patlen = strlen (pattern);
+ size_t fullsize;
+ bool alloca_fullname
+ = (! size_add_wrapv (dirlen + 1, patlen + 1, &fullsize)
+ && glob_use_alloca (alloca_used, fullsize));
+ char *fullname;
+ if (alloca_fullname)
+ fullname = alloca_account (fullsize, alloca_used);
+ else
+ {
+ fullname = malloc (fullsize);
+ if (fullname == NULL)
+ return GLOB_NOSPACE;
+ }
+
+ mempcpy (mempcpy (mempcpy (fullname, directory, dirlen),
+ "/", 1),
+ pattern, patlen + 1);
+ if ((__builtin_expect (flags & GLOB_ALTDIRFUNC, 0)
+ ? (*pglob->gl_stat) (fullname, &ust.st)
+ : __stat64 (fullname, &ust.st64)) == 0)
+ /* We found this file to be existing. Now tell the rest
+ of the function to copy this name into the result. */
+ flags |= GLOB_NOCHECK;
+
+ if (__glibc_unlikely (!alloca_fullname))
+ free (fullname);
+ }
+ else
+ {
+ stream = (__builtin_expect (flags & GLOB_ALTDIRFUNC, 0)
+ ? (*pglob->gl_opendir) (directory)
+ : opendir (directory));
+ if (stream == NULL)
+ {
+ if (errno != ENOTDIR
+ && ((errfunc != NULL && (*errfunc) (directory, errno))
+ || (flags & GLOB_ERR)))
+ return GLOB_ABORTED;
+ }
+ else
+ {
+ int dfd = (__builtin_expect (flags & GLOB_ALTDIRFUNC, 0)
+ ? -1 : dirfd ((DIR *) stream));
+ int fnm_flags = ((!(flags & GLOB_PERIOD) ? FNM_PERIOD : 0)
+ | ((flags & GLOB_NOESCAPE) ? FNM_NOESCAPE : 0)
+#if defined _AMIGA || defined VMS
+ | FNM_CASEFOLD
+#endif
+ );
+ flags |= GLOB_MAGCHAR;
+
+ while (1)
+ {
+ struct readdir_result d;
+ {
+ if (__builtin_expect (flags & GLOB_ALTDIRFUNC, 0))
+ d = convert_dirent (GL_READDIR (pglob, stream));
+ else
+ {
+#ifdef COMPILE_GLOB64
+ d = convert_dirent (__readdir (stream));
+#else
+ d = convert_dirent64 (__readdir64 (stream));
+#endif
+ }
+ }
+ if (d.name == NULL)
+ break;
+ if (d.skip_entry)
+ continue;
+
+ /* If we shall match only directories use the information
+ provided by the dirent call if possible. */
+ if ((flags & GLOB_ONLYDIR) && !readdir_result_might_be_dir (d))
+ continue;
+
+ if (fnmatch (pattern, d.name, fnm_flags) == 0)
+ {
+ /* If the file we found is a symlink we have to
+ make sure the target file exists. */
+ if (!readdir_result_might_be_symlink (d)
+ || link_exists_p (dfd, directory, dirlen, d.name,
+ pglob, flags))
+ {
+ if (cur == names->count)
+ {
+ struct globnames *newnames;
+ size_t count = names->count * 2;
+ size_t nameoff = offsetof (struct globnames, name);
+ size_t size = FLEXSIZEOF (struct globnames, name,
+ count * sizeof (char *));
+ if ((SIZE_MAX - nameoff) / 2 / sizeof (char *)
+ < names->count)
+ goto memory_error;
+ if (glob_use_alloca (alloca_used, size))
+ newnames = names_alloca
+ = alloca_account (size, alloca_used);
+ else if ((newnames = malloc (size))
+ == NULL)
+ goto memory_error;
+ newnames->count = count;
+ newnames->next = names;
+ names = newnames;
+ cur = 0;
+ }
+ names->name[cur] = strdup (d.name);
+ if (names->name[cur] == NULL)
+ goto memory_error;
+ ++cur;
+ ++nfound;
+ if (SIZE_MAX - pglob->gl_offs <= nfound)
+ goto memory_error;
+ }
+ }
+ }
+ }
+ }
+
+ if (nfound == 0 && (flags & GLOB_NOCHECK))
+ {
+ size_t len = strlen (pattern);
+ nfound = 1;
+ names->name[cur] = malloc (len + 1);
+ if (names->name[cur] == NULL)
+ goto memory_error;
+ *((char *) mempcpy (names->name[cur++], pattern, len)) = '\0';
+ }
+
+ result = GLOB_NOMATCH;
+ if (nfound != 0)
+ {
+ char **new_gl_pathv;
+ result = 0;
+
+ if (SIZE_MAX / sizeof (char *) - pglob->gl_pathc
+ < pglob->gl_offs + nfound + 1)
+ goto memory_error;
+
+ new_gl_pathv
+ = realloc (pglob->gl_pathv,
+ (pglob->gl_pathc + pglob->gl_offs + nfound + 1)
+ * sizeof (char *));
+
+ if (new_gl_pathv == NULL)
+ {
+ memory_error:
+ while (1)
+ {
+ struct globnames *old = names;
+ size_t i;
+ for (i = 0; i < cur; ++i)
+ free (names->name[i]);
+ names = names->next;
+ /* NB: we will not leak memory here if we exit without
+ freeing the current block assigned to OLD. At least
+ the very first block is always allocated on the stack
+ and this is the block assigned to OLD here. */
+ if (names == NULL)
+ {
+ assert (old == &init_names);
+ break;
+ }
+ cur = names->count;
+ if (old == names_alloca)
+ names_alloca = names;
+ else
+ free (old);
+ }
+ result = GLOB_NOSPACE;
+ }
+ else
+ {
+ while (1)
+ {
+ struct globnames *old = names;
+ size_t i;
+ for (i = 0; i < cur; ++i)
+ new_gl_pathv[pglob->gl_offs + pglob->gl_pathc++]
+ = names->name[i];
+ names = names->next;
+ /* NB: we will not leak memory here if we exit without
+ freeing the current block assigned to OLD. At least
+ the very first block is always allocated on the stack
+ and this is the block assigned to OLD here. */
+ if (names == NULL)
+ {
+ assert (old == &init_names);
+ break;
+ }
+ cur = names->count;
+ if (old == names_alloca)
+ names_alloca = names;
+ else
+ free (old);
+ }
+
+ pglob->gl_pathv = new_gl_pathv;
+
+ pglob->gl_pathv[pglob->gl_offs + pglob->gl_pathc] = NULL;
+
+ pglob->gl_flags = flags;
+ }
+ }
+
+ if (stream != NULL)
+ {
+ save = errno;
+ if (__glibc_unlikely (flags & GLOB_ALTDIRFUNC))
+ (*pglob->gl_closedir) (stream);
+ else
+ closedir (stream);
+ __set_errno (save);
+ }
+
+ return result;
+}
diff --git a/gdb/gnulib/import/glob.in.h b/gdb/gnulib/import/glob.in.h
new file mode 100644
index 0000000000..77816bc099
--- /dev/null
+++ b/gdb/gnulib/import/glob.in.h
@@ -0,0 +1,93 @@
+/* glob.h -- Find a path matching a pattern.
+
+ Copyright (C) 2005-2007, 2009-2016 Free Software Foundation, Inc.
+
+ Written by Derek Price <***@ximbiot.com> & Paul Eggert <***@CS.UCLA.EDU>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, see <http://www.gnu.org/licenses/>. */
+
+#ifndef _GL_GLOB_H
+#define _GL_GLOB_H
+
+#if @HAVE_SYS_CDEFS_H@
+# include <sys/cdefs.h>
+#endif
+
+#include <stddef.h>
+
+/* On some systems, such as AIX 5.1, <sys/stat.h> does a "#define stat stat64".
+ Make sure this definition is seen before glob-libc.h defines types that
+ rely on 'struct stat'. */
+#include <sys/stat.h>
+
+#ifndef __BEGIN_DECLS
+# ifdef __cplusplus
+# define __BEGIN_DECLS extern "C" {
+# define __END_DECLS }
+# else
+# define __BEGIN_DECLS
+# define __END_DECLS
+# endif
+#endif
+#ifndef __THROW
+# define __THROW
+#endif
+#ifndef __THROWNL
+# define __THROWNL
+#endif
+
+/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
+
+/* The definition of _GL_ARG_NONNULL is copied here. */
+
+/* The definition of _GL_WARN_ON_USE is copied here. */
+
+#ifndef __size_t
+# define __size_t size_t
+#endif
+#ifndef __USE_GNU
+# define __USE_GNU 1
+#endif
+
+
+#define glob rpl_glob
+#define globfree rpl_globfree
+#define glob_pattern_p rpl_glob_pattern_p
+
+#define __GLOB_GNULIB 1
+
+/* Now the standard GNU C Library header should work. */
+#include "glob-libc.h"
+
+__BEGIN_DECLS
+typedef int (*_gl_glob_errfunc_fn) (const char *, int);
+__END_DECLS
+
+#if defined __cplusplus && defined GNULIB_NAMESPACE
+# undef glob
+# undef globfree
+# undef glob_pattern_p
+_GL_CXXALIAS_RPL (glob, int, (const char *_Restrict_ __pattern, int __flags,
+ _gl_glob_errfunc_fn __errfunc,
+ glob_t *_Restrict_ __pglob));
+_GL_CXXALIAS_RPL (globfree, void, (glob_t *__pglob));
+_GL_CXXALIAS_RPL (glob_pattern_p, int, (const char *__pattern, int __quote));
+# if 0 /* The C function name is rpl_glob, not glob. */
+_GL_CXXALIASWARN (glob);
+_GL_CXXALIASWARN (globfree);
+_GL_CXXALIASWARN (glob_pattern_p);
+# endif
+#endif
+
+#endif /* _GL_GLOB_H */
diff --git a/gdb/gnulib/import/m4/closedir.m4 b/gdb/gnulib/import/m4/closedir.m4
new file mode 100644
index 0000000000..0c9fd82de2
--- /dev/null
+++ b/gdb/gnulib/import/m4/closedir.m4
@@ -0,0 +1,30 @@
+# closedir.m4 serial 5
+dnl Copyright (C) 2011-2016 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+AC_DEFUN([gl_FUNC_CLOSEDIR],
+[
+ AC_REQUIRE([gl_DIRENT_H_DEFAULTS])
+
+ AC_CHECK_FUNCS([closedir])
+ if test $ac_cv_func_closedir = no; then
+ HAVE_CLOSEDIR=0
+ fi
+ dnl Replace closedir() for supporting the gnulib-defined fchdir() function,
+ dnl to keep fchdir's bookkeeping up-to-date.
+ m4_ifdef([gl_FUNC_FCHDIR], [
+ gl_TEST_FCHDIR
+ if test $HAVE_FCHDIR = 0; then
+ if test $HAVE_CLOSEDIR = 1; then
+ REPLACE_CLOSEDIR=1
+ fi
+ fi
+ ])
+ dnl Replace closedir() for supporting the gnulib-defined dirfd() function.
+ case $host_os,$HAVE_CLOSEDIR in
+ os2*,1)
+ REPLACE_CLOSEDIR=1;;
+ esac
+])
diff --git a/gdb/gnulib/import/m4/d-type.m4 b/gdb/gnulib/import/m4/d-type.m4
new file mode 100644
index 0000000000..eda762c47f
--- /dev/null
+++ b/gdb/gnulib/import/m4/d-type.m4
@@ -0,0 +1,32 @@
+# serial 11
+
+dnl From Jim Meyering.
+dnl
+dnl Check whether struct dirent has a member named d_type.
+dnl
+
+# Copyright (C) 1997, 1999-2004, 2006, 2009-2016 Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+AC_DEFUN([gl_CHECK_TYPE_STRUCT_DIRENT_D_TYPE],
+ [AC_CACHE_CHECK([for d_type member in directory struct],
+ gl_cv_struct_dirent_d_type,
+ [AC_LINK_IFELSE([AC_LANG_PROGRAM([[
+#include <sys/types.h>
+#include <dirent.h>
+ ]],
+ [[struct dirent dp; dp.d_type = 0;]])],
+ [gl_cv_struct_dirent_d_type=yes],
+ [gl_cv_struct_dirent_d_type=no])
+ ]
+ )
+ if test $gl_cv_struct_dirent_d_type = yes; then
+ AC_DEFINE([HAVE_STRUCT_DIRENT_D_TYPE], [1],
+ [Define if there is a member named d_type in the struct describing
+ directory headers.])
+ fi
+ ]
+)
diff --git a/gdb/gnulib/import/m4/getlogin_r.m4 b/gdb/gnulib/import/m4/getlogin_r.m4
new file mode 100644
index 0000000000..80f82f4f92
--- /dev/null
+++ b/gdb/gnulib/import/m4/getlogin_r.m4
@@ -0,0 +1,88 @@
+#serial 11
+
+# Copyright (C) 2005-2007, 2009-2016 Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+dnl From Derek Price
+dnl
+dnl Provide getlogin_r when the system lacks it.
+dnl
+
+AC_DEFUN([gl_FUNC_GETLOGIN_R],
+[
+ AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
+
+ dnl Persuade glibc <unistd.h> to declare getlogin_r().
+ dnl Persuade Solaris <unistd.h> to provide the POSIX compliant declaration of
+ dnl getlogin_r().
+ AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
+
+ AC_CHECK_DECLS_ONCE([getlogin_r])
+ if test $ac_cv_have_decl_getlogin_r = no; then
+ HAVE_DECL_GETLOGIN_R=0
+ fi
+
+ AC_CHECK_FUNCS_ONCE([getlogin_r])
+ if test $ac_cv_func_getlogin_r = no; then
+ HAVE_GETLOGIN_R=0
+ else
+ HAVE_GETLOGIN_R=1
+ dnl On OSF/1 5.1, getlogin_r returns a truncated result if the buffer is
+ dnl not large enough.
+ AC_REQUIRE([AC_CANONICAL_HOST])
+ AC_CACHE_CHECK([whether getlogin_r works with small buffers],
+ [gl_cv_func_getlogin_r_works],
+ [
+ dnl Initial guess, used when cross-compiling.
+changequote(,)dnl
+ case "$host_os" in
+ # Guess no on OSF/1.
+ osf*) gl_cv_func_getlogin_r_works="guessing no" ;;
+ # Guess yes otherwise.
+ *) gl_cv_func_getlogin_r_works="guessing yes" ;;
+ esac
+changequote([,])dnl
+ AC_RUN_IFELSE(
+ [AC_LANG_SOURCE([[
+#include <stddef.h>
+#include <unistd.h>
+#if !HAVE_DECL_GETLOGIN_R
+extern
+# ifdef __cplusplus
+"C"
+# endif
+int getlogin_r (char *, size_t);
+#endif
+int
+main (void)
+{
+ int result = 0;
+ char buf[100];
+
+ if (getlogin_r (buf, 0) == 0)
+ result |= 16;
+ if (getlogin_r (buf, 1) == 0)
+ result |= 17;
+ return result;
+}]])],
+ [gl_cv_func_getlogin_r_works=yes],
+ [case $? in
+ 16 | 17) gl_cv_func_getlogin_r_works=no ;;
+ esac
+ ],
+ [:])
+ ])
+ case "$gl_cv_func_getlogin_r_works" in
+ *yes) ;;
+ *) REPLACE_GETLOGIN_R=1 ;;
+ esac
+ fi
+])
+
+AC_DEFUN([gl_PREREQ_GETLOGIN_R],
+[
+ AC_CHECK_DECLS_ONCE([getlogin])
+])
diff --git a/gdb/gnulib/import/m4/glob.m4 b/gdb/gnulib/import/m4/glob.m4
new file mode 100644
index 0000000000..adf5fe2865
--- /dev/null
+++ b/gdb/gnulib/import/m4/glob.m4
@@ -0,0 +1,76 @@
+# glob.m4 serial 14
+dnl Copyright (C) 2005-2007, 2009-2016 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+# The glob module assumes you want GNU glob, with glob_pattern_p etc,
+# rather than vanilla POSIX glob. This means your code should
+# always include <glob.h> for the glob prototypes.
+
+AC_DEFUN([gl_GLOB],
+[ GLOB_H=
+ AC_CHECK_HEADERS([glob.h], [], [GLOB_H=glob.h])
+
+ if test -z "$GLOB_H"; then
+ AC_CACHE_CHECK([for GNU glob interface version 1],
+ [gl_cv_gnu_glob_interface_version_1],
+[ AC_COMPILE_IFELSE([AC_LANG_SOURCE(
+[[#include <gnu-versions.h>
+char a[_GNU_GLOB_INTERFACE_VERSION == 1 ? 1 : -1];]])],
+ [gl_cv_gnu_glob_interface_version_1=yes],
+ [gl_cv_gnu_glob_interface_version_1=no])])
+
+ if test "$gl_cv_gnu_glob_interface_version_1" = "no"; then
+ GLOB_H=glob.h
+ fi
+ fi
+
+ if test -z "$GLOB_H"; then
+ AC_CACHE_CHECK([whether glob lists broken symlinks],
+ [gl_cv_glob_lists_symlinks],
+[ if ln -s conf-doesntexist conf$$-globtest 2>/dev/null; then
+ gl_cv_glob_lists_symlinks=maybe
+ else
+ # If we can't make a symlink, then we cannot test this issue. Be
+ # pessimistic about this.
+ gl_cv_glob_lists_symlinks=no
+ fi
+
+ if test $gl_cv_glob_lists_symlinks = maybe; then
+ AC_RUN_IFELSE([
+AC_LANG_PROGRAM(
+[[#include <stddef.h>
+#include <glob.h>]],
+[[glob_t found;
+if (glob ("conf*-globtest", 0, NULL, &found) == GLOB_NOMATCH) return 1;]])],
+ [gl_cv_glob_lists_symlinks=yes],
+ [gl_cv_glob_lists_symlinks=no], [gl_cv_glob_lists_symlinks=no])
+ fi])
+
+ if test $gl_cv_glob_lists_symlinks = no; then
+ GLOB_H=glob.h
+ fi
+ fi
+
+ rm -f conf$$-globtest
+
+ AC_SUBST([GLOB_H])
+ AM_CONDITIONAL([GL_GENERATE_GLOB_H], [test -n "$GLOB_H"])
+])
+
+# Prerequisites of lib/glob.*.
+AC_DEFUN([gl_PREREQ_GLOB],
+[
+ AC_REQUIRE([gl_CHECK_TYPE_STRUCT_DIRENT_D_TYPE])dnl
+ AC_REQUIRE([AC_C_RESTRICT])dnl
+ AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])dnl
+ AC_CHECK_HEADERS_ONCE([sys/cdefs.h unistd.h])dnl
+ if test $ac_cv_header_sys_cdefs_h = yes; then
+ HAVE_SYS_CDEFS_H=1
+ else
+ HAVE_SYS_CDEFS_H=0
+ fi
+ AC_SUBST([HAVE_SYS_CDEFS_H])
+ AC_CHECK_FUNCS_ONCE([fstatat getlogin_r getpwnam_r])dnl
+])
diff --git a/gdb/gnulib/import/m4/gnulib-cache.m4 b/gdb/gnulib/import/m4/gnulib-cache.m4
index c4ebb73bfb..b1e6430882 100644
--- a/gdb/gnulib/import/m4/gnulib-cache.m4
+++ b/gdb/gnulib/import/m4/gnulib-cache.m4
@@ -27,7 +27,7 @@
# Specification in the form of a command-line invocation:
-# gnulib-tool --import --lib=libgnu --source-base=import --m4-base=import/m4 --doc-base=doc --tests-base=tests --aux-dir=import/extra --no-conditional-dependencies --no-libtool --macro-prefix=gl --no-vc-files alloca canonicalize-lgpl dirent dirfd errno fnmatch-gnu frexpl inttypes limits-h lstat memchr memmem pathmax rawmemchr readlink rename setenv signal-h strchrnul strstr strtok_r sys_stat unistd unsetenv update-copyright wchar wctype-h
+# gnulib-tool --import --lib=libgnu --source-base=import --m4-base=import/m4 --doc-base=doc --tests-base=tests --aux-dir=import/extra --no-conditional-dependencies --no-libtool --macro-prefix=gl --no-vc-files alloca canonicalize-lgpl dirent dirfd errno fnmatch-gnu frexpl glob inttypes limits-h lstat memchr memmem pathmax rawmemchr readlink rename setenv signal-h strchrnul strstr strtok_r sys_stat unistd unsetenv update-copyright wchar wctype-h
# Specification in the form of a few gnulib-tool.m4 macro invocations:
gl_LOCAL_DIR([])
@@ -39,6 +39,7 @@ gl_MODULES([
errno
fnmatch-gnu
frexpl
+ glob
inttypes
limits-h
lstat
diff --git a/gdb/gnulib/import/m4/gnulib-comp.m4 b/gdb/gnulib/import/m4/gnulib-comp.m4
index 5a3656713d..7f69c95145 100644
--- a/gdb/gnulib/import/m4/gnulib-comp.m4
+++ b/gdb/gnulib/import/m4/gnulib-comp.m4
@@ -47,7 +47,9 @@ AC_DEFUN([gl_EARLY],
# Code from module alloca-opt:
# Code from module canonicalize-lgpl:
# Code from module chdir:
+ # Code from module closedir:
# Code from module configmake:
+ # Code from module d-type:
# Code from module dirent:
# Code from module dirfd:
# Code from module dirname-lgpl:
@@ -57,6 +59,7 @@ AC_DEFUN([gl_EARLY],
# Code from module errno:
# Code from module extensions:
# Code from module extern-inline:
+ # Code from module filename:
# Code from module flexmember:
# Code from module float:
# Code from module fnmatch:
@@ -66,7 +69,9 @@ AC_DEFUN([gl_EARLY],
# Code from module fpucw:
# Code from module frexp:
# Code from module frexpl:
+ # Code from module getlogin_r:
# Code from module gettimeofday:
+ # Code from module glob:
# Code from module hard-locale:
# Code from module include_next:
# Code from module inttypes:
@@ -87,10 +92,13 @@ AC_DEFUN([gl_EARLY],
# Code from module memchr:
# Code from module memmem:
# Code from module memmem-simple:
+ # Code from module mempcpy:
# Code from module multiarch:
# Code from module nocrash:
+ # Code from module opendir:
# Code from module pathmax:
# Code from module rawmemchr:
+ # Code from module readdir:
# Code from module readlink:
# Code from module rename:
# Code from module rmdir:
@@ -152,7 +160,13 @@ AC_DEFUN([gl_INIT],
gl_STDLIB_MODULE_INDICATOR([canonicalize_file_name])
gl_STDLIB_MODULE_INDICATOR([realpath])
gl_UNISTD_MODULE_INDICATOR([chdir])
+ gl_FUNC_CLOSEDIR
+ if test $HAVE_CLOSEDIR = 0 || test $REPLACE_CLOSEDIR = 1; then
+ AC_LIBOBJ([closedir])
+ fi
+ gl_DIRENT_MODULE_INDICATOR([closedir])
gl_CONFIGMAKE_PREP
+ gl_CHECK_TYPE_STRUCT_DIRENT_D_TYPE
gl_DIRENT_H
gl_FUNC_DIRFD
if test $ac_cv_func_dirfd = no && test $gl_cv_func_dirfd_macro = no \
@@ -195,12 +209,23 @@ AC_DEFUN([gl_INIT],
AC_LIBOBJ([frexpl])
fi
gl_MATH_MODULE_INDICATOR([frexpl])
+ gl_FUNC_GETLOGIN_R
+ if test $HAVE_GETLOGIN_R = 0 || test $REPLACE_GETLOGIN_R = 1; then
+ AC_LIBOBJ([getlogin_r])
+ gl_PREREQ_GETLOGIN_R
+ fi
+ gl_UNISTD_MODULE_INDICATOR([getlogin_r])
gl_FUNC_GETTIMEOFDAY
if test $HAVE_GETTIMEOFDAY = 0 || test $REPLACE_GETTIMEOFDAY = 1; then
AC_LIBOBJ([gettimeofday])
gl_PREREQ_GETTIMEOFDAY
fi
gl_SYS_TIME_MODULE_INDICATOR([gettimeofday])
+ gl_GLOB
+ if test -n "$GLOB_H"; then
+ AC_LIBOBJ([glob])
+ gl_PREREQ_GLOB
+ fi
gl_HARD_LOCALE
gl_INTTYPES_H
gl_INTTYPES_INCOMPLETE
@@ -266,7 +291,18 @@ AC_DEFUN([gl_INIT],
AC_LIBOBJ([memmem])
fi
gl_STRING_MODULE_INDICATOR([memmem])
+ gl_FUNC_MEMPCPY
+ if test $HAVE_MEMPCPY = 0; then
+ AC_LIBOBJ([mempcpy])
+ gl_PREREQ_MEMPCPY
+ fi
+ gl_STRING_MODULE_INDICATOR([mempcpy])
gl_MULTIARCH
+ gl_FUNC_OPENDIR
+ if test $HAVE_OPENDIR = 0 || test $REPLACE_OPENDIR = 1; then
+ AC_LIBOBJ([opendir])
+ fi
+ gl_DIRENT_MODULE_INDICATOR([opendir])
gl_PATHMAX
gl_FUNC_RAWMEMCHR
if test $HAVE_RAWMEMCHR = 0; then
@@ -274,6 +310,11 @@ AC_DEFUN([gl_INIT],
gl_PREREQ_RAWMEMCHR
fi
gl_STRING_MODULE_INDICATOR([rawmemchr])
+ gl_FUNC_READDIR
+ if test $HAVE_READDIR = 0; then
+ AC_LIBOBJ([readdir])
+ fi
+ gl_DIRENT_MODULE_INDICATOR([readdir])
gl_FUNC_READLINK
if test $HAVE_READLINK = 0 || test $REPLACE_READLINK = 1; then
AC_LIBOBJ([readlink])
@@ -495,13 +536,16 @@ AC_DEFUN([gl_FILE_LIST], [
lib/alloca.in.h
lib/basename-lgpl.c
lib/canonicalize-lgpl.c
+ lib/closedir.c
lib/config.charset
+ lib/dirent-private.h
lib/dirent.in.h
lib/dirfd.c
lib/dirname-lgpl.c
lib/dirname.h
lib/dosname.h
lib/errno.in.h
+ lib/filename.h
lib/flexmember.h
lib/float+.h
lib/float.c
@@ -512,7 +556,11 @@ AC_DEFUN([gl_FILE_LIST], [
lib/fpucw.h
lib/frexp.c
lib/frexpl.c
+ lib/getlogin_r.c
lib/gettimeofday.c
+ lib/glob-libc.h
+ lib/glob.c
+ lib/glob.in.h
lib/hard-locale.c
lib/hard-locale.h
lib/inttypes.in.h
@@ -540,9 +588,12 @@ AC_DEFUN([gl_FILE_LIST], [
lib/memchr.c
lib/memchr.valgrind
lib/memmem.c
+ lib/mempcpy.c
+ lib/opendir.c
lib/pathmax.h
lib/rawmemchr.c
lib/rawmemchr.valgrind
+ lib/readdir.c
lib/readlink.c
lib/ref-add.sin
lib/ref-del.sin
@@ -582,8 +633,10 @@ AC_DEFUN([gl_FILE_LIST], [
m4/absolute-header.m4
m4/alloca.m4
m4/canonicalize.m4
+ m4/closedir.m4
m4/codeset.m4
m4/configmake.m4
+ m4/d-type.m4
m4/dirent_h.m4
m4/dirfd.m4
m4/dirname.m4
@@ -602,8 +655,10 @@ AC_DEFUN([gl_FILE_LIST], [
m4/fpieee.m4
m4/frexp.m4
m4/frexpl.m4
+ m4/getlogin_r.m4
m4/gettimeofday.m4
m4/glibc21.m4
+ m4/glob.m4
m4/gnulib-common.m4
m4/hard-locale.m4
m4/include_next.m4
@@ -628,12 +683,15 @@ AC_DEFUN([gl_FILE_LIST], [
m4/mbstate_t.m4
m4/memchr.m4
m4/memmem.m4
+ m4/mempcpy.m4
m4/mmap-anon.m4
m4/multiarch.m4
m4/nocrash.m4
m4/off_t.m4
+ m4/opendir.m4
m4/pathmax.m4
m4/rawmemchr.m4
+ m4/readdir.m4
m4/readlink.m4
m4/rename.m4
m4/rmdir.m4
diff --git a/gdb/gnulib/import/m4/mempcpy.m4 b/gdb/gnulib/import/m4/mempcpy.m4
new file mode 100644
index 0000000000..6991f29f03
--- /dev/null
+++ b/gdb/gnulib/import/m4/mempcpy.m4
@@ -0,0 +1,26 @@
+# mempcpy.m4 serial 11
+dnl Copyright (C) 2003-2004, 2006-2007, 2009-2016 Free Software Foundation,
+dnl Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+AC_DEFUN([gl_FUNC_MEMPCPY],
+[
+ dnl Persuade glibc <string.h> to declare mempcpy().
+ AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
+
+ dnl The mempcpy() declaration in lib/string.in.h uses 'restrict'.
+ AC_REQUIRE([AC_C_RESTRICT])
+
+ AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS])
+ AC_CHECK_FUNCS([mempcpy])
+ if test $ac_cv_func_mempcpy = no; then
+ HAVE_MEMPCPY=0
+ fi
+])
+
+# Prerequisites of lib/mempcpy.c.
+AC_DEFUN([gl_PREREQ_MEMPCPY], [
+ :
+])
diff --git a/gdb/gnulib/import/m4/opendir.m4 b/gdb/gnulib/import/m4/opendir.m4
new file mode 100644
index 0000000000..ffaa6ae3ba
--- /dev/null
+++ b/gdb/gnulib/import/m4/opendir.m4
@@ -0,0 +1,31 @@
+# opendir.m4 serial 4
+dnl Copyright (C) 2011-2016 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+AC_DEFUN([gl_FUNC_OPENDIR],
+[
+ AC_REQUIRE([gl_DIRENT_H_DEFAULTS])
+
+ AC_CHECK_FUNCS([opendir])
+ if test $ac_cv_func_opendir = no; then
+ HAVE_OPENDIR=0
+ fi
+ dnl Replace opendir() for supporting the gnulib-defined fchdir() function,
+ dnl to keep fchdir's bookkeeping up-to-date.
+ m4_ifdef([gl_FUNC_FCHDIR], [
+ gl_TEST_FCHDIR
+ if test $HAVE_FCHDIR = 0; then
+ if test $HAVE_OPENDIR = 1; then
+ REPLACE_OPENDIR=1
+ fi
+ fi
+ ])
+ dnl Replace opendir() on OS/2 kLIBC to support dirfd() function replaced
+ dnl by gnulib.
+ case $host_os,$HAVE_OPENDIR in
+ os2*,1)
+ REPLACE_OPENDIR=1;;
+ esac
+])
diff --git a/gdb/gnulib/import/m4/readdir.m4 b/gdb/gnulib/import/m4/readdir.m4
new file mode 100644
index 0000000000..eda3acf73d
--- /dev/null
+++ b/gdb/gnulib/import/m4/readdir.m4
@@ -0,0 +1,15 @@
+# readdir.m4 serial 1
+dnl Copyright (C) 2011-2016 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+AC_DEFUN([gl_FUNC_READDIR],
+[
+ AC_REQUIRE([gl_DIRENT_H_DEFAULTS])
+
+ AC_CHECK_FUNCS([readdir])
+ if test $ac_cv_func_readdir = no; then
+ HAVE_READDIR=0
+ fi
+])
diff --git a/gdb/gnulib/import/mempcpy.c b/gdb/gnulib/import/mempcpy.c
new file mode 100644
index 0000000000..d579f64a0a
--- /dev/null
+++ b/gdb/gnulib/import/mempcpy.c
@@ -0,0 +1,28 @@
+/* Copy memory area and return pointer after last written byte.
+ Copyright (C) 2003, 2007, 2009-2016 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, see <http://www.gnu.org/licenses/>. */
+
+#include <config.h>
+
+/* Specification. */
+#include <string.h>
+
+/* Copy N bytes of SRC to DEST, return pointer to bytes after the
+ last written byte. */
+void *
+mempcpy (void *dest, const void *src, size_t n)
+{
+ return (char *) memcpy (dest, src, n) + n;
+}
diff --git a/gdb/gnulib/import/opendir.c b/gdb/gnulib/import/opendir.c
new file mode 100644
index 0000000000..a135fd834a
--- /dev/null
+++ b/gdb/gnulib/import/opendir.c
@@ -0,0 +1,169 @@
+/* Start reading the entries of a directory.
+ Copyright (C) 2006-2016 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include <config.h>
+
+/* Specification. */
+#include <dirent.h>
+
+#include <errno.h>
+#include <stddef.h>
+
+#if HAVE_OPENDIR
+
+/* Override opendir(), to keep track of the open file descriptors.
+ Needed because there is a function dirfd(). */
+
+#else
+
+# include <stdlib.h>
+
+# include "dirent-private.h"
+# include "filename.h"
+
+#endif
+
+#if REPLACE_FCHDIR
+# include <unistd.h>
+#endif
+
+#ifdef __KLIBC__
+# include <io.h>
+# include <fcntl.h>
+#endif
+
+DIR *
+opendir (const char *dir_name)
+{
+#if HAVE_OPENDIR
+# undef opendir
+ DIR *dirp;
+
+ dirp = opendir (dir_name);
+ if (dirp == NULL)
+ return NULL;
+
+# ifdef __KLIBC__
+ {
+ int fd = open (dir_name, O_RDONLY);
+ if (fd == -1 || _gl_register_dirp_fd (fd, dirp))
+ {
+ int saved_errno = errno;
+
+ close (fd);
+ closedir (dirp);
+
+ errno = saved_errno;
+
+ return NULL;
+ }
+ }
+# endif
+#else
+
+ char dir_name_mask[MAX_PATH + 1 + 1 + 1];
+ int status;
+ HANDLE current;
+ WIN32_FIND_DATA entry;
+ struct gl_directory *dirp;
+
+ if (dir_name[0] == '\0')
+ {
+ errno = ENOENT;
+ return NULL;
+ }
+
+ /* Make the dir_name absolute, so that we continue reading the same
+ directory if the current directory changed between this opendir()
+ call and a subsequent rewinddir() call. */
+ if (!GetFullPathName (dir_name, MAX_PATH, dir_name_mask, NULL))
+ {
+ errno = EINVAL;
+ return NULL;
+ }
+
+ /* Append the mask.
+ "*" and "*.*" appear to be equivalent. */
+ {
+ char *p;
+
+ p = dir_name_mask + strlen (dir_name_mask);
+ if (p > dir_name_mask && !ISSLASH (p[-1]))
+ *p++ = '\\';
+ *p++ = '*';
+ *p = '\0';
+ }
+
+ /* Start searching the directory. */
+ status = -1;
+ current = FindFirstFile (dir_name_mask, &entry);
+ if (current == INVALID_HANDLE_VALUE)
+ {
+ switch (GetLastError ())
+ {
+ case ERROR_FILE_NOT_FOUND:
+ status = -2;
+ break;
+ case ERROR_PATH_NOT_FOUND:
+ errno = ENOENT;
+ return NULL;
+ case ERROR_DIRECTORY:
+ errno = ENOTDIR;
+ return NULL;
+ case ERROR_ACCESS_DENIED:
+ errno = EACCES;
+ return NULL;
+ default:
+ errno = EIO;
+ return NULL;
+ }
+ }
+
+ /* Allocate the result. */
+ dirp =
+ (struct gl_directory *)
+ malloc (offsetof (struct gl_directory, dir_name_mask[0])
+ + strlen (dir_name_mask) + 1);
+ if (dirp == NULL)
+ {
+ if (current != INVALID_HANDLE_VALUE)
+ FindClose (current);
+ errno = ENOMEM;
+ return NULL;
+ }
+ dirp->status = status;
+ dirp->current = current;
+ if (status == -1)
+ memcpy (&dirp->entry, &entry, sizeof (WIN32_FIND_DATA));
+ strcpy (dirp->dir_name_mask, dir_name_mask);
+
+#endif
+
+#if REPLACE_FCHDIR
+ {
+ int fd = dirfd (dirp);
+ if (0 <= fd && _gl_register_fd (fd, dir_name) != fd)
+ {
+ int saved_errno = errno;
+ closedir (dirp);
+ errno = saved_errno;
+ return NULL;
+ }
+ }
+#endif
+
+ return dirp;
+}
diff --git a/gdb/gnulib/import/readdir.c b/gdb/gnulib/import/readdir.c
new file mode 100644
index 0000000000..76b7e9d819
--- /dev/null
+++ b/gdb/gnulib/import/readdir.c
@@ -0,0 +1,98 @@
+/* Read the next entry of a directory.
+ Copyright (C) 2011-2016 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include <config.h>
+
+/* Specification. */
+#include <dirent.h>
+
+#include <errno.h>
+#include <stddef.h>
+
+#include "dirent-private.h"
+
+struct dirent *
+readdir (DIR *dirp)
+{
+ char type;
+ struct dirent *result;
+
+ /* There is no need to add code to produce entries for "." and "..".
+ According to the POSIX:2008 section "4.12 Pathname Resolution"
+ <http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap04.html>
+ "." and ".." are syntactic entities.
+ POSIX also says:
+ "If entries for dot or dot-dot exist, one entry shall be returned
+ for dot and one entry shall be returned for dot-dot; otherwise,
+ they shall not be returned." */
+
+ switch (dirp->status)
+ {
+ case -2:
+ /* End of directory already reached. */
+ return NULL;
+ case -1:
+ break;
+ case 0:
+ if (!FindNextFile (dirp->current, &dirp->entry))
+ {
+ switch (GetLastError ())
+ {
+ case ERROR_NO_MORE_FILES:
+ dirp->status = -2;
+ return NULL;
+ default:
+ errno = EIO;
+ return NULL;
+ }
+ }
+ break;
+ default:
+ errno = dirp->status;
+ return NULL;
+ }
+
+ dirp->status = 0;
+
+ if (dirp->entry.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
+ type = DT_DIR;
+ else if (dirp->entry.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT)
+ type = DT_LNK;
+ else if ((dirp->entry.dwFileAttributes
+ & ~(FILE_ATTRIBUTE_READONLY
+ | FILE_ATTRIBUTE_HIDDEN
+ | FILE_ATTRIBUTE_SYSTEM
+ | FILE_ATTRIBUTE_ARCHIVE
+ | FILE_ATTRIBUTE_NORMAL
+ | FILE_ATTRIBUTE_TEMPORARY
+ | FILE_ATTRIBUTE_SPARSE_FILE
+ | FILE_ATTRIBUTE_COMPRESSED
+ | FILE_ATTRIBUTE_NOT_CONTENT_INDEXED
+ | FILE_ATTRIBUTE_ENCRYPTED)) == 0)
+ /* Devices like COM1, LPT1, NUL would also have the attributes 0x20 but
+ they cannot occur here. */
+ type = DT_REG;
+ else
+ type = DT_UNKNOWN;
+
+ /* Reuse the memory of dirp->entry for the result. */
+ result =
+ (struct dirent *)
+ ((char *) dirp->entry.cFileName - offsetof (struct dirent, d_name[0]));
+ result->d_type = type;
+
+ return result;
+}
diff --git a/gdb/gnulib/update-gnulib.sh b/gdb/gnulib/update-gnulib.sh
index 2775dc7338..ccf603fceb 100755
--- a/gdb/gnulib/update-gnulib.sh
+++ b/gdb/gnulib/update-gnulib.sh
@@ -37,6 +37,7 @@ IMPORTED_GNULIB_MODULES="\
errno \
fnmatch-gnu \
frexpl \
+ glob \
inttypes \
lstat \
limits-h \
--
2.13.3