libidn-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[SCM] GNU libidn branch, master, updated. libidn-1-32-25-g87d779b


From: Simon Josefsson
Subject: [SCM] GNU libidn branch, master, updated. libidn-1-32-25-g87d779b
Date: Wed, 20 Jul 2016 17:40:39 +0000 (UTC)

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU libidn".

http://git.savannah.gnu.org/cgit/libidn.git/commit/?id=87d779b13f3343f1de101d5fdaf4065c8fb30be8

The branch, master has been updated
       via  87d779b13f3343f1de101d5fdaf4065c8fb30be8 (commit)
       via  0bb408dd1cfe4fdc10f678729d27dbe5f271a446 (commit)
       via  7ed9a56c22c5ebb6b61992b63ea9a4fc6279f253 (commit)
       via  39c9648262ddd0d7d01d02b16a163a08e96f21d7 (commit)
       via  b2e9176dc40fba299edae5508c05e8ff03017d8e (commit)
      from  7f06bc9edb80c1169d8fd4e887a982d719f1a1c9 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 87d779b13f3343f1de101d5fdaf4065c8fb30be8
Author: Simon Josefsson <address@hidden>
Date:   Wed Jul 20 19:25:58 2016 +0200

    Version 1.33.

commit 0bb408dd1cfe4fdc10f678729d27dbe5f271a446
Author: Simon Josefsson <address@hidden>
Date:   Wed Jul 20 18:40:35 2016 +0200

    Doc fix.

commit 7ed9a56c22c5ebb6b61992b63ea9a4fc6279f253
Author: Simon Josefsson <address@hidden>
Date:   Wed Jul 20 18:00:03 2016 +0200

    Ignore more.

commit 39c9648262ddd0d7d01d02b16a163a08e96f21d7
Author: Simon Josefsson <address@hidden>
Date:   Wed Jul 20 17:51:26 2016 +0200

    Update gnulib files.

commit b2e9176dc40fba299edae5508c05e8ff03017d8e
Author: Simon Josefsson <address@hidden>
Date:   Wed Jul 20 17:49:16 2016 +0200

    Update gl override patches.

-----------------------------------------------------------------------

Summary of changes:
 .gitignore                         |    2 +
 NEWS                               |    2 +-
 build-aux/gendocs.sh               |   40 ++++++-------
 gl/intprops.h                      |  110 +++++++++++++++++++++---------------
 gl/m4/dup2.m4                      |   14 ++++-
 gl/m4/extern-inline.m4             |    1 +
 gl/m4/getcwd.m4                    |    4 +-
 gl/m4/getdelim.m4                  |    4 +-
 gl/m4/getline.m4                   |    5 +-
 gl/m4/malloc.m4                    |   11 ++--
 gl/m4/manywarnings.m4              |   14 ++++-
 gl/m4/nocrash.m4                   |    3 +-
 gl/m4/realloc.m4                   |   11 ++--
 gl/m4/stdbool.m4                   |   34 ++++++-----
 gl/m4/stdint.m4                    |   29 +++++++++-
 gl/override/lib/gettext.h.diff     |   14 +++--
 gl/stddef.in.h                     |    6 +-
 gl/stdint.in.h                     |   14 ++---
 gl/verify.h                        |    2 +-
 gltests/Makefile.am                |    5 ++
 gltests/binary-io.h                |    2 +-
 gltests/dup2.c                     |   51 +++++++++++++++++
 gltests/init.sh                    |   31 +++++-----
 gltests/stdalign.in.h              |    6 +-
 gltests/test-getline.c             |    4 +-
 gltests/test-intprops.c            |   37 ++++--------
 gltests/test-stat.c                |    1 +
 gltests/test-stat.h                |    1 +
 gltests/wchar.in.h                 |    7 ++-
 lib/gl/m4/extern-inline.m4         |    1 +
 lib/gl/m4/malloc.m4                |   11 ++--
 lib/gl/m4/stdbool.m4               |   34 ++++++-----
 lib/gl/m4/stdint.m4                |   29 +++++++++-
 lib/gl/override/lib/gettext.h.diff |   14 +++--
 lib/gl/stddef.in.h                 |    6 +-
 lib/gl/stdint.in.h                 |   14 ++---
 lib/gltests/Makefile.am            |    5 ++
 lib/gltests/init.sh                |   31 +++++-----
 lib/gltests/intprops.h             |  110 +++++++++++++++++++++---------------
 lib/gltests/setlocale.c            |    1 +
 lib/gltests/stdalign.in.h          |    6 +-
 lib/gltests/test-intprops.c        |   37 ++++--------
 lib/gltests/test-localename.c      |   40 ++++++++++---
 lib/gltests/test-setlocale1.c      |    2 +
 lib/gltests/verify.h               |    2 +-
 lib/gltests/wchar.in.h             |    7 ++-
 maint.mk                           |    3 +-
 tests/tst_toascii64oob.c           |   11 +++-
 48 files changed, 533 insertions(+), 296 deletions(-)

diff --git a/.gitignore b/.gitignore
index 437b434..c18482f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -435,6 +435,8 @@ lib/gltests/test-c-strcasecmp
 lib/gltests/test-c-strcasecmp.o
 lib/gltests/test-c-strncasecmp
 lib/gltests/test-c-strncasecmp.o
+lib/gltests/test-ctype
+lib/gltests/test-ctype.o
 lib/gltests/test-environ
 lib/gltests/test-environ.o
 lib/gltests/test-iconv
diff --git a/NEWS b/NEWS
index 5fa080c..a082f90 100644
--- a/NEWS
+++ b/NEWS
@@ -2,7 +2,7 @@ Libidn NEWS -- History of user-visible changes.                 
-*- outline -*-
 Copyright (C) 2002-2016 Simon Josefsson
 See the end for copying conditions.
 
-* Version 1.33 (unreleased) [beta]
+* Version 1.33 (released 2016-07-20) [beta]
 
 ** libidn: Fix out-of-bounds stack read in idna_to_ascii_4i.
 See tests/tst_toascii64oob.c for regression check (and the comment in
diff --git a/build-aux/gendocs.sh b/build-aux/gendocs.sh
index 1d1e1e7..fef6280 100755
--- a/build-aux/gendocs.sh
+++ b/build-aux/gendocs.sh
@@ -2,7 +2,7 @@
 # gendocs.sh -- generate a GNU manual in many formats.  This script is
 #   mentioned in maintain.texi.  See the help message below for usage details.
 
-scriptversion=2016-01-01.00
+scriptversion=2016-05-20.09
 
 # Copyright 2003-2016 Free Software Foundation, Inc.
 #
@@ -52,6 +52,24 @@ 
templateurl="http://git.savannah.gnu.org/cgit/gnulib.git/plain/doc/gendocs_templ
 unset CDPATH
 unset use_texi2html
 
+MANUAL_TITLE=
+PACKAGE=
address@hidden  # please override with --email
+commonarg= # passed to all makeinfo/texi2html invcations.
+dirargs=   # passed to all tools (-I dir).
+dirs=      # -I directories.
+htmlarg="--css-ref=/software/gnulib/manual.css -c TOP_NODE_UP_URL=/manual"
+infoarg=--no-split
+generate_ascii=true
+generate_html=true
+generate_info=true
+generate_tex=true
+outdir=manual
+source_extra=
+split=node
+srcfile=
+texarg="-t @finalout"
+
 version="gendocs.sh $scriptversion
 
 Copyright 2016 Free Software Foundation, Inc.
@@ -74,7 +92,7 @@ Options:
   -I DIR       append DIR to the Texinfo search path.
   --common ARG pass ARG in all invocations.
   --html ARG   pass ARG to makeinfo or texi2html for HTML targets,
-                 instead of --css-ref=/software/gnulib/manual.css.
+                 instead of '$htmlarg'.
   --info ARG   pass ARG to makeinfo for Info, instead of --no-split.
   --no-ascii   skip generating the plain text output.
   --no-html    skip generating the html output.
@@ -137,24 +155,6 @@ SETLANG setting in the source.
 Email bug reports or enhancement requests to address@hidden
 "
 
-MANUAL_TITLE=
-PACKAGE=
address@hidden  # please override with --email
-commonarg= # passed to all makeinfo/texi2html invcations.
-dirargs=   # passed to all tools (-I dir).
-dirs=      # -I directories.
-htmlarg=--css-ref=/software/gnulib/manual.css
-infoarg=--no-split
-generate_ascii=true
-generate_html=true
-generate_info=true
-generate_tex=true
-outdir=manual
-source_extra=
-split=node
-srcfile=
-texarg="-t @finalout"
-
 while test $# -gt 0; do
   case $1 in
     -s)          shift; srcfile=$1;;
diff --git a/gl/intprops.h b/gl/intprops.h
index e1a6107..e1fce5c 100644
--- a/gl/intprops.h
+++ b/gl/intprops.h
@@ -1,10 +1,10 @@
 /* intprops.h -- properties of integer types
 
-   Copyright (C) 2001-2005, 2009-2016 Free Software Foundation, Inc.
+   Copyright (C) 2001-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
+   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,
@@ -21,6 +21,7 @@
 #define _GL_INTPROPS_H
 
 #include <limits.h>
+#include <verify.h>
 
 /* Return a value with the common real type of E and V and the value of V.  */
 #define _GL_INT_CONVERT(e, v) (0 * (e) + (v))
@@ -36,17 +37,6 @@
    an integer.  */
 #define TYPE_IS_INTEGER(t) ((t) 1.5 == 1)
 
-/* True if negative values of the signed integer type T use two's
-   complement, ones' complement, or signed magnitude representation,
-   respectively.  Much GNU code assumes two's complement, but some
-   people like to be portable to all possible C hosts.  */
-#define TYPE_TWOS_COMPLEMENT(t) ((t) ~ (t) 0 == (t) -1)
-#define TYPE_ONES_COMPLEMENT(t) ((t) ~ (t) 0 == 0)
-#define TYPE_SIGNED_MAGNITUDE(t) ((t) ~ (t) 0 < (t) -1)
-
-/* True if the signed integer expression E uses two's complement.  */
-#define _GL_INT_TWOS_COMPLEMENT(e) (~ _GL_INT_CONVERT (e, 0) == -1)
-
 /* True if the real type T is signed.  */
 #define TYPE_SIGNED(t) (! ((t) 0 < (t) -1))
 
@@ -55,18 +45,10 @@
 #define EXPR_SIGNED(e) (_GL_INT_NEGATE_CONVERT (e, 1) < 0)
 
 
-/* Minimum and maximum values for integer types and expressions.  These
-   macros have undefined behavior if T is signed and has padding bits.
-   If this is a problem for you, please let us know how to fix it for
-   your host.  */
+/* Minimum and maximum values for integer types and expressions.  */
 
 /* The maximum and minimum values for the integer type T.  */
