commit d81aa8516ef6df79d6d602d4f732d8a65bf1677c (HEAD, refs/remotes/origin/master) Author: Paul Eggert Date: Sun Jan 27 16:20:03 2019 -0800 Update from Gnulib This incorporates: 2019-01-26 getloadavg: Add support for Android 2019-01-24 fchownat: Fix compilation error on Android 4.3 2019-01-24 mbtowc: Fix compilation error on Android 4.3 2019-01-24 random: Fix compilation error on Android 4.3 2019-01-24 renameat: Fix compilation error on Android 4.3 2019-01-24 unlinkat: Fix compilation error on Android 4.3 2019-01-19 gettext: support disabling use of VLAs 2019-01-17 sys_stat: Fix warning on OS/2 kLIBC 2019-01-17 fcntl: Fix syntax error (regression from 2018-10-05) 2019-01-10 verify: Enable _GL_HAVE_STATIC_ASSERT for recent G++ 2018-12-22 stdioext: port to newer 32-bit Android 2018-12-16 libc-config: Support HP-UX cc in C99 mode. * build-aux/config.guess, build-aux/config.sub, doc/misc/texinfo.tex: * lib/cdefs.h, lib/fcntl.c, lib/getloadavg.c, lib/gettext.h: * lib/regexec.c, lib/stdio-impl.h, lib/stdio.in.h, lib/stdlib.in.h: * lib/sys_stat.in.h, lib/unistd.in.h, lib/verify.h, m4/stdlib_h.m4: Copy from Gnulib. * lib/gnulib.mk.in: Regenerate. diff --git a/build-aux/config.guess b/build-aux/config.guess index 0f9b29c884..a81aa505ba 100755 --- a/build-aux/config.guess +++ b/build-aux/config.guess @@ -2,7 +2,7 @@ # Attempt to guess a canonical system name. # Copyright 1992-2019 Free Software Foundation, Inc. -timestamp='2019-01-01' +timestamp='2019-01-15' # 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 diff --git a/build-aux/config.sub b/build-aux/config.sub index a8f3f7e7cd..3b4c7624b6 100755 --- a/build-aux/config.sub +++ b/build-aux/config.sub @@ -2,7 +2,7 @@ # Configuration validation subroutine script. # Copyright 1992-2019 Free Software Foundation, Inc. -timestamp='2019-01-01' +timestamp='2019-01-05' # 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 @@ -111,6 +111,7 @@ case $# in esac # Split fields of configuration type +# shellcheck disable=SC2162 IFS="-" read field1 field2 field3 field4 < # else /* NLIST_STRUCT */ @@ -286,7 +286,7 @@ # ifndef LDAV_SYMBOL # define LDAV_SYMBOL "_avenrun" # endif /* LDAV_SYMBOL */ -# endif /* __linux__ */ +# endif /* __linux__ || __ANDROID__ */ # else /* __VMS */ @@ -359,7 +359,8 @@ # include # endif -# if (defined __linux__ || defined __CYGWIN__ || defined SUNOS_5 \ +# if (defined __linux__ || defined __ANDROID__ \ + || defined __CYGWIN__ || defined SUNOS_5 \ || (defined LOAD_AVE_TYPE && ! defined __VMS)) # include # endif @@ -388,7 +389,7 @@ static bool getloadavg_initialized; /* Offset in kmem to seek to read load average, or 0 means invalid. */ static long offset; -# if ! defined __VMS && ! defined sgi && ! defined __linux__ +# if ! defined __VMS && ! defined sgi && ! (defined __linux__ || defined __ANDROID__) static struct nlist name_list[2]; # endif @@ -498,8 +499,8 @@ getloadavg (double loadavg[], int nelem) } # endif -# if !defined (LDAV_DONE) && (defined (__linux__) || defined (__CYGWIN__)) - /* Linux without glibc, Cygwin */ +# if !defined (LDAV_DONE) && (defined __linux__ || defined __ANDROID__ || defined __CYGWIN__) + /* Linux without glibc, Android, Cygwin */ # define LDAV_DONE # undef LOAD_AVE_TYPE @@ -554,7 +555,7 @@ getloadavg (double loadavg[], int nelem) return elem; -# endif /* __linux__ || __CYGWIN__ */ +# endif /* __linux__ || __ANDROID__ || __CYGWIN__ */ # if !defined (LDAV_DONE) && defined (__NetBSD__) /* NetBSD < 0.9 */ # define LDAV_DONE diff --git a/lib/gettext.h b/lib/gettext.h index 89f53d917b..c7c0fdb531 100644 --- a/lib/gettext.h +++ b/lib/gettext.h @@ -184,9 +184,16 @@ npgettext_aux (const char *domain, #include -#if (((__GNUC__ >= 3 || __GNUG__ >= 2) && !defined __STRICT_ANSI__) \ - /* || (__STDC_VERSION__ == 199901L && !defined __HP_cc) - || (__STDC_VERSION__ >= 201112L && !defined __STDC_NO_VLA__) */ ) +/* GNULIB_NO_VLA can be defined to disable use of VLAs even if supported. + This relates to the -Wvla and -Wvla-larger-than warnings, enabled in + the default GCC many warnings set. This allows programs to disable use + of VLAs, which may be unintended, or may be awkward to support portably, + or may have security implications due to non-deterministic stack usage. */ + +#if (!defined GNULIB_NO_VLA \ + && (((__GNUC__ >= 3 || __GNUG__ >= 2) && !defined __STRICT_ANSI__) \ + /* || (__STDC_VERSION__ == 199901L && !defined __HP_cc) + || (__STDC_VERSION__ >= 201112L && !defined __STDC_NO_VLA__) */ )) # define _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS 1 #else # define _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS 0 diff --git a/lib/gnulib.mk.in b/lib/gnulib.mk.in index 9666cd4e3e..fdf45d61c4 100644 --- a/lib/gnulib.mk.in +++ b/lib/gnulib.mk.in @@ -197,6 +197,7 @@ DBUS_OBJ = @DBUS_OBJ@ DEFS = @DEFS@ DESLIB = @DESLIB@ DOCMISC_W32 = @DOCMISC_W32@ +DUMPING = @DUMPING@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ @@ -556,6 +557,7 @@ HAVE_GETTIMEOFDAY = @HAVE_GETTIMEOFDAY@ HAVE_GRANTPT = @HAVE_GRANTPT@ HAVE_GROUP_MEMBER = @HAVE_GROUP_MEMBER@ HAVE_IMAXDIV_T = @HAVE_IMAXDIV_T@ +HAVE_INITSTATE = @HAVE_INITSTATE@ HAVE_INTTYPES_H = @HAVE_INTTYPES_H@ HAVE_LCHMOD = @HAVE_LCHMOD@ HAVE_LCHOWN = @HAVE_LCHOWN@ @@ -566,6 +568,7 @@ HAVE_LSTAT = @HAVE_LSTAT@ HAVE_MAKEINFO = @HAVE_MAKEINFO@ HAVE_MAX_ALIGN_T = @HAVE_MAX_ALIGN_T@ HAVE_MBSLEN = @HAVE_MBSLEN@ +HAVE_MBTOWC = @HAVE_MBTOWC@ HAVE_MEMCHR = @HAVE_MEMCHR@ HAVE_MEMPCPY = @HAVE_MEMPCPY@ HAVE_MKDIRAT = @HAVE_MKDIRAT@ @@ -613,6 +616,7 @@ HAVE_SCANDIR = @HAVE_SCANDIR@ HAVE_SECURE_GETENV = @HAVE_SECURE_GETENV@ HAVE_SETENV = @HAVE_SETENV@ HAVE_SETHOSTNAME = @HAVE_SETHOSTNAME@ +HAVE_SETSTATE = @HAVE_SETSTATE@ HAVE_SIGACTION = @HAVE_SIGACTION@ HAVE_SIGHANDLER_T = @HAVE_SIGHANDLER_T@ HAVE_SIGINFO_T = @HAVE_SIGINFO_T@ @@ -859,6 +863,7 @@ REPLACE_GETPAGESIZE = @REPLACE_GETPAGESIZE@ REPLACE_GETPASS = @REPLACE_GETPASS@ REPLACE_GETTIMEOFDAY = @REPLACE_GETTIMEOFDAY@ REPLACE_GMTIME = @REPLACE_GMTIME@ +REPLACE_INITSTATE = @REPLACE_INITSTATE@ REPLACE_ISATTY = @REPLACE_ISATTY@ REPLACE_LCHOWN = @REPLACE_LCHOWN@ REPLACE_LINK = @REPLACE_LINK@ @@ -894,6 +899,7 @@ REPLACE_PUTENV = @REPLACE_PUTENV@ REPLACE_PWRITE = @REPLACE_PWRITE@ REPLACE_QSORT_R = @REPLACE_QSORT_R@ REPLACE_RAISE = @REPLACE_RAISE@ +REPLACE_RANDOM = @REPLACE_RANDOM@ REPLACE_RANDOM_R = @REPLACE_RANDOM_R@ REPLACE_READ = @REPLACE_READ@ REPLACE_READLINK = @REPLACE_READLINK@ @@ -906,6 +912,7 @@ REPLACE_RENAMEAT = @REPLACE_RENAMEAT@ REPLACE_RMDIR = @REPLACE_RMDIR@ REPLACE_SELECT = @REPLACE_SELECT@ REPLACE_SETENV = @REPLACE_SETENV@ +REPLACE_SETSTATE = @REPLACE_SETSTATE@ REPLACE_SLEEP = @REPLACE_SLEEP@ REPLACE_SNPRINTF = @REPLACE_SNPRINTF@ REPLACE_SPRINTF = @REPLACE_SPRINTF@ @@ -952,7 +959,6 @@ REPLACE_WRITE = @REPLACE_WRITE@ RSVG_CFLAGS = @RSVG_CFLAGS@ RSVG_LIBS = @RSVG_LIBS@ SEPCHAR = @SEPCHAR@ -SETFATTR = @SETFATTR@ SETTINGS_CFLAGS = @SETTINGS_CFLAGS@ SETTINGS_LIBS = @SETTINGS_LIBS@ SHELL = @SHELL@ @@ -1009,6 +1015,7 @@ XMKMF = @XMKMF@ XOBJ = @XOBJ@ XRANDR_CFLAGS = @XRANDR_CFLAGS@ XRANDR_LIBS = @XRANDR_LIBS@ +XRENDER_LIBS = @XRENDER_LIBS@ XWIDGETS_OBJ = @XWIDGETS_OBJ@ X_TOOLKIT_TYPE = @X_TOOLKIT_TYPE@ ac_ct_CC = @ac_ct_CC@ @@ -2552,7 +2559,9 @@ stdlib.h: stdlib.in.h $(top_builddir)/config.status $(CXXDEFS_H) \ -e 's|@''HAVE_DECL_GETLOADAVG''@|$(HAVE_DECL_GETLOADAVG)|g' \ -e 's|@''HAVE_GETSUBOPT''@|$(HAVE_GETSUBOPT)|g' \ -e 's|@''HAVE_GRANTPT''@|$(HAVE_GRANTPT)|g' \ + -e 's|@''HAVE_INITSTATE''@|$(HAVE_INITSTATE)|g' \ -e 's|@''HAVE_DECL_INITSTATE''@|$(HAVE_DECL_INITSTATE)|g' \ + -e 's|@''HAVE_MBTOWC''@|$(HAVE_MBTOWC)|g' \ -e 's|@''HAVE_MKDTEMP''@|$(HAVE_MKDTEMP)|g' \ -e 's|@''HAVE_MKOSTEMP''@|$(HAVE_MKOSTEMP)|g' \ -e 's|@''HAVE_MKOSTEMPS''@|$(HAVE_MKOSTEMPS)|g' \ @@ -2570,6 +2579,7 @@ stdlib.h: stdlib.in.h $(top_builddir)/config.status $(CXXDEFS_H) \ -e 's|@''HAVE_RPMATCH''@|$(HAVE_RPMATCH)|g' \ -e 's|@''HAVE_SECURE_GETENV''@|$(HAVE_SECURE_GETENV)|g' \ -e 's|@''HAVE_DECL_SETENV''@|$(HAVE_DECL_SETENV)|g' \ + -e 's|@''HAVE_SETSTATE''@|$(HAVE_SETSTATE)|g' \ -e 's|@''HAVE_DECL_SETSTATE''@|$(HAVE_DECL_SETSTATE)|g' \ -e 's|@''HAVE_STRTOD''@|$(HAVE_STRTOD)|g' \ -e 's|@''HAVE_STRTOLL''@|$(HAVE_STRTOLL)|g' \ @@ -2580,6 +2590,7 @@ stdlib.h: stdlib.in.h $(top_builddir)/config.status $(CXXDEFS_H) \ -e 's|@''HAVE_DECL_UNSETENV''@|$(HAVE_DECL_UNSETENV)|g' \ -e 's|@''REPLACE_CALLOC''@|$(REPLACE_CALLOC)|g' \ -e 's|@''REPLACE_CANONICALIZE_FILE_NAME''@|$(REPLACE_CANONICALIZE_FILE_NAME)|g' \ + -e 's|@''REPLACE_INITSTATE''@|$(REPLACE_INITSTATE)|g' \ -e 's|@''REPLACE_MALLOC''@|$(REPLACE_MALLOC)|g' \ -e 's|@''REPLACE_MBTOWC''@|$(REPLACE_MBTOWC)|g' \ -e 's|@''REPLACE_MKSTEMP''@|$(REPLACE_MKSTEMP)|g' \ @@ -2587,10 +2598,12 @@ stdlib.h: stdlib.in.h $(top_builddir)/config.status $(CXXDEFS_H) \ -e 's|@''REPLACE_PTSNAME_R''@|$(REPLACE_PTSNAME_R)|g' \ -e 's|@''REPLACE_PUTENV''@|$(REPLACE_PUTENV)|g' \ -e 's|@''REPLACE_QSORT_R''@|$(REPLACE_QSORT_R)|g' \ + -e 's|@''REPLACE_RANDOM''@|$(REPLACE_RANDOM)|g' \ -e 's|@''REPLACE_RANDOM_R''@|$(REPLACE_RANDOM_R)|g' \ -e 's|@''REPLACE_REALLOC''@|$(REPLACE_REALLOC)|g' \ -e 's|@''REPLACE_REALPATH''@|$(REPLACE_REALPATH)|g' \ -e 's|@''REPLACE_SETENV''@|$(REPLACE_SETENV)|g' \ + -e 's|@''REPLACE_SETSTATE''@|$(REPLACE_SETSTATE)|g' \ -e 's|@''REPLACE_STRTOD''@|$(REPLACE_STRTOD)|g' \ -e 's|@''REPLACE_UNSETENV''@|$(REPLACE_UNSETENV)|g' \ -e 's|@''REPLACE_WCTOMB''@|$(REPLACE_WCTOMB)|g' \ diff --git a/lib/regexec.c b/lib/regexec.c index 21cf7915f7..2f7cb5dcb1 100644 --- a/lib/regexec.c +++ b/lib/regexec.c @@ -2207,7 +2207,7 @@ sift_states_iter_mb (const re_match_context_t *mctx, re_sift_context_t *sctx, dfa->nexts[node_idx])) /* The node can't accept the "multi byte", or the destination was already thrown away, then the node - could't accept the current input "multi byte". */ + couldn't accept the current input "multi byte". */ naccepted = 0; /* Otherwise, it is sure that the node could accept 'naccepted' bytes input. */ diff --git a/lib/stdio-impl.h b/lib/stdio-impl.h index b2b2971f2f..4260468b61 100644 --- a/lib/stdio-impl.h +++ b/lib/stdio-impl.h @@ -61,6 +61,11 @@ # define _r pub._r # define _w pub._w # elif defined __ANDROID__ /* Android */ +# ifdef __LP64__ +# define _gl_flags_file_t int +# else +# define _gl_flags_file_t short +# endif /* Up to this commit from 2015-10-12 the innards of FILE were public, and fp_ub could be defined like for OpenBSD, @@ -70,8 +75,8 @@ # define fp_ ((struct { unsigned char *_p; \ int _r; \ int _w; \ - int _flags; \ - int _file; \ + _gl_flags_file_t _flags; \ + _gl_flags_file_t _file; \ struct { unsigned char *_base; size_t _size; } _bf; \ int _lbfsize; \ void *_cookie; \ diff --git a/lib/stdio.in.h b/lib/stdio.in.h index acf29c4be0..4a8aa55528 100644 --- a/lib/stdio.in.h +++ b/lib/stdio.in.h @@ -118,6 +118,13 @@ # include #endif +/* Android 4.3 declares renameat in , not in . */ +/* But in any case avoid namespace pollution on glibc systems. */ +#if (@GNULIB_RENAMEAT@ || defined GNULIB_POSIXCHECK) && defined __ANDROID__ \ + && ! defined __GLIBC__ +# include +#endif + /* MSVC declares 'perror' in , not in . We must include it before we #define perror rpl_perror. */ /* But in any case avoid namespace pollution on glibc systems. */ diff --git a/lib/stdlib.in.h b/lib/stdlib.in.h index d80d7ec6b0..be8ab3b86c 100644 --- a/lib/stdlib.in.h +++ b/lib/stdlib.in.h @@ -306,9 +306,18 @@ _GL_WARN_ON_USE (malloc, "malloc is not POSIX compliant everywhere - " _GL_FUNCDECL_RPL (mbtowc, int, (wchar_t *pwc, const char *s, size_t n)); _GL_CXXALIAS_RPL (mbtowc, int, (wchar_t *pwc, const char *s, size_t n)); # else +# if !@HAVE_MBTOWC@ +_GL_FUNCDECL_SYS (mbtowc, int, (wchar_t *pwc, const char *s, size_t n)); +# endif _GL_CXXALIAS_SYS (mbtowc, int, (wchar_t *pwc, const char *s, size_t n)); # endif _GL_CXXALIASWARN (mbtowc); +#elif defined GNULIB_POSIXCHECK +# undef mbtowc +# if HAVE_RAW_DECL_MBTOWC +_GL_WARN_ON_USE (mbtowc, "mbtowc is not portable - " + "use gnulib module mbtowc for portability"); +# endif #endif #if @GNULIB_MKDTEMP@ @@ -573,10 +582,19 @@ _GL_WARN_ON_USE (qsort_r, "qsort_r is not portable - " #if @GNULIB_RANDOM@ -# if !@HAVE_RANDOM@ +# if @REPLACE_RANDOM@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef random +# define random rpl_random +# endif +_GL_FUNCDECL_RPL (random, long, (void)); +_GL_CXXALIAS_RPL (random, long, (void)); +# else +# if !@HAVE_RANDOM@ _GL_FUNCDECL_SYS (random, long, (void)); -# endif +# endif _GL_CXXALIAS_SYS (random, long, (void)); +# endif _GL_CXXALIASWARN (random); #elif defined GNULIB_POSIXCHECK # undef random @@ -587,10 +605,19 @@ _GL_WARN_ON_USE (random, "random is unportable - " #endif #if @GNULIB_RANDOM@ -# if !@HAVE_RANDOM@ +# if @REPLACE_RANDOM@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef srandom +# define srandom rpl_srandom +# endif +_GL_FUNCDECL_RPL (srandom, void, (unsigned int seed)); +_GL_CXXALIAS_RPL (srandom, void, (unsigned int seed)); +# else +# if !@HAVE_RANDOM@ _GL_FUNCDECL_SYS (srandom, void, (unsigned int seed)); -# endif +# endif _GL_CXXALIAS_SYS (srandom, void, (unsigned int seed)); +# endif _GL_CXXALIASWARN (srandom); #elif defined GNULIB_POSIXCHECK # undef srandom @@ -601,31 +628,52 @@ _GL_WARN_ON_USE (srandom, "srandom is unportable - " #endif #if @GNULIB_RANDOM@ -# if !@HAVE_RANDOM@ || !@HAVE_DECL_INITSTATE@ +# if @REPLACE_INITSTATE@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef initstate +# define initstate rpl_initstate +# endif +_GL_FUNCDECL_RPL (initstate, char *, + (unsigned int seed, char *buf, size_t buf_size) + _GL_ARG_NONNULL ((2))); +_GL_CXXALIAS_RPL (initstate, char *, + (unsigned int seed, char *buf, size_t buf_size)); +# else +# if !@HAVE_INITSTATE@ || !@HAVE_DECL_INITSTATE@ _GL_FUNCDECL_SYS (initstate, char *, (unsigned int seed, char *buf, size_t buf_size) _GL_ARG_NONNULL ((2))); -# endif +# endif _GL_CXXALIAS_SYS (initstate, char *, (unsigned int seed, char *buf, size_t buf_size)); +# endif _GL_CXXALIASWARN (initstate); #elif defined GNULIB_POSIXCHECK # undef initstate -# if HAVE_RAW_DECL_INITSTATE_R +# if HAVE_RAW_DECL_INITSTATE _GL_WARN_ON_USE (initstate, "initstate is unportable - " "use gnulib module random for portability"); # endif #endif #if @GNULIB_RANDOM@ -# if !@HAVE_RANDOM@ || !@HAVE_DECL_SETSTATE@ +# if @REPLACE_SETSTATE@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef setstate +# define setstate rpl_setstate +# endif +_GL_FUNCDECL_RPL (setstate, char *, (char *arg_state) _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_RPL (setstate, char *, (char *arg_state)); +# else +# if !@HAVE_SETSTATE@ || !@HAVE_DECL_SETSTATE@ _GL_FUNCDECL_SYS (setstate, char *, (char *arg_state) _GL_ARG_NONNULL ((1))); -# endif +# endif _GL_CXXALIAS_SYS (setstate, char *, (char *arg_state)); +# endif _GL_CXXALIASWARN (setstate); #elif defined GNULIB_POSIXCHECK # undef setstate -# if HAVE_RAW_DECL_SETSTATE_R +# if HAVE_RAW_DECL_SETSTATE _GL_WARN_ON_USE (setstate, "setstate is unportable - " "use gnulib module random for portability"); # endif diff --git a/lib/sys_stat.in.h b/lib/sys_stat.in.h index 58fa93fd0a..9ddd1a8d00 100644 --- a/lib/sys_stat.in.h +++ b/lib/sys_stat.in.h @@ -54,9 +54,16 @@ /* The definition of _GL_WARN_ON_USE is copied here. */ +/* Before doing "#define mknod rpl_mknod" below, we need to include all + headers that may declare mknod(). OS/2 kLIBC declares mknod() in + , not in . */ +#ifdef __KLIBC__ +# include +#endif + /* Before doing "#define mkdir rpl_mkdir" below, we need to include all headers that may declare mkdir(). Native Windows platforms declare mkdir - in and/or , not in . */ + in and/or , not in . */ #if defined _WIN32 && ! defined __CYGWIN__ # include /* mingw32, mingw64 */ # include /* mingw64, MSVC 9 */ diff --git a/lib/unistd.in.h b/lib/unistd.in.h index a10ca28a53..7778d25dc7 100644 --- a/lib/unistd.in.h +++ b/lib/unistd.in.h @@ -68,9 +68,11 @@ # include #endif -/* Cygwin 1.7.1 declares unlinkat in , not in . */ +/* Cygwin 1.7.1 and Android 4.3 declare unlinkat in , not in + . */ /* But avoid namespace pollution on glibc systems. */ -#if (@GNULIB_UNLINKAT@ || defined GNULIB_POSIXCHECK) && defined __CYGWIN__ \ +#if (@GNULIB_UNLINKAT@ || defined GNULIB_POSIXCHECK) \ + && (defined __CYGWIN__ || defined __ANDROID__) \ && ! defined __GLIBC__ # include #endif @@ -113,6 +115,13 @@ # include #endif +/* Android 4.3 declares fchownat in , not in . */ +/* But avoid namespace pollution on glibc systems. */ +#if (@GNULIB_FCHOWNAT@ || defined GNULIB_POSIXCHECK) && defined __ANDROID__ \ + && !defined __GLIBC__ +# include +#endif + /* MSVC defines off_t in . May also define off_t to a 64-bit type on native Windows. */ #if !@HAVE_UNISTD_H@ || @WINDOWS_64_BIT_OFF_T@ diff --git a/lib/verify.h b/lib/verify.h index b2e5f6446e..6930645a35 100644 --- a/lib/verify.h +++ b/lib/verify.h @@ -26,7 +26,7 @@ here generates easier-to-read diagnostics when verify (R) fails. Define _GL_HAVE_STATIC_ASSERT to 1 if static_assert works as per C++11. - This will likely be supported by future GCC versions, in C++ mode. + This is supported by GCC 6.1.0 and later, in C++ mode. Use this only with GCC. If we were willing to slow 'configure' down we could also use it with other compilers, but since this @@ -36,9 +36,7 @@ && !defined __cplusplus) # define _GL_HAVE__STATIC_ASSERT 1 #endif -/* The condition (99 < __GNUC__) is temporary, until we know about the - first G++ release that supports static_assert. */ -#if (99 < __GNUC__) && defined __cplusplus +#if (6 <= __GNUC__) && defined __cplusplus # define _GL_HAVE_STATIC_ASSERT 1 #endif diff --git a/m4/stdlib_h.m4 b/m4/stdlib_h.m4 index cf064284b6..c5db804e4d 100644 --- a/m4/stdlib_h.m4 +++ b/m4/stdlib_h.m4 @@ -1,4 +1,4 @@ -# stdlib_h.m4 serial 45 +# stdlib_h.m4 serial 47 dnl Copyright (C) 2007-2019 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -23,7 +23,7 @@ AC_DEFUN([gl_STDLIB_H], # include #endif ]], [_Exit atoll canonicalize_file_name getloadavg getsubopt grantpt - initstate initstate_r mkdtemp mkostemp mkostemps mkstemp mkstemps + initstate initstate_r mbtowc mkdtemp mkostemp mkostemps mkstemp mkstemps posix_openpt ptsname ptsname_r qsort_r random random_r reallocarray realpath rpmatch secure_getenv setenv setstate setstate_r srandom srandom_r strtod strtoll strtoull unlockpt unsetenv]) @@ -81,7 +81,9 @@ AC_DEFUN([gl_STDLIB_H_DEFAULTS], HAVE_DECL_GETLOADAVG=1; AC_SUBST([HAVE_DECL_GETLOADAVG]) HAVE_GETSUBOPT=1; AC_SUBST([HAVE_GETSUBOPT]) HAVE_GRANTPT=1; AC_SUBST([HAVE_GRANTPT]) + HAVE_INITSTATE=1; AC_SUBST([HAVE_INITSTATE]) HAVE_DECL_INITSTATE=1; AC_SUBST([HAVE_DECL_INITSTATE]) + HAVE_MBTOWC=1; AC_SUBST([HAVE_MBTOWC]) HAVE_MKDTEMP=1; AC_SUBST([HAVE_MKDTEMP]) HAVE_MKOSTEMP=1; AC_SUBST([HAVE_MKOSTEMP]) HAVE_MKOSTEMPS=1; AC_SUBST([HAVE_MKOSTEMPS]) @@ -100,6 +102,7 @@ AC_DEFUN([gl_STDLIB_H_DEFAULTS], HAVE_SECURE_GETENV=1; AC_SUBST([HAVE_SECURE_GETENV]) HAVE_SETENV=1; AC_SUBST([HAVE_SETENV]) HAVE_DECL_SETENV=1; AC_SUBST([HAVE_DECL_SETENV]) + HAVE_SETSTATE=1; AC_SUBST([HAVE_SETSTATE]) HAVE_DECL_SETSTATE=1; AC_SUBST([HAVE_DECL_SETSTATE]) HAVE_STRTOD=1; AC_SUBST([HAVE_STRTOD]) HAVE_STRTOLL=1; AC_SUBST([HAVE_STRTOLL]) @@ -110,6 +113,7 @@ AC_DEFUN([gl_STDLIB_H_DEFAULTS], HAVE_DECL_UNSETENV=1; AC_SUBST([HAVE_DECL_UNSETENV]) REPLACE_CALLOC=0; AC_SUBST([REPLACE_CALLOC]) REPLACE_CANONICALIZE_FILE_NAME=0; AC_SUBST([REPLACE_CANONICALIZE_FILE_NAME]) + REPLACE_INITSTATE=0; AC_SUBST([REPLACE_INITSTATE]) REPLACE_MALLOC=0; AC_SUBST([REPLACE_MALLOC]) REPLACE_MBTOWC=0; AC_SUBST([REPLACE_MBTOWC]) REPLACE_MKSTEMP=0; AC_SUBST([REPLACE_MKSTEMP]) @@ -117,10 +121,12 @@ AC_DEFUN([gl_STDLIB_H_DEFAULTS], REPLACE_PTSNAME_R=0; AC_SUBST([REPLACE_PTSNAME_R]) REPLACE_PUTENV=0; AC_SUBST([REPLACE_PUTENV]) REPLACE_QSORT_R=0; AC_SUBST([REPLACE_QSORT_R]) + REPLACE_RANDOM=0; AC_SUBST([REPLACE_RANDOM]) REPLACE_RANDOM_R=0; AC_SUBST([REPLACE_RANDOM_R]) REPLACE_REALLOC=0; AC_SUBST([REPLACE_REALLOC]) REPLACE_REALPATH=0; AC_SUBST([REPLACE_REALPATH]) REPLACE_SETENV=0; AC_SUBST([REPLACE_SETENV]) + REPLACE_SETSTATE=0; AC_SUBST([REPLACE_SETSTATE]) REPLACE_STRTOD=0; AC_SUBST([REPLACE_STRTOD]) REPLACE_UNSETENV=0; AC_SUBST([REPLACE_UNSETENV]) REPLACE_WCTOMB=0; AC_SUBST([REPLACE_WCTOMB]) commit cc1c46e4122a08657a7c75495115d1c60efb1b31 Author: Paul Eggert Date: Sun Jan 27 15:49:53 2019 -0800 forward-line now works with bignums * src/cmds.c (Fforward_line): Support bignum arg. (scan_newline): Return void since no caller was using the return value. * src/search.c (find_newline, scan_newline_from_point) (find_newline1): Return the number of newlines counted, not the count shortage, so that the return value always fits in ptrdiff_t even if the original count was a bignum. All callers changed. * test/src/cmds-tests.el (forward-line-with-bignum): New test. diff --git a/src/cmds.c b/src/cmds.c index 1f81b9986a..239e3be5c0 100644 --- a/src/cmds.c +++ b/src/cmds.c @@ -121,28 +121,36 @@ it as a line moved across, even though there is no next line to go to its beginning. */) (Lisp_Object n) { - ptrdiff_t opoint = PT, pos, pos_byte, shortage, count; + ptrdiff_t opoint = PT, pos, pos_byte, count; + bool excessive = false; if (NILP (n)) count = 1; else { - CHECK_FIXNUM (n); - count = XFIXNUM (n); + CHECK_INTEGER (n); + if (FIXNUMP (n) + && -BUF_BYTES_MAX <= XFIXNUM (n) && XFIXNUM (n) <= BUF_BYTES_MAX) + count = XFIXNUM (n); + else + { + count = !NILP (Fnatnump (n)) ? BUF_BYTES_MAX : -BUF_BYTES_MAX; + excessive = true; + } } - shortage = scan_newline_from_point (count, &pos, &pos_byte); + ptrdiff_t counted = scan_newline_from_point (count, &pos, &pos_byte); SET_PT_BOTH (pos, pos_byte); - if (shortage > 0 - && (count <= 0 - || (ZV > BEGV - && PT != opoint - && (FETCH_BYTE (PT_BYTE - 1) != '\n')))) - shortage--; - - return make_fixnum (count <= 0 ? - shortage : shortage); + ptrdiff_t shortage = count - (count <= 0) - counted; + if (shortage != 0) + shortage -= (count <= 0 ? -1 + : (BEGV < ZV && PT != opoint + && FETCH_BYTE (PT_BYTE - 1) != '\n')); + return (excessive + ? CALLN (Fplus, make_fixnum (shortage - count), n) + : make_fixnum (shortage)); } DEFUN ("beginning-of-line", Fbeginning_of_line, Sbeginning_of_line, 0, 1, "^p", diff --git a/src/editfns.c b/src/editfns.c index 01376b0637..3edfd1dc20 100644 --- a/src/editfns.c +++ b/src/editfns.c @@ -668,7 +668,7 @@ Field boundaries are not noticed if `inhibit-field-text-motion' is non-nil. */) /* It is possible that NEW_POS is not within the same field as OLD_POS; try to move NEW_POS so that it is. */ { - ptrdiff_t shortage; + ptrdiff_t counted; Lisp_Object field_bound; if (fwd) @@ -691,8 +691,8 @@ Field boundaries are not noticed if `inhibit-field-text-motion' is non-nil. */) there's an intervening newline or not. */ || (find_newline (XFIXNAT (new_pos), -1, XFIXNAT (field_bound), -1, - fwd ? -1 : 1, &shortage, NULL, 1), - shortage != 0))) + fwd ? -1 : 1, &counted, NULL, 1), + counted == 0))) /* Constrain NEW_POS to FIELD_BOUND. */ new_pos = field_bound; diff --git a/src/lisp.h b/src/lisp.h index 78bc423bed..c5631e2845 100644 --- a/src/lisp.h +++ b/src/lisp.h @@ -4271,8 +4271,8 @@ extern ptrdiff_t fast_looking_at (Lisp_Object, ptrdiff_t, ptrdiff_t, ptrdiff_t, ptrdiff_t, Lisp_Object); extern ptrdiff_t find_newline (ptrdiff_t, ptrdiff_t, ptrdiff_t, ptrdiff_t, ptrdiff_t, ptrdiff_t *, ptrdiff_t *, bool); -extern ptrdiff_t scan_newline (ptrdiff_t, ptrdiff_t, ptrdiff_t, ptrdiff_t, - ptrdiff_t, bool); +extern void scan_newline (ptrdiff_t, ptrdiff_t, ptrdiff_t, ptrdiff_t, + ptrdiff_t, bool); extern ptrdiff_t scan_newline_from_point (ptrdiff_t, ptrdiff_t *, ptrdiff_t *); extern ptrdiff_t find_newline_no_quit (ptrdiff_t, ptrdiff_t, ptrdiff_t, ptrdiff_t *); diff --git a/src/search.c b/src/search.c index 059f8fc4d2..17bc8d0c94 100644 --- a/src/search.c +++ b/src/search.c @@ -647,14 +647,16 @@ newline_cache_on_off (struct buffer *buf) If COUNT is zero, do anything you please; run rogue, for all I care. If END is zero, use BEGV or ZV instead, as appropriate for the - direction indicated by COUNT. + direction indicated by COUNT. If START_BYTE is -1 it is unknown, + and similarly for END_BYTE. - If we find COUNT instances, set *SHORTAGE to zero, and return the + If we find COUNT instances, set *COUNTED to COUNT, and return the position past the COUNTth match. Note that for reverse motion this is not the same as the usual convention for Emacs motion commands. - If we don't find COUNT instances before reaching END, set *SHORTAGE - to the number of newlines left unfound, and return END. + If we don't find COUNT instances before reaching END, set *COUNTED + to the number of newlines left found (negated if COUNT is negative), + and return END. If BYTEPOS is not NULL, set *BYTEPOS to the byte position corresponding to the returned character position. @@ -664,23 +666,17 @@ newline_cache_on_off (struct buffer *buf) ptrdiff_t find_newline (ptrdiff_t start, ptrdiff_t start_byte, ptrdiff_t end, - ptrdiff_t end_byte, ptrdiff_t count, ptrdiff_t *shortage, + ptrdiff_t end_byte, ptrdiff_t count, ptrdiff_t *counted, ptrdiff_t *bytepos, bool allow_quit) { struct region_cache *newline_cache; - int direction; struct buffer *cache_buffer; - if (count > 0) + if (!end) { - direction = 1; - if (!end) + if (count > 0) end = ZV, end_byte = ZV_BYTE; - } - else - { - direction = -1; - if (!end) + else end = BEGV, end_byte = BEGV_BYTE; } if (end_byte == -1) @@ -692,8 +688,8 @@ find_newline (ptrdiff_t start, ptrdiff_t start_byte, ptrdiff_t end, else cache_buffer = current_buffer; - if (shortage != 0) - *shortage = 0; + if (counted) + *counted = count; if (count > 0) while (start != end) @@ -936,8 +932,8 @@ find_newline (ptrdiff_t start, ptrdiff_t start_byte, ptrdiff_t end, } } - if (shortage) - *shortage = count * direction; + if (counted) + *counted -= count; if (bytepos) { *bytepos = start_byte == -1 ? CHAR_TO_BYTE (start) : start_byte; @@ -952,30 +948,28 @@ find_newline (ptrdiff_t start, ptrdiff_t start_byte, ptrdiff_t end, We report the resulting position by calling TEMP_SET_PT_BOTH. If we find COUNT instances. we position after (always after, - even if scanning backwards) the COUNTth match, and return 0. + even if scanning backwards) the COUNTth match. If we don't find COUNT instances before reaching the end of the - buffer (or the beginning, if scanning backwards), we return - the number of line boundaries left unfound, and position at + buffer (or the beginning, if scanning backwards), we position at the limit we bumped up against. If ALLOW_QUIT, check for quitting. That's good to do except in special cases. */ -ptrdiff_t +void scan_newline (ptrdiff_t start, ptrdiff_t start_byte, ptrdiff_t limit, ptrdiff_t limit_byte, ptrdiff_t count, bool allow_quit) { - ptrdiff_t charpos, bytepos, shortage; + ptrdiff_t charpos, bytepos, counted; charpos = find_newline (start, start_byte, limit, limit_byte, - count, &shortage, &bytepos, allow_quit); - if (shortage) + count, &counted, &bytepos, allow_quit); + if (counted != count) TEMP_SET_PT_BOTH (limit, limit_byte); else TEMP_SET_PT_BOTH (charpos, bytepos); - return shortage; } /* Like above, but always scan from point and report the @@ -985,19 +979,19 @@ ptrdiff_t scan_newline_from_point (ptrdiff_t count, ptrdiff_t *charpos, ptrdiff_t *bytepos) { - ptrdiff_t shortage; + ptrdiff_t counted; if (count <= 0) *charpos = find_newline (PT, PT_BYTE, BEGV, BEGV_BYTE, count - 1, - &shortage, bytepos, 1); + &counted, bytepos, 1); else *charpos = find_newline (PT, PT_BYTE, ZV, ZV_BYTE, count, - &shortage, bytepos, 1); - return shortage; + &counted, bytepos, 1); + return counted; } /* Like find_newline, but doesn't allow QUITting and doesn't return - SHORTAGE. */ + COUNTED. */ ptrdiff_t find_newline_no_quit (ptrdiff_t from, ptrdiff_t frombyte, ptrdiff_t cnt, ptrdiff_t *bytepos) @@ -1013,10 +1007,10 @@ ptrdiff_t find_before_next_newline (ptrdiff_t from, ptrdiff_t to, ptrdiff_t cnt, ptrdiff_t *bytepos) { - ptrdiff_t shortage; - ptrdiff_t pos = find_newline (from, -1, to, -1, cnt, &shortage, bytepos, 1); + ptrdiff_t counted; + ptrdiff_t pos = find_newline (from, -1, to, -1, cnt, &counted, bytepos, 1); - if (shortage == 0) + if (counted == cnt) { if (bytepos) DEC_BOTH (pos, *bytepos); @@ -3210,7 +3204,7 @@ DEFUN ("regexp-quote", Fregexp_quote, Sregexp_quote, 1, 1, 0, /* Like find_newline, but doesn't use the cache, and only searches forward. */ static ptrdiff_t find_newline1 (ptrdiff_t start, ptrdiff_t start_byte, ptrdiff_t end, - ptrdiff_t end_byte, ptrdiff_t count, ptrdiff_t *shortage, + ptrdiff_t end_byte, ptrdiff_t count, ptrdiff_t *counted, ptrdiff_t *bytepos, bool allow_quit) { if (count > 0) @@ -3226,8 +3220,8 @@ find_newline1 (ptrdiff_t start, ptrdiff_t start_byte, ptrdiff_t end, if (end_byte == -1) end_byte = CHAR_TO_BYTE (end); - if (shortage != 0) - *shortage = 0; + if (counted) + *counted = count; if (count > 0) while (start != end) @@ -3284,8 +3278,8 @@ find_newline1 (ptrdiff_t start, ptrdiff_t start_byte, ptrdiff_t end, } } - if (shortage) - *shortage = count; + if (counted) + *counted -= count; if (bytepos) { *bytepos = start_byte == -1 ? CHAR_TO_BYTE (start) : start_byte; @@ -3306,7 +3300,7 @@ the buffer. If the buffer doesn't have a cache, the value is nil. */) (Lisp_Object buffer) { struct buffer *buf, *old = NULL; - ptrdiff_t shortage, nl_count_cache, nl_count_buf; + ptrdiff_t nl_count_cache, nl_count_buf; Lisp_Object cache_newlines, buf_newlines, val; ptrdiff_t from, found, i; @@ -3332,8 +3326,7 @@ the buffer. If the buffer doesn't have a cache, the value is nil. */) /* How many newlines are there according to the cache? */ find_newline (BEGV, BEGV_BYTE, ZV, ZV_BYTE, - TYPE_MAXIMUM (ptrdiff_t), &shortage, NULL, true); - nl_count_cache = TYPE_MAXIMUM (ptrdiff_t) - shortage; + TYPE_MAXIMUM (ptrdiff_t), &nl_count_cache, NULL, true); /* Create vector and populate it. */ cache_newlines = make_uninit_vector (nl_count_cache); @@ -3342,11 +3335,11 @@ the buffer. If the buffer doesn't have a cache, the value is nil. */) { for (from = BEGV, found = from, i = 0; from < ZV; from = found, i++) { - ptrdiff_t from_byte = CHAR_TO_BYTE (from); + ptrdiff_t from_byte = CHAR_TO_BYTE (from), counted; - found = find_newline (from, from_byte, 0, -1, 1, &shortage, + found = find_newline (from, from_byte, 0, -1, 1, &counted, NULL, true); - if (shortage != 0 || i >= nl_count_cache) + if (counted == 0 || i >= nl_count_cache) break; ASET (cache_newlines, i, make_fixnum (found - 1)); } @@ -3357,18 +3350,17 @@ the buffer. If the buffer doesn't have a cache, the value is nil. */) /* Now do the same, but without using the cache. */ find_newline1 (BEGV, BEGV_BYTE, ZV, ZV_BYTE, - TYPE_MAXIMUM (ptrdiff_t), &shortage, NULL, true); - nl_count_buf = TYPE_MAXIMUM (ptrdiff_t) - shortage; + TYPE_MAXIMUM (ptrdiff_t), &nl_count_buf, NULL, true); buf_newlines = make_uninit_vector (nl_count_buf); if (nl_count_buf) { for (from = BEGV, found = from, i = 0; from < ZV; from = found, i++) { - ptrdiff_t from_byte = CHAR_TO_BYTE (from); + ptrdiff_t from_byte = CHAR_TO_BYTE (from), counted; - found = find_newline1 (from, from_byte, 0, -1, 1, &shortage, + found = find_newline1 (from, from_byte, 0, -1, 1, &counted, NULL, true); - if (shortage != 0 || i >= nl_count_buf) + if (counted == 0 || i >= nl_count_buf) break; ASET (buf_newlines, i, make_fixnum (found - 1)); } diff --git a/test/src/cmds-tests.el b/test/src/cmds-tests.el index 05c6285877..bab8b5f26e 100644 --- a/test/src/cmds-tests.el +++ b/test/src/cmds-tests.el @@ -30,5 +30,13 @@ (let ((last-command-event ?a)) (should-error (self-insert-command -1)))) +(ert-deftest forward-line-with-bignum () + (with-temp-buffer + (insert "x\n") + (let ((shortage (forward-line (1- most-negative-fixnum)))) + (should (= shortage most-negative-fixnum))) + (let ((shortage (forward-line (+ 2 most-positive-fixnum)))) + (should (= shortage (1+ most-positive-fixnum)))))) + (provide 'cmds-tests) ;;; cmds-tests.el ends here commit 6c2ee11d8f27cc39f852b69a49056ba76ac6bee9 Author: Eli Zaretskii Date: Sun Jan 27 17:55:27 2019 +0200 Improve pdump load diagnostics * src/emacs.c (load_pdump): Improve diagnostics when pdump file fails to load correctly. diff --git a/src/emacs.c b/src/emacs.c index aed4e0d150..2acee8e6fe 100644 --- a/src/emacs.c +++ b/src/emacs.c @@ -813,12 +813,14 @@ load_pdump (int argc, char **argv) path_exec, DIRECTORY_SEP, argv0_base, suffix); result = pdumper_load (dump_file); } - else - fatal ("could not load dump file \"%s\": %s", - dump_file, dump_error_to_string (result)); if (result != PDUMPER_LOAD_SUCCESS) - dump_file = NULL; + { + if (result != PDUMPER_LOAD_FILE_NOT_FOUND) + fatal ("could not load dump file \"%s\": %s", + dump_file, dump_error_to_string (result)); + dump_file = NULL; + } out: return result;