diff options
author | Nikos Mavrogiannopoulos <nmav@gnutls.org> | 2016-05-28 09:55:53 +0200 |
---|---|---|
committer | Nikos Mavrogiannopoulos <nmav@gnutls.org> | 2016-05-28 09:58:16 +0200 |
commit | 6e12d9e04dda23d32a235f9003c91d6042744914 (patch) | |
tree | 08516b1edfc061aedfa73d2ba769bd3320671baf /gl | |
parent | cde83335fa212445bdf25803f7373c8f47c89cd3 (diff) | |
download | gnutls-6e12d9e04dda23d32a235f9003c91d6042744914.tar.gz |
Rely on gnulib's secure_getenv()
Diffstat (limited to 'gl')
241 files changed, 1402 insertions, 1334 deletions
diff --git a/gl/Makefile.am b/gl/Makefile.am index e5e982009a..13eed87cdf 100644 --- a/gl/Makefile.am +++ b/gl/Makefile.am @@ -1,6 +1,6 @@ ## DO NOT EDIT! GENERATED AUTOMATICALLY! ## Process this file with automake to produce Makefile.in. -# Copyright (C) 2002-2015 Free Software Foundation, Inc. +# Copyright (C) 2002-2016 Free Software Foundation, Inc. # # This file is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -21,7 +21,7 @@ # the same distribution terms as the rest of that program. # # Generated by gnulib-tool. -# Reproduce by: gnulib-tool --import --dir=. --local-dir=gl/override --lib=libgnu --source-base=gl --m4-base=gl/m4 --doc-base=doc --tests-base=gl/tests --aux-dir=build-aux --with-tests --avoid=alignof-tests --avoid=lock-tests --avoid=lseek-tests --lgpl=2 --no-conditional-dependencies --libtool --macro-prefix=gl --no-vc-files --lgpl=2 alloca byteswap c-ctype extensions func gendocs getline gettext-h gettimeofday hash-pjw-bare havelib iconv intprops lib-msvc-compat lib-symbol-versions maintainer-makefile manywarnings memmem-simple minmax netdb netinet_in pmccabe2html read-file snprintf stdint strcase strndup strtok_r strverscmp sys_socket sys_stat time_r unistd valgrind-tests vasprintf vsnprintf warnings +# Reproduce by: gnulib-tool --import --local-dir=gl/override --lib=libgnu --source-base=gl --m4-base=gl/m4 --doc-base=doc --tests-base=gl/tests --aux-dir=build-aux --with-tests --avoid=alignof-tests --avoid=lock-tests --avoid=lseek-tests --lgpl=2 --no-conditional-dependencies --libtool --macro-prefix=gl --no-vc-files --lgpl=2 alloca byteswap c-ctype extensions func gendocs getline gettext-h gettimeofday hash-pjw-bare havelib iconv intprops lib-msvc-compat lib-symbol-versions maintainer-makefile manywarnings memmem-simple minmax netdb netinet_in pmccabe2html read-file secure_getenv snprintf stdint strcase strndup strtok_r strverscmp sys_socket sys_stat time_r unistd valgrind-tests vasprintf vsnprintf warnings AUTOMAKE_OPTIONS = 1.9.6 gnits @@ -443,6 +443,15 @@ EXTRA_libgnu_la_SOURCES += realloc.c ## end gnulib module realloc-posix +## begin gnulib module secure_getenv + + +EXTRA_DIST += secure_getenv.c + +EXTRA_libgnu_la_SOURCES += secure_getenv.c + +## end gnulib module secure_getenv + ## begin gnulib module size_max libgnu_la_SOURCES += size_max.h diff --git a/gl/alloca.in.h b/gl/alloca.in.h index 16a27c690d..a87da81818 100644 --- a/gl/alloca.in.h +++ b/gl/alloca.in.h @@ -1,6 +1,6 @@ /* Memory allocation on the stack. - Copyright (C) 1995, 1999, 2001-2004, 2006-2015 Free Software Foundation, + Copyright (C) 1995, 1999, 2001-2004, 2006-2016 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it diff --git a/gl/asnprintf.c b/gl/asnprintf.c index 375503cb04..d89877cd8e 100644 --- a/gl/asnprintf.c +++ b/gl/asnprintf.c @@ -1,5 +1,5 @@ /* Formatted output to strings. - Copyright (C) 1999, 2002, 2006, 2009-2015 Free Software Foundation, Inc. + Copyright (C) 1999, 2002, 2006, 2009-2016 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by diff --git a/gl/asprintf.c b/gl/asprintf.c index ff0fba0cdf..ee2b58f2d8 100644 --- a/gl/asprintf.c +++ b/gl/asprintf.c @@ -1,5 +1,5 @@ /* Formatted output to strings. - Copyright (C) 1999, 2002, 2006-2007, 2009-2015 Free Software Foundation, + Copyright (C) 1999, 2002, 2006-2007, 2009-2016 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify diff --git a/gl/byteswap.in.h b/gl/byteswap.in.h index 0316896062..31c1c6ea8f 100644 --- a/gl/byteswap.in.h +++ b/gl/byteswap.in.h @@ -1,5 +1,5 @@ /* byteswap.h - Byte swapping - Copyright (C) 2005, 2007, 2009-2015 Free Software Foundation, Inc. + Copyright (C) 2005, 2007, 2009-2016 Free Software Foundation, Inc. Written by Oskar Liljeblad <oskar@osk.mine.nu>, 2005. This program is free software: you can redistribute it and/or modify diff --git a/gl/c-ctype.c b/gl/c-ctype.c index 932d676dfe..5d9d4d87a6 100644 --- a/gl/c-ctype.c +++ b/gl/c-ctype.c @@ -1,395 +1,3 @@ -/* Character handling in C locale. - - Copyright 2000-2003, 2006, 2009-2015 Free Software Foundation, Inc. - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU Lesser General Public License as published by -the Free Software Foundation; either version 2.1 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public License -along with this program; if not, see <http://www.gnu.org/licenses/>. */ - #include <config.h> - -/* Specification. */ -#define NO_C_CTYPE_MACROS +#define C_CTYPE_INLINE _GL_EXTERN_INLINE #include "c-ctype.h" - -/* The function isascii is not locale dependent. Its use in EBCDIC is - questionable. */ -bool -c_isascii (int c) -{ - return (c >= 0x00 && c <= 0x7f); -} - -bool -c_isalnum (int c) -{ -#if C_CTYPE_CONSECUTIVE_DIGITS \ - && C_CTYPE_CONSECUTIVE_UPPERCASE && C_CTYPE_CONSECUTIVE_LOWERCASE -#if C_CTYPE_ASCII - return ((c >= '0' && c <= '9') - || ((c & ~0x20) >= 'A' && (c & ~0x20) <= 'Z')); -#else - return ((c >= '0' && c <= '9') - || (c >= 'A' && c <= 'Z') - || (c >= 'a' && c <= 'z')); -#endif -#else - switch (c) - { - case '0': case '1': case '2': case '3': case '4': case '5': - case '6': case '7': case '8': case '9': - case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': - case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': - case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': - case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': - case 'Y': case 'Z': - case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': - case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': - case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': - case 's': case 't': case 'u': case 'v': case 'w': case 'x': - case 'y': case 'z': - return 1; - default: - return 0; - } -#endif -} - -bool -c_isalpha (int c) -{ -#if C_CTYPE_CONSECUTIVE_UPPERCASE && C_CTYPE_CONSECUTIVE_LOWERCASE -#if C_CTYPE_ASCII - return ((c & ~0x20) >= 'A' && (c & ~0x20) <= 'Z'); -#else - return ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z')); -#endif -#else - switch (c) - { - case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': - case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': - case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': - case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': - case 'Y': case 'Z': - case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': - case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': - case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': - case 's': case 't': case 'u': case 'v': case 'w': case 'x': - case 'y': case 'z': - return 1; - default: - return 0; - } -#endif -} - -bool -c_isblank (int c) -{ - return (c == ' ' || c == '\t'); -} - -bool -c_iscntrl (int c) -{ -#if C_CTYPE_ASCII - return ((c & ~0x1f) == 0 || c == 0x7f); -#else - switch (c) - { - case ' ': case '!': case '"': case '#': case '$': case '%': - case '&': case '\'': case '(': case ')': case '*': case '+': - case ',': case '-': case '.': case '/': - case '0': case '1': case '2': case '3': case '4': case '5': - case '6': case '7': case '8': case '9': - case ':': case ';': case '<': case '=': case '>': case '?': - case '@': - case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': - case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': - case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': - case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': - case 'Y': case 'Z': - case '[': case '\\': case ']': case '^': case '_': case '`': - case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': - case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': - case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': - case 's': case 't': case 'u': case 'v': case 'w': case 'x': - case 'y': case 'z': - case '{': case '|': case '}': case '~': - return 0; - default: - return 1; - } -#endif -} - -bool -c_isdigit (int c) -{ -#if C_CTYPE_CONSECUTIVE_DIGITS - return (c >= '0' && c <= '9'); -#else - switch (c) - { - case '0': case '1': case '2': case '3': case '4': case '5': - case '6': case '7': case '8': case '9': - return 1; - default: - return 0; - } -#endif -} - -bool -c_islower (int c) -{ -#if C_CTYPE_CONSECUTIVE_LOWERCASE - return (c >= 'a' && c <= 'z'); -#else - switch (c) - { - case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': - case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': - case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': - case 's': case 't': case 'u': case 'v': case 'w': case 'x': - case 'y': case 'z': - return 1; - default: - return 0; - } -#endif -} - -bool -c_isgraph (int c) -{ -#if C_CTYPE_ASCII - return (c >= '!' && c <= '~'); -#else - switch (c) - { - case '!': case '"': case '#': case '$': case '%': case '&': - case '\'': case '(': case ')': case '*': case '+': case ',': - case '-': case '.': case '/': - case '0': case '1': case '2': case '3': case '4': case '5': - case '6': case '7': case '8': case '9': - case ':': case ';': case '<': case '=': case '>': case '?': - case '@': - case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': - case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': - case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': - case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': - case 'Y': case 'Z': - case '[': case '\\': case ']': case '^': case '_': case '`': - case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': - case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': - case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': - case 's': case 't': case 'u': case 'v': case 'w': case 'x': - case 'y': case 'z': - case '{': case '|': case '}': case '~': - return 1; - default: - return 0; - } -#endif -} - -bool -c_isprint (int c) -{ -#if C_CTYPE_ASCII - return (c >= ' ' && c <= '~'); -#else - switch (c) - { - case ' ': case '!': case '"': case '#': case '$': case '%': - case '&': case '\'': case '(': case ')': case '*': case '+': - case ',': case '-': case '.': case '/': - case '0': case '1': case '2': case '3': case '4': case '5': - case '6': case '7': case '8': case '9': - case ':': case ';': case '<': case '=': case '>': case '?': - case '@': - case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': - case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': - case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': - case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': - case 'Y': case 'Z': - case '[': case '\\': case ']': case '^': case '_': case '`': - case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': - case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': - case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': - case 's': case 't': case 'u': case 'v': case 'w': case 'x': - case 'y': case 'z': - case '{': case '|': case '}': case '~': - return 1; - default: - return 0; - } -#endif -} - -bool -c_ispunct (int c) -{ -#if C_CTYPE_ASCII - return ((c >= '!' && c <= '~') - && !((c >= '0' && c <= '9') - || ((c & ~0x20) >= 'A' && (c & ~0x20) <= 'Z'))); -#else - switch (c) - { - case '!': case '"': case '#': case '$': case '%': case '&': - case '\'': case '(': case ')': case '*': case '+': case ',': - case '-': case '.': case '/': - case ':': case ';': case '<': case '=': case '>': case '?': - case '@': - case '[': case '\\': case ']': case '^': case '_': case '`': - case '{': case '|': case '}': case '~': - return 1; - default: - return 0; - } -#endif -} - -bool -c_isspace (int c) -{ - return (c == ' ' || c == '\t' - || c == '\n' || c == '\v' || c == '\f' || c == '\r'); -} - -bool -c_isupper (int c) -{ -#if C_CTYPE_CONSECUTIVE_UPPERCASE - return (c >= 'A' && c <= 'Z'); -#else - switch (c) - { - case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': - case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': - case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': - case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': - case 'Y': case 'Z': - return 1; - default: - return 0; - } -#endif -} - -bool -c_isxdigit (int c) -{ -#if C_CTYPE_CONSECUTIVE_DIGITS \ - && C_CTYPE_CONSECUTIVE_UPPERCASE && C_CTYPE_CONSECUTIVE_LOWERCASE -#if C_CTYPE_ASCII - return ((c >= '0' && c <= '9') - || ((c & ~0x20) >= 'A' && (c & ~0x20) <= 'F')); -#else - return ((c >= '0' && c <= '9') - || (c >= 'A' && c <= 'F') - || (c >= 'a' && c <= 'f')); -#endif -#else - switch (c) - { - case '0': case '1': case '2': case '3': case '4': case '5': - case '6': case '7': case '8': case '9': - case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': - case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': - return 1; - default: - return 0; - } -#endif -} - -int -c_tolower (int c) -{ -#if C_CTYPE_CONSECUTIVE_UPPERCASE && C_CTYPE_CONSECUTIVE_LOWERCASE - return (c >= 'A' && c <= 'Z' ? c - 'A' + 'a' : c); -#else - switch (c) - { - case 'A': return 'a'; - case 'B': return 'b'; - case 'C': return 'c'; - case 'D': return 'd'; - case 'E': return 'e'; - case 'F': return 'f'; - case 'G': return 'g'; - case 'H': return 'h'; - case 'I': return 'i'; - case 'J': return 'j'; - case 'K': return 'k'; - case 'L': return 'l'; - case 'M': return 'm'; - case 'N': return 'n'; - case 'O': return 'o'; - case 'P': return 'p'; - case 'Q': return 'q'; - case 'R': return 'r'; - case 'S': return 's'; - case 'T': return 't'; - case 'U': return 'u'; - case 'V': return 'v'; - case 'W': return 'w'; - case 'X': return 'x'; - case 'Y': return 'y'; - case 'Z': return 'z'; - default: return c; - } -#endif -} - -int -c_toupper (int c) -{ -#if C_CTYPE_CONSECUTIVE_UPPERCASE && C_CTYPE_CONSECUTIVE_LOWERCASE - return (c >= 'a' && c <= 'z' ? c - 'a' + 'A' : c); -#else - switch (c) - { - case 'a': return 'A'; - case 'b': return 'B'; - case 'c': return 'C'; - case 'd': return 'D'; - case 'e': return 'E'; - case 'f': return 'F'; - case 'g': return 'G'; - case 'h': return 'H'; - case 'i': return 'I'; - case 'j': return 'J'; - case 'k': return 'K'; - case 'l': return 'L'; - case 'm': return 'M'; - case 'n': return 'N'; - case 'o': return 'O'; - case 'p': return 'P'; - case 'q': return 'Q'; - case 'r': return 'R'; - case 's': return 'S'; - case 't': return 'T'; - case 'u': return 'U'; - case 'v': return 'V'; - case 'w': return 'W'; - case 'x': return 'X'; - case 'y': return 'Y'; - case 'z': return 'Z'; - default: return c; - } -#endif -} diff --git a/gl/c-ctype.h b/gl/c-ctype.h index d57cf43767..80d704135d 100644 --- a/gl/c-ctype.h +++ b/gl/c-ctype.h @@ -5,7 +5,7 @@ <ctype.h> functions' behaviour depends on the current locale set via setlocale. - Copyright (C) 2000-2003, 2006, 2008-2015 Free Software Foundation, Inc. + Copyright (C) 2000-2003, 2006, 2008-2016 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by @@ -25,6 +25,13 @@ along with this program; if not, see <http://www.gnu.org/licenses/>. */ #include <stdbool.h> +#ifndef _GL_INLINE_HEADER_BEGIN + #error "Please include config.h first." +#endif +_GL_INLINE_HEADER_BEGIN +#ifndef C_CTYPE_INLINE +# define C_CTYPE_INLINE _GL_INLINE +#endif #ifdef __cplusplus extern "C" { @@ -39,38 +46,6 @@ extern "C" { characters. */ -/* Check whether the ASCII optimizations apply. */ - -/* ANSI C89 (and ISO C99 5.2.1.3 too) already guarantees that - '0', '1', ..., '9' have consecutive integer values. */ -#define C_CTYPE_CONSECUTIVE_DIGITS 1 - -#if ('A' <= 'Z') \ - && ('A' + 1 == 'B') && ('B' + 1 == 'C') && ('C' + 1 == 'D') \ - && ('D' + 1 == 'E') && ('E' + 1 == 'F') && ('F' + 1 == 'G') \ - && ('G' + 1 == 'H') && ('H' + 1 == 'I') && ('I' + 1 == 'J') \ - && ('J' + 1 == 'K') && ('K' + 1 == 'L') && ('L' + 1 == 'M') \ - && ('M' + 1 == 'N') && ('N' + 1 == 'O') && ('O' + 1 == 'P') \ - && ('P' + 1 == 'Q') && ('Q' + 1 == 'R') && ('R' + 1 == 'S') \ - && ('S' + 1 == 'T') && ('T' + 1 == 'U') && ('U' + 1 == 'V') \ - && ('V' + 1 == 'W') && ('W' + 1 == 'X') && ('X' + 1 == 'Y') \ - && ('Y' + 1 == 'Z') -#define C_CTYPE_CONSECUTIVE_UPPERCASE 1 -#endif - -#if ('a' <= 'z') \ - && ('a' + 1 == 'b') && ('b' + 1 == 'c') && ('c' + 1 == 'd') \ - && ('d' + 1 == 'e') && ('e' + 1 == 'f') && ('f' + 1 == 'g') \ - && ('g' + 1 == 'h') && ('h' + 1 == 'i') && ('i' + 1 == 'j') \ - && ('j' + 1 == 'k') && ('k' + 1 == 'l') && ('l' + 1 == 'm') \ - && ('m' + 1 == 'n') && ('n' + 1 == 'o') && ('o' + 1 == 'p') \ - && ('p' + 1 == 'q') && ('q' + 1 == 'r') && ('r' + 1 == 's') \ - && ('s' + 1 == 't') && ('t' + 1 == 'u') && ('u' + 1 == 'v') \ - && ('v' + 1 == 'w') && ('w' + 1 == 'x') && ('x' + 1 == 'y') \ - && ('y' + 1 == 'z') -#define C_CTYPE_CONSECUTIVE_LOWERCASE 1 -#endif - #if (' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \ && ('%' == 37) && ('&' == 38) && ('\'' == 39) && ('(' == 40) \ && (')' == 41) && ('*' == 42) && ('+' == 43) && (',' == 44) \ @@ -96,11 +71,84 @@ extern "C" { && ('{' == 123) && ('|' == 124) && ('}' == 125) && ('~' == 126) /* The character set is ASCII or one of its variants or extensions, not EBCDIC. Testing the value of '\n' and '\r' is not relevant. */ -#define C_CTYPE_ASCII 1 +# define C_CTYPE_ASCII 1 +#elif ! (' ' == '\x40' && '0' == '\xf0' \ + && 'A' == '\xc1' && 'J' == '\xd1' && 'S' == '\xe2' \ + && 'a' == '\x81' && 'j' == '\x91' && 's' == '\xa2') +# error "Only ASCII and EBCDIC are supported" #endif +#if 'A' < 0 +# error "EBCDIC and char is signed -- not supported" +#endif + +/* Cases for control characters. */ + +#define _C_CTYPE_CNTRL \ + case '\a': case '\b': case '\f': case '\n': \ + case '\r': case '\t': case '\v': \ + _C_CTYPE_OTHER_CNTRL + +/* ASCII control characters other than those with \-letter escapes. */ + +#if C_CTYPE_ASCII +# define _C_CTYPE_OTHER_CNTRL \ + case '\x00': case '\x01': case '\x02': case '\x03': \ + case '\x04': case '\x05': case '\x06': case '\x0e': \ + case '\x0f': case '\x10': case '\x11': case '\x12': \ + case '\x13': case '\x14': case '\x15': case '\x16': \ + case '\x17': case '\x18': case '\x19': case '\x1a': \ + case '\x1b': case '\x1c': case '\x1d': case '\x1e': \ + case '\x1f': case '\x7f' +#else + /* Use EBCDIC code page 1047's assignments for ASCII control chars; + assume all EBCDIC code pages agree about these assignments. */ +# define _C_CTYPE_OTHER_CNTRL \ + case '\x00': case '\x01': case '\x02': case '\x03': \ + case '\x07': case '\x0e': case '\x0f': case '\x10': \ + case '\x11': case '\x12': case '\x13': case '\x18': \ + case '\x19': case '\x1c': case '\x1d': case '\x1e': \ + case '\x1f': case '\x26': case '\x27': case '\x2d': \ + case '\x2e': case '\x32': case '\x37': case '\x3c': \ + case '\x3d': case '\x3f' +#endif -/* Function declarations. */ +/* Cases for lowercase hex letters, and lowercase letters, all offset by N. */ + +#define _C_CTYPE_LOWER_A_THRU_F_N(n) \ + case 'a' + (n): case 'b' + (n): case 'c' + (n): case 'd' + (n): \ + case 'e' + (n): case 'f' + (n) +#define _C_CTYPE_LOWER_N(n) \ + _C_CTYPE_LOWER_A_THRU_F_N(n): \ + case 'g' + (n): case 'h' + (n): case 'i' + (n): case 'j' + (n): \ + case 'k' + (n): case 'l' + (n): case 'm' + (n): case 'n' + (n): \ + case 'o' + (n): case 'p' + (n): case 'q' + (n): case 'r' + (n): \ + case 's' + (n): case 't' + (n): case 'u' + (n): case 'v' + (n): \ + case 'w' + (n): case 'x' + (n): case 'y' + (n): case 'z' + (n) + +/* Cases for hex letters, digits, lower, punct, and upper. */ + +#define _C_CTYPE_A_THRU_F \ + _C_CTYPE_LOWER_A_THRU_F_N (0): \ + _C_CTYPE_LOWER_A_THRU_F_N ('A' - 'a') +#define _C_CTYPE_DIGIT \ + case '0': case '1': case '2': case '3': \ + case '4': case '5': case '6': case '7': \ + case '8': case '9' +#define _C_CTYPE_LOWER _C_CTYPE_LOWER_N (0) +#define _C_CTYPE_PUNCT \ + case '!': case '"': case '#': case '$': \ + case '%': case '&': case '\'': case '(': \ + case ')': case '*': case '+': case ',': \ + case '-': case '.': case '/': case ':': \ + case ';': case '<': case '=': case '>': \ + case '?': case '@': case '[': case '\\': \ + case ']': case '^': case '_': case '`': \ + case '{': case '|': case '}': case '~' +#define _C_CTYPE_UPPER _C_CTYPE_LOWER_N ('A' - 'a') + + +/* Function definitions. */ /* Unlike the functions in <ctype.h>, which require an argument in the range of the 'unsigned char' type, the functions here operate on values that are @@ -117,179 +165,202 @@ extern "C" { if (c_isalpha (*s)) ... */ -extern bool c_isascii (int c) _GL_ATTRIBUTE_CONST; /* not locale dependent */ - -extern bool c_isalnum (int c) _GL_ATTRIBUTE_CONST; -extern bool c_isalpha (int c) _GL_ATTRIBUTE_CONST; -extern bool c_isblank (int c) _GL_ATTRIBUTE_CONST; -extern bool c_iscntrl (int c) _GL_ATTRIBUTE_CONST; -extern bool c_isdigit (int c) _GL_ATTRIBUTE_CONST; -extern bool c_islower (int c) _GL_ATTRIBUTE_CONST; -extern bool c_isgraph (int c) _GL_ATTRIBUTE_CONST; -extern bool c_isprint (int c) _GL_ATTRIBUTE_CONST; -extern bool c_ispunct (int c) _GL_ATTRIBUTE_CONST; -extern bool c_isspace (int c) _GL_ATTRIBUTE_CONST; -extern bool c_isupper (int c) _GL_ATTRIBUTE_CONST; -extern bool c_isxdigit (int c) _GL_ATTRIBUTE_CONST; - -extern int c_tolower (int c) _GL_ATTRIBUTE_CONST; -extern int c_toupper (int c) _GL_ATTRIBUTE_CONST; - - -#if (defined __GNUC__ && !defined __STRICT_ANSI__ && defined __OPTIMIZE__ \ - && !defined __OPTIMIZE_SIZE__ && !defined NO_C_CTYPE_MACROS) - -/* ASCII optimizations. */ - -#undef c_isascii -#define c_isascii(c) \ - ({ int __c = (c); \ - (__c >= 0x00 && __c <= 0x7f); \ - }) +C_CTYPE_INLINE bool +c_isalnum (int c) +{ + switch (c) + { + _C_CTYPE_DIGIT: + _C_CTYPE_LOWER: + _C_CTYPE_UPPER: + return true; + default: + return false; + } +} -#if C_CTYPE_CONSECUTIVE_DIGITS \ - && C_CTYPE_CONSECUTIVE_UPPERCASE && C_CTYPE_CONSECUTIVE_LOWERCASE -#if C_CTYPE_ASCII -#undef c_isalnum -#define c_isalnum(c) \ - ({ int __c = (c); \ - ((__c >= '0' && __c <= '9') \ - || ((__c & ~0x20) >= 'A' && (__c & ~0x20) <= 'Z')); \ - }) -#else -#undef c_isalnum -#define c_isalnum(c) \ - ({ int __c = (c); \ - ((__c >= '0' && __c <= '9') \ - || (__c >= 'A' && __c <= 'Z') \ - || (__c >= 'a' && __c <= 'z')); \ - }) -#endif -#endif +C_CTYPE_INLINE bool +c_isalpha (int c) +{ + switch (c) + { + _C_CTYPE_LOWER: + _C_CTYPE_UPPER: + return true; + default: + return false; + } +} -#if C_CTYPE_CONSECUTIVE_UPPERCASE && C_CTYPE_CONSECUTIVE_LOWERCASE -#if C_CTYPE_ASCII -#undef c_isalpha -#define c_isalpha(c) \ - ({ int __c = (c); \ - ((__c & ~0x20) >= 'A' && (__c & ~0x20) <= 'Z'); \ - }) -#else -#undef c_isalpha -#define c_isalpha(c) \ - ({ int __c = (c); \ - ((__c >= 'A' && __c <= 'Z') || (__c >= 'a' && __c <= 'z')); \ - }) -#endif -#endif +/* The function isascii is not locale dependent. + Its use in EBCDIC is questionable. */ +C_CTYPE_INLINE bool +c_isascii (int c) +{ + switch (c) + { + case ' ': + _C_CTYPE_CNTRL: + _C_CTYPE_DIGIT: + _C_CTYPE_LOWER: + _C_CTYPE_PUNCT: + _C_CTYPE_UPPER: + return true; + default: + return false; + } +} -#undef c_isblank -#define c_isblank(c) \ - ({ int __c = (c); \ - (__c == ' ' || __c == '\t'); \ - }) +C_CTYPE_INLINE bool +c_isblank (int c) +{ + return c == ' ' || c == '\t'; +} -#if C_CTYPE_ASCII -#undef c_iscntrl -#define c_iscntrl(c) \ - ({ int __c = (c); \ - ((__c & ~0x1f) == 0 || __c == 0x7f); \ - }) -#endif +C_CTYPE_INLINE bool +c_iscntrl (int c) +{ + switch (c) + { + _C_CTYPE_CNTRL: + return true; + default: + return false; + } +} -#if C_CTYPE_CONSECUTIVE_DIGITS -#undef c_isdigit -#define c_isdigit(c) \ - ({ int __c = (c); \ - (__c >= '0' && __c <= '9'); \ - }) -#endif +C_CTYPE_INLINE bool +c_isdigit (int c) +{ + switch (c) + { + _C_CTYPE_DIGIT: + return true; + default: + return false; + } +} -#if C_CTYPE_CONSECUTIVE_LOWERCASE -#undef c_islower -#define c_islower(c) \ - ({ int __c = (c); \ - (__c >= 'a' && __c <= 'z'); \ - }) -#endif +C_CTYPE_INLINE bool +c_isgraph (int c) +{ + switch (c) + { + _C_CTYPE_DIGIT: + _C_CTYPE_LOWER: + _C_CTYPE_PUNCT: + _C_CTYPE_UPPER: + return true; + default: + return false; + } +} -#if C_CTYPE_ASCII -#undef c_isgraph -#define c_isgraph(c) \ - ({ int __c = (c); \ - (__c >= '!' && __c <= '~'); \ - }) -#endif +C_CTYPE_INLINE bool +c_islower (int c) +{ + switch (c) + { + _C_CTYPE_LOWER: + return true; + default: + return false; + } +} -#if C_CTYPE_ASCII -#undef c_isprint -#define c_isprint(c) \ - ({ int __c = (c); \ - (__c >= ' ' && __c <= '~'); \ - }) -#endif +C_CTYPE_INLINE bool +c_isprint (int c) +{ + switch (c) + { + case ' ': + _C_CTYPE_DIGIT: + _C_CTYPE_LOWER: + _C_CTYPE_PUNCT: + _C_CTYPE_UPPER: + return true; + default: + return false; + } +} -#if C_CTYPE_ASCII -#undef c_ispunct -#define c_ispunct(c) \ - ({ int _c = (c); \ - (c_isgraph (_c) && ! c_isalnum (_c)); \ - }) -#endif +C_CTYPE_INLINE bool +c_ispunct (int c) +{ + switch (c) + { + _C_CTYPE_PUNCT: + return true; + default: + return false; + } +} -#undef c_isspace -#define c_isspace(c) \ - ({ int __c = (c); \ - (__c == ' ' || __c == '\t' \ - || __c == '\n' || __c == '\v' || __c == '\f' || __c == '\r'); \ - }) - -#if C_CTYPE_CONSECUTIVE_UPPERCASE -#undef c_isupper -#define c_isupper(c) \ - ({ int __c = (c); \ - (__c >= 'A' && __c <= 'Z'); \ - }) -#endif +C_CTYPE_INLINE bool +c_isspace (int c) +{ + switch (c) + { + case ' ': case '\t': case '\n': case '\v': case '\f': case '\r': + return true; + default: + return false; + } +} -#if C_CTYPE_CONSECUTIVE_DIGITS \ - && C_CTYPE_CONSECUTIVE_UPPERCASE && C_CTYPE_CONSECUTIVE_LOWERCASE -#if C_CTYPE_ASCII -#undef c_isxdigit -#define c_isxdigit(c) \ - ({ int __c = (c); \ - ((__c >= '0' && __c <= '9') \ - || ((__c & ~0x20) >= 'A' && (__c & ~0x20) <= 'F')); \ - }) -#else -#undef c_isxdigit -#define c_isxdigit(c) \ - ({ int __c = (c); \ - ((__c >= '0' && __c <= '9') \ - || (__c >= 'A' && __c <= 'F') \ - || (__c >= 'a' && __c <= 'f')); \ - }) -#endif -#endif +C_CTYPE_INLINE bool +c_isupper (int c) +{ + switch (c) + { + _C_CTYPE_UPPER: + return true; + default: + return false; + } +} -#if C_CTYPE_CONSECUTIVE_UPPERCASE && C_CTYPE_CONSECUTIVE_LOWERCASE -#undef c_tolower -#define c_tolower(c) \ - ({ int __c = (c); \ - (__c >= 'A' && __c <= 'Z' ? __c - 'A' + 'a' : __c); \ - }) -#undef c_toupper -#define c_toupper(c) \ - ({ int __c = (c); \ - (__c >= 'a' && __c <= 'z' ? __c - 'a' + 'A' : __c); \ - }) -#endif +C_CTYPE_INLINE bool +c_isxdigit (int c) +{ + switch (c) + { + _C_CTYPE_DIGIT: + _C_CTYPE_A_THRU_F: + return true; + default: + return false; + } +} -#endif /* optimizing for speed */ +C_CTYPE_INLINE int +c_tolower (int c) +{ + switch (c) + { + _C_CTYPE_UPPER: + return c - 'A' + 'a'; + default: + return c; + } +} +C_CTYPE_INLINE int +c_toupper (int c) +{ + switch (c) + { + _C_CTYPE_LOWER: + return c - 'a' + 'A'; + default: + return c; + } +} #ifdef __cplusplus } #endif +_GL_INLINE_HEADER_END + #endif /* C_CTYPE_H */ diff --git a/gl/errno.in.h b/gl/errno.in.h index 4d68ea0e53..f1fcf1fb3e 100644 --- a/gl/errno.in.h +++ b/gl/errno.in.h @@ -1,6 +1,6 @@ /* A POSIX-like <errno.h>. - Copyright (C) 2008-2015 Free Software Foundation, Inc. + Copyright (C) 2008-2016 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by diff --git a/gl/float+.h b/gl/float+.h index ac1b02d526..49a9dfc0f6 100644 --- a/gl/float+.h +++ b/gl/float+.h @@ -1,5 +1,5 @@ /* Supplemental information about the floating-point formats. - Copyright (C) 2007, 2009-2015 Free Software Foundation, Inc. + Copyright (C) 2007, 2009-2016 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2007. This program is free software; you can redistribute it and/or modify diff --git a/gl/float.c b/gl/float.c index 9869971e85..a2c7fe6af0 100644 --- a/gl/float.c +++ b/gl/float.c @@ -1,5 +1,5 @@ /* Auxiliary definitions for <float.h>. - Copyright (C) 2011-2015 Free Software Foundation, Inc. + Copyright (C) 2011-2016 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2011. This program is free software: you can redistribute it and/or modify diff --git a/gl/float.in.h b/gl/float.in.h index 98bd7f74e6..c80126116b 100644 --- a/gl/float.in.h +++ b/gl/float.in.h @@ -1,6 +1,6 @@ /* A correct <float.h>. - Copyright (C) 2007-2015 Free Software Foundation, Inc. + Copyright (C) 2007-2016 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by diff --git a/gl/fstat.c b/gl/fstat.c index 6433514c93..b2104d3bdd 100644 --- a/gl/fstat.c +++ b/gl/fstat.c @@ -1,5 +1,5 @@ /* fstat() replacement. - Copyright (C) 2011-2015 Free Software Foundation, Inc. + Copyright (C) 2011-2016 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by diff --git a/gl/ftell.c b/gl/ftell.c index 01dc62f180..0c77bd2ac3 100644 --- a/gl/ftell.c +++ b/gl/ftell.c @@ -1,5 +1,5 @@ /* An ftell() function that works around platform bugs. - Copyright (C) 2007-2015 Free Software Foundation, Inc. + Copyright (C) 2007-2016 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by diff --git a/gl/ftello.c b/gl/ftello.c index c74bd4c8e3..d1b00d1247 100644 --- a/gl/ftello.c +++ b/gl/ftello.c @@ -1,5 +1,5 @@ /* An ftello() function that works around platform bugs. - Copyright (C) 2007, 2009-2015 Free Software Foundation, Inc. + Copyright (C) 2007, 2009-2016 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by diff --git a/gl/getdelim.c b/gl/getdelim.c index f87b708763..46f145aba4 100644 --- a/gl/getdelim.c +++ b/gl/getdelim.c @@ -1,5 +1,5 @@ /* getdelim.c --- Implementation of replacement getdelim function. - Copyright (C) 1994, 1996-1998, 2001, 2003, 2005-2015 Free Software + Copyright (C) 1994, 1996-1998, 2001, 2003, 2005-2016 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or diff --git a/gl/getline.c b/gl/getline.c index 2f3e4ce3ce..08b8f0796a 100644 --- a/gl/getline.c +++ b/gl/getline.c @@ -1,5 +1,5 @@ /* getline.c --- Implementation of replacement getline function. - Copyright (C) 2005-2007, 2009-2015 Free Software Foundation, Inc. + Copyright (C) 2005-2007, 2009-2016 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as diff --git a/gl/gettext.h b/gl/gettext.h index 7d3ea3cbf1..4aa138ea13 100644 --- a/gl/gettext.h +++ b/gl/gettext.h @@ -1,5 +1,5 @@ /* Convenience header for conditional use of GNU <libintl.h>. - Copyright (C) 1995-1998, 2000-2002, 2004-2006, 2009-2015 Free Software + Copyright (C) 1995-1998, 2000-2002, 2004-2006, 2009-2016 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify @@ -225,15 +225,17 @@ dcpgettext_expr (const char *domain, 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; @@ -271,15 +273,17 @@ dcnpgettext_expr (const char *domain, 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/gettimeofday.c b/gl/gettimeofday.c index ab76abfb28..df01908d50 100644 --- a/gl/gettimeofday.c +++ b/gl/gettimeofday.c @@ -1,6 +1,6 @@ /* Provide gettimeofday for systems that don't have it or for which it's broken. - Copyright (C) 2001-2003, 2005-2007, 2009-2015 Free Software Foundation, Inc. + Copyright (C) 2001-2003, 2005-2007, 2009-2016 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by diff --git a/gl/hash-pjw-bare.c b/gl/hash-pjw-bare.c index 6dab917d61..3e25cae878 100644 --- a/gl/hash-pjw-bare.c +++ b/gl/hash-pjw-bare.c @@ -1,6 +1,6 @@ /* hash-pjw-bare.c -- compute a hash value from a provided buffer. - Copyright (C) 2012-2015 Free Software Foundation, Inc. + Copyright (C) 2012-2016 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published diff --git a/gl/hash-pjw-bare.h b/gl/hash-pjw-bare.h index 2aa39acf84..af4892af92 100644 --- a/gl/hash-pjw-bare.h +++ b/gl/hash-pjw-bare.h @@ -1,5 +1,5 @@ /* hash-pjw-bare.h -- declaration for a simple hash function - Copyright (C) 2012-2015 Free Software Foundation, Inc. + Copyright (C) 2012-2016 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published @@ -20,5 +20,5 @@ and return the hash code. Note that unlike hash_pjw(), it does not return it modulo a table size. The result is platform dependent: it depends on the size of the 'size_t' - type and on the signedness of the 'char' type. */ + type. */ extern size_t hash_pjw_bare (const void *x, size_t n) _GL_ATTRIBUTE_PURE; diff --git a/gl/intprops.h b/gl/intprops.h index 2ae151b929..0be799dfe3 100644 --- a/gl/intprops.h +++ b/gl/intprops.h @@ -1,10 +1,10 @@ /* intprops.h -- properties of integer types - Copyright (C) 2001-2005, 2009-2015 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 Lesser General Public License as published by - the Free Software Foundation; either version 2.1 of the License, or + This program is free software: you can redistribute it and/or modify it + under the terms of the GNU Lesser General Public License as published + by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, @@ -21,9 +21,9 @@ #define _GL_INTPROPS_H #include <limits.h> +#include <verify.h> -/* Return an integer value, converted to the same type as the integer - expression E after integer type promotion. V is the unconverted value. */ +/* 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)) /* Act like _GL_INT_CONVERT (E, -V) but work around a bug in IRIX 6.5 cc; see @@ -37,37 +37,18 @@ 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 arithmetic type T is signed. */ +/* True if the real type T is signed. */ #define TYPE_SIGNED(t) (! ((t) 0 < (t) -1)) -/* Return 1 if the integer expression E, after integer promotion, has - a signed type. */ -#define _GL_INT_SIGNED(e) (_GL_INT_NEGATE_CONVERT (e, 1) < 0) +/* Return 1 if the real expression E, after promotion, has a + signed or floating type. */ +#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,18 +57,35 @@ /* The maximum and minimum values for the type of the expression E, after integer promotion. E should not have side effects. */ #define _GL_INT_MINIMUM(e) \ - (_GL_INT_SIGNED (e) \ - ? - _GL_INT_TWOS_COMPLEMENT (e) - _GL_SIGNED_INT_MAXIMUM (e) \ + (EXPR_SIGNED (e) \ + ? ~ _GL_SIGNED_INT_MAXIMUM (e) \ : _GL_INT_CONVERT (e, 0)) #define _GL_INT_MAXIMUM(e) \ - (_GL_INT_SIGNED (e) \ + (EXPR_SIGNED (e) \ ? _GL_SIGNED_INT_MAXIMUM (e) \ : _GL_INT_NEGATE_CONVERT (e, 1)) #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__)) @@ -263,22 +261,29 @@ : (a) % - (b)) \ == 0) - -/* Integer overflow checks. +/* Check for integer overflow, and report low order bits of answer. The INT_<op>_OVERFLOW macros return 1 if the corresponding C operators might not yield numerically correct answers due to arithmetic overflow. - They work correctly on all known practical hosts, and do not rely + The INT_<op>_WRAPV macros also store the low-order bits of the answer. + These macros work correctly on all known practical hosts, and do not rely on undefined behavior due to signed arithmetic overflow. - Example usage: + Example usage, assuming A and B are long int: - long int i = ...; - long int j = ...; - if (INT_MULTIPLY_OVERFLOW (i, j)) - printf ("multiply would overflow"); + if (INT_MULTIPLY_OVERFLOW (a, b)) + printf ("result would overflow\n"); else - printf ("product is %ld", i * j); + printf ("result is %ld (no overflow)\n", a * b); + + Example usage with WRAPV flavor: + + long int result; + bool overflow = INT_MULTIPLY_WRAPV (a, b, &result); + printf ("result is %ld (%s)\n", result, + overflow ? "after overflow" : "no overflow"); + + Restrictions on these macros: These macros do not check for all possible numerical problems or undefined or unspecified behavior: they do not check for division @@ -287,6 +292,9 @@ These macros may evaluate their arguments zero or multiple times, so the arguments should not have side effects. + The WRAPV macros are not constant expressions. They support only + +, binary -, and *. The result type must be signed. + These macros are tuned for their last argument being a constant. Return 1 if the integer expressions A * B, A - B, -A, A * B, A / B, @@ -317,4 +325,104 @@ _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. + 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) +#define INT_SUBTRACT_WRAPV(a, b, r) \ + _GL_INT_OP_WRAPV (a, b, r, -, __builtin_sub_overflow, INT_SUBTRACT_OVERFLOW) +#define INT_MULTIPLY_WRAPV(a, b, r) \ + _GL_INT_OP_WRAPV (a, b, r, *, __builtin_mul_overflow, INT_MULTIPLY_OVERFLOW) + +#ifndef __has_builtin +# define __has_builtin(x) 0 +#endif + +/* Nonzero if this compiler has GCC bug 68193 or Clang bug 25390. See: + https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68193 + https://llvm.org/bugs/show_bug.cgi?id=25390 + For now, assume all versions of GCC-like compilers generate bogus + warnings for _Generic. This matters only for older compilers that + lack __builtin_add_overflow. */ +#if __GNUC__ +# define _GL__GENERIC_BOGUS 1 +#else +# 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. */ +#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 +# define _GL_INT_OP_WRAPV(a, b, r, op, builtin, overflow) \ + (_Generic \ + (*(r), \ + signed char: \ + _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned char, \ + signed char, SCHAR_MIN, SCHAR_MAX), \ + short int: \ + _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned short int, \ + short int, SHRT_MIN, SHRT_MAX), \ + int: \ + _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, \ + int, INT_MIN, INT_MAX), \ + long int: \ + _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long int, \ + long int, LONG_MIN, LONG_MAX), \ + long long int: \ + _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long long int, \ + long long int, LLONG_MIN, LLONG_MAX))) +#else +# define _GL_INT_OP_WRAPV(a, b, r, op, builtin, overflow) \ + (sizeof *(r) == sizeof (signed char) \ + ? _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned char, \ + signed char, SCHAR_MIN, SCHAR_MAX) \ + : sizeof *(r) == sizeof (short int) \ + ? _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned short int, \ + short int, SHRT_MIN, SHRT_MAX) \ + : sizeof *(r) == sizeof (int) \ + ? _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, \ + int, INT_MIN, INT_MAX) \ + : _GL_INT_OP_WRAPV_LONGISH(a, b, r, op, overflow)) +# ifdef LLONG_MAX +# define _GL_INT_OP_WRAPV_LONGISH(a, b, r, op, overflow) \ + (sizeof *(r) == sizeof (long int) \ + ? _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long int, \ + long int, LONG_MIN, LONG_MAX) \ + : _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long long int, \ + long long int, LLONG_MIN, LLONG_MAX)) +# else +# define _GL_INT_OP_WRAPV_LONGISH(a, b, r, op, overflow) \ + _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long int, \ + long int, LONG_MIN, LONG_MAX)) +# endif +#endif + +/* 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. */ +#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) \ + : _GL_INT_OP_CALC1 (a, b, r, op, overflow, ut, t, tmin, tmax)) +#define _GL_INT_OP_CALC1(a, b, r, op, overflow, ut, t, tmin, tmax) \ + ((overflow (a, b) \ + || (EXPR_SIGNED ((a) op (b)) && ((a) op (b)) < (tmin)) \ + || (tmax) < ((a) op (b))) \ + ? (*(r) = _GL_INT_OP_WRAPV_VIA_UNSIGNED (a, b, op, ut, t, tmin, tmax), 1) \ + : (*(r) = _GL_INT_OP_WRAPV_VIA_UNSIGNED (a, b, op, ut, t, tmin, tmax), 0)) + +/* Return A <op> B, where the operation is given by OP. Use the + unsigned type UT for calculation to avoid overflow problems. + Convert the result to type T without overflow by subtracting TMIN + from large values before converting, and adding it afterwards. + Compilers can optimize all the operations except OP. */ +#define _GL_INT_OP_WRAPV_VIA_UNSIGNED(a, b, op, ut, t, tmin, tmax) \ + (((ut) (a) op (ut) (b)) <= (tmax) \ + ? (t) ((ut) (a) op (ut) (b)) \ + : ((t) (((ut) (a) op (ut) (b)) - (tmin)) + (tmin))) + #endif /* _GL_INTPROPS_H */ diff --git a/gl/itold.c b/gl/itold.c index 9361e11512..fde7619fc4 100644 --- a/gl/itold.c +++ b/gl/itold.c @@ -1,5 +1,5 @@ /* Replacement for 'int' to 'long double' conversion routine. - Copyright (C) 2011-2015 Free Software Foundation, Inc. + Copyright (C) 2011-2016 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2011. This program is free software: you can redistribute it and/or modify diff --git a/gl/lseek.c b/gl/lseek.c index 021e15c5b7..071742b131 100644 --- a/gl/lseek.c +++ b/gl/lseek.c @@ -1,5 +1,5 @@ /* An lseek() function that detects pipes. - Copyright (C) 2007, 2009-2015 Free Software Foundation, Inc. + Copyright (C) 2007, 2009-2016 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by diff --git a/gl/m4/00gnulib.m4 b/gl/m4/00gnulib.m4 index c7103ed52f..bb37e32aa3 100644 --- a/gl/m4/00gnulib.m4 +++ b/gl/m4/00gnulib.m4 @@ -1,5 +1,5 @@ # 00gnulib.m4 serial 3 -dnl Copyright (C) 2009-2015 Free Software Foundation, Inc. +dnl Copyright (C) 2009-2016 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/gl/m4/absolute-header.m4 b/gl/m4/absolute-header.m4 index bc19dfc301..7ffc38d7a2 100644 --- a/gl/m4/absolute-header.m4 +++ b/gl/m4/absolute-header.m4 @@ -1,5 +1,5 @@ # absolute-header.m4 serial 16 -dnl Copyright (C) 2006-2015 Free Software Foundation, Inc. +dnl Copyright (C) 2006-2016 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/gl/m4/alloca.m4 b/gl/m4/alloca.m4 index 8408bed288..2382ff1eee 100644 --- a/gl/m4/alloca.m4 +++ b/gl/m4/alloca.m4 @@ -1,5 +1,5 @@ # alloca.m4 serial 14 -dnl Copyright (C) 2002-2004, 2006-2007, 2009-2015 Free Software Foundation, +dnl Copyright (C) 2002-2004, 2006-2007, 2009-2016 Free Software Foundation, dnl Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, diff --git a/gl/m4/byteswap.m4 b/gl/m4/byteswap.m4 index ec5d46cde2..27f0fd69d2 100644 --- a/gl/m4/byteswap.m4 +++ b/gl/m4/byteswap.m4 @@ -1,5 +1,5 @@ # byteswap.m4 serial 4 -dnl Copyright (C) 2005, 2007, 2009-2015 Free Software Foundation, Inc. +dnl Copyright (C) 2005, 2007, 2009-2016 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/gl/m4/ctype.m4 b/gl/m4/ctype.m4 new file mode 100644 index 0000000000..a2165aaac4 --- /dev/null +++ b/gl/m4/ctype.m4 @@ -0,0 +1,32 @@ +# ctype_h.m4 serial 6 +dnl Copyright (C) 2009-2016 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_CTYPE_H], +[ + AC_REQUIRE([gl_CTYPE_H_DEFAULTS]) + + dnl <ctype.h> is always overridden, because of GNULIB_POSIXCHECK. + gl_NEXT_HEADERS([ctype.h]) + + dnl Check for declarations of anything we want to poison if the + dnl corresponding gnulib module is not in use. + gl_WARN_ON_USE_PREPARE([[#include <ctype.h> + ]], [isblank]) +]) + +AC_DEFUN([gl_CTYPE_MODULE_INDICATOR], +[ + dnl Use AC_REQUIRE here, so that the default settings are expanded once only. + AC_REQUIRE([gl_CTYPE_H_DEFAULTS]) + gl_MODULE_INDICATOR_SET_VARIABLE([$1]) +]) + +AC_DEFUN([gl_CTYPE_H_DEFAULTS], +[ + GNULIB_ISBLANK=0; AC_SUBST([GNULIB_ISBLANK]) + dnl Assume proper GNU behavior unless another module says otherwise. + HAVE_ISBLANK=1; AC_SUBST([HAVE_ISBLANK]) +]) diff --git a/gl/m4/errno_h.m4 b/gl/m4/errno_h.m4 index cfaa687615..b111fce053 100644 --- a/gl/m4/errno_h.m4 +++ b/gl/m4/errno_h.m4 @@ -1,5 +1,5 @@ # errno_h.m4 serial 12 -dnl Copyright (C) 2004, 2006, 2008-2015 Free Software Foundation, Inc. +dnl Copyright (C) 2004, 2006, 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, dnl with or without modifications, as long as this notice is preserved. diff --git a/gl/m4/exponentd.m4 b/gl/m4/exponentd.m4 index 84f1691a65..7869a7d6cb 100644 --- a/gl/m4/exponentd.m4 +++ b/gl/m4/exponentd.m4 @@ -1,5 +1,5 @@ # exponentd.m4 serial 3 -dnl Copyright (C) 2007-2008, 2010-2015 Free Software Foundation, Inc. +dnl Copyright (C) 2007-2008, 2010-2016 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/gl/m4/extensions.m4 b/gl/m4/extensions.m4 index 35bc49c97b..6d378ec41c 100644 --- a/gl/m4/extensions.m4 +++ b/gl/m4/extensions.m4 @@ -1,7 +1,7 @@ # serial 13 -*- Autoconf -*- # Enable extensions on systems that normally disable them. -# Copyright (C) 2003, 2006-2015 Free Software Foundation, Inc. +# Copyright (C) 2003, 2006-2016 Free Software Foundation, Inc. # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. diff --git a/gl/m4/extern-inline.m4 b/gl/m4/extern-inline.m4 index 72800650e6..1e578f3deb 100644 --- a/gl/m4/extern-inline.m4 +++ b/gl/m4/extern-inline.m4 @@ -1,6 +1,6 @@ dnl 'extern inline' a la ISO C99. -dnl Copyright 2012-2015 Free Software Foundation, Inc. +dnl Copyright 2012-2016 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. @@ -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/fcntl-o.m4 b/gl/m4/fcntl-o.m4 index 891a62fb6a..24fcf88d09 100644 --- a/gl/m4/fcntl-o.m4 +++ b/gl/m4/fcntl-o.m4 @@ -1,5 +1,5 @@ # fcntl-o.m4 serial 4 -dnl Copyright (C) 2006, 2009-2015 Free Software Foundation, Inc. +dnl Copyright (C) 2006, 2009-2016 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/gl/m4/fcntl_h.m4 b/gl/m4/fcntl_h.m4 index b279162a17..ef0d78dde1 100644 --- a/gl/m4/fcntl_h.m4 +++ b/gl/m4/fcntl_h.m4 @@ -1,6 +1,6 @@ # serial 15 # Configure fcntl.h. -dnl Copyright (C) 2006-2007, 2009-2015 Free Software Foundation, Inc. +dnl Copyright (C) 2006-2007, 2009-2016 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/gl/m4/fdopen.m4 b/gl/m4/fdopen.m4 index 8c57b9931c..685a1bb9c9 100644 --- a/gl/m4/fdopen.m4 +++ b/gl/m4/fdopen.m4 @@ -1,5 +1,5 @@ # fdopen.m4 serial 3 -dnl Copyright (C) 2011-2015 Free Software Foundation, Inc. +dnl Copyright (C) 2011-2016 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/gl/m4/float_h.m4 b/gl/m4/float_h.m4 index e4853f3b09..e2887eb5c6 100644 --- a/gl/m4/float_h.m4 +++ b/gl/m4/float_h.m4 @@ -1,5 +1,5 @@ # float_h.m4 serial 9 -dnl Copyright (C) 2007, 2009-2015 Free Software Foundation, Inc. +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, dnl with or without modifications, as long as this notice is preserved. diff --git a/gl/m4/fpieee.m4 b/gl/m4/fpieee.m4 index a4e48997ed..e11ac9f09c 100644 --- a/gl/m4/fpieee.m4 +++ b/gl/m4/fpieee.m4 @@ -1,5 +1,5 @@ -# fpieee.m4 serial 2 -dnl Copyright (C) 2007, 2009-2015 Free Software Foundation, Inc. +# fpieee.m4 serial 2 -*- coding: utf-8 -*- +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, dnl with or without modifications, as long as this notice is preserved. diff --git a/gl/m4/fseeko.m4 b/gl/m4/fseeko.m4 index 84555e2cba..6c7f551bda 100644 --- a/gl/m4/fseeko.m4 +++ b/gl/m4/fseeko.m4 @@ -1,5 +1,5 @@ # fseeko.m4 serial 17 -dnl Copyright (C) 2007-2015 Free Software Foundation, Inc. +dnl Copyright (C) 2007-2016 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/gl/m4/fstat.m4 b/gl/m4/fstat.m4 index d6a928827e..29f9b81654 100644 --- a/gl/m4/fstat.m4 +++ b/gl/m4/fstat.m4 @@ -1,5 +1,5 @@ # fstat.m4 serial 4 -dnl Copyright (C) 2011-2015 Free Software Foundation, Inc. +dnl Copyright (C) 2011-2016 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/gl/m4/ftell.m4 b/gl/m4/ftell.m4 index 77989192dc..6701f0a76c 100644 --- a/gl/m4/ftell.m4 +++ b/gl/m4/ftell.m4 @@ -1,5 +1,5 @@ # ftell.m4 serial 3 -dnl Copyright (C) 2007, 2009-2015 Free Software Foundation, Inc. +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, dnl with or without modifications, as long as this notice is preserved. diff --git a/gl/m4/ftello.m4 b/gl/m4/ftello.m4 index 3825cf2d0f..3f4808bf37 100644 --- a/gl/m4/ftello.m4 +++ b/gl/m4/ftello.m4 @@ -1,5 +1,5 @@ # ftello.m4 serial 11 -dnl Copyright (C) 2007-2015 Free Software Foundation, Inc. +dnl Copyright (C) 2007-2016 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/gl/m4/func.m4 b/gl/m4/func.m4 index fcc74ff2c2..f537b157dd 100644 --- a/gl/m4/func.m4 +++ b/gl/m4/func.m4 @@ -1,5 +1,5 @@ # func.m4 serial 2 -dnl Copyright (C) 2008-2015 Free Software Foundation, Inc. +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, dnl with or without modifications, as long as this notice is preserved. diff --git a/gl/m4/getdelim.m4 b/gl/m4/getdelim.m4 index af9b1faa9a..a1a7dcc526 100644 --- a/gl/m4/getdelim.m4 +++ b/gl/m4/getdelim.m4 @@ -1,6 +1,6 @@ -# getdelim.m4 serial 10 +# getdelim.m4 serial 11 -dnl Copyright (C) 2005-2007, 2009-2015 Free Software Foundation, Inc. +dnl Copyright (C) 2005-2007, 2009-2016 Free Software Foundation, Inc. dnl dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -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 a35f3a295b..f44751cd4b 100644 --- a/gl/m4/getline.m4 +++ b/gl/m4/getline.m4 @@ -1,6 +1,6 @@ -# getline.m4 serial 26 +# getline.m4 serial 27 -dnl Copyright (C) 1998-2003, 2005-2007, 2009-2015 Free Software Foundation, +dnl Copyright (C) 1998-2003, 2005-2007, 2009-2016 Free Software Foundation, dnl Inc. dnl dnl This file is free software; the Free Software Foundation @@ -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/getpagesize.m4 b/gl/m4/getpagesize.m4 index 7057a21d0f..8902b7b56b 100644 --- a/gl/m4/getpagesize.m4 +++ b/gl/m4/getpagesize.m4 @@ -1,5 +1,5 @@ # getpagesize.m4 serial 9 -dnl Copyright (C) 2002, 2004-2005, 2007, 2009-2015 Free Software Foundation, +dnl Copyright (C) 2002, 2004-2005, 2007, 2009-2016 Free Software Foundation, dnl Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, diff --git a/gl/m4/gettimeofday.m4 b/gl/m4/gettimeofday.m4 index ce246e18bc..4ae5d63fe3 100644 --- a/gl/m4/gettimeofday.m4 +++ b/gl/m4/gettimeofday.m4 @@ -1,6 +1,6 @@ # serial 21 -# Copyright (C) 2001-2003, 2005, 2007, 2009-2015 Free Software Foundation, Inc. +# Copyright (C) 2001-2003, 2005, 2007, 2009-2016 Free Software Foundation, Inc. # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. diff --git a/gl/m4/gnulib-cache.m4 b/gl/m4/gnulib-cache.m4 index 1a0d96067f..ba1b6fb8a4 100644 --- a/gl/m4/gnulib-cache.m4 +++ b/gl/m4/gnulib-cache.m4 @@ -1,4 +1,4 @@ -# Copyright (C) 2002-2015 Free Software Foundation, Inc. +# Copyright (C) 2002-2016 Free Software Foundation, Inc. # # This file is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -27,7 +27,7 @@ # Specification in the form of a command-line invocation: -# gnulib-tool --import --dir=. --local-dir=gl/override --lib=libgnu --source-base=gl --m4-base=gl/m4 --doc-base=doc --tests-base=gl/tests --aux-dir=build-aux --with-tests --avoid=alignof-tests --avoid=lock-tests --avoid=lseek-tests --lgpl=2 --no-conditional-dependencies --libtool --macro-prefix=gl --no-vc-files --lgpl=2 alloca byteswap c-ctype extensions func gendocs getline gettext-h gettimeofday hash-pjw-bare havelib iconv intprops lib-msvc-compat lib-symbol-versions maintainer-makefile manywarnings memmem-simple minmax netdb netinet_in pmccabe2html read-file snprintf stdint strcase strndup strtok_r strverscmp sys_socket sys_stat time_r unistd valgrind-tests vasprintf vsnprintf warnings +# gnulib-tool --import --local-dir=gl/override --lib=libgnu --source-base=gl --m4-base=gl/m4 --doc-base=doc --tests-base=gl/tests --aux-dir=build-aux --with-tests --avoid=alignof-tests --avoid=lock-tests --avoid=lseek-tests --lgpl=2 --no-conditional-dependencies --libtool --macro-prefix=gl --no-vc-files --lgpl=2 alloca byteswap c-ctype extensions func gendocs getline gettext-h gettimeofday hash-pjw-bare havelib iconv intprops lib-msvc-compat lib-symbol-versions maintainer-makefile manywarnings memmem-simple minmax netdb netinet_in pmccabe2html read-file secure_getenv snprintf stdint strcase strndup strtok_r strverscmp sys_socket sys_stat time_r unistd valgrind-tests vasprintf vsnprintf warnings # Specification in the form of a few gnulib-tool.m4 macro invocations: gl_LOCAL_DIR([gl/override]) @@ -56,6 +56,7 @@ gl_MODULES([ netinet_in pmccabe2html read-file + secure_getenv snprintf stdint strcase diff --git a/gl/m4/gnulib-common.m4 b/gl/m4/gnulib-common.m4 index 40e82f6e27..f8454c8a01 100644 --- a/gl/m4/gnulib-common.m4 +++ b/gl/m4/gnulib-common.m4 @@ -1,5 +1,5 @@ # gnulib-common.m4 serial 36 -dnl Copyright (C) 2007-2015 Free Software Foundation, Inc. +dnl Copyright (C) 2007-2016 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. @@ -253,9 +253,10 @@ AC_DEFUN([gl_PROG_AR_RANLIB], [ dnl Minix 3 comes with two toolchains: The Amsterdam Compiler Kit compiler dnl as "cc", and GCC as "gcc". They have different object file formats and - dnl library formats. In particular, the GNU binutils programs ar, ranlib + dnl library formats. In particular, the GNU binutils programs ar and ranlib dnl produce libraries that work only with gcc, not with cc. AC_REQUIRE([AC_PROG_CC]) + AC_BEFORE([$0], [AM_PROG_AR]) AC_CACHE_CHECK([for Minix Amsterdam compiler], [gl_cv_c_amsterdam_compiler], [ AC_EGREP_CPP([Amsterdam], @@ -267,25 +268,37 @@ Amsterdam [gl_cv_c_amsterdam_compiler=yes], [gl_cv_c_amsterdam_compiler=no]) ]) - if test -z "$AR"; then - if test $gl_cv_c_amsterdam_compiler = yes; then + + dnl Don't compete with AM_PROG_AR's decision about AR/ARFLAGS if we are not + dnl building with __ACK__. + if test $gl_cv_c_amsterdam_compiler = yes; then + if test -z "$AR"; then AR='cc -c.a' - if test -z "$ARFLAGS"; then - ARFLAGS='-o' - fi - else - dnl Use the Automake-documented default values for AR and ARFLAGS, - dnl but prefer ${host}-ar over ar (useful for cross-compiling). - AC_CHECK_TOOL([AR], [ar], [ar]) - if test -z "$ARFLAGS"; then - ARFLAGS='cr' - fi fi - else if test -z "$ARFLAGS"; then - ARFLAGS='cr' + ARFLAGS='-o' fi + else + dnl AM_PROG_AR was added in automake v1.11.2. AM_PROG_AR does not AC_SUBST + dnl ARFLAGS variable (it is filed into Makefile.in directly by automake + dnl script on-demand, if not specified by ./configure of course). + dnl Don't AC_REQUIRE the AM_PROG_AR otherwise the code for __ACK__ above + dnl will be ignored. Also, pay attention to call AM_PROG_AR in else block + dnl because AM_PROG_AR is written so it could re-set AR variable even for + dnl __ACK__. It may seem like its easier to avoid calling the macro here, + dnl but we need to AC_SUBST both AR/ARFLAGS (thus those must have some good + dnl default value and automake should usually know them). + m4_ifdef([AM_PROG_AR], [AM_PROG_AR], [:]) + fi + + dnl In case the code above has not helped with setting AR/ARFLAGS, use + dnl Automake-documented default values for AR and ARFLAGS, but prefer + dnl ${host}-ar over ar (useful for cross-compiling). + AC_CHECK_TOOL([AR], [ar], [ar]) + if test -z "$ARFLAGS"; then + ARFLAGS='cr' fi + AC_SUBST([AR]) AC_SUBST([ARFLAGS]) if test -z "$RANLIB"; then diff --git a/gl/m4/gnulib-comp.m4 b/gl/m4/gnulib-comp.m4 index b5977951df..b4d6dff739 100644 --- a/gl/m4/gnulib-comp.m4 +++ b/gl/m4/gnulib-comp.m4 @@ -1,5 +1,5 @@ # DO NOT EDIT! GENERATED AUTOMATICALLY! -# Copyright (C) 2002-2015 Free Software Foundation, Inc. +# Copyright (C) 2002-2016 Free Software Foundation, Inc. # # This file is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -37,7 +37,11 @@ AC_DEFUN([gl_EARLY], m4_pattern_allow([^gl_ES$])dnl a valid locale name m4_pattern_allow([^gl_LIBOBJS$])dnl a variable m4_pattern_allow([^gl_LTLIBOBJS$])dnl a variable + + # Pre-early section. + AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) AC_REQUIRE([gl_PROG_AR_RANLIB]) + # Code from module absolute-header: # Code from module alloca: # Code from module alloca-opt: @@ -48,10 +52,11 @@ AC_DEFUN([gl_EARLY], # Code from module byteswap-tests: # Code from module c-ctype: # Code from module c-ctype-tests: + # Code from module ctype: + # Code from module ctype-tests: # Code from module errno: # Code from module errno-tests: # Code from module extensions: - AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) # Code from module extern-inline: # Code from module fcntl-h: # Code from module fcntl-h-tests: @@ -118,6 +123,7 @@ AC_DEFUN([gl_EARLY], # Code from module read-file: # Code from module read-file-tests: # Code from module realloc-posix: + # Code from module secure_getenv: # Code from module size_max: # Code from module snippet/_Noreturn: # Code from module snippet/arg-nonnull: @@ -293,11 +299,11 @@ AC_SUBST([LTALLOCA]) fi gl_STRING_MODULE_INDICATOR([memmem]) gl_MINMAX - gl_MSVC_INVAL + AC_REQUIRE([gl_MSVC_INVAL]) if test $HAVE_MSVC_INVALID_PARAMETER_HANDLER = 1; then AC_LIBOBJ([msvc-inval]) fi - gl_MSVC_NOTHROW + AC_REQUIRE([gl_MSVC_NOTHROW]) if test $HAVE_MSVC_INVALID_PARAMETER_HANDLER = 1; then AC_LIBOBJ([msvc-nothrow]) fi @@ -312,6 +318,12 @@ AC_SUBST([LTALLOCA]) AC_LIBOBJ([realloc]) fi gl_STDLIB_MODULE_INDICATOR([realloc-posix]) + gl_FUNC_SECURE_GETENV + if test $HAVE_SECURE_GETENV = 0; then + AC_LIBOBJ([secure_getenv]) + gl_PREREQ_SECURE_GETENV + fi + gl_STDLIB_MODULE_INDICATOR([secure_getenv]) gl_SIZE_MAX gl_FUNC_SNPRINTF gl_STDIO_MODULE_INDICATOR([snprintf]) @@ -433,6 +445,7 @@ changequote([, ])dnl AC_SUBST([gltests_WITNESS]) gl_module_indicator_condition=$gltests_WITNESS m4_pushdef([gl_MODULE_INDICATOR_CONDITION], [$gl_module_indicator_condition]) + gl_CTYPE_H gl_FCNTL_H gl_FUNC_FDOPEN if test $REPLACE_FDOPEN = 1; then @@ -608,6 +621,7 @@ AC_DEFUN([gl_FILE_LIST], [ lib/read-file.c lib/read-file.h lib/realloc.c + lib/secure_getenv.c lib/size_max.h lib/snprintf.c lib/stdalign.in.h @@ -648,6 +662,7 @@ AC_DEFUN([gl_FILE_LIST], [ m4/absolute-header.m4 m4/alloca.m4 m4/byteswap.m4 + m4/ctype.m4 m4/errno_h.m4 m4/exponentd.m4 m4/extensions.m4 @@ -697,6 +712,7 @@ AC_DEFUN([gl_FILE_LIST], [ m4/printf.m4 m4/read-file.m4 m4/realloc.m4 + m4/secure_getenv.m4 m4/size_max.m4 m4/snprintf.m4 m4/socklen.m4 @@ -743,6 +759,7 @@ AC_DEFUN([gl_FILE_LIST], [ tests/test-binary-io.sh tests/test-byteswap.c tests/test-c-ctype.c + tests/test-ctype.c tests/test-errno.c tests/test-fcntl-h.c tests/test-fdopen.c @@ -804,6 +821,7 @@ AC_DEFUN([gl_FILE_LIST], [ tests/zerosize-ptr.h tests=lib/binary-io.c tests=lib/binary-io.h + tests=lib/ctype.in.h tests=lib/fcntl.in.h tests=lib/fdopen.c tests=lib/fpucw.h diff --git a/gl/m4/gnulib-tool.m4 b/gl/m4/gnulib-tool.m4 index fede1fc3bd..0d2ee444b4 100644 --- a/gl/m4/gnulib-tool.m4 +++ b/gl/m4/gnulib-tool.m4 @@ -1,5 +1,5 @@ # gnulib-tool.m4 serial 2 -dnl Copyright (C) 2004-2005, 2009-2015 Free Software Foundation, Inc. +dnl Copyright (C) 2004-2005, 2009-2016 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/gl/m4/include_next.m4 b/gl/m4/include_next.m4 index 233d254e80..db0f2c0795 100644 --- a/gl/m4/include_next.m4 +++ b/gl/m4/include_next.m4 @@ -1,5 +1,5 @@ # include_next.m4 serial 23 -dnl Copyright (C) 2006-2015 Free Software Foundation, Inc. +dnl Copyright (C) 2006-2016 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/gl/m4/intmax_t.m4 b/gl/m4/intmax_t.m4 index 4bd8155c83..9559accabf 100644 --- a/gl/m4/intmax_t.m4 +++ b/gl/m4/intmax_t.m4 @@ -1,5 +1,5 @@ # intmax_t.m4 serial 8 -dnl Copyright (C) 1997-2004, 2006-2007, 2009-2015 Free Software Foundation, +dnl Copyright (C) 1997-2004, 2006-2007, 2009-2016 Free Software Foundation, dnl Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, diff --git a/gl/m4/inttypes-pri.m4 b/gl/m4/inttypes-pri.m4 index 0884e71e67..ae20183db4 100644 --- a/gl/m4/inttypes-pri.m4 +++ b/gl/m4/inttypes-pri.m4 @@ -1,5 +1,5 @@ # inttypes-pri.m4 serial 7 (gettext-0.18.2) -dnl Copyright (C) 1997-2002, 2006, 2008-2015 Free Software Foundation, Inc. +dnl Copyright (C) 1997-2002, 2006, 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, dnl with or without modifications, as long as this notice is preserved. diff --git a/gl/m4/inttypes.m4 b/gl/m4/inttypes.m4 index 4209ffd150..61cdb1a848 100644 --- a/gl/m4/inttypes.m4 +++ b/gl/m4/inttypes.m4 @@ -1,5 +1,5 @@ # inttypes.m4 serial 26 -dnl Copyright (C) 2006-2015 Free Software Foundation, Inc. +dnl Copyright (C) 2006-2016 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/gl/m4/inttypes_h.m4 b/gl/m4/inttypes_h.m4 index d0b5f5d982..76571199f3 100644 --- a/gl/m4/inttypes_h.m4 +++ b/gl/m4/inttypes_h.m4 @@ -1,5 +1,5 @@ # inttypes_h.m4 serial 10 -dnl Copyright (C) 1997-2004, 2006, 2008-2015 Free Software Foundation, Inc. +dnl Copyright (C) 1997-2004, 2006, 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, dnl with or without modifications, as long as this notice is preserved. diff --git a/gl/m4/largefile.m4 b/gl/m4/largefile.m4 index b7a6c48b68..8bbdfaac1d 100644 --- a/gl/m4/largefile.m4 +++ b/gl/m4/largefile.m4 @@ -1,6 +1,6 @@ # Enable large files on systems where this is not the default. -# Copyright 1992-1996, 1998-2015 Free Software Foundation, Inc. +# Copyright 1992-1996, 1998-2016 Free Software Foundation, Inc. # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. diff --git a/gl/m4/ld-output-def.m4 b/gl/m4/ld-output-def.m4 index c505ab2a2e..040a04fc02 100644 --- a/gl/m4/ld-output-def.m4 +++ b/gl/m4/ld-output-def.m4 @@ -1,5 +1,5 @@ # ld-output-def.m4 serial 2 -dnl Copyright (C) 2008-2015 Free Software Foundation, Inc. +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, dnl with or without modifications, as long as this notice is preserved. diff --git a/gl/m4/ld-version-script.m4 b/gl/m4/ld-version-script.m4 index 211d67b963..330c2ccf09 100644 --- a/gl/m4/ld-version-script.m4 +++ b/gl/m4/ld-version-script.m4 @@ -1,5 +1,5 @@ # ld-version-script.m4 serial 4 -dnl Copyright (C) 2008-2015 Free Software Foundation, Inc. +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, dnl with or without modifications, as long as this notice is preserved. diff --git a/gl/m4/lib-ld.m4 b/gl/m4/lib-ld.m4 index 91ca911709..6209de65d9 100644 --- a/gl/m4/lib-ld.m4 +++ b/gl/m4/lib-ld.m4 @@ -1,5 +1,5 @@ # lib-ld.m4 serial 6 -dnl Copyright (C) 1996-2003, 2009-2015 Free Software Foundation, Inc. +dnl Copyright (C) 1996-2003, 2009-2016 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/gl/m4/lib-link.m4 b/gl/m4/lib-link.m4 index d8d5d1f0e1..2f518553bc 100644 --- a/gl/m4/lib-link.m4 +++ b/gl/m4/lib-link.m4 @@ -1,5 +1,5 @@ # lib-link.m4 serial 26 (gettext-0.18.2) -dnl Copyright (C) 2001-2015 Free Software Foundation, Inc. +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, dnl with or without modifications, as long as this notice is preserved. diff --git a/gl/m4/lib-prefix.m4 b/gl/m4/lib-prefix.m4 index 0465f477c0..6851031d39 100644 --- a/gl/m4/lib-prefix.m4 +++ b/gl/m4/lib-prefix.m4 @@ -1,5 +1,5 @@ # lib-prefix.m4 serial 7 (gettext-0.18) -dnl Copyright (C) 2001-2005, 2008-2015 Free Software Foundation, Inc. +dnl Copyright (C) 2001-2005, 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, dnl with or without modifications, as long as this notice is preserved. diff --git a/gl/m4/longlong.m4 b/gl/m4/longlong.m4 index d57bc700d4..36d8b12421 100644 --- a/gl/m4/longlong.m4 +++ b/gl/m4/longlong.m4 @@ -1,5 +1,5 @@ # longlong.m4 serial 17 -dnl Copyright (C) 1999-2007, 2009-2015 Free Software Foundation, Inc. +dnl Copyright (C) 1999-2007, 2009-2016 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/gl/m4/lseek.m4 b/gl/m4/lseek.m4 index f337abf1a8..4a95440073 100644 --- a/gl/m4/lseek.m4 +++ b/gl/m4/lseek.m4 @@ -1,5 +1,5 @@ # lseek.m4 serial 10 -dnl Copyright (C) 2007, 2009-2015 Free Software Foundation, Inc. +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, dnl with or without modifications, as long as this notice is preserved. diff --git a/gl/m4/malloc.m4 b/gl/m4/malloc.m4 index 31368ab97f..c393690e27 100644 --- a/gl/m4/malloc.m4 +++ b/gl/m4/malloc.m4 @@ -1,13 +1,13 @@ -# malloc.m4 serial 14 -dnl Copyright (C) 2007, 2009-2015 Free Software Foundation, Inc. +# 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, 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 b4e38d9446..90823b0acf 100644 --- a/gl/m4/manywarnings.m4 +++ b/gl/m4/manywarnings.m4 @@ -1,5 +1,5 @@ -# manywarnings.m4 serial 7 -dnl Copyright (C) 2008-2015 Free Software Foundation, Inc. +# 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, dnl with or without modifications, as long as this notice is preserved. @@ -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/math_h.m4 b/gl/m4/math_h.m4 index 7d0f58346b..35d07ee5f5 100644 --- a/gl/m4/math_h.m4 +++ b/gl/m4/math_h.m4 @@ -1,5 +1,5 @@ # math_h.m4 serial 114 -dnl Copyright (C) 2007-2015 Free Software Foundation, Inc. +dnl Copyright (C) 2007-2016 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/gl/m4/memchr.m4 b/gl/m4/memchr.m4 index cb958d8626..25d32f0ec9 100644 --- a/gl/m4/memchr.m4 +++ b/gl/m4/memchr.m4 @@ -1,5 +1,5 @@ # memchr.m4 serial 12 -dnl Copyright (C) 2002-2004, 2009-2015 Free Software Foundation, Inc. +dnl Copyright (C) 2002-2004, 2009-2016 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/gl/m4/memmem.m4 b/gl/m4/memmem.m4 index b190a7cb9b..981ede76b4 100644 --- a/gl/m4/memmem.m4 +++ b/gl/m4/memmem.m4 @@ -1,5 +1,5 @@ # memmem.m4 serial 24 -dnl Copyright (C) 2002-2004, 2007-2015 Free Software Foundation, Inc. +dnl Copyright (C) 2002-2004, 2007-2016 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/gl/m4/minmax.m4 b/gl/m4/minmax.m4 index 0df832c833..9c43e6452c 100644 --- a/gl/m4/minmax.m4 +++ b/gl/m4/minmax.m4 @@ -1,5 +1,5 @@ # minmax.m4 serial 4 -dnl Copyright (C) 2005, 2009-2015 Free Software Foundation, Inc. +dnl Copyright (C) 2005, 2009-2016 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/gl/m4/mmap-anon.m4 b/gl/m4/mmap-anon.m4 index 92a88d05fb..853c89dc9b 100644 --- a/gl/m4/mmap-anon.m4 +++ b/gl/m4/mmap-anon.m4 @@ -1,5 +1,5 @@ # mmap-anon.m4 serial 10 -dnl Copyright (C) 2005, 2007, 2009-2015 Free Software Foundation, Inc. +dnl Copyright (C) 2005, 2007, 2009-2016 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/gl/m4/msvc-inval.m4 b/gl/m4/msvc-inval.m4 index 9446fa5850..f5e4c89309 100644 --- a/gl/m4/msvc-inval.m4 +++ b/gl/m4/msvc-inval.m4 @@ -1,5 +1,5 @@ # msvc-inval.m4 serial 1 -dnl Copyright (C) 2011-2015 Free Software Foundation, Inc. +dnl Copyright (C) 2011-2016 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/gl/m4/msvc-nothrow.m4 b/gl/m4/msvc-nothrow.m4 index 5d72a042da..58f5c0bc20 100644 --- a/gl/m4/msvc-nothrow.m4 +++ b/gl/m4/msvc-nothrow.m4 @@ -1,5 +1,5 @@ # msvc-nothrow.m4 serial 1 -dnl Copyright (C) 2011-2015 Free Software Foundation, Inc. +dnl Copyright (C) 2011-2016 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/gl/m4/multiarch.m4 b/gl/m4/multiarch.m4 index fc575c1d43..43b5d05750 100644 --- a/gl/m4/multiarch.m4 +++ b/gl/m4/multiarch.m4 @@ -1,5 +1,5 @@ # multiarch.m4 serial 7 -dnl Copyright (C) 2008-2015 Free Software Foundation, Inc. +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, dnl with or without modifications, as long as this notice is preserved. diff --git a/gl/m4/netdb_h.m4 b/gl/m4/netdb_h.m4 index fce208014c..4e5206cebe 100644 --- a/gl/m4/netdb_h.m4 +++ b/gl/m4/netdb_h.m4 @@ -1,5 +1,5 @@ # netdb_h.m4 serial 11 -dnl Copyright (C) 2008-2015 Free Software Foundation, Inc. +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, dnl with or without modifications, as long as this notice is preserved. diff --git a/gl/m4/netinet_in_h.m4 b/gl/m4/netinet_in_h.m4 index 42ac008442..93dcc68947 100644 --- a/gl/m4/netinet_in_h.m4 +++ b/gl/m4/netinet_in_h.m4 @@ -1,5 +1,5 @@ # netinet_in_h.m4 serial 5 -dnl Copyright (C) 2006-2015 Free Software Foundation, Inc. +dnl Copyright (C) 2006-2016 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/gl/m4/off_t.m4 b/gl/m4/off_t.m4 index 0eb14678be..282751b47b 100644 --- a/gl/m4/off_t.m4 +++ b/gl/m4/off_t.m4 @@ -1,5 +1,5 @@ # off_t.m4 serial 1 -dnl Copyright (C) 2012-2015 Free Software Foundation, Inc. +dnl Copyright (C) 2012-2016 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/gl/m4/printf.m4 b/gl/m4/printf.m4 index d06746aae7..e495e0cbc5 100644 --- a/gl/m4/printf.m4 +++ b/gl/m4/printf.m4 @@ -1,5 +1,5 @@ # printf.m4 serial 52 -dnl Copyright (C) 2003, 2007-2015 Free Software Foundation, Inc. +dnl Copyright (C) 2003, 2007-2016 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/gl/m4/read-file.m4 b/gl/m4/read-file.m4 index 67e50bd1e0..aa23b5840c 100644 --- a/gl/m4/read-file.m4 +++ b/gl/m4/read-file.m4 @@ -1,5 +1,5 @@ # read-file.m4 serial 3 -dnl Copyright (C) 2002-2006, 2009-2015 Free Software Foundation, Inc. +dnl Copyright (C) 2002-2006, 2009-2016 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/gl/m4/realloc.m4 b/gl/m4/realloc.m4 index 0e1d3386e7..fc2282544d 100644 --- a/gl/m4/realloc.m4 +++ b/gl/m4/realloc.m4 @@ -1,13 +1,13 @@ -# realloc.m4 serial 13 -dnl Copyright (C) 2007, 2009-2015 Free Software Foundation, Inc. +# 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, 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/secure_getenv.m4 b/gl/m4/secure_getenv.m4 new file mode 100644 index 0000000000..00194c8497 --- /dev/null +++ b/gl/m4/secure_getenv.m4 @@ -0,0 +1,25 @@ +# Look up an environment variable more securely. +dnl Copyright 2013-2016 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_FUNC_SECURE_GETENV], +[ + dnl Persuade glibc <stdlib.h> to declare secure_getenv(). + AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS]) + + AC_REQUIRE([gl_STDLIB_H_DEFAULTS]) + AC_CHECK_FUNCS_ONCE([secure_getenv]) + if test $ac_cv_func_secure_getenv = no; then + HAVE_SECURE_GETENV=0 + fi +]) + +# Prerequisites of lib/secure_getenv.c. +AC_DEFUN([gl_PREREQ_SECURE_GETENV], [ + AC_CHECK_FUNCS([__secure_getenv]) + if test $ac_cv_func___secure_getenv = no; then + AC_CHECK_FUNCS([issetugid]) + fi +]) diff --git a/gl/m4/size_max.m4 b/gl/m4/size_max.m4 index 186e3fddab..de69025d62 100644 --- a/gl/m4/size_max.m4 +++ b/gl/m4/size_max.m4 @@ -1,5 +1,5 @@ # size_max.m4 serial 10 -dnl Copyright (C) 2003, 2005-2006, 2008-2015 Free Software Foundation, Inc. +dnl Copyright (C) 2003, 2005-2006, 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, dnl with or without modifications, as long as this notice is preserved. diff --git a/gl/m4/snprintf.m4 b/gl/m4/snprintf.m4 index 8ae70050c8..f876b55995 100644 --- a/gl/m4/snprintf.m4 +++ b/gl/m4/snprintf.m4 @@ -1,5 +1,5 @@ # snprintf.m4 serial 6 -dnl Copyright (C) 2002-2004, 2007-2015 Free Software Foundation, Inc. +dnl Copyright (C) 2002-2004, 2007-2016 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/gl/m4/socklen.m4 b/gl/m4/socklen.m4 index bcabed3ef0..634c43a35c 100644 --- a/gl/m4/socklen.m4 +++ b/gl/m4/socklen.m4 @@ -1,5 +1,5 @@ # socklen.m4 serial 10 -dnl Copyright (C) 2005-2007, 2009-2015 Free Software Foundation, Inc. +dnl Copyright (C) 2005-2007, 2009-2016 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/gl/m4/sockpfaf.m4 b/gl/m4/sockpfaf.m4 index 50eb7619da..dce8b8f01e 100644 --- a/gl/m4/sockpfaf.m4 +++ b/gl/m4/sockpfaf.m4 @@ -1,5 +1,5 @@ # sockpfaf.m4 serial 8 -dnl Copyright (C) 2004, 2006, 2009-2015 Free Software Foundation, Inc. +dnl Copyright (C) 2004, 2006, 2009-2016 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/gl/m4/ssize_t.m4 b/gl/m4/ssize_t.m4 index 25bd451434..3e7b9e6e02 100644 --- a/gl/m4/ssize_t.m4 +++ b/gl/m4/ssize_t.m4 @@ -1,5 +1,5 @@ # ssize_t.m4 serial 5 (gettext-0.18.2) -dnl Copyright (C) 2001-2003, 2006, 2010-2015 Free Software Foundation, Inc. +dnl Copyright (C) 2001-2003, 2006, 2010-2016 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/gl/m4/stdalign.m4 b/gl/m4/stdalign.m4 index 033b0d39e4..49980cd636 100644 --- a/gl/m4/stdalign.m4 +++ b/gl/m4/stdalign.m4 @@ -1,6 +1,6 @@ # Check for stdalign.h that conforms to C11. -dnl Copyright 2011-2015 Free Software Foundation, Inc. +dnl Copyright 2011-2016 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/gl/m4/stdbool.m4 b/gl/m4/stdbool.m4 index 7273b82246..625520ff07 100644 --- a/gl/m4/stdbool.m4 +++ b/gl/m4/stdbool.m4 @@ -1,6 +1,6 @@ # Check for stdbool.h that conforms to C99. -dnl Copyright (C) 2002-2006, 2009-2015 Free Software Foundation, Inc. +dnl Copyright (C) 2002-2006, 2009-2016 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/gl/m4/stddef_h.m4 b/gl/m4/stddef_h.m4 index 231050274a..c045c65f9f 100644 --- a/gl/m4/stddef_h.m4 +++ b/gl/m4/stddef_h.m4 @@ -1,6 +1,6 @@ dnl A placeholder for <stddef.h>, for platforms that have issues. # stddef_h.m4 serial 5 -dnl Copyright (C) 2009-2015 Free Software Foundation, Inc. +dnl Copyright (C) 2009-2016 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/gl/m4/stdint.m4 b/gl/m4/stdint.m4 index 4011a4942a..0b4b9060db 100644 --- a/gl/m4/stdint.m4 +++ b/gl/m4/stdint.m4 @@ -1,5 +1,5 @@ -# stdint.m4 serial 43 -dnl Copyright (C) 2001-2015 Free Software Foundation, Inc. +# 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, dnl with or without modifications, as long as this notice is preserved. @@ -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/m4/stdint_h.m4 b/gl/m4/stdint_h.m4 index 5097c0b0dc..f823b94c33 100644 --- a/gl/m4/stdint_h.m4 +++ b/gl/m4/stdint_h.m4 @@ -1,5 +1,5 @@ # stdint_h.m4 serial 9 -dnl Copyright (C) 1997-2004, 2006, 2008-2015 Free Software Foundation, Inc. +dnl Copyright (C) 1997-2004, 2006, 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, dnl with or without modifications, as long as this notice is preserved. diff --git a/gl/m4/stdio_h.m4 b/gl/m4/stdio_h.m4 index f60cc2156e..0e387585d2 100644 --- a/gl/m4/stdio_h.m4 +++ b/gl/m4/stdio_h.m4 @@ -1,5 +1,5 @@ # stdio_h.m4 serial 46 -dnl Copyright (C) 2007-2015 Free Software Foundation, Inc. +dnl Copyright (C) 2007-2016 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/gl/m4/stdlib_h.m4 b/gl/m4/stdlib_h.m4 index 0b4c623ec7..19107c4199 100644 --- a/gl/m4/stdlib_h.m4 +++ b/gl/m4/stdlib_h.m4 @@ -1,5 +1,5 @@ # stdlib_h.m4 serial 42 -dnl Copyright (C) 2007-2015 Free Software Foundation, Inc. +dnl Copyright (C) 2007-2016 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/gl/m4/strcase.m4 b/gl/m4/strcase.m4 index ece6722aff..eefc047f7f 100644 --- a/gl/m4/strcase.m4 +++ b/gl/m4/strcase.m4 @@ -1,5 +1,5 @@ # strcase.m4 serial 11 -dnl Copyright (C) 2002, 2005-2015 Free Software Foundation, Inc. +dnl Copyright (C) 2002, 2005-2016 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/gl/m4/string_h.m4 b/gl/m4/string_h.m4 index 55d09ef407..0c5ec6f9a0 100644 --- a/gl/m4/string_h.m4 +++ b/gl/m4/string_h.m4 @@ -1,6 +1,6 @@ # Configure a GNU-like replacement for <string.h>. -# Copyright (C) 2007-2015 Free Software Foundation, Inc. +# Copyright (C) 2007-2016 Free Software Foundation, Inc. # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. diff --git a/gl/m4/strings_h.m4 b/gl/m4/strings_h.m4 index 28b754b6ef..62a62e20b3 100644 --- a/gl/m4/strings_h.m4 +++ b/gl/m4/strings_h.m4 @@ -1,7 +1,7 @@ # Configure a replacement for <strings.h>. # serial 6 -# Copyright (C) 2007, 2009-2015 Free Software Foundation, Inc. +# Copyright (C) 2007, 2009-2016 Free Software Foundation, Inc. # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. diff --git a/gl/m4/strndup.m4 b/gl/m4/strndup.m4 index e6e2300dec..ac48a228f4 100644 --- a/gl/m4/strndup.m4 +++ b/gl/m4/strndup.m4 @@ -1,5 +1,5 @@ -# strndup.m4 serial 21 -dnl Copyright (C) 2002-2003, 2005-2015 Free Software Foundation, Inc. +# strndup.m4 serial 22 +dnl Copyright (C) 2002-2003, 2005-2016 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. @@ -31,11 +31,14 @@ AC_DEFUN([gl_FUNC_STRNDUP], #endif char *strndup (const char *, size_t); #endif + int result; char *s; s = strndup ("some longer string", 15); free (s); s = strndup ("shorter string", 13); - return s[13] != '\0';]])], + result = s[13] != '\0'; + free (s); + return result;]])], [gl_cv_func_strndup_works=yes], [gl_cv_func_strndup_works=no], [ diff --git a/gl/m4/strnlen.m4 b/gl/m4/strnlen.m4 index 5f85d3fa7d..67b38597a8 100644 --- a/gl/m4/strnlen.m4 +++ b/gl/m4/strnlen.m4 @@ -1,5 +1,5 @@ # strnlen.m4 serial 13 -dnl Copyright (C) 2002-2003, 2005-2007, 2009-2015 Free Software Foundation, +dnl Copyright (C) 2002-2003, 2005-2007, 2009-2016 Free Software Foundation, dnl Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, diff --git a/gl/m4/strtok_r.m4 b/gl/m4/strtok_r.m4 index 9ed6a25c91..d010307bbc 100644 --- a/gl/m4/strtok_r.m4 +++ b/gl/m4/strtok_r.m4 @@ -1,5 +1,5 @@ # strtok_r.m4 serial 13 -dnl Copyright (C) 2002-2004, 2006-2007, 2009-2015 Free Software Foundation, +dnl Copyright (C) 2002-2004, 2006-2007, 2009-2016 Free Software Foundation, dnl Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, diff --git a/gl/m4/strverscmp.m4 b/gl/m4/strverscmp.m4 index c6c17d160b..5524294c2e 100644 --- a/gl/m4/strverscmp.m4 +++ b/gl/m4/strverscmp.m4 @@ -1,5 +1,5 @@ # strverscmp.m4 serial 8 -dnl Copyright (C) 2002, 2005-2015 Free Software Foundation, Inc. +dnl Copyright (C) 2002, 2005-2016 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/gl/m4/sys_socket_h.m4 b/gl/m4/sys_socket_h.m4 index eaeabe7d96..ae500c7605 100644 --- a/gl/m4/sys_socket_h.m4 +++ b/gl/m4/sys_socket_h.m4 @@ -1,5 +1,5 @@ # sys_socket_h.m4 serial 23 -dnl Copyright (C) 2005-2015 Free Software Foundation, Inc. +dnl Copyright (C) 2005-2016 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/gl/m4/sys_stat_h.m4 b/gl/m4/sys_stat_h.m4 index 6c909e816a..3d43b6f5ef 100644 --- a/gl/m4/sys_stat_h.m4 +++ b/gl/m4/sys_stat_h.m4 @@ -1,5 +1,5 @@ # sys_stat_h.m4 serial 28 -*- Autoconf -*- -dnl Copyright (C) 2006-2015 Free Software Foundation, Inc. +dnl Copyright (C) 2006-2016 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/gl/m4/sys_time_h.m4 b/gl/m4/sys_time_h.m4 index 28c8b1acbb..3061a9c185 100644 --- a/gl/m4/sys_time_h.m4 +++ b/gl/m4/sys_time_h.m4 @@ -1,7 +1,7 @@ # Configure a replacement for <sys/time.h>. # serial 8 -# Copyright (C) 2007, 2009-2015 Free Software Foundation, Inc. +# Copyright (C) 2007, 2009-2016 Free Software Foundation, Inc. # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. diff --git a/gl/m4/sys_types_h.m4 b/gl/m4/sys_types_h.m4 index 2232aece63..b0aabb4786 100644 --- a/gl/m4/sys_types_h.m4 +++ b/gl/m4/sys_types_h.m4 @@ -1,5 +1,5 @@ # sys_types_h.m4 serial 5 -dnl Copyright (C) 2011-2015 Free Software Foundation, Inc. +dnl Copyright (C) 2011-2016 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/gl/m4/sys_uio_h.m4 b/gl/m4/sys_uio_h.m4 index 3dfbcbe6e6..d4d967fd57 100644 --- a/gl/m4/sys_uio_h.m4 +++ b/gl/m4/sys_uio_h.m4 @@ -1,5 +1,5 @@ # sys_uio_h.m4 serial 1 -dnl Copyright (C) 2011-2015 Free Software Foundation, Inc. +dnl Copyright (C) 2011-2016 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/gl/m4/time_h.m4 b/gl/m4/time_h.m4 index 754b469a0d..eb2a631e2c 100644 --- a/gl/m4/time_h.m4 +++ b/gl/m4/time_h.m4 @@ -1,6 +1,6 @@ # Configure a more-standard replacement for <time.h>. -# Copyright (C) 2000-2001, 2003-2007, 2009-2015 Free Software Foundation, Inc. +# Copyright (C) 2000-2001, 2003-2007, 2009-2016 Free Software Foundation, Inc. # serial 9 diff --git a/gl/m4/time_r.m4 b/gl/m4/time_r.m4 index 8df7e139cf..21b4a2cc18 100644 --- a/gl/m4/time_r.m4 +++ b/gl/m4/time_r.m4 @@ -1,6 +1,6 @@ dnl Reentrant time functions: localtime_r, gmtime_r. -dnl Copyright (C) 2003, 2006-2015 Free Software Foundation, Inc. +dnl Copyright (C) 2003, 2006-2016 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/gl/m4/ungetc.m4 b/gl/m4/ungetc.m4 index 2a34b3019f..e5d10eb9ff 100644 --- a/gl/m4/ungetc.m4 +++ b/gl/m4/ungetc.m4 @@ -1,5 +1,5 @@ # ungetc.m4 serial 3 -dnl Copyright (C) 2009-2015 Free Software Foundation, Inc. +dnl Copyright (C) 2009-2016 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/gl/m4/unistd_h.m4 b/gl/m4/unistd_h.m4 index b3c581f7b2..544dadb412 100644 --- a/gl/m4/unistd_h.m4 +++ b/gl/m4/unistd_h.m4 @@ -1,5 +1,5 @@ # unistd_h.m4 serial 68 -dnl Copyright (C) 2006-2015 Free Software Foundation, Inc. +dnl Copyright (C) 2006-2016 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/gl/m4/valgrind-tests.m4 b/gl/m4/valgrind-tests.m4 index 19601e002c..b80bda60bc 100644 --- a/gl/m4/valgrind-tests.m4 +++ b/gl/m4/valgrind-tests.m4 @@ -1,5 +1,5 @@ # valgrind-tests.m4 serial 3 -dnl Copyright (C) 2008-2015 Free Software Foundation, Inc. +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, dnl with or without modifications, as long as this notice is preserved. diff --git a/gl/m4/vasnprintf.m4 b/gl/m4/vasnprintf.m4 index 4708f2b8e2..2d4b46310b 100644 --- a/gl/m4/vasnprintf.m4 +++ b/gl/m4/vasnprintf.m4 @@ -1,5 +1,5 @@ # vasnprintf.m4 serial 36 -dnl Copyright (C) 2002-2004, 2006-2015 Free Software Foundation, Inc. +dnl Copyright (C) 2002-2004, 2006-2016 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/gl/m4/vasprintf.m4 b/gl/m4/vasprintf.m4 index b785dc3289..d7866b1929 100644 --- a/gl/m4/vasprintf.m4 +++ b/gl/m4/vasprintf.m4 @@ -1,5 +1,5 @@ # vasprintf.m4 serial 6 -dnl Copyright (C) 2002-2003, 2006-2007, 2009-2015 Free Software Foundation, +dnl Copyright (C) 2002-2003, 2006-2007, 2009-2016 Free Software Foundation, dnl Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, diff --git a/gl/m4/vsnprintf.m4 b/gl/m4/vsnprintf.m4 index 28be6fd186..e056f05cd5 100644 --- a/gl/m4/vsnprintf.m4 +++ b/gl/m4/vsnprintf.m4 @@ -1,5 +1,5 @@ # vsnprintf.m4 serial 6 -dnl Copyright (C) 2002-2004, 2007-2015 Free Software Foundation, Inc. +dnl Copyright (C) 2002-2004, 2007-2016 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/gl/m4/warn-on-use.m4 b/gl/m4/warn-on-use.m4 index 1e98dc9b77..08440ec593 100644 --- a/gl/m4/warn-on-use.m4 +++ b/gl/m4/warn-on-use.m4 @@ -1,5 +1,5 @@ # warn-on-use.m4 serial 5 -dnl Copyright (C) 2010-2015 Free Software Foundation, Inc. +dnl Copyright (C) 2010-2016 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/gl/m4/warnings.m4 b/gl/m4/warnings.m4 index 5ae01def13..924e21d5e8 100644 --- a/gl/m4/warnings.m4 +++ b/gl/m4/warnings.m4 @@ -1,5 +1,5 @@ # warnings.m4 serial 11 -dnl Copyright (C) 2008-2015 Free Software Foundation, Inc. +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, dnl with or without modifications, as long as this notice is preserved. diff --git a/gl/m4/wchar_h.m4 b/gl/m4/wchar_h.m4 index 9d1b0f8b6d..b40b73237d 100644 --- a/gl/m4/wchar_h.m4 +++ b/gl/m4/wchar_h.m4 @@ -1,6 +1,6 @@ dnl A placeholder for ISO C99 <wchar.h>, for platforms that have issues. -dnl Copyright (C) 2007-2015 Free Software Foundation, Inc. +dnl Copyright (C) 2007-2016 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/gl/m4/wchar_t.m4 b/gl/m4/wchar_t.m4 index dc964e67e2..2db8c3f2f6 100644 --- a/gl/m4/wchar_t.m4 +++ b/gl/m4/wchar_t.m4 @@ -1,5 +1,5 @@ # wchar_t.m4 serial 4 (gettext-0.18.2) -dnl Copyright (C) 2002-2003, 2008-2015 Free Software Foundation, Inc. +dnl Copyright (C) 2002-2003, 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, dnl with or without modifications, as long as this notice is preserved. diff --git a/gl/m4/wint_t.m4 b/gl/m4/wint_t.m4 index ca3fd449a1..8ff2a5b5a2 100644 --- a/gl/m4/wint_t.m4 +++ b/gl/m4/wint_t.m4 @@ -1,5 +1,5 @@ # wint_t.m4 serial 5 (gettext-0.18.2) -dnl Copyright (C) 2003, 2007-2015 Free Software Foundation, Inc. +dnl Copyright (C) 2003, 2007-2016 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/gl/m4/xsize.m4 b/gl/m4/xsize.m4 index 98faf7de0b..16764e89dd 100644 --- a/gl/m4/xsize.m4 +++ b/gl/m4/xsize.m4 @@ -1,5 +1,5 @@ # xsize.m4 serial 5 -dnl Copyright (C) 2003-2004, 2008-2015 Free Software Foundation, Inc. +dnl Copyright (C) 2003-2004, 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, dnl with or without modifications, as long as this notice is preserved. diff --git a/gl/malloc.c b/gl/malloc.c index e1c1880c47..ce1e6869d9 100644 --- a/gl/malloc.c +++ b/gl/malloc.c @@ -1,6 +1,6 @@ /* malloc() function that is glibc compatible. - Copyright (C) 1997-1998, 2006-2007, 2009-2015 Free Software Foundation, Inc. + Copyright (C) 1997-1998, 2006-2007, 2009-2016 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by diff --git a/gl/memchr.c b/gl/memchr.c index 5be1bb7afd..4865cb8c77 100644 --- a/gl/memchr.c +++ b/gl/memchr.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991, 1993, 1996-1997, 1999-2000, 2003-2004, 2006, 2008-2015 +/* Copyright (C) 1991, 1993, 1996-1997, 1999-2000, 2003-2004, 2006, 2008-2016 Free Software Foundation, Inc. Based on strlen implementation by Torbjorn Granlund (tege@sics.se), diff --git a/gl/memmem.c b/gl/memmem.c index 658b165e4e..407af7e317 100644 --- a/gl/memmem.c +++ b/gl/memmem.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991-1994, 1996-1998, 2000, 2004, 2007-2015 Free Software +/* Copyright (C) 1991-1994, 1996-1998, 2000, 2004, 2007-2016 Free Software Foundation, Inc. This file is part of the GNU C Library. diff --git a/gl/minmax.h b/gl/minmax.h index 0d87ef3d4b..971bd38a34 100644 --- a/gl/minmax.h +++ b/gl/minmax.h @@ -1,5 +1,5 @@ /* MIN, MAX macros. - Copyright (C) 1995, 1998, 2001, 2003, 2005, 2009-2015 Free Software + Copyright (C) 1995, 1998, 2001, 2003, 2005, 2009-2016 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify diff --git a/gl/msvc-inval.c b/gl/msvc-inval.c index acec415288..add72b0ca5 100644 --- a/gl/msvc-inval.c +++ b/gl/msvc-inval.c @@ -1,5 +1,5 @@ /* Invalid parameter handler for MSVC runtime libraries. - Copyright (C) 2011-2015 Free Software Foundation, Inc. + Copyright (C) 2011-2016 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by diff --git a/gl/msvc-inval.h b/gl/msvc-inval.h index 544283c9bc..e2bc97787b 100644 --- a/gl/msvc-inval.h +++ b/gl/msvc-inval.h @@ -1,5 +1,5 @@ /* Invalid parameter handler for MSVC runtime libraries. - Copyright (C) 2011-2015 Free Software Foundation, Inc. + Copyright (C) 2011-2016 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by diff --git a/gl/msvc-nothrow.c b/gl/msvc-nothrow.c index dc8f6e091e..d36b1e0b93 100644 --- a/gl/msvc-nothrow.c +++ b/gl/msvc-nothrow.c @@ -1,6 +1,6 @@ /* Wrappers that don't throw invalid parameter notifications with MSVC runtime libraries. - Copyright (C) 2011-2015 Free Software Foundation, Inc. + Copyright (C) 2011-2016 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by diff --git a/gl/msvc-nothrow.h b/gl/msvc-nothrow.h index c75799c5b6..7dc914b0c3 100644 --- a/gl/msvc-nothrow.h +++ b/gl/msvc-nothrow.h @@ -1,6 +1,6 @@ /* Wrappers that don't throw invalid parameter notifications with MSVC runtime libraries. - Copyright (C) 2011-2015 Free Software Foundation, Inc. + Copyright (C) 2011-2016 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by diff --git a/gl/netdb.in.h b/gl/netdb.in.h index fe269a4c8e..055925928e 100644 --- a/gl/netdb.in.h +++ b/gl/netdb.in.h @@ -1,5 +1,5 @@ /* Provide a netdb.h header file for systems lacking it (read: MinGW). - Copyright (C) 2008-2015 Free Software Foundation, Inc. + Copyright (C) 2008-2016 Free Software Foundation, Inc. Written by Simon Josefsson. This program is free software; you can redistribute it and/or modify diff --git a/gl/netinet_in.in.h b/gl/netinet_in.in.h index 1a87ce7b55..4411af3cf8 100644 --- a/gl/netinet_in.in.h +++ b/gl/netinet_in.in.h @@ -1,5 +1,5 @@ /* Substitute for <netinet/in.h>. - Copyright (C) 2007-2015 Free Software Foundation, Inc. + Copyright (C) 2007-2016 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by diff --git a/gl/printf-args.c b/gl/printf-args.c index 4475d60ec1..aabe48349c 100644 --- a/gl/printf-args.c +++ b/gl/printf-args.c @@ -1,5 +1,5 @@ /* Decomposed printf argument list. - Copyright (C) 1999, 2002-2003, 2005-2007, 2009-2015 Free Software + Copyright (C) 1999, 2002-2003, 2005-2007, 2009-2016 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify diff --git a/gl/printf-args.h b/gl/printf-args.h index 7363ccc18f..f58bf0864c 100644 --- a/gl/printf-args.h +++ b/gl/printf-args.h @@ -1,5 +1,5 @@ /* Decomposed printf argument list. - Copyright (C) 1999, 2002-2003, 2006-2007, 2011-2015 Free Software + Copyright (C) 1999, 2002-2003, 2006-2007, 2011-2016 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify diff --git a/gl/printf-parse.c b/gl/printf-parse.c index ab21cfdb5f..7c14a6ddc5 100644 --- a/gl/printf-parse.c +++ b/gl/printf-parse.c @@ -1,5 +1,5 @@ /* Formatted output to strings. - Copyright (C) 1999-2000, 2002-2003, 2006-2015 Free Software Foundation, Inc. + Copyright (C) 1999-2000, 2002-2003, 2006-2016 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by diff --git a/gl/printf-parse.h b/gl/printf-parse.h index 366266020e..887cde4eb3 100644 --- a/gl/printf-parse.h +++ b/gl/printf-parse.h @@ -1,5 +1,5 @@ /* Parse printf format string. - Copyright (C) 1999, 2002-2003, 2005, 2007, 2010-2015 Free Software + Copyright (C) 1999, 2002-2003, 2005, 2007, 2010-2016 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify diff --git a/gl/read-file.c b/gl/read-file.c index a648380115..56d6c72c0f 100644 --- a/gl/read-file.c +++ b/gl/read-file.c @@ -1,5 +1,5 @@ /* read-file.c -- read file contents into a string - Copyright (C) 2006, 2009-2015 Free Software Foundation, Inc. + Copyright (C) 2006, 2009-2016 Free Software Foundation, Inc. Written by Simon Josefsson and Bruno Haible. This program is free software; you can redistribute it and/or modify diff --git a/gl/read-file.h b/gl/read-file.h index 165583c80b..078be42078 100644 --- a/gl/read-file.h +++ b/gl/read-file.h @@ -1,5 +1,5 @@ /* read-file.h -- read file contents into a string - Copyright (C) 2006, 2009-2015 Free Software Foundation, Inc. + Copyright (C) 2006, 2009-2016 Free Software Foundation, Inc. Written by Simon Josefsson. This program is free software; you can redistribute it and/or modify diff --git a/gl/realloc.c b/gl/realloc.c index d9774861b0..5653e7ae89 100644 --- a/gl/realloc.c +++ b/gl/realloc.c @@ -1,6 +1,6 @@ /* realloc() function that is glibc compatible. - Copyright (C) 1997, 2003-2004, 2006-2007, 2009-2015 Free Software + Copyright (C) 1997, 2003-2004, 2006-2007, 2009-2016 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify diff --git a/gl/secure_getenv.c b/gl/secure_getenv.c new file mode 100644 index 0000000000..896ceeefeb --- /dev/null +++ b/gl/secure_getenv.c @@ -0,0 +1,41 @@ +/* Look up an environment variable more securely. + + Copyright 2013-2016 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify it + under the terms of the GNU Lesser General Public License as published + by the Free Software Foundation; either version 2.1 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. */ + +#include <config.h> + +#include <stdlib.h> + +#if !HAVE___SECURE_GETENV +# if HAVE_ISSETUGID +# include <unistd.h> +# else +# undef issetugid +# define issetugid() 1 +# endif +#endif + +char * +secure_getenv (char const *name) +{ +#if HAVE___SECURE_GETENV + return __secure_getenv (name); +#else + if (issetugid ()) + return 0; + return getenv (name); +#endif +} diff --git a/gl/size_max.h b/gl/size_max.h index b7a99a580d..5e89e69be4 100644 --- a/gl/size_max.h +++ b/gl/size_max.h @@ -1,5 +1,5 @@ /* size_max.h -- declare SIZE_MAX through system headers - Copyright (C) 2005-2006, 2009-2015 Free Software Foundation, Inc. + Copyright (C) 2005-2006, 2009-2016 Free Software Foundation, Inc. Written by Simon Josefsson. This program is free software; you can redistribute it and/or modify diff --git a/gl/snprintf.c b/gl/snprintf.c index bccb6521ca..070485b0db 100644 --- a/gl/snprintf.c +++ b/gl/snprintf.c @@ -1,5 +1,5 @@ /* Formatted output to strings. - Copyright (C) 2004, 2006-2015 Free Software Foundation, Inc. + Copyright (C) 2004, 2006-2016 Free Software Foundation, Inc. Written by Simon Josefsson and Paul Eggert. This program is free software; you can redistribute it and/or modify diff --git a/gl/stdalign.in.h b/gl/stdalign.in.h index 39873a7d29..9aac795a9e 100644 --- a/gl/stdalign.in.h +++ b/gl/stdalign.in.h @@ -1,6 +1,6 @@ /* A substitute for ISO C11 <stdalign.h>. - Copyright 2011-2015 Free Software Foundation, Inc. + Copyright 2011-2016 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by @@ -52,7 +52,10 @@ #undef _Alignas #undef _Alignof -#if !defined __STDC_VERSION__ || __STDC_VERSION__ < 201112 +/* GCC releases before GCC 4.9 had a bug in _Alignof. See GCC bug 52023 + <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52023>. */ +#if (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112 \ + || (defined __GNUC__ && __GNUC__ < 4 + (__GNUC_MINOR__ < 9))) # ifdef __cplusplus # if 201103 <= __cplusplus # define _Alignof(type) alignof (type) @@ -64,7 +67,9 @@ # define _Alignof(type) offsetof (struct { char __a; type __b; }, __b) # endif #endif -#define alignof _Alignof +#if ! (defined __cplusplus && 201103 <= __cplusplus) +# define alignof _Alignof +#endif #define __alignof_is_defined 1 /* alignas (A), also known as _Alignas (A), aligns a variable or type @@ -98,15 +103,18 @@ # elif ((defined __APPLE__ && defined __MACH__ \ ? 4 < __GNUC__ + (1 <= __GNUC_MINOR__) \ : __GNUC__) \ - || __HP_cc || __HP_aCC || __IBMC__ || __IBMCPP__ \ - || __ICC || 0x5110 <= __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 __STDC_VERSION && 201112 <= __STDC_VERSION__) +#if ((defined _Alignas && ! (defined __cplusplus && 201103 <= __cplusplus)) \ + || (defined __STDC_VERSION__ && 201112 <= __STDC_VERSION__)) # define alignas _Alignas +#endif +#if defined alignas || (defined __cplusplus && 201103 <= __cplusplus) # define __alignas_is_defined 1 #endif diff --git a/gl/stdbool.in.h b/gl/stdbool.in.h index 2bd9ec0279..25a76d37b9 100644 --- a/gl/stdbool.in.h +++ b/gl/stdbool.in.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2001-2003, 2006-2015 Free Software Foundation, Inc. +/* Copyright (C) 2001-2003, 2006-2016 Free Software Foundation, Inc. Written by Bruno Haible <haible@clisp.cons.org>, 2001. This program is free software; you can redistribute it and/or modify diff --git a/gl/stddef.in.h b/gl/stddef.in.h index 5398faf78b..a400474bd1 100644 --- a/gl/stddef.in.h +++ b/gl/stddef.in.h @@ -1,6 +1,6 @@ /* A substitute for POSIX 2008 <stddef.h>, for platforms that have issues. - Copyright (C) 2009-2015 Free Software Foundation, Inc. + Copyright (C) 2009-2016 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by @@ -81,8 +81,10 @@ # define wchar_t int #endif -/* Some platforms lack max_align_t. */ -#if !@HAVE_MAX_ALIGN_T@ +/* 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 6608d5fe08..35a41bb7d7 100644 --- a/gl/stdint.in.h +++ b/gl/stdint.in.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2001-2002, 2004-2015 Free Software Foundation, Inc. +/* Copyright (C) 2001-2002, 2004-2016 Free Software Foundation, Inc. Written by Paul Eggert, Bruno Haible, Sam Steingold, Peter Burwood. This file is part of gnulib. @@ -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/stdio-impl.h b/gl/stdio-impl.h index bf6e7c828b..4c02c9f614 100644 --- a/gl/stdio-impl.h +++ b/gl/stdio-impl.h @@ -1,5 +1,5 @@ /* Implementation details of FILE streams. - Copyright (C) 2007-2008, 2010-2015 Free Software Foundation, Inc. + Copyright (C) 2007-2008, 2010-2016 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by diff --git a/gl/stdio.in.h b/gl/stdio.in.h index 5ba9413269..8db24a8fc5 100644 --- a/gl/stdio.in.h +++ b/gl/stdio.in.h @@ -1,6 +1,6 @@ /* A GNU-like <stdio.h>. - Copyright (C) 2004, 2007-2015 Free Software Foundation, Inc. + Copyright (C) 2004, 2007-2016 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by diff --git a/gl/stdlib.in.h b/gl/stdlib.in.h index 2a09628f65..ab0b614f6c 100644 --- a/gl/stdlib.in.h +++ b/gl/stdlib.in.h @@ -1,6 +1,6 @@ /* A GNU-like <stdlib.h>. - Copyright (C) 1995, 2001-2004, 2006-2015 Free Software Foundation, Inc. + Copyright (C) 1995, 2001-2004, 2006-2016 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by diff --git a/gl/str-two-way.h b/gl/str-two-way.h index 0d59e9bf77..43b5a7e2b6 100644 --- a/gl/str-two-way.h +++ b/gl/str-two-way.h @@ -1,5 +1,5 @@ /* Byte-wise substring search, using the Two-Way algorithm. - Copyright (C) 2008-2015 Free Software Foundation, Inc. + Copyright (C) 2008-2016 Free Software Foundation, Inc. This file is part of the GNU C Library. Written by Eric Blake <ebb9@byu.net>, 2008. diff --git a/gl/strcasecmp.c b/gl/strcasecmp.c index 4f994bff74..1c3fabc76d 100644 --- a/gl/strcasecmp.c +++ b/gl/strcasecmp.c @@ -1,5 +1,5 @@ /* Case-insensitive string comparison function. - Copyright (C) 1998-1999, 2005-2007, 2009-2015 Free Software Foundation, Inc. + Copyright (C) 1998-1999, 2005-2007, 2009-2016 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by diff --git a/gl/string.in.h b/gl/string.in.h index 47e11883ec..c6f610d207 100644 --- a/gl/string.in.h +++ b/gl/string.in.h @@ -1,6 +1,6 @@ /* A GNU-like <string.h>. - Copyright (C) 1995-1996, 2001-2015 Free Software Foundation, Inc. + Copyright (C) 1995-1996, 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 Lesser General Public License as published by diff --git a/gl/strings.in.h b/gl/strings.in.h index ee43813ed6..7d93355650 100644 --- a/gl/strings.in.h +++ b/gl/strings.in.h @@ -1,6 +1,6 @@ /* A substitute <strings.h>. - Copyright (C) 2007-2015 Free Software Foundation, Inc. + Copyright (C) 2007-2016 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by diff --git a/gl/strncasecmp.c b/gl/strncasecmp.c index dda3a3dcf7..d9f22533ed 100644 --- a/gl/strncasecmp.c +++ b/gl/strncasecmp.c @@ -1,5 +1,5 @@ /* strncasecmp.c -- case insensitive string comparator - Copyright (C) 1998-1999, 2005-2007, 2009-2015 Free Software Foundation, Inc. + Copyright (C) 1998-1999, 2005-2007, 2009-2016 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by diff --git a/gl/strndup.c b/gl/strndup.c index 058137ae43..2d7fd400a3 100644 --- a/gl/strndup.c +++ b/gl/strndup.c @@ -1,6 +1,6 @@ /* A replacement function, for systems that lack strndup. - Copyright (C) 1996-1998, 2001-2003, 2005-2007, 2009-2015 Free Software + Copyright (C) 1996-1998, 2001-2003, 2005-2007, 2009-2016 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it diff --git a/gl/strnlen.c b/gl/strnlen.c index 032ba55097..3a7492e6e2 100644 --- a/gl/strnlen.c +++ b/gl/strnlen.c @@ -1,5 +1,5 @@ /* Find the length of STRING, but scan at most MAXLEN characters. - Copyright (C) 2005-2007, 2009-2015 Free Software Foundation, Inc. + Copyright (C) 2005-2007, 2009-2016 Free Software Foundation, Inc. Written by Simon Josefsson. This program is free software; you can redistribute it and/or modify diff --git a/gl/strtok_r.c b/gl/strtok_r.c index 6e3cb76614..9cae5c61a6 100644 --- a/gl/strtok_r.c +++ b/gl/strtok_r.c @@ -1,5 +1,5 @@ /* Reentrant string tokenizer. Generic version. - Copyright (C) 1991, 1996-1999, 2001, 2004, 2007, 2009-2015 Free Software + Copyright (C) 1991, 1996-1999, 2001, 2004, 2007, 2009-2016 Free Software Foundation, Inc. This file is part of the GNU C Library. diff --git a/gl/strverscmp.c b/gl/strverscmp.c index 9e4f00da5a..f1e3594d1d 100644 --- a/gl/strverscmp.c +++ b/gl/strverscmp.c @@ -1,5 +1,5 @@ -/* Compare strings while treating digits characters numerically. - Copyright (C) 1997, 2000, 2002, 2004, 2006, 2009-2015 Free Software +/* Compare strings while treating digits numerically. -*- coding: utf-8 -*- + Copyright (C) 1997, 2000, 2002, 2004, 2006, 2009-2016 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Jean-François Bignolles <bignolle@ecoledoc.ibp.fr>, 1997. diff --git a/gl/sys_socket.c b/gl/sys_socket.c index 3f017f8fc6..3b261da039 100644 --- a/gl/sys_socket.c +++ b/gl/sys_socket.c @@ -1,3 +1,4 @@ #include <config.h> #define _GL_SYS_SOCKET_INLINE _GL_EXTERN_INLINE #include "sys/socket.h" +typedef int dummy; diff --git a/gl/sys_socket.in.h b/gl/sys_socket.in.h index 243eda27c0..d99d831d48 100644 --- a/gl/sys_socket.in.h +++ b/gl/sys_socket.in.h @@ -1,6 +1,6 @@ /* Provide a sys/socket header file for systems lacking it (read: MinGW) and for systems where it is incomplete. - Copyright (C) 2005-2015 Free Software Foundation, Inc. + Copyright (C) 2005-2016 Free Software Foundation, Inc. Written by Simon Josefsson. This program is free software; you can redistribute it and/or modify diff --git a/gl/sys_stat.in.h b/gl/sys_stat.in.h index 746b858cbe..6a6f2e6d7c 100644 --- a/gl/sys_stat.in.h +++ b/gl/sys_stat.in.h @@ -1,5 +1,5 @@ /* Provide a more complete sys/stat header file. - Copyright (C) 2005-2015 Free Software Foundation, Inc. + Copyright (C) 2005-2016 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by diff --git a/gl/sys_time.in.h b/gl/sys_time.in.h index 046b3a2528..a005712a27 100644 --- a/gl/sys_time.in.h +++ b/gl/sys_time.in.h @@ -1,6 +1,6 @@ /* Provide a more complete sys/time.h. - Copyright (C) 2007-2015 Free Software Foundation, Inc. + Copyright (C) 2007-2016 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by diff --git a/gl/sys_types.in.h b/gl/sys_types.in.h index 188b1d3fbe..8a795e56c5 100644 --- a/gl/sys_types.in.h +++ b/gl/sys_types.in.h @@ -1,6 +1,6 @@ /* Provide a more complete sys/types.h. - Copyright (C) 2011-2015 Free Software Foundation, Inc. + Copyright (C) 2011-2016 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by diff --git a/gl/sys_uio.in.h b/gl/sys_uio.in.h index 53411bcd0e..479dc31dae 100644 --- a/gl/sys_uio.in.h +++ b/gl/sys_uio.in.h @@ -1,5 +1,5 @@ /* Substitute for <sys/uio.h>. - Copyright (C) 2011-2015 Free Software Foundation, Inc. + Copyright (C) 2011-2016 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by diff --git a/gl/tests/Makefile.am b/gl/tests/Makefile.am index 6bcd811d15..fc5fd048fc 100644 --- a/gl/tests/Makefile.am +++ b/gl/tests/Makefile.am @@ -1,6 +1,6 @@ ## DO NOT EDIT! GENERATED AUTOMATICALLY! ## Process this file with automake to produce Makefile.in. -# Copyright (C) 2002-2015 Free Software Foundation, Inc. +# Copyright (C) 2002-2016 Free Software Foundation, Inc. # # This file is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -94,11 +94,45 @@ EXTRA_DIST += test-byteswap.c macros.h TESTS += test-c-ctype check_PROGRAMS += test-c-ctype - EXTRA_DIST += test-c-ctype.c macros.h ## end gnulib module c-ctype-tests +## begin gnulib module ctype + +BUILT_SOURCES += ctype.h + +# We need the following in order to create <ctype.h> when the system +# doesn't have one that works with the given compiler. +ctype.h: ctype.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(WARN_ON_USE_H) + $(AM_V_GEN)rm -f $@-t $@ && \ + { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ + sed -e 's|@''GUARD_PREFIX''@|GL|g' \ + -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ + -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ + -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ + -e 's|@''NEXT_CTYPE_H''@|$(NEXT_CTYPE_H)|g' \ + -e 's/@''GNULIB_ISBLANK''@/$(GNULIB_ISBLANK)/g' \ + -e 's/@''HAVE_ISBLANK''@/$(HAVE_ISBLANK)/g' \ + -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \ + -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \ + < $(srcdir)/ctype.in.h; \ + } > $@-t && \ + mv $@-t $@ +MOSTLYCLEANFILES += ctype.h ctype.h-t + +EXTRA_DIST += ctype.in.h + +## end gnulib module ctype + +## begin gnulib module ctype-tests + +TESTS += test-ctype +check_PROGRAMS += test-ctype +EXTRA_DIST += test-ctype.c + +## end gnulib module ctype-tests + ## begin gnulib module errno-tests TESTS += test-errno @@ -654,6 +688,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/gl/tests/binary-io.c b/gl/tests/binary-io.c index 8bbdb44d12..d828bcd015 100644 --- a/gl/tests/binary-io.c +++ b/gl/tests/binary-io.c @@ -1,3 +1,4 @@ #include <config.h> #define BINARY_IO_INLINE _GL_EXTERN_INLINE #include "binary-io.h" +typedef int dummy; diff --git a/gl/tests/binary-io.h b/gl/tests/binary-io.h index f5b66c7909..9f17c0d398 100644 --- a/gl/tests/binary-io.h +++ b/gl/tests/binary-io.h @@ -1,5 +1,5 @@ /* Binary mode I/O. - Copyright (C) 2001, 2003, 2005, 2008-2015 Free Software Foundation, Inc. + Copyright (C) 2001, 2003, 2005, 2008-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 @@ -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/gl/tests/ctype.in.h b/gl/tests/ctype.in.h new file mode 100644 index 0000000000..217812de10 --- /dev/null +++ b/gl/tests/ctype.in.h @@ -0,0 +1,57 @@ +/* A substitute for ISO C99 <ctype.h>, for platforms on which it is incomplete. + + Copyright (C) 2009-2016 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, see <http://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible. */ + +/* + * ISO C 99 <ctype.h> for platforms on which it is incomplete. + * <http://www.opengroup.org/onlinepubs/9699919799/basedefs/ctype.h.html> + */ + +#ifndef _@GUARD_PREFIX@_CTYPE_H + +#if __GNUC__ >= 3 +@PRAGMA_SYSTEM_HEADER@ +#endif +@PRAGMA_COLUMNS@ + +/* Include the original <ctype.h>. */ +/* The include_next requires a split double-inclusion guard. */ +#@INCLUDE_NEXT@ @NEXT_CTYPE_H@ + +#ifndef _@GUARD_PREFIX@_CTYPE_H +#define _@GUARD_PREFIX@_CTYPE_H + +/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ + +/* The definition of _GL_WARN_ON_USE is copied here. */ + +/* Return non-zero if c is a blank, i.e. a space or tab character. */ +#if @GNULIB_ISBLANK@ +# if !@HAVE_ISBLANK@ +_GL_EXTERN_C int isblank (int c); +# endif +#elif defined GNULIB_POSIXCHECK +# undef isblank +# if HAVE_RAW_DECL_ISBLANK +_GL_WARN_ON_USE (isblank, "isblank is unportable - " + "use gnulib module isblank for portability"); +# endif +#endif + +#endif /* _@GUARD_PREFIX@_CTYPE_H */ +#endif /* _@GUARD_PREFIX@_CTYPE_H */ diff --git a/gl/tests/fcntl.in.h b/gl/tests/fcntl.in.h index e2880185c6..b94397307e 100644 --- a/gl/tests/fcntl.in.h +++ b/gl/tests/fcntl.in.h @@ -1,6 +1,6 @@ /* Like <fcntl.h>, but with non-working flags defined to 0. - Copyright (C) 2006-2015 Free Software Foundation, Inc. + Copyright (C) 2006-2016 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/gl/tests/fdopen.c b/gl/tests/fdopen.c index b72c0e8fe0..61fbfdfc5a 100644 --- a/gl/tests/fdopen.c +++ b/gl/tests/fdopen.c @@ -1,5 +1,5 @@ /* Open a stream with a given file descriptor. - Copyright (C) 2011-2015 Free Software Foundation, Inc. + Copyright (C) 2011-2016 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/gl/tests/fpucw.h b/gl/tests/fpucw.h index cedd5b427f..05ee0cac94 100644 --- a/gl/tests/fpucw.h +++ b/gl/tests/fpucw.h @@ -1,5 +1,5 @@ -/* Manipulating the FPU control word. - Copyright (C) 2007-2015 Free Software Foundation, Inc. +/* Manipulating the FPU control word. -*- coding: utf-8 -*- + Copyright (C) 2007-2016 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2007. This program is free software: you can redistribute it and/or modify diff --git a/gl/tests/getpagesize.c b/gl/tests/getpagesize.c index 10e9c18776..dc4a200b21 100644 --- a/gl/tests/getpagesize.c +++ b/gl/tests/getpagesize.c @@ -1,6 +1,6 @@ /* getpagesize emulation for systems where it cannot be done in a C macro. - Copyright (C) 2007, 2009-2015 Free Software Foundation, Inc. + Copyright (C) 2007, 2009-2016 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/gl/tests/init.sh b/gl/tests/init.sh index d36620610e..97e4e4ba5e 100644 --- a/gl/tests/init.sh +++ b/gl/tests/init.sh @@ -1,6 +1,6 @@ # source this file; set up for tests -# Copyright (C) 2009-2015 Free Software Foundation, Inc. +# Copyright (C) 2009-2016 Free Software Foundation, Inc. # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -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. @@ -327,7 +333,7 @@ elif diff_out_=`exec 2>/dev/null; diff -c "$0" "$0" < /dev/null`; then fi } fi -elif ( cmp --version < /dev/null 2>&1 | grep GNU ) > /dev/null 2>&1; then +elif cmp -s /dev/null /dev/null 2>/dev/null; then compare_ () { cmp -s "$@"; } else compare_ () { cmp "$@"; } @@ -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/gl/tests/inttypes.in.h b/gl/tests/inttypes.in.h index 78846f6968..ed09db6e86 100644 --- a/gl/tests/inttypes.in.h +++ b/gl/tests/inttypes.in.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2006-2015 Free Software Foundation, Inc. +/* Copyright (C) 2006-2016 Free Software Foundation, Inc. Written by Paul Eggert, Bruno Haible, Derek Price. This file is part of gnulib. diff --git a/gl/tests/macros.h b/gl/tests/macros.h index b6fdd1cad4..578bfe737e 100644 --- a/gl/tests/macros.h +++ b/gl/tests/macros.h @@ -1,5 +1,5 @@ /* Common macros used by gnulib tests. - Copyright (C) 2006-2015 Free Software Foundation, Inc. + Copyright (C) 2006-2016 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/gl/tests/signature.h b/gl/tests/signature.h index 0a6cf915d1..2df806788a 100644 --- a/gl/tests/signature.h +++ b/gl/tests/signature.h @@ -1,5 +1,5 @@ /* Macro for checking that a function declaration is compliant. - Copyright (C) 2009-2015 Free Software Foundation, Inc. + Copyright (C) 2009-2016 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/gl/tests/test-alloca-opt.c b/gl/tests/test-alloca-opt.c index c189cc66d5..b9aaa4a147 100644 --- a/gl/tests/test-alloca-opt.c +++ b/gl/tests/test-alloca-opt.c @@ -1,5 +1,5 @@ /* Test of optional automatic memory allocation. - Copyright (C) 2005, 2007, 2009-2015 Free Software Foundation, Inc. + Copyright (C) 2005, 2007, 2009-2016 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/gl/tests/test-binary-io.c b/gl/tests/test-binary-io.c index 9c3f8f2199..6801e9621f 100644 --- a/gl/tests/test-binary-io.c +++ b/gl/tests/test-binary-io.c @@ -1,5 +1,5 @@ /* Test of binary mode I/O. - Copyright (C) 2005, 2007-2015 Free Software Foundation, Inc. + Copyright (C) 2005, 2007-2016 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/gl/tests/test-byteswap.c b/gl/tests/test-byteswap.c index 66ef8d82a3..909bd54d30 100644 --- a/gl/tests/test-byteswap.c +++ b/gl/tests/test-byteswap.c @@ -1,5 +1,5 @@ /* Test of <byteswap.h> substitute. - Copyright (C) 2007-2015 Free Software Foundation, Inc. + Copyright (C) 2007-2016 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/gl/tests/test-c-ctype.c b/gl/tests/test-c-ctype.c index 81fe936ec1..184cdec6e0 100644 --- a/gl/tests/test-c-ctype.c +++ b/gl/tests/test-c-ctype.c @@ -1,5 +1,5 @@ /* Test of character handling in C locale. - Copyright (C) 2005, 2007-2015 Free Software Foundation, Inc. + Copyright (C) 2005, 2007-2016 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -20,59 +20,79 @@ #include "c-ctype.h" +#include <ctype.h> +#include <limits.h> #include <locale.h> #include "macros.h" static void -test_all (void) +test_agree_with_C_locale (void) { int c; - for (c = -0x80; c < 0x100; c++) + for (c = 0; c <= UCHAR_MAX; c++) { - ASSERT (c_isascii (c) == (c >= 0 && c < 0x80)); - - switch (c) + ASSERT (c_isascii (c) == (isascii (c) != 0)); + if (c_isascii (c)) { - case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': - case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': - case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': - case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': - case 'Y': case 'Z': - case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': - case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': - case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': - case 's': case 't': case 'u': case 'v': case 'w': case 'x': - case 'y': case 'z': - case '0': case '1': case '2': case '3': case '4': case '5': - case '6': case '7': case '8': case '9': - ASSERT (c_isalnum (c) == 1); - break; - default: - ASSERT (c_isalnum (c) == 0); - break; + ASSERT (c_isalnum (c) == (isalnum (c) != 0)); + ASSERT (c_isalpha (c) == (isalpha (c) != 0)); + ASSERT (c_isblank (c) == (isblank (c) != 0)); + ASSERT (c_iscntrl (c) == (iscntrl (c) != 0)); + ASSERT (c_isdigit (c) == (isdigit (c) != 0)); + ASSERT (c_islower (c) == (islower (c) != 0)); + ASSERT (c_isgraph (c) == (isgraph (c) != 0)); + ASSERT (c_isprint (c) == (isprint (c) != 0)); + ASSERT (c_ispunct (c) == (ispunct (c) != 0)); + ASSERT (c_isspace (c) == (isspace (c) != 0)); + ASSERT (c_isupper (c) == (isupper (c) != 0)); + ASSERT (c_isxdigit (c) == (isxdigit (c) != 0)); + ASSERT (c_tolower (c) == tolower (c)); + ASSERT (c_toupper (c) == toupper (c)); } + } +} - switch (c) +static void +test_all (void) +{ + int c; + int n_isascii = 0; + + for (c = CHAR_MIN; c <= UCHAR_MAX; c++) + { + if (! (0 <= c && c <= CHAR_MAX)) { - case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': - case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': - case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': - case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': - case 'Y': case 'Z': - case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': - case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': - case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': - case 's': case 't': case 'u': case 'v': case 'w': case 'x': - case 'y': case 'z': - ASSERT (c_isalpha (c) == 1); - break; - default: - ASSERT (c_isalpha (c) == 0); - break; + ASSERT (! c_isascii (c)); + ASSERT (! c_isalnum (c)); + ASSERT (! c_isalpha (c)); + ASSERT (! c_isblank (c)); + ASSERT (! c_iscntrl (c)); + ASSERT (! c_isdigit (c)); + ASSERT (! c_islower (c)); + ASSERT (! c_isgraph (c)); + ASSERT (! c_isprint (c)); + ASSERT (! c_ispunct (c)); + ASSERT (! c_isspace (c)); + ASSERT (! c_isupper (c)); + ASSERT (! c_isxdigit (c)); + ASSERT (c_tolower (c) == c); + ASSERT (c_toupper (c) == c); } + n_isascii += c_isascii (c); + +#ifdef C_CTYPE_ASCII + ASSERT (c_isascii (c) == (0 <= c && c <= 0x7f)); +#endif + + ASSERT (c_isascii (c) == (c_isprint (c) || c_iscntrl (c))); + + ASSERT (c_isalnum (c) == (c_isalpha (c) || c_isdigit (c))); + + ASSERT (c_isalpha (c) == (c_islower (c) || c_isupper (c))); + switch (c) { case '\t': case ' ': @@ -83,7 +103,19 @@ test_all (void) break; } +#ifdef C_CTYPE_ASCII ASSERT (c_iscntrl (c) == ((c >= 0 && c < 0x20) || c == 0x7f)); +#endif + + switch (c) + { + case '\a': case '\b': case '\f': case '\n': + case '\r': case '\t': case '\v': + ASSERT (c_iscntrl (c)); + break; + } + + ASSERT (! (c_iscntrl (c) && c_isprint (c))); switch (c) { @@ -104,17 +136,37 @@ test_all (void) case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': ASSERT (c_islower (c) == 1); + ASSERT (c_toupper (c) == c - 'a' + 'A'); break; default: ASSERT (c_islower (c) == 0); + ASSERT (c_toupper (c) == c); break; } +#ifdef C_CTYPE_ASCII ASSERT (c_isgraph (c) == ((c >= 0x20 && c < 0x7f) && c != ' ')); ASSERT (c_isprint (c) == (c >= 0x20 && c < 0x7f)); +#endif + + ASSERT (c_isgraph (c) == (c_isalnum (c) || c_ispunct (c))); + + ASSERT (c_isprint (c) == (c_isgraph (c) || c == ' ')); - ASSERT (c_ispunct (c) == (c_isgraph (c) && !c_isalnum (c))); + switch (c) + { + case '!': case '"': case '#': case '$': case '%': case '&': case '\'': + case '(': case ')': case '*': case '+': case ',': case '-': case '.': + case '/': case ':': case ';': case '<': case '=': case '>': case '?': + case '@': case '[': case'\\': case ']': case '^': case '_': case '`': + case '{': case '|': case '}': case '~': + ASSERT (c_ispunct (c) == 1); + break; + default: + ASSERT (c_ispunct (c) == 0); + break; + } switch (c) { @@ -134,9 +186,11 @@ test_all (void) case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': ASSERT (c_isupper (c) == 1); + ASSERT (c_tolower (c) == c - 'A' + 'a'); break; default: ASSERT (c_isupper (c) == 0); + ASSERT (c_tolower (c) == c); break; } @@ -152,228 +206,16 @@ test_all (void) ASSERT (c_isxdigit (c) == 0); break; } - - switch (c) - { - case 'A': - ASSERT (c_tolower (c) == 'a'); - ASSERT (c_toupper (c) == c); - break; - case 'B': - ASSERT (c_tolower (c) == 'b'); - ASSERT (c_toupper (c) == c); - break; - case 'C': - ASSERT (c_tolower (c) == 'c'); - ASSERT (c_toupper (c) == c); - break; - case 'D': - ASSERT (c_tolower (c) == 'd'); - ASSERT (c_toupper (c) == c); - break; - case 'E': - ASSERT (c_tolower (c) == 'e'); - ASSERT (c_toupper (c) == c); - break; - case 'F': - ASSERT (c_tolower (c) == 'f'); - ASSERT (c_toupper (c) == c); - break; - case 'G': - ASSERT (c_tolower (c) == 'g'); - ASSERT (c_toupper (c) == c); - break; - case 'H': - ASSERT (c_tolower (c) == 'h'); - ASSERT (c_toupper (c) == c); - break; - case 'I': - ASSERT (c_tolower (c) == 'i'); - ASSERT (c_toupper (c) == c); - break; - case 'J': - ASSERT (c_tolower (c) == 'j'); - ASSERT (c_toupper (c) == c); - break; - case 'K': - ASSERT (c_tolower (c) == 'k'); - ASSERT (c_toupper (c) == c); - break; - case 'L': - ASSERT (c_tolower (c) == 'l'); - ASSERT (c_toupper (c) == c); - break; - case 'M': - ASSERT (c_tolower (c) == 'm'); - ASSERT (c_toupper (c) == c); - break; - case 'N': - ASSERT (c_tolower (c) == 'n'); - ASSERT (c_toupper (c) == c); - break; - case 'O': - ASSERT (c_tolower (c) == 'o'); - ASSERT (c_toupper (c) == c); - break; - case 'P': - ASSERT (c_tolower (c) == 'p'); - ASSERT (c_toupper (c) == c); - break; - case 'Q': - ASSERT (c_tolower (c) == 'q'); - ASSERT (c_toupper (c) == c); - break; - case 'R': - ASSERT (c_tolower (c) == 'r'); - ASSERT (c_toupper (c) == c); - break; - case 'S': - ASSERT (c_tolower (c) == 's'); - ASSERT (c_toupper (c) == c); - break; - case 'T': - ASSERT (c_tolower (c) == 't'); - ASSERT (c_toupper (c) == c); - break; - case 'U': - ASSERT (c_tolower (c) == 'u'); - ASSERT (c_toupper (c) == c); - break; - case 'V': - ASSERT (c_tolower (c) == 'v'); - ASSERT (c_toupper (c) == c); - break; - case 'W': - ASSERT (c_tolower (c) == 'w'); - ASSERT (c_toupper (c) == c); - break; - case 'X': - ASSERT (c_tolower (c) == 'x'); - ASSERT (c_toupper (c) == c); - break; - case 'Y': - ASSERT (c_tolower (c) == 'y'); - ASSERT (c_toupper (c) == c); - break; - case 'Z': - ASSERT (c_tolower (c) == 'z'); - ASSERT (c_toupper (c) == c); - break; - case 'a': - ASSERT (c_tolower (c) == c); - ASSERT (c_toupper (c) == 'A'); - break; - case 'b': - ASSERT (c_tolower (c) == c); - ASSERT (c_toupper (c) == 'B'); - break; - case 'c': - ASSERT (c_tolower (c) == c); - ASSERT (c_toupper (c) == 'C'); - break; - case 'd': - ASSERT (c_tolower (c) == c); - ASSERT (c_toupper (c) == 'D'); - break; - case 'e': - ASSERT (c_tolower (c) == c); - ASSERT (c_toupper (c) == 'E'); - break; - case 'f': - ASSERT (c_tolower (c) == c); - ASSERT (c_toupper (c) == 'F'); - break; - case 'g': - ASSERT (c_tolower (c) == c); - ASSERT (c_toupper (c) == 'G'); - break; - case 'h': - ASSERT (c_tolower (c) == c); - ASSERT (c_toupper (c) == 'H'); - break; - case 'i': - ASSERT (c_tolower (c) == c); - ASSERT (c_toupper (c) == 'I'); - break; - case 'j': - ASSERT (c_tolower (c) == c); - ASSERT (c_toupper (c) == 'J'); - break; - case 'k': - ASSERT (c_tolower (c) == c); - ASSERT (c_toupper (c) == 'K'); - break; - case 'l': - ASSERT (c_tolower (c) == c); - ASSERT (c_toupper (c) == 'L'); - break; - case 'm': - ASSERT (c_tolower (c) == c); - ASSERT (c_toupper (c) == 'M'); - break; - case 'n': - ASSERT (c_tolower (c) == c); - ASSERT (c_toupper (c) == 'N'); - break; - case 'o': - ASSERT (c_tolower (c) == c); - ASSERT (c_toupper (c) == 'O'); - break; - case 'p': - ASSERT (c_tolower (c) == c); - ASSERT (c_toupper (c) == 'P'); - break; - case 'q': - ASSERT (c_tolower (c) == c); - ASSERT (c_toupper (c) == 'Q'); - break; - case 'r': - ASSERT (c_tolower (c) == c); - ASSERT (c_toupper (c) == 'R'); - break; - case 's': - ASSERT (c_tolower (c) == c); - ASSERT (c_toupper (c) == 'S'); - break; - case 't': - ASSERT (c_tolower (c) == c); - ASSERT (c_toupper (c) == 'T'); - break; - case 'u': - ASSERT (c_tolower (c) == c); - ASSERT (c_toupper (c) == 'U'); - break; - case 'v': - ASSERT (c_tolower (c) == c); - ASSERT (c_toupper (c) == 'V'); - break; - case 'w': - ASSERT (c_tolower (c) == c); - ASSERT (c_toupper (c) == 'W'); - break; - case 'x': - ASSERT (c_tolower (c) == c); - ASSERT (c_toupper (c) == 'X'); - break; - case 'y': - ASSERT (c_tolower (c) == c); - ASSERT (c_toupper (c) == 'Y'); - break; - case 'z': - ASSERT (c_tolower (c) == c); - ASSERT (c_toupper (c) == 'Z'); - break; - default: - ASSERT (c_tolower (c) == c); - ASSERT (c_toupper (c) == c); - break; - } } + + ASSERT (n_isascii == 128); } int main () { + test_agree_with_C_locale (); + test_all (); setlocale (LC_ALL, "de_DE"); diff --git a/gl/tests/test-ctype.c b/gl/tests/test-ctype.c new file mode 100644 index 0000000000..570fbdb0c1 --- /dev/null +++ b/gl/tests/test-ctype.c @@ -0,0 +1,27 @@ +/* Test of <ctype.h> substitute. + Copyright (C) 2009-2016 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. */ + +/* Written by Eric Blake <ebb9@byu.net>, 2009. */ + +#include <config.h> + +#include <ctype.h> + +int +main (void) +{ + return 0; +} diff --git a/gl/tests/test-errno.c b/gl/tests/test-errno.c index fab35d0dc0..1e0bb6d4d3 100644 --- a/gl/tests/test-errno.c +++ b/gl/tests/test-errno.c @@ -1,5 +1,5 @@ /* Test of <errno.h> substitute. - Copyright (C) 2008-2015 Free Software Foundation, Inc. + Copyright (C) 2008-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 diff --git a/gl/tests/test-fcntl-h.c b/gl/tests/test-fcntl-h.c index e177b3e691..aef1661a64 100644 --- a/gl/tests/test-fcntl-h.c +++ b/gl/tests/test-fcntl-h.c @@ -1,5 +1,5 @@ /* Test of <fcntl.h> substitute. - Copyright (C) 2007, 2009-2015 Free Software Foundation, Inc. + Copyright (C) 2007, 2009-2016 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/gl/tests/test-fdopen.c b/gl/tests/test-fdopen.c index c4e035521c..55b49a6490 100644 --- a/gl/tests/test-fdopen.c +++ b/gl/tests/test-fdopen.c @@ -1,5 +1,5 @@ /* Test opening a stream with a file descriptor. - Copyright (C) 2011-2015 Free Software Foundation, Inc. + Copyright (C) 2011-2016 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/gl/tests/test-fgetc.c b/gl/tests/test-fgetc.c index 63e1e4a22b..c62e70c6d9 100644 --- a/gl/tests/test-fgetc.c +++ b/gl/tests/test-fgetc.c @@ -1,5 +1,5 @@ /* Test of fgetc() function. - Copyright (C) 2011-2015 Free Software Foundation, Inc. + Copyright (C) 2011-2016 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/gl/tests/test-float.c b/gl/tests/test-float.c index f8321995b0..1c95b12f97 100644 --- a/gl/tests/test-float.c +++ b/gl/tests/test-float.c @@ -1,5 +1,5 @@ /* Test of <float.h> substitute. - Copyright (C) 2011-2015 Free Software Foundation, Inc. + Copyright (C) 2011-2016 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/gl/tests/test-fputc.c b/gl/tests/test-fputc.c index 41ae0965b0..95a1cb6014 100644 --- a/gl/tests/test-fputc.c +++ b/gl/tests/test-fputc.c @@ -1,5 +1,5 @@ /* Test of fputc() function. - Copyright (C) 2011-2015 Free Software Foundation, Inc. + Copyright (C) 2011-2016 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/gl/tests/test-fread.c b/gl/tests/test-fread.c index 41cea56c8a..b9fc72afa1 100644 --- a/gl/tests/test-fread.c +++ b/gl/tests/test-fread.c @@ -1,5 +1,5 @@ /* Test of fread() function. - Copyright (C) 2011-2015 Free Software Foundation, Inc. + Copyright (C) 2011-2016 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/gl/tests/test-fstat.c b/gl/tests/test-fstat.c index 7f393638a8..c9ac749db8 100644 --- a/gl/tests/test-fstat.c +++ b/gl/tests/test-fstat.c @@ -1,5 +1,5 @@ /* Tests of fstat() function. - Copyright (C) 2011-2015 Free Software Foundation, Inc. + Copyright (C) 2011-2016 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/gl/tests/test-ftell.c b/gl/tests/test-ftell.c index 2853226888..9b523444eb 100644 --- a/gl/tests/test-ftell.c +++ b/gl/tests/test-ftell.c @@ -1,5 +1,5 @@ /* Test of ftell() function. - Copyright (C) 2007-2015 Free Software Foundation, Inc. + Copyright (C) 2007-2016 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/gl/tests/test-ftell3.c b/gl/tests/test-ftell3.c index 8a95e1c337..695e5b2dc7 100644 --- a/gl/tests/test-ftell3.c +++ b/gl/tests/test-ftell3.c @@ -1,5 +1,5 @@ /* Test of ftell() function. - Copyright (C) 2007-2015 Free Software Foundation, Inc. + Copyright (C) 2007-2016 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/gl/tests/test-ftello.c b/gl/tests/test-ftello.c index b9b5c969d1..369d476518 100644 --- a/gl/tests/test-ftello.c +++ b/gl/tests/test-ftello.c @@ -1,5 +1,5 @@ /* Test of ftello() function. - Copyright (C) 2007-2015 Free Software Foundation, Inc. + Copyright (C) 2007-2016 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/gl/tests/test-ftello3.c b/gl/tests/test-ftello3.c index 67b4671135..f75ce03432 100644 --- a/gl/tests/test-ftello3.c +++ b/gl/tests/test-ftello3.c @@ -1,5 +1,5 @@ /* Test of ftello() function. - Copyright (C) 2007-2015 Free Software Foundation, Inc. + Copyright (C) 2007-2016 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/gl/tests/test-ftello4.c b/gl/tests/test-ftello4.c index 68e64593de..1f94ef67d8 100644 --- a/gl/tests/test-ftello4.c +++ b/gl/tests/test-ftello4.c @@ -1,5 +1,5 @@ /* Test of ftello() function. - Copyright (C) 2011-2015 Free Software Foundation, Inc. + Copyright (C) 2011-2016 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/gl/tests/test-func.c b/gl/tests/test-func.c index 4da2e035ff..54e3328d35 100644 --- a/gl/tests/test-func.c +++ b/gl/tests/test-func.c @@ -1,5 +1,5 @@ /* Test whether __func__ is available - Copyright (C) 2008-2015 Free Software Foundation, Inc. + Copyright (C) 2008-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 diff --git a/gl/tests/test-fwrite.c b/gl/tests/test-fwrite.c index df4114ced6..bc285f3017 100644 --- a/gl/tests/test-fwrite.c +++ b/gl/tests/test-fwrite.c @@ -1,5 +1,5 @@ /* Test of fwrite() function. - Copyright (C) 2011-2015 Free Software Foundation, Inc. + Copyright (C) 2011-2016 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/gl/tests/test-getdelim.c b/gl/tests/test-getdelim.c index bbcc3cded6..0770d5b3aa 100644 --- a/gl/tests/test-getdelim.c +++ b/gl/tests/test-getdelim.c @@ -1,5 +1,5 @@ /* Test of getdelim() function. - Copyright (C) 2007-2015 Free Software Foundation, Inc. + Copyright (C) 2007-2016 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/gl/tests/test-getline.c b/gl/tests/test-getline.c index 238742cf0f..13dcb1d7f8 100644 --- a/gl/tests/test-getline.c +++ b/gl/tests/test-getline.c @@ -1,5 +1,5 @@ /* Test of getline() function. - Copyright (C) 2007-2015 Free Software Foundation, Inc. + Copyright (C) 2007-2016 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -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/gl/tests/test-gettimeofday.c b/gl/tests/test-gettimeofday.c index 3b15f1298e..7a44d71fa4 100644 --- a/gl/tests/test-gettimeofday.c +++ b/gl/tests/test-gettimeofday.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005, 2007, 2009-2015 Free Software Foundation, Inc. + * Copyright (C) 2005, 2007, 2009-2016 Free Software Foundation, Inc. * Written by Jim Meyering. * * This program is free software: you can redistribute it and/or modify diff --git a/gl/tests/test-iconv.c b/gl/tests/test-iconv.c index ed715bda3f..3e4c4ff0a7 100644 --- a/gl/tests/test-iconv.c +++ b/gl/tests/test-iconv.c @@ -1,5 +1,5 @@ /* Test of character set conversion. - Copyright (C) 2007-2015 Free Software Foundation, Inc. + Copyright (C) 2007-2016 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/gl/tests/test-init.sh b/gl/tests/test-init.sh index 0875a75b94..1dd05f4504 100755 --- a/gl/tests/test-init.sh +++ b/gl/tests/test-init.sh @@ -1,6 +1,6 @@ #!/bin/sh # Unit tests for init.sh -# Copyright (C) 2011-2015 Free Software Foundation, Inc. +# Copyright (C) 2011-2016 Free Software Foundation, Inc. # This file is part of the GNUlib Library. # # This program is free software: you can redistribute it and/or modify diff --git a/gl/tests/test-intprops.c b/gl/tests/test-intprops.c index 06df5a7c11..51fe09638e 100644 --- a/gl/tests/test-intprops.c +++ b/gl/tests/test-intprops.c @@ -1,5 +1,5 @@ /* Test intprops.h. - Copyright (C) 2011-2015 Free Software Foundation, Inc. + Copyright (C) 2011-2016 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -16,10 +16,19 @@ /* Written by Paul Eggert. */ -/* Tell gcc not to warn about the many (X < 0) expressions that - the overflow macros expand to. */ -#if (__GNUC__ == 4 && 3 <= __GNUC_MINOR__) || 4 < __GNUC__ +/* Tell gcc not to warn about the long expressions that the overflow + macros expand to, or about the (X < 0) expressions. */ +#if 4 < __GNUC__ + (3 <= __GNUC_MINOR__) +# 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 + #endif #include <config.h> @@ -29,6 +38,7 @@ #include <stdbool.h> #include <inttypes.h> +#include <limits.h> #include "macros.h" @@ -43,6 +53,8 @@ # define VERIFY(x) ASSERT (x) #endif +#define DONTCARE __LINE__ + int main (void) { @@ -82,12 +94,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); @@ -128,148 +136,238 @@ main (void) #endif /* All the INT_<op>_RANGE_OVERFLOW tests are equally valid as - INT_<op>_OVERFLOW tests, so define a single macro to do both. */ - #define CHECK_BINOP(op, a, b, min, max, overflow) \ - (INT_##op##_RANGE_OVERFLOW (a, b, min, max) == (overflow) \ - && INT_##op##_OVERFLOW (a, b) == (overflow)) - #define CHECK_UNOP(op, a, min, max, overflow) \ - (INT_##op##_RANGE_OVERFLOW (a, min, max) == (overflow) \ - && INT_##op##_OVERFLOW (a) == (overflow)) + INT_<op>_OVERFLOW tests, so define macros to do both. OP is the + operation, OPNAME its symbolic name, A and B its operands, T the + result type, V the overflow flag, and VRES the result if V and if + two's complement. CHECK_BINOP is for most binary operatinos, + CHECK_SBINOP for binary +, -, * when the result type is signed, + and CHECK_UNOP for unary operations. */ + #define CHECK_BINOP(op, opname, a, b, t, v, vres) \ + VERIFY (INT_##opname##_RANGE_OVERFLOW (a, b, TYPE_MINIMUM (t), \ + TYPE_MAXIMUM (t)) \ + == (v)); \ + VERIFY (INT_##opname##_OVERFLOW (a, b) == (v)) + #define CHECK_SBINOP(op, opname, a, b, t, v, vres) \ + CHECK_BINOP(op, opname, a, b, t, v, vres); \ + { \ + t result; \ + ASSERT (INT_##opname##_WRAPV (a, b, &result) == (v)); \ + ASSERT (result == ((v) ? (vres) : ((a) op (b)))); \ + } + #define CHECK_UNOP(op, opname, a, t, v) \ + VERIFY (INT_##opname##_RANGE_OVERFLOW (a, TYPE_MINIMUM (t), \ + TYPE_MAXIMUM (t)) \ + == (v)); \ + VERIFY (INT_##opname##_OVERFLOW (a) == (v)) /* INT_<op>_RANGE_OVERFLOW, INT_<op>_OVERFLOW. */ VERIFY (INT_ADD_RANGE_OVERFLOW (INT_MAX, 1, INT_MIN, INT_MAX)); VERIFY (INT_ADD_OVERFLOW (INT_MAX, 1)); - VERIFY (CHECK_BINOP (ADD, INT_MAX, 1, INT_MIN, INT_MAX, true)); - VERIFY (CHECK_BINOP (ADD, INT_MAX, -1, INT_MIN, INT_MAX, false)); - VERIFY (CHECK_BINOP (ADD, INT_MIN, 1, INT_MIN, INT_MAX, false)); - VERIFY (CHECK_BINOP (ADD, INT_MIN, -1, INT_MIN, INT_MAX, true)); - VERIFY (CHECK_BINOP (ADD, UINT_MAX, 1u, 0u, UINT_MAX, true)); - VERIFY (CHECK_BINOP (ADD, 0u, 1u, 0u, UINT_MAX, false)); - - VERIFY (CHECK_BINOP (SUBTRACT, INT_MAX, 1, INT_MIN, INT_MAX, false)); - VERIFY (CHECK_BINOP (SUBTRACT, INT_MAX, -1, INT_MIN, INT_MAX, true)); - VERIFY (CHECK_BINOP (SUBTRACT, INT_MIN, 1, INT_MIN, INT_MAX, true)); - VERIFY (CHECK_BINOP (SUBTRACT, INT_MIN, -1, INT_MIN, INT_MAX, false)); - VERIFY (CHECK_BINOP (SUBTRACT, UINT_MAX, 1u, 0u, UINT_MAX, false)); - VERIFY (CHECK_BINOP (SUBTRACT, 0u, 1u, 0u, UINT_MAX, true)); - - VERIFY (CHECK_UNOP (NEGATE, INT_MIN, INT_MIN, INT_MAX, - TYPE_TWOS_COMPLEMENT (int))); - VERIFY (CHECK_UNOP (NEGATE, 0, INT_MIN, INT_MAX, false)); - VERIFY (CHECK_UNOP (NEGATE, INT_MAX, INT_MIN, INT_MAX, false)); - VERIFY (CHECK_UNOP (NEGATE, 0u, 0u, UINT_MAX, false)); - VERIFY (CHECK_UNOP (NEGATE, 1u, 0u, UINT_MAX, true)); - VERIFY (CHECK_UNOP (NEGATE, UINT_MAX, 0u, UINT_MAX, true)); - - VERIFY (CHECK_BINOP (MULTIPLY, INT_MAX, INT_MAX, INT_MIN, INT_MAX, true)); - VERIFY (CHECK_BINOP (MULTIPLY, INT_MAX, INT_MIN, INT_MIN, INT_MAX, true)); - VERIFY (CHECK_BINOP (MULTIPLY, INT_MIN, INT_MAX, INT_MIN, INT_MAX, true)); - VERIFY (CHECK_BINOP (MULTIPLY, INT_MIN, INT_MIN, INT_MIN, INT_MAX, true)); - VERIFY (CHECK_BINOP (MULTIPLY, -1, INT_MIN, INT_MIN, INT_MAX, - INT_NEGATE_OVERFLOW (INT_MIN))); - VERIFY (CHECK_BINOP (MULTIPLY, LONG_MIN / INT_MAX, (long int) INT_MAX, - LONG_MIN, LONG_MIN, false)); - - VERIFY (CHECK_BINOP (DIVIDE, INT_MIN, -1, INT_MIN, INT_MAX, - INT_NEGATE_OVERFLOW (INT_MIN))); - VERIFY (CHECK_BINOP (DIVIDE, INT_MAX, 1, INT_MIN, INT_MAX, false)); - VERIFY (CHECK_BINOP (DIVIDE, (unsigned int) INT_MIN, - -1u, 0u, UINT_MAX, false)); - - VERIFY (CHECK_BINOP (REMAINDER, INT_MIN, -1, INT_MIN, INT_MAX, - INT_NEGATE_OVERFLOW (INT_MIN))); - VERIFY (CHECK_BINOP (REMAINDER, INT_MAX, 1, INT_MIN, INT_MAX, false)); - VERIFY (CHECK_BINOP (REMAINDER, (unsigned int) INT_MIN, - -1u, 0u, UINT_MAX, false)); - - VERIFY (CHECK_BINOP (LEFT_SHIFT, UINT_MAX, 1, 0u, UINT_MAX, true)); - VERIFY (CHECK_BINOP (LEFT_SHIFT, UINT_MAX / 2 + 1, 1, 0u, UINT_MAX, true)); - VERIFY (CHECK_BINOP (LEFT_SHIFT, UINT_MAX / 2, 1, 0u, UINT_MAX, false)); - - /* INT_<op>_OVERFLOW with mixed types. */ - #define CHECK_SUM(a, b, overflow) \ - VERIFY (INT_ADD_OVERFLOW (a, b) == (overflow)); \ - VERIFY (INT_ADD_OVERFLOW (b, a) == (overflow)) - CHECK_SUM (-1, LONG_MIN, true); - CHECK_SUM (-1, UINT_MAX, false); - CHECK_SUM (-1L, INT_MIN, INT_MIN == LONG_MIN); - CHECK_SUM (0u, -1, true); - CHECK_SUM (0u, 0, false); - CHECK_SUM (0u, 1, false); - CHECK_SUM (1, LONG_MAX, true); - CHECK_SUM (1, UINT_MAX, true); - CHECK_SUM (1L, INT_MAX, INT_MAX == LONG_MAX); - CHECK_SUM (1u, INT_MAX, INT_MAX == UINT_MAX); - CHECK_SUM (1u, INT_MIN, true); - - VERIFY (! INT_SUBTRACT_OVERFLOW (INT_MAX, 1u)); - VERIFY (! INT_SUBTRACT_OVERFLOW (UINT_MAX, 1)); - VERIFY (! INT_SUBTRACT_OVERFLOW (0u, -1)); - VERIFY (INT_SUBTRACT_OVERFLOW (UINT_MAX, -1)); - VERIFY (INT_SUBTRACT_OVERFLOW (INT_MIN, 1u)); - VERIFY (INT_SUBTRACT_OVERFLOW (-1, 0u)); - - #define CHECK_PRODUCT(a, b, overflow) \ - VERIFY (INT_MULTIPLY_OVERFLOW (a, b) == (overflow)); \ - VERIFY (INT_MULTIPLY_OVERFLOW (b, a) == (overflow)) - - CHECK_PRODUCT (-1, 1u, true); - CHECK_PRODUCT (-1, INT_MIN, INT_NEGATE_OVERFLOW (INT_MIN)); - CHECK_PRODUCT (-1, UINT_MAX, true); - CHECK_PRODUCT (-12345, LONG_MAX / -12345 - 1, true); - CHECK_PRODUCT (-12345, LONG_MAX / -12345, false); - CHECK_PRODUCT (0, -1, false); - CHECK_PRODUCT (0, 0, false); - CHECK_PRODUCT (0, 0u, false); - CHECK_PRODUCT (0, 1, false); - CHECK_PRODUCT (0, INT_MAX, false); - CHECK_PRODUCT (0, INT_MIN, false); - CHECK_PRODUCT (0, UINT_MAX, false); - CHECK_PRODUCT (0u, -1, false); - CHECK_PRODUCT (0u, 0, false); - CHECK_PRODUCT (0u, 0u, false); - CHECK_PRODUCT (0u, 1, false); - CHECK_PRODUCT (0u, INT_MAX, false); - CHECK_PRODUCT (0u, INT_MIN, false); - CHECK_PRODUCT (0u, UINT_MAX, false); - CHECK_PRODUCT (1, INT_MAX, false); - CHECK_PRODUCT (1, INT_MIN, false); - CHECK_PRODUCT (1, UINT_MAX, false); - CHECK_PRODUCT (1u, INT_MIN, true); - CHECK_PRODUCT (1u, INT_MAX, UINT_MAX < INT_MAX); - CHECK_PRODUCT (INT_MAX, UINT_MAX, true); - CHECK_PRODUCT (INT_MAX, ULONG_MAX, true); - CHECK_PRODUCT (INT_MIN, LONG_MAX / INT_MIN - 1, true); - CHECK_PRODUCT (INT_MIN, LONG_MAX / INT_MIN, false); - CHECK_PRODUCT (INT_MIN, UINT_MAX, true); - CHECK_PRODUCT (INT_MIN, ULONG_MAX, true); - - VERIFY (INT_DIVIDE_OVERFLOW (INT_MIN, -1L) - == (TYPE_TWOS_COMPLEMENT (long int) && INT_MIN == LONG_MIN)); - VERIFY (! INT_DIVIDE_OVERFLOW (INT_MIN, UINT_MAX)); - VERIFY (! INT_DIVIDE_OVERFLOW (INTMAX_MIN, UINTMAX_MAX)); - VERIFY (! INT_DIVIDE_OVERFLOW (INTMAX_MIN, UINT_MAX)); - VERIFY (INT_DIVIDE_OVERFLOW (-11, 10u)); - VERIFY (INT_DIVIDE_OVERFLOW (-10, 10u)); - VERIFY (! INT_DIVIDE_OVERFLOW (-9, 10u)); - VERIFY (INT_DIVIDE_OVERFLOW (11u, -10)); - VERIFY (INT_DIVIDE_OVERFLOW (10u, -10)); - VERIFY (! INT_DIVIDE_OVERFLOW (9u, -10)); - - VERIFY (INT_REMAINDER_OVERFLOW (INT_MIN, -1L) - == (TYPE_TWOS_COMPLEMENT (long int) && INT_MIN == LONG_MIN)); - VERIFY (INT_REMAINDER_OVERFLOW (-1, UINT_MAX)); - VERIFY (INT_REMAINDER_OVERFLOW ((intmax_t) -1, UINTMAX_MAX)); - VERIFY (INT_REMAINDER_OVERFLOW (INTMAX_MIN, UINT_MAX) - == (INTMAX_MAX < UINT_MAX - && - (unsigned int) INTMAX_MIN % UINT_MAX != 0)); - VERIFY (INT_REMAINDER_OVERFLOW (INT_MIN, ULONG_MAX) - == (INT_MIN % ULONG_MAX != 1)); - VERIFY (! INT_REMAINDER_OVERFLOW (1u, -1)); - VERIFY (! INT_REMAINDER_OVERFLOW (37*39u, -39)); - VERIFY (INT_REMAINDER_OVERFLOW (37*39u + 1, -39)); - VERIFY (INT_REMAINDER_OVERFLOW (37*39u - 1, -39)); - VERIFY (! INT_REMAINDER_OVERFLOW (LONG_MAX, -INT_MAX)); + + CHECK_SBINOP (+, ADD, INT_MAX, 1, int, true, INT_MIN); + CHECK_SBINOP (+, ADD, INT_MAX, -1, int, false, INT_MAX - 1); + CHECK_SBINOP (+, ADD, INT_MIN, 1, int, false, INT_MIN + 1); + CHECK_SBINOP (+, ADD, INT_MIN, -1, int, true, INT_MAX); + CHECK_BINOP (+, ADD, UINT_MAX, 1u, unsigned int, true, 0u); + CHECK_BINOP (+, ADD, 0u, 1u, unsigned int, false, 1u); + + CHECK_SBINOP (-, SUBTRACT, INT_MAX, 1, int, false, INT_MAX - 1); + CHECK_SBINOP (-, SUBTRACT, INT_MAX, -1, int, true, INT_MIN); + CHECK_SBINOP (-, SUBTRACT, INT_MIN, 1, int, true, INT_MAX); + CHECK_SBINOP (-, SUBTRACT, INT_MIN, -1, int, false, INT_MIN - -1); + 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, true); + CHECK_UNOP (-, NEGATE, 0, int, false); + CHECK_UNOP (-, NEGATE, INT_MAX, int, false); + CHECK_UNOP (-, NEGATE, 0u, unsigned int, false); + CHECK_UNOP (-, NEGATE, 1u, unsigned int, true); + CHECK_UNOP (-, NEGATE, UINT_MAX, unsigned int, true); + + CHECK_SBINOP (*, MULTIPLY, INT_MAX, INT_MAX, int, true, 1); + CHECK_SBINOP (*, MULTIPLY, INT_MAX, INT_MIN, int, true, INT_MIN); + CHECK_SBINOP (*, MULTIPLY, INT_MIN, INT_MAX, int, true, INT_MIN); + CHECK_SBINOP (*, MULTIPLY, INT_MIN, INT_MIN, int, true, 0); + CHECK_SBINOP (*, MULTIPLY, -1, INT_MIN, int, + INT_NEGATE_OVERFLOW (INT_MIN), INT_MIN); + CHECK_SBINOP (*, MULTIPLY, LONG_MIN / INT_MAX, (long int) INT_MAX, + long int, false, LONG_MIN - LONG_MIN % INT_MAX); + + CHECK_BINOP (/, DIVIDE, INT_MIN, -1, int, + INT_NEGATE_OVERFLOW (INT_MIN), INT_MIN); + CHECK_BINOP (/, DIVIDE, INT_MAX, 1, int, false, INT_MAX); + CHECK_BINOP (/, DIVIDE, (unsigned int) INT_MIN, -1u, unsigned int, + false, INT_MIN / -1u); + + CHECK_BINOP (%, REMAINDER, INT_MIN, -1, int, INT_NEGATE_OVERFLOW (INT_MIN), 0); + CHECK_BINOP (%, REMAINDER, INT_MAX, 1, int, false, 0); + CHECK_BINOP (%, REMAINDER, (unsigned int) INT_MIN, -1u, unsigned int, + false, INT_MIN % -1u); + + CHECK_BINOP (<<, LEFT_SHIFT, UINT_MAX, 1, unsigned int, true, UINT_MAX << 1); + CHECK_BINOP (<<, LEFT_SHIFT, UINT_MAX / 2 + 1, 1, unsigned int, true, + (UINT_MAX / 2 + 1) << 1); + CHECK_BINOP (<<, LEFT_SHIFT, UINT_MAX / 2, 1, unsigned int, false, + (UINT_MAX / 2) << 1); + + /* INT_<op>_OVERFLOW and INT_<op>_WRAPV with mixed types. */ + #define CHECK_SUM(a, b, t, v, vres) \ + CHECK_SUM1(a, b, t, v, vres); \ + CHECK_SUM1(b, a, t, v, vres) + #define CHECK_SSUM(a, b, t, v, vres) \ + CHECK_SSUM1(a, b, t, v, vres); \ + CHECK_SSUM1(b, a, t, v, vres) + #define CHECK_SUM1(a, b, t, v, vres) \ + VERIFY (INT_ADD_OVERFLOW (a, b) == (v)) + #define CHECK_SSUM1(a, b, t, v, vres) \ + CHECK_SUM1(a, b, t, v, vres); \ + { \ + t result; \ + ASSERT (INT_ADD_WRAPV (a, b, &result) == (v)); \ + 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); + CHECK_SSUM (-1L, INT_MIN, long int, INT_MIN == LONG_MIN, + INT_MIN == LONG_MIN ? INT_MAX : DONTCARE); + CHECK_SUM (0u, -1, unsigned int, true, 0u + -1); + CHECK_SUM (0u, 0, unsigned int, false, DONTCARE); + CHECK_SUM (0u, 1, unsigned int, false, DONTCARE); + CHECK_SSUM (1, LONG_MAX, long int, true, LONG_MIN); + CHECK_SUM (1, UINT_MAX, unsigned int, true, 0u); + CHECK_SSUM (1L, INT_MAX, long int, INT_MAX == LONG_MAX, + INT_MAX == LONG_MAX ? INT_MIN : DONTCARE); + CHECK_SUM (1u, INT_MAX, unsigned int, INT_MAX == UINT_MAX, 1u + INT_MAX); + CHECK_SUM (1u, INT_MIN, unsigned int, true, 1u + INT_MIN); + { + long int result; + ASSERT (INT_ADD_WRAPV (1, INT_MAX, &result) == (INT_MAX == LONG_MAX)); + ASSERT (INT_ADD_WRAPV (-1, INT_MIN, &result) == (INT_MIN == LONG_MIN)); + } + + #define CHECK_DIFFERENCE(a, b, t, v, vres) \ + VERIFY (INT_SUBTRACT_OVERFLOW (a, b) == (v)) + #define CHECK_SDIFFERENCE(a, b, t, v, vres) \ + CHECK_DIFFERENCE(a, b, t, v, vres); \ + { \ + t result; \ + ASSERT (INT_SUBTRACT_WRAPV (a, b, &result) == (v)); \ + ASSERT (result == ((v) ? (vres) : ((a) - (b)))); \ + } + CHECK_DIFFERENCE (INT_MAX, 1u, unsigned int, UINT_MAX < INT_MAX - 1, + INT_MAX - 1u); + CHECK_DIFFERENCE (UINT_MAX, 1, unsigned int, false, UINT_MAX - 1); + CHECK_DIFFERENCE (0u, -1, unsigned int, false, 0u - -1); + CHECK_DIFFERENCE (UINT_MAX, -1, unsigned int, true, UINT_MAX - -1); + CHECK_DIFFERENCE (INT_MIN, 1u, unsigned int, true, INT_MIN - 1u); + CHECK_DIFFERENCE (-1, 0u, unsigned int, true, -1 - 0u); + CHECK_SDIFFERENCE (-1, INT_MIN, int, false, -1 - INT_MIN); + CHECK_SDIFFERENCE (-1, INT_MAX, int, false, -1 - INT_MAX); + CHECK_SDIFFERENCE (0, INT_MIN, int, INT_MIN < -INT_MAX, INT_MIN); + CHECK_SDIFFERENCE (0, INT_MAX, int, false, 0 - INT_MAX); + { + long int result; + ASSERT (INT_SUBTRACT_WRAPV (INT_MAX, -1, &result) == (INT_MAX == LONG_MAX)); + ASSERT (INT_SUBTRACT_WRAPV (INT_MIN, 1, &result) == (INT_MAX == LONG_MAX)); + } + + #define CHECK_PRODUCT(a, b, t, v, vres) \ + CHECK_PRODUCT1(a, b, t, v, vres); \ + CHECK_PRODUCT1(b, a, t, v, vres) + #define CHECK_SPRODUCT(a, b, t, v, vres) \ + CHECK_SPRODUCT1(a, b, t, v, vres); \ + CHECK_SPRODUCT1(b, a, t, v, vres) + #define CHECK_PRODUCT1(a, b, t, v, vres) \ + VERIFY (INT_MULTIPLY_OVERFLOW (a, b) == (v)) + #define CHECK_SPRODUCT1(a, b, t, v, vres) \ + CHECK_PRODUCT1(a, b, t, v, vres); \ + { \ + t result; \ + ASSERT (INT_MULTIPLY_WRAPV (a, b, &result) == (v)); \ + 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); + CHECK_PRODUCT (-1, UINT_MAX, unsigned int, true, -1 * UINT_MAX); + CHECK_SPRODUCT (-32768, LONG_MAX / -32768 - 1, long int, true, LONG_MIN); + CHECK_SPRODUCT (-12345, LONG_MAX / -12345, long int, false, DONTCARE); + CHECK_SPRODUCT (0, -1, int, false, DONTCARE); + CHECK_SPRODUCT (0, 0, int, false, DONTCARE); + CHECK_PRODUCT (0, 0u, unsigned int, false, DONTCARE); + CHECK_SPRODUCT (0, 1, int, false, DONTCARE); + CHECK_SPRODUCT (0, INT_MAX, int, false, DONTCARE); + CHECK_SPRODUCT (0, INT_MIN, int, false, DONTCARE); + CHECK_PRODUCT (0, UINT_MAX, unsigned int, false, DONTCARE); + CHECK_PRODUCT (0u, -1, unsigned int, false, DONTCARE); + CHECK_PRODUCT (0u, 0, unsigned int, false, DONTCARE); + CHECK_PRODUCT (0u, 0u, unsigned int, false, DONTCARE); + CHECK_PRODUCT (0u, 1, unsigned int, false, DONTCARE); + CHECK_PRODUCT (0u, INT_MAX, unsigned int, false, DONTCARE); + CHECK_PRODUCT (0u, INT_MIN, unsigned int, false, DONTCARE); + CHECK_PRODUCT (0u, UINT_MAX, unsigned int, false, DONTCARE); + CHECK_SPRODUCT (1, INT_MAX, int, false, DONTCARE); + CHECK_SPRODUCT (1, INT_MIN, int, false, DONTCARE); + CHECK_PRODUCT (1, UINT_MAX, unsigned int, false, DONTCARE); + CHECK_PRODUCT (1u, INT_MIN, unsigned int, true, 1u * INT_MIN); + CHECK_PRODUCT (1u, INT_MAX, unsigned int, UINT_MAX < INT_MAX, 1u * INT_MAX); + CHECK_PRODUCT (INT_MAX, UINT_MAX, unsigned int, true, INT_MAX * UINT_MAX); + CHECK_PRODUCT (INT_MAX, ULONG_MAX, unsigned long int, true, + INT_MAX * ULONG_MAX); + CHECK_SPRODUCT (INT_MIN, LONG_MAX / INT_MIN - 1, long int, true, LONG_MIN); + CHECK_SPRODUCT (INT_MIN, LONG_MAX / INT_MIN, long int, false, DONTCARE); + CHECK_PRODUCT (INT_MIN, UINT_MAX, unsigned int, true, INT_MIN * UINT_MAX); + CHECK_PRODUCT (INT_MIN, ULONG_MAX, unsigned long int, true, + INT_MIN * ULONG_MAX); + { + long int result; + ASSERT (INT_MULTIPLY_WRAPV (INT_MAX, INT_MAX, &result) + == (LONG_MAX / INT_MAX < INT_MAX)); + ASSERT (INT_MULTIPLY_WRAPV (INT_MAX, INT_MAX, &result) + || result == INT_MAX * (long int) INT_MAX); + ASSERT (INT_MULTIPLY_WRAPV (INT_MIN, INT_MIN, &result) + || result == INT_MIN * (long int) INT_MIN); + } + +# ifdef LLONG_MAX + { + long long int result; + ASSERT (INT_MULTIPLY_WRAPV (LONG_MAX, LONG_MAX, &result) + == (LLONG_MAX / LONG_MAX < LONG_MAX)); + ASSERT (INT_MULTIPLY_WRAPV (LONG_MAX, LONG_MAX, &result) + || result == LONG_MAX * (long long int) LONG_MAX); + ASSERT (INT_MULTIPLY_WRAPV (LONG_MIN, LONG_MIN, &result) + || result == LONG_MIN * (long long int) LONG_MIN); + } +# endif + + #define CHECK_QUOTIENT(a, b, v) VERIFY (INT_DIVIDE_OVERFLOW (a, b) == (v)) + + 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); + CHECK_QUOTIENT (-11, 10u, true); + CHECK_QUOTIENT (-10, 10u, true); + CHECK_QUOTIENT (-9, 10u, false); + CHECK_QUOTIENT (11u, -10, true); + CHECK_QUOTIENT (10u, -10, true); + CHECK_QUOTIENT (9u, -10, false); + + #define CHECK_REMAINDER(a, b, v) VERIFY (INT_REMAINDER_OVERFLOW (a, b) == (v)) + + 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, + (INTMAX_MAX < UINT_MAX + && - (unsigned int) INTMAX_MIN % UINT_MAX != 0)); + CHECK_REMAINDER (INT_MIN, ULONG_MAX, INT_MIN % ULONG_MAX != 1); + CHECK_REMAINDER (1u, -1, false); + CHECK_REMAINDER (37*39u, -39, false); + CHECK_REMAINDER (37*39u + 1, -39, true); + CHECK_REMAINDER (37*39u - 1, -39, true); + CHECK_REMAINDER (LONG_MAX, -INT_MAX, false); return 0; } diff --git a/gl/tests/test-inttypes.c b/gl/tests/test-inttypes.c index 7fa18b2392..9a3193c398 100644 --- a/gl/tests/test-inttypes.c +++ b/gl/tests/test-inttypes.c @@ -1,5 +1,5 @@ /* Test of <inttypes.h> substitute. - Copyright (C) 2006-2007, 2009-2015 Free Software Foundation, Inc. + Copyright (C) 2006-2007, 2009-2016 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/gl/tests/test-memchr.c b/gl/tests/test-memchr.c index bc1acf9f0f..1526ed2a69 100644 --- a/gl/tests/test-memchr.c +++ b/gl/tests/test-memchr.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2008-2015 Free Software Foundation, Inc. + * Copyright (C) 2008-2016 Free Software Foundation, Inc. * Written by Eric Blake and Bruno Haible * * This program is free software: you can redistribute it and/or modify diff --git a/gl/tests/test-netdb.c b/gl/tests/test-netdb.c index 97abfd2783..93d9c97a5c 100644 --- a/gl/tests/test-netdb.c +++ b/gl/tests/test-netdb.c @@ -1,5 +1,5 @@ /* Test of <netdb.h> substitute. - Copyright (C) 2007-2008, 2010-2015 Free Software Foundation, Inc. + Copyright (C) 2007-2008, 2010-2016 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/gl/tests/test-netinet_in.c b/gl/tests/test-netinet_in.c index ae1634f686..8a603da6eb 100644 --- a/gl/tests/test-netinet_in.c +++ b/gl/tests/test-netinet_in.c @@ -1,5 +1,5 @@ /* Test of <netinet/in.h> substitute. - Copyright (C) 2007, 2009-2015 Free Software Foundation, Inc. + Copyright (C) 2007, 2009-2016 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/gl/tests/test-read-file.c b/gl/tests/test-read-file.c index f8b160f58c..ab13f14b32 100644 --- a/gl/tests/test-read-file.c +++ b/gl/tests/test-read-file.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2006-2007, 2010-2015 Free Software Foundation, Inc. + * Copyright (C) 2006-2007, 2010-2016 Free Software Foundation, Inc. * Written by Simon Josefsson * * This program is free software: you can redistribute it and/or modify diff --git a/gl/tests/test-snprintf.c b/gl/tests/test-snprintf.c index c14a2c1bf9..9041e4a047 100644 --- a/gl/tests/test-snprintf.c +++ b/gl/tests/test-snprintf.c @@ -1,5 +1,5 @@ /* Test of snprintf() function. - Copyright (C) 2007-2015 Free Software Foundation, Inc. + Copyright (C) 2007-2016 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/gl/tests/test-stdalign.c b/gl/tests/test-stdalign.c index 68b9ef15b2..0f240c5516 100644 --- a/gl/tests/test-stdalign.c +++ b/gl/tests/test-stdalign.c @@ -1,5 +1,5 @@ /* Test of <stdalign.h>. - Copyright 2009-2015 Free Software Foundation, Inc. + Copyright 2009-2016 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/gl/tests/test-stdbool.c b/gl/tests/test-stdbool.c index 1da25d0733..45dc837675 100644 --- a/gl/tests/test-stdbool.c +++ b/gl/tests/test-stdbool.c @@ -1,5 +1,5 @@ /* Test of <stdbool.h> substitute. - Copyright (C) 2002-2007, 2009-2015 Free Software Foundation, Inc. + Copyright (C) 2002-2007, 2009-2016 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/gl/tests/test-stddef.c b/gl/tests/test-stddef.c index aa6ae549cc..bfb72a01dc 100644 --- a/gl/tests/test-stddef.c +++ b/gl/tests/test-stddef.c @@ -1,5 +1,5 @@ /* Test of <stddef.h> substitute. - Copyright (C) 2009-2015 Free Software Foundation, Inc. + Copyright (C) 2009-2016 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/gl/tests/test-stdint.c b/gl/tests/test-stdint.c index 8d54db2ecf..7705fc706e 100644 --- a/gl/tests/test-stdint.c +++ b/gl/tests/test-stdint.c @@ -1,5 +1,5 @@ /* Test of <stdint.h> substitute. - Copyright (C) 2006-2015 Free Software Foundation, Inc. + Copyright (C) 2006-2016 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/gl/tests/test-stdio.c b/gl/tests/test-stdio.c index cbec2a6ff0..6cde888b69 100644 --- a/gl/tests/test-stdio.c +++ b/gl/tests/test-stdio.c @@ -1,5 +1,5 @@ /* Test of <stdio.h> substitute. - Copyright (C) 2007, 2009-2015 Free Software Foundation, Inc. + Copyright (C) 2007, 2009-2016 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/gl/tests/test-stdlib.c b/gl/tests/test-stdlib.c index b2da7ecc78..a1fc0d814c 100644 --- a/gl/tests/test-stdlib.c +++ b/gl/tests/test-stdlib.c @@ -1,5 +1,5 @@ /* Test of <stdlib.h> substitute. - Copyright (C) 2007, 2009-2015 Free Software Foundation, Inc. + Copyright (C) 2007, 2009-2016 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/gl/tests/test-string.c b/gl/tests/test-string.c index 647d3b9b77..f4c60f72c9 100644 --- a/gl/tests/test-string.c +++ b/gl/tests/test-string.c @@ -1,5 +1,5 @@ /* Test of <string.h> substitute. - Copyright (C) 2007, 2009-2015 Free Software Foundation, Inc. + Copyright (C) 2007, 2009-2016 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/gl/tests/test-strings.c b/gl/tests/test-strings.c index 8a59a9f0c8..5eaa61a68e 100644 --- a/gl/tests/test-strings.c +++ b/gl/tests/test-strings.c @@ -1,5 +1,5 @@ /* Test of <strings.h> substitute. - Copyright (C) 2007, 2009-2015 Free Software Foundation, Inc. + Copyright (C) 2007, 2009-2016 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/gl/tests/test-strnlen.c b/gl/tests/test-strnlen.c index 19e41cffdc..ee5bd78262 100644 --- a/gl/tests/test-strnlen.c +++ b/gl/tests/test-strnlen.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010-2015 Free Software Foundation, Inc. + * Copyright (C) 2010-2016 Free Software Foundation, Inc. * Written by Eric Blake * * This program is free software: you can redistribute it and/or modify diff --git a/gl/tests/test-strverscmp.c b/gl/tests/test-strverscmp.c index 771977e588..e5a6bb10f8 100644 --- a/gl/tests/test-strverscmp.c +++ b/gl/tests/test-strverscmp.c @@ -1,5 +1,5 @@ /* Test of strverscmp() function. - Copyright (C) 2008-2015 Free Software Foundation, Inc. + Copyright (C) 2008-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 diff --git a/gl/tests/test-sys_socket.c b/gl/tests/test-sys_socket.c index 8d8528b12b..a4f7108735 100644 --- a/gl/tests/test-sys_socket.c +++ b/gl/tests/test-sys_socket.c @@ -1,5 +1,5 @@ /* Test of <sys/socket.h> substitute. - Copyright (C) 2007, 2009-2015 Free Software Foundation, Inc. + Copyright (C) 2007, 2009-2016 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/gl/tests/test-sys_stat.c b/gl/tests/test-sys_stat.c index e4194a13b5..8a3af941be 100644 --- a/gl/tests/test-sys_stat.c +++ b/gl/tests/test-sys_stat.c @@ -1,5 +1,5 @@ /* Test of <sys/stat.h> substitute. - Copyright (C) 2007-2015 Free Software Foundation, Inc. + Copyright (C) 2007-2016 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/gl/tests/test-sys_time.c b/gl/tests/test-sys_time.c index 653ff467a3..44535b99dd 100644 --- a/gl/tests/test-sys_time.c +++ b/gl/tests/test-sys_time.c @@ -1,5 +1,5 @@ /* Test of <sys/time.h> substitute. - Copyright (C) 2007, 2009-2015 Free Software Foundation, Inc. + Copyright (C) 2007, 2009-2016 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/gl/tests/test-sys_types.c b/gl/tests/test-sys_types.c index 1ef3b90363..7f8fb6d121 100644 --- a/gl/tests/test-sys_types.c +++ b/gl/tests/test-sys_types.c @@ -1,5 +1,5 @@ /* Test of <sys/types.h> substitute. - Copyright (C) 2011-2015 Free Software Foundation, Inc. + Copyright (C) 2011-2016 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/gl/tests/test-sys_uio.c b/gl/tests/test-sys_uio.c index 3878c96a77..c433847918 100644 --- a/gl/tests/test-sys_uio.c +++ b/gl/tests/test-sys_uio.c @@ -1,5 +1,5 @@ /* Test of <sys/uio.h> substitute. - Copyright (C) 2011-2015 Free Software Foundation, Inc. + Copyright (C) 2011-2016 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/gl/tests/test-sys_wait.h b/gl/tests/test-sys_wait.h index e4a79b5481..7389be4256 100644 --- a/gl/tests/test-sys_wait.h +++ b/gl/tests/test-sys_wait.h @@ -1,5 +1,5 @@ /* Test of macros shared between <sys/wait.h> and <stdlib.h>. - Copyright (C) 2010-2015 Free Software Foundation, Inc. + Copyright (C) 2010-2016 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/gl/tests/test-time.c b/gl/tests/test-time.c index 25bdcf0a0c..dec2b1338a 100644 --- a/gl/tests/test-time.c +++ b/gl/tests/test-time.c @@ -1,5 +1,5 @@ /* Test of <time.h> substitute. - Copyright (C) 2007, 2009-2015 Free Software Foundation, Inc. + Copyright (C) 2007, 2009-2016 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/gl/tests/test-unistd.c b/gl/tests/test-unistd.c index 930b5e21b9..463ef578cc 100644 --- a/gl/tests/test-unistd.c +++ b/gl/tests/test-unistd.c @@ -1,5 +1,5 @@ /* Test of <unistd.h> substitute. - Copyright (C) 2007, 2009-2015 Free Software Foundation, Inc. + Copyright (C) 2007, 2009-2016 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/gl/tests/test-vasnprintf.c b/gl/tests/test-vasnprintf.c index 8ff59006e2..a75c004ffc 100644 --- a/gl/tests/test-vasnprintf.c +++ b/gl/tests/test-vasnprintf.c @@ -1,5 +1,5 @@ /* Test of vasnprintf() and asnprintf() functions. - Copyright (C) 2007-2015 Free Software Foundation, Inc. + Copyright (C) 2007-2016 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/gl/tests/test-vasprintf.c b/gl/tests/test-vasprintf.c index b304275995..ebcbfc4d15 100644 --- a/gl/tests/test-vasprintf.c +++ b/gl/tests/test-vasprintf.c @@ -1,5 +1,5 @@ /* Test of vasprintf() and asprintf() functions. - Copyright (C) 2007-2015 Free Software Foundation, Inc. + Copyright (C) 2007-2016 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/gl/tests/test-vc-list-files-cvs.sh b/gl/tests/test-vc-list-files-cvs.sh index a2a237f05a..6262944412 100755 --- a/gl/tests/test-vc-list-files-cvs.sh +++ b/gl/tests/test-vc-list-files-cvs.sh @@ -1,6 +1,6 @@ #!/bin/sh # Unit tests for vc-list-files -# Copyright (C) 2008-2015 Free Software Foundation, Inc. +# Copyright (C) 2008-2016 Free Software Foundation, Inc. # This file is part of the GNUlib Library. # # This program is free software: you can redistribute it and/or modify diff --git a/gl/tests/test-vc-list-files-git.sh b/gl/tests/test-vc-list-files-git.sh index 2882d32893..4358115ffe 100755 --- a/gl/tests/test-vc-list-files-git.sh +++ b/gl/tests/test-vc-list-files-git.sh @@ -1,6 +1,6 @@ #!/bin/sh # Unit tests for vc-list-files -# Copyright (C) 2008-2015 Free Software Foundation, Inc. +# Copyright (C) 2008-2016 Free Software Foundation, Inc. # This file is part of the GNUlib Library. # # This program is free software: you can redistribute it and/or modify diff --git a/gl/tests/test-verify.c b/gl/tests/test-verify.c index 640dc4265c..d7ca0538b0 100644 --- a/gl/tests/test-verify.c +++ b/gl/tests/test-verify.c @@ -1,6 +1,6 @@ /* Test the "verify" module. - Copyright (C) 2005, 2009-2015 Free Software Foundation, Inc. + Copyright (C) 2005, 2009-2016 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/gl/tests/test-vsnprintf.c b/gl/tests/test-vsnprintf.c index a37ace5359..0a2ff02991 100644 --- a/gl/tests/test-vsnprintf.c +++ b/gl/tests/test-vsnprintf.c @@ -1,5 +1,5 @@ /* Test of vsnprintf() function. - Copyright (C) 2007-2015 Free Software Foundation, Inc. + Copyright (C) 2007-2016 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/gl/tests/test-wchar.c b/gl/tests/test-wchar.c index e857ab5dd3..e118048224 100644 --- a/gl/tests/test-wchar.c +++ b/gl/tests/test-wchar.c @@ -1,5 +1,5 @@ /* Test of <wchar.h> substitute. - Copyright (C) 2007-2015 Free Software Foundation, Inc. + Copyright (C) 2007-2016 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/gl/tests/zerosize-ptr.h b/gl/tests/zerosize-ptr.h index 76418aa5a0..e6ff672b64 100644 --- a/gl/tests/zerosize-ptr.h +++ b/gl/tests/zerosize-ptr.h @@ -1,5 +1,5 @@ /* Return a pointer to a zero-size object in memory. - Copyright (C) 2009-2015 Free Software Foundation, Inc. + Copyright (C) 2009-2016 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/gl/time.in.h b/gl/time.in.h index 861a5ff1d2..a2c321ed0a 100644 --- a/gl/time.in.h +++ b/gl/time.in.h @@ -1,6 +1,6 @@ /* A more-standard <time.h>. - Copyright (C) 2007-2015 Free Software Foundation, Inc. + Copyright (C) 2007-2016 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by diff --git a/gl/time_r.c b/gl/time_r.c index fc53fd9057..cd066f0fcc 100644 --- a/gl/time_r.c +++ b/gl/time_r.c @@ -1,6 +1,6 @@ /* Reentrant time functions like localtime_r. - Copyright (C) 2003, 2006-2007, 2010-2015 Free Software Foundation, Inc. + Copyright (C) 2003, 2006-2007, 2010-2016 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by diff --git a/gl/unistd.c b/gl/unistd.c index 6c6a8e268c..72bad1c052 100644 --- a/gl/unistd.c +++ b/gl/unistd.c @@ -1,3 +1,4 @@ #include <config.h> #define _GL_UNISTD_INLINE _GL_EXTERN_INLINE #include "unistd.h" +typedef int dummy; diff --git a/gl/unistd.in.h b/gl/unistd.in.h index e32428d9d8..fd16379ffb 100644 --- a/gl/unistd.in.h +++ b/gl/unistd.in.h @@ -1,5 +1,5 @@ /* Substitute for and wrapper around <unistd.h>. - Copyright (C) 2003-2015 Free Software Foundation, Inc. + Copyright (C) 2003-2016 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by diff --git a/gl/vasnprintf.c b/gl/vasnprintf.c index c291be1f9a..2edb70c41f 100644 --- a/gl/vasnprintf.c +++ b/gl/vasnprintf.c @@ -1,5 +1,5 @@ /* vsprintf with automatic memory allocation. - Copyright (C) 1999, 2002-2015 Free Software Foundation, Inc. + Copyright (C) 1999, 2002-2016 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by diff --git a/gl/vasnprintf.h b/gl/vasnprintf.h index a2c867104e..d2bcfb59fa 100644 --- a/gl/vasnprintf.h +++ b/gl/vasnprintf.h @@ -1,5 +1,5 @@ /* vsprintf with automatic memory allocation. - Copyright (C) 2002-2004, 2007-2015 Free Software Foundation, Inc. + Copyright (C) 2002-2004, 2007-2016 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by diff --git a/gl/vasprintf.c b/gl/vasprintf.c index 8c945fd32c..a5e00a108c 100644 --- a/gl/vasprintf.c +++ b/gl/vasprintf.c @@ -1,5 +1,5 @@ /* Formatted output to strings. - Copyright (C) 1999, 2002, 2006-2015 Free Software Foundation, Inc. + Copyright (C) 1999, 2002, 2006-2016 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by diff --git a/gl/verify.h b/gl/verify.h index 4784fb397a..267de29591 100644 --- a/gl/verify.h +++ b/gl/verify.h @@ -1,6 +1,6 @@ /* Compile-time assert-like macros. - Copyright (C) 2005-2006, 2009-2015 Free Software Foundation, Inc. + Copyright (C) 2005-2006, 2009-2016 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by diff --git a/gl/vsnprintf.c b/gl/vsnprintf.c index 0afd04dbeb..63bd79651b 100644 --- a/gl/vsnprintf.c +++ b/gl/vsnprintf.c @@ -1,5 +1,5 @@ /* Formatted output to strings. - Copyright (C) 2004, 2006-2015 Free Software Foundation, Inc. + Copyright (C) 2004, 2006-2016 Free Software Foundation, Inc. Written by Simon Josefsson and Yoann Vandoorselaere <yoann@prelude-ids.org>. This program is free software; you can redistribute it and/or modify diff --git a/gl/wchar.in.h b/gl/wchar.in.h index ae31e8d804..cf27441065 100644 --- a/gl/wchar.in.h +++ b/gl/wchar.in.h @@ -1,6 +1,6 @@ /* A substitute for ISO C99 <wchar.h>, for platforms that have issues. - Copyright (C) 2007-2015 Free Software Foundation, Inc. + Copyright (C) 2007-2016 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by @@ -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 !@HAVE_DECL_WCWIDTH@ /* 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/gl/xsize.h b/gl/xsize.h index de3d92ed14..c82712d3e2 100644 --- a/gl/xsize.h +++ b/gl/xsize.h @@ -1,6 +1,6 @@ /* xsize.h -- Checked size_t computations. - Copyright (C) 2003, 2008-2015 Free Software Foundation, Inc. + Copyright (C) 2003, 2008-2016 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by |