-#define TYPE_MINIMUM(t)                                                 \
-  ((t) (! TYPE_SIGNED (t)                                               \
-        ? (t) 0                                                         \
-        : TYPE_SIGNED_MAGNITUDE (t)                                     \
-        ? ~ (t) 0                                                       \
-        : ~ TYPE_MAXIMUM (t)))
+#define TYPE_MINIMUM(t) ((t) ~ TYPE_MAXIMUM (t))
 #define TYPE_MAXIMUM(t)                                                 \
   ((t) (! TYPE_SIGNED (t)                                               \
         ? (t) -1                                                        \
@@ -76,7 +58,7 @@
    after integer promotion.  E should not have side effects.  */
 #define _GL_INT_MINIMUM(e)                                              \
   (EXPR_SIGNED (e)                                                      \
-   ? - _GL_INT_TWOS_COMPLEMENT (e) - _GL_SIGNED_INT_MAXIMUM (e)         \
+   ? ~ _GL_SIGNED_INT_MAXIMUM (e)                                       \
    : _GL_INT_CONVERT (e, 0))
 #define _GL_INT_MAXIMUM(e)                                              \
   (EXPR_SIGNED (e)                                                      \
@@ -85,8 +67,25 @@
 #define _GL_SIGNED_INT_MAXIMUM(e)                                       \
   (((_GL_INT_CONVERT (e, 1) << (sizeof ((e) + 0) * CHAR_BIT - 2)) - 1) * 2 + 1)
 
+/* This include file assumes that signed types are two's complement without
+   padding bits; the above macros have undefined behavior otherwise.
+   If this is a problem for you, please let us know how to fix it for your 
host.
+   As a sanity check, test the assumption for some signed types that
+   <limits.h> bounds.  */
+verify (TYPE_MINIMUM (signed char) == SCHAR_MIN);
+verify (TYPE_MAXIMUM (signed char) == SCHAR_MAX);
+verify (TYPE_MINIMUM (short int) == SHRT_MIN);
+verify (TYPE_MAXIMUM (short int) == SHRT_MAX);
+verify (TYPE_MINIMUM (int) == INT_MIN);
+verify (TYPE_MAXIMUM (int) == INT_MAX);
+verify (TYPE_MINIMUM (long int) == LONG_MIN);
+verify (TYPE_MAXIMUM (long int) == LONG_MAX);
+#ifdef LLONG_MAX
+verify (TYPE_MINIMUM (long long int) == LLONG_MIN);
+verify (TYPE_MAXIMUM (long long int) == LLONG_MAX);
+#endif
 
-/* Return 1 if the __typeof__ keyword works.  This could be done by
+/* Does the __typeof__ keyword work?  This could be done by
    'configure', but for now it's easier to do it by hand.  */
 #if (2 <= __GNUC__ || defined __IBM__TYPEOF__ \
      || (0x5110 <= __SUNPRO_C && !__STDC__))
@@ -223,24 +222,35 @@
    ? (a) < (min) >> (b)                                 \
    : (max) >> (b) < (a))
 
+/* True if __builtin_add_overflow (A, B, P) works when P is null.  */
+#define _GL_HAS_BUILTIN_OVERFLOW_WITH_NULL (7 <= __GNUC__)
 
 /* The _GL*_OVERFLOW macros have the same restrictions as the
    *_RANGE_OVERFLOW macros, except that they do not assume that operands
    (e.g., A and B) have the same type as MIN and MAX.  Instead, they assume
    that the result (e.g., A + B) has that type.  */
-#define _GL_ADD_OVERFLOW(a, b, min, max)                                \
-  ((min) < 0 ? INT_ADD_RANGE_OVERFLOW (a, b, min, max)                  \
-   : (a) < 0 ? (b) <= (a) + (b)                                         \
-   : (b) < 0 ? (a) <= (a) + (b)                                         \
-   : (a) + (b) < (b))
-#define _GL_SUBTRACT_OVERFLOW(a, b, min, max)                           \
-  ((min) < 0 ? INT_SUBTRACT_RANGE_OVERFLOW (a, b, min, max)             \
-   : (a) < 0 ? 1                                                        \
-   : (b) < 0 ? (a) - (b) <= (a)                                         \
-   : (a) < (b))
-#define _GL_MULTIPLY_OVERFLOW(a, b, min, max)                           \
-  (((min) == 0 && (((a) < 0 && 0 < (b)) || ((b) < 0 && 0 < (a))))       \
-   || INT_MULTIPLY_RANGE_OVERFLOW (a, b, min, max))
+#if _GL_HAS_BUILTIN_OVERFLOW_WITH_NULL
+# define _GL_ADD_OVERFLOW(a, b, min, max)
+   __builtin_add_overflow (a, b, (__typeof__ ((a) + (b)) *) 0)
+# define _GL_SUBTRACT_OVERFLOW(a, b, min, max)
+   __builtin_sub_overflow (a, b, (__typeof__ ((a) - (b)) *) 0)
+# define _GL_MULTIPLY_OVERFLOW(a, b, min, max)
+   __builtin_mul_overflow (a, b, (__typeof__ ((a) * (b)) *) 0)
+#else
+# define _GL_ADD_OVERFLOW(a, b, min, max)                                \
+   ((min) < 0 ? INT_ADD_RANGE_OVERFLOW (a, b, min, max)                  \
+    : (a) < 0 ? (b) <= (a) + (b)                                         \
+    : (b) < 0 ? (a) <= (a) + (b)                                         \
+    : (a) + (b) < (b))
+# define _GL_SUBTRACT_OVERFLOW(a, b, min, max)                           \
+   ((min) < 0 ? INT_SUBTRACT_RANGE_OVERFLOW (a, b, min, max)             \
+    : (a) < 0 ? 1                                                        \
+    : (b) < 0 ? (a) - (b) <= (a)                                         \
+    : (a) < (b))
+# define _GL_MULTIPLY_OVERFLOW(a, b, min, max)                           \
+   (((min) == 0 && (((a) < 0 && 0 < (b)) || ((b) < 0 && 0 < (a))))       \
+    || INT_MULTIPLY_RANGE_OVERFLOW (a, b, min, max))
+#endif
 #define _GL_DIVIDE_OVERFLOW(a, b, min, max)                             \
   ((min) < 0 ? (b) == _GL_INT_NEGATE_CONVERT (min, 1) && (a) < - (max)  \
    : (a) < 0 ? (b) <= (a) + (b) - 1                                     \
@@ -305,8 +315,12 @@
   _GL_BINARY_OP_OVERFLOW (a, b, _GL_ADD_OVERFLOW)
 #define INT_SUBTRACT_OVERFLOW(a, b) \
   _GL_BINARY_OP_OVERFLOW (a, b, _GL_SUBTRACT_OVERFLOW)
-#define INT_NEGATE_OVERFLOW(a) \
-  INT_NEGATE_RANGE_OVERFLOW (a, _GL_INT_MINIMUM (a), _GL_INT_MAXIMUM (a))
+#if _GL_HAS_BUILTIN_OVERFLOW_WITH_NULL
+# define INT_NEGATE_OVERFLOW(a) INT_SUBTRACT_OVERFLOW (0, a)
+#else
+# define INT_NEGATE_OVERFLOW(a) \
+   INT_NEGATE_RANGE_OVERFLOW (a, _GL_INT_MINIMUM (a), _GL_INT_MAXIMUM (a))
+#endif
 #define INT_MULTIPLY_OVERFLOW(a, b) \
   _GL_BINARY_OP_OVERFLOW (a, b, _GL_MULTIPLY_OVERFLOW)
 #define INT_DIVIDE_OVERFLOW(a, b) \
@@ -326,7 +340,7 @@
                       _GL_INT_MINIMUM (0 * (b) + (a)),          \
                       _GL_INT_MAXIMUM (0 * (b) + (a)))
 
-/* Compute A + B, A - B, A * B, respectively, storing the result into *R.
+/* Store the low-order bits of A + B, A - B, A * B, respectively, into *R.
    Return 1 if the result overflows.  See above for restrictions.  */
 #define INT_ADD_WRAPV(a, b, r) \
   _GL_INT_OP_WRAPV (a, b, r, +, __builtin_add_overflow, INT_ADD_OVERFLOW)
@@ -351,9 +365,10 @@
 # define _GL__GENERIC_BOGUS 0
 #endif
 
-/* Store A <op> B into *R, where OP specifies the operation.
-   BUILTIN is the builtin operation, and OVERFLOW the overflow predicate.
-   See above for restrictions.  */
+/* Store the low-order bits of A <op> B into *R, where OP specifies
+   the operation.  BUILTIN is the builtin operation, and OVERFLOW the
+   overflow predicate.  Return 1 if the result overflows.  See above
+   for restrictions.  */
 #if 5 <= __GNUC__ || __has_builtin (__builtin_add_overflow)
 # define _GL_INT_OP_WRAPV(a, b, r, op, builtin, overflow) builtin (a, b, r)
 #elif 201112 <= __STDC_VERSION__ && !_GL__GENERIC_BOGUS
@@ -404,7 +419,8 @@
 /* Store the low-order bits of A <op> B into *R, where the operation
    is given by OP.  Use the unsigned type UT for calculation to avoid
    overflow problems.  *R's type is T, with extremal values TMIN and
-   TMAX.  T must be a signed integer type.  */
+   TMAX.  T must be a signed integer type.  Return 1 if the result
+   overflows.  */
 #define _GL_INT_OP_CALC(a, b, r, op, overflow, ut, t, tmin, tmax) \
   (sizeof ((a) op (b)) < sizeof (t) \
    ? _GL_INT_OP_CALC1 ((t) (a), (t) (b), r, op, overflow, ut, t, tmin, tmax) \
diff --git a/gl/m4/dup2.m4 b/gl/m4/dup2.m4
index 63d6d8e..5b68312 100644
--- a/gl/m4/dup2.m4
+++ b/gl/m4/dup2.m4
@@ -1,4 +1,4 @@
-#serial 24
+#serial 25
 dnl Copyright (C) 2002, 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,
@@ -62,6 +62,16 @@ AC_DEFUN([gl_FUNC_DUP2],
                result |= 32;
              dup2 (2, 255);
              dup2 (2, 256);
+             /* On OS/2 kLIBC, dup2() does not work on a directory fd.  */
+             {
+               int fd = open (".", O_RDONLY);
+               if (fd == -1)
+                 result |= 64;
+               else if (dup2 (fd, fd + 1) == -1)
+                 result |= 128;
+
+               close (fd);
+             }
              return result;]])
         ],
         [gl_cv_func_dup2_works=yes], [gl_cv_func_dup2_works=no],
@@ -78,6 +88,8 @@ AC_DEFUN([gl_FUNC_DUP2],
              gl_cv_func_dup2_works="guessing no" ;;
            *-android*) # implemented using dup3(), which fails if oldfd == 
newfd
              gl_cv_func_dup2_works="guessing no" ;;
+           os2*) # on OS/2 kLIBC, dup2() does not work on a directory fd.
+             gl_cv_func_dup2_works="guessing no" ;;
            *) gl_cv_func_dup2_works="guessing yes" ;;
          esac])
       ])
diff --git a/gl/m4/extern-inline.m4 b/gl/m4/extern-inline.m4
index fe282a5..1e578f3 100644
--- a/gl/m4/extern-inline.m4
+++ b/gl/m4/extern-inline.m4
@@ -54,6 +54,7 @@ AC_DEFUN([gl_EXTERN_INLINE],
       ? defined __GNUC_STDC_INLINE__ && __GNUC_STDC_INLINE__ \
       : (199901L <= __STDC_VERSION__ \
          && !defined __HP_cc \
+         && !defined __PGI \
          && !(defined __SUNPRO_C && __STDC__))) \
      && !defined _GL_EXTERN_INLINE_STDHEADER_BUG)
 # define _GL_INLINE inline
diff --git a/gl/m4/getcwd.m4 b/gl/m4/getcwd.m4
index 2b1c416..566c3c1 100644
--- a/gl/m4/getcwd.m4
+++ b/gl/m4/getcwd.m4
@@ -6,7 +6,7 @@
 # with or without modifications, as long as this notice is preserved.
 
 # Written by Paul Eggert.
-# serial 12
+# serial 13
 
 AC_DEFUN([gl_FUNC_GETCWD_NULL],
   [
@@ -15,6 +15,7 @@ AC_DEFUN([gl_FUNC_GETCWD_NULL],
    AC_CACHE_CHECK([whether getcwd (NULL, 0) allocates memory for result],
      [gl_cv_func_getcwd_null],
      [AC_RUN_IFELSE([AC_LANG_PROGRAM([[
+#       include <stdlib.h>
 #        if HAVE_UNISTD_H
 #         include <unistd.h>
 #        else /* on Windows with MSVC */
@@ -39,6 +40,7 @@ AC_DEFUN([gl_FUNC_GETCWD_NULL],
                  return 3;
                if (f[1] != '\0')
                  return 4;
+               free (f);
                return 0;
              }
 #endif
diff --git a/gl/m4/getdelim.m4 b/gl/m4/getdelim.m4
index f11195a..a1a7dcc 100644
--- a/gl/m4/getdelim.m4
+++ b/gl/m4/getdelim.m4
@@ -1,4 +1,4 @@
-# getdelim.m4 serial 10
+# getdelim.m4 serial 11
 
 dnl Copyright (C) 2005-2007, 2009-2016 Free Software Foundation, Inc.
 dnl
@@ -48,7 +48,9 @@ AC_DEFUN([gl_FUNC_GETDELIM],
         size_t siz = (size_t)(~0) / 4;
         if (getdelim (&line, &siz, '\n', in) == -1)
           return 3;
+        free (line);
       }
+      fclose (in);
       return 0;
     }
     ]])], [gl_cv_func_working_getdelim=yes] dnl The library version works.
diff --git a/gl/m4/getline.m4 b/gl/m4/getline.m4
index 443871f..f44751c 100644
--- a/gl/m4/getline.m4
+++ b/gl/m4/getline.m4
@@ -1,4 +1,4 @@
-# getline.m4 serial 26
+# getline.m4 serial 27
 
 dnl Copyright (C) 1998-2003, 2005-2007, 2009-2016 Free Software Foundation,
 dnl Inc.
@@ -47,6 +47,7 @@ AC_DEFUN([gl_FUNC_GETLINE],
         int len = getline (&line, &siz, in);
         if (!(len == 4 && line && strcmp (line, "foo\n") == 0))
           return 2;
+        free (line);
       }
       {
         /* Test result for a NULL buffer and a non-zero size.
@@ -55,7 +56,9 @@ AC_DEFUN([gl_FUNC_GETLINE],
         size_t siz = (size_t)(~0) / 4;
         if (getline (&line, &siz, in) == -1)
           return 3;
+        free (line);
       }
+      fclose (in);
       return 0;
     }
     ]])], [am_cv_func_working_getline=yes] dnl The library version works.
diff --git a/gl/m4/malloc.m4 b/gl/m4/malloc.m4
index 717e8ad..c393690 100644
--- a/gl/m4/malloc.m4
+++ b/gl/m4/malloc.m4
@@ -1,4 +1,4 @@
-# malloc.m4 serial 14
+# malloc.m4 serial 15
 dnl Copyright (C) 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,
@@ -6,8 +6,8 @@ dnl with or without modifications, as long as this notice is 
preserved.
 
 m4_version_prereq([2.70], [] ,[
 
-# This is taken from the following Autoconf patch:
-# 
http://git.savannah.gnu.org/gitweb/?p=autoconf.git;a=commitdiff;h=7fbb553727ed7e0e689a17594b58559ecf3ea6e9
+# This is adapted with modifications from upstream Autoconf here:
+# 
http://git.savannah.gnu.org/cgit/autoconf.git/commit/?id=04be2b7a29d65d9a08e64e8e56e594c91749598c
 AC_DEFUN([_AC_FUNC_MALLOC_IF],
 [
   AC_REQUIRE([AC_HEADER_STDC])dnl
@@ -23,7 +23,10 @@ AC_DEFUN([_AC_FUNC_MALLOC_IF],
             char *malloc ();
             #endif
           ]],
-          [[return ! malloc (0);]])
+          [[char *p = malloc (0);
+            int result = !p;
+            free (p);
+            return result;]])
        ],
        [ac_cv_func_malloc_0_nonnull=yes],
        [ac_cv_func_malloc_0_nonnull=no],
diff --git a/gl/m4/manywarnings.m4 b/gl/m4/manywarnings.m4
index 12d68da..90823b0 100644
--- a/gl/m4/manywarnings.m4
+++ b/gl/m4/manywarnings.m4
@@ -1,4 +1,4 @@
-# manywarnings.m4 serial 7
+# manywarnings.m4 serial 8
 dnl Copyright (C) 2008-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,
@@ -129,6 +129,7 @@ AC_DEFUN([gl_MANYWARN_ALL_GCC],
     -Wdiscarded-qualifiers \
     -Wdiv-by-zero \
     -Wdouble-promotion \
+    -Wduplicated-cond \
     -Wempty-body \
     -Wendif-labels \
     -Wenum-compare \
@@ -140,7 +141,10 @@ AC_DEFUN([gl_MANYWARN_ALL_GCC],
     -Wformat-signedness \
     -Wformat-y2k \
     -Wformat-zero-length \
+    -Wframe-address \
     -Wfree-nonheap-object \
+    -Whsa \
+    -Wignored-attributes \
     -Wignored-qualifiers \
     -Wimplicit \
     -Wimplicit-function-declaration \
@@ -158,6 +162,7 @@ AC_DEFUN([gl_MANYWARN_ALL_GCC],
     -Wmain \
     -Wmaybe-uninitialized \
     -Wmemset-transposed-args \
+    -Wmisleading-indentation \
     -Wmissing-braces \
     -Wmissing-declarations \
     -Wmissing-field-initializers \
@@ -168,6 +173,8 @@ AC_DEFUN([gl_MANYWARN_ALL_GCC],
     -Wnarrowing \
     -Wnested-externs \
     -Wnonnull \
+    -Wnonnull-compare \
+    -Wnull-dereference \
     -Wodr \
     -Wold-style-declaration \
     -Wold-style-definition \
@@ -184,10 +191,12 @@ AC_DEFUN([gl_MANYWARN_ALL_GCC],
     -Wpragmas \
     -Wreturn-local-addr \
     -Wreturn-type \
+    -Wscalar-storage-order \
     -Wsequence-point \
     -Wshadow \
     -Wshift-count-negative \
     -Wshift-count-overflow \
+    -Wshift-negative-value \
     -Wsizeof-array-argument \
     -Wsizeof-pointer-memaccess \
     -Wstack-protector \
@@ -205,6 +214,7 @@ AC_DEFUN([gl_MANYWARN_ALL_GCC],
     -Wswitch-default \
     -Wsync-nand \
     -Wsystem-headers \
+    -Wtautological-compare \
     -Wtrampolines \
     -Wtrigraphs \
     -Wtype-limits \
@@ -237,6 +247,8 @@ AC_DEFUN([gl_MANYWARN_ALL_GCC],
   # them here so that the above 'comm' command doesn't report a false match.
   gl_manywarn_set="$gl_manywarn_set -Warray-bounds=2"
   gl_manywarn_set="$gl_manywarn_set -Wnormalized=nfc"
+  gl_manywarn_set="$gl_manywarn_set -Wshift-overflow=2"
+  gl_manywarn_set="$gl_manywarn_set -Wunused-const-variable=2"
 
   # These are needed for older GCC versions.
   if test -n "$GCC"; then
diff --git a/gl/m4/nocrash.m4 b/gl/m4/nocrash.m4
index ecc55c6..d8dd8f1 100644
--- a/gl/m4/nocrash.m4
+++ b/gl/m4/nocrash.m4
@@ -110,11 +110,12 @@ nocrash_init (void)
 #else
 /* Avoid a crash on POSIX systems.  */
 #include <signal.h>
+#include <unistd.h>
 /* A POSIX signal handler.  */
 static void
 exception_handler (int sig)
 {
-  exit (1);
+  _exit (1);
 }
 static void
 nocrash_init (void)
diff --git a/gl/m4/realloc.m4 b/gl/m4/realloc.m4
index 7b32ddf..fc22825 100644
--- a/gl/m4/realloc.m4
+++ b/gl/m4/realloc.m4
@@ -1,4 +1,4 @@
-# realloc.m4 serial 13
+# realloc.m4 serial 14
 dnl Copyright (C) 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,
@@ -6,8 +6,8 @@ dnl with or without modifications, as long as this notice is 
preserved.
 
 m4_version_prereq([2.70], [] ,[
 
-# This is taken from the following Autoconf patch:
-# 
http://git.savannah.gnu.org/gitweb/?p=autoconf.git;a=commitdiff;h=7fbb553727ed7e0e689a17594b58559ecf3ea6e9
+# This is adapted with modifications from upstream Autoconf here:
+# 
http://git.savannah.gnu.org/cgit/autoconf.git/commit/?id=04be2b7a29d65d9a08e64e8e56e594c91749598c
 AC_DEFUN([_AC_FUNC_REALLOC_IF],
 [
   AC_REQUIRE([AC_HEADER_STDC])dnl
@@ -23,7 +23,10 @@ AC_DEFUN([_AC_FUNC_REALLOC_IF],
             char *realloc ();
             #endif
           ]],
-          [[return ! realloc (0, 0);]])
+          [[char *p = realloc (0, 0);
+            int result = !p;
+            free (p);
+            return result;]])
        ],
        [ac_cv_func_realloc_0_nonnull=yes],
        [ac_cv_func_realloc_0_nonnull=no],
diff --git a/gl/m4/stdbool.m4 b/gl/m4/stdbool.m4
index 625520f..a556153 100644
--- a/gl/m4/stdbool.m4
+++ b/gl/m4/stdbool.m4
@@ -5,7 +5,7 @@ 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.
 
-#serial 5
+#serial 6
 
 # Prepare for substituting <stdbool.h> if it is not supported.
 
@@ -43,21 +43,25 @@ AC_DEFUN([AC_CHECK_HEADER_STDBOOL],
         [AC_LANG_PROGRAM(
            [[
              #include <stdbool.h>
-             #ifndef bool
-              "error: bool is not defined"
-             #endif
-             #ifndef false
-              "error: false is not defined"
-             #endif
-             #if false
-              "error: false is not 0"
-             #endif
-             #ifndef true
-              "error: true is not defined"
-             #endif
-             #if true != 1
-              "error: true is not 1"
+
+             #if __cplusplus < 201103
+              #ifndef bool
+               "error: bool is not defined"
+              #endif
+              #ifndef false
+               "error: false is not defined"
+              #endif
+              #if false
+               "error: false is not 0"
+              #endif
+              #ifndef true
+               "error: true is not defined"
+              #endif
+              #if true != 1
+               "error: true is not 1"
+              #endif
              #endif
+
              #ifndef __bool_true_false_are_defined
               "error: __bool_true_false_are_defined is not defined"
              #endif
diff --git a/gl/m4/stdint.m4 b/gl/m4/stdint.m4
index 0f40ce8..0b4b906 100644
--- a/gl/m4/stdint.m4
+++ b/gl/m4/stdint.m4
@@ -1,4 +1,4 @@
-# stdint.m4 serial 43
+# stdint.m4 serial 44
 dnl Copyright (C) 2001-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,
@@ -70,6 +70,8 @@ AC_DEFUN_ONCE([gl_STDINT_H],
        AC_COMPILE_IFELSE([
          AC_LANG_PROGRAM([[
 #define _GL_JUST_INCLUDE_SYSTEM_STDINT_H 1 /* work if build isn't clean */
+#define __STDC_CONSTANT_MACROS 1
+#define __STDC_LIMIT_MACROS 1
 #include <stdint.h>
 /* Dragonfly defines WCHAR_MIN, WCHAR_MAX only in <wchar.h>.  */
 #if !(defined WCHAR_MIN && defined WCHAR_MAX)
@@ -218,6 +220,8 @@ struct s {
           AC_RUN_IFELSE([
             AC_LANG_PROGRAM([[
 #define _GL_JUST_INCLUDE_SYSTEM_STDINT_H 1 /* work if build isn't clean */
+#define __STDC_CONSTANT_MACROS 1
+#define __STDC_LIMIT_MACROS 1
 #include <stdint.h>
 ]
 gl_STDINT_INCLUDES
@@ -279,6 +283,29 @@ static const char *macro_values[] =
       ])
   fi
   if test "$gl_cv_header_working_stdint_h" = yes; then
+    dnl Now see whether the system <stdint.h> works without
+    dnl __STDC_CONSTANT_MACROS/__STDC_LIMIT_MACROS defined.
+    AC_CACHE_CHECK([whether stdint.h predates C++11],
+      [gl_cv_header_stdint_predates_cxx11_h],
+      [gl_cv_header_stdint_predates_cxx11_h=yes
+       AC_COMPILE_IFELSE([
+        AC_LANG_PROGRAM([[
+#define _GL_JUST_INCLUDE_SYSTEM_STDINT_H 1 /* work if build isn't clean */
+#include <stdint.h>
+]
+gl_STDINT_INCLUDES
+[
+intmax_t im = INTMAX_MAX;
+int32_t i32 = INT32_C (0x7fffffff);
+         ]])],
+         [gl_cv_header_stdint_predates_cxx11_h=no])])
+
+    if test "$gl_cv_header_stdint_predates_cxx11_h" = yes; then
+      AC_DEFINE([__STDC_CONSTANT_MACROS], [1],
+                [Define to 1 if the system <stdint.h> predates C++11.])
+      AC_DEFINE([__STDC_LIMIT_MACROS], [1],
+                [Define to 1 if the system <stdint.h> predates C++11.])
+    fi
     STDINT_H=
   else
     dnl Check for <sys/inttypes.h>, and for
diff --git a/gl/override/lib/gettext.h.diff b/gl/override/lib/gettext.h.diff
index f3546bb..03ffd2e 100644
--- a/gl/override/lib/gettext.h.diff
+++ b/gl/override/lib/gettext.h.diff
@@ -1,6 +1,6 @@
---- gl/gettext.h.orig  2012-08-02 22:38:36.802409103 +0200
-+++ gl/gettext.h       2012-08-02 22:38:45.550409325 +0200
-@@ -107,182 +107,4 @@
+--- gl/gettext.h.orig
++++ gl/gettext.h
+@@ -107,186 +107,4 @@
     initializer for static 'char[]' or 'const char[]' variables.  */
  #define gettext_noop(String) String
  
@@ -122,15 +122,17 @@
 -  if (msg_ctxt_id != NULL)
 -#endif
 -    {
+-      int found_translation;
 -      memcpy (msg_ctxt_id, msgctxt, msgctxt_len - 1);
 -      msg_ctxt_id[msgctxt_len - 1] = '\004';
 -      memcpy (msg_ctxt_id + msgctxt_len, msgid, msgid_len);
 -      translation = dcgettext (domain, msg_ctxt_id, category);
+-      found_translation = (translation != msg_ctxt_id);
 -#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
 -      if (msg_ctxt_id != buf)
 -        free (msg_ctxt_id);
 -#endif
--      if (translation != msg_ctxt_id)
+-      if (found_translation)
 -        return translation;
 -    }
 -  return msgid;
@@ -168,15 +170,17 @@
 -  if (msg_ctxt_id != NULL)
 -#endif
 -    {
+-      int found_translation;
 -      memcpy (msg_ctxt_id, msgctxt, msgctxt_len - 1);
 -      msg_ctxt_id[msgctxt_len - 1] = '\004';
 -      memcpy (msg_ctxt_id + msgctxt_len, msgid, msgid_len);
 -      translation = dcngettext (domain, msg_ctxt_id, msgid_plural, n, 
category);
+-      found_translation = !(translation == msg_ctxt_id || translation == 
msgid_plural);
 -#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
 -      if (msg_ctxt_id != buf)
 -        free (msg_ctxt_id);
 -#endif
--      if (!(translation == msg_ctxt_id || translation == msgid_plural))
+-      if (found_translation)
 -        return translation;
 -    }
 -  return (n == 1 ? msgid : msgid_plural);
diff --git a/gl/stddef.in.h b/gl/stddef.in.h
index c6d2317..f4c4a10 100644
--- a/gl/stddef.in.h
+++ b/gl/stddef.in.h
@@ -81,8 +81,10 @@
 # define wchar_t int
 #endif
 
-/* Some platforms lack max_align_t.  */
-#if address@hidden@
+/* Some platforms lack max_align_t.  The check for _GCC_MAX_ALIGN_T is
+   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)
 /* 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
diff --git a/gl/stdint.in.h b/gl/stdint.in.h
index d241391..cf65ec6 100644
--- a/gl/stdint.in.h
+++ b/gl/stdint.in.h
@@ -118,15 +118,10 @@
    picky compilers.  */
 
 #define _STDINT_MIN(signed, bits, zero) \
-  ((signed) ? (- ((zero) + 1) << ((bits) ? (bits) - 1 : 0)) : (zero))
+  ((signed) ? ~ _STDINT_MAX (signed, bits, zero) : (zero))
 
 #define _STDINT_MAX(signed, bits, zero) \
-  ((signed) \
-   ? ~ _STDINT_MIN (signed, bits, zero) \
-   : /* The expression for the unsigned case.  The subtraction of (signed) \
-        is a nop in the unsigned case and avoids "signed integer overflow" \
-        warnings in the signed case.  */ \
-     ((((zero) + 1) << ((bits) ? (bits) - 1 - (signed) : 0)) - 1) * 2 + 1)
+  (((((zero) + 1) << ((bits) ? (bits) - 1 - (signed) : 0)) - 1) * 2 + 1)
 
 #if !GNULIB_defined_stdint_types
 
@@ -288,12 +283,17 @@ typedef gl_uint_fast32_t gl_uint_fast16_t;
 
 /* 7.18.1.4. Integer types capable of holding object pointers */
 
+/* kLIBC's stdint.h defines _INTPTR_T_DECLARED and needs its own
+   definitions of intptr_t and uintptr_t (which use int and unsigned)
+   to avoid clashes with declarations of system functions like sbrk.  */
+#ifndef _INTPTR_T_DECLARED
 #undef intptr_t
 #undef uintptr_t
 typedef long int gl_intptr_t;
 typedef unsigned long int gl_uintptr_t;
 #define intptr_t gl_intptr_t
 #define uintptr_t gl_uintptr_t
+#endif
 
 /* 7.18.1.5. Greatest-width integer types */
 
diff --git a/gl/verify.h b/gl/verify.h
index 2f43837..5c8381d 100644
--- a/gl/verify.h
+++ b/gl/verify.h
@@ -263,7 +263,7 @@ template <int w>
 # define assume(R) ((R) ? (void) 0 : __builtin_unreachable ())
 #elif 1200 <= _MSC_VER
 # define assume(R) __assume (R)
-#elif (defined lint \
+#elif ((defined GCC_LINT || defined lint) \
        && (__has_builtin (__builtin_trap) \
            || 3 < __GNUC__ + (3 < __GNUC_MINOR__ + (4 <= 
__GNUC_PATCHLEVEL__))))
   /* Doing it this way helps various packages when configured with
diff --git a/gltests/Makefile.am b/gltests/Makefile.am
index 0b7a6b3..422b79a 100644
--- a/gltests/Makefile.am
+++ b/gltests/Makefile.am
@@ -946,6 +946,11 @@ EXTRA_DIST += test-vc-list-files-git.sh 
test-vc-list-files-cvs.sh
 TESTS_ENVIRONMENT += MAKE='$(MAKE)'
 TESTS += test-verify test-verify.sh
 check_PROGRAMS += test-verify
+
+# This test expects compilation of test-verify.c to fail, and
+# each time it fails, the makefile rule does not perform the usual
+#  "mv -f $name.Tpo $name.po, so tell make clean to remove that file.
+MOSTLYCLEANFILES += .deps/test-verify.Tpo
 EXTRA_DIST += test-verify.c test-verify.sh
 
 ## end   gnulib module verify-tests
diff --git a/gltests/binary-io.h b/gltests/binary-io.h
index d5c8233..9f17c0d 100644
--- a/gltests/binary-io.h
+++ b/gltests/binary-io.h
@@ -60,7 +60,7 @@ set_binary_mode (int fd, int mode)
 
 /* SET_BINARY (fd);
    changes the file descriptor fd to perform binary I/O.  */
-#ifdef __DJGPP__
+#if defined __DJGPP__ || defined __EMX__
 # include <unistd.h> /* declares isatty() */
   /* Avoid putting stdin/stdout in binary mode if it is connected to
      the console, because that would make it impossible for the user
diff --git a/gltests/dup2.c b/gltests/dup2.c
index c913f47..5d026f2 100644
--- a/gltests/dup2.c
+++ b/gltests/dup2.c
@@ -85,6 +85,57 @@ ms_windows_dup2 (int fd, int desired_fd)
 
 #  define dup2 ms_windows_dup2
 
+# elif defined __KLIBC__
+
+#  include <InnoTekLIBC/backend.h>
+
+static int
+klibc_dup2dirfd (int fd, int desired_fd)
+{
+  int tempfd;
+  int dupfd;
+
+  tempfd = open ("NUL", O_RDONLY);
+  if (tempfd == -1)
+    return -1;
+
+  if (tempfd == desired_fd)
+    {
+      close (tempfd);
+
+      char path[_MAX_PATH];
+      if (__libc_Back_ioFHToPath (fd, path, sizeof (path)))
+        return -1;
+
+      return open(path, O_RDONLY);
+    }
+
+  dupfd = klibc_dup2dirfd (fd, desired_fd);
+
+  close (tempfd);
+
+  return dupfd;
+}
+
+static int
+klibc_dup2 (int fd, int desired_fd)
+{
+  int dupfd;
+  struct stat sbuf;
+
+  dupfd = dup2 (fd, desired_fd);
+  if (dupfd == -1 && errno == ENOTSUP \
+      && !fstat (fd, &sbuf) && S_ISDIR (sbuf.st_mode))
+    {
+      close (desired_fd);
+
+      return klibc_dup2dirfd (fd, desired_fd);
+    }
+
+  return dupfd;
+}
+
+#  define dup2 klibc_dup2
 # endif
 
 int
diff --git a/gltests/init.sh b/gltests/init.sh
index ee08022..97e4e4b 100644
--- a/gltests/init.sh
+++ b/gltests/init.sh
@@ -308,13 +308,19 @@ if diff_out_=`exec 2>/dev/null; diff -u "$0" "$0" < 
/dev/null` \
       fi
     }
   fi
-elif diff_out_=`exec 2>/dev/null; diff -c "$0" "$0" < /dev/null`; then
+elif
+  for diff_opt_ in -U3 -c '' no; do
+    test "$diff_opt_" = no && break
+    diff_out_=`exec 2>/dev/null; diff $diff_opt_ "$0" "$0" </dev/null` && break
+  done
+  test "$diff_opt_" != no
+then
   if test -z "$diff_out_"; then
-    compare_ () { diff -c "$@"; }
+    compare_ () { diff $diff_opt_ "$@"; }
   else
     compare_ ()
     {
-      if diff -c "$@" > diff.out; then
+      if diff $diff_opt_ "$@" > diff.out; then
         # No differences were found, but AIX and HP-UX 'diff' produce output
         # "No differences encountered" or "There are no differences between the
         # files.". Hide this output.
@@ -466,7 +472,6 @@ setup_ ()
   fi
 
   initial_cwd_=$PWD
-  fail=0
 
   pfx_=`testdir_prefix_`
   test_dir_=`mktempd_ "$initial_cwd_" "$pfx_-$ME_.XXXX"` \
@@ -550,8 +555,9 @@ mktempd_ ()
   # Disallow any trailing slash on specified destdir:
   # it would subvert the post-mktemp "case"-based destdir test.
   case $destdir_ in
-  /) ;;
+  / | //) destdir_slash_=$destdir;;
   */) fail_ "invalid destination dir: remove trailing slash(es)";;
+  *) destdir_slash_=$destdir_/;;
   esac
 
   case $template_ in
@@ -561,20 +567,17 @@ mktempd_ ()
   esac
 
   # First, try to use mktemp.
-  d=`unset TMPDIR; { mktemp -d -t -p "$destdir_" "$template_"; } 2>/dev/null` \
-    || fail=1
+  d=`unset TMPDIR; { mktemp -d -t -p "$destdir_" "$template_"; } 2>/dev/null` 
&&
 
   # The resulting name must be in the specified directory.
-  case $d in "$destdir_"*);; *) fail=1;; esac
+  case $d in "$destdir_slash_"*) :;; *) false;; esac &&
 
   # It must have created the directory.
-  test -d "$d" || fail=1
+  test -d "$d" &&
 
   # It must have 0700 permissions.  Handle sticky "S" bits.
-  perms=`ls -dgo "$d" 2>/dev/null|tr S -` || fail=1
-  case $perms in drwx------*) ;; *) fail=1;; esac
-
-  test $fail = 0 && {
+  perms=`ls -dgo "$d" 2>/dev/null` &&
+  case $perms in drwx--[-S]---*) :;; *) false;; esac && {
     echo "$d"
     return
   }
@@ -593,7 +596,7 @@ mktempd_ ()
   i_=1
   while :; do
     X_=`rand_bytes_ $nx_`
-    candidate_dir_="$destdir_/$base_template_$X_"
+    candidate_dir_="$destdir_slash_$base_template_$X_"
     err_=`mkdir -m 0700 "$candidate_dir_" 2>&1` \
       && { echo "$candidate_dir_"; return; }
     test $MAX_TRIES_ -le $i_ && break;
diff --git a/gltests/stdalign.in.h b/gltests/stdalign.in.h
index 9abb9aa..12f8a15 100644
--- a/gltests/stdalign.in.h
+++ b/gltests/stdalign.in.h
@@ -103,15 +103,15 @@
 # elif ((defined __APPLE__ && defined __MACH__                  \
          ? 4 < __GNUC__ + (1 <= __GNUC_MINOR__)                 \
          : __GNUC__)                                            \
-        || __HP_cc || __HP_aCC || __IBMC__ || __IBMCPP__        \
-        || __ICC || 0x590 <= __SUNPRO_C)
+        || 061200 <= __HP_cc || 061200 <= __HP_aCC                \
+        || __ICC || 0x590 <= __SUNPRO_C || 0x0600 <= __xlC__)
 #  define _Alignas(a) __attribute__ ((__aligned__ (a)))
 # elif 1300 <= _MSC_VER
 #  define _Alignas(a) __declspec (align (a))
 # endif
 #endif
 #if ((defined _Alignas && ! (defined __cplusplus && 201103 <= __cplusplus)) \
-     || (defined __STDC_VERSION && 201112 <= __STDC_VERSION__))
+     || (defined __STDC_VERSION__ && 201112 <= __STDC_VERSION__))
 # define alignas _Alignas
 #endif
 #if defined alignas || (defined __cplusplus && 201103 <= __cplusplus)
diff --git a/gltests/test-getline.c b/gltests/test-getline.c
index adf2cc4..13dcb1d 100644
--- a/gltests/test-getline.c
+++ b/gltests/test-getline.c
@@ -71,8 +71,8 @@ main (void)
   free (line);
 
   /* Test growth of buffer, must not leak.  */
-  line = malloc (1);
-  len = 0;
+  len = 1;
+  line = malloc (len);
   result = getline (&line, &len, f);
   ASSERT (result == 3);
   ASSERT (strcmp (line, "bc\n") == 0);
diff --git a/gltests/test-intprops.c b/gltests/test-intprops.c
index 174ddec..0a8ddcd 100644
--- a/gltests/test-intprops.c
+++ b/gltests/test-intprops.c
@@ -22,12 +22,9 @@
 # pragma GCC diagnostic ignored "-Woverlength-strings"
 # pragma GCC diagnostic ignored "-Wtype-limits"
 
-/* Work around a bug in GCC 5.3.1 and earlier; see:
-   https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68971
-   Hope it will be fixed by the time GCC 6 comes out.  */
-# if __GNUC__ < 6
-#  pragma GCC diagnostic ignored "-Woverflow"
-# endif
+/* Work around a bug in GCC 6.1 and earlier; see:
+   https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68971  */
+# pragma GCC diagnostic ignored "-Woverflow"
 
 #endif
 
@@ -94,12 +91,8 @@ main (void)
   ASSERT (TYPE_SIGNED (double));
   ASSERT (TYPE_SIGNED (long double));
 
-  /* Integer representation.  */
-  VERIFY (INT_MIN + INT_MAX < 0
-          ? (TYPE_TWOS_COMPLEMENT (int)
-             && ! TYPE_ONES_COMPLEMENT (int) && ! TYPE_SIGNED_MAGNITUDE (int))
-          : (! TYPE_TWOS_COMPLEMENT (int)
-             && (TYPE_ONES_COMPLEMENT (int) || TYPE_SIGNED_MAGNITUDE (int))));
+  /* Integer representation.  Check that it is two's complement.  */
+  VERIFY (INT_MIN + INT_MAX < 0);
 
   /* TYPE_MINIMUM, TYPE_MAXIMUM.  */
   VERIFY (TYPE_MINIMUM (char) == CHAR_MIN);
@@ -156,8 +149,7 @@ main (void)
     {                                                                     \
       t result;                                                           \
       ASSERT (INT_##opname##_WRAPV (a, b, &result) == (v));               \
-      ASSERT (result == ((v) ? (vres) : ((a) op (b)))                     \
-              || ((v) && !TYPE_TWOS_COMPLEMENT (t)));                     \
+      ASSERT (result == ((v) ? (vres) : ((a) op (b))));                   \
     }
   #define CHECK_UNOP(op, opname, a, t, v)                                 \
     VERIFY (INT_##opname##_RANGE_OVERFLOW (a, TYPE_MINIMUM (t),           \
@@ -183,7 +175,7 @@ main (void)
   CHECK_BINOP (-, SUBTRACT, UINT_MAX, 1u, unsigned int, false, UINT_MAX - 1u);
   CHECK_BINOP (-, SUBTRACT, 0u, 1u, unsigned int, true, 0u - 1u);
 
-  CHECK_UNOP (-, NEGATE, INT_MIN, int, TYPE_TWOS_COMPLEMENT (int));
+  CHECK_UNOP (-, NEGATE, INT_MIN, int, true);
   CHECK_UNOP (-, NEGATE, 0, int, false);
   CHECK_UNOP (-, NEGATE, INT_MAX, int, false);
   CHECK_UNOP (-, NEGATE, 0u, unsigned int, false);
@@ -230,8 +222,7 @@ main (void)
     {                                                                     \
       t result;                                                           \
       ASSERT (INT_ADD_WRAPV (a, b, &result) == (v));                      \
-      ASSERT (result == ((v) ? (vres) : ((a) + (b)))                      \
-              || ((v) && !TYPE_TWOS_COMPLEMENT (t)));                     \
+      ASSERT (result == ((v) ? (vres) : ((a) + (b))));                    \
     }
   CHECK_SSUM (-1, LONG_MIN, long int, true, LONG_MAX);
   CHECK_SUM (-1, UINT_MAX, unsigned int, false, DONTCARE);
@@ -259,8 +250,7 @@ main (void)
     {                                                                     \
       t result;                                                           \
       ASSERT (INT_SUBTRACT_WRAPV (a, b, &result) == (v));                 \
-      ASSERT (result == ((v) ? (vres) : ((a) - (b)))                      \
-              || ((v) && !TYPE_TWOS_COMPLEMENT (t)));                     \
+      ASSERT (result == ((v) ? (vres) : ((a) - (b))));                    \
     }
   CHECK_DIFFERENCE (INT_MAX, 1u, unsigned int, UINT_MAX < INT_MAX - 1,
                     INT_MAX - 1u);
@@ -292,8 +282,7 @@ main (void)
     {                                                                     \
       t result;                                                           \
       ASSERT (INT_MULTIPLY_WRAPV (a, b, &result) == (v));                 \
-      ASSERT (result == ((v) ? (vres) : ((a) * (b)))                      \
-              || ((v) && !TYPE_TWOS_COMPLEMENT (t)));                     \
+      ASSERT (result == ((v) ? (vres) : ((a) * (b))));                    \
     }
   CHECK_PRODUCT (-1, 1u, unsigned int, true, -1 * 1u);
   CHECK_SPRODUCT (-1, INT_MIN, int, INT_NEGATE_OVERFLOW (INT_MIN), INT_MIN);
@@ -351,8 +340,7 @@ main (void)
 
   #define CHECK_QUOTIENT(a, b, v) VERIFY (INT_DIVIDE_OVERFLOW (a, b) == (v))
 
-  CHECK_QUOTIENT (INT_MIN, -1L,
-                  TYPE_TWOS_COMPLEMENT (long int) && INT_MIN == LONG_MIN);
+  CHECK_QUOTIENT (INT_MIN, -1L, INT_MIN == LONG_MIN);
   CHECK_QUOTIENT (INT_MIN, UINT_MAX, false);
   CHECK_QUOTIENT (INTMAX_MIN, UINTMAX_MAX, false);
   CHECK_QUOTIENT (INTMAX_MIN, UINT_MAX, false);
@@ -365,8 +353,7 @@ main (void)
 
   #define CHECK_REMAINDER(a, b, v) VERIFY (INT_REMAINDER_OVERFLOW (a, b) == 
(v))
 
-  CHECK_REMAINDER (INT_MIN, -1L,
-                   TYPE_TWOS_COMPLEMENT (long int) && INT_MIN == LONG_MIN);
+  CHECK_REMAINDER (INT_MIN, -1L, INT_MIN == LONG_MIN);
   CHECK_REMAINDER (-1, UINT_MAX, true);
   CHECK_REMAINDER ((intmax_t) -1, UINTMAX_MAX, true);
   CHECK_REMAINDER (INTMAX_MIN, UINT_MAX,
diff --git a/gltests/test-stat.c b/gltests/test-stat.c
index b1f2d12..4510e59 100644
--- a/gltests/test-stat.c
+++ b/gltests/test-stat.c
@@ -30,6 +30,7 @@ SIGNATURE_CHECK (stat, int, (char const *, struct stat *));
 #include <fcntl.h>
 #include <errno.h>
 #include <stdbool.h>
+#include <stdlib.h>
 #include <stdio.h>
 #include <unistd.h>
 
diff --git a/gltests/test-stat.h b/gltests/test-stat.h
index 28e1e24..4cf6c6d 100644
--- a/gltests/test-stat.h
+++ b/gltests/test-stat.h
@@ -95,6 +95,7 @@ test_stat_func (int (*func) (char const *, struct stat *), 
bool print)
   ASSERT (unlink (BASE "link2") == 0);
   ASSERT (unlink (BASE "link3") == 0);
   ASSERT (unlink (BASE "link4") == 0);
+  free (cwd);
 
   return 0;
 }
diff --git a/gltests/wchar.in.h b/gltests/wchar.in.h
index e98ab61..755600f 100644
--- a/gltests/wchar.in.h
+++ b/gltests/wchar.in.h
@@ -31,7 +31,7 @@
 @PRAGMA_COLUMNS@
 
 #if (((defined __need_mbstate_t || defined __need_wint_t)               \
-      && !defined __MINGW32__)                                          \
+      && !defined __MINGW32__ && !defined __KLIBC__)                    \
      || (defined __hpux                                                 \
          && ((defined _INTTYPES_INCLUDED && !defined strtoimax)         \
              || defined _GL_JUST_INCLUDE_SYSTEM_WCHAR_H))               \
@@ -445,6 +445,11 @@ _GL_CXXALIAS_RPL (wcwidth, int, (wchar_t));
 #  if address@hidden@
 /* wcwidth exists but is not declared.  */
 _GL_FUNCDECL_SYS (wcwidth, int, (wchar_t) _GL_ATTRIBUTE_PURE);
+#  elif defined __KLIBC__
+/* On OS/2 kLIBC, wcwidth is a macro that expands to the name of a
+   static inline function.  The implementation of wcwidth in wcwidth.c
+   causes a "conflicting types" error. */
+#   undef wcwidth
 #  endif
 _GL_CXXALIAS_SYS (wcwidth, int, (wchar_t));
 # endif
diff --git a/lib/gl/m4/extern-inline.m4 b/lib/gl/m4/extern-inline.m4
index fe282a5..1e578f3 100644
--- a/lib/gl/m4/extern-inline.m4
+++ b/lib/gl/m4/extern-inline.m4
@@ -54,6 +54,7 @@ AC_DEFUN([gl_EXTERN_INLINE],
       ? defined __GNUC_STDC_INLINE__ && __GNUC_STDC_INLINE__ \
       : (199901L <= __STDC_VERSION__ \
          && !defined __HP_cc \
+         && !defined __PGI \
          && !(defined __SUNPRO_C && __STDC__))) \
      && !defined _GL_EXTERN_INLINE_STDHEADER_BUG)
 # define _GL_INLINE inline
diff --git a/lib/gl/m4/malloc.m4 b/lib/gl/m4/malloc.m4
index 717e8ad..c393690 100644
--- a/lib/gl/m4/malloc.m4
+++ b/lib/gl/m4/malloc.m4
@@ -1,4 +1,4 @@
-# malloc.m4 serial 14
+# malloc.m4 serial 15
 dnl Copyright (C) 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,
@@ -6,8 +6,8 @@ dnl with or without modifications, as long as this notice is 
preserved.
 
 m4_version_prereq([2.70], [] ,[
 
-# This is taken from the following Autoconf patch:
-# 
http://git.savannah.gnu.org/gitweb/?p=autoconf.git;a=commitdiff;h=7fbb553727ed7e0e689a17594b58559ecf3ea6e9
+# This is adapted with modifications from upstream Autoconf here:
+# 
http://git.savannah.gnu.org/cgit/autoconf.git/commit/?id=04be2b7a29d65d9a08e64e8e56e594c91749598c
 AC_DEFUN([_AC_FUNC_MALLOC_IF],
 [
   AC_REQUIRE([AC_HEADER_STDC])dnl
@@ -23,7 +23,10 @@ AC_DEFUN([_AC_FUNC_MALLOC_IF],
             char *malloc ();
             #endif
           ]],
-          [[return ! malloc (0);]])
+          [[char *p = malloc (0);
+            int result = !p;
+            free (p);
+            return result;]])
        ],
        [ac_cv_func_malloc_0_nonnull=yes],
        [ac_cv_func_malloc_0_nonnull=no],
diff --git a/lib/gl/m4/stdbool.m4 b/lib/gl/m4/stdbool.m4
index 625520f..a556153 100644
--- a/lib/gl/m4/stdbool.m4
+++ b/lib/gl/m4/stdbool.m4
@@ -5,7 +5,7 @@ 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.
 
-#serial 5
+#serial 6
 
 # Prepare for substituting <stdbool.h> if it is not supported.
 
@@ -43,21 +43,25 @@ AC_DEFUN([AC_CHECK_HEADER_STDBOOL],
         [AC_LANG_PROGRAM(
            [[
              #include <stdbool.h>
-             #ifndef bool
-              "error: bool is not defined"
-             #endif
-             #ifndef false
-              "error: false is not defined"
-             #endif
-             #if false
-              "error: false is not 0"
-             #endif
-             #ifndef true
-              "error: true is not defined"
-             #endif
-             #if true != 1
-              "error: true is not 1"
+
+             #if __cplusplus < 201103
+              #ifndef bool
+               "error: bool is not defined"
+              #endif
+              #ifndef false
+               "error: false is not defined"
+              #endif
+              #if false
+               "error: false is not 0"
+              #endif
+              #ifndef true
+               "error: true is not defined"
+              #endif
+              #if true != 1
+               "error: true is not 1"
+              #endif
              #endif
+
              #ifndef __bool_true_false_are_defined
               "error: __bool_true_false_are_defined is not defined"
              #endif
diff --git a/lib/gl/m4/stdint.m4 b/lib/gl/m4/stdint.m4
index 0f40ce8..0b4b906 100644
--- a/lib/gl/m4/stdint.m4
+++ b/lib/gl/m4/stdint.m4
@@ -1,4 +1,4 @@
-# stdint.m4 serial 43
+# stdint.m4 serial 44
 dnl Copyright (C) 2001-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,
@@ -70,6 +70,8 @@ AC_DEFUN_ONCE([gl_STDINT_H],
        AC_COMPILE_IFELSE([
          AC_LANG_PROGRAM([[
 #define _GL_JUST_INCLUDE_SYSTEM_STDINT_H 1 /* work if build isn't clean */
+#define __STDC_CONSTANT_MACROS 1
+#define __STDC_LIMIT_MACROS 1
 #include <stdint.h>
 /* Dragonfly defines WCHAR_MIN, WCHAR_MAX only in <wchar.h>.  */
 #if !(defined WCHAR_MIN && defined WCHAR_MAX)
@@ -218,6 +220,8 @@ struct s {
           AC_RUN_IFELSE([
             AC_LANG_PROGRAM([[
 #define _GL_JUST_INCLUDE_SYSTEM_STDINT_H 1 /* work if build isn't clean */
+#define __STDC_CONSTANT_MACROS 1
+#define __STDC_LIMIT_MACROS 1
 #include <stdint.h>
 ]
 gl_STDINT_INCLUDES
@@ -279,6 +283,29 @@ static const char *macro_values[] =
       ])
   fi
   if test "$gl_cv_header_working_stdint_h" = yes; then
+    dnl Now see whether the system <stdint.h> works without
+    dnl __STDC_CONSTANT_MACROS/__STDC_LIMIT_MACROS defined.
+    AC_CACHE_CHECK([whether stdint.h predates C++11],
+      [gl_cv_header_stdint_predates_cxx11_h],
+      [gl_cv_header_stdint_predates_cxx11_h=yes
+       AC_COMPILE_IFELSE([
+        AC_LANG_PROGRAM([[
+#define _GL_JUST_INCLUDE_SYSTEM_STDINT_H 1 /* work if build isn't clean */
+#include <stdint.h>
+]
+gl_STDINT_INCLUDES
+[
+intmax_t im = INTMAX_MAX;
+int32_t i32 = INT32_C (0x7fffffff);
+         ]])],
+         [gl_cv_header_stdint_predates_cxx11_h=no])])
+
+    if test "$gl_cv_header_stdint_predates_cxx11_h" = yes; then
+      AC_DEFINE([__STDC_CONSTANT_MACROS], [1],
+                [Define to 1 if the system <stdint.h> predates C++11.])
+      AC_DEFINE([__STDC_LIMIT_MACROS], [1],
+                [Define to 1 if the system <stdint.h> predates C++11.])
+    fi
     STDINT_H=
   else
     dnl Check for <sys/inttypes.h>, and for
diff --git a/lib/gl/override/lib/gettext.h.diff 
b/lib/gl/override/lib/gettext.h.diff
index 4a10e0d..4d20640 100644
--- a/lib/gl/override/lib/gettext.h.diff
+++ b/lib/gl/override/lib/gettext.h.diff
@@ -1,6 +1,6 @@
---- lib/gl/gettext.h.orig      2012-08-02 22:39:01.426409735 +0200
-+++ lib/gl/gettext.h   2012-08-02 22:39:11.198409976 +0200
-@@ -107,182 +107,4 @@
+--- lib/gl/gettext.h.orig
++++ lib/gl/gettext.h
+@@ -107,186 +107,4 @@
     initializer for static 'char[]' or 'const char[]' variables.  */
  #define gettext_noop(String) String
  
@@ -122,15 +122,17 @@
 -  if (msg_ctxt_id != NULL)
 -#endif
 -    {
+-      int found_translation;
 -      memcpy (msg_ctxt_id, msgctxt, msgctxt_len - 1);
 -      msg_ctxt_id[msgctxt_len - 1] = '\004';
 -      memcpy (msg_ctxt_id + msgctxt_len, msgid, msgid_len);
 -      translation = dcgettext (domain, msg_ctxt_id, category);
+-      found_translation = (translation != msg_ctxt_id);
 -#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
 -      if (msg_ctxt_id != buf)
 -        free (msg_ctxt_id);
 -#endif
--      if (translation != msg_ctxt_id)
+-      if (found_translation)
 -        return translation;
 -    }
 -  return msgid;
@@ -168,15 +170,17 @@
 -  if (msg_ctxt_id != NULL)
 -#endif
 -    {
+-      int found_translation;
 -      memcpy (msg_ctxt_id, msgctxt, msgctxt_len - 1);
 -      msg_ctxt_id[msgctxt_len - 1] = '\004';
 -      memcpy (msg_ctxt_id + msgctxt_len, msgid, msgid_len);
 -      translation = dcngettext (domain, msg_ctxt_id, msgid_plural, n, 
category);
+-      found_translation = !(translation == msg_ctxt_id || translation == 
msgid_plural);
 -#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
 -      if (msg_ctxt_id != buf)
 -        free (msg_ctxt_id);
 -#endif
--      if (!(translation == msg_ctxt_id || translation == msgid_plural))
+-      if (found_translation)
 -        return translation;
 -    }
 -  return (n == 1 ? msgid : msgid_plural);
diff --git a/lib/gl/stddef.in.h b/lib/gl/stddef.in.h
index edbf852..a400474 100644
--- a/lib/gl/stddef.in.h
+++ b/lib/gl/stddef.in.h
@@ -81,8 +81,10 @@
 # define wchar_t int
 #endif
 
-/* Some platforms lack max_align_t.  */
-#if address@hidden@
+/* Some platforms lack max_align_t.  The check for _GCC_MAX_ALIGN_T is
+   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)
 /* 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
diff --git a/lib/gl/stdint.in.h b/lib/gl/stdint.in.h
index deb5591..7ac0b1b 100644
--- a/lib/gl/stdint.in.h
+++ b/lib/gl/stdint.in.h
@@ -118,15 +118,10 @@
    picky compilers.  */
 
 #define _STDINT_MIN(signed, bits, zero) \
-  ((signed) ? (- ((zero) + 1) << ((bits) ? (bits) - 1 : 0)) : (zero))
+  ((signed) ? ~ _STDINT_MAX (signed, bits, zero) : (zero))
 
 #define _STDINT_MAX(signed, bits, zero) \
-  ((signed) \
-   ? ~ _STDINT_MIN (signed, bits, zero) \
-   : /* The expression for the unsigned case.  The subtraction of (signed) \
-        is a nop in the unsigned case and avoids "signed integer overflow" \
-        warnings in the signed case.  */ \
-     ((((zero) + 1) << ((bits) ? (bits) - 1 - (signed) : 0)) - 1) * 2 + 1)
+  (((((zero) + 1) << ((bits) ? (bits) - 1 - (signed) : 0)) - 1) * 2 + 1)
 
 #if !GNULIB_defined_stdint_types
 
@@ -288,12 +283,17 @@ typedef gl_uint_fast32_t gl_uint_fast16_t;
 
 /* 7.18.1.4. Integer types capable of holding object pointers */
 
+/* kLIBC's stdint.h defines _INTPTR_T_DECLARED and needs its own
+   definitions of intptr_t and uintptr_t (which use int and unsigned)
+   to avoid clashes with declarations of system functions like sbrk.  */
+#ifndef _INTPTR_T_DECLARED
 #undef intptr_t
 #undef uintptr_t
 typedef long int gl_intptr_t;
 typedef unsigned long int gl_uintptr_t;
 #define intptr_t gl_intptr_t
 #define uintptr_t gl_uintptr_t
+#endif
 
 /* 7.18.1.5. Greatest-width integer types */
 
diff --git a/lib/gltests/Makefile.am b/lib/gltests/Makefile.am
index 6a04b70..89d744b 100644
--- a/lib/gltests/Makefile.am
+++ b/lib/gltests/Makefile.am
@@ -973,6 +973,11 @@ EXTRA_DIST += verify.h
 TESTS_ENVIRONMENT += MAKE='$(MAKE)'
 TESTS += test-verify test-verify.sh
 check_PROGRAMS += test-verify
+
+# This test expects compilation of test-verify.c to fail, and
+# each time it fails, the makefile rule does not perform the usual
+#  "mv -f $name.Tpo $name.po, so tell make clean to remove that file.
+MOSTLYCLEANFILES += .deps/test-verify.Tpo
 EXTRA_DIST += test-verify.c test-verify.sh
 
 ## end   gnulib module verify-tests
diff --git a/lib/gltests/init.sh b/lib/gltests/init.sh
index ee08022..97e4e4b 100644
--- a/lib/gltests/init.sh
+++ b/lib/gltests/init.sh
@@ -308,13 +308,19 @@ if diff_out_=`exec 2>/dev/null; diff -u "$0" "$0" < 
/dev/null` \
       fi
     }
   fi
-elif diff_out_=`exec 2>/dev/null; diff -c "$0" "$0" < /dev/null`; then
+elif
+  for diff_opt_ in -U3 -c '' no; do
+    test "$diff_opt_" = no && break
+    diff_out_=`exec 2>/dev/null; diff $diff_opt_ "$0" "$0" </dev/null` && break
+  done
+  test "$diff_opt_" != no
+then
   if test -z "$diff_out_"; then
-    compare_ () { diff -c "$@"; }
+    compare_ () { diff $diff_opt_ "$@"; }
   else
     compare_ ()
     {
-      if diff -c "$@" > diff.out; then
+      if diff $diff_opt_ "$@" > diff.out; then
         # No differences were found, but AIX and HP-UX 'diff' produce output
         # "No differences encountered" or "There are no differences between the
         # files.". Hide this output.
@@ -466,7 +472,6 @@ setup_ ()
   fi
 
   initial_cwd_=$PWD
-  fail=0
 
   pfx_=`testdir_prefix_`
   test_dir_=`mktempd_ "$initial_cwd_" "$pfx_-$ME_.XXXX"` \
@@ -550,8 +555,9 @@ mktempd_ ()
   # Disallow any trailing slash on specified destdir:
   # it would subvert the post-mktemp "case"-based destdir test.
   case $destdir_ in
-  /) ;;
+  / | //) destdir_slash_=$destdir;;
   */) fail_ "invalid destination dir: remove trailing slash(es)";;
+  *) destdir_slash_=$destdir_/;;
   esac
 
   case $template_ in
@@ -561,20 +567,17 @@ mktempd_ ()
   esac
 
   # First, try to use mktemp.
-  d=`unset TMPDIR; { mktemp -d -t -p "$destdir_" "$template_"; } 2>/dev/null` \
-    || fail=1
+  d=`unset TMPDIR; { mktemp -d -t -p "$destdir_" "$template_"; } 2>/dev/null` 
&&
 
   # The resulting name must be in the specified directory.
-  case $d in "$destdir_"*);; *) fail=1;; esac
+  case $d in "$destdir_slash_"*) :;; *) false;; esac &&
 
   # It must have created the directory.
-  test -d "$d" || fail=1
+  test -d "$d" &&
 
   # It must have 0700 permissions.  Handle sticky "S" bits.
-  perms=`ls -dgo "$d" 2>/dev/null|tr S -` || fail=1
-  case $perms in drwx------*) ;; *) fail=1;; esac
-
-  test $fail = 0 && {
+  perms=`ls -dgo "$d" 2>/dev/null` &&
+  case $perms in drwx--[-S]---*) :;; *) false;; esac && {
     echo "$d"
     return
   }
@@ -593,7 +596,7 @@ mktempd_ ()
   i_=1
   while :; do
     X_=`rand_bytes_ $nx_`
-    candidate_dir_="$destdir_/$base_template_$X_"
+    candidate_dir_="$destdir_slash_$base_template_$X_"
     err_=`mkdir -m 0700 "$candidate_dir_" 2>&1` \
       && { echo "$candidate_dir_"; return; }
     test $MAX_TRIES_ -le $i_ && break;
diff --git a/lib/gltests/intprops.h b/lib/gltests/intprops.h
index e1a6107..e1fce5c 100644
--- a/lib/gltests/intprops.h
+++ b/lib/gltests/intprops.h
@@ -1,10 +1,10 @@
 /* intprops.h -- properties of integer types
 
-   Copyright (C) 2001-2005, 2009-2016 Free Software Foundation, Inc.
+   Copyright (C) 2001-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
+   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,
@@ -21,6 +21,7 @@
 #define _GL_INTPROPS_H
 
 #include <limits.h>
+#include <verify.h>
 
 /* Return a value with the common real type of E and V and the value of V.  */
 #define _GL_INT_CONVERT(e, v) (0 * (e) + (v))
@@ -36,17 +37,6 @@
    an integer.  */
 #define TYPE_IS_INTEGER(t) ((t) 1.5 == 1)
 
-/* True if negative values of the signed integer type T use two's
-   complement, ones' complement, or signed magnitude representation,
-   respectively.  Much GNU code assumes two's complement, but some
-   people like to be portable to all possible C hosts.  */
-#define TYPE_TWOS_COMPLEMENT(t) ((t) ~ (t) 0 == (t) -1)
-#define TYPE_ONES_COMPLEMENT(t) ((t) ~ (t) 0 == 0)
-#define TYPE_SIGNED_MAGNITUDE(t) ((t) ~ (t) 0 < (t) -1)
-
-/* True if the signed integer expression E uses two's complement.  */
-#define _GL_INT_TWOS_COMPLEMENT(e) (~ _GL_INT_CONVERT (e, 0) == -1)
-
 /* True if the real type T is signed.  */
 #define TYPE_SIGNED(t) (! ((t) 0 < (t) -1))
 
@@ -55,18 +45,10 @@
 #define EXPR_SIGNED(e) (_GL_INT_NEGATE_CONVERT (e, 1) < 0)
 
 
-/* Minimum and maximum values for integer types and expressions.  These
-   macros have undefined behavior if T is signed and has padding bits.
-   If this is a problem for you, please let us know how to fix it for
-   your host.  */
+/* Minimum and maximum values for integer types and expressions.  */
 
 /* The maximum and minimum values for the integer type T.  */
-#define TYPE_MINIMUM(t)                                                 \
-  ((t) (! TYPE_SIGNED (t)                                               \
-        ? (t) 0                                                         \
-        : TYPE_SIGNED_MAGNITUDE (t)                                     \
-        ? ~ (t) 0                                                       \
-        : ~ TYPE_MAXIMUM (t)))
+#define TYPE_MINIMUM(t) ((t) ~ TYPE_MAXIMUM (t))
 #define TYPE_MAXIMUM(t)                                                 \
   ((t) (! TYPE_SIGNED (t)                                               \
         ? (t) -1                                                        \
@@ -76,7 +58,7 @@
    after integer promotion.  E should not have side effects.  */
 #define _GL_INT_MINIMUM(e)                                              \
   (EXPR_SIGNED (e)                                                      \
-   ? - _GL_INT_TWOS_COMPLEMENT (e) - _GL_SIGNED_INT_MAXIMUM (e)         \
+   ? ~ _GL_SIGNED_INT_MAXIMUM (e)                                       \
    : _GL_INT_CONVERT (e, 0))
 #define _GL_INT_MAXIMUM(e)                                              \
   (EXPR_SIGNED (e)                                                      \
@@ -85,8 +67,25 @@
 #define _GL_SIGNED_INT_MAXIMUM(e)                                       \
   (((_GL_INT_CONVERT (e, 1) << (sizeof ((e) + 0) * CHAR_BIT - 2)) - 1) * 2 + 1)
 
+/* This include file assumes that signed types are two's complement without
+   padding bits; the above macros have undefined behavior otherwise.
+   If this is a problem for you, please let us know how to fix it for your 
host.
+   As a sanity check, test the assumption for some signed types that
+   <limits.h> bounds.  */
+verify (TYPE_MINIMUM (signed char) == SCHAR_MIN);
+verify (TYPE_MAXIMUM (signed char) == SCHAR_MAX);
+verify (TYPE_MINIMUM (short int) == SHRT_MIN);
+verify (TYPE_MAXIMUM (short int) == SHRT_MAX);
+verify (TYPE_MINIMUM (int) == INT_MIN);
+verify (TYPE_MAXIMUM (int) == INT_MAX);
+verify (TYPE_MINIMUM (long int) == LONG_MIN);
+verify (TYPE_MAXIMUM (long int) == LONG_MAX);
+#ifdef LLONG_MAX
+verify (TYPE_MINIMUM (long long int) == LLONG_MIN);
+verify (TYPE_MAXIMUM (long long int) == LLONG_MAX);
+#endif
 
-/* Return 1 if the __typeof__ keyword works.  This could be done by
+/* Does the __typeof__ keyword work?  This could be done by
    'configure', but for now it's easier to do it by hand.  */
 #if (2 <= __GNUC__ || defined __IBM__TYPEOF__ \
      || (0x5110 <= __SUNPRO_C && !__STDC__))
@@ -223,24 +222,35 @@
    ? (a) < (min) >> (b)                                 \
    : (max) >> (b) < (a))
 
+/* True if __builtin_add_overflow (A, B, P) works when P is null.  */
+#define _GL_HAS_BUILTIN_OVERFLOW_WITH_NULL (7 <= __GNUC__)
 
 /* The _GL*_OVERFLOW macros have the same restrictions as the
    *_RANGE_OVERFLOW macros, except that they do not assume that operands
    (e.g., A and B) have the same type as MIN and MAX.  Instead, they assume
    that the result (e.g., A + B) has that type.  */
-#define _GL_ADD_OVERFLOW(a, b, min, max)                                \
-  ((min) < 0 ? INT_ADD_RANGE_OVERFLOW (a, b, min, max)                  \
-   : (a) < 0 ? (b) <= (a) + (b)                                         \
-   : (b) < 0 ? (a) <= (a) + (b)                                         \
-   : (a) + (b) < (b))
-#define _GL_SUBTRACT_OVERFLOW(a, b, min, max)                           \
-  ((min) < 0 ? INT_SUBTRACT_RANGE_OVERFLOW (a, b, min, max)             \
-   : (a) < 0 ? 1                                                        \
-   : (b) < 0 ? (a) - (b) <= (a)                                         \
-   : (a) < (b))
-#define _GL_MULTIPLY_OVERFLOW(a, b, min, max)                           \
-  (((min) == 0 && (((a) < 0 && 0 < (b)) || ((b) < 0 && 0 < (a))))       \
-   || INT_MULTIPLY_RANGE_OVERFLOW (a, b, min, max))
+#if _GL_HAS_BUILTIN_OVERFLOW_WITH_NULL
+# define _GL_ADD_OVERFLOW(a, b, min, max)
+   __builtin_add_overflow (a, b, (__typeof__ ((a) + (b)) *) 0)
+# define _GL_SUBTRACT_OVERFLOW(a, b, min, max)
+   __builtin_sub_overflow (a, b, (__typeof__ ((a) - (b)) *) 0)
+# define _GL_MULTIPLY_OVERFLOW(a, b, min, max)
+   __builtin_mul_overflow (a, b, (__typeof__ ((a) * (b)) *) 0)
+#else
+# define _GL_ADD_OVERFLOW(a, b, min, max)                                \
+   ((min) < 0 ? INT_ADD_RANGE_OVERFLOW (a, b, min, max)                  \
+    : (a) < 0 ? (b) <= (a) + (b)                                         \
+    : (b) < 0 ? (a) <= (a) + (b)                                         \
+    : (a) + (b) < (b))
+# define _GL_SUBTRACT_OVERFLOW(a, b, min, max)                           \
+   ((min) < 0 ? INT_SUBTRACT_RANGE_OVERFLOW (a, b, min, max)             \
+    : (a) < 0 ? 1                                                        \
+    : (b) < 0 ? (a) - (b) <= (a)                                         \
+    : (a) < (b))
+# define _GL_MULTIPLY_OVERFLOW(a, b, min, max)                           \
+   (((min) == 0 && (((a) < 0 && 0 < (b)) || ((b) < 0 && 0 < (a))))       \
+    || INT_MULTIPLY_RANGE_OVERFLOW (a, b, min, max))
+#endif
 #define _GL_DIVIDE_OVERFLOW(a, b, min, max)                             \
   ((min) < 0 ? (b) == _GL_INT_NEGATE_CONVERT (min, 1) && (a) < - (max)  \
    : (a) < 0 ? (b) <= (a) + (b) - 1                                     \
@@ -305,8 +315,12 @@
   _GL_BINARY_OP_OVERFLOW (a, b, _GL_ADD_OVERFLOW)
 #define INT_SUBTRACT_OVERFLOW(a, b) \
   _GL_BINARY_OP_OVERFLOW (a, b, _GL_SUBTRACT_OVERFLOW)
-#define INT_NEGATE_OVERFLOW(a) \
-  INT_NEGATE_RANGE_OVERFLOW (a, _GL_INT_MINIMUM (a), _GL_INT_MAXIMUM (a))
+#if _GL_HAS_BUILTIN_OVERFLOW_WITH_NULL
+# define INT_NEGATE_OVERFLOW(a) INT_SUBTRACT_OVERFLOW (0, a)
+#else
+# define INT_NEGATE_OVERFLOW(a) \
+   INT_NEGATE_RANGE_OVERFLOW (a, _GL_INT_MINIMUM (a), _GL_INT_MAXIMUM (a))
+#endif
 #define INT_MULTIPLY_OVERFLOW(a, b) \
   _GL_BINARY_OP_OVERFLOW (a, b, _GL_MULTIPLY_OVERFLOW)
 #define INT_DIVIDE_OVERFLOW(a, b) \
@@ -326,7 +340,7 @@
                       _GL_INT_MINIMUM (0 * (b) + (a)),          \
                       _GL_INT_MAXIMUM (0 * (b) + (a)))
 
-/* Compute A + B, A - B, A * B, respectively, storing the result into *R.
+/* Store the low-order bits of A + B, A - B, A * B, respectively, into *R.
    Return 1 if the result overflows.  See above for restrictions.  */
 #define INT_ADD_WRAPV(a, b, r) \
   _GL_INT_OP_WRAPV (a, b, r, +, __builtin_add_overflow, INT_ADD_OVERFLOW)
@@ -351,9 +365,10 @@
 # define _GL__GENERIC_BOGUS 0
 #endif
 
-/* Store A <op> B into *R, where OP specifies the operation.
-   BUILTIN is the builtin operation, and OVERFLOW the overflow predicate.
-   See above for restrictions.  */
+/* Store the low-order bits of A <op> B into *R, where OP specifies
+   the operation.  BUILTIN is the builtin operation, and OVERFLOW the
+   overflow predicate.  Return 1 if the result overflows.  See above
+   for restrictions.  */
 #if 5 <= __GNUC__ || __has_builtin (__builtin_add_overflow)
 # define _GL_INT_OP_WRAPV(a, b, r, op, builtin, overflow) builtin (a, b, r)
 #elif 201112 <= __STDC_VERSION__ && !_GL__GENERIC_BOGUS
@@ -404,7 +419,8 @@
 /* Store the low-order bits of A <op> B into *R, where the operation
    is given by OP.  Use the unsigned type UT for calculation to avoid
    overflow problems.  *R's type is T, with extremal values TMIN and
-   TMAX.  T must be a signed integer type.  */
+   TMAX.  T must be a signed integer type.  Return 1 if the result
+   overflows.  */
 #define _GL_INT_OP_CALC(a, b, r, op, overflow, ut, t, tmin, tmax) \
   (sizeof ((a) op (b)) < sizeof (t) \
    ? _GL_INT_OP_CALC1 ((t) (a), (t) (b), r, op, overflow, ut, t, tmin, tmax) \
diff --git a/lib/gltests/setlocale.c b/lib/gltests/setlocale.c
index 8b3ebb3..7d366ed 100644
--- a/lib/gltests/setlocale.c
+++ b/lib/gltests/setlocale.c
@@ -381,6 +381,7 @@ static const struct table_entry language_table[] =
     { "sq", "Albanian" },
     { "sr", "Serbian (Latin)" },
     { "address@hidden", "SRB" }, /* Serbian (Cyrillic) */
+    { "sv", "Swedish" },
     { "sw", "Swahili" },
     { "syr", "Syriac" },
     { "ta", "Tamil" },
diff --git a/lib/gltests/stdalign.in.h b/lib/gltests/stdalign.in.h
index 9abb9aa..12f8a15 100644
--- a/lib/gltests/stdalign.in.h
+++ b/lib/gltests/stdalign.in.h
@@ -103,15 +103,15 @@
 # elif ((defined __APPLE__ && defined __MACH__                  \
          ? 4 < __GNUC__ + (1 <= __GNUC_MINOR__)                 \
          : __GNUC__)                                            \
-        || __HP_cc || __HP_aCC || __IBMC__ || __IBMCPP__        \
-        || __ICC || 0x590 <= __SUNPRO_C)
+        || 061200 <= __HP_cc || 061200 <= __HP_aCC                \
+        || __ICC || 0x590 <= __SUNPRO_C || 0x0600 <= __xlC__)
 #  define _Alignas(a) __attribute__ ((__aligned__ (a)))
 # elif 1300 <= _MSC_VER
 #  define _Alignas(a) __declspec (align (a))
 # endif
 #endif
 #if ((defined _Alignas && ! (defined __cplusplus && 201103 <= __cplusplus)) \
-     || (defined __STDC_VERSION && 201112 <= __STDC_VERSION__))
+     || (defined __STDC_VERSION__ && 201112 <= __STDC_VERSION__))
 # define alignas _Alignas
 #endif
 #if defined alignas || (defined __cplusplus && 201103 <= __cplusplus)
diff --git a/lib/gltests/test-intprops.c b/lib/gltests/test-intprops.c
index 174ddec..0a8ddcd 100644
--- a/lib/gltests/test-intprops.c
+++ b/lib/gltests/test-intprops.c
@@ -22,12 +22,9 @@
 # pragma GCC diagnostic ignored "-Woverlength-strings"
 # pragma GCC diagnostic ignored "-Wtype-limits"
 
-/* Work around a bug in GCC 5.3.1 and earlier; see:
-   https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68971
-   Hope it will be fixed by the time GCC 6 comes out.  */
-# if __GNUC__ < 6
-#  pragma GCC diagnostic ignored "-Woverflow"
-# endif
+/* Work around a bug in GCC 6.1 and earlier; see:
+   https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68971  */
+# pragma GCC diagnostic ignored "-Woverflow"
 
 #endif
 
@@ -94,12 +91,8 @@ main (void)
   ASSERT (TYPE_SIGNED (double));
   ASSERT (TYPE_SIGNED (long double));
 
-  /* Integer representation.  */
-  VERIFY (INT_MIN + INT_MAX < 0
-          ? (TYPE_TWOS_COMPLEMENT (int)
-             && ! TYPE_ONES_COMPLEMENT (int) && ! TYPE_SIGNED_MAGNITUDE (int))
-          : (! TYPE_TWOS_COMPLEMENT (int)
-             && (TYPE_ONES_COMPLEMENT (int) || TYPE_SIGNED_MAGNITUDE (int))));
+  /* Integer representation.  Check that it is two's complement.  */
+  VERIFY (INT_MIN + INT_MAX < 0);
 
   /* TYPE_MINIMUM, TYPE_MAXIMUM.  */
   VERIFY (TYPE_MINIMUM (char) == CHAR_MIN);
@@ -156,8 +149,7 @@ main (void)
     {                                                                     \
       t result;                                                           \
       ASSERT (INT_##opname##_WRAPV (a, b, &result) == (v));               \
-      ASSERT (result == ((v) ? (vres) : ((a) op (b)))                     \
-              || ((v) && !TYPE_TWOS_COMPLEMENT (t)));                     \
+      ASSERT (result == ((v) ? (vres) : ((a) op (b))));                   \
     }
   #define CHECK_UNOP(op, opname, a, t, v)                                 \
     VERIFY (INT_##opname##_RANGE_OVERFLOW (a, TYPE_MINIMUM (t),           \
@@ -183,7 +175,7 @@ main (void)
   CHECK_BINOP (-, SUBTRACT, UINT_MAX, 1u, unsigned int, false, UINT_MAX - 1u);
   CHECK_BINOP (-, SUBTRACT, 0u, 1u, unsigned int, true, 0u - 1u);
 
-  CHECK_UNOP (-, NEGATE, INT_MIN, int, TYPE_TWOS_COMPLEMENT (int));
+  CHECK_UNOP (-, NEGATE, INT_MIN, int, true);
   CHECK_UNOP (-, NEGATE, 0, int, false);
   CHECK_UNOP (-, NEGATE, INT_MAX, int, false);
   CHECK_UNOP (-, NEGATE, 0u, unsigned int, false);
@@ -230,8 +222,7 @@ main (void)
     {                                                                     \
       t result;                                                           \
       ASSERT (INT_ADD_WRAPV (a, b, &result) == (v));                      \
-      ASSERT (result == ((v) ? (vres) : ((a) + (b)))                      \
-              || ((v) && !TYPE_TWOS_COMPLEMENT (t)));                     \
+      ASSERT (result == ((v) ? (vres) : ((a) + (b))));                    \
     }
   CHECK_SSUM (-1, LONG_MIN, long int, true, LONG_MAX);
   CHECK_SUM (-1, UINT_MAX, unsigned int, false, DONTCARE);
@@ -259,8 +250,7 @@ main (void)
     {                                                                     \
       t result;                                                           \
       ASSERT (INT_SUBTRACT_WRAPV (a, b, &result) == (v));                 \
-      ASSERT (result == ((v) ? (vres) : ((a) - (b)))                      \
-              || ((v) && !TYPE_TWOS_COMPLEMENT (t)));                     \
+      ASSERT (result == ((v) ? (vres) : ((a) - (b))));                    \
     }
   CHECK_DIFFERENCE (INT_MAX, 1u, unsigned int, UINT_MAX < INT_MAX - 1,
                     INT_MAX - 1u);
@@ -292,8 +282,7 @@ main (void)
     {                                                                     \
       t result;                                                           \
       ASSERT (INT_MULTIPLY_WRAPV (a, b, &result) == (v));                 \
-      ASSERT (result == ((v) ? (vres) : ((a) * (b)))                      \
-              || ((v) && !TYPE_TWOS_COMPLEMENT (t)));                     \
+      ASSERT (result == ((v) ? (vres) : ((a) * (b))));                    \
     }
   CHECK_PRODUCT (-1, 1u, unsigned int, true, -1 * 1u);
   CHECK_SPRODUCT (-1, INT_MIN, int, INT_NEGATE_OVERFLOW (INT_MIN), INT_MIN);
@@ -351,8 +340,7 @@ main (void)
 
   #define CHECK_QUOTIENT(a, b, v) VERIFY (INT_DIVIDE_OVERFLOW (a, b) == (v))
 
-  CHECK_QUOTIENT (INT_MIN, -1L,
-                  TYPE_TWOS_COMPLEMENT (long int) && INT_MIN == LONG_MIN);
+  CHECK_QUOTIENT (INT_MIN, -1L, INT_MIN == LONG_MIN);
   CHECK_QUOTIENT (INT_MIN, UINT_MAX, false);
   CHECK_QUOTIENT (INTMAX_MIN, UINTMAX_MAX, false);
   CHECK_QUOTIENT (INTMAX_MIN, UINT_MAX, false);
@@ -365,8 +353,7 @@ main (void)
 
   #define CHECK_REMAINDER(a, b, v) VERIFY (INT_REMAINDER_OVERFLOW (a, b) == 
(v))
 
-  CHECK_REMAINDER (INT_MIN, -1L,
-                   TYPE_TWOS_COMPLEMENT (long int) && INT_MIN == LONG_MIN);
+  CHECK_REMAINDER (INT_MIN, -1L, INT_MIN == LONG_MIN);
   CHECK_REMAINDER (-1, UINT_MAX, true);
   CHECK_REMAINDER ((intmax_t) -1, UINTMAX_MAX, true);
   CHECK_REMAINDER (INTMAX_MIN, UINT_MAX,
diff --git a/lib/gltests/test-localename.c b/lib/gltests/test-localename.c
index 040c025..be8fcaf 100644
--- a/lib/gltests/test-localename.c
+++ b/lib/gltests/test-localename.c
@@ -183,6 +183,8 @@ test_locale_name (void)
         ASSERT (strcmp (name, "fr_FR.UTF-8") == 0);
         name = gl_locale_name (LC_MESSAGES, "LC_MESSAGES");
         ASSERT (strcmp (name, "fr_FR.UTF-8") == 0);
+        uselocale (LC_GLOBAL_LOCALE);
+        freelocale (locale);
       }
   }
 
@@ -194,11 +196,13 @@ test_locale_name (void)
     for (i = 0; i < SIZEOF (categories); i++)
       {
         int category_mask = categories[i].mask;
-        locale_t locale = newlocale (LC_ALL_MASK, "fr_FR.UTF-8", NULL);
-        if (locale != NULL)
+        locale_t loc = newlocale (LC_ALL_MASK, "fr_FR.UTF-8", NULL);
+        if (loc != NULL)
           {
-            locale = newlocale (category_mask, "de_DE.UTF-8", locale);
-            if (locale != NULL)
+            locale_t locale = newlocale (category_mask, "de_DE.UTF-8", loc);
+            if (locale == NULL)
+              freelocale (loc);
+            else
               {
                 unsigned int j;
 
@@ -212,6 +216,8 @@ test_locale_name (void)
                     else
                       ASSERT (strcmp (name_j, "fr_FR.UTF-8") == 0);
                   }
+                uselocale (LC_GLOBAL_LOCALE);
+                freelocale (locale);
               }
           }
       }
@@ -245,6 +251,8 @@ test_locale_name_thread (void)
         ASSERT (strcmp (name, "fr_FR.UTF-8") == 0);
         name = gl_locale_name_thread (LC_MESSAGES, "LC_MESSAGES");
         ASSERT (strcmp (name, "fr_FR.UTF-8") == 0);
+        uselocale (LC_GLOBAL_LOCALE);
+        freelocale (locale);
       }
   }
 
@@ -256,11 +264,13 @@ test_locale_name_thread (void)
     for (i = 0; i < SIZEOF (categories); i++)
       {
         int category_mask = categories[i].mask;
-        locale_t locale = newlocale (LC_ALL_MASK, "fr_FR.UTF-8", NULL);
-        if (locale != NULL)
+        locale_t loc = newlocale (LC_ALL_MASK, "fr_FR.UTF-8", NULL);
+        if (loc != NULL)
           {
-            locale = newlocale (category_mask, "de_DE.UTF-8", locale);
-            if (locale != NULL)
+            locale_t locale = newlocale (category_mask, "de_DE.UTF-8", loc);
+            if (locale == NULL)
+              freelocale (loc);
+            else
               {
                 unsigned int j;
 
@@ -275,6 +285,8 @@ test_locale_name_thread (void)
                     else
                       ASSERT (strcmp (name_j, "fr_FR.UTF-8") == 0);
                   }
+                uselocale (LC_GLOBAL_LOCALE);
+                freelocale (locale);
               }
           }
       }
@@ -444,6 +456,7 @@ test_locale_name_thread (void)
                 ASSERT (strcmp (unsaved_names[j][i], name) == 0);
               }
             uselocale (LC_GLOBAL_LOCALE);
+            freelocale (locale);
           }
       }
     /* Verify the unsaved_names are still valid.  */
@@ -453,7 +466,10 @@ test_locale_name_thread (void)
           unsigned int i;
 
           for (i = 0; i < SIZEOF (categories); i++)
-            ASSERT (strcmp (unsaved_names[j][i], saved_names[j][i]) == 0);
+            {
+              ASSERT (strcmp (unsaved_names[j][i], saved_names[j][i]) == 0);
+              free (saved_names[j][i]);
+            }
         }
   }
 #else
@@ -590,6 +606,8 @@ test_locale_name_posix (void)
         uselocale (locale);
         name = gl_locale_name_posix (LC_MESSAGES, "LC_MESSAGES");
         ASSERT (strcmp (name, "C") == 0);
+        uselocale (LC_GLOBAL_LOCALE);
+        freelocale (locale);
       }
   }
 #endif
@@ -702,6 +720,8 @@ test_locale_name_environ (void)
         uselocale (locale);
         name = gl_locale_name_environ (LC_MESSAGES, "LC_MESSAGES");
         ASSERT (strcmp (name, "C") == 0);
+        uselocale (LC_GLOBAL_LOCALE);
+        freelocale (locale);
       }
   }
 #endif
@@ -729,6 +749,8 @@ test_locale_name_default (void)
       {
         uselocale (locale);
         ASSERT (strcmp (gl_locale_name_default (), name) == 0);
+        uselocale (LC_GLOBAL_LOCALE);
+        freelocale (locale);
       }
   }
 #endif
diff --git a/lib/gltests/test-setlocale1.c b/lib/gltests/test-setlocale1.c
index 3bb9c3e..143c0d8 100644
--- a/lib/gltests/test-setlocale1.c
+++ b/lib/gltests/test-setlocale1.c
@@ -54,6 +54,8 @@ main (int argc, char *argv[])
 
   /* Test that the two results are the same.  */
   ASSERT (strcmp (name1, name2) == 0);
+  free (name1);
+  free (name2);
 
   return 0;
 }
diff --git a/lib/gltests/verify.h b/lib/gltests/verify.h
index 2f43837..5c8381d 100644
--- a/lib/gltests/verify.h
+++ b/lib/gltests/verify.h
@@ -263,7 +263,7 @@ template <int w>
 # define assume(R) ((R) ? (void) 0 : __builtin_unreachable ())
 #elif 1200 <= _MSC_VER
 # define assume(R) __assume (R)
-#elif (defined lint \
+#elif ((defined GCC_LINT || defined lint) \
        && (__has_builtin (__builtin_trap) \
            || 3 < __GNUC__ + (3 < __GNUC_MINOR__ + (4 <= 
__GNUC_PATCHLEVEL__))))
   /* Doing it this way helps various packages when configured with
diff --git a/lib/gltests/wchar.in.h b/lib/gltests/wchar.in.h
index e98ab61..755600f 100644
--- a/lib/gltests/wchar.in.h
+++ b/lib/gltests/wchar.in.h
@@ -31,7 +31,7 @@
 @PRAGMA_COLUMNS@
 
 #if (((defined __need_mbstate_t || defined __need_wint_t)               \
-      && !defined __MINGW32__)                                          \
+      && !defined __MINGW32__ && !defined __KLIBC__)                    \
      || (defined __hpux                                                 \
          && ((defined _INTTYPES_INCLUDED && !defined strtoimax)         \
              || defined _GL_JUST_INCLUDE_SYSTEM_WCHAR_H))               \
@@ -445,6 +445,11 @@ _GL_CXXALIAS_RPL (wcwidth, int, (wchar_t));
 #  if address@hidden@
 /* wcwidth exists but is not declared.  */
 _GL_FUNCDECL_SYS (wcwidth, int, (wchar_t) _GL_ATTRIBUTE_PURE);
