diff --git a/doc/misc/texinfo.tex b/doc/misc/texinfo.tex index 1ddfef4b878..a32c84197ae 100644 --- a/doc/misc/texinfo.tex +++ b/doc/misc/texinfo.tex @@ -3,7 +3,7 @@ % Load plain if necessary, i.e., if running under initex. \expandafter\ifx\csname fmtname\endcsname\relax\input plain\fi % -\def\texinfoversion{2023-03-04.12} +\def\texinfoversion{2023-03-27.21} % % Copyright 1985, 1986, 1988, 1990-2023 Free Software Foundation, Inc. % @@ -1102,27 +1102,33 @@ % Output page labels information. % See PDF reference v.1.7 p.594, section 8.3.1. +% Page label ranges must be increasing. \ifpdf \def\pagelabels{% \def\title{0 << /P (T-) /S /D >>}% - \edef\roman{\the\romancount << /S /r >>}% - \edef\arabic{\the\arabiccount << /S /D >>}% % - % Page label ranges must be increasing. Remove any duplicates. - % (There is a slight chance of this being wrong if e.g. there is - % a @contents but no @titlepage, etc.) - % - \ifnum\romancount=0 \def\roman{}\fi - \ifnum\arabiccount=0 \def\title{}% + % support @contents at very end of document + \ifnum\contentsendcount=\pagecount + \ifnum\arabiccount<\romancount + \pdfcatalog{/PageLabels << /Nums + [\title + \the\arabiccount << /S /D >> + \the\romancount << /S /r >> + ] >> }\relax + \fi + % no contents in document + \else\ifnum\contentsendcount=0 + \pdfcatalog{/PageLabels << /Nums + [\title + \the\arabiccount << /S /D >> + ] >> }\relax \else - \ifnum\romancount=\arabiccount \def\roman{}\fi - \fi - % - \ifnum\romancount<\arabiccount - \pdfcatalog{/PageLabels << /Nums [\title \roman \arabic ] >> }\relax - \else - \pdfcatalog{/PageLabels << /Nums [\title \arabic \roman ] >> }\relax - \fi + \pdfcatalog{/PageLabels << /Nums + [\title + \the\romancount << /S /r >> + \the\contentsendcount << /S /D >> + ] >> }\relax + \fi\fi } \else \let\pagelabels\relax @@ -1131,6 +1137,8 @@ \newcount\pagecount \pagecount=0 \newcount\romancount \romancount=0 \newcount\arabiccount \arabiccount=0 +\newcount\contentsendcount \contentsendcount=0 + \ifpdf \let\ptxadvancepageno\advancepageno \def\advancepageno{% @@ -4102,7 +4110,6 @@ \nobreak\kern\dimen0 \endgroup \itemxneedsnegativevskiptrue - \penalty 10021 % for \indexpar \fi } @@ -4219,7 +4226,6 @@ % We can be in inner vertical mode in a footnote, although an % @itemize looks awful there. }% - \penalty 10021 % for \indexpar \flushcr } @@ -4784,17 +4790,11 @@ % and it is the two-letter name of the index. \def\doindex#1{\edef\indexname{#1}\parsearg\doindexxxx} -\def\doindexxxx #1{\indexpar\doind{\indexname}{#1}} +\def\doindexxxx #1{\doind{\indexname}{#1}} % like the previous two, but they put @code around the argument. \def\docodeindex#1{\edef\indexname{#1}\parsearg\docodeindexxxx} -\def\docodeindexxxx #1{\indexpar\docind{\indexname}{#1}} - -% End any open paragraph, unless we are immediately after @item in -% @itemize or @enumerate. -\def\indexpar{% -\ifnum\lastpenalty=10021 \else\endgraf\fi -} +\def\docodeindexxxx #1{\docind{\indexname}{#1}} % \definedummyword defines \#1 as \string\#1\space, thus effectively @@ -5351,9 +5351,7 @@ % ..., ready, GO: % \def\safewhatsit#1{\ifhmode - \whatsitpenalty = \lastpenalty #1% - \ifnum\whatsitpenalty>9999 \penalty\whatsitpenalty \fi \else % \lastskip and \lastpenalty cannot both be nonzero simultaneously. \whatsitskip = \lastskip @@ -6819,12 +6817,8 @@ % Get ready to use Arabic numerals again \def\contentsendroman{% \lastnegativepageno = \pageno - \global\pageno = \savepageno - % - % If \romancount > \arabiccount, the contents are at the end of the - % document. Otherwise, advance where the Arabic numerals start for - % the page numbers. - \ifnum\romancount>\arabiccount\else\global\arabiccount=\pagecount\fi + \global\pageno=1 + \contentsendcount = \pagecount } % Typeset the label for a chapter or appendix for the short contents. @@ -7597,7 +7591,7 @@ \parseargusing\activeparens{\printdefunline\deflineheader}% } \def\deflineheader#1 #2 #3\endheader{% - \defname{#1}{}{#2}\magicamp\defunargs{#3\unskip}% + \printdefname{#1}{}{#2}\magicamp\defunargs{#3\unskip}% } \def\deftypeline{% \doingtypefntrue @@ -7660,14 +7654,14 @@ % @deffn category name args \makedefun{deffn}#1 #2 #3\endheader{% \doind{fn}{\code{#2}}% - \defname{#1}{}{#2}\magicamp\defunargs{#3\unskip}% + \printdefname{#1}{}{#2}\magicamp\defunargs{#3\unskip}% } % @defop category class name args \makedefun{defop}#1 {\defopheaderx{#1\ \putwordon}} \def\defopheaderx#1#2 #3 #4\endheader{% \doind{fn}{\code{#3}\space\putwordon\ \code{#2}}% - \defname{#1\ \code{#2}}{}{#3}\magicamp\defunargs{#4\unskip}% + \printdefname{#1\ \code{#2}}{}{#3}\magicamp\defunargs{#4\unskip}% } % Typed functions: @@ -7676,7 +7670,7 @@ \makedefun{deftypefn}#1 #2 #3 #4\endheader{% \doind{fn}{\code{#3}}% \doingtypefntrue - \defname{#1}{#2}{#3}\defunargs{#4\unskip}% + \printdefname{#1}{#2}{#3}\defunargs{#4\unskip}% } % @deftypeop category class type name args @@ -7684,7 +7678,7 @@ \def\deftypeopheaderx#1#2 #3 #4 #5\endheader{% \doind{fn}{\code{#4}\space\putwordon\ \code{#1\ \code{#2}}}% \doingtypefntrue - \defname{#1\ \code{#2}}{#3}{#4}\defunargs{#5\unskip}% + \printdefname{#1\ \code{#2}}{#3}{#4}\defunargs{#5\unskip}% } % Typed variables: @@ -7692,14 +7686,14 @@ % @deftypevr category type var args \makedefun{deftypevr}#1 #2 #3 #4\endheader{% \doind{vr}{\code{#3}}% - \defname{#1}{#2}{#3}\defunargs{#4\unskip}% + \printdefname{#1}{#2}{#3}\defunargs{#4\unskip}% } % @deftypecv category class type var args \makedefun{deftypecv}#1 {\deftypecvheaderx{#1\ \putwordof}} \def\deftypecvheaderx#1#2 #3 #4 #5\endheader{% \doind{vr}{\code{#4}\space\putwordof\ \code{#2}}% - \defname{#1\ \code{#2}}{#3}{#4}\defunargs{#5\unskip}% + \printdefname{#1\ \code{#2}}{#3}{#4}\defunargs{#5\unskip}% } % Untyped variables: @@ -7716,7 +7710,7 @@ % @deftp category name args \makedefun{deftp}#1 #2 #3\endheader{% \doind{tp}{\code{#2}}% - \defname{#1}{}{#2}\defunargs{#3\unskip}% + \printdefname{#1}{}{#2}\defunargs{#3\unskip}% } % Remaining @defun-like shortcuts: @@ -7732,14 +7726,14 @@ \makedefun{defivar}{\defcvheaderx\putwordInstanceVariableof} \makedefun{deftypeivar}{\deftypecvheaderx\putwordInstanceVariableof} -% \defname, which formats the name of the @def (not the args). +% \printdefname, which formats the name of the @def (not the args). % #1 is the category, such as "Function". % #2 is the return type, if any. % #3 is the function name. % % We are followed by (but not passed) the arguments, if any. % -\def\defname#1#2#3{% +\def\printdefname#1#2#3{% \par % Get the values of \leftskip and \rightskip as they were outside the @def... \advance\leftskip by -\defbodyindent @@ -7864,7 +7858,7 @@ % If we encounter &foo, then turn on ()-hacking afterwards \newif\ifampseen -\def\amprm#1 {\ampseentrue{\bf\ }} +\def\amprm#1 {\ampseentrue{\rm\ }} \def\parenfont{% \ifampseen @@ -8188,12 +8182,12 @@ % % We are in \macrobodyctxt, and the \xdef causes backslashshes in the macro % body to be transformed. -% Set \macrobody to the body of the macro, and call \defmacro. +% Set \macrobody to the body of the macro, and call \macrodef. % {\catcode`\ =\other\long\gdef\parsemacbody#1@end macro{% -\xdef\macrobody{\eatcr{#1}}\endgroup\defmacro}}% +\xdef\macrobody{\eatcr{#1}}\endgroup\macrodef}}% {\catcode`\ =\other\long\gdef\parsermacbody#1@end rmacro{% -\xdef\macrobody{\eatcr{#1}}\endgroup\defmacro}}% +\xdef\macrobody{\eatcr{#1}}\endgroup\macrodef}}% % Make @ a letter, so that we can make private-to-Texinfo macro names. \edef\texiatcatcode{\the\catcode`\@} @@ -8412,16 +8406,17 @@ % \xdef is used so that macro definitions will survive the file % they're defined in: @include reads the file inside a group. % -\def\defmacro{% +\def\macrodef{% \let\hash=##% convert placeholders to macro parameter chars \ifnum\paramno=1 - \def\xeatspaces##1{##1}% - % This removes the pair of braces around the argument. We don't - % use \eatspaces, because this can cause ends of lines to be lost - % when the argument to \eatspaces is read, leading to line-based - % commands like "@itemize" not being read correctly. + \long\def\xeatspaces##1{##1}% + % We don't use \xeatspaces for single-argument macros, because we + % want to keep ends of lines. This definition removes \xeatspaces + % when \macrobody is expanded below. \else - \let\xeatspaces\relax % suppress expansion + \def\xeatspaces{\string\xeatspaces}% + % This expands \xeatspaces as a sequence of character tokens, which + % stops \scantokens inserting an extra space after the control sequence. \fi \ifcase\paramno % 0 @@ -8590,40 +8585,35 @@ % @linemacro \parseargdef\linemacro{% - \linegetargs#1 \linegetargs - \expandafter\linegetparamlist\argl;% + \getargs{#1}% now \macname is the macname and \argl the arglist + \ifx\argl\empty + \paramno=0 + \let\hash\relax + \def\paramlist{\hash 1\endlinemacro}% + \else + \expandafter\linegetparamlist\argl;% + \fi \begingroup \macrobodyctxt \usembodybackslash \parselinemacrobody } -% Parse the arguments to a @linemacro line. Set \macname to the name -% of the macro and \argl to the list of arguments. -\def\linegetargs#1 #2\linegetargs{% - \macname={#1}% - \def\argl{#2}% -} - % Build up \paramlist which will be used as the parameter text for the macro. % At the end it will be like "#1 #2 #3\endlinemacro". \def\linegetparamlist#1;{% \paramno=0\def\paramlist{}% - \let\hash\relax \let\xeatspaces\relax - \linegetparamlistxxx#1; % + \let\hash\relax + \linegetparamlistxxx#1,;,% } -\def\linegetparamlistxxx#1 {% +\def\linegetparamlistxxx#1,{% \if#1;\let\next=\linegetparamlistxxxx \else \let\next=\linegetparamlistxxx \advance\paramno by 1 \expandafter\edef\csname macarg.\eatspaces{#1}\endcsname - {\noexpand\xeatspaces{\hash\the\paramno}}% + {\hash\the\paramno}% \edef\paramlist{\paramlist\hash\the\paramno\space}% \fi\next} \def\linegetparamlistxxxx{% - \ifx\paramlist\empty - \def\paramlist{\hash 1\endlinemacro}% - \else - \expandafter\fixparamlist\paramlist\fixparamlist - \fi + \expandafter\fixparamlist\paramlist\fixparamlist } % Replace final space token \def\fixparamlist#1 \fixparamlist{% @@ -8633,7 +8623,6 @@ % Read the body of the macro, replacing backslash-surrounded variables % {\catcode`\ =\other\long\gdef\parselinemacrobody#1@end linemacro{% -\let\xeatspaces\relax \xdef\macrobody{#1}% \endgroup \linemacrodef @@ -8642,26 +8631,20 @@ % Make the definition \def\linemacrodef{% \let\hash=##% - \let\xeatspaces\relax \expandafter\xdef\csname\the\macname\endcsname{% \bgroup - \noexpand\scanctxt \noexpand\parsearg \expandafter\noexpand\csname\the\macname @@\endcsname } \expandafter\xdef\csname\the\macname @@\endcsname##1{% \egroup \expandafter\noexpand - \csname\the\macname @@@\endcsname##1 \noexpand\endlinemacro - % Note that we append a space to the macro line to terminate the last - % argument in case the final argument is empty. @xeatspaces may be needed - % to remove this space. + \csname\the\macname @@@\endcsname##1\noexpand\endlinemacro } \expandafter\expandafter \expandafter\xdef \expandafter\expandafter\csname\the\macname @@@\endcsname\paramlist{% \newlinechar=13 % split \macrobody into lines - \let\noexpand\xeatspaces\noexpand\eatspaces \noexpand\scantokens{\macrobody}% } } @@ -9659,8 +9642,8 @@ % \def\caption{\docaption\thiscaption} \def\shortcaption{\docaption\thisshortcaption} -\def\docaption{\checkenv\float \bgroup\scanctxt\defcaption} -\def\defcaption#1#2{\egroup \def#1{#2}} +\def\docaption{\checkenv\float \bgroup\scanctxt\docaptionz} +\def\docaptionz#1#2{\egroup \def#1{#2}} % The parameter is the control sequence identifying the counter we are % going to use. Create it if it doesn't exist and assign it to \floatno. diff --git a/lib/acl-internal.h b/lib/acl-internal.h index c97e847cdc5..496e41d7b21 100644 --- a/lib/acl-internal.h +++ b/lib/acl-internal.h @@ -17,6 +17,11 @@ Written by Paul Eggert, Andreas Grünbacher, and Bruno Haible. */ +/* This file uses _GL_INLINE_HEADER_BEGIN, _GL_INLINE, _GL_ATTRIBUTE_PURE. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + #include "acl.h" #include @@ -60,9 +65,6 @@ extern int aclsort (int, int, struct acl *); # define fchmod(fd, mode) (-1) #endif -#ifndef _GL_INLINE_HEADER_BEGIN - #error "Please include config.h first." -#endif _GL_INLINE_HEADER_BEGIN #ifndef ACL_INTERNAL_INLINE # define ACL_INTERNAL_INLINE _GL_INLINE diff --git a/lib/acl.h b/lib/acl.h index 58e5797179e..0d021200556 100644 --- a/lib/acl.h +++ b/lib/acl.h @@ -20,6 +20,11 @@ #ifndef _GL_ACL_H #define _GL_ACL_H 1 +/* This file uses _GL_ATTRIBUTE_CONST. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + #include #include diff --git a/lib/attribute.h b/lib/attribute.h index 130644d8798..9464fde0f30 100644 --- a/lib/attribute.h +++ b/lib/attribute.h @@ -41,6 +41,21 @@ These names begin with 'ATTRIBUTE_' to avoid name clashes. */ +/* This file uses _GL_ATTRIBUTE_ALLOC_SIZE, _GL_ATTRIBUTE_ALWAYS_INLINE, + _GL_ATTRIBUTE_ARTIFICIAL, _GL_ATTRIBUTE_COLD, _GL_ATTRIBUTE_CONST, + _GL_ATTRIBUTE_DEALLOC, _GL_ATTRIBUTE_DEPRECATED, _GL_ATTRIBUTE_ERROR, + _GL_ATTRIBUTE_WARNING, _GL_ATTRIBUTE_EXTERNALLY_VISIBLE, + _GL_ATTRIBUTE_FALLTHROUGH, _GL_ATTRIBUTE_FORMAT, _GL_ATTRIBUTE_LEAF, + _GL_ATTRIBUTE_MALLOC, _GL_ATTRIBUTE_MAY_ALIAS, _GL_ATTRIBUTE_MAYBE_UNUSED, + _GL_ATTRIBUTE_NODISCARD, _GL_ATTRIBUTE_NOINLINE, _GL_ATTRIBUTE_NONNULL, + _GL_ATTRIBUTE_NONSTRING, _GL_ATTRIBUTE_NOTHROW, _GL_ATTRIBUTE_PACKED, + _GL_ATTRIBUTE_PURE, _GL_ATTRIBUTE_RETURNS_NONNULL, + _GL_ATTRIBUTE_SENTINEL. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + + /* =============== Attributes for specific kinds of functions =============== */ /* Attributes for functions that should not be used. */ diff --git a/lib/binary-io.h b/lib/binary-io.h index 6f4db253354..855d6f819f0 100644 --- a/lib/binary-io.h +++ b/lib/binary-io.h @@ -17,6 +17,11 @@ #ifndef _BINARY_H #define _BINARY_H +/* This file uses _GL_INLINE_HEADER_BEGIN, _GL_INLINE, _GL_UNUSED. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + /* For systems that distinguish between text and binary I/O. O_BINARY is guaranteed by the gnulib . */ #include @@ -25,9 +30,6 @@ so we include it here first. */ #include -#ifndef _GL_INLINE_HEADER_BEGIN - #error "Please include config.h first." -#endif _GL_INLINE_HEADER_BEGIN #ifndef BINARY_IO_INLINE # define BINARY_IO_INLINE _GL_INLINE diff --git a/lib/c++defs.h b/lib/c++defs.h index 8ad46951ad4..458c014de5c 100644 --- a/lib/c++defs.h +++ b/lib/c++defs.h @@ -99,6 +99,12 @@ Example: _GL_FUNCDECL_RPL (open, int, (const char *filename, int flags, ...) _GL_ARG_NONNULL ((1))); + + Note: Attributes, such as _GL_ATTRIBUTE_DEPRECATED, are supported in front + of a _GL_FUNCDECL_RPL invocation only in C mode, not in C++ mode. (That's + because + [[...]] extern "C" ; + is invalid syntax in C++.) */ #define _GL_FUNCDECL_RPL(func,rettype,parameters_and_attributes) \ _GL_FUNCDECL_RPL_1 (rpl_##func, rettype, parameters_and_attributes) diff --git a/lib/c-ctype.h b/lib/c-ctype.h index 35ca83d7d43..cb0f4f3ba1f 100644 --- a/lib/c-ctype.h +++ b/lib/c-ctype.h @@ -23,9 +23,11 @@ #ifndef C_CTYPE_H #define C_CTYPE_H -#ifndef _GL_INLINE_HEADER_BEGIN +/* This file uses _GL_INLINE_HEADER_BEGIN, _GL_INLINE. */ +#if !_GL_CONFIG_H_INCLUDED #error "Please include config.h first." #endif + _GL_INLINE_HEADER_BEGIN #ifndef C_CTYPE_INLINE # define C_CTYPE_INLINE _GL_INLINE diff --git a/lib/c-strcase.h b/lib/c-strcase.h index 9bcca01b27c..5dfa96c41f4 100644 --- a/lib/c-strcase.h +++ b/lib/c-strcase.h @@ -18,6 +18,11 @@ #ifndef C_STRCASE_H #define C_STRCASE_H +/* This file uses _GL_ATTRIBUTE_PURE. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + #include diff --git a/lib/careadlinkat.h b/lib/careadlinkat.h index 201d0415fff..562cf013b75 100644 --- a/lib/careadlinkat.h +++ b/lib/careadlinkat.h @@ -20,6 +20,11 @@ #ifndef _GL_CAREADLINKAT_H #define _GL_CAREADLINKAT_H +/* This file uses HAVE_READLINKAT. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + #include #include diff --git a/lib/count-leading-zeros.h b/lib/count-leading-zeros.h index 99151d695bf..9fe2a03ee09 100644 --- a/lib/count-leading-zeros.h +++ b/lib/count-leading-zeros.h @@ -19,12 +19,14 @@ #ifndef COUNT_LEADING_ZEROS_H #define COUNT_LEADING_ZEROS_H 1 +/* This file uses _GL_INLINE_HEADER_BEGIN, _GL_INLINE. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + #include #include -#ifndef _GL_INLINE_HEADER_BEGIN - #error "Please include config.h first." -#endif _GL_INLINE_HEADER_BEGIN #ifndef COUNT_LEADING_ZEROS_INLINE # define COUNT_LEADING_ZEROS_INLINE _GL_INLINE diff --git a/lib/count-one-bits.h b/lib/count-one-bits.h index 01a60b77b85..2821a1fb75e 100644 --- a/lib/count-one-bits.h +++ b/lib/count-one-bits.h @@ -19,12 +19,14 @@ #ifndef COUNT_ONE_BITS_H #define COUNT_ONE_BITS_H 1 +/* This file uses _GL_INLINE_HEADER_BEGIN, _GL_INLINE. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + #include #include -#ifndef _GL_INLINE_HEADER_BEGIN - #error "Please include config.h first." -#endif _GL_INLINE_HEADER_BEGIN #ifndef COUNT_ONE_BITS_INLINE # define COUNT_ONE_BITS_INLINE _GL_INLINE diff --git a/lib/count-trailing-zeros.h b/lib/count-trailing-zeros.h index ef8e164126a..9b33df76f6d 100644 --- a/lib/count-trailing-zeros.h +++ b/lib/count-trailing-zeros.h @@ -19,12 +19,14 @@ #ifndef COUNT_TRAILING_ZEROS_H #define COUNT_TRAILING_ZEROS_H 1 +/* This file uses _GL_INLINE_HEADER_BEGIN, _GL_INLINE. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + #include #include -#ifndef _GL_INLINE_HEADER_BEGIN - #error "Please include config.h first." -#endif _GL_INLINE_HEADER_BEGIN #ifndef COUNT_TRAILING_ZEROS_INLINE # define COUNT_TRAILING_ZEROS_INLINE _GL_INLINE diff --git a/lib/dirent-private.h b/lib/dirent-private.h new file mode 100644 index 00000000000..012b6837198 --- /dev/null +++ b/lib/dirent-private.h @@ -0,0 +1,67 @@ +/* Private details of the DIR type. + Copyright (C) 2011-2023 Free Software Foundation, Inc. + + This file 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 file 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 . */ + +#ifndef _DIRENT_PRIVATE_H +#define _DIRENT_PRIVATE_H 1 + +#if HAVE_DIRENT_H /* mingw */ + +# undef DIR + +struct gl_directory +{ + /* File descriptor to close during closedir(). + Needed for implementing fdopendir(). */ + int fd_to_close; + /* Pointer to the real DIR. */ + DIR *real_dirp; +}; + +/* Restore definition from dirent.h. */ +# define DIR struct gl_directory + +#else /* MSVC */ + +# define WIN32_LEAN_AND_MEAN +# include + +/* Don't assume that UNICODE is not defined. */ +# undef WIN32_FIND_DATA +# define WIN32_FIND_DATA WIN32_FIND_DATAA + +struct gl_directory +{ + /* File descriptor to close during closedir(). + Needed for implementing fdopendir(). */ + int fd_to_close; + /* Status, or error code to produce in next readdir() call. + -2 means the end of the directory is already reached, + -1 means the entry was already filled by FindFirstFile, + 0 means the entry needs to be filled using FindNextFile. + A positive value is an error code. */ + int status; + /* Handle, reading the directory, at current position. */ + HANDLE current; + /* Found directory entry. */ + WIN32_FIND_DATA entry; + /* Argument to pass to FindFirstFile. It consists of the absolutized + directory name, followed by a directory separator and the wildcards. */ + char dir_name_mask[1]; +}; + +#endif + +#endif /* _DIRENT_PRIVATE_H */ diff --git a/lib/dirent.in.h b/lib/dirent.in.h index 2aaabd054a8..d409a031ec8 100644 --- a/lib/dirent.in.h +++ b/lib/dirent.in.h @@ -29,6 +29,12 @@ #ifndef _@GUARD_PREFIX@_DIRENT_H #define _@GUARD_PREFIX@_DIRENT_H +/* This file uses _GL_ATTRIBUTE_DEALLOC, _GL_ATTRIBUTE_MALLOC, + _GL_ATTRIBUTE_PURE, GNULIB_POSIXCHECK, HAVE_RAW_DECL_*. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + /* Get ino_t. Needed on some systems, including glibc 2.8. */ #include @@ -50,11 +56,24 @@ struct dirent # define DT_LNK 10 /* symbolic link */ # define DT_SOCK 12 /* socket */ # define DT_WHT 14 /* whiteout */ -typedef struct gl_directory DIR; # define GNULIB_defined_struct_dirent 1 # endif #endif +#if !@DIR_HAS_FD_MEMBER@ +# if !GNULIB_defined_DIR +/* struct gl_directory is a type with a field 'int fd_to_close'. + It is needed for implementing fdopendir(). */ +struct gl_directory; +# if @HAVE_DIRENT_H@ +# define DIR struct gl_directory +# else +typedef struct gl_directory DIR; +# endif +# define GNULIB_defined_DIR 1 +# endif +#endif + /* _GL_ATTRIBUTE_DEALLOC (F, I) declares that the function returns pointers that can be freed by passing them as the Ith argument to the function F. */ @@ -143,7 +162,7 @@ _GL_CXXALIAS_SYS (opendir, DIR *, (const char *dir_name)); # endif _GL_CXXALIASWARN (opendir); #else -# if @GNULIB_CLOSEDIR@ && __GNUC__ >= 11 && !defined opendir +# if @GNULIB_CLOSEDIR@ && !GNULIB_defined_DIR && __GNUC__ >= 11 && !defined opendir /* For -Wmismatched-dealloc: Associate opendir with closedir or rpl_closedir. */ _GL_FUNCDECL_SYS (opendir, DIR *, @@ -161,10 +180,19 @@ _GL_WARN_ON_USE (opendir, "opendir is not portable - " #endif #if @GNULIB_READDIR@ -# if !@HAVE_READDIR@ +# if @REPLACE_READDIR@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef readdir +# define readdir rpl_readdir +# endif +_GL_FUNCDECL_RPL (readdir, struct dirent *, (DIR *dirp) _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_RPL (readdir, struct dirent *, (DIR *dirp)); +# else +# if !@HAVE_READDIR@ _GL_FUNCDECL_SYS (readdir, struct dirent *, (DIR *dirp) _GL_ARG_NONNULL ((1))); -# endif +# endif _GL_CXXALIAS_SYS (readdir, struct dirent *, (DIR *dirp)); +# endif _GL_CXXALIASWARN (readdir); #elif defined GNULIB_POSIXCHECK # undef readdir @@ -175,10 +203,19 @@ _GL_WARN_ON_USE (readdir, "readdir is not portable - " #endif #if @GNULIB_REWINDDIR@ -# if !@HAVE_REWINDDIR@ +# if @REPLACE_REWINDDIR@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef rewinddir +# define rewinddir rpl_rewinddir +# endif +_GL_FUNCDECL_RPL (rewinddir, void, (DIR *dirp) _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_RPL (rewinddir, void, (DIR *dirp)); +# else +# if !@HAVE_REWINDDIR@ _GL_FUNCDECL_SYS (rewinddir, void, (DIR *dirp) _GL_ARG_NONNULL ((1))); -# endif +# endif _GL_CXXALIAS_SYS (rewinddir, void, (DIR *dirp)); +# endif _GL_CXXALIASWARN (rewinddir); #elif defined GNULIB_POSIXCHECK # undef rewinddir diff --git a/lib/dirfd.c b/lib/dirfd.c index b2b1d25cdbd..75b2163c353 100644 --- a/lib/dirfd.c +++ b/lib/dirfd.c @@ -22,6 +22,10 @@ #include #include +#if GNULIB_defined_DIR +# include "dirent-private.h" +#endif + #ifdef __KLIBC__ # include # include @@ -78,11 +82,17 @@ _gl_unregister_dirp_fd (int fd) int dirfd (DIR *dir_p) { +#if GNULIB_defined_DIR + int fd = dir_p->fd_to_close; + if (fd == -1) + errno = EINVAL; + return fd; +#else int fd = DIR_TO_FD (dir_p); if (fd == -1) -#ifndef __KLIBC__ +# ifndef __KLIBC__ errno = ENOTSUP; -#else +# else { struct dirp_fd_list *dirp_fd; @@ -92,7 +102,8 @@ dirfd (DIR *dir_p) errno = EINVAL; } -#endif +# endif return fd; +#endif } diff --git a/lib/eloop-threshold.h b/lib/eloop-threshold.h index 510f261795d..d9b154e4868 100644 --- a/lib/eloop-threshold.h +++ b/lib/eloop-threshold.h @@ -19,6 +19,11 @@ #ifndef _ELOOP_THRESHOLD_H #define _ELOOP_THRESHOLD_H 1 +/* This file uses _GL_ATTRIBUTE_CONST. */ +#if !_LIBC && !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + #include #ifdef _LIBC # include diff --git a/lib/execinfo.in.h b/lib/execinfo.in.h index ff9293b6327..56b04d1d862 100644 --- a/lib/execinfo.in.h +++ b/lib/execinfo.in.h @@ -20,9 +20,11 @@ #ifndef _GL_EXECINFO_H #define _GL_EXECINFO_H -#ifndef _GL_INLINE_HEADER_BEGIN +/* This file uses _GL_INLINE_HEADER_BEGIN, _GL_INLINE. */ +#if !_GL_CONFIG_H_INCLUDED #error "Please include config.h first." #endif + _GL_INLINE_HEADER_BEGIN #ifndef _GL_EXECINFO_INLINE # define _GL_EXECINFO_INLINE _GL_INLINE diff --git a/lib/fcntl.in.h b/lib/fcntl.in.h index e034eaf9f5a..d0bb85f30b5 100644 --- a/lib/fcntl.in.h +++ b/lib/fcntl.in.h @@ -74,6 +74,11 @@ #ifndef _@GUARD_PREFIX@_FCNTL_H #define _@GUARD_PREFIX@_FCNTL_H +/* This file uses GNULIB_POSIXCHECK, HAVE_RAW_DECL_*. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + #ifndef __GLIBC__ /* Avoid namespace pollution on glibc systems. */ # include #endif diff --git a/lib/fdopendir.c b/lib/fdopendir.c index aa841e3e819..0f43d6ff349 100644 --- a/lib/fdopendir.c +++ b/lib/fdopendir.c @@ -25,44 +25,27 @@ #if !HAVE_FDOPENDIR -# include "openat.h" -# include "openat-priv.h" -# include "save-cwd.h" +# if GNULIB_defined_DIR +/* We are in control of the file descriptor of a DIR. */ -# if GNULIB_DIRENT_SAFER -# include "dirent--.h" -# endif +# include "dirent-private.h" -# ifndef REPLACE_FCHDIR -# define REPLACE_FCHDIR 0 -# endif +# if !REPLACE_FCHDIR +# error "unexpected configuration: GNULIB_defined_DIR but fchdir not replaced" +# endif -static DIR *fdopendir_with_dup (int, int, struct saved_cwd const *); -static DIR *fd_clone_opendir (int, struct saved_cwd const *); +DIR * +fdopendir (int fd) +{ + char const *name = _gl_directory_name (fd); + DIR *dirp = name ? opendir (name) : NULL; + if (dirp != NULL) + dirp->fd_to_close = fd; + return dirp; +} -/* Replacement for POSIX fdopendir. +# elif defined __KLIBC__ - First, try to simulate it via opendir ("/proc/self/fd/..."). Failing - that, simulate it by using fchdir metadata, or by doing - save_cwd/fchdir/opendir(".")/restore_cwd. - If either the save_cwd or the restore_cwd fails (relatively unlikely), - then give a diagnostic and exit nonzero. - - If successful, the resulting stream is based on FD in - implementations where streams are based on file descriptors and in - applications where no other thread or signal handler allocates or - frees file descriptors. In other cases, consult dirfd on the result - to find out whether FD is still being used. - - Otherwise, this function works just like POSIX fdopendir. - - W A R N I N G: - - Unlike other fd-related functions, this one places constraints on FD. - If this function returns successfully, FD is under control of the - dirent.h system, and the caller should not close or modify the state of - FD other than by the dirent.h functions. */ -# ifdef __KLIBC__ # include DIR * @@ -96,7 +79,48 @@ fdopendir (int fd) return dirp; } + # else +/* We are not in control of the file descriptor of a DIR, and therefore have to + play tricks with file descriptors before and after a call to opendir(). */ + +# include "openat.h" +# include "openat-priv.h" +# include "save-cwd.h" + +# if GNULIB_DIRENT_SAFER +# include "dirent--.h" +# endif + +# ifndef REPLACE_FCHDIR +# define REPLACE_FCHDIR 0 +# endif + +static DIR *fdopendir_with_dup (int, int, struct saved_cwd const *); +static DIR *fd_clone_opendir (int, struct saved_cwd const *); + +/* Replacement for POSIX fdopendir. + + First, try to simulate it via opendir ("/proc/self/fd/..."). Failing + that, simulate it by using fchdir metadata, or by doing + save_cwd/fchdir/opendir(".")/restore_cwd. + If either the save_cwd or the restore_cwd fails (relatively unlikely), + then give a diagnostic and exit nonzero. + + If successful, the resulting stream is based on FD in + implementations where streams are based on file descriptors and in + applications where no other thread or signal handler allocates or + frees file descriptors. In other cases, consult dirfd on the result + to find out whether FD is still being used. + + Otherwise, this function works just like POSIX fdopendir. + + W A R N I N G: + + Unlike other fd-related functions, this one places constraints on FD. + If this function returns successfully, FD is under control of the + dirent.h system, and the caller should not close or modify the state of + FD other than by the dirent.h functions. */ DIR * fdopendir (int fd) { @@ -119,7 +143,6 @@ fdopendir (int fd) return dir; } -# endif /* Like fdopendir, except that if OLDER_DUPFD is not -1, it is known to be a dup of FD which is less than FD - 1 and which will be @@ -188,7 +211,7 @@ fd_clone_opendir (int fd, struct saved_cwd const *cwd) if (proc_file != buf) free (proc_file); } -# if REPLACE_FCHDIR +# if REPLACE_FCHDIR if (! dir && EXPECTED_ERRNO (saved_errno)) { char const *name = _gl_directory_name (fd); @@ -203,7 +226,7 @@ fd_clone_opendir (int fd, struct saved_cwd const *cwd) return dp; } -# endif +# endif errno = saved_errno; return dir; } @@ -223,6 +246,8 @@ fd_clone_opendir (int fd, struct saved_cwd const *cwd) } } +# endif + #else /* HAVE_FDOPENDIR */ # include diff --git a/lib/file-has-acl.c b/lib/file-has-acl.c index b31a2ea2523..38bc806dc49 100644 --- a/lib/file-has-acl.c +++ b/lib/file-has-acl.c @@ -29,7 +29,7 @@ #include "acl-internal.h" -#if USE_ACL && GETXATTR_WITH_POSIX_ACLS +#if USE_ACL && HAVE_LINUX_XATTR_H && HAVE_LISTXATTR # include # include # include @@ -44,6 +44,20 @@ enum { ACE4_IDENTIFIER_GROUP = 0x00000040 }; +/* Return true if ATTR is in the set represented by the NUL-terminated + strings in LISTBUF, which is of size LISTSIZE. */ + +static bool +have_xattr (char const *attr, char const *listbuf, ssize_t listsize) +{ + char const *blim = listbuf + listsize; + for (char const *b = listbuf; b < blim; b += strlen (b) + 1) + for (char const *a = attr; *a == *b; a++, b++) + if (!*a) + return true; + return false; +} + /* Return 1 if given ACL in XDR format is non-trivial, 0 if it is trivial. -1 upon failure to determine it. Possibly change errno. Assume that the ACL is valid, except avoid undefined behavior even if invalid. @@ -137,37 +151,65 @@ file_has_acl (char const *name, struct stat const *sb) if (! S_ISLNK (sb->st_mode)) { -# if GETXATTR_WITH_POSIX_ACLS - - ssize_t ret; +# if HAVE_LINUX_XATTR_H && HAVE_LISTXATTR int initial_errno = errno; - ret = getxattr (name, XATTR_NAME_POSIX_ACL_ACCESS, NULL, 0); - if (ret < 0 && errno == ENODATA) - ret = 0; - else if (ret > 0) - return 1; + /* The max length of a trivial NFSv4 ACL is 6 words for owner, + 6 for group, 7 for everyone, all times 2 because there are + both allow and deny ACEs. There are 6 words for owner + because of type, flag, mask, wholen, "OWNER@"+pad and + similarly for group; everyone is another word to hold + "EVERYONE@". */ + typedef uint32_t trivial_NFSv4_xattr_buf[2 * (6 + 6 + 7)]; - if (ret == 0 && S_ISDIR (sb->st_mode)) + /* A buffer large enough to hold any trivial NFSv4 ACL, + and also useful as a small array of char. */ + union { + trivial_NFSv4_xattr_buf xattr; + char ch[sizeof (trivial_NFSv4_xattr_buf)]; + } stackbuf; + + char *listbuf = stackbuf.ch; + ssize_t listbufsize = sizeof stackbuf.ch; + char *heapbuf = NULL; + ssize_t listsize; + + /* Use listxattr first, as this means just one syscall in the + typical case where the file lacks an ACL. Try stackbuf + first, falling back on malloc if stackbuf is too small. */ + while ((listsize = listxattr (name, listbuf, listbufsize)) < 0 + && errno == ERANGE) { - ret = getxattr (name, XATTR_NAME_POSIX_ACL_DEFAULT, NULL, 0); - if (ret < 0 && errno == ENODATA) - ret = 0; - else if (ret > 0) - return 1; + free (heapbuf); + listbufsize = listxattr (name, NULL, 0); + if (listbufsize < 0) + return -1; + if (SIZE_MAX < listbufsize) + { + errno = ENOMEM; + return -1; + } + listbuf = heapbuf = malloc (listbufsize); + if (!listbuf) + return -1; } - if (ret < 0) - { - /* Check for NFSv4 ACLs. The max length of a trivial - ACL is 6 words for owner, 6 for group, 7 for everyone, - all times 2 because there are both allow and deny ACEs. - There are 6 words for owner because of type, flag, mask, - wholen, "OWNER@"+pad and similarly for group; everyone is - another word to hold "EVERYONE@". */ - uint32_t xattr[2 * (6 + 6 + 7)]; + int ret + = (listsize < 0 ? -1 + : (have_xattr (XATTR_NAME_POSIX_ACL_ACCESS, listbuf, listsize) + || (S_ISDIR (sb->st_mode) + && have_xattr (XATTR_NAME_POSIX_ACL_DEFAULT, + listbuf, listsize)))); + bool nfsv4_acl_but_no_posix_acl + = ret == 0 && have_xattr (XATTR_NAME_NFSV4_ACL, listbuf, listsize); + free (heapbuf); - ret = getxattr (name, XATTR_NAME_NFSV4_ACL, xattr, sizeof xattr); + /* If there is an NFSv4 ACL but no POSIX ACL, follow up with a + getxattr syscall to see whether the NFSv4 ACL is nontrivial. */ + if (nfsv4_acl_but_no_posix_acl) + { + ret = getxattr (name, XATTR_NAME_NFSV4_ACL, + stackbuf.xattr, sizeof stackbuf.xattr); if (ret < 0) switch (errno) { @@ -177,7 +219,7 @@ file_has_acl (char const *name, struct stat const *sb) else { /* It looks like a trivial ACL, but investigate further. */ - ret = acl_nfs4_nontrivial (xattr, ret); + ret = acl_nfs4_nontrivial (stackbuf.xattr, ret); if (ret < 0) { errno = EINVAL; diff --git a/lib/filemode.h b/lib/filemode.h index 15a8dcc3760..3e1d9903eac 100644 --- a/lib/filemode.h +++ b/lib/filemode.h @@ -17,6 +17,12 @@ along with this program. If not, see . */ #ifndef FILEMODE_H_ +# define FILEMODE_H_ + +/* This file uses HAVE_DECL_STRMODE. */ +# if !_GL_CONFIG_H_INCLUDED +# error "Please include config.h first." +# endif # include # include diff --git a/lib/filevercmp.h b/lib/filevercmp.h index 6b81ab32a7f..9e052bdd08c 100644 --- a/lib/filevercmp.h +++ b/lib/filevercmp.h @@ -20,6 +20,11 @@ #ifndef FILEVERCMP_H #define FILEVERCMP_H +/* This file uses _GL_ATTRIBUTE_PURE. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + #include /* Compare strings A and B as file names containing version numbers, diff --git a/lib/flexmember.h b/lib/flexmember.h index a6cc876a6d5..8c5915ecf9c 100644 --- a/lib/flexmember.h +++ b/lib/flexmember.h @@ -20,6 +20,11 @@ Written by Paul Eggert. */ +/* This file uses _Alignof. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + #include /* Nonzero multiple of alignment of TYPE, suitable for FLEXSIZEOF below. diff --git a/lib/fpending.h b/lib/fpending.h index 5e860db6810..1604ca0b7af 100644 --- a/lib/fpending.h +++ b/lib/fpending.h @@ -18,6 +18,12 @@ Written by Jim Meyering. */ +/* This file uses _GL_ATTRIBUTE_PURE, HAVE_STDIO_EXT_H, + HAVE_DECL___FPENDING. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + #include #include #if HAVE_STDIO_EXT_H diff --git a/lib/gnulib.mk.in b/lib/gnulib.mk.in index 47d08a5e27f..29861a31d12 100644 --- a/lib/gnulib.mk.in +++ b/lib/gnulib.mk.in @@ -221,6 +221,7 @@ DBUS_LIBS = @DBUS_LIBS@ DBUS_OBJ = @DBUS_OBJ@ DEFS = @DEFS@ DESLIB = @DESLIB@ +DIR_HAS_FD_MEMBER = @DIR_HAS_FD_MEMBER@ DOCMISC_W32 = @DOCMISC_W32@ DUMPING = @DUMPING@ DYNAMIC_LIB_SECONDARY_SUFFIX = @DYNAMIC_LIB_SECONDARY_SUFFIX@ @@ -444,6 +445,7 @@ GL_GNULIB_MBSSEP = @GL_GNULIB_MBSSEP@ GL_GNULIB_MBSSPN = @GL_GNULIB_MBSSPN@ GL_GNULIB_MBSSTR = @GL_GNULIB_MBSSTR@ GL_GNULIB_MBSTOK_R = @GL_GNULIB_MBSTOK_R@ +GL_GNULIB_MBSTOWCS = @GL_GNULIB_MBSTOWCS@ GL_GNULIB_MBTOWC = @GL_GNULIB_MBTOWC@ GL_GNULIB_MDA_ACCESS = @GL_GNULIB_MDA_ACCESS@ GL_GNULIB_MDA_CHDIR = @GL_GNULIB_MDA_CHDIR@ @@ -689,6 +691,7 @@ HAVE_DECL_MEMMEM = @HAVE_DECL_MEMMEM@ HAVE_DECL_MEMRCHR = @HAVE_DECL_MEMRCHR@ HAVE_DECL_OBSTACK_PRINTF = @HAVE_DECL_OBSTACK_PRINTF@ HAVE_DECL_POSIX_SPAWN_SETSID = @HAVE_DECL_POSIX_SPAWN_SETSID@ +HAVE_DECL_PROGRAM_INVOCATION_NAME = @HAVE_DECL_PROGRAM_INVOCATION_NAME@ HAVE_DECL_PUTW = @HAVE_DECL_PUTW@ HAVE_DECL_SETENV = @HAVE_DECL_SETENV@ HAVE_DECL_SETHOSTNAME = @HAVE_DECL_SETHOSTNAME@ @@ -956,6 +959,7 @@ LIB_WSOCK32 = @LIB_WSOCK32@ LIB_XATTR = @LIB_XATTR@ LIMITS_H = @LIMITS_H@ LN_S_FILEONLY = @LN_S_FILEONLY@ +LOCALE_FR_UTF8 = @LOCALE_FR_UTF8@ LTLIBGMP = @LTLIBGMP@ LTLIBINTL = @LTLIBINTL@ LTLIBOBJS = @LTLIBOBJS@ @@ -1127,7 +1131,9 @@ REPLACE_LSEEK = @REPLACE_LSEEK@ REPLACE_LSTAT = @REPLACE_LSTAT@ REPLACE_MALLOC_FOR_MALLOC_GNU = @REPLACE_MALLOC_FOR_MALLOC_GNU@ REPLACE_MALLOC_FOR_MALLOC_POSIX = @REPLACE_MALLOC_FOR_MALLOC_POSIX@ +REPLACE_MBSTOWCS = @REPLACE_MBSTOWCS@ REPLACE_MBTOWC = @REPLACE_MBTOWC@ +REPLACE_MB_CUR_MAX = @REPLACE_MB_CUR_MAX@ REPLACE_MEMCHR = @REPLACE_MEMCHR@ REPLACE_MEMMEM = @REPLACE_MEMMEM@ REPLACE_MEMPCPY = @REPLACE_MEMPCPY@ @@ -1164,6 +1170,7 @@ REPLACE_RAISE = @REPLACE_RAISE@ REPLACE_RANDOM = @REPLACE_RANDOM@ REPLACE_RANDOM_R = @REPLACE_RANDOM_R@ REPLACE_READ = @REPLACE_READ@ +REPLACE_READDIR = @REPLACE_READDIR@ REPLACE_READLINK = @REPLACE_READLINK@ REPLACE_READLINKAT = @REPLACE_READLINKAT@ REPLACE_REALLOCARRAY = @REPLACE_REALLOCARRAY@ @@ -1173,6 +1180,7 @@ REPLACE_REALPATH = @REPLACE_REALPATH@ REPLACE_REMOVE = @REPLACE_REMOVE@ REPLACE_RENAME = @REPLACE_RENAME@ REPLACE_RENAMEAT = @REPLACE_RENAMEAT@ +REPLACE_REWINDDIR = @REPLACE_REWINDDIR@ REPLACE_RMDIR = @REPLACE_RMDIR@ REPLACE_SELECT = @REPLACE_SELECT@ REPLACE_SETENV = @REPLACE_SETENV@ @@ -1732,6 +1740,7 @@ dirent.h: dirent.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ -e 's|@''NEXT_DIRENT_H''@|$(NEXT_DIRENT_H)|g' \ + -e 's/@''DIR_HAS_FD_MEMBER''@/$(DIR_HAS_FD_MEMBER)/g' \ -e 's/@''GNULIB_OPENDIR''@/$(GL_GNULIB_OPENDIR)/g' \ -e 's/@''GNULIB_READDIR''@/$(GL_GNULIB_READDIR)/g' \ -e 's/@''GNULIB_REWINDDIR''@/$(GL_GNULIB_REWINDDIR)/g' \ @@ -1750,6 +1759,8 @@ dirent.h: dirent.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H -e 's|@''HAVE_SCANDIR''@|$(HAVE_SCANDIR)|g' \ -e 's|@''HAVE_ALPHASORT''@|$(HAVE_ALPHASORT)|g' \ -e 's|@''REPLACE_OPENDIR''@|$(REPLACE_OPENDIR)|g' \ + -e 's|@''REPLACE_READDIR''@|$(REPLACE_READDIR)|g' \ + -e 's|@''REPLACE_REWINDDIR''@|$(REPLACE_REWINDDIR)|g' \ -e 's|@''REPLACE_CLOSEDIR''@|$(REPLACE_CLOSEDIR)|g' \ -e 's|@''REPLACE_DIRFD''@|$(REPLACE_DIRFD)|g' \ -e 's|@''REPLACE_FDOPENDIR''@|$(REPLACE_FDOPENDIR)|g' \ @@ -1774,6 +1785,8 @@ libgnu_a_SOURCES += dirfd.c endif endif +EXTRA_DIST += dirent-private.h + endif ## end gnulib module dirfd @@ -1974,6 +1987,8 @@ ifneq (,$(GL_COND_OBJ_FDOPENDIR_CONDITION)) libgnu_a_SOURCES += fdopendir.c endif +EXTRA_DIST += dirent-private.h + endif ## end gnulib module fdopendir @@ -3209,6 +3224,7 @@ stdlib.h: stdlib.in.h $(top_builddir)/config.status $(CXXDEFS_H) \ -e 's/@''GNULIB_GRANTPT''@/$(GL_GNULIB_GRANTPT)/g' \ -e 's/@''GNULIB_MALLOC_GNU''@/$(GL_GNULIB_MALLOC_GNU)/g' \ -e 's/@''GNULIB_MALLOC_POSIX''@/$(GL_GNULIB_MALLOC_POSIX)/g' \ + -e 's/@''GNULIB_MBSTOWCS''@/$(GL_GNULIB_MBSTOWCS)/g' \ -e 's/@''GNULIB_MBTOWC''@/$(GL_GNULIB_MBTOWC)/g' \ -e 's/@''GNULIB_MKDTEMP''@/$(GL_GNULIB_MKDTEMP)/g' \ -e 's/@''GNULIB_MKOSTEMP''@/$(GL_GNULIB_MKOSTEMP)/g' \ @@ -3254,6 +3270,7 @@ stdlib.h: stdlib.in.h $(top_builddir)/config.status $(CXXDEFS_H) \ -e 's|@''HAVE_DECL_FCVT''@|$(HAVE_DECL_FCVT)|g' \ -e 's|@''HAVE_DECL_GCVT''@|$(HAVE_DECL_GCVT)|g' \ -e 's|@''HAVE_DECL_GETLOADAVG''@|$(HAVE_DECL_GETLOADAVG)|g' \ + -e 's|@''HAVE_DECL_PROGRAM_INVOCATION_NAME''@|$(HAVE_DECL_PROGRAM_INVOCATION_NAME)|g' \ -e 's|@''HAVE_GETPROGNAME''@|$(HAVE_GETPROGNAME)|g' \ -e 's|@''HAVE_GETSUBOPT''@|$(HAVE_GETSUBOPT)|g' \ -e 's|@''HAVE_GRANTPT''@|$(HAVE_GRANTPT)|g' \ @@ -3302,6 +3319,8 @@ stdlib.h: stdlib.in.h $(top_builddir)/config.status $(CXXDEFS_H) \ -e 's|@''REPLACE_INITSTATE''@|$(REPLACE_INITSTATE)|g' \ -e 's|@''REPLACE_MALLOC_FOR_MALLOC_GNU''@|$(REPLACE_MALLOC_FOR_MALLOC_GNU)|g' \ -e 's|@''REPLACE_MALLOC_FOR_MALLOC_POSIX''@|$(REPLACE_MALLOC_FOR_MALLOC_POSIX)|g' \ + -e 's|@''REPLACE_MB_CUR_MAX''@|$(REPLACE_MB_CUR_MAX)|g' \ + -e 's|@''REPLACE_MBSTOWCS''@|$(REPLACE_MBSTOWCS)|g' \ -e 's|@''REPLACE_MBTOWC''@|$(REPLACE_MBTOWC)|g' \ -e 's|@''REPLACE_MKOSTEMP''@|$(REPLACE_MKOSTEMP)|g' \ -e 's|@''REPLACE_MKOSTEMPS''@|$(REPLACE_MKOSTEMPS)|g' \ diff --git a/lib/inttypes.in.h b/lib/inttypes.in.h index 5b7ef12dc7e..22643876ab3 100644 --- a/lib/inttypes.in.h +++ b/lib/inttypes.in.h @@ -46,6 +46,11 @@ #if ! defined INTTYPES_H && ! defined _GL_JUST_INCLUDE_SYSTEM_INTTYPES_H #define INTTYPES_H +/* This file uses GNULIB_POSIXCHECK, HAVE_RAW_DECL_*. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + /* Include or the gnulib replacement. But avoid namespace pollution on glibc systems. */ #ifndef __GLIBC__ diff --git a/lib/limits.in.h b/lib/limits.in.h index a01b4c6a280..45d46fd6897 100644 --- a/lib/limits.in.h +++ b/lib/limits.in.h @@ -99,6 +99,11 @@ # endif #endif +/* Assume no multibyte character is longer than 16 bytes. */ +#ifndef MB_LEN_MAX +# define MB_LEN_MAX 16 +#endif + /* Macros specified by C23 and by ISO/IEC TS 18661-1:2014. */ #if (! defined ULLONG_WIDTH \ diff --git a/lib/malloc/dynarray_emplace_enlarge.c b/lib/malloc/dynarray_emplace_enlarge.c index 7da539316c1..65aabb1e4a5 100644 --- a/lib/malloc/dynarray_emplace_enlarge.c +++ b/lib/malloc/dynarray_emplace_enlarge.c @@ -22,7 +22,7 @@ #include #include -#include +#include #include #include @@ -56,7 +56,7 @@ __libc_dynarray_emplace_enlarge (struct dynarray_header *list, } size_t new_size; - if (INT_MULTIPLY_WRAPV (new_allocated, element_size, &new_size)) + if (ckd_mul (&new_size, new_allocated, element_size)) return false; void *new_array; if (list->array == scratch) diff --git a/lib/malloc/dynarray_resize.c b/lib/malloc/dynarray_resize.c index 7ecd4de63b9..014f98c330e 100644 --- a/lib/malloc/dynarray_resize.c +++ b/lib/malloc/dynarray_resize.c @@ -22,7 +22,7 @@ #include #include -#include +#include #include #include @@ -42,7 +42,7 @@ __libc_dynarray_resize (struct dynarray_header *list, size_t size, over-allocation here. */ size_t new_size_bytes; - if (INT_MULTIPLY_WRAPV (size, element_size, &new_size_bytes)) + if (ckd_mul (&new_size_bytes, size, element_size)) { /* Overflow. */ __set_errno (ENOMEM); diff --git a/lib/md5.h b/lib/md5.h index f34e7cb8dfa..92dc6038988 100644 --- a/lib/md5.h +++ b/lib/md5.h @@ -20,6 +20,11 @@ #ifndef _MD5_H #define _MD5_H 1 +/* This file uses HAVE_OPENSSL_MD5. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + #include #include diff --git a/lib/minmax.h b/lib/minmax.h index 1fbfc6616cf..0ac40198e24 100644 --- a/lib/minmax.h +++ b/lib/minmax.h @@ -23,6 +23,11 @@ MIN, MAX macro redefinitions on some systems; the workaround is to #include this file as the last one among the #include list. */ +/* This file uses HAVE_MINMAX_IN_LIMITS_H, HAVE_MINMAX_IN_SYS_PARAM_H. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + /* Before we define the following symbols we get the file since otherwise we get redefinitions on some systems if is included after this file. Likewise for . diff --git a/lib/mktime.c b/lib/mktime.c index 94a4320e6ca..8e80bcdbd16 100644 --- a/lib/mktime.c +++ b/lib/mktime.c @@ -46,6 +46,7 @@ #include #include #include +#include #include #include @@ -379,7 +380,7 @@ __mktime_internal (struct tm *tp, /* Invert CONVERT by probing. First assume the same offset as last time. */ - INT_SUBTRACT_WRAPV (0, off, &negative_offset_guess); + ckd_sub (&negative_offset_guess, 0, off); long_int t0 = ydhms_diff (year, yday, hour, min, sec, EPOCH_YEAR - TM_YEAR_BASE, 0, 0, 0, negative_offset_guess); @@ -465,7 +466,7 @@ __mktime_internal (struct tm *tp, for (direction = -1; direction <= 1; direction += 2) { long_int ot; - if (! INT_ADD_WRAPV (t, delta * direction, &ot)) + if (! ckd_add (&ot, t, delta * direction)) { struct tm otm; if (! ranged_convert (convert, &ot, &otm)) @@ -503,8 +504,8 @@ __mktime_internal (struct tm *tp, /* Set *OFFSET to the low-order bits of T - T0 - NEGATIVE_OFFSET_GUESS. This is just a heuristic to speed up the next mktime call, and correctness is unaffected if integer overflow occurs here. */ - INT_SUBTRACT_WRAPV (t, t0, offset); - INT_SUBTRACT_WRAPV (*offset, negative_offset_guess, offset); + ckd_sub (offset, t, t0); + ckd_sub (offset, *offset, negative_offset_guess); if (LEAP_SECONDS_POSSIBLE && sec_requested != tm.tm_sec) { @@ -513,7 +514,7 @@ __mktime_internal (struct tm *tp, long_int sec_adjustment = sec == 0 && tm.tm_sec == 60; sec_adjustment -= sec; sec_adjustment += sec_requested; - if (INT_ADD_WRAPV (t, sec_adjustment, &t) + if (ckd_add (&t, t, sec_adjustment) || ! (mktime_min <= t && t <= mktime_max)) { __set_errno (EOVERFLOW); diff --git a/lib/openat.h b/lib/openat.h index 37d8eedbee4..97f066d10f8 100644 --- a/lib/openat.h +++ b/lib/openat.h @@ -19,15 +19,18 @@ #ifndef _GL_HEADER_OPENAT #define _GL_HEADER_OPENAT +/* This file uses _GL_INLINE_HEADER_BEGIN, _GL_INLINE, _Noreturn, + _GL_ATTRIBUTE_DEPRECATED, HAVE_OPENAT. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + #include #include #include #include -#ifndef _GL_INLINE_HEADER_BEGIN - #error "Please include config.h first." -#endif _GL_INLINE_HEADER_BEGIN #if !HAVE_OPENAT diff --git a/lib/pathmax.h b/lib/pathmax.h index 0dd8f3bc5ce..6930283b82a 100644 --- a/lib/pathmax.h +++ b/lib/pathmax.h @@ -39,6 +39,11 @@ #endif */ +/* This file uses HAVE_SYS_PARAM_H. */ +# if !_GL_CONFIG_H_INCLUDED +# error "Please include config.h first." +# endif + # include # include diff --git a/lib/pselect.c b/lib/pselect.c index f5d21e1048a..52d38378783 100644 --- a/lib/pselect.c +++ b/lib/pselect.c @@ -45,6 +45,12 @@ pselect (int nfds, fd_set *restrict rfds, sigset_t origmask; struct timeval tv, *tvp; + if (nfds < 0 || nfds > FD_SETSIZE) + { + errno = EINVAL; + return -1; + } + if (timeout) { if (! (0 <= timeout->tv_nsec && timeout->tv_nsec < 1000000000)) diff --git a/lib/regex_internal.h b/lib/regex_internal.h index 149ec2e868a..0270091df70 100644 --- a/lib/regex_internal.h +++ b/lib/regex_internal.h @@ -29,6 +29,7 @@ #include #include #include +#include #include #ifndef _LIBC @@ -822,7 +823,7 @@ re_string_elem_size_at (const re_string_t *pstr, Idx idx) } #ifdef _LIBC -# if __GNUC__ >= 7 +# if __glibc_has_attribute (__fallthrough__) # define FALLTHROUGH __attribute__ ((__fallthrough__)) # else # define FALLTHROUGH ((void) 0) diff --git a/lib/regexec.c b/lib/regexec.c index 13e0349e727..f05f38ae0e0 100644 --- a/lib/regexec.c +++ b/lib/regexec.c @@ -324,7 +324,7 @@ re_search_2_stub (struct re_pattern_buffer *bufp, const char *string1, char *s = NULL; if (__glibc_unlikely ((length1 < 0 || length2 < 0 || stop < 0 - || INT_ADD_WRAPV (length1, length2, &len)))) + || ckd_add (&len, length1, length2)))) return -2; /* Concatenate the strings. */ diff --git a/lib/sha1.h b/lib/sha1.h index 5a58b567ceb..854213a9211 100644 --- a/lib/sha1.h +++ b/lib/sha1.h @@ -19,6 +19,11 @@ #ifndef SHA1_H # define SHA1_H 1 +/* This file uses HAVE_OPENSSL_SHA1. */ +# if !_GL_CONFIG_H_INCLUDED +# error "Please include config.h first." +# endif + # include # include diff --git a/lib/sha256.h b/lib/sha256.h index 2879477e89c..938b1067062 100644 --- a/lib/sha256.h +++ b/lib/sha256.h @@ -18,6 +18,11 @@ #ifndef SHA256_H # define SHA256_H 1 +/* This file uses HAVE_OPENSSL_SHA256. */ +# if !_GL_CONFIG_H_INCLUDED +# error "Please include config.h first." +# endif + # include # include diff --git a/lib/sha512.h b/lib/sha512.h index e3a98a2644c..f3465bc8a68 100644 --- a/lib/sha512.h +++ b/lib/sha512.h @@ -18,6 +18,11 @@ #ifndef SHA512_H # define SHA512_H 1 +/* This file uses HAVE_OPENSSL_SHA512. */ +# if !_GL_CONFIG_H_INCLUDED +# error "Please include config.h first." +# endif + # include # include "u64.h" diff --git a/lib/signal.in.h b/lib/signal.in.h index fea12e6572d..418d59c582d 100644 --- a/lib/signal.in.h +++ b/lib/signal.in.h @@ -55,6 +55,11 @@ #ifndef _@GUARD_PREFIX@_SIGNAL_H #define _@GUARD_PREFIX@_SIGNAL_H +/* This file uses GNULIB_POSIXCHECK, HAVE_RAW_DECL_*. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + /* For testing the OpenBSD version. */ #if (@GNULIB_PTHREAD_SIGMASK@ || defined GNULIB_POSIXCHECK) \ && defined __OpenBSD__ diff --git a/lib/stat-time.h b/lib/stat-time.h index 92aa1e64e20..5b2702356ee 100644 --- a/lib/stat-time.h +++ b/lib/stat-time.h @@ -20,15 +20,18 @@ #ifndef STAT_TIME_H #define STAT_TIME_H 1 +/* This file uses _GL_INLINE_HEADER_BEGIN, _GL_INLINE, _GL_UNUSED, + _GL_ATTRIBUTE_PURE, HAVE_STRUCT_STAT_*. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + #include #include #include #include #include -#ifndef _GL_INLINE_HEADER_BEGIN - #error "Please include config.h first." -#endif _GL_INLINE_HEADER_BEGIN #ifndef _GL_STAT_TIME_INLINE # define _GL_STAT_TIME_INLINE _GL_INLINE diff --git a/lib/stddef.in.h b/lib/stddef.in.h index 6eadcc3d5a4..431e819b8bf 100644 --- a/lib/stddef.in.h +++ b/lib/stddef.in.h @@ -18,7 +18,7 @@ /* Written by Eric Blake. */ /* - * POSIX 2008 for platforms that have issues. + * POSIX 2008 and ISO C 23 for platforms that have issues. * */ @@ -37,9 +37,9 @@ remember if special invocation has ever been used to obtain wint_t, in which case we need to clean up NULL yet again. */ -# if !(defined _@GUARD_PREFIX@_STDDEF_H && defined _GL_STDDEF_WINT_T) +# if !(defined _@GUARD_PREFIX@_STDDEF_H && defined _@GUARD_PREFIX@_STDDEF_WINT_T) # ifdef __need_wint_t -# define _GL_STDDEF_WINT_T +# define _@GUARD_PREFIX@_STDDEF_WINT_T # endif # @INCLUDE_NEXT@ @NEXT_STDDEF_H@ /* On TinyCC, make sure that the macros that indicate the special invocation @@ -69,6 +69,7 @@ typedef long rpl_max_align_t; typedef long max_align_t; # define _MAX_ALIGN_T # endif +# define __CLANG_MAX_ALIGN_T_DEFINED # define GNULIB_defined_max_align_t 1 # endif # endif @@ -79,7 +80,7 @@ typedef long max_align_t; /* On NetBSD 5.0, the definition of NULL lacks proper parentheses. */ # if (@REPLACE_NULL@ \ - && (!defined _@GUARD_PREFIX@_STDDEF_H || defined _GL_STDDEF_WINT_T)) + && (!defined _@GUARD_PREFIX@_STDDEF_H || defined _@GUARD_PREFIX@_STDDEF_WINT_T)) # undef NULL # ifdef __cplusplus /* ISO C++ says that the macro NULL must expand to an integer constant @@ -100,6 +101,11 @@ typedef long max_align_t; # ifndef _@GUARD_PREFIX@_STDDEF_H # define _@GUARD_PREFIX@_STDDEF_H +/* This file uses _Noreturn. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + /* Some platforms lack wchar_t. */ #if !@HAVE_WCHAR_T@ # define wchar_t int @@ -137,11 +143,49 @@ typedef union long int __i _GL_STDDEF_ALIGNAS (long int); } rpl_max_align_t; # define max_align_t rpl_max_align_t +# define __CLANG_MAX_ALIGN_T_DEFINED # define GNULIB_defined_max_align_t 1 # endif # endif #endif +/* ISO C 23 § 7.21.1 The unreachable macro */ +#ifndef unreachable + +/* Code borrowed from verify.h. */ +# ifndef _GL_HAS_BUILTIN_UNREACHABLE +# if defined __clang_major__ && __clang_major__ < 5 +# define _GL_HAS_BUILTIN_UNREACHABLE 0 +# elif 4 < __GNUC__ + (5 <= __GNUC_MINOR__) +# define _GL_HAS_BUILTIN_UNREACHABLE 1 +# elif defined __has_builtin +# define _GL_HAS_BUILTIN_UNREACHABLE __has_builtin (__builtin_unreachable) +# else +# define _GL_HAS_BUILTIN_UNREACHABLE 0 +# endif +# endif + +# if _GL_HAS_BUILTIN_UNREACHABLE +# define unreachable() __builtin_unreachable () +# elif 1200 <= _MSC_VER +# define unreachable() __assume (0) +# else +/* Declare abort(), without including . */ +extern +# if defined __cplusplus +"C" +# endif +_Noreturn +void abort (void) +# if defined __cplusplus && (__GLIBC__ >= 2) +throw () +# endif +; +# define unreachable() abort () +# endif + +#endif + # endif /* _@GUARD_PREFIX@_STDDEF_H */ # endif /* _@GUARD_PREFIX@_STDDEF_H */ #endif /* __need_XXX */ diff --git a/lib/stdio.in.h b/lib/stdio.in.h index 098f841738c..6be12c0525d 100644 --- a/lib/stdio.in.h +++ b/lib/stdio.in.h @@ -57,6 +57,12 @@ #ifndef _@GUARD_PREFIX@_STDIO_H #define _@GUARD_PREFIX@_STDIO_H +/* This file uses _GL_ATTRIBUTE_DEALLOC, _GL_ATTRIBUTE_FORMAT, + _GL_ATTRIBUTE_MALLOC, GNULIB_POSIXCHECK, HAVE_RAW_DECL_*. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + /* Get va_list. Needed on many systems, including glibc 2.8. */ #include @@ -127,6 +133,16 @@ # endif #endif +/* _GL_ATTRIBUTE_MALLOC declares that the function returns a pointer to freshly + allocated memory. */ +#ifndef _GL_ATTRIBUTE_MALLOC +# if __GNUC__ >= 3 || defined __clang__ +# define _GL_ATTRIBUTE_MALLOC __attribute__ ((__malloc__)) +# else +# define _GL_ATTRIBUTE_MALLOC +# endif +#endif + /* An __attribute__ __format__ specifier for a function that takes a format string and arguments, where the format string directives are the ones standardized by ISO C99 and POSIX. @@ -204,6 +220,36 @@ # undef putc_unlocked #endif + +/* Maximum number of characters produced by printing a NaN value. */ +#ifndef _PRINTF_NAN_LEN_MAX +# if defined __FreeBSD__ || defined __DragonFly__ \ + || defined __NetBSD__ \ + || (defined __APPLE__ && defined __MACH__) +/* On BSD systems, a NaN value prints as just "nan", without a sign. */ +# define _PRINTF_NAN_LEN_MAX 3 +# elif (__GLIBC__ >= 2) || MUSL_LIBC || defined __OpenBSD__ || defined __sun || defined __CYGWIN__ +/* glibc, musl libc, OpenBSD, Solaris libc, and Cygwin produce "[-]nan". */ +# define _PRINTF_NAN_LEN_MAX 4 +# elif defined _AIX +/* AIX produces "[-]NaNQ". */ +# define _PRINTF_NAN_LEN_MAX 5 +# elif defined _WIN32 && !defined __CYGWIN__ +/* On native Windows, the output can be: + - with MSVC ucrt: "[-]nan" or "[-]nan(ind)" or "[-]nan(snan)", + - with mingw: "[-]1.#IND" or "[-]1.#QNAN". */ +# define _PRINTF_NAN_LEN_MAX 10 +# elif defined __sgi +/* On IRIX, the output typically is "[-]nan0xNNNNNNNN" with 8 hexadecimal + digits. */ +# define _PRINTF_NAN_LEN_MAX 14 +# else +/* We don't know, but 32 should be a safe maximum. */ +# define _PRINTF_NAN_LEN_MAX 32 +# endif +#endif + + #if @GNULIB_DPRINTF@ # if @REPLACE_DPRINTF@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) @@ -286,7 +332,8 @@ _GL_CXXALIASWARN (fcloseall); # endif _GL_FUNCDECL_RPL (fdopen, FILE *, (int fd, const char *mode) - _GL_ARG_NONNULL ((2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1)); + _GL_ARG_NONNULL ((2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1) + _GL_ATTRIBUTE_MALLOC); _GL_CXXALIAS_RPL (fdopen, FILE *, (int fd, const char *mode)); # elif defined _WIN32 && !defined __CYGWIN__ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) @@ -299,7 +346,8 @@ _GL_CXXALIAS_MDA (fdopen, FILE *, (int fd, const char *mode)); /* For -Wmismatched-dealloc: Associate fdopen with fclose or rpl_fclose. */ _GL_FUNCDECL_SYS (fdopen, FILE *, (int fd, const char *mode) - _GL_ARG_NONNULL ((2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1)); + _GL_ARG_NONNULL ((2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1) + _GL_ATTRIBUTE_MALLOC); # endif _GL_CXXALIAS_SYS (fdopen, FILE *, (int fd, const char *mode)); # endif @@ -309,7 +357,8 @@ _GL_CXXALIASWARN (fdopen); /* For -Wmismatched-dealloc: Associate fdopen with fclose or rpl_fclose. */ _GL_FUNCDECL_SYS (fdopen, FILE *, (int fd, const char *mode) - _GL_ARG_NONNULL ((2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1)); + _GL_ARG_NONNULL ((2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1) + _GL_ATTRIBUTE_MALLOC); # endif # if defined GNULIB_POSIXCHECK # undef fdopen @@ -420,7 +469,8 @@ _GL_CXXALIASWARN (fileno); # endif _GL_FUNCDECL_RPL (fopen, FILE *, (const char *restrict filename, const char *restrict mode) - _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1)); + _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1) + _GL_ATTRIBUTE_MALLOC); _GL_CXXALIAS_RPL (fopen, FILE *, (const char *restrict filename, const char *restrict mode)); # else @@ -967,6 +1017,10 @@ _GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead"); _GL_CXXALIAS_MDA (getw, int, (FILE *restrict stream)); # else # if @HAVE_DECL_GETW@ +# if defined __APPLE__ && defined __MACH__ +/* The presence of the declaration depends on _POSIX_C_SOURCE. */ +_GL_FUNCDECL_SYS (getw, int, (FILE *restrict stream)); +# endif _GL_CXXALIAS_SYS (getw, int, (FILE *restrict stream)); # endif # endif @@ -1071,13 +1125,15 @@ _GL_WARN_ON_USE (perror, "perror is not always POSIX compliant - " # endif _GL_FUNCDECL_RPL (popen, FILE *, (const char *cmd, const char *mode) - _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_DEALLOC (pclose, 1)); + _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_DEALLOC (pclose, 1) + _GL_ATTRIBUTE_MALLOC); _GL_CXXALIAS_RPL (popen, FILE *, (const char *cmd, const char *mode)); # else # if !@HAVE_POPEN@ || __GNUC__ >= 11 _GL_FUNCDECL_SYS (popen, FILE *, (const char *cmd, const char *mode) - _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_DEALLOC (pclose, 1)); + _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_DEALLOC (pclose, 1) + _GL_ATTRIBUTE_MALLOC); # endif _GL_CXXALIAS_SYS (popen, FILE *, (const char *cmd, const char *mode)); # endif @@ -1087,7 +1143,8 @@ _GL_CXXALIASWARN (popen); /* For -Wmismatched-dealloc: Associate popen with pclose or rpl_pclose. */ _GL_FUNCDECL_SYS (popen, FILE *, (const char *cmd, const char *mode) - _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_DEALLOC (pclose, 1)); + _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_DEALLOC (pclose, 1) + _GL_ATTRIBUTE_MALLOC); # endif # if defined GNULIB_POSIXCHECK # undef popen @@ -1210,6 +1267,10 @@ _GL_CXXALIASWARN (puts); _GL_CXXALIAS_MDA (putw, int, (int w, FILE *restrict stream)); # else # if @HAVE_DECL_PUTW@ +# if defined __APPLE__ && defined __MACH__ +/* The presence of the declaration depends on _POSIX_C_SOURCE. */ +_GL_FUNCDECL_SYS (putw, int, (int w, FILE *restrict stream)); +# endif _GL_CXXALIAS_SYS (putw, int, (int w, FILE *restrict stream)); # endif # endif @@ -1421,13 +1482,15 @@ _GL_CXXALIASWARN (tempnam); # define tmpfile rpl_tmpfile # endif _GL_FUNCDECL_RPL (tmpfile, FILE *, (void) - _GL_ATTRIBUTE_DEALLOC (fclose, 1)); + _GL_ATTRIBUTE_DEALLOC (fclose, 1) + _GL_ATTRIBUTE_MALLOC); _GL_CXXALIAS_RPL (tmpfile, FILE *, (void)); # else # if __GNUC__ >= 11 /* For -Wmismatched-dealloc: Associate tmpfile with fclose or rpl_fclose. */ _GL_FUNCDECL_SYS (tmpfile, FILE *, (void) - _GL_ATTRIBUTE_DEALLOC (fclose, 1)); + _GL_ATTRIBUTE_DEALLOC (fclose, 1) + _GL_ATTRIBUTE_MALLOC); # endif _GL_CXXALIAS_SYS (tmpfile, FILE *, (void)); # endif @@ -1438,7 +1501,8 @@ _GL_CXXALIASWARN (tmpfile); # if @GNULIB_FCLOSE@ && __GNUC__ >= 11 && !defined tmpfile /* For -Wmismatched-dealloc: Associate tmpfile with fclose or rpl_fclose. */ _GL_FUNCDECL_SYS (tmpfile, FILE *, (void) - _GL_ATTRIBUTE_DEALLOC (fclose, 1)); + _GL_ATTRIBUTE_DEALLOC (fclose, 1) + _GL_ATTRIBUTE_MALLOC); # endif # if defined GNULIB_POSIXCHECK # undef tmpfile diff --git a/lib/stdlib.in.h b/lib/stdlib.in.h index a91f4e23d67..1479a2b2871 100644 --- a/lib/stdlib.in.h +++ b/lib/stdlib.in.h @@ -37,6 +37,12 @@ #ifndef _@GUARD_PREFIX@_STDLIB_H #define _@GUARD_PREFIX@_STDLIB_H +/* This file uses _Noreturn, _GL_ATTRIBUTE_DEALLOC, _GL_ATTRIBUTE_MALLOC, + _GL_ATTRIBUTE_PURE, GNULIB_POSIXCHECK, HAVE_RAW_DECL_*. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + /* NetBSD 5.0 mis-defines NULL. */ #include @@ -67,9 +73,7 @@ # include # endif -# if !@HAVE_STRUCT_RANDOM_DATA@ || @REPLACE_RANDOM_R@ || !@HAVE_RANDOM_R@ -# include -# endif +# include # if !@HAVE_STRUCT_RANDOM_DATA@ /* Define 'struct random_data'. @@ -461,7 +465,7 @@ _GL_WARN_ON_USE (getloadavg, "getloadavg is not portable - " # undef getprogname # define getprogname rpl_getprogname # endif -# ifdef HAVE_DECL_PROGRAM_INVOCATION_NAME +# if @HAVE_DECL_PROGRAM_INVOCATION_NAME@ _GL_FUNCDECL_RPL (getprogname, const char *, (void) _GL_ATTRIBUTE_PURE); # else _GL_FUNCDECL_RPL (getprogname, const char *, (void)); @@ -469,7 +473,7 @@ _GL_FUNCDECL_RPL (getprogname, const char *, (void)); _GL_CXXALIAS_RPL (getprogname, const char *, (void)); # else # if !@HAVE_GETPROGNAME@ -# ifdef HAVE_DECL_PROGRAM_INVOCATION_NAME +# if @HAVE_DECL_PROGRAM_INVOCATION_NAME@ _GL_FUNCDECL_SYS (getprogname, const char *, (void) _GL_ATTRIBUTE_PURE); # else _GL_FUNCDECL_SYS (getprogname, const char *, (void)); @@ -589,6 +593,51 @@ _GL_WARN_ON_USE (malloc, "malloc is not POSIX compliant everywhere - " # endif #endif +/* Return maximum number of bytes of a multibyte character. */ +#if @REPLACE_MB_CUR_MAX@ +# if !GNULIB_defined_MB_CUR_MAX +static inline +int gl_MB_CUR_MAX (void) +{ + /* Turn the value 3 to the value 4, as needed for the UTF-8 encoding. */ + return MB_CUR_MAX + (MB_CUR_MAX == 3); +} +# undef MB_CUR_MAX +# define MB_CUR_MAX gl_MB_CUR_MAX () +# define GNULIB_defined_MB_CUR_MAX 1 +# endif +#endif + +/* Convert a string to a wide string. */ +#if @GNULIB_MBSTOWCS@ +# if @REPLACE_MBSTOWCS@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef mbstowcs +# define mbstowcs rpl_mbstowcs +# endif +_GL_FUNCDECL_RPL (mbstowcs, size_t, + (wchar_t *restrict dest, const char *restrict src, + size_t len) + _GL_ARG_NONNULL ((2))); +_GL_CXXALIAS_RPL (mbstowcs, size_t, + (wchar_t *restrict dest, const char *restrict src, + size_t len)); +# else +_GL_CXXALIAS_SYS (mbstowcs, size_t, + (wchar_t *restrict dest, const char *restrict src, + size_t len)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (mbstowcs); +# endif +#elif defined GNULIB_POSIXCHECK +# undef mbstowcs +# if HAVE_RAW_DECL_MBSTOWCS +_GL_WARN_ON_USE (mbstowcs, "mbstowcs is unportable - " + "use gnulib module mbstowcs for portability"); +# endif +#endif + /* Convert a multibyte character to a wide character. */ #if @GNULIB_MBTOWC@ # if @REPLACE_MBTOWC@ @@ -1009,7 +1058,9 @@ _GL_FUNCDECL_SYS (random, long, (void)); int. */ _GL_CXXALIAS_SYS_CAST (random, long, (void)); # endif +# if __GLIBC__ >= 2 _GL_CXXALIASWARN (random); +# endif #elif defined GNULIB_POSIXCHECK # undef random # if HAVE_RAW_DECL_RANDOM @@ -1034,7 +1085,9 @@ _GL_FUNCDECL_SYS (srandom, void, (unsigned int seed)); unsigned long seed. */ _GL_CXXALIAS_SYS_CAST (srandom, void, (unsigned int seed)); # endif +# if __GLIBC__ >= 2 _GL_CXXALIASWARN (srandom); +# endif #elif defined GNULIB_POSIXCHECK # undef srandom # if HAVE_RAW_DECL_SRANDOM diff --git a/lib/string.in.h b/lib/string.in.h index b6bf432e1f1..912d0f7a306 100644 --- a/lib/string.in.h +++ b/lib/string.in.h @@ -44,6 +44,12 @@ #ifndef _@GUARD_PREFIX@_STRING_H #define _@GUARD_PREFIX@_STRING_H +/* This file uses _GL_ATTRIBUTE_DEALLOC, _GL_ATTRIBUTE_MALLOC, + _GL_ATTRIBUTE_PURE, GNULIB_POSIXCHECK, HAVE_RAW_DECL_*. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + /* NetBSD 5.0 mis-defines NULL. */ #include diff --git a/lib/strtol.c b/lib/strtol.c index d11269b2622..b93483dca49 100644 --- a/lib/strtol.c +++ b/lib/strtol.c @@ -288,6 +288,11 @@ INTERNAL (strtol) (const STRING_TYPE *nptr, STRING_TYPE **endptr, s += 2; base = 16; } + else if ((base == 0 || base == 2) && TOUPPER (s[1]) == L_('B')) + { + s += 2; + base = 2; + } else if (base == 0) base = 8; } @@ -378,11 +383,14 @@ INTERNAL (strtol) (const STRING_TYPE *nptr, STRING_TYPE **endptr, noconv: /* We must handle a special case here: the base is 0 or 16 and the first two characters are '0' and 'x', but the rest are no - hexadecimal digits. This is no error case. We return 0 and - ENDPTR points to the 'x'. */ + hexadecimal digits. Likewise when the base is 0 or 2 and the + first two characters are '0' and 'b', but the rest are no binary + digits. This is no error case. We return 0 and ENDPTR points to + the 'x' or 'b'. */ if (endptr != NULL) { - if (save - nptr >= 2 && TOUPPER (save[-1]) == L_('X') + if (save - nptr >= 2 + && (TOUPPER (save[-1]) == L_('X') || TOUPPER (save[-1]) == L_('B')) && save[-2] == L_('0')) *endptr = (STRING_TYPE *) &save[-1]; else diff --git a/lib/sys_random.in.h b/lib/sys_random.in.h index 8dca1326837..b240033bcbf 100644 --- a/lib/sys_random.in.h +++ b/lib/sys_random.in.h @@ -45,6 +45,11 @@ #ifndef _@GUARD_PREFIX@_SYS_RANDOM_H #define _@GUARD_PREFIX@_SYS_RANDOM_H +/* This file uses GNULIB_POSIXCHECK, HAVE_RAW_DECL_*. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + #include /* Define the GRND_* constants. */ diff --git a/lib/sys_select.in.h b/lib/sys_select.in.h index 13440fa6f0a..3abfc48af09 100644 --- a/lib/sys_select.in.h +++ b/lib/sys_select.in.h @@ -19,6 +19,13 @@ # endif @PRAGMA_COLUMNS@ +/* This file uses #include_next of a system file that defines time_t. + For the 'year2038' module to work right, needs to have been + included before. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + /* On OSF/1 and Solaris 2.6, and both include . On Cygwin and OpenBSD, includes . @@ -71,6 +78,11 @@ #ifndef _@GUARD_PREFIX@_SYS_SELECT_H +/* This file uses GNULIB_POSIXCHECK, HAVE_RAW_DECL_*. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + /* On many platforms, assumes prior inclusion of . Also, mingw defines sigset_t there, instead of in where it belongs. */ diff --git a/lib/sys_stat.in.h b/lib/sys_stat.in.h index 0c2f39c12bf..ad4da17fa46 100644 --- a/lib/sys_stat.in.h +++ b/lib/sys_stat.in.h @@ -25,6 +25,13 @@ #endif @PRAGMA_COLUMNS@ +/* This file uses #include_next of a system file that defines time_t. + For the 'year2038' module to work right, needs to have been + included before. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + #if defined __need_system_sys_stat_h /* Special invocation convention. */ @@ -48,6 +55,11 @@ #ifndef _@GUARD_PREFIX@_SYS_STAT_H #define _@GUARD_PREFIX@_SYS_STAT_H +/* This file uses GNULIB_POSIXCHECK, HAVE_RAW_DECL_*. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ /* The definition of _GL_ARG_NONNULL is copied here. */ diff --git a/lib/sys_time.in.h b/lib/sys_time.in.h index e833d551677..59cce1440da 100644 --- a/lib/sys_time.in.h +++ b/lib/sys_time.in.h @@ -24,6 +24,13 @@ #endif @PRAGMA_COLUMNS@ +/* This file uses #include_next of a system file that defines time_t. + For the 'year2038' module to work right, needs to have been + included before. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + /* On Cygwin and on many BSDish systems, includes itself recursively via . Simply delegate to the system's header in this case; it is a no-op. @@ -41,6 +48,11 @@ #ifndef _@GUARD_PREFIX@_SYS_TIME_H #define _@GUARD_PREFIX@_SYS_TIME_H +/* This file uses GNULIB_POSIXCHECK, HAVE_RAW_DECL_*. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + #if ! @HAVE_SYS_TIME_H@ # include #endif diff --git a/lib/sys_types.in.h b/lib/sys_types.in.h index 082a6c674de..ea77e140be9 100644 --- a/lib/sys_types.in.h +++ b/lib/sys_types.in.h @@ -20,6 +20,13 @@ #endif @PRAGMA_COLUMNS@ +/* This file uses #include_next of a system file that defines time_t. + For the 'year2038' module to work right, needs to have been + included before. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + #if defined _WIN32 && !defined __CYGWIN__ \ && (defined __need_off_t || defined __need___off64_t \ || defined __need_ssize_t || defined __need_time_t) diff --git a/lib/time.in.h b/lib/time.in.h index 3f9af920e34..06428adb1d0 100644 --- a/lib/time.in.h +++ b/lib/time.in.h @@ -20,6 +20,13 @@ #endif @PRAGMA_COLUMNS@ +/* This file uses #include_next of a system file that defines time_t. + For the 'year2038' module to work right, needs to have been + included before. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + /* Don't get in the way of glibc when it includes time.h merely to declare a few standard symbols, rather than to declare all the symbols. (However, skip this for MinGW as it treats __need_time_t @@ -45,6 +52,12 @@ # @INCLUDE_NEXT@ @NEXT_TIME_H@ +/* This file uses _GL_ATTRIBUTE_DEPRECATED, GNULIB_POSIXCHECK, + HAVE_RAW_DECL_*. */ +# if !_GL_CONFIG_H_INCLUDED +# error "Please include config.h first." +# endif + /* NetBSD 5.0 mis-defines NULL. */ # include @@ -154,7 +167,9 @@ _GL_CXXALIAS_RPL (time, time_t, (time_t *__tp)); # else _GL_CXXALIAS_SYS (time, time_t, (time_t *__tp)); # endif +# if __GLIBC__ >= 2 _GL_CXXALIASWARN (time); +# endif # endif /* Sleep for at least RQTP seconds unless interrupted, If interrupted, @@ -341,7 +356,9 @@ _GL_CXXALIASWARN (strptime); # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # define ctime rpl_ctime # endif +# ifndef __cplusplus _GL_ATTRIBUTE_DEPRECATED +# endif _GL_FUNCDECL_RPL (ctime, char *, (time_t const *__tp) _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_RPL (ctime, char *, (time_t const *__tp)); diff --git a/lib/timespec.h b/lib/timespec.h index ba78647f09a..0bdfd76ef78 100644 --- a/lib/timespec.h +++ b/lib/timespec.h @@ -19,11 +19,14 @@ #if ! defined TIMESPEC_H #define TIMESPEC_H -#include - -#ifndef _GL_INLINE_HEADER_BEGIN +/* This file uses _GL_INLINE_HEADER_BEGIN, _GL_INLINE, _GL_ATTRIBUTE_CONST, + _GL_ATTRIBUTE_PURE, _GL_CMP. */ +#if !_GL_CONFIG_H_INCLUDED #error "Please include config.h first." #endif + +#include + _GL_INLINE_HEADER_BEGIN #ifndef _GL_TIMESPEC_INLINE # define _GL_TIMESPEC_INLINE _GL_INLINE diff --git a/lib/u64.h b/lib/u64.h index 0353ad4d9af..8a99335b6aa 100644 --- a/lib/u64.h +++ b/lib/u64.h @@ -17,11 +17,13 @@ /* Written by Paul Eggert. */ -#include - -#ifndef _GL_INLINE_HEADER_BEGIN +/* This file uses _GL_INLINE_HEADER_BEGIN, _GL_INLINE. */ +#if !_GL_CONFIG_H_INCLUDED #error "Please include config.h first." #endif + +#include + _GL_INLINE_HEADER_BEGIN #ifndef _GL_U64_INLINE # define _GL_U64_INLINE _GL_INLINE diff --git a/lib/unistd.in.h b/lib/unistd.in.h index 8ba9867894e..2ae040a76b3 100644 --- a/lib/unistd.in.h +++ b/lib/unistd.in.h @@ -69,6 +69,12 @@ #if !defined _@GUARD_PREFIX@_UNISTD_H && !defined _GL_INCLUDING_WINSOCK2_H #define _@GUARD_PREFIX@_UNISTD_H +/* This file uses _GL_INLINE_HEADER_BEGIN, _GL_INLINE, GNULIB_POSIXCHECK, + HAVE_RAW_DECL_*. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + /* NetBSD 5.0 mis-defines NULL. Also get size_t. */ /* But avoid namespace pollution on glibc systems. */ #ifndef __GLIBC__ @@ -170,9 +176,6 @@ # include #endif -#ifndef _GL_INLINE_HEADER_BEGIN - #error "Please include config.h first." -#endif _GL_INLINE_HEADER_BEGIN #ifndef _GL_UNISTD_INLINE # define _GL_UNISTD_INLINE _GL_INLINE diff --git a/lib/unlocked-io.h b/lib/unlocked-io.h index fdef624ab9c..4830df4a747 100644 --- a/lib/unlocked-io.h +++ b/lib/unlocked-io.h @@ -31,6 +31,11 @@ the *_unlocked functions directly. On hosts that lack those functions, invoke the non-thread-safe versions instead. */ +/* This file uses HAVE_DECL_*_UNLOCKED. */ +# if !_GL_CONFIG_H_INCLUDED +# error "Please include config.h first." +# endif + # include # if HAVE_DECL_CLEARERR_UNLOCKED || defined clearerr_unlocked diff --git a/lib/utimens.h b/lib/utimens.h index a7056981f32..4a21792a7e4 100644 --- a/lib/utimens.h +++ b/lib/utimens.h @@ -17,6 +17,11 @@ /* Written by Paul Eggert. */ +/* This file uses _GL_INLINE_HEADER_BEGIN, _GL_INLINE. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + #include int fdutimens (int, char const *, struct timespec const [2]); int utimens (char const *, struct timespec const [2]); @@ -26,9 +31,6 @@ int lutimens (char const *, struct timespec const [2]); # include # include -#ifndef _GL_INLINE_HEADER_BEGIN - #error "Please include config.h first." -#endif _GL_INLINE_HEADER_BEGIN #ifndef _GL_UTIMENS_INLINE # define _GL_UTIMENS_INLINE _GL_INLINE diff --git a/lib/verify.h b/lib/verify.h index f0b3fc5851b..e4af91517e6 100644 --- a/lib/verify.h +++ b/lib/verify.h @@ -241,10 +241,16 @@ template # define _Static_assert(...) \ _GL_VERIFY (__VA_ARGS__, "static assertion failed", -) # else - /* Work around MSVC preprocessor incompatibility with ISO C; see - . */ -# define _Static_assert(R, ...) \ - _GL_VERIFY ((R), "static assertion failed", -) +# if defined __cplusplus && _MSC_VER >= 1910 + /* In MSVC 14.1 or newer, static_assert accepts one or two arguments, + but _Static_assert is not defined. */ +# define _Static_assert static_assert +# else + /* Work around MSVC preprocessor incompatibility with ISO C; see + . */ +# define _Static_assert(R, ...) \ + _GL_VERIFY ((R), "static assertion failed", -) +# endif # endif # endif /* Define static_assert if needed. */ @@ -252,7 +258,7 @@ template && __STDC_VERSION__ < 202311 \ && (!defined __cplusplus \ || (__cpp_static_assert < 201411 \ - && __GNUG__ < 6 && __clang_major__ < 6))) + && __GNUG__ < 6 && __clang_major__ < 6 && _MSC_VER < 1910))) # if defined __cplusplus && _MSC_VER >= 1900 && !defined __clang__ /* MSVC 14 in C++ mode supports the two-arguments static_assert but not the one-argument static_assert, and it does not support _Static_assert. @@ -285,14 +291,16 @@ template # define _GL_HAS_BUILTIN_TRAP 0 #endif -#if defined __clang_major__ && __clang_major__ < 5 -# define _GL_HAS_BUILTIN_UNREACHABLE 0 -#elif 4 < __GNUC__ + (5 <= __GNUC_MINOR__) -# define _GL_HAS_BUILTIN_UNREACHABLE 1 -#elif defined __has_builtin -# define _GL_HAS_BUILTIN_UNREACHABLE __has_builtin (__builtin_unreachable) -#else -# define _GL_HAS_BUILTIN_UNREACHABLE 0 +#ifndef _GL_HAS_BUILTIN_UNREACHABLE +# if defined __clang_major__ && __clang_major__ < 5 +# define _GL_HAS_BUILTIN_UNREACHABLE 0 +# elif 4 < __GNUC__ + (5 <= __GNUC_MINOR__) +# define _GL_HAS_BUILTIN_UNREACHABLE 1 +# elif defined __has_builtin +# define _GL_HAS_BUILTIN_UNREACHABLE __has_builtin (__builtin_unreachable) +# else +# define _GL_HAS_BUILTIN_UNREACHABLE 0 +# endif #endif /* Each of these macros verifies that its argument R is nonzero. To diff --git a/m4/acl.m4 b/m4/acl.m4 index dc9853a156d..38b1dc66212 100644 --- a/m4/acl.m4 +++ b/m4/acl.m4 @@ -1,5 +1,5 @@ # acl.m4 - check for access control list (ACL) primitives -# serial 27 +# serial 29 # Copyright (C) 2002, 2004-2023 Free Software Foundation, Inc. # This file is free software; the Free Software Foundation @@ -12,7 +12,7 @@ AC_DEFUN([gl_FUNC_ACL_ARG], [ gl_need_lib_has_acl= AC_ARG_ENABLE([acl], - AS_HELP_STRING([--disable-acl], [do not support ACLs]), + AS_HELP_STRING([[--disable-acl]], [do not support ACLs]), , [enable_acl=auto]) ]) @@ -177,37 +177,23 @@ AC_DEFUN([gl_ACL_GET_FILE], AS_IF([test "$gl_cv_func_working_acl_get_file" != no], [$1], [$2]) ]) -# On GNU/Linux, testing if a file has an acl can be done with the getxattr -# syscall which doesn't require linking against additional libraries. +# On GNU/Linux, testing if a file has an acl can be done with the +# listxattr and getxattr syscalls, which don't require linking +# against additional libraries. Assume this works if linux/attr.h +# and listxattr are present. AC_DEFUN([gl_FILE_HAS_ACL], [ AC_REQUIRE([gl_FUNC_ACL_ARG]) - if test "$enable_acl" != no; then - AC_CACHE_CHECK([for getxattr with XATTR_NAME_POSIX_ACL macros], - [gl_cv_getxattr_with_posix_acls], - [gl_cv_getxattr_with_posix_acls=no - AC_LINK_IFELSE( - [AC_LANG_PROGRAM( - [[#include - #include - #include - ]], - [[ssize_t a = getxattr (".", XATTR_NAME_POSIX_ACL_ACCESS, 0, 0); - ssize_t b = getxattr (".", XATTR_NAME_POSIX_ACL_DEFAULT, 0, 0); - return a < 0 || b < 0; - ]])], - [gl_cv_getxattr_with_posix_acls=yes])]) - fi - if test "$gl_cv_getxattr_with_posix_acls" = yes; then - FILE_HAS_ACL_LIB= - AC_DEFINE([GETXATTR_WITH_POSIX_ACLS], 1, - [Define to 1 if getxattr works with XATTR_NAME_POSIX_ACL_ACCESS - and XATTR_NAME_POSIX_ACL_DEFAULT.]) - else - dnl Set gl_need_lib_has_acl to a nonempty value, so that any - dnl later gl_FUNC_ACL call will set FILE_HAS_ACL_LIB=$LIB_ACL. - gl_need_lib_has_acl=1 - FILE_HAS_ACL_LIB=$LIB_ACL - fi + AC_CHECK_HEADERS_ONCE([linux/xattr.h]) + AC_CHECK_FUNCS_ONCE([listxattr]) + FILE_HAS_ACL_LIB= + AS_CASE([$enable_acl,$ac_cv_header_linux_xattr_h,$ac_cv_func_listxattr], + [no,*,*], [], + [*,yes,yes], [], + [*], + [dnl Set gl_need_lib_has_acl to a nonempty value, so that any + dnl later gl_FUNC_ACL call will set FILE_HAS_ACL_LIB=$LIB_ACL. + gl_need_lib_has_acl=1 + FILE_HAS_ACL_LIB=$LIB_ACL]) AC_SUBST([FILE_HAS_ACL_LIB]) ]) diff --git a/m4/codeset.m4 b/m4/codeset.m4 new file mode 100644 index 00000000000..5804f472e9a --- /dev/null +++ b/m4/codeset.m4 @@ -0,0 +1,24 @@ +# codeset.m4 serial 5 (gettext-0.18.2) +dnl Copyright (C) 2000-2002, 2006, 2008-2014, 2016, 2019-2023 Free Software +dnl 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. + +dnl From Bruno Haible. + +AC_DEFUN([AM_LANGINFO_CODESET], +[ + AC_CACHE_CHECK([for nl_langinfo and CODESET], [am_cv_langinfo_codeset], + [AC_LINK_IFELSE( + [AC_LANG_PROGRAM( + [[#include ]], + [[char* cs = nl_langinfo(CODESET); return !cs;]])], + [am_cv_langinfo_codeset=yes], + [am_cv_langinfo_codeset=no]) + ]) + if test $am_cv_langinfo_codeset = yes; then + AC_DEFINE([HAVE_LANGINFO_CODESET], [1], + [Define if you have and nl_langinfo(CODESET).]) + fi +]) diff --git a/m4/dirent_h.m4 b/m4/dirent_h.m4 index 2a232a7622e..b6c189c0d9f 100644 --- a/m4/dirent_h.m4 +++ b/m4/dirent_h.m4 @@ -1,4 +1,4 @@ -# dirent_h.m4 serial 19 +# dirent_h.m4 serial 20 dnl Copyright (C) 2008-2023 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -21,12 +21,29 @@ AC_DEFUN_ONCE([gl_DIRENT_H], fi AC_SUBST([HAVE_DIRENT_H]) + gl_DIRENT_DIR + 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 ]], [alphasort closedir dirfd fdopendir opendir readdir rewinddir scandir]) ]) +dnl Determine whether needs to override the DIR type. +AC_DEFUN_ONCE([gl_DIRENT_DIR], +[ + dnl Set DIR_HAS_FD_MEMBER if dirfd() works, i.e. not always returns -1, + dnl or has the __KLIBC__ workaround as in lib/dirfd.c. + dnl We could use the findings from gl_FUNC_DIRFD and gl_PREREQ_DIRFD, but + dnl it's simpler since we know the affected platforms. + AC_REQUIRE([AC_CANONICAL_HOST]) + case "$host_os" in + mingw*) DIR_HAS_FD_MEMBER=0 ;; + *) DIR_HAS_FD_MEMBER=1 ;; + esac + AC_SUBST([DIR_HAS_FD_MEMBER]) +]) + # gl_DIRENT_MODULE_INDICATOR([modulename]) # sets the shell variable that indicates the presence of the given module # to a C preprocessor expression that will evaluate to 1. @@ -73,6 +90,8 @@ AC_DEFUN([gl_DIRENT_H_DEFAULTS], HAVE_SCANDIR=1; AC_SUBST([HAVE_SCANDIR]) HAVE_ALPHASORT=1; AC_SUBST([HAVE_ALPHASORT]) REPLACE_OPENDIR=0; AC_SUBST([REPLACE_OPENDIR]) + REPLACE_READDIR=0; AC_SUBST([REPLACE_READDIR]) + REPLACE_REWINDDIR=0; AC_SUBST([REPLACE_REWINDDIR]) REPLACE_CLOSEDIR=0; AC_SUBST([REPLACE_CLOSEDIR]) REPLACE_DIRFD=0; AC_SUBST([REPLACE_DIRFD]) REPLACE_FDOPENDIR=0; AC_SUBST([REPLACE_FDOPENDIR]) diff --git a/m4/dirfd.m4 b/m4/dirfd.m4 index 2135535042b..7968b1287ce 100644 --- a/m4/dirfd.m4 +++ b/m4/dirfd.m4 @@ -1,4 +1,4 @@ -# serial 26 -*- Autoconf -*- +# serial 28 -*- Autoconf -*- dnl Find out how to get the file descriptor associated with an open DIR*. @@ -12,7 +12,7 @@ dnl From Jim Meyering AC_DEFUN([gl_FUNC_DIRFD], [ AC_REQUIRE([gl_DIRENT_H_DEFAULTS]) - AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles + AC_REQUIRE([AC_CANONICAL_HOST]) dnl Persuade glibc to declare dirfd(). AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS]) @@ -36,15 +36,20 @@ AC_DEFUN([gl_FUNC_DIRFD], [gl_cv_func_dirfd_macro=yes], [gl_cv_func_dirfd_macro=no])]) - # Use the replacement if we have no function or macro with that name, - # or if OS/2 kLIBC whose dirfd() does not work. - # Replace only if the system declares dirfd already. - case $ac_cv_func_dirfd,$gl_cv_func_dirfd_macro,$host_os,$ac_cv_have_decl_dirfd in - no,no,*,yes | *,*,os2*,yes) + if test $ac_cv_func_dirfd = no && test $gl_cv_func_dirfd_macro = no; then + HAVE_DIRFD=0 + else + HAVE_DIRFD=1 + dnl Replace dirfd() on native Windows, to support fdopendir(). + AC_REQUIRE([gl_DIRENT_DIR]) + if test $DIR_HAS_FD_MEMBER = 0; then REPLACE_DIRFD=1 - AC_DEFINE([REPLACE_DIRFD], [1], - [Define to 1 if gnulib's dirfd() replacement is used.]);; - esac + fi + dnl OS/2 kLIBC dirfd() does not work. + case "$host_os" in + os2*) REPLACE_DIRFD=1 ;; + esac + fi ]) dnl Prerequisites of lib/dirfd.c. diff --git a/m4/extern-inline.m4 b/m4/extern-inline.m4 index c001b1cff7d..f9894d7fe5c 100644 --- a/m4/extern-inline.m4 +++ b/m4/extern-inline.m4 @@ -79,7 +79,8 @@ AC_DEFUN([gl_EXTERN_INLINE], # define _GL_EXTERN_INLINE_STDHEADER_BUG #endif #if ((__GNUC__ \ - ? defined __GNUC_STDC_INLINE__ && __GNUC_STDC_INLINE__ \ + ? (defined __GNUC_STDC_INLINE__ && __GNUC_STDC_INLINE__ \ + && !defined __PCC__) \ : (199901L <= __STDC_VERSION__ \ && !defined __HP_cc \ && !defined __PGI \ @@ -89,6 +90,7 @@ AC_DEFUN([gl_EXTERN_INLINE], # define _GL_EXTERN_INLINE extern inline # define _GL_EXTERN_INLINE_IN_USE #elif (2 < __GNUC__ + (7 <= __GNUC_MINOR__) && !defined __STRICT_ANSI__ \ + && !defined __PCC__ \ && !defined _GL_EXTERN_INLINE_STDHEADER_BUG) # if defined __GNUC_GNU_INLINE__ && __GNUC_GNU_INLINE__ /* __gnu_inline__ suppresses a GCC 4.2 diagnostic. */ diff --git a/m4/gnulib-common.m4 b/m4/gnulib-common.m4 index c84a2afd9c5..edb8572da25 100644 --- a/m4/gnulib-common.m4 +++ b/m4/gnulib-common.m4 @@ -1,4 +1,4 @@ -# gnulib-common.m4 serial 82 +# gnulib-common.m4 serial 86 dnl Copyright (C) 2007-2023 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -15,6 +15,10 @@ AC_DEFUN([gl_COMMON], [ AC_REQUIRE([gl_ZZGNULIB]) ]) AC_DEFUN([gl_COMMON_BODY], [ + AH_VERBATIM([0witness], +[/* Witness that has been included. */ +#define _GL_CONFIG_H_INCLUDED 1 +]) AH_VERBATIM([_GL_GNUC_PREREQ], [/* True if the compiler says it groks GNU C version MAJOR.MINOR. */ #if defined __GNUC__ && defined __GNUC_MINOR__ @@ -116,6 +120,20 @@ AC_DEFUN([gl_COMMON_BODY], [ # pragma GCC diagnostic ignored "-Wpedantic" #endif +/* Define if, in a function declaration, the attributes in bracket syntax + [[...]] must come before the attributes in __attribute__((...)) syntax. + If this is defined, it is best to avoid the bracket syntax, so that the + various _GL_ATTRIBUTE_* can be cumulated on the same declaration in any + order. */ +#ifdef __cplusplus +# if defined __clang__ +# define _GL_BRACKET_BEFORE_ATTRIBUTE 1 +# endif +#else +# if defined __GNUC__ && !defined __clang__ +# define _GL_BRACKET_BEFORE_ATTRIBUTE 1 +# endif +#endif ]dnl There is no _GL_ATTRIBUTE_ALIGNED; use stdalign's alignas instead. [ /* _GL_ATTRIBUTE_ALLOC_SIZE ((N)) declares that the Nth argument of the function @@ -223,9 +241,11 @@ AC_DEFUN([gl_COMMON_BODY], [ - typedef, in C++ also: namespace, class, template specialization. */ #ifndef _GL_ATTRIBUTE_DEPRECATED -# ifdef __has_c_attribute -# if __has_c_attribute (__deprecated__) -# define _GL_ATTRIBUTE_DEPRECATED [[__deprecated__]] +# ifndef _GL_BRACKET_BEFORE_ATTRIBUTE +# ifdef __has_c_attribute +# if __has_c_attribute (__deprecated__) +# define _GL_ATTRIBUTE_DEPRECATED [[__deprecated__]] +# endif # endif # endif # if !defined _GL_ATTRIBUTE_DEPRECATED && _GL_HAS_ATTRIBUTE (deprecated) @@ -355,13 +375,15 @@ AC_DEFUN([gl_COMMON_BODY], [ __has_c_attribute (__maybe_unused__) yields true but the use of [[__maybe_unused__]] nevertheless produces a warning. */ #ifndef _GL_ATTRIBUTE_MAYBE_UNUSED -# if defined __clang__ && defined __cplusplus -# if !defined __apple_build_version__ && __clang_major__ >= 10 -# define _GL_ATTRIBUTE_MAYBE_UNUSED [[__maybe_unused__]] -# endif -# elif defined __has_c_attribute -# if __has_c_attribute (__maybe_unused__) -# define _GL_ATTRIBUTE_MAYBE_UNUSED [[__maybe_unused__]] +# ifndef _GL_BRACKET_BEFORE_ATTRIBUTE +# if defined __clang__ && defined __cplusplus +# if !defined __apple_build_version__ && __clang_major__ >= 10 +# define _GL_ATTRIBUTE_MAYBE_UNUSED [[__maybe_unused__]] +# endif +# elif defined __has_c_attribute +# if __has_c_attribute (__maybe_unused__) +# define _GL_ATTRIBUTE_MAYBE_UNUSED [[__maybe_unused__]] +# endif # endif # endif # ifndef _GL_ATTRIBUTE_MAYBE_UNUSED @@ -379,18 +401,20 @@ AC_DEFUN([gl_COMMON_BODY], [ the return value, unless the caller uses something like ignore_value. */ /* Applies to: function, enumeration, class. */ #ifndef _GL_ATTRIBUTE_NODISCARD -# if defined __clang__ && defined __cplusplus +# ifndef _GL_BRACKET_BEFORE_ATTRIBUTE +# if defined __clang__ && defined __cplusplus /* With clang up to 15.0.6 (at least), in C++ mode, [[__nodiscard__]] produces a warning. The 1000 below means a yet unknown threshold. When clang++ version X starts supporting [[__nodiscard__]] without warning about it, you can replace the 1000 with X. */ -# if __clang_major__ >= 1000 -# define _GL_ATTRIBUTE_NODISCARD [[__nodiscard__]] -# endif -# elif defined __has_c_attribute -# if __has_c_attribute (__nodiscard__) -# define _GL_ATTRIBUTE_NODISCARD [[__nodiscard__]] +# if __clang_major__ >= 1000 +# define _GL_ATTRIBUTE_NODISCARD [[__nodiscard__]] +# endif +# elif defined __has_c_attribute +# if __has_c_attribute (__nodiscard__) +# define _GL_ATTRIBUTE_NODISCARD [[__nodiscard__]] +# endif # endif # endif # if !defined _GL_ATTRIBUTE_NODISCARD && _GL_HAS_ATTRIBUTE (warn_unused_result) @@ -527,6 +551,18 @@ AC_DEFUN([gl_COMMON_BODY], [ # define _GL_UNUSED_LABEL # endif #endif +]) + AH_VERBATIM([c_linkage], +[/* In C++, there is the concept of "language linkage", that encompasses + name mangling and function calling conventions. + The following macros start and end a block of "C" linkage. */ +#ifdef __cplusplus +# define _GL_BEGIN_C_LINKAGE extern "C" { +# define _GL_END_C_LINKAGE } +#else +# define _GL_BEGIN_C_LINKAGE +# define _GL_END_C_LINKAGE +#endif ]) AH_VERBATIM([async_safe], [/* The _GL_ASYNC_SAFE marker should be attached to functions that are @@ -583,7 +619,7 @@ AC_DEFUN([gl_COMMON_BODY], [ dnl gl_cross_guess_normal (to be used when 'yes' is good and 'no' is bad), dnl gl_cross_guess_inverted (to be used when 'no' is good and 'yes' is bad). AC_ARG_ENABLE([cross-guesses], - [AS_HELP_STRING([--enable-cross-guesses={conservative|risky}], + [AS_HELP_STRING([[--enable-cross-guesses={conservative|risky}]], [specify policy for cross-compilation guesses])], [if test "x$enableval" != xconservative && test "x$enableval" != xrisky; then AC_MSG_WARN([invalid argument supplied to --enable-cross-guesses]) diff --git a/m4/gnulib-comp.m4 b/m4/gnulib-comp.m4 index 1bd16a779eb..58fcd1c0481 100644 --- a/m4/gnulib-comp.m4 +++ b/m4/gnulib-comp.m4 @@ -176,6 +176,7 @@ AC_DEFUN([gl_EARLY], # Code from module stddef: # Code from module stdint: # Code from module stdio: + gl_STDIO_H_EARLY # Code from module stdlib: # Code from module stpcpy: # Code from module string: @@ -660,7 +661,7 @@ AC_DEFUN([gl_INIT], gl_gnulib_enabled_682e609604ccaac6be382e4ee3a4eaec=false func_gl_gnulib_m4code_260941c0e5dc67ec9e87d1fb321c300b () { - if ! $gl_gnulib_enabled_260941c0e5dc67ec9e87d1fb321c300b; then + if $gl_gnulib_enabled_260941c0e5dc67ec9e87d1fb321c300b; then :; else AC_REQUIRE([AC_CANONICAL_HOST]) gl_gnulib_enabled_260941c0e5dc67ec9e87d1fb321c300b=true if case $host_os in mingw*) false;; *) :;; esac; then @@ -670,17 +671,17 @@ AC_DEFUN([gl_INIT], } func_gl_gnulib_m4code_cloexec () { - if ! $gl_gnulib_enabled_cloexec; then + if $gl_gnulib_enabled_cloexec; then :; else gl_MODULE_INDICATOR_FOR_TESTS([cloexec]) gl_gnulib_enabled_cloexec=true fi } func_gl_gnulib_m4code_dirfd () { - if ! $gl_gnulib_enabled_dirfd; then + if $gl_gnulib_enabled_dirfd; then :; else gl_FUNC_DIRFD gl_CONDITIONAL([GL_COND_OBJ_DIRFD], - [test $ac_cv_func_dirfd = no && test $gl_cv_func_dirfd_macro = no || test $REPLACE_DIRFD = 1]) + [test $HAVE_DIRFD = 0 || test $REPLACE_DIRFD = 1]) AM_COND_IF([GL_COND_OBJ_DIRFD], [ gl_PREREQ_DIRFD ]) @@ -690,13 +691,13 @@ AC_DEFUN([gl_INIT], } func_gl_gnulib_m4code_925677f0343de64b89a9f0c790b4104c () { - if ! $gl_gnulib_enabled_925677f0343de64b89a9f0c790b4104c; then + if $gl_gnulib_enabled_925677f0343de64b89a9f0c790b4104c; then :; else gl_gnulib_enabled_925677f0343de64b89a9f0c790b4104c=true fi } func_gl_gnulib_m4code_euidaccess () { - if ! $gl_gnulib_enabled_euidaccess; then + if $gl_gnulib_enabled_euidaccess; then :; else gl_FUNC_EUIDACCESS gl_CONDITIONAL([GL_COND_OBJ_EUIDACCESS], [test $HAVE_EUIDACCESS = 0]) AM_COND_IF([GL_COND_OBJ_EUIDACCESS], [ @@ -712,7 +713,7 @@ AC_DEFUN([gl_INIT], } func_gl_gnulib_m4code_getdtablesize () { - if ! $gl_gnulib_enabled_getdtablesize; then + if $gl_gnulib_enabled_getdtablesize; then :; else gl_FUNC_GETDTABLESIZE gl_CONDITIONAL([GL_COND_OBJ_GETDTABLESIZE], [test $HAVE_GETDTABLESIZE = 0 || test $REPLACE_GETDTABLESIZE = 1]) @@ -725,7 +726,7 @@ AC_DEFUN([gl_INIT], } func_gl_gnulib_m4code_getgroups () { - if ! $gl_gnulib_enabled_getgroups; then + if $gl_gnulib_enabled_getgroups; then :; else gl_FUNC_GETGROUPS gl_CONDITIONAL([GL_COND_OBJ_GETGROUPS], [test $HAVE_GETGROUPS = 0 || test $REPLACE_GETGROUPS = 1]) @@ -738,7 +739,7 @@ AC_DEFUN([gl_INIT], } func_gl_gnulib_m4code_be453cec5eecf5731a274f2de7f2db36 () { - if ! $gl_gnulib_enabled_be453cec5eecf5731a274f2de7f2db36; then + if $gl_gnulib_enabled_be453cec5eecf5731a274f2de7f2db36; then :; else AC_SUBST([LIBINTL]) AC_SUBST([LTLIBINTL]) gl_gnulib_enabled_be453cec5eecf5731a274f2de7f2db36=true @@ -746,14 +747,14 @@ AC_DEFUN([gl_INIT], } func_gl_gnulib_m4code_fd38c7e463b54744b77b98aeafb4fa7c () { - if ! $gl_gnulib_enabled_fd38c7e463b54744b77b98aeafb4fa7c; then + if $gl_gnulib_enabled_fd38c7e463b54744b77b98aeafb4fa7c; then :; else AC_PROG_MKDIR_P gl_gnulib_enabled_fd38c7e463b54744b77b98aeafb4fa7c=true fi } func_gl_gnulib_m4code_8444034ea779b88768865bb60b4fb8c9 () { - if ! $gl_gnulib_enabled_8444034ea779b88768865bb60b4fb8c9; then + if $gl_gnulib_enabled_8444034ea779b88768865bb60b4fb8c9; then :; else AC_PROG_MKDIR_P gl_gnulib_enabled_8444034ea779b88768865bb60b4fb8c9=true func_gl_gnulib_m4code_ef455225c00f5049c808c2eda3e76866 @@ -762,7 +763,7 @@ AC_DEFUN([gl_INIT], } func_gl_gnulib_m4code_a9786850e999ae65a836a6041e8e5ed1 () { - if ! $gl_gnulib_enabled_a9786850e999ae65a836a6041e8e5ed1; then + if $gl_gnulib_enabled_a9786850e999ae65a836a6041e8e5ed1; then :; else gl_FUNC_GROUP_MEMBER gl_CONDITIONAL([GL_COND_OBJ_GROUP_MEMBER], [test $HAVE_GROUP_MEMBER = 0]) AM_COND_IF([GL_COND_OBJ_GROUP_MEMBER], [ @@ -780,7 +781,7 @@ AC_DEFUN([gl_INIT], } func_gl_gnulib_m4code_lchmod () { - if ! $gl_gnulib_enabled_lchmod; then + if $gl_gnulib_enabled_lchmod; then :; else gl_FUNC_LCHMOD gl_CONDITIONAL([GL_COND_OBJ_LCHMOD], [test $HAVE_LCHMOD = 0]) AM_COND_IF([GL_COND_OBJ_LCHMOD], [ @@ -792,7 +793,7 @@ AC_DEFUN([gl_INIT], } func_gl_gnulib_m4code_e80bf6f757095d2e5fc94dafb8f8fc8b () { - if ! $gl_gnulib_enabled_e80bf6f757095d2e5fc94dafb8f8fc8b; then + if $gl_gnulib_enabled_e80bf6f757095d2e5fc94dafb8f8fc8b; then :; else gl_FUNC_MALLOC_GNU if test $REPLACE_MALLOC_FOR_MALLOC_GNU = 1; then AC_LIBOBJ([malloc]) @@ -807,7 +808,7 @@ AC_DEFUN([gl_INIT], } func_gl_gnulib_m4code_ef455225c00f5049c808c2eda3e76866 () { - if ! $gl_gnulib_enabled_ef455225c00f5049c808c2eda3e76866; then + if $gl_gnulib_enabled_ef455225c00f5049c808c2eda3e76866; then :; else AC_REQUIRE([gl_FUNC_MALLOC_POSIX]) if test $REPLACE_MALLOC_FOR_MALLOC_POSIX = 1; then AC_LIBOBJ([malloc]) @@ -821,7 +822,7 @@ AC_DEFUN([gl_INIT], } func_gl_gnulib_m4code_5264294aa0a5557541b53c8c741f7f31 () { - if ! $gl_gnulib_enabled_5264294aa0a5557541b53c8c741f7f31; then + if $gl_gnulib_enabled_5264294aa0a5557541b53c8c741f7f31; then :; else gl_FUNC_MKTIME_INTERNAL if test $WANT_MKTIME_INTERNAL = 1; then AC_LIBOBJ([mktime]) @@ -832,7 +833,7 @@ AC_DEFUN([gl_INIT], } func_gl_gnulib_m4code_open () { - if ! $gl_gnulib_enabled_open; then + if $gl_gnulib_enabled_open; then :; else gl_FUNC_OPEN gl_CONDITIONAL([GL_COND_OBJ_OPEN], [test $REPLACE_OPEN = 1]) AM_COND_IF([GL_COND_OBJ_OPEN], [ @@ -847,13 +848,13 @@ AC_DEFUN([gl_INIT], } func_gl_gnulib_m4code_03e0aaad4cb89ca757653bd367a6ccb7 () { - if ! $gl_gnulib_enabled_03e0aaad4cb89ca757653bd367a6ccb7; then + if $gl_gnulib_enabled_03e0aaad4cb89ca757653bd367a6ccb7; then :; else gl_gnulib_enabled_03e0aaad4cb89ca757653bd367a6ccb7=true fi } func_gl_gnulib_m4code_rawmemchr () { - if ! $gl_gnulib_enabled_rawmemchr; then + if $gl_gnulib_enabled_rawmemchr; then :; else gl_FUNC_RAWMEMCHR gl_CONDITIONAL([GL_COND_OBJ_RAWMEMCHR], [test $HAVE_RAWMEMCHR = 0]) AM_COND_IF([GL_COND_OBJ_RAWMEMCHR], [ @@ -865,7 +866,7 @@ AC_DEFUN([gl_INIT], } func_gl_gnulib_m4code_d3b2383720ee0e541357aa2aac598e2b () { - if ! $gl_gnulib_enabled_d3b2383720ee0e541357aa2aac598e2b; then + if $gl_gnulib_enabled_d3b2383720ee0e541357aa2aac598e2b; then :; else gl_FUNC_REALLOC_GNU if test $REPLACE_REALLOC_FOR_REALLOC_GNU = 1; then AC_LIBOBJ([realloc]) @@ -883,7 +884,7 @@ AC_DEFUN([gl_INIT], } func_gl_gnulib_m4code_61bcaca76b3e6f9ae55d57a1c3193bc4 () { - if ! $gl_gnulib_enabled_61bcaca76b3e6f9ae55d57a1c3193bc4; then + if $gl_gnulib_enabled_61bcaca76b3e6f9ae55d57a1c3193bc4; then :; else gl_FUNC_REALLOC_POSIX if test $REPLACE_REALLOC_FOR_REALLOC_POSIX = 1; then AC_LIBOBJ([realloc]) @@ -900,13 +901,13 @@ AC_DEFUN([gl_INIT], } func_gl_gnulib_m4code_6099e9737f757db36c47fa9d9f02e88c () { - if ! $gl_gnulib_enabled_6099e9737f757db36c47fa9d9f02e88c; then + if $gl_gnulib_enabled_6099e9737f757db36c47fa9d9f02e88c; then :; else gl_gnulib_enabled_6099e9737f757db36c47fa9d9f02e88c=true fi } func_gl_gnulib_m4code_strtoll () { - if ! $gl_gnulib_enabled_strtoll; then + if $gl_gnulib_enabled_strtoll; then :; else gl_FUNC_STRTOLL gl_CONDITIONAL([GL_COND_OBJ_STRTOLL], [test $HAVE_STRTOLL = 0 || test $REPLACE_STRTOLL = 1]) @@ -919,14 +920,14 @@ AC_DEFUN([gl_INIT], } func_gl_gnulib_m4code_utimens () { - if ! $gl_gnulib_enabled_utimens; then + if $gl_gnulib_enabled_utimens; then :; else gl_UTIMENS gl_gnulib_enabled_utimens=true fi } func_gl_gnulib_m4code_682e609604ccaac6be382e4ee3a4eaec () { - if ! $gl_gnulib_enabled_682e609604ccaac6be382e4ee3a4eaec; then + if $gl_gnulib_enabled_682e609604ccaac6be382e4ee3a4eaec; then :; else gl_gnulib_enabled_682e609604ccaac6be382e4ee3a4eaec=true fi } @@ -1246,6 +1247,7 @@ AC_DEFUN([gl_FILE_LIST], [ lib/count-trailing-zeros.c lib/count-trailing-zeros.h lib/diffseq.h + lib/dirent-private.h lib/dirent.in.h lib/dirfd.c lib/dtoastr.c @@ -1429,6 +1431,7 @@ AC_DEFUN([gl_FILE_LIST], [ m4/c-bool.m4 m4/canonicalize.m4 m4/clock_time.m4 + m4/codeset.m4 m4/copy-file-range.m4 m4/d-type.m4 m4/dirent_h.m4 @@ -1474,6 +1477,7 @@ AC_DEFUN([gl_FILE_LIST], [ m4/lchmod.m4 m4/libgmp.m4 m4/limits-h.m4 + m4/locale-fr.m4 m4/lstat.m4 m4/malloc.m4 m4/manywarnings-c++.m4 @@ -1489,6 +1493,7 @@ AC_DEFUN([gl_FILE_LIST], [ m4/mktime.m4 m4/mode_t.m4 m4/multiarch.m4 + m4/musl.m4 m4/nanosleep.m4 m4/nocrash.m4 m4/nproc.m4 diff --git a/m4/largefile.m4 b/m4/largefile.m4 index 7fb81b864af..a2adb533ae6 100644 --- a/m4/largefile.m4 +++ b/m4/largefile.m4 @@ -10,7 +10,7 @@ # It does not set _LARGEFILE_SOURCE=1 on HP-UX/ia64 32-bit, although this # setting of _LARGEFILE_SOURCE is needed so that declares fseeko # and ftello in C++ mode as well. -# Fixed in Autoconf 2.72, which has AC_SYS_YEAR2038. +# This problem occurs in Autoconf 2.71 and earlier, which lack AC_SYS_YEAR2038. AC_DEFUN([gl_SET_LARGEFILE_SOURCE], m4_ifndef([AC_SYS_YEAR2038], [[ AC_REQUIRE([AC_CANONICAL_HOST]) @@ -24,29 +24,9 @@ AC_DEFUN([gl_SET_LARGEFILE_SOURCE], ]]) ) -# Work around a problem in autoconf <= 2.69: -# AC_SYS_LARGEFILE does not configure for large inodes on Mac OS X 10.5, -# or configures them incorrectly in some cases. -m4_version_prereq([2.70], [], [ - -# _AC_SYS_LARGEFILE_TEST_INCLUDES -# ------------------------------- -m4_define([_AC_SYS_LARGEFILE_TEST_INCLUDES], -[#include - /* Check that off_t can represent 2**63 - 1 correctly. - We can't simply define LARGE_OFF_T to be 9223372036854775807, - since some C++ compilers masquerading as C compilers - incorrectly reject 9223372036854775807. */ -#define LARGE_OFF_T (((off_t) 1 << 31 << 31) - 1 + ((off_t) 1 << 31 << 31)) - int off_t_is_large[[(LARGE_OFF_T % 2147483629 == 721 - && LARGE_OFF_T % 2147483647 == 1) - ? 1 : -1]];[]dnl -]) -])# m4_version_prereq 2.70 - -# Support AC_SYS_YEAR2038, even if Autoconf 2.71 or earlier. -# This code is taken from Autoconf master. -m4_ifndef([AC_SYS_YEAR2038], [ +m4_ifndef([AC_SYS_YEAR2038_RECOMMENDED], [ +# Support AC_SYS_YEAR2038_RECOMMENDED and related macros, even if +# Autoconf 2.71 or earlier. This code is taken from Autoconf master. # _AC_SYS_YEAR2038_TEST_CODE # -------------------------- @@ -78,8 +58,8 @@ m4_define([_AC_SYS_YEAR2038_OPTIONS], m4_normalize( dnl 32-bit MinGW (misconfiguration) )) -# _AC_SYS_YEAR2038_PROBE([IF-NOT-DETECTED]) -# ----------------------------------------- +# _AC_SYS_YEAR2038_PROBE +# ---------------------- # Subroutine of AC_SYS_YEAR2038. Probe for time_t that can represent # time points more than 2**31 - 1 seconds after the epoch (dates after # 2038-01-18, see above) and set the cache variable ac_cv_sys_year2038_opts @@ -92,13 +72,10 @@ m4_define([_AC_SYS_YEAR2038_OPTIONS], m4_normalize( # AC_TRY_RUN. Note also that some systems only support large time_t # together with large off_t. # -# If support is not detected, the behavior depends on which of the -# top-level AC_SYS_YEAR2038 macros was used (see below). -# # If you change this macro you may also need to change # _AC_SYS_YEAR2038_OPTIONS. AC_DEFUN([_AC_SYS_YEAR2038_PROBE], -[AC_CACHE_CHECK([for $CC option to enable timestamps after Jan 2038], +[AC_CACHE_CHECK([for $CC option for timestamps after 2038], [ac_cv_sys_year2038_opts], [ac_save_CPPFLAGS="$CPPFLAGS" ac_opt_found=no @@ -117,40 +94,20 @@ ac_have_year2038=yes AS_CASE([$ac_cv_sys_year2038_opts], ["none needed"], [], ["support not detected"], - [ac_have_year2038=no - AS_CASE([$enable_year2038], - [yes], - [# If we're not cross compiling and 'touch' works with a large - # timestamp, then we can presume the system supports wider time_t - # *somehow* and we just weren't able to detect it. One common - # case that we deliberately *don't* probe for is a system that - # supports both 32- and 64-bit ABIs but only the 64-bit ABI offers - # wide time_t. (It would be inappropriate for us to override an - # intentional use of -m32.) Error out, demanding use of - # --disable-year2038 if this is intentional. - AS_IF([test $cross_compiling = no], - [AS_IF([TZ=UTC0 touch -t 210602070628.15 conftest.time 2>/dev/null], - [AS_CASE([`TZ=UTC0 LC_ALL=C ls -l conftest.time 2>/dev/null`], - [*'Feb 7 2106'* | *'Feb 7 17:10'*], - [AC_MSG_FAILURE(m4_text_wrap( - [this system appears to support timestamps after January 2038, - but no mechanism for enabling wide 'time_t' was detected. - Did you mean to build a 64-bit binary? (e.g. 'CC="${CC} -m64"'.) - To proceed with 32-bit time_t, configure with '--disable-year2038'.], - [], [], [55]))])])])])], + [ac_have_year2038=no], ["-D_TIME_BITS=64"], [AC_DEFINE([_TIME_BITS], [64], [Number of bits in time_t, on hosts where this is settable.])], - ["-D__MINGW_USE_VC2005_COMPAT=1"], + ["-D__MINGW_USE_VC2005_COMPAT"], [AC_DEFINE([__MINGW_USE_VC2005_COMPAT], [1], [Define to 1 on platforms where this makes time_t a 64-bit type.])], ["-U_USE_32_BIT_TIME_T"*], [AC_MSG_FAILURE(m4_text_wrap( [the 'time_t' type is currently forced to be 32-bit. - It will stop working after January 2038. + It will stop working after mid-January 2038. Remove _USE_32BIT_TIME_T from the compiler flags.], [], [], [55]))], @@ -160,12 +117,11 @@ AS_CASE([$ac_cv_sys_year2038_opts], # _AC_SYS_YEAR2038_ENABLE # ----------------------- -# Subroutine of AC_SYS_YEAR2038 and _AC_SYS_YEAR2038_OPT_IN. # Depending on which of the YEAR2038 macros was used, add either an -# --enable-year2038, or a --disable-year2038, or no option at all to -# the configure script. Note that this is expanded very late and +# --enable-year2038 or a --disable-year2038 to +# the configure script. This is expanded very late and # therefore there cannot be any code in the AC_ARG_ENABLE. The -# default value for enable_year2038 is emitted unconditionally +# default value for 'enable_year2038' is emitted unconditionally # because the generated code always looks at this variable. m4_define([_AC_SYS_YEAR2038_ENABLE], [m4_divert_text([DEFAULTS], @@ -175,35 +131,50 @@ m4_define([_AC_SYS_YEAR2038_ENABLE], [AC_ARG_ENABLE([year2038], m4_provide_if([AC_SYS_YEAR2038], [AS_HELP_STRING([--disable-year2038], - [do not support timestamps after 2038])], + [don't support timestamps after 2038])], [AS_HELP_STRING([--enable-year2038], [support timestamps after 2038])]))]) -# _AC_SYS_YEAR2038_OPT_IN -# ----------------------- -# If the --enable-year2038 option is given to configure, attempt to -# detect and activate support for large time_t on 32-bit systems. -# This macro is automatically invoked by AC_SYS_LARGEFILE when large -# *file* support is detected. It does not AC_REQUIRE AC_SYS_LARGEFILE -# to avoid a dependency loop, and is therefore unsafe to expose as a -# documented macro. -AC_DEFUN([_AC_SYS_YEAR2038_OPT_IN], -[m4_provide_if([_AC_SYS_YEAR2038_PROBE], [], [dnl - AS_IF([test "$enable_year2038" != no], [_AC_SYS_YEAR2038_PROBE]) - AC_CONFIG_COMMANDS_PRE([_AC_SYS_YEAR2038_ENABLE]) -])]) - # AC_SYS_YEAR2038 # --------------- # Attempt to detect and activate support for large time_t. # On systems where time_t is not always 64 bits, this probe can be # skipped by passing the --disable-year2038 option to configure. AC_DEFUN([AC_SYS_YEAR2038], -[AC_REQUIRE([AC_SYS_LARGEFILE])]dnl -[m4_provide_if([_AC_SYS_YEAR2038_PROBE], [], [dnl - AS_IF([test "$enable_year2038" != no], [_AC_SYS_YEAR2038_PROBE]) - AC_CONFIG_COMMANDS_PRE([_AC_SYS_YEAR2038_ENABLE]) -])]) +[AC_REQUIRE([AC_SYS_LARGEFILE])dnl +AS_IF([test "$enable_year2038,$ac_have_year2038,$cross_compiling" = yes,no,no], + [# If we're not cross compiling and 'touch' works with a large + # timestamp, then we can presume the system supports wider time_t + # *somehow* and we just weren't able to detect it. One common + # case that we deliberately *don't* probe for is a system that + # supports both 32- and 64-bit ABIs but only the 64-bit ABI offers + # wide time_t. (It would be inappropriate for us to override an + # intentional use of -m32.) Error out, demanding use of + # --disable-year2038 if this is intentional. + AS_IF([TZ=UTC0 touch -t 210602070628.15 conftest.time 2>/dev/null], + [AS_CASE([`TZ=UTC0 LC_ALL=C ls -l conftest.time 2>/dev/null`], + [*'Feb 7 2106'* | *'Feb 7 17:10'*], + [AC_MSG_FAILURE(m4_text_wrap( + [this system appears to support timestamps after mid-January 2038, + but no mechanism for enabling wide 'time_t' was detected. + Did you mean to build a 64-bit binary? (E.g., 'CC="${CC} -m64"'.) + To proceed with 32-bit time_t, configure with '--disable-year2038'.], + [], [], [55]))])])])]) + +# AC_SYS_YEAR2038_RECOMMENDED +# --------------------------- +# Same as AC_SYS_YEAR2038, but recommend support for large time_t. +# If we cannot find any way to make time_t capable of representing +# values larger than 2**31 - 1, error out unless --disable-year2038 is given. +AC_DEFUN([AC_SYS_YEAR2038_RECOMMENDED], +[AC_REQUIRE([AC_SYS_YEAR2038])dnl +AS_IF([test "$enable_year2038,$ac_have_year2038" = yes,no], + [AC_MSG_FAILURE(m4_text_wrap( + [could not enable timestamps after mid-January 2038. + This package recommends support for these later timestamps. + However, to proceed with signed 32-bit time_t even though it + will fail then, configure with '--disable-year2038'.], + [], [], [55]))])]) # _AC_SYS_LARGEFILE_TEST_CODE # --------------------------- @@ -219,6 +190,8 @@ m4_define([_AC_SYS_LARGEFILE_TEST_CODE], && LARGE_OFF_T % 2147483647 == 1) ? 1 : -1]];[]dnl ]) +# Defined by Autoconf 2.71 and circa 2022 Gnulib unwisely depended on it. +m4_define([_AC_SYS_LARGEFILE_TEST_INCLUDES], [_AC_SYS_LARGEFILE_TEST_CODE]) # _AC_SYS_LARGEFILE_OPTIONS # ------------------------- @@ -228,8 +201,8 @@ m4_define([_AC_SYS_LARGEFILE_TEST_CODE], m4_define([_AC_SYS_LARGEFILE_OPTIONS], m4_normalize( ["none needed"] dnl Most current systems ["-D_FILE_OFFSET_BITS=64"] dnl X/Open LFS spec - ["-D_LARGE_FILES=1"] dnl AIX (which versions?) - ["-n32"] dnl Irix 6.2 w/ SGI compiler + ["-D_LARGE_FILES=1"] dnl 32-bit AIX 4.2.1+, 32-bit z/OS + ["-n32"] dnl 32-bit IRIX 6, SGI cc (obsolete) )) # _AC_SYS_LARGEFILE_PROBE @@ -259,11 +232,24 @@ AC_DEFUN([_AC_SYS_LARGEFILE_PROBE], test $ac_opt_found = no || break done CC="$ac_save_CC" + dnl Gnulib implements large file support for native Windows, based on the + dnl variables WINDOWS_64_BIT_OFF_T, WINDOWS_64_BIT_ST_SIZE. + m4_ifdef([gl_LARGEFILE], [ + AC_REQUIRE([AC_CANONICAL_HOST]) + if test $ac_opt_found != yes; then + AS_CASE([$host_os], + [mingw*], + [ac_cv_sys_largefile_opts="supported through gnulib" + ac_opt_found=yes] + ) + fi + ]) test $ac_opt_found = yes || ac_cv_sys_largefile_opts="support not detected"]) ac_have_largefile=yes AS_CASE([$ac_cv_sys_largefile_opts], ["none needed"], [], + ["supported through gnulib"], [], ["support not detected"], [ac_have_largefile=no], @@ -281,21 +267,9 @@ AS_CASE([$ac_cv_sys_largefile_opts], [AC_MSG_ERROR( [internal error: bad value for \$ac_cv_sys_largefile_opts])]) -_AC_SYS_YEAR2038_OPT_IN -]) - -# _AC_SYS_LARGEFILE_ENABLE -# ------------------------ -# Subroutine of AC_SYS_LARGEFILE. Note that this -# is expanded very late and therefore there cannot be any code in the -# AC_ARG_ENABLE. The default value for enable_largefile is emitted -# unconditionally because the generated shell code always looks at -# this variable. -m4_define([_AC_SYS_LARGEFILE_ENABLE], -[m4_divert_text([DEFAULTS], - enable_largefile=yes)]dnl -[AC_ARG_ENABLE([largefile], - [AS_HELP_STRING([--disable-largefile], [omit support for large files])])]) +AS_IF([test "$enable_year2038" != no], + [_AC_SYS_YEAR2038_PROBE]) +AC_CONFIG_COMMANDS_PRE([_AC_SYS_YEAR2038_ENABLE])]) # AC_SYS_LARGEFILE # ---------------- @@ -306,14 +280,13 @@ m4_define([_AC_SYS_LARGEFILE_ENABLE], # Additionally, on Linux file systems with 64-bit inodes a file that happens # to have a 64-bit inode number cannot be accessed by 32-bit applications on # Linux x86/x86_64. This can occur with file systems such as XFS and NFS. -# This macro allows configuration to continue if the system doesn't support -# large files. AC_DEFUN([AC_SYS_LARGEFILE], -[m4_provide_if([_AC_SYS_LARGEFILE_PROBE], [], [dnl - AS_IF([test "$enable_largefile" != no], [_AC_SYS_LARGEFILE_PROBE]) - AC_CONFIG_COMMANDS_PRE([_AC_SYS_LARGEFILE_ENABLE]) -])]) -])# m4_ifndef AC_SYS_YEAR2038 +[AC_ARG_ENABLE([largefile], + [AS_HELP_STRING([--disable-largefile], + [omit support for large files])])dnl +AS_IF([test "$enable_largefile,$enable_year2038" != no,no], + [_AC_SYS_LARGEFILE_PROBE])]) +])# m4_ifndef AC_SYS_YEAR2038_RECOMMENDED # Enable large files on systems where this is implemented by Gnulib, not by the # system headers. diff --git a/m4/libgmp.m4 b/m4/libgmp.m4 index 58576c4d0c5..eb20ada0fa5 100644 --- a/m4/libgmp.m4 +++ b/m4/libgmp.m4 @@ -1,4 +1,4 @@ -# libgmp.m4 serial 7 +# libgmp.m4 serial 8 # Configure the GMP library or a replacement. dnl Copyright 2020-2023 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation @@ -15,7 +15,7 @@ dnl empty. AC_DEFUN([gl_LIBGMP], [ AC_ARG_WITH([libgmp], - [AS_HELP_STRING([--without-libgmp], + [AS_HELP_STRING([[--without-libgmp]], [do not use the GNU Multiple Precision (GMP) library; this is the default on systems lacking libgmp.])]) HAVE_LIBGMP=no diff --git a/m4/limits-h.m4 b/m4/limits-h.m4 index 4f8ce41098a..ca0294e5500 100644 --- a/m4/limits-h.m4 +++ b/m4/limits-h.m4 @@ -24,6 +24,7 @@ AC_DEFUN_ONCE([gl_LIMITS_H], int ullw = ULLONG_WIDTH; int bw = BOOL_WIDTH; int bm = BOOL_MAX; + int mblm = MB_LEN_MAX; ]])], [gl_cv_header_limits_width=yes], [gl_cv_header_limits_width=no])]) diff --git a/m4/locale-fr.m4 b/m4/locale-fr.m4 new file mode 100644 index 00000000000..5e13f3945d2 --- /dev/null +++ b/m4/locale-fr.m4 @@ -0,0 +1,253 @@ +# locale-fr.m4 serial 21 +dnl Copyright (C) 2003, 2005-2023 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. + +dnl From Bruno Haible. + +dnl Determine the name of a french locale with traditional encoding. +AC_DEFUN_ONCE([gt_LOCALE_FR], +[ + AC_REQUIRE([AC_CANONICAL_HOST]) + AC_REQUIRE([AM_LANGINFO_CODESET]) + AC_CACHE_CHECK([for a traditional french locale], [gt_cv_locale_fr], [ + AC_LANG_CONFTEST([AC_LANG_SOURCE([[ +#include +#include +#if HAVE_LANGINFO_CODESET +# include +#endif +#include +#include +struct tm t; +char buf[16]; +int main () { + /* On BeOS and Haiku, locales are not implemented in libc. Rather, libintl + imitates locale dependent behaviour by looking at the environment + variables, and all locales use the UTF-8 encoding. */ +#if defined __BEOS__ || defined __HAIKU__ + return 1; +#else + /* Check whether the given locale name is recognized by the system. */ +# if defined _WIN32 && !defined __CYGWIN__ + /* On native Windows, setlocale(category, "") looks at the system settings, + not at the environment variables. Also, when an encoding suffix such + as ".65001" or ".54936" is specified, it succeeds but sets the LC_CTYPE + category of the locale to "C". */ + if (setlocale (LC_ALL, getenv ("LC_ALL")) == NULL + || strcmp (setlocale (LC_CTYPE, NULL), "C") == 0) + return 1; +# else + if (setlocale (LC_ALL, "") == NULL) return 1; +# endif + /* Check whether nl_langinfo(CODESET) is nonempty and not "ASCII" or "646". + On Mac OS X 10.3.5 (Darwin 7.5) in the fr_FR locale, nl_langinfo(CODESET) + is empty, and the behaviour of Tcl 8.4 in this locale is not useful. + On OpenBSD 4.0, when an unsupported locale is specified, setlocale() + succeeds but then nl_langinfo(CODESET) is "646". In this situation, + some unit tests fail. + On MirBSD 10, when an unsupported locale is specified, setlocale() + succeeds but then nl_langinfo(CODESET) is "UTF-8". */ +# if HAVE_LANGINFO_CODESET + { + const char *cs = nl_langinfo (CODESET); + if (cs[0] == '\0' || strcmp (cs, "ASCII") == 0 || strcmp (cs, "646") == 0 + || strcmp (cs, "UTF-8") == 0) + return 1; + } +# endif +# ifdef __CYGWIN__ + /* On Cygwin, avoid locale names without encoding suffix, because the + locale_charset() function relies on the encoding suffix. Note that + LC_ALL is set on the command line. */ + if (strchr (getenv ("LC_ALL"), '.') == NULL) return 1; +# endif + /* Check whether in the abbreviation of the second month, the second + character (should be U+00E9: LATIN SMALL LETTER E WITH ACUTE) is only + one byte long. This excludes the UTF-8 encoding. */ + t.tm_year = 1975 - 1900; t.tm_mon = 2 - 1; t.tm_mday = 4; + if (strftime (buf, sizeof (buf), "%b", &t) < 3 || buf[2] != 'v') return 1; +# if !defined __BIONIC__ /* Bionic libc's 'struct lconv' is just a dummy. */ + /* Check whether the decimal separator is a comma. + On NetBSD 3.0 in the fr_FR.ISO8859-1 locale, localeconv()->decimal_point + are nl_langinfo(RADIXCHAR) are both ".". */ + if (localeconv () ->decimal_point[0] != ',') return 1; +# endif + return 0; +#endif +} + ]])]) + if AC_TRY_EVAL([ac_link]) && test -s conftest$ac_exeext; then + case "$host_os" in + # Handle native Windows specially, because there setlocale() interprets + # "ar" as "Arabic" or "Arabic_Saudi Arabia.1256", + # "fr" or "fra" as "French" or "French_France.1252", + # "ge"(!) or "deu"(!) as "German" or "German_Germany.1252", + # "ja" as "Japanese" or "Japanese_Japan.932", + # and similar. + mingw*) + # Test for the native Windows locale name. + if (LC_ALL=French_France.1252 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then + gt_cv_locale_fr=French_France.1252 + else + # None found. + gt_cv_locale_fr=none + fi + ;; + *) + # Setting LC_ALL is not enough. Need to set LC_TIME to empty, because + # otherwise on Mac OS X 10.3.5 the LC_TIME=C from the beginning of the + # configure script would override the LC_ALL setting. Likewise for + # LC_CTYPE, which is also set at the beginning of the configure script. + # Test for the usual locale name. + if (LC_ALL=fr_FR LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then + gt_cv_locale_fr=fr_FR + else + # Test for the locale name with explicit encoding suffix. + if (LC_ALL=fr_FR.ISO-8859-1 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then + gt_cv_locale_fr=fr_FR.ISO-8859-1 + else + # Test for the AIX, OSF/1, FreeBSD, NetBSD, OpenBSD locale name. + if (LC_ALL=fr_FR.ISO8859-1 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then + gt_cv_locale_fr=fr_FR.ISO8859-1 + else + # Test for the HP-UX locale name. + if (LC_ALL=fr_FR.iso88591 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then + gt_cv_locale_fr=fr_FR.iso88591 + else + # Test for the Solaris 7 locale name. + if (LC_ALL=fr LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then + gt_cv_locale_fr=fr + else + # None found. + gt_cv_locale_fr=none + fi + fi + fi + fi + fi + ;; + esac + fi + rm -fr conftest* + ]) + LOCALE_FR=$gt_cv_locale_fr + AC_SUBST([LOCALE_FR]) +]) + +dnl Determine the name of a french locale with UTF-8 encoding. +AC_DEFUN_ONCE([gt_LOCALE_FR_UTF8], +[ + AC_REQUIRE([AM_LANGINFO_CODESET]) + AC_CACHE_CHECK([for a french Unicode locale], [gt_cv_locale_fr_utf8], [ + AC_LANG_CONFTEST([AC_LANG_SOURCE([[ +#include +#include +#if HAVE_LANGINFO_CODESET +# include +#endif +#include +#include +struct tm t; +char buf[16]; +int main () { + /* On BeOS and Haiku, locales are not implemented in libc. Rather, libintl + imitates locale dependent behaviour by looking at the environment + variables, and all locales use the UTF-8 encoding. */ +#if !(defined __BEOS__ || defined __HAIKU__) + /* Check whether the given locale name is recognized by the system. */ +# if defined _WIN32 && !defined __CYGWIN__ + /* On native Windows, setlocale(category, "") looks at the system settings, + not at the environment variables. Also, when an encoding suffix such + as ".65001" or ".54936" is specified, it succeeds but sets the LC_CTYPE + category of the locale to "C". */ + if (setlocale (LC_ALL, getenv ("LC_ALL")) == NULL + || strcmp (setlocale (LC_CTYPE, NULL), "C") == 0) + return 1; +# else + if (setlocale (LC_ALL, "") == NULL) return 1; +# endif + /* Check whether nl_langinfo(CODESET) is nonempty and not "ASCII" or "646". + On Mac OS X 10.3.5 (Darwin 7.5) in the fr_FR locale, nl_langinfo(CODESET) + is empty, and the behaviour of Tcl 8.4 in this locale is not useful. + On OpenBSD 4.0, when an unsupported locale is specified, setlocale() + succeeds but then nl_langinfo(CODESET) is "646". In this situation, + some unit tests fail. */ +# if HAVE_LANGINFO_CODESET + { + const char *cs = nl_langinfo (CODESET); + if (cs[0] == '\0' || strcmp (cs, "ASCII") == 0 || strcmp (cs, "646") == 0) + return 1; + } +# endif +# ifdef __CYGWIN__ + /* On Cygwin, avoid locale names without encoding suffix, because the + locale_charset() function relies on the encoding suffix. Note that + LC_ALL is set on the command line. */ + if (strchr (getenv ("LC_ALL"), '.') == NULL) return 1; +# endif + /* Check whether in the abbreviation of the second month, the second + character (should be U+00E9: LATIN SMALL LETTER E WITH ACUTE) is + two bytes long, with UTF-8 encoding. */ + t.tm_year = 1975 - 1900; t.tm_mon = 2 - 1; t.tm_mday = 4; + if (strftime (buf, sizeof (buf), "%b", &t) < 4 + || buf[1] != (char) 0xc3 || buf[2] != (char) 0xa9 || buf[3] != 'v') + return 1; +#endif +#if !defined __BIONIC__ /* Bionic libc's 'struct lconv' is just a dummy. */ + /* Check whether the decimal separator is a comma. + On NetBSD 3.0 in the fr_FR.ISO8859-1 locale, localeconv()->decimal_point + are nl_langinfo(RADIXCHAR) are both ".". */ + if (localeconv () ->decimal_point[0] != ',') return 1; +#endif + return 0; +} + ]])]) + if AC_TRY_EVAL([ac_link]) && test -s conftest$ac_exeext; then + case "$host_os" in + # Handle native Windows specially, because there setlocale() interprets + # "ar" as "Arabic" or "Arabic_Saudi Arabia.1256", + # "fr" or "fra" as "French" or "French_France.1252", + # "ge"(!) or "deu"(!) as "German" or "German_Germany.1252", + # "ja" as "Japanese" or "Japanese_Japan.932", + # and similar. + mingw*) + # Test for the hypothetical native Windows locale name. + if (LC_ALL=French_France.65001 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then + gt_cv_locale_fr_utf8=French_France.65001 + else + # None found. + gt_cv_locale_fr_utf8=none + fi + ;; + *) + # Setting LC_ALL is not enough. Need to set LC_TIME to empty, because + # otherwise on Mac OS X 10.3.5 the LC_TIME=C from the beginning of the + # configure script would override the LC_ALL setting. Likewise for + # LC_CTYPE, which is also set at the beginning of the configure script. + # Test for the usual locale name. + if (LC_ALL=fr_FR LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then + gt_cv_locale_fr_utf8=fr_FR + else + # Test for the locale name with explicit encoding suffix. + if (LC_ALL=fr_FR.UTF-8 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then + gt_cv_locale_fr_utf8=fr_FR.UTF-8 + else + # Test for the Solaris 7 locale name. + if (LC_ALL=fr.UTF-8 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then + gt_cv_locale_fr_utf8=fr.UTF-8 + else + # None found. + gt_cv_locale_fr_utf8=none + fi + fi + fi + ;; + esac + fi + rm -fr conftest* + ]) + LOCALE_FR_UTF8=$gt_cv_locale_fr_utf8 + AC_SUBST([LOCALE_FR_UTF8]) +]) diff --git a/m4/manywarnings.m4 b/m4/manywarnings.m4 index 2fac86e20be..13db996516d 100644 --- a/m4/manywarnings.m4 +++ b/m4/manywarnings.m4 @@ -46,8 +46,7 @@ AC_DEFUN([gl_MANYWARN_ALL_GCC(C)], dnl First, check for some issues that only occur when combining multiple dnl gcc warning categories. AC_REQUIRE([AC_PROG_CC]) - if test -n "$GCC"; then - + AS_IF([test -n "$GCC"], [ dnl Check if -Wextra -Werror -Wno-missing-field-initializers is supported dnl with the current $CC $CFLAGS $CPPFLAGS. AC_CACHE_CHECK([whether -Wno-missing-field-initializers is supported], @@ -61,7 +60,7 @@ AC_DEFUN([gl_MANYWARN_ALL_GCC(C)], CFLAGS="$gl_save_CFLAGS" ]) - if test "$gl_cv_cc_nomfi_supported" = yes; then + AS_IF([test "$gl_cv_cc_nomfi_supported" = yes], [ dnl Now check whether -Wno-missing-field-initializers is needed dnl for the { 0, } construct. AC_CACHE_CHECK([whether -Wno-missing-field-initializers is needed], @@ -82,7 +81,7 @@ AC_DEFUN([gl_MANYWARN_ALL_GCC(C)], [gl_cv_cc_nomfi_needed=yes]) CFLAGS="$gl_save_CFLAGS" ]) - fi + ]) dnl Next, check if -Werror -Wuninitialized is useful with the dnl user's choice of $CFLAGS; some versions of gcc warn that it @@ -97,8 +96,7 @@ AC_DEFUN([gl_MANYWARN_ALL_GCC(C)], [gl_cv_cc_uninitialized_supported=no]) CFLAGS="$gl_save_CFLAGS" ]) - - fi + ]) # List all gcc warning categories. # To compare this list to your installed GCC's, run this Bash command: @@ -109,7 +107,7 @@ AC_DEFUN([gl_MANYWARN_ALL_GCC(C)], # <(LC_ALL=C gcc --help=warnings | sed -n 's/^ \(-[^ ]*\) .*/\1/p' | sort) $1= - for gl_manywarn_item in -fanalyzer -fno-common \ + for gl_manywarn_item in -fanalyzer -fstrict-flex-arrays \ -Wall \ -Warith-conversion \ -Wbad-function-cast \ @@ -137,6 +135,7 @@ AC_DEFUN([gl_MANYWARN_ALL_GCC(C)], -Wpointer-arith \ -Wshadow \ -Wstack-protector \ + -Wstrict-flex-arrays \ -Wstrict-overflow \ -Wstrict-prototypes \ -Wsuggest-attribute=cold \ @@ -178,14 +177,19 @@ AC_DEFUN([gl_MANYWARN_ALL_GCC(C)], gl_AS_VAR_APPEND([$1], [' -Wvla-larger-than=4031']) # These are needed for older GCC versions. - if test -n "$GCC"; then - case `($CC --version) 2>/dev/null` in + if test -n "$GCC" && gl_gcc_version=`($CC --version) 2>/dev/null`; then + case $gl_gcc_version in 'gcc (GCC) '[[0-3]].* | \ 'gcc (GCC) '4.[[0-7]].*) gl_AS_VAR_APPEND([$1], [' -fdiagnostics-show-option']) gl_AS_VAR_APPEND([$1], [' -funit-at-a-time']) ;; esac + case $gl_gcc_version in + 'gcc (GCC) '[[0-9]].*) + gl_AS_VAR_APPEND([$1], [' -fno-common']) + ;; + esac fi # Disable specific options as needed. diff --git a/m4/musl.m4 b/m4/musl.m4 new file mode 100644 index 00000000000..e28a3fed677 --- /dev/null +++ b/m4/musl.m4 @@ -0,0 +1,20 @@ +# musl.m4 serial 4 +dnl Copyright (C) 2019-2023 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. + +# Test for musl libc, despite the musl libc authors don't like it +# +# . +# From Bruno Haible. + +AC_DEFUN_ONCE([gl_MUSL_LIBC], +[ + AC_REQUIRE([AC_CANONICAL_HOST]) + case "$host_os" in + *-musl* | midipix*) + AC_DEFINE([MUSL_LIBC], [1], [Define to 1 on musl libc.]) + ;; + esac +]) diff --git a/m4/regex.m4 b/m4/regex.m4 index c89a1432a7b..7acadc48343 100644 --- a/m4/regex.m4 +++ b/m4/regex.m4 @@ -1,4 +1,4 @@ -# serial 73 +# serial 74 # Copyright (C) 1996-2001, 2003-2023 Free Software Foundation, Inc. # @@ -15,7 +15,7 @@ AC_DEFUN([gl_REGEX], [ AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles AC_ARG_WITH([included-regex], - [AS_HELP_STRING([--without-included-regex], + [AS_HELP_STRING([[--without-included-regex]], [don't compile regex; this is the default on systems with recent-enough versions of the GNU C Library (use with caution on other systems).])]) diff --git a/m4/stdalign.m4 b/m4/stdalign.m4 index f49cf8ec162..1a236d66d2f 100644 --- a/m4/stdalign.m4 +++ b/m4/stdalign.m4 @@ -151,22 +151,22 @@ AC_DEFUN([gl_ALIGNASOF], - alignas (TYPE) is equivalent to alignas (alignof (TYPE)). */ -# if !HAVE_STDALIGN_H -# if !defined __STDC_VERSION__ || __STDC_VERSION__ < 201112 -# if defined __cplusplus && (201103 <= __cplusplus || defined _MSC_VER) -# define _Alignas(a) alignas (a) -# elif (!defined __attribute__ \ - && ((defined __APPLE__ && defined __MACH__ \ - ? 4 < __GNUC__ + (1 <= __GNUC_MINOR__) \ - : __GNUC__ && !defined __ibmxl__) \ - || (4 <= __clang_major__) \ - || (__ia64 && (61200 <= __HP_cc || 61200 <= __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 +# if !defined __STDC_VERSION__ || __STDC_VERSION__ < 201112 +# if defined __cplusplus && (201103 <= __cplusplus || defined _MSC_VER) +# define _Alignas(a) alignas (a) +# elif (!defined __attribute__ \ + && ((defined __APPLE__ && defined __MACH__ \ + ? 4 < __GNUC__ + (1 <= __GNUC_MINOR__) \ + : __GNUC__ && !defined __ibmxl__) \ + || (4 <= __clang_major__) \ + || (__ia64 && (61200 <= __HP_cc || 61200 <= __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 !HAVE_STDALIGN_H # if ((defined _Alignas \ && !(defined __cplusplus \ && (201103 <= __cplusplus || defined _MSC_VER))) \ diff --git a/m4/stddef_h.m4 b/m4/stddef_h.m4 index a2322ebb7ee..aa012219fcd 100644 --- a/m4/stddef_h.m4 +++ b/m4/stddef_h.m4 @@ -1,4 +1,4 @@ -# stddef_h.m4 serial 13 +# stddef_h.m4 serial 14 dnl Copyright (C) 2009-2023 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -68,6 +68,21 @@ AC_DEFUN_ONCE([gl_STDDEF_H], GL_GENERATE_STDDEF_H=true fi + AC_CACHE_CHECK([for unreachable], + [gl_cv_func_unreachable], + [AC_LINK_IFELSE( + [AC_LANG_PROGRAM( + [[#include + ]], + [[unreachable (); + ]])], + [gl_cv_func_unreachable=yes], + [gl_cv_func_unreachable=no]) + ]) + if test $gl_cv_func_unreachable = no; then + GL_GENERATE_STDDEF_H=true + fi + if $GL_GENERATE_STDDEF_H; then gl_NEXT_HEADERS([stddef.h]) fi diff --git a/m4/stdio_h.m4 b/m4/stdio_h.m4 index 07569961f8b..dbfa0d5d61b 100644 --- a/m4/stdio_h.m4 +++ b/m4/stdio_h.m4 @@ -1,12 +1,22 @@ -# stdio_h.m4 serial 61 +# stdio_h.m4 serial 63 dnl Copyright (C) 2007-2023 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_ONCE([gl_STDIO_H], +AC_DEFUN([gl_STDIO_H_EARLY], [ - AC_REQUIRE([gl_STDIO_H_DEFAULTS]) + dnl Defining __USE_MINGW_ANSI_STDIO to 1 must be done early, because + dnl the results of several configure tests depend on it: The tests + dnl - checking whether snprintf returns a byte count as in C99... + dnl - checking whether snprintf truncates the result as in C99... + dnl - checking whether printf supports the 'F' directive... + dnl - checking whether printf supports the grouping flag... + dnl - checking whether printf supports the zero flag correctly... + dnl - checking whether printf supports infinite 'double' arguments... + dnl - checking whether printf supports large precisions... + dnl report 'yes' if __USE_MINGW_ANSI_STDIO is 1 but 'no' if + dnl __USE_MINGW_ANSI_STDIO is not set. AH_VERBATIM([MINGW_ANSI_STDIO], [/* Use GNU style printf and scanf. */ #ifndef __USE_MINGW_ANSI_STDIO @@ -14,6 +24,11 @@ AC_DEFUN_ONCE([gl_STDIO_H], #endif ]) AC_DEFINE([__USE_MINGW_ANSI_STDIO]) +]) + +AC_DEFUN_ONCE([gl_STDIO_H], +[ + AC_REQUIRE([gl_STDIO_H_DEFAULTS]) gl_NEXT_HEADERS([stdio.h]) dnl Determine whether __USE_MINGW_ANSI_STDIO makes printf and @@ -40,6 +55,9 @@ AC_DEFUN_ONCE([gl_STDIO_H], attribute "__gnu_printf__" instead of "__printf__"]) fi + dnl For defining _PRINTF_NAN_LEN_MAX. + gl_MUSL_LIBC + dnl This ifdef is an optimization, to avoid performing a configure check whose dnl result is not used. But it does not make the test of dnl GNULIB_STDIO_H_NONBLOCKING or GNULIB_NONBLOCKING redundant. diff --git a/m4/stdlib_h.m4 b/m4/stdlib_h.m4 index 249ef657224..f47c1eb37b3 100644 --- a/m4/stdlib_h.m4 +++ b/m4/stdlib_h.m4 @@ -1,4 +1,4 @@ -# stdlib_h.m4 serial 71 +# stdlib_h.m4 serial 75 dnl Copyright (C) 2007-2023 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -24,14 +24,57 @@ AC_DEFUN_ONCE([gl_STDLIB_H], #endif ]], [_Exit aligned_alloc atoll canonicalize_file_name free getloadavg getprogname getsubopt grantpt - initstate initstate_r mbtowc mkdtemp mkostemp mkostemps mkstemp mkstemps - posix_memalign posix_openpt ptsname ptsname_r qsort_r + initstate initstate_r mbstowcs mbtowc mkdtemp mkostemp mkostemps mkstemp + mkstemps posix_memalign posix_openpt ptsname ptsname_r qsort_r random random_r reallocarray realpath rpmatch secure_getenv setenv setstate setstate_r srandom srandom_r strtod strtol strtold strtoll strtoul strtoull unlockpt unsetenv]) AC_REQUIRE([AC_C_RESTRICT]) + dnl Test whether MB_CUR_MAX needs to be overridden. + dnl On Solaris 10, in UTF-8 locales, its value is 3 but needs to be 4. + dnl Fortunately, we can do this because on this platform MB_LEN_MAX is 5. + AC_REQUIRE([AC_CANONICAL_HOST]) + AC_REQUIRE([gt_LOCALE_FR_UTF8]) + AC_CACHE_CHECK([whether MB_CUR_MAX is correct], + [gl_cv_macro_MB_CUR_MAX_good], + [ + dnl Initial guess, used when cross-compiling or when no suitable locale + dnl is present. +changequote(,)dnl + case "$host_os" in + # Guess no on Solaris. + solaris*) gl_cv_macro_MB_CUR_MAX_good="guessing no" ;; + # Guess yes otherwise. + *) gl_cv_macro_MB_CUR_MAX_good="guessing yes" ;; + esac +changequote([,])dnl + if test $LOCALE_FR_UTF8 != none; then + AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ +#include +#include +int main () +{ + int result = 0; + if (setlocale (LC_ALL, "$LOCALE_FR_UTF8") != NULL) + { + if (MB_CUR_MAX < 4) + result |= 1; + } + return result; +}]])], + [gl_cv_macro_MB_CUR_MAX_good=yes], + [gl_cv_macro_MB_CUR_MAX_good=no], + [:]) + fi + ]) + case "$gl_cv_macro_MB_CUR_MAX_good" in + *yes) ;; + *) REPLACE_MB_CUR_MAX=1 ;; + esac + AC_CHECK_DECLS_ONCE([ecvt]) if test $ac_cv_have_decl_ecvt = no; then HAVE_DECL_ECVT=0 @@ -78,6 +121,7 @@ AC_DEFUN([gl_STDLIB_H_REQUIRE_DEFAULTS], gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GRANTPT]) gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MALLOC_GNU]) gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MALLOC_POSIX]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBSTOWCS]) gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBTOWC]) gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MKDTEMP]) gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MKOSTEMP]) @@ -131,6 +175,7 @@ AC_DEFUN([gl_STDLIB_H_DEFAULTS], HAVE_DECL_FCVT=1; AC_SUBST([HAVE_DECL_FCVT]) HAVE_DECL_GCVT=1; AC_SUBST([HAVE_DECL_GCVT]) HAVE_DECL_GETLOADAVG=1; AC_SUBST([HAVE_DECL_GETLOADAVG]) + HAVE_DECL_PROGRAM_INVOCATION_NAME=1; AC_SUBST([HAVE_DECL_PROGRAM_INVOCATION_NAME]) HAVE_GETPROGNAME=1; AC_SUBST([HAVE_GETPROGNAME]) HAVE_GETSUBOPT=1; AC_SUBST([HAVE_GETSUBOPT]) HAVE_GRANTPT=1; AC_SUBST([HAVE_GRANTPT]) @@ -180,6 +225,8 @@ AC_DEFUN([gl_STDLIB_H_DEFAULTS], REPLACE_INITSTATE=0; AC_SUBST([REPLACE_INITSTATE]) REPLACE_MALLOC_FOR_MALLOC_GNU=0; AC_SUBST([REPLACE_MALLOC_FOR_MALLOC_GNU]) REPLACE_MALLOC_FOR_MALLOC_POSIX=0; AC_SUBST([REPLACE_MALLOC_FOR_MALLOC_POSIX]) + REPLACE_MB_CUR_MAX=0; AC_SUBST([REPLACE_MB_CUR_MAX]) + REPLACE_MBSTOWCS=0; AC_SUBST([REPLACE_MBSTOWCS]) REPLACE_MBTOWC=0; AC_SUBST([REPLACE_MBTOWC]) REPLACE_MKOSTEMP=0; AC_SUBST([REPLACE_MKOSTEMP]) REPLACE_MKOSTEMPS=0; AC_SUBST([REPLACE_MKOSTEMPS]) diff --git a/m4/strtoll.m4 b/m4/strtoll.m4 index ede630c6061..ec09609cd42 100644 --- a/m4/strtoll.m4 +++ b/m4/strtoll.m4 @@ -1,4 +1,4 @@ -# strtoll.m4 serial 9 +# strtoll.m4 serial 10 dnl Copyright (C) 2002, 2004, 2006, 2008-2023 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -24,15 +24,26 @@ AC_DEFUN([gl_FUNC_STRTOLL], if (term != input + 1) result |= 1; } + /* This test fails on pre-C23 platforms. */ + { + const char input[] = "0b1"; + (void) strtoll (input, &term, 2); + if (term != input + 3) + result |= 2; + } return result; ]]) ], [gl_cv_func_strtoll_works=yes], [gl_cv_func_strtoll_works=no], [case "$host_os" in - # Guess no on native Windows. - mingw*) gl_cv_func_strtoll_works="guessing no" ;; - *) gl_cv_func_strtoll_works="$gl_cross_guess_normal" ;; + # Guess no on native Windows. + mingw*) gl_cv_func_strtoll_works="guessing no" ;; + # Guess no on glibc systems. + *-gnu* | gnu*) gl_cv_func_strtoll_works="guessing no" ;; + # Guess no on musl systems. + *-musl* | midipix*) gl_cv_func_strtoll_works="guessing no" ;; + *) gl_cv_func_strtoll_works="$gl_cross_guess_normal" ;; esac ]) ]) diff --git a/m4/xattr.m4 b/m4/xattr.m4 index 0e179cc0d1d..70bf0db4419 100644 --- a/m4/xattr.m4 +++ b/m4/xattr.m4 @@ -1,5 +1,5 @@ # xattr.m4 - check for Extended Attributes (Linux) -# serial 6 +# serial 7 # Copyright (C) 2003-2023 Free Software Foundation, Inc. # This file is free software; the Free Software Foundation @@ -9,7 +9,7 @@ AC_DEFUN([gl_FUNC_XATTR], [ AC_ARG_ENABLE([xattr], - AS_HELP_STRING([--disable-xattr], + AS_HELP_STRING([[--disable-xattr]], [do not support extended attributes]), [use_xattr=$enableval], [use_xattr=yes])