changeset 19138:7cd8c0c156ef pygnulib

Merge branch 'master' of ssh://git.savannah.gnu.org:/srv/git/gnulib into pygnulib
author Dmitry Selyutin <ghostmansd@gmail.com>
date Fri, 08 Sep 2017 20:55:47 +0300
parents bd081518df01 (current diff) 504d2bd44d07 (diff)
children
files
diffstat 9 files changed, 140 insertions(+), 82 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Fri Sep 08 18:34:58 2017 +0300
+++ b/ChangeLog	Fri Sep 08 20:55:47 2017 +0300
@@ -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.
--- a/lib/fts.c	Fri Sep 08 18:34:58 2017 +0300
+++ b/lib/fts.c	Fri Sep 08 20:55:47 2017 +0300
@@ -814,10 +814,10 @@
 {
   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 @@
         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)
--- a/lib/glob.c	Fri Sep 08 18:34:58 2017 +0300
+++ b/lib/glob.c	Fri Sep 08 20:55:47 2017 +0300
@@ -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 @@
               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)
+                    {
+# if defined HAVE_GETPWNAM_R || defined _LIBC
+                      size_t ssize = strlen (s.data) + 1;
+                      err = getpwnam_r (s.data, &pwbuf, s.data + ssize,
+                                        s.length - ssize, &p);
+# else
+                      p = getpwnam (s.data);
+                      if (p == NULL)
+                        err = errno;
+# endif
+                    }
+                  if (err != ERANGE)
+                    break;
+                  if (!scratch_buffer_grow (&s))
                     {
                       retval = GLOB_NOSPACE;
                       goto out;
                     }
-                  malloc_name = 1;
                 }
-
-              success = __getlogin_r (name, buflen) == 0;
-              if (success)
+              if (err == 0)
                 {
-                  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;
-                        }
-                    }
-# else
-                  p = getpwnam (name);
-# endif
-                  if (p != NULL)
-                    {
-                      home_dir = strdup (p->pw_dir);
-                      malloc_home_dir = 1;
-                      if (home_dir == NULL)
-                        {
-                          scratch_buffer_free (&pwtmpbuf);
-                          retval = GLOB_NOSPACE;
-                          goto out;
-                        }
-                    }
-                  scratch_buffer_free (&pwtmpbuf);
+                  home_dir = strdup (p->pw_dir);
+                  malloc_home_dir = 1;
                 }
-              else
+              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 @@
      [ 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 @@
       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 @@
                        / 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
       {
--- a/lib/glob_internal.h	Fri Sep 08 18:34:58 2017 +0300
+++ b/lib/glob_internal.h	Fri Sep 08 20:55:47 2017 +0300
@@ -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;
       }
 
--- a/lib/glob_pattern_p.c	Fri Sep 08 18:34:58 2017 +0300
+++ b/lib/glob_pattern_p.c	Fri Sep 08 20:55:47 2017 +0300
@@ -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)
--- a/lib/libc-config.h	Fri Sep 08 18:34:58 2017 +0300
+++ b/lib/libc-config.h	Fri Sep 08 20:55:47 2017 +0300
@@ -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)
--- a/lib/stddef.in.h	Fri Sep 08 18:34:58 2017 +0300
+++ b/lib/stddef.in.h	Fri Sep 08 20:55:47 2017 +0300
@@ -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 */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/m4/__inline.m4	Fri Sep 08 20:55:47 2017 +0300
@@ -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
+])
--- a/modules/libc-config	Fri Sep 08 18:34:58 2017 +0300
+++ b/modules/libc-config	Fri Sep 08 20:55:47 2017 +0300
@@ -4,10 +4,12 @@
 Files:
 lib/cdefs.h
 lib/libc-config.h
+m4/__inline.m4
 
 Depends-on:
 
 configure.ac:
+gl___INLINE
 
 Makefile.am: