summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Selyutin <ghostmansd@gmail.com>2017-09-08 20:55:47 +0300
committerDmitry Selyutin <ghostmansd@gmail.com>2017-09-08 20:55:47 +0300
commit6ce7367385f1380b702aea0da5828ac3ea34795b (patch)
tree4e9a25647951bd289d684de71b6b18c3415bbfd3
parentd1967197f677a5508f6e824bb1c87f526809b42b (diff)
parent80ad545e6d9c44bc358690dbbbca9835a85d3081 (diff)
downloadgnulib-pygnulib.tar.gz
gnulib-pygnulib.tar.bz2
Merge branch 'master' of ssh://git.savannah.gnu.org:/srv/git/gnulib into pygnulibpygnulib
-rw-r--r--ChangeLog50
-rw-r--r--lib/fts.c6
-rw-r--r--lib/glob.c98
-rw-r--r--lib/glob_internal.h18
-rw-r--r--lib/glob_pattern_p.c2
-rw-r--r--lib/libc-config.h6
-rw-r--r--lib/stddef.in.h18
-rw-r--r--m4/__inline.m422
-rw-r--r--modules/libc-config2
9 files changed, 140 insertions, 82 deletions
diff --git a/ChangeLog b/ChangeLog
index b67d217995..68d3205019 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,53 @@
+2017-09-08 Bruno Haible <bruno@clisp.org>
+
+ stddef: Avoid conflict with system-defined max_align_t.
+ The configure-determined HAVE_MAX_ALIGN_T may not always be accurate.
+ Reported by Werner Lemberg <wl@gnu.org> in
+ <https://lists.gnu.org/archive/html/bug-gnulib/2017-08/msg00185.html>.
+ * lib/stddef.in.h (rpl_max_align_t): Renamed from max_align_t.
+ (max_align_t): Define as a macro.
+ (GNULIB_defined_max_align_t): New macro. Guards against multiple
+ definitions of rpl_max_align_t in different copies of gnulib-generated
+ <stddef.h>.
+
+2017-09-05 Paul Eggert <eggert@cs.ucla.edu>
+
+ libc-config: port to MSVC
+ Problems reported by Gisle Vanem in:
+ http://lists.gnu.org/archive/html/bug-gnulib/2017-09/msg00016.html
+ * lib/libc-config.h (__inline): Don't define if HAVE___INLINE.
+ (libc_hidden_proto): Stick to Standard C syntax for varargs macro.
+ * m4/__inline.m4: New file.
+ * modules/libc-config (Files): Add it.
+ (Depends-on): Use it.
+
+ glob: Use enum for __glob_pattern_type result
+ From a patch proposed by Adhemerval Zanella in:
+ https://sourceware.org/ml/libc-alpha/2017-09/msg00212.html
+ * lib/glob_internal.h (GLOBPAT_NONE, GLOBPAT_SPECIAL)
+ (GLOBPAT_BACKSLASH, GLOBPAT_BRACKET): New constants.
+ * lib/glob_internal.h (__glob_pattern_type):
+ * lib/glob.c (glob):
+ * lib/glob_pattern_p.c (__glob_pattern_p):
+ Use them.
+
+ glob: fix for use in glibc
+ Problem reported by Adhemerval Zanella in:
+ https://sourceware.org/ml/libc-alpha/2017-09/msg00213.html
+ * lib/glob.c (DT_UNKNOWN, DT_DIR, DT_LINK):
+ Do not redefine if _LIBC.
+
+2017-09-02 Paul Eggert <eggert@cs.ucla.edu>
+
+ glob: fix bugs with long login names
+ Problem reported by Adhemerval Zanella in:
+ https://sourceware.org/ml/libc-alpha/2017-08/msg00455.html
+ * lib/glob.c (GET_LOGIN_NAME_MAX): Remove.
+ (glob): Use the same scratch buffer for both getlogin_r and
+ getpwnam_r. Don’t require preallocation of the login name. This
+ simplifies storage allocation, and corrects the handling of
+ long login names.
+
2017-09-02 Bruno Haible <bruno@clisp.org>
dirent: Update doc.
diff --git a/lib/fts.c b/lib/fts.c
index ffa41130a2..01fc532917 100644
--- a/lib/fts.c
+++ b/lib/fts.c
@@ -814,10 +814,10 @@ leaf_optimization (FTSENT const *p)
{
switch (filesystem_type (p))
{
- /* List here the file system types that lack usable dirent.d_type
+ /* List here the file system types that may lack usable dirent.d_type
info, yet for which the optimization does apply. */
case S_MAGIC_REISERFS:
- case S_MAGIC_XFS:
+ case S_MAGIC_XFS: /* XFS lacked it until 2013-08-22 commit. */
return NOSTAT_LEAF_OPTIMIZATION;
case 0:
@@ -1417,7 +1417,7 @@ fts_build (register FTS *sp, int type)
else
{
/* Try to descend unless it is a names-only fts_children,
- or the directory is a known to lack subdirectories. */
+ or the directory is known to lack subdirectories. */
descend = (type != BNAMES
&& ! (ISSET (FTS_NOSTAT) && ISSET (FTS_PHYSICAL)
&& ! ISSET (FTS_SEEDOT)
diff --git a/lib/glob.c b/lib/glob.c
index 7ca11361ec..4c6c31b819 100644
--- a/lib/glob.c
+++ b/lib/glob.c
@@ -75,18 +75,12 @@
#include <flexmember.h>
#include <glob_internal.h>
#include <scratch_buffer.h>
-
-#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;
typedef uint_fast8_t dirent_type;
-#ifndef HAVE_STRUCT_DIRENT_D_TYPE
+#if !defined _LIBC && !defined HAVE_STRUCT_DIRENT_D_TYPE
/* Any distinct values will do here.
Undef any existing macros out of the way. */
# undef DT_UNKNOWN
@@ -611,67 +605,45 @@ glob (const char *pattern, int flags, int (*errfunc) (const char *, int),
else
home_dir = "c:/users/default"; /* poor default */
#else
- 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
+ int err;
+ struct passwd *p;
+ struct passwd pwbuf;
+ struct scratch_buffer s;
+ scratch_buffer_init (&s);
+ while (true)
{
- name = malloc (buflen);
- if (name == NULL)
+ p = NULL;
+ err = __getlogin_r (s.data, s.length);
+ if (err == 0)
{
- retval = GLOB_NOSPACE;
- goto out;
- }
- malloc_name = 1;
- }
-
- success = __getlogin_r (name, buflen) == 0;
- if (success)
- {
- struct passwd *p;
- struct scratch_buffer pwtmpbuf;
- scratch_buffer_init (&pwtmpbuf);
# if defined HAVE_GETPWNAM_R || defined _LIBC
- struct passwd pwbuf;
-
- while (getpwnam_r (name, &pwbuf,
- pwtmpbuf.data, pwtmpbuf.length, &p)
- == ERANGE)
- {
- if (!scratch_buffer_grow (&pwtmpbuf))
- {
- retval = GLOB_NOSPACE;
- goto out;
- }
- }
+ size_t ssize = strlen (s.data) + 1;
+ err = getpwnam_r (s.data, &pwbuf, s.data + ssize,
+ s.length - ssize, &p);
# else
- p = getpwnam (name);
+ p = getpwnam (s.data);
+ if (p == NULL)
+ err = errno;
# endif
- if (p != NULL)
+ }
+ if (err != ERANGE)
+ break;
+ if (!scratch_buffer_grow (&s))
{
- home_dir = strdup (p->pw_dir);
- malloc_home_dir = 1;
- if (home_dir == NULL)
- {
- scratch_buffer_free (&pwtmpbuf);
- retval = GLOB_NOSPACE;
- goto out;
- }
+ retval = GLOB_NOSPACE;
+ goto out;
}
- scratch_buffer_free (&pwtmpbuf);
}
- else
+ if (err == 0)
+ {
+ home_dir = strdup (p->pw_dir);
+ malloc_home_dir = 1;
+ }
+ scratch_buffer_free (&s);
+ if (err == 0 && home_dir == NULL)
{
- if (__glibc_unlikely (malloc_name))
- free (name);
+ retval = GLOB_NOSPACE;
+ goto out;
}
#endif /* WINDOWS32 */
}
@@ -931,7 +903,7 @@ glob (const char *pattern, int flags, int (*errfunc) (const char *, int),
[ 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)
+ if (meta & (GLOBPAT_SPECIAL | GLOBPAT_BRACKET))
{
/* The directory name contains metacharacters, so we
have to glob for the directory, and then glob for
@@ -1072,7 +1044,7 @@ glob (const char *pattern, int flags, int (*errfunc) (const char *, int),
size_t old_pathc = pglob->gl_pathc;
int orig_flags = flags;
- if (meta & 2)
+ if (meta & GLOBPAT_BACKSLASH)
{
char *p = strchr (dirname, '\\'), *q;
/* We need to unescape the dirname string. It is certainly
@@ -1270,14 +1242,14 @@ glob_in_dir (const char *pattern, const char *directory, int flags,
/ sizeof init_names->name[0]);
meta = __glob_pattern_type (pattern, !(flags & GLOB_NOESCAPE));
- if (meta == 0 && (flags & (GLOB_NOCHECK|GLOB_NOMAGIC)))
+ if (meta == GLOBPAT_NONE && (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)
+ else if (meta == GLOBPAT_NONE)
{
union
{
diff --git a/lib/glob_internal.h b/lib/glob_internal.h
index 12c93660b7..d118b3533d 100644
--- a/lib/glob_internal.h
+++ b/lib/glob_internal.h
@@ -19,35 +19,43 @@
#ifndef GLOB_INTERNAL_H
# define GLOB_INTERNAL_H
+enum
+{
+ GLOBPAT_NONE = 0x0,
+ GLOBPAT_SPECIAL = 0x1,
+ GLOBPAT_BACKSLASH = 0x2,
+ GLOBPAT_BRACKET = 0x4
+};
+
static inline int
__glob_pattern_type (const char *pattern, int quote)
{
const char *p;
- int ret = 0;
+ int ret = GLOBPAT_NONE;
for (p = pattern; *p != '\0'; ++p)
switch (*p)
{
case '?':
case '*':
- return 1;
+ return GLOBPAT_SPECIAL;
case '\\':
if (quote)
{
if (p[1] != '\0')
++p;
- ret |= 2;
+ ret |= GLOBPAT_BACKSLASH;
}
break;
case '[':
- ret |= 4;
+ ret |= GLOBPAT_BRACKET;
break;
case ']':
if (ret & 4)
- return 1;
+ return GLOBPAT_SPECIAL;
break;
}
diff --git a/lib/glob_pattern_p.c b/lib/glob_pattern_p.c
index a17d337182..8489106e90 100644
--- a/lib/glob_pattern_p.c
+++ b/lib/glob_pattern_p.c
@@ -28,6 +28,6 @@
int
__glob_pattern_p (const char *pattern, int quote)
{
- return __glob_pattern_type (pattern, quote) == 1;
+ return __glob_pattern_type (pattern, quote) == GLOBPAT_SPECIAL;
}
weak_alias (__glob_pattern_p, glob_pattern_p)
diff --git a/lib/libc-config.h b/lib/libc-config.h
index 2ebb8756e1..93a8db043c 100644
--- a/lib/libc-config.h
+++ b/lib/libc-config.h
@@ -150,8 +150,8 @@
/* <cdefs.h> __inline is too pessimistic for non-GCC. */
#undef __inline
-#ifndef __GNUC__
-# if 199901 <= __STDC_VERSION__
+#ifndef HAVE___INLINE
+# if 199901 <= __STDC_VERSION__ || defined inline
# define __inline inline
# else
# define __inline
@@ -172,7 +172,7 @@
/* A substitute for glibc <libc-symbols.h>, good enough for Gnulib. */
#define attribute_hidden
-#define libc_hidden_proto(name, attrs...)
+#define libc_hidden_proto(name, ...)
#define libc_hidden_def(name)
#define libc_hidden_weak(name)
#define libc_hidden_ver(local, name)
diff --git a/lib/stddef.in.h b/lib/stddef.in.h
index 2a11d2b71d..a79f5363df 100644
--- a/lib/stddef.in.h
+++ b/lib/stddef.in.h
@@ -85,24 +85,28 @@
a hack in case the configure-time test was done with g++ even though
we are currently compiling with gcc. */
#if ! (@HAVE_MAX_ALIGN_T@ || defined _GCC_MAX_ALIGN_T)
+# if !GNULIB_defined_max_align_t
/* On the x86, the maximum storage alignment of double, long, etc. is 4,
but GCC's C11 ABI for x86 says that max_align_t has an alignment of 8,
and the C11 standard allows this. Work around this problem by
using __alignof__ (which returns 8 for double) rather than _Alignof
(which returns 4), and align each union member accordingly. */
-# ifdef __GNUC__
-# define _GL_STDDEF_ALIGNAS(type) \
- __attribute__ ((__aligned__ (__alignof__ (type))))
-# else
-# define _GL_STDDEF_ALIGNAS(type) /* */
-# endif
+# ifdef __GNUC__
+# define _GL_STDDEF_ALIGNAS(type) \
+ __attribute__ ((__aligned__ (__alignof__ (type))))
+# else
+# define _GL_STDDEF_ALIGNAS(type) /* */
+# endif
typedef union
{
char *__p _GL_STDDEF_ALIGNAS (char *);
double __d _GL_STDDEF_ALIGNAS (double);
long double __ld _GL_STDDEF_ALIGNAS (long double);
long int __i _GL_STDDEF_ALIGNAS (long int);
-} max_align_t;
+} rpl_max_align_t;
+# define max_align_t rpl_max_align_t
+# define GNULIB_defined_max_align_t 1
+# endif
#endif
# endif /* _@GUARD_PREFIX@_STDDEF_H */
diff --git a/m4/__inline.m4 b/m4/__inline.m4
new file mode 100644
index 0000000000..95c34a9094
--- /dev/null
+++ b/m4/__inline.m4
@@ -0,0 +1,22 @@
+# Test for __inline keyword
+dnl Copyright 2017 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___INLINE],
+[
+ AC_CACHE_CHECK([whether the compiler supports the __inline keyword],
+ [gl_cv_c___inline],
+ [AC_COMPILE_IFELSE(
+ [AC_LANG_PROGRAM(
+ [[typedef int foo_t;
+ static __inline foo_t foo (void) { return 0; }]],
+ [[return foo ();]])],
+ [gl_cv_c___inline=yes],
+ [gl_cv_c___inline=no])])
+ if test $gl_cv_c___inline = yes; then
+ AC_DEFINE([HAVE___INLINE], [1],
+ [Define to 1 if the compiler supports the keyword '__inline'.])
+ fi
+])
diff --git a/modules/libc-config b/modules/libc-config
index 8df46fec90..7706165d20 100644
--- a/modules/libc-config
+++ b/modules/libc-config
@@ -4,10 +4,12 @@ System definitions for code taken from the GNU C Library
Files:
lib/cdefs.h
lib/libc-config.h
+m4/__inline.m4
Depends-on:
configure.ac:
+gl___INLINE
Makefile.am:

Return to:

Send suggestions and report system problems to the System administrator.