+#  elif defined __KLIBC__
+/* On OS/2 kLIBC, wcwidth is a macro that expands to the name of a
+   static inline function.  The implementation of wcwidth in wcwidth.c
+   causes a "conflicting types" error. */
+#   undef wcwidth
 #  endif
 _GL_CXXALIAS_SYS (wcwidth, int, (wchar_t));
 # endif
diff --git a/maint.mk b/maint.mk
index 9470328..aa23364 100644
--- a/maint.mk
+++ b/maint.mk
@@ -651,8 +651,7 @@ sc_prohibit_strings_without_use:
 # Get the list of symbol names with this:
 # perl -lne '/^# *define ([A-Z]\w+)\(/ and print $1' lib/intprops.h|fmt
 _intprops_names =                                                      \
-  TYPE_IS_INTEGER TYPE_TWOS_COMPLEMENT TYPE_ONES_COMPLEMENT            \
-  TYPE_SIGNED_MAGNITUDE TYPE_SIGNED TYPE_MINIMUM TYPE_MAXIMUM          \
+  TYPE_IS_INTEGER TYPE_SIGNED TYPE_MINIMUM TYPE_MAXIMUM                        
\
   INT_BITS_STRLEN_BOUND INT_STRLEN_BOUND INT_BUFSIZE_BOUND             \
   INT_ADD_RANGE_OVERFLOW INT_SUBTRACT_RANGE_OVERFLOW                   \
   INT_NEGATE_RANGE_OVERFLOW INT_MULTIPLY_RANGE_OVERFLOW                        
\
diff --git a/tests/tst_toascii64oob.c b/tests/tst_toascii64oob.c
index 318168f..31b940e 100644
--- a/tests/tst_toascii64oob.c
+++ b/tests/tst_toascii64oob.c
@@ -37,7 +37,16 @@
 
 /* This test requires you to build with CFLAGS="-fsanitize=address"
    and disable valgrind since asan and valgrind conflict.  Thus
-   normally a bit uneffective, but may be useful to have around. */
+   normally a bit uneffective, but may be useful to have around.
+
+   make
+   make
+   make clean
+   make CFLAGS="-fsanitize=address" WERROR_CFLAGS=
+   make CFLAGS="-fsanitize=address" WERROR_CFLAGS= check VALGRIND=
+
+   Revert patch in URL above to trigger this self test.
+ */
 
 void
 doit (void)


hooks/post-receive
-- 
GNU libidn



reply via email to

[Prev in Thread] Current Thread [Next in Thread]