mirror of
https://github.com/monitoring-plugins/monitoring-plugins.git
synced 2026-04-23 07:07:00 -04:00
Merge branch 'master' into netsnmp595-fix
This commit is contained in:
commit
1e108210b6
542 changed files with 38136 additions and 3816 deletions
4
.github/monitoring-plugins.spec
vendored
4
.github/monitoring-plugins.spec
vendored
|
|
@ -922,3 +922,7 @@ Provides check_wave of the Monitoring Plugins.
|
|||
|
||||
%files wave
|
||||
%{plugindir}/check_wave
|
||||
|
||||
%changelog
|
||||
* Wed Oct 20 2011 John Doe <jdoe@example.com> 0.8.18.1-0.1
|
||||
- Initial RPM release
|
||||
|
|
|
|||
1042
gl/Makefile.am
1042
gl/Makefile.am
File diff suppressed because it is too large
Load diff
|
|
@ -1,5 +1,5 @@
|
|||
/* A C macro for declaring that a function does not return.
|
||||
Copyright (C) 2011-2024 Free Software Foundation, Inc.
|
||||
Copyright (C) 2011-2025 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU Lesser General Public License as published
|
||||
|
|
@ -14,33 +14,26 @@
|
|||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
||||
|
||||
/* The _Noreturn keyword of C11.
|
||||
Do not use [[noreturn]], because with it the syntax
|
||||
extern _Noreturn void func (...);
|
||||
would not be valid; such a declaration would be valid only with 'extern'
|
||||
and '_Noreturn' swapped, or without the 'extern' keyword. However, some
|
||||
AIX system header files and several gnulib header files use precisely
|
||||
this syntax with 'extern'. So even though C23 deprecates _Noreturn,
|
||||
it is currently more portable to prefer it to [[noreturn]].
|
||||
|
||||
Also, do not try to work around LLVM bug 59792 (clang 15 or earlier).
|
||||
This rare bug can be worked around by compiling with 'clang -D_Noreturn=',
|
||||
though the workaround may generate many false-alarm warnings. */
|
||||
#ifndef _Noreturn
|
||||
# if (defined __cplusplus \
|
||||
&& ((201103 <= __cplusplus && !(__GNUC__ == 4 && __GNUC_MINOR__ == 7)) \
|
||||
|| (defined _MSC_VER && 1900 <= _MSC_VER)) \
|
||||
&& 0)
|
||||
/* [[noreturn]] is not practically usable, because with it the syntax
|
||||
extern _Noreturn void func (...);
|
||||
would not be valid; such a declaration would only be valid with 'extern'
|
||||
and '_Noreturn' swapped, or without the 'extern' keyword. However, some
|
||||
AIX system header files and several gnulib header files use precisely
|
||||
this syntax with 'extern'. */
|
||||
# define _Noreturn [[noreturn]]
|
||||
# elif (defined __clang__ && __clang_major__ < 16 \
|
||||
&& defined _GL_WORK_AROUND_LLVM_BUG_59792)
|
||||
/* Compile with -D_GL_WORK_AROUND_LLVM_BUG_59792 to work around
|
||||
that rare LLVM bug, though you may get many false-alarm warnings. */
|
||||
# define _Noreturn
|
||||
# elif ((!defined __cplusplus || defined __clang__) \
|
||||
&& (201112 <= (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) \
|
||||
|| (!defined __STRICT_ANSI__ \
|
||||
&& (4 < __GNUC__ + (7 <= __GNUC_MINOR__) \
|
||||
|| (defined __apple_build_version__ \
|
||||
? 6000000 <= __apple_build_version__ \
|
||||
: 3 < __clang_major__ + (5 <= __clang_minor__))))))
|
||||
# if ((!defined __cplusplus || defined __clang__) \
|
||||
&& (201112 <= (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0)))
|
||||
/* _Noreturn works as-is. */
|
||||
# elif (2 < __GNUC__ + (8 <= __GNUC_MINOR__) || defined __clang__ \
|
||||
|| 0x5110 <= __SUNPRO_C)
|
||||
/* Prefer __attribute__ ((__noreturn__)) to plain _Noreturn even if the
|
||||
latter works, as 'gcc -std=gnu99 -Wpedantic' warns about _Noreturn. */
|
||||
# define _Noreturn __attribute__ ((__noreturn__))
|
||||
# elif 1200 <= (defined _MSC_VER ? _MSC_VER : 0)
|
||||
# define _Noreturn __declspec (noreturn)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* af_alg.c - Compute message digests from file streams and buffers.
|
||||
Copyright (C) 2018-2024 Free Software Foundation, Inc.
|
||||
Copyright (C) 2018-2025 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
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* af_alg.h - Compute message digests from file streams and buffers.
|
||||
Copyright (C) 2018-2024 Free Software Foundation, Inc.
|
||||
Copyright (C) 2018-2025 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
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/* Memory allocation on the stack.
|
||||
|
||||
Copyright (C) 1995, 1999, 2001-2004, 2006-2024 Free Software Foundation,
|
||||
Copyright (C) 1995, 1999, 2001-2004, 2006-2025 Free Software Foundation,
|
||||
Inc.
|
||||
|
||||
This file is free software: you can redistribute it and/or modify
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* A C macro for declaring that specific arguments must not be NULL.
|
||||
Copyright (C) 2009-2024 Free Software Foundation, Inc.
|
||||
Copyright (C) 2009-2025 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU Lesser General Public License as published
|
||||
|
|
|
|||
21
gl/arpa_inet.c
Normal file
21
gl/arpa_inet.c
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
/* Inline functions for <arpa/inet.h>.
|
||||
|
||||
Copyright (C) 2024-2025 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 <https://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#define _GL_ARPA_INET_INLINE _GL_EXTERN_INLINE
|
||||
#include <arpa/inet.h>
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
/* A GNU-like <arpa/inet.h>.
|
||||
|
||||
Copyright (C) 2005-2006, 2008-2024 Free Software Foundation, Inc.
|
||||
Copyright (C) 2005-2006, 2008-2025 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
|
||||
|
|
@ -60,6 +60,53 @@
|
|||
# include <ws2tcpip.h>
|
||||
#endif
|
||||
|
||||
#if !(@HAVE_DECL_HTONL@ || @HAVE_DECL_HTONS@ || @HAVE_DECL_NTOHL@ || @HAVE_DECL_NTOHS@)
|
||||
# include <endian.h>
|
||||
#endif
|
||||
|
||||
_GL_INLINE_HEADER_BEGIN
|
||||
#ifndef _GL_ARPA_INET_INLINE
|
||||
# define _GL_ARPA_INET_INLINE _GL_INLINE
|
||||
#endif
|
||||
|
||||
|
||||
/* Host to network byte order. */
|
||||
|
||||
#if !@HAVE_DECL_HTONS@
|
||||
_GL_ARPA_INET_INLINE uint16_t
|
||||
htons (uint16_t value)
|
||||
{
|
||||
return htobe16 (value);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !@HAVE_DECL_HTONL@
|
||||
_GL_ARPA_INET_INLINE uint32_t
|
||||
htonl (uint32_t value)
|
||||
{
|
||||
return htobe32 (value);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Network to host byte order. */
|
||||
|
||||
#if !@HAVE_DECL_NTOHS@
|
||||
_GL_ARPA_INET_INLINE uint16_t
|
||||
ntohs (uint16_t value)
|
||||
{
|
||||
return htobe16 (value);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !@HAVE_DECL_NTOHL@
|
||||
_GL_ARPA_INET_INLINE uint32_t
|
||||
ntohl (uint32_t value)
|
||||
{
|
||||
return htobe32 (value);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
|
||||
|
||||
/* The definition of _GL_ARG_NONNULL is copied here. */
|
||||
|
|
@ -90,7 +137,7 @@
|
|||
# endif
|
||||
_GL_FUNCDECL_RPL (inet_ntop, const char *,
|
||||
(int af, const void *restrict src,
|
||||
char *restrict dst, socklen_t cnt)
|
||||
char *restrict dst, socklen_t cnt),
|
||||
_GL_ARG_NONNULL ((2, 3)));
|
||||
_GL_CXXALIAS_RPL (inet_ntop, const char *,
|
||||
(int af, const void *restrict src,
|
||||
|
|
@ -99,7 +146,7 @@ _GL_CXXALIAS_RPL (inet_ntop, const char *,
|
|||
# if !@HAVE_DECL_INET_NTOP@
|
||||
_GL_FUNCDECL_SYS (inet_ntop, const char *,
|
||||
(int af, const void *restrict src,
|
||||
char *restrict dst, socklen_t cnt)
|
||||
char *restrict dst, socklen_t cnt),
|
||||
_GL_ARG_NONNULL ((2, 3)));
|
||||
# endif
|
||||
/* Need to cast, because on NonStop Kernel, the fourth parameter is
|
||||
|
|
@ -126,14 +173,14 @@ _GL_WARN_ON_USE (inet_ntop, "inet_ntop is unportable - "
|
|||
# define inet_pton rpl_inet_pton
|
||||
# endif
|
||||
_GL_FUNCDECL_RPL (inet_pton, int,
|
||||
(int af, const char *restrict src, void *restrict dst)
|
||||
(int af, const char *restrict src, void *restrict dst),
|
||||
_GL_ARG_NONNULL ((2, 3)));
|
||||
_GL_CXXALIAS_RPL (inet_pton, int,
|
||||
(int af, const char *restrict src, void *restrict dst));
|
||||
# else
|
||||
# if !@HAVE_DECL_INET_PTON@
|
||||
_GL_FUNCDECL_SYS (inet_pton, int,
|
||||
(int af, const char *restrict src, void *restrict dst)
|
||||
(int af, const char *restrict src, void *restrict dst),
|
||||
_GL_ARG_NONNULL ((2, 3)));
|
||||
# endif
|
||||
_GL_CXXALIAS_SYS (inet_pton, int,
|
||||
|
|
@ -150,6 +197,7 @@ _GL_WARN_ON_USE (inet_pton, "inet_pton is unportable - "
|
|||
# endif
|
||||
#endif
|
||||
|
||||
_GL_INLINE_HEADER_END
|
||||
|
||||
#endif /* _@GUARD_PREFIX@_ARPA_INET_H */
|
||||
#endif /* _@GUARD_PREFIX@_ARPA_INET_H */
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* Formatted output to strings.
|
||||
Copyright (C) 1999, 2002, 2006, 2009-2024 Free Software Foundation, Inc.
|
||||
Copyright (C) 1999, 2002, 2006, 2009-2025 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
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* Formatted output to strings.
|
||||
Copyright (C) 1999, 2002, 2006-2007, 2009-2024 Free Software Foundation,
|
||||
Copyright (C) 1999, 2002, 2006-2007, 2009-2025 Free Software Foundation,
|
||||
Inc.
|
||||
|
||||
This file is free software: you can redistribute it and/or modify
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* Substitute for and wrapper around <assert.h>
|
||||
Copyright (C) 2011-2024 Free Software Foundation, Inc.
|
||||
Copyright (C) 2011-2025 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
|
||||
|
|
|
|||
132
gl/attribute.h
132
gl/attribute.h
|
|
@ -1,6 +1,6 @@
|
|||
/* ATTRIBUTE_* macros for using attributes in GCC and similar compilers
|
||||
|
||||
Copyright 2020-2024 Free Software Foundation, Inc.
|
||||
Copyright 2020-2025 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
|
||||
|
|
@ -20,12 +20,50 @@
|
|||
/* Provide public ATTRIBUTE_* names for the private _GL_ATTRIBUTE_*
|
||||
macros used within Gnulib. */
|
||||
|
||||
/* These attributes can be placed in two ways:
|
||||
- At the start of a declaration (i.e. even before storage-class
|
||||
specifiers!); then they apply to all entities that are declared
|
||||
by the declaration.
|
||||
- Immediately after the name of an entity being declared by the
|
||||
declaration; then they apply to that entity only. */
|
||||
/* The placement of these attributes depends on the kind of declaration
|
||||
and, in some cases, also on the programming language (C vs. C++).
|
||||
|
||||
In function declarations and function definitions:
|
||||
|
||||
* ATTRIBUTE_NOTHROW must come after the parameter list.
|
||||
|
||||
* The macros
|
||||
ATTRIBUTE_CONST
|
||||
ATTRIBUTE_PURE
|
||||
DEPRECATED
|
||||
MAYBE_UNUSED
|
||||
NODISCARD
|
||||
REPRODUCIBLE
|
||||
UNSEQUENCED
|
||||
must come before the return type, and more precisely:
|
||||
- In a function declaration/definition without a storage-class
|
||||
specifier: at the beginning of the declaration/definition.
|
||||
- In a function declaration/definition with a storage-class
|
||||
specifier:
|
||||
- In C: before the storage-class specifier.
|
||||
- In C++: between the storage-class specifier and the return type.
|
||||
|
||||
* The other macros can be placed
|
||||
- Either
|
||||
- In a function declaration/definition without a storage-class
|
||||
specifier: at the beginning of the declaration/definition.
|
||||
- In a function declaration/definition with a storage-class
|
||||
specifier: between the storage-class specifier and the return
|
||||
type.
|
||||
- Or, in a function declaration:
|
||||
after the parameter list,
|
||||
∙ but after ATTRIBUTE_NOTHROW if present.
|
||||
|
||||
In other declarations, such as variable declarations:
|
||||
|
||||
* Either
|
||||
- In C: before the storage-class specifier.
|
||||
- In C++: between the storage-class specifier and the return type.
|
||||
Then they apply to all entities that are declared by the declaration.
|
||||
|
||||
* Or immediately after the name of an entity being declared by the
|
||||
declaration. Then they apply to that entity only.
|
||||
*/
|
||||
|
||||
#ifndef _GL_ATTRIBUTE_H
|
||||
#define _GL_ATTRIBUTE_H
|
||||
|
|
@ -48,9 +86,10 @@
|
|||
_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. */
|
||||
_GL_ATTRIBUTE_NONNULL_IF_NONZERO, _GL_ATTRIBUTE_NONSTRING,
|
||||
_GL_ATTRIBUTE_NOTHROW, _GL_ATTRIBUTE_PACKED, _GL_ATTRIBUTE_PURE,
|
||||
_GL_ATTRIBUTE_REPRODUCIBLE, _GL_ATTRIBUTE_RETURNS_NONNULL,
|
||||
_GL_ATTRIBUTE_SENTINEL, _GL_ATTRIBUTE_UNSEQUENCED. */
|
||||
#if !_GL_CONFIG_H_INCLUDED
|
||||
#error "Please include config.h first."
|
||||
#endif
|
||||
|
|
@ -88,7 +127,7 @@
|
|||
is the size of the returned memory block.
|
||||
ATTRIBUTE_ALLOC_SIZE ((M, N)) - Multiply the Mth and Nth arguments
|
||||
to determine the size of the returned memory block. */
|
||||
/* Applies to: function, pointer to function, function types. */
|
||||
/* Applies to: functions, pointer to functions, function types. */
|
||||
#define ATTRIBUTE_ALLOC_SIZE(args) _GL_ATTRIBUTE_ALLOC_SIZE (args)
|
||||
|
||||
/* ATTRIBUTE_DEALLOC (F, I) declares that the function returns pointers
|
||||
|
|
@ -132,6 +171,12 @@
|
|||
/* Applies to: functions. */
|
||||
#define ATTRIBUTE_NONNULL(args) _GL_ATTRIBUTE_NONNULL (args)
|
||||
|
||||
/* ATTRIBUTE_NONNULL_IF_NONZERO (NP, NI) - Argument NP (a pointer)
|
||||
must not be NULL if the argument NI (an integer) is != 0. */
|
||||
/* Applies to: functions. */
|
||||
#define ATTRIBUTE_NONNULL_IF_NONZERO(np, ni) _GL_ATTRIBUTE_NONNULL_IF_NONZERO (np, ni)
|
||||
|
||||
|
||||
/* The function's return value is a non-NULL pointer. */
|
||||
/* Applies to: functions. */
|
||||
#define ATTRIBUTE_RETURNS_NONNULL _GL_ATTRIBUTE_RETURNS_NONNULL
|
||||
|
|
@ -170,7 +215,7 @@
|
|||
/* Attributes regarding debugging information emitted by the compiler. */
|
||||
|
||||
/* Omit the function from stack traces when debugging. */
|
||||
/* Applies to: function. */
|
||||
/* Applies to: functions. */
|
||||
#define ATTRIBUTE_ARTIFICIAL _GL_ATTRIBUTE_ARTIFICIAL
|
||||
|
||||
/* Make the entity visible to debuggers etc., even with '-fwhole-program'. */
|
||||
|
|
@ -192,25 +237,68 @@
|
|||
|
||||
/* Always inline the function, and report an error if the compiler
|
||||
cannot inline. */
|
||||
/* Applies to: function. */
|
||||
/* Applies to: functions. */
|
||||
#define ATTRIBUTE_ALWAYS_INLINE _GL_ATTRIBUTE_ALWAYS_INLINE
|
||||
|
||||
/* It is OK for a compiler to omit duplicate calls with the same arguments.
|
||||
/* It is OK for a compiler to move calls to the function and to omit
|
||||
calls to the function if another call has the same arguments or the
|
||||
result is not used.
|
||||
This attribute is safe for a function that neither depends on
|
||||
nor affects observable state, and always returns exactly once -
|
||||
e.g., does not loop forever, and does not call longjmp.
|
||||
(This attribute is stricter than ATTRIBUTE_PURE.) */
|
||||
nor affects state, and always returns exactly once -
|
||||
e.g., does not raise an exception, call longjmp, or loop forever.
|
||||
(This attribute is stricter than ATTRIBUTE_PURE because the
|
||||
function cannot observe state. It is stricter than UNSEQUENCED
|
||||
because the function must return exactly once and cannot depend on
|
||||
state addressed by its arguments.) */
|
||||
/* Applies to: functions. */
|
||||
#define ATTRIBUTE_CONST _GL_ATTRIBUTE_CONST
|
||||
|
||||
/* It is OK for a compiler to omit duplicate calls with the same
|
||||
arguments if observable state is not changed between calls.
|
||||
This attribute is safe for a function that does not affect
|
||||
observable state, and always returns exactly once.
|
||||
(This attribute is looser than ATTRIBUTE_CONST.) */
|
||||
/* It is OK for a compiler to move calls to the function and to omit duplicate
|
||||
calls to the function with the same arguments, so long as the state
|
||||
addressed by its arguments is the same.
|
||||
This attribute is safe for a function that is effectless, idempotent,
|
||||
stateless, and independent; see ISO C 23 § 6.7.12.7 for a definition of
|
||||
these terms.
|
||||
(This attribute is stricter than REPRODUCIBLE because the function
|
||||
must be stateless and independent. It is looser than ATTRIBUTE_CONST
|
||||
because the function need not return exactly once and can depend
|
||||
on state addressed by its arguments.)
|
||||
See also <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2956.htm> and
|
||||
<https://stackoverflow.com/questions/76847905/>.
|
||||
ATTENTION! Efforts are underway to change the meaning of this attribute.
|
||||
See <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3424.htm>. */
|
||||
/* Applies to: functions, pointer to functions, function type. */
|
||||
#define UNSEQUENCED _GL_ATTRIBUTE_UNSEQUENCED
|
||||
|
||||
/* It is OK for a compiler to move calls to the function and to omit
|
||||
calls to the function if another call has the same arguments or the
|
||||
result is not used, and if observable state is the same.
|
||||
This attribute is safe for a function that does not affect observable state
|
||||
and always returns exactly once.
|
||||
(This attribute is looser than ATTRIBUTE_CONST because the function
|
||||
can depend on observable state. It is stricter than REPRODUCIBLE
|
||||
because the function must return exactly once and cannot affect
|
||||
state addressed by its arguments.) */
|
||||
/* Applies to: functions. */
|
||||
#define ATTRIBUTE_PURE _GL_ATTRIBUTE_PURE
|
||||
|
||||
/* It is OK for a compiler to move calls to the function and to omit duplicate
|
||||
calls to the function with the same arguments, so long as the state
|
||||
addressed by its arguments is the same and is updated in time for
|
||||
the rest of the program.
|
||||
This attribute is safe for a function that is effectless and idempotent; see
|
||||
ISO C 23 § 6.7.12.7 for a definition of these terms.
|
||||
(This attribute is looser than UNSEQUENCED because the function need
|
||||
not be stateless and idempotent. It is looser than ATTRIBUTE_PURE
|
||||
because the function need not return exactly once and can affect
|
||||
state addressed by its arguments.)
|
||||
See also <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2956.htm> and
|
||||
<https://stackoverflow.com/questions/76847905/>.
|
||||
ATTENTION! Efforts are underway to change the meaning of this attribute.
|
||||
See <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3424.htm>. */
|
||||
/* Applies to: functions, pointer to functions, function type. */
|
||||
#define REPRODUCIBLE _GL_ATTRIBUTE_REPRODUCIBLE
|
||||
|
||||
/* The function is rarely executed. */
|
||||
/* Applies to: functions. */
|
||||
#define ATTRIBUTE_COLD _GL_ATTRIBUTE_COLD
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* base64.c -- Encode binary data using printable characters.
|
||||
Copyright (C) 1999-2001, 2004-2006, 2009-2024 Free Software Foundation, Inc.
|
||||
Copyright (C) 1999-2001, 2004-2006, 2009-2025 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
|
||||
|
|
@ -48,7 +48,7 @@
|
|||
/* Get imalloc. */
|
||||
#include <ialloc.h>
|
||||
|
||||
#include <intprops.h>
|
||||
#include <stdckdint.h>
|
||||
|
||||
#include <string.h>
|
||||
|
||||
|
|
@ -59,7 +59,7 @@ to_uchar (char ch)
|
|||
return ch;
|
||||
}
|
||||
|
||||
static const char b64c[64] =
|
||||
static const char b64c[64] _GL_ATTRIBUTE_NONSTRING =
|
||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
||||
|
||||
/* Base64 encode IN array of size INLEN into OUT array. OUT needs
|
||||
|
|
@ -148,7 +148,7 @@ base64_encode_alloc (const char *in, idx_t inlen, char **out)
|
|||
Treat negative INLEN as overflow, for better compatibility with
|
||||
pre-2021-08-27 API, which used size_t. */
|
||||
idx_t in_over_3 = inlen / 3 + (inlen % 3 != 0), outlen;
|
||||
if (! INT_MULTIPLY_OK (in_over_3, 4, &outlen) || inlen < 0)
|
||||
if (ckd_mul (&outlen, in_over_3, 4) || inlen < 0)
|
||||
{
|
||||
*out = NULL;
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* base64.h -- Encode binary data using printable characters.
|
||||
Copyright (C) 2004-2006, 2009-2024 Free Software Foundation, Inc.
|
||||
Copyright (C) 2004-2006, 2009-2025 Free Software Foundation, Inc.
|
||||
Written by Simon Josefsson.
|
||||
|
||||
This file is free software: you can redistribute it and/or modify
|
||||
|
|
@ -27,7 +27,7 @@
|
|||
#include <idx.h>
|
||||
|
||||
/* Pacify GCC in isubase64. */
|
||||
#if defined __GNUC__ && 4 < __GNUC__ + (3 <= __GNUC_MINOR__)
|
||||
#if 4 < __GNUC__ + (3 <= __GNUC_MINOR__) && !defined __clang__
|
||||
# pragma GCC diagnostic ignored "-Wtype-limits"
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/* basename.c -- return the last element in a file name
|
||||
|
||||
Copyright (C) 1990, 1998-2001, 2003-2006, 2009-2024 Free Software
|
||||
Copyright (C) 1990, 1998-2001, 2003-2006, 2009-2025 Free Software
|
||||
Foundation, Inc.
|
||||
|
||||
This file is free software: you can redistribute it and/or modify
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/* Extract the last component (base name) of a file name.
|
||||
|
||||
Copyright (C) 1998, 2001, 2003-2006, 2009-2024 Free Software Foundation,
|
||||
Copyright (C) 1998, 2001, 2003-2006, 2009-2025 Free Software Foundation,
|
||||
Inc.
|
||||
|
||||
This file is free software: you can redistribute it and/or modify
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/* basename.c -- return the last element in a file name
|
||||
|
||||
Copyright (C) 1990, 1998-2001, 2003-2006, 2009-2024 Free Software
|
||||
Copyright (C) 1990, 1998-2001, 2003-2006, 2009-2025 Free Software
|
||||
Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* Convert unibyte character to wide character.
|
||||
Copyright (C) 2008, 2010-2024 Free Software Foundation, Inc.
|
||||
Copyright (C) 2008, 2010-2025 Free Software Foundation, Inc.
|
||||
Written by Bruno Haible <bruno@clisp.org>, 2008.
|
||||
|
||||
This file is free software: you can redistribute it and/or modify
|
||||
|
|
|
|||
21
gl/byteswap.c
Normal file
21
gl/byteswap.c
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
/* Inline functions for <byteswap.h>.
|
||||
|
||||
Copyright 2024-2025 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 <https://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#define _GL_BYTESWAP_INLINE _GL_EXTERN_INLINE
|
||||
#include <byteswap.h>
|
||||
106
gl/byteswap.in.h
106
gl/byteswap.in.h
|
|
@ -1,5 +1,5 @@
|
|||
/* byteswap.h - Byte swapping
|
||||
Copyright (C) 2005, 2007, 2009-2024 Free Software Foundation, Inc.
|
||||
Copyright (C) 2005, 2007, 2009-2025 Free Software Foundation, Inc.
|
||||
Written by Oskar Liljeblad <oskar@osk.mine.nu>, 2005.
|
||||
|
||||
This file is free software: you can redistribute it and/or modify
|
||||
|
|
@ -16,29 +16,103 @@
|
|||
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
||||
|
||||
#ifndef _GL_BYTESWAP_H
|
||||
#define _GL_BYTESWAP_H
|
||||
#define _GL_BYTESWAP_H 1
|
||||
|
||||
/* This file uses _GL_INLINE. */
|
||||
#if !_GL_CONFIG_H_INCLUDED
|
||||
#error "Please include config.h first."
|
||||
#endif
|
||||
|
||||
/* Define this now, rather than after including stdint.h, in case
|
||||
stdint.h recursively includes us. This is for Gnulib endian.h. */
|
||||
#ifndef _GL_BYTESWAP_INLINE
|
||||
# define _GL_BYTESWAP_INLINE _GL_INLINE
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
_GL_INLINE_HEADER_BEGIN
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)
|
||||
# define _GL_BYTESWAP_HAS_BUILTIN_BSWAP16 true
|
||||
#elif defined __has_builtin
|
||||
# if __has_builtin (__builtin_bswap16)
|
||||
# define _GL_BYTESWAP_HAS_BUILTIN_BSWAP16 true
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
|
||||
# define _GL_BYTESWAP_HAS_BUILTIN_BSWAP32 true
|
||||
# define _GL_BYTESWAP_HAS_BUILTIN_BSWAP64 true
|
||||
#elif defined __has_builtin
|
||||
# if __has_builtin (__builtin_bswap32)
|
||||
# define _GL_BYTESWAP_HAS_BUILTIN_BSWAP32 true
|
||||
# endif
|
||||
# if __has_builtin (__builtin_bswap64)
|
||||
# define _GL_BYTESWAP_HAS_BUILTIN_BSWAP64 true
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Given an unsigned 16-bit argument X, return the value corresponding to
|
||||
X with reversed byte order. */
|
||||
#define bswap_16(x) ((((x) & 0x00FF) << 8) | \
|
||||
(((x) & 0xFF00) >> 8))
|
||||
_GL_BYTESWAP_INLINE uint_least16_t
|
||||
bswap_16 (uint_least16_t x)
|
||||
{
|
||||
#ifdef _GL_BYTESWAP_HAS_BUILTIN_BSWAP16
|
||||
return __builtin_bswap16 (x);
|
||||
#else
|
||||
uint_fast16_t mask = 0xff;
|
||||
return ( (x & mask << 8 * 1) >> 8 * 1
|
||||
| (x & mask << 8 * 0) << 8 * 1);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Given an unsigned 32-bit argument X, return the value corresponding to
|
||||
X with reversed byte order. */
|
||||
#define bswap_32(x) ((((x) & 0x000000FF) << 24) | \
|
||||
(((x) & 0x0000FF00) << 8) | \
|
||||
(((x) & 0x00FF0000) >> 8) | \
|
||||
(((x) & 0xFF000000) >> 24))
|
||||
_GL_BYTESWAP_INLINE uint_least32_t
|
||||
bswap_32 (uint_least32_t x)
|
||||
{
|
||||
#ifdef _GL_BYTESWAP_HAS_BUILTIN_BSWAP32
|
||||
return __builtin_bswap32 (x);
|
||||
#else
|
||||
uint_fast32_t mask = 0xff;
|
||||
return ( (x & mask << 8 * 3) >> 8 * 3
|
||||
| (x & mask << 8 * 2) >> 8 * 1
|
||||
| (x & mask << 8 * 1) << 8 * 1
|
||||
| (x & mask << 8 * 0) << 8 * 3);
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef UINT_LEAST64_MAX
|
||||
/* Given an unsigned 64-bit argument X, return the value corresponding to
|
||||
X with reversed byte order. */
|
||||
#define bswap_64(x) ((((x) & 0x00000000000000FFULL) << 56) | \
|
||||
(((x) & 0x000000000000FF00ULL) << 40) | \
|
||||
(((x) & 0x0000000000FF0000ULL) << 24) | \
|
||||
(((x) & 0x00000000FF000000ULL) << 8) | \
|
||||
(((x) & 0x000000FF00000000ULL) >> 8) | \
|
||||
(((x) & 0x0000FF0000000000ULL) >> 24) | \
|
||||
(((x) & 0x00FF000000000000ULL) >> 40) | \
|
||||
(((x) & 0xFF00000000000000ULL) >> 56))
|
||||
_GL_BYTESWAP_INLINE uint_least64_t
|
||||
bswap_64 (uint_least64_t x)
|
||||
{
|
||||
# ifdef _GL_BYTESWAP_HAS_BUILTIN_BSWAP64
|
||||
return __builtin_bswap64 (x);
|
||||
# else
|
||||
uint_fast64_t mask = 0xff;
|
||||
return ( (x & mask << 8 * 7) >> 8 * 7
|
||||
| (x & mask << 8 * 6) >> 8 * 5
|
||||
| (x & mask << 8 * 5) >> 8 * 3
|
||||
| (x & mask << 8 * 4) >> 8 * 1
|
||||
| (x & mask << 8 * 3) << 8 * 1
|
||||
| (x & mask << 8 * 2) << 8 * 3
|
||||
| (x & mask << 8 * 1) << 8 * 5
|
||||
| (x & mask << 8 * 0) << 8 * 7);
|
||||
# endif
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
_GL_INLINE_HEADER_END
|
||||
|
||||
#endif /* _GL_BYTESWAP_H */
|
||||
|
|
|
|||
50
gl/c++defs.h
50
gl/c++defs.h
|
|
@ -1,5 +1,5 @@
|
|||
/* C++ compatible function declaration macros.
|
||||
Copyright (C) 2010-2024 Free Software Foundation, Inc.
|
||||
Copyright (C) 2010-2025 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU Lesser General Public License as published
|
||||
|
|
@ -93,11 +93,27 @@
|
|||
# define _GL_EXTERN_C extern
|
||||
#endif
|
||||
|
||||
/* _GL_FUNCDECL_RPL (func, rettype, parameters_and_attributes);
|
||||
/* _GL_EXTERN_C_FUNC declaration;
|
||||
performs the declaration of a function with C linkage. */
|
||||
#if defined __cplusplus
|
||||
# define _GL_EXTERN_C_FUNC extern "C"
|
||||
#else
|
||||
/* In C mode, omit the 'extern' keyword, because attributes in bracket syntax
|
||||
are not allowed between 'extern' and the return type (see gnulib-common.m4).
|
||||
*/
|
||||
# define _GL_EXTERN_C_FUNC
|
||||
#endif
|
||||
|
||||
/* _GL_FUNCDECL_RPL (func, rettype, parameters, [attributes]);
|
||||
declares a replacement function, named rpl_func, with the given prototype,
|
||||
consisting of return type, parameters, and attributes.
|
||||
Example:
|
||||
_GL_FUNCDECL_RPL (open, int, (const char *filename, int flags, ...)
|
||||
Although attributes are optional, the comma before them is required
|
||||
for portability to C17 and earlier. The attribute _GL_ATTRIBUTE_NOTHROW,
|
||||
if needed, must be placed after the _GL_FUNCDECL_RPL invocation,
|
||||
at the end of the declaration.
|
||||
Examples:
|
||||
_GL_FUNCDECL_RPL (free, void, (void *ptr), ) _GL_ATTRIBUTE_NOTHROW;
|
||||
_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
|
||||
|
|
@ -106,20 +122,24 @@
|
|||
[[...]] extern "C" <declaration>;
|
||||
is invalid syntax in C++.)
|
||||
*/
|
||||
#define _GL_FUNCDECL_RPL(func,rettype,parameters_and_attributes) \
|
||||
_GL_FUNCDECL_RPL_1 (rpl_##func, rettype, parameters_and_attributes)
|
||||
#define _GL_FUNCDECL_RPL_1(rpl_func,rettype,parameters_and_attributes) \
|
||||
_GL_EXTERN_C rettype rpl_func parameters_and_attributes
|
||||
#define _GL_FUNCDECL_RPL(func,rettype,parameters,...) \
|
||||
_GL_FUNCDECL_RPL_1 (rpl_##func, rettype, parameters, __VA_ARGS__)
|
||||
#define _GL_FUNCDECL_RPL_1(rpl_func,rettype,parameters,...) \
|
||||
_GL_EXTERN_C_FUNC __VA_ARGS__ rettype rpl_func parameters
|
||||
|
||||
/* _GL_FUNCDECL_SYS (func, rettype, parameters_and_attributes);
|
||||
/* _GL_FUNCDECL_SYS (func, rettype, parameters, [attributes]);
|
||||
declares the system function, named func, with the given prototype,
|
||||
consisting of return type, parameters, and attributes.
|
||||
Example:
|
||||
_GL_FUNCDECL_SYS (open, int, (const char *filename, int flags, ...)
|
||||
_GL_ARG_NONNULL ((1)));
|
||||
Although attributes are optional, the comma before them is required
|
||||
for portability to C17 and earlier. The attribute _GL_ATTRIBUTE_NOTHROW,
|
||||
if needed, must be placed after the _GL_FUNCDECL_RPL invocation,
|
||||
at the end of the declaration.
|
||||
Examples:
|
||||
_GL_FUNCDECL_SYS (getumask, mode_t, (void), ) _GL_ATTRIBUTE_NOTHROW;
|
||||
_GL_FUNCDECL_SYS (posix_openpt, int, (int flags), _GL_ATTRIBUTE_NODISCARD);
|
||||
*/
|
||||
#define _GL_FUNCDECL_SYS(func,rettype,parameters_and_attributes) \
|
||||
_GL_EXTERN_C rettype func parameters_and_attributes
|
||||
#define _GL_FUNCDECL_SYS(func,rettype,parameters,...) \
|
||||
_GL_EXTERN_C_FUNC __VA_ARGS__ rettype func parameters
|
||||
|
||||
/* _GL_CXXALIAS_RPL (func, rettype, parameters);
|
||||
declares a C++ alias called GNULIB_NAMESPACE::func
|
||||
|
|
@ -297,7 +317,7 @@
|
|||
_GL_WARN_ON_USE (func, \
|
||||
"The symbol ::" #func " refers to the system function. " \
|
||||
"Use " #namespace "::" #func " instead.")
|
||||
# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
|
||||
# elif (__GNUC__ >= 3 || defined __clang__) && GNULIB_STRICT_CHECKING
|
||||
# define _GL_CXXALIASWARN_2(func,namespace) \
|
||||
extern __typeof__ (func) func
|
||||
# else
|
||||
|
|
|
|||
21
gl/c-ctype.c
Normal file
21
gl/c-ctype.c
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
/* Character handling in C locale.
|
||||
|
||||
Copyright (C) 2003-2025 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 <https://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#define C_CTYPE_INLINE _GL_EXTERN_INLINE
|
||||
#include "c-ctype.h"
|
||||
366
gl/c-ctype.h
Normal file
366
gl/c-ctype.h
Normal file
|
|
@ -0,0 +1,366 @@
|
|||
/* Character handling in C locale.
|
||||
|
||||
These functions work like the corresponding functions in <ctype.h>,
|
||||
except that they have the C (POSIX) locale hardwired, whereas the
|
||||
<ctype.h> functions' behaviour depends on the current locale set via
|
||||
setlocale.
|
||||
|
||||
Copyright (C) 2000-2003, 2006, 2008-2025 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 <https://www.gnu.org/licenses/>. */
|
||||
|
||||
#ifndef C_CTYPE_H
|
||||
#define C_CTYPE_H
|
||||
|
||||
/* 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
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/* The functions defined in this file assume the "C" locale and a character
|
||||
set without diacritics (ASCII-US or EBCDIC-US or something like that).
|
||||
Even if the "C" locale on a particular system is an extension of the ASCII
|
||||
character set (like on BeOS, where it is UTF-8, or on AmigaOS, where it
|
||||
is ISO-8859-1), the functions in this file recognize only the ASCII
|
||||
characters. */
|
||||
|
||||
|
||||
#if (' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \
|
||||
&& ('%' == 37) && ('&' == 38) && ('\'' == 39) && ('(' == 40) \
|
||||
&& (')' == 41) && ('*' == 42) && ('+' == 43) && (',' == 44) \
|
||||
&& ('-' == 45) && ('.' == 46) && ('/' == 47) && ('0' == 48) \
|
||||
&& ('1' == 49) && ('2' == 50) && ('3' == 51) && ('4' == 52) \
|
||||
&& ('5' == 53) && ('6' == 54) && ('7' == 55) && ('8' == 56) \
|
||||
&& ('9' == 57) && (':' == 58) && (';' == 59) && ('<' == 60) \
|
||||
&& ('=' == 61) && ('>' == 62) && ('?' == 63) && ('A' == 65) \
|
||||
&& ('B' == 66) && ('C' == 67) && ('D' == 68) && ('E' == 69) \
|
||||
&& ('F' == 70) && ('G' == 71) && ('H' == 72) && ('I' == 73) \
|
||||
&& ('J' == 74) && ('K' == 75) && ('L' == 76) && ('M' == 77) \
|
||||
&& ('N' == 78) && ('O' == 79) && ('P' == 80) && ('Q' == 81) \
|
||||
&& ('R' == 82) && ('S' == 83) && ('T' == 84) && ('U' == 85) \
|
||||
&& ('V' == 86) && ('W' == 87) && ('X' == 88) && ('Y' == 89) \
|
||||
&& ('Z' == 90) && ('[' == 91) && ('\\' == 92) && (']' == 93) \
|
||||
&& ('^' == 94) && ('_' == 95) && ('a' == 97) && ('b' == 98) \
|
||||
&& ('c' == 99) && ('d' == 100) && ('e' == 101) && ('f' == 102) \
|
||||
&& ('g' == 103) && ('h' == 104) && ('i' == 105) && ('j' == 106) \
|
||||
&& ('k' == 107) && ('l' == 108) && ('m' == 109) && ('n' == 110) \
|
||||
&& ('o' == 111) && ('p' == 112) && ('q' == 113) && ('r' == 114) \
|
||||
&& ('s' == 115) && ('t' == 116) && ('u' == 117) && ('v' == 118) \
|
||||
&& ('w' == 119) && ('x' == 120) && ('y' == 121) && ('z' == 122) \
|
||||
&& ('{' == 123) && ('|' == 124) && ('}' == 125) && ('~' == 126)
|
||||
/* The character set is ASCII or one of its variants or extensions, not EBCDIC.
|
||||
Testing the value of '\n' and '\r' is not relevant. */
|
||||
# define C_CTYPE_ASCII 1
|
||||
#elif ! (' ' == '\x40' && '0' == '\xf0' \
|
||||
&& 'A' == '\xc1' && 'J' == '\xd1' && 'S' == '\xe2' \
|
||||
&& 'a' == '\x81' && 'j' == '\x91' && 's' == '\xa2')
|
||||
# error "Only ASCII and EBCDIC are supported"
|
||||
#endif
|
||||
|
||||
#if 'A' < 0
|
||||
# error "EBCDIC and char is signed -- not supported"
|
||||
#endif
|
||||
|
||||
/* Cases for control characters. */
|
||||
|
||||
#define _C_CTYPE_CNTRL \
|
||||
case '\a': case '\b': case '\f': case '\n': \
|
||||
case '\r': case '\t': case '\v': \
|
||||
_C_CTYPE_OTHER_CNTRL
|
||||
|
||||
/* ASCII control characters other than those with \-letter escapes. */
|
||||
|
||||
#if C_CTYPE_ASCII
|
||||
# define _C_CTYPE_OTHER_CNTRL \
|
||||
case '\x00': case '\x01': case '\x02': case '\x03': \
|
||||
case '\x04': case '\x05': case '\x06': case '\x0e': \
|
||||
case '\x0f': case '\x10': case '\x11': case '\x12': \
|
||||
case '\x13': case '\x14': case '\x15': case '\x16': \
|
||||
case '\x17': case '\x18': case '\x19': case '\x1a': \
|
||||
case '\x1b': case '\x1c': case '\x1d': case '\x1e': \
|
||||
case '\x1f': case '\x7f'
|
||||
#else
|
||||
/* Use EBCDIC code page 1047's assignments for ASCII control chars;
|
||||
assume all EBCDIC code pages agree about these assignments. */
|
||||
# define _C_CTYPE_OTHER_CNTRL \
|
||||
case '\x00': case '\x01': case '\x02': case '\x03': \
|
||||
case '\x07': case '\x0e': case '\x0f': case '\x10': \
|
||||
case '\x11': case '\x12': case '\x13': case '\x18': \
|
||||
case '\x19': case '\x1c': case '\x1d': case '\x1e': \
|
||||
case '\x1f': case '\x26': case '\x27': case '\x2d': \
|
||||
case '\x2e': case '\x32': case '\x37': case '\x3c': \
|
||||
case '\x3d': case '\x3f'
|
||||
#endif
|
||||
|
||||
/* Cases for lowercase hex letters, and lowercase letters, all offset by N. */
|
||||
|
||||
#define _C_CTYPE_LOWER_A_THRU_F_N(N) \
|
||||
case 'a' + (N): case 'b' + (N): case 'c' + (N): case 'd' + (N): \
|
||||
case 'e' + (N): case 'f' + (N)
|
||||
#define _C_CTYPE_LOWER_N(N) \
|
||||
_C_CTYPE_LOWER_A_THRU_F_N(N): \
|
||||
case 'g' + (N): case 'h' + (N): case 'i' + (N): case 'j' + (N): \
|
||||
case 'k' + (N): case 'l' + (N): case 'm' + (N): case 'n' + (N): \
|
||||
case 'o' + (N): case 'p' + (N): case 'q' + (N): case 'r' + (N): \
|
||||
case 's' + (N): case 't' + (N): case 'u' + (N): case 'v' + (N): \
|
||||
case 'w' + (N): case 'x' + (N): case 'y' + (N): case 'z' + (N)
|
||||
|
||||
/* Cases for hex letters, digits, lower, punct, and upper. */
|
||||
|
||||
#define _C_CTYPE_A_THRU_F \
|
||||
_C_CTYPE_LOWER_A_THRU_F_N (0): \
|
||||
_C_CTYPE_LOWER_A_THRU_F_N ('A' - 'a')
|
||||
#define _C_CTYPE_DIGIT \
|
||||
case '0': case '1': case '2': case '3': \
|
||||
case '4': case '5': case '6': case '7': \
|
||||
case '8': case '9'
|
||||
#define _C_CTYPE_LOWER _C_CTYPE_LOWER_N (0)
|
||||
#define _C_CTYPE_PUNCT \
|
||||
case '!': case '"': case '#': case '$': \
|
||||
case '%': case '&': case '\'': case '(': \
|
||||
case ')': case '*': case '+': case ',': \
|
||||
case '-': case '.': case '/': case ':': \
|
||||
case ';': case '<': case '=': case '>': \
|
||||
case '?': case '@': case '[': case '\\': \
|
||||
case ']': case '^': case '_': case '`': \
|
||||
case '{': case '|': case '}': case '~'
|
||||
#define _C_CTYPE_UPPER _C_CTYPE_LOWER_N ('A' - 'a')
|
||||
|
||||
|
||||
/* Function definitions. */
|
||||
|
||||
/* Unlike the functions in <ctype.h>, which require an argument in the range
|
||||
of the 'unsigned char' type, the functions here operate on values that are
|
||||
in the 'unsigned char' range or in the 'char' range. In other words,
|
||||
when you have a 'char' value, you need to cast it before using it as
|
||||
argument to a <ctype.h> function:
|
||||
|
||||
const char *s = ...;
|
||||
if (isalpha ((unsigned char) *s)) ...
|
||||
|
||||
but you don't need to cast it for the functions defined in this file:
|
||||
|
||||
const char *s = ...;
|
||||
if (c_isalpha (*s)) ...
|
||||
*/
|
||||
|
||||
C_CTYPE_INLINE bool
|
||||
c_isalnum (int c)
|
||||
{
|
||||
switch (c)
|
||||
{
|
||||
_C_CTYPE_DIGIT:
|
||||
_C_CTYPE_LOWER:
|
||||
_C_CTYPE_UPPER:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
C_CTYPE_INLINE bool
|
||||
c_isalpha (int c)
|
||||
{
|
||||
switch (c)
|
||||
{
|
||||
_C_CTYPE_LOWER:
|
||||
_C_CTYPE_UPPER:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/* The function isascii is not locale dependent.
|
||||
Its use in EBCDIC is questionable. */
|
||||
C_CTYPE_INLINE bool
|
||||
c_isascii (int c)
|
||||
{
|
||||
switch (c)
|
||||
{
|
||||
case ' ':
|
||||
_C_CTYPE_CNTRL:
|
||||
_C_CTYPE_DIGIT:
|
||||
_C_CTYPE_LOWER:
|
||||
_C_CTYPE_PUNCT:
|
||||
_C_CTYPE_UPPER:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
C_CTYPE_INLINE bool
|
||||
c_isblank (int c)
|
||||
{
|
||||
return c == ' ' || c == '\t';
|
||||
}
|
||||
|
||||
C_CTYPE_INLINE bool
|
||||
c_iscntrl (int c)
|
||||
{
|
||||
switch (c)
|
||||
{
|
||||
_C_CTYPE_CNTRL:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
C_CTYPE_INLINE bool
|
||||
c_isdigit (int c)
|
||||
{
|
||||
switch (c)
|
||||
{
|
||||
_C_CTYPE_DIGIT:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
C_CTYPE_INLINE bool
|
||||
c_isgraph (int c)
|
||||
{
|
||||
switch (c)
|
||||
{
|
||||
_C_CTYPE_DIGIT:
|
||||
_C_CTYPE_LOWER:
|
||||
_C_CTYPE_PUNCT:
|
||||
_C_CTYPE_UPPER:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
C_CTYPE_INLINE bool
|
||||
c_islower (int c)
|
||||
{
|
||||
switch (c)
|
||||
{
|
||||
_C_CTYPE_LOWER:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
C_CTYPE_INLINE bool
|
||||
c_isprint (int c)
|
||||
{
|
||||
switch (c)
|
||||
{
|
||||
case ' ':
|
||||
_C_CTYPE_DIGIT:
|
||||
_C_CTYPE_LOWER:
|
||||
_C_CTYPE_PUNCT:
|
||||
_C_CTYPE_UPPER:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
C_CTYPE_INLINE bool
|
||||
c_ispunct (int c)
|
||||
{
|
||||
switch (c)
|
||||
{
|
||||
_C_CTYPE_PUNCT:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
C_CTYPE_INLINE bool
|
||||
c_isspace (int c)
|
||||
{
|
||||
switch (c)
|
||||
{
|
||||
case ' ': case '\t': case '\n': case '\v': case '\f': case '\r':
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
C_CTYPE_INLINE bool
|
||||
c_isupper (int c)
|
||||
{
|
||||
switch (c)
|
||||
{
|
||||
_C_CTYPE_UPPER:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
C_CTYPE_INLINE bool
|
||||
c_isxdigit (int c)
|
||||
{
|
||||
switch (c)
|
||||
{
|
||||
_C_CTYPE_DIGIT:
|
||||
_C_CTYPE_A_THRU_F:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
C_CTYPE_INLINE int
|
||||
c_tolower (int c)
|
||||
{
|
||||
switch (c)
|
||||
{
|
||||
_C_CTYPE_UPPER:
|
||||
return c - 'A' + 'a';
|
||||
default:
|
||||
return c;
|
||||
}
|
||||
}
|
||||
|
||||
C_CTYPE_INLINE int
|
||||
c_toupper (int c)
|
||||
{
|
||||
switch (c)
|
||||
{
|
||||
_C_CTYPE_LOWER:
|
||||
return c - 'a' + 'A';
|
||||
default:
|
||||
return c;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
_GL_INLINE_HEADER_END
|
||||
|
||||
#endif /* C_CTYPE_H */
|
||||
105
gl/c32is-impl.h
Normal file
105
gl/c32is-impl.h
Normal file
|
|
@ -0,0 +1,105 @@
|
|||
/* Test whether a 32-bit wide character belongs to a specific character class.
|
||||
Copyright (C) 2020-2025 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 <https://www.gnu.org/licenses/>. */
|
||||
|
||||
/* Written by Bruno Haible <bruno@clisp.org>, 2020. */
|
||||
|
||||
#include <wchar.h>
|
||||
#include <wctype.h>
|
||||
|
||||
#ifdef __CYGWIN__
|
||||
# include <cygwin/version.h>
|
||||
#endif
|
||||
|
||||
#if GNULIB_defined_mbstate_t
|
||||
# include "localcharset.h"
|
||||
# include "streq.h"
|
||||
#endif
|
||||
|
||||
#if GL_CHAR32_T_IS_UNICODE
|
||||
# include "lc-charset-unicode.h"
|
||||
#endif
|
||||
|
||||
#include "unictype.h"
|
||||
|
||||
#if _GL_WCHAR_T_IS_UCS4 && !GNULIB_defined_mbstate_t
|
||||
_GL_EXTERN_INLINE
|
||||
#endif
|
||||
int
|
||||
FUNC (wint_t wc)
|
||||
{
|
||||
/* The char32_t encoding of a multibyte character is defined by the way
|
||||
mbrtoc32() is defined. */
|
||||
|
||||
#if GNULIB_defined_mbstate_t /* AIX, IRIX */
|
||||
/* mbrtoc32() is defined on top of mbtowc() for the non-UTF-8 locales
|
||||
and directly for the UTF-8 locales. */
|
||||
if (wc != WEOF)
|
||||
{
|
||||
const char *encoding = locale_charset ();
|
||||
if (STREQ_OPT (encoding, "UTF-8", 'U', 'T', 'F', '-', '8', 0, 0, 0, 0))
|
||||
return UCS_FUNC (wc);
|
||||
else
|
||||
return WCHAR_FUNC (wc);
|
||||
}
|
||||
else
|
||||
return 0;
|
||||
|
||||
#elif HAVE_WORKING_MBRTOC32 && HAVE_WORKING_C32RTOMB /* glibc, Android */
|
||||
/* mbrtoc32() is essentially defined by the system libc. */
|
||||
|
||||
# if _GL_WCHAR_T_IS_UCS4
|
||||
/* The char32_t encoding of a multibyte character is known to be the same as
|
||||
the wchar_t encoding. */
|
||||
return WCHAR_FUNC (wc);
|
||||
# else
|
||||
/* The char32_t encoding of a multibyte character is known to be UCS-4,
|
||||
different from the wchar_t encoding. */
|
||||
if (wc != WEOF)
|
||||
return UCS_FUNC (wc);
|
||||
else
|
||||
return 0;
|
||||
# endif
|
||||
|
||||
#elif _GL_SMALL_WCHAR_T /* Cygwin, mingw, MSVC */
|
||||
/* The wchar_t encoding is UTF-16.
|
||||
The char32_t encoding is UCS-4. */
|
||||
|
||||
# if defined __CYGWIN__ && CYGWIN_VERSION_DLL_MAJOR >= 1007
|
||||
/* As an extension to POSIX, the iswalnum() function of Cygwin >= 1.7
|
||||
supports also wc arguments outside the Unicode BMP, that is, outside
|
||||
the 'wchar_t' range. See
|
||||
<https://lists.gnu.org/archive/html/bug-gnulib/2011-02/msg00019.html>
|
||||
= <https://cygwin.com/ml/cygwin/2011-02/msg00044.html>. */
|
||||
return WCHAR_FUNC (wc);
|
||||
# else
|
||||
if (wc == WEOF || wc == (wchar_t) wc)
|
||||
/* wc is in the range for the isw* functions. */
|
||||
return WCHAR_FUNC (wc);
|
||||
else
|
||||
return UCS_FUNC (wc);
|
||||
# endif
|
||||
|
||||
#else /* macOS, FreeBSD, NetBSD, OpenBSD, HP-UX, Solaris, Minix, Android */
|
||||
/* char32_t and wchar_t are equivalent. */
|
||||
static_assert (sizeof (char32_t) == sizeof (wchar_t));
|
||||
|
||||
# if GL_CHAR32_T_IS_UNICODE && GL_CHAR32_T_VS_WCHAR_T_NEEDS_CONVERSION
|
||||
return UCS_FUNC (wc);
|
||||
# else
|
||||
return WCHAR_FUNC (wc);
|
||||
# endif
|
||||
#endif
|
||||
}
|
||||
26
gl/c32isalnum.c
Normal file
26
gl/c32isalnum.c
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
/* Test 32-bit wide character for being alphanumeric.
|
||||
Copyright (C) 2020-2025 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 <https://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#define IN_C32ISALNUM
|
||||
/* Specification. */
|
||||
#include <uchar.h>
|
||||
|
||||
#define FUNC c32isalnum
|
||||
#define WCHAR_FUNC iswalnum
|
||||
#define UCS_FUNC uc_is_alnum
|
||||
#include "c32is-impl.h"
|
||||
26
gl/c32isalpha.c
Normal file
26
gl/c32isalpha.c
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
/* Test 32-bit wide character for being alphabetic.
|
||||
Copyright (C) 2020-2025 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 <https://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#define IN_C32ISALPHA
|
||||
/* Specification. */
|
||||
#include <uchar.h>
|
||||
|
||||
#define FUNC c32isalpha
|
||||
#define WCHAR_FUNC iswalpha
|
||||
#define UCS_FUNC uc_is_alpha
|
||||
#include "c32is-impl.h"
|
||||
26
gl/c32isblank.c
Normal file
26
gl/c32isblank.c
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
/* Test 32-bit wide character for being blank.
|
||||
Copyright (C) 2020-2025 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 <https://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#define IN_C32ISBLANK
|
||||
/* Specification. */
|
||||
#include <uchar.h>
|
||||
|
||||
#define FUNC c32isblank
|
||||
#define WCHAR_FUNC iswblank
|
||||
#define UCS_FUNC uc_is_blank
|
||||
#include "c32is-impl.h"
|
||||
26
gl/c32iscntrl.c
Normal file
26
gl/c32iscntrl.c
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
/* Test 32-bit wide character for being a control character.
|
||||
Copyright (C) 2020-2025 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 <https://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#define IN_C32ISCNTRL
|
||||
/* Specification. */
|
||||
#include <uchar.h>
|
||||
|
||||
#define FUNC c32iscntrl
|
||||
#define WCHAR_FUNC iswcntrl
|
||||
#define UCS_FUNC uc_is_cntrl
|
||||
#include "c32is-impl.h"
|
||||
26
gl/c32isdigit.c
Normal file
26
gl/c32isdigit.c
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
/* Test 32-bit wide character for being a digit.
|
||||
Copyright (C) 2020-2025 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 <https://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#define IN_C32ISDIGIT
|
||||
/* Specification. */
|
||||
#include <uchar.h>
|
||||
|
||||
#define FUNC c32isdigit
|
||||
#define WCHAR_FUNC iswdigit
|
||||
#define UCS_FUNC uc_is_digit
|
||||
#include "c32is-impl.h"
|
||||
26
gl/c32isgraph.c
Normal file
26
gl/c32isgraph.c
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
/* Test 32-bit wide character for being graphic.
|
||||
Copyright (C) 2020-2025 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 <https://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#define IN_C32ISGRAPH
|
||||
/* Specification. */
|
||||
#include <uchar.h>
|
||||
|
||||
#define FUNC c32isgraph
|
||||
#define WCHAR_FUNC iswgraph
|
||||
#define UCS_FUNC uc_is_graph
|
||||
#include "c32is-impl.h"
|
||||
26
gl/c32islower.c
Normal file
26
gl/c32islower.c
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
/* Test 32-bit wide character for being lowercase.
|
||||
Copyright (C) 2020-2025 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 <https://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#define IN_C32ISLOWER
|
||||
/* Specification. */
|
||||
#include <uchar.h>
|
||||
|
||||
#define FUNC c32islower
|
||||
#define WCHAR_FUNC iswlower
|
||||
#define UCS_FUNC uc_is_lower
|
||||
#include "c32is-impl.h"
|
||||
26
gl/c32isprint.c
Normal file
26
gl/c32isprint.c
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
/* Test 32-bit wide character for being printable.
|
||||
Copyright (C) 2020-2025 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 <https://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#define IN_C32ISPRINT
|
||||
/* Specification. */
|
||||
#include <uchar.h>
|
||||
|
||||
#define FUNC c32isprint
|
||||
#define WCHAR_FUNC iswprint
|
||||
#define UCS_FUNC uc_is_print
|
||||
#include "c32is-impl.h"
|
||||
26
gl/c32ispunct.c
Normal file
26
gl/c32ispunct.c
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
/* Test 32-bit wide character for being a punctuation or symbol character.
|
||||
Copyright (C) 2020-2025 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 <https://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#define IN_C32ISPUNCT
|
||||
/* Specification. */
|
||||
#include <uchar.h>
|
||||
|
||||
#define FUNC c32ispunct
|
||||
#define WCHAR_FUNC iswpunct
|
||||
#define UCS_FUNC uc_is_punct
|
||||
#include "c32is-impl.h"
|
||||
26
gl/c32isspace.c
Normal file
26
gl/c32isspace.c
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
/* Test 32-bit wide character for being white-space.
|
||||
Copyright (C) 2020-2025 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 <https://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#define IN_C32ISSPACE
|
||||
/* Specification. */
|
||||
#include <uchar.h>
|
||||
|
||||
#define FUNC c32isspace
|
||||
#define WCHAR_FUNC iswspace
|
||||
#define UCS_FUNC uc_is_space
|
||||
#include "c32is-impl.h"
|
||||
26
gl/c32isupper.c
Normal file
26
gl/c32isupper.c
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
/* Test 32-bit wide character for being uppercase.
|
||||
Copyright (C) 2020-2025 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 <https://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#define IN_C32ISUPPER
|
||||
/* Specification. */
|
||||
#include <uchar.h>
|
||||
|
||||
#define FUNC c32isupper
|
||||
#define WCHAR_FUNC iswupper
|
||||
#define UCS_FUNC uc_is_upper
|
||||
#include "c32is-impl.h"
|
||||
26
gl/c32isxdigit.c
Normal file
26
gl/c32isxdigit.c
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
/* Test 32-bit wide character for being a hexadecimal digit.
|
||||
Copyright (C) 2020-2025 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 <https://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#define IN_C32ISXDIGIT
|
||||
/* Specification. */
|
||||
#include <uchar.h>
|
||||
|
||||
#define FUNC c32isxdigit
|
||||
#define WCHAR_FUNC iswxdigit
|
||||
#define UCS_FUNC uc_is_xdigit
|
||||
#include "c32is-impl.h"
|
||||
103
gl/c32to-impl.h
Normal file
103
gl/c32to-impl.h
Normal file
|
|
@ -0,0 +1,103 @@
|
|||
/* Case mapping of a 32-bit wide character.
|
||||
Copyright (C) 2020-2025 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 <https://www.gnu.org/licenses/>. */
|
||||
|
||||
/* Written by Bruno Haible <bruno@clisp.org>, 2023. */
|
||||
|
||||
#include <wchar.h>
|
||||
#include <wctype.h>
|
||||
|
||||
#if GNULIB_defined_mbstate_t
|
||||
# include "localcharset.h"
|
||||
# include "streq.h"
|
||||
#endif
|
||||
|
||||
#if GL_CHAR32_T_IS_UNICODE
|
||||
# include "lc-charset-unicode.h"
|
||||
#endif
|
||||
|
||||
#include "unicase.h"
|
||||
|
||||
#if _GL_WCHAR_T_IS_UCS4 && !GNULIB_defined_mbstate_t
|
||||
_GL_EXTERN_INLINE
|
||||
#endif
|
||||
wint_t
|
||||
FUNC (wint_t wc)
|
||||
{
|
||||
/* The char32_t encoding of a multibyte character is defined by the way
|
||||
mbrtoc32() is defined. */
|
||||
|
||||
#if GNULIB_defined_mbstate_t /* AIX, IRIX */
|
||||
/* mbrtoc32() is defined on top of mbtowc() for the non-UTF-8 locales
|
||||
and directly for the UTF-8 locales. */
|
||||
if (wc != WEOF)
|
||||
{
|
||||
const char *encoding = locale_charset ();
|
||||
if (STREQ_OPT (encoding, "UTF-8", 'U', 'T', 'F', '-', '8', 0, 0, 0, 0))
|
||||
return UCS_FUNC (wc);
|
||||
else
|
||||
return WCHAR_FUNC (wc);
|
||||
}
|
||||
else
|
||||
return wc;
|
||||
|
||||
#elif HAVE_WORKING_MBRTOC32 && HAVE_WORKING_C32RTOMB /* glibc, Android */
|
||||
/* mbrtoc32() is essentially defined by the system libc. */
|
||||
|
||||
# if _GL_WCHAR_T_IS_UCS4
|
||||
/* The char32_t encoding of a multibyte character is known to be the same as
|
||||
the wchar_t encoding. */
|
||||
return WCHAR_FUNC (wc);
|
||||
# else
|
||||
/* The char32_t encoding of a multibyte character is known to be UCS-4,
|
||||
different from the wchar_t encoding. */
|
||||
if (wc != WEOF)
|
||||
return UCS_FUNC (wc);
|
||||
else
|
||||
return wc;
|
||||
# endif
|
||||
|
||||
#elif _GL_SMALL_WCHAR_T /* Cygwin, mingw, MSVC */
|
||||
/* The wchar_t encoding is UTF-16.
|
||||
The char32_t encoding is UCS-4. */
|
||||
|
||||
# if defined _WIN32 && !defined __CYGWIN__
|
||||
/* On native Windows, in the UTF-8 locale, towlower and towupper are
|
||||
lacking (at least) the mappings for ISO-8859-1 characters, such as
|
||||
0x00C9 <-> 0x00E9. Since it is expensive to test whether the locale
|
||||
encoding is UTF-8, ignore the system's WCHAR_FUNC altogether. */
|
||||
if (wc != WEOF)
|
||||
return UCS_FUNC (wc);
|
||||
else
|
||||
return wc;
|
||||
# else
|
||||
if (wc == WEOF || wc == (wchar_t) wc)
|
||||
/* wc is in the range for the tow* functions. */
|
||||
return WCHAR_FUNC (wc);
|
||||
else
|
||||
return UCS_FUNC (wc);
|
||||
# endif
|
||||
|
||||
#else /* macOS, FreeBSD, NetBSD, OpenBSD, HP-UX, Solaris, Minix, Android */
|
||||
/* char32_t and wchar_t are equivalent. */
|
||||
static_assert (sizeof (char32_t) == sizeof (wchar_t));
|
||||
|
||||
# if GL_CHAR32_T_IS_UNICODE && GL_CHAR32_T_VS_WCHAR_T_NEEDS_CONVERSION
|
||||
return UCS_FUNC (wc);
|
||||
# else
|
||||
return WCHAR_FUNC (wc);
|
||||
# endif
|
||||
#endif
|
||||
}
|
||||
26
gl/c32tolower.c
Normal file
26
gl/c32tolower.c
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
/* Map a 32-bit wide character to lowercase.
|
||||
Copyright (C) 2023-2025 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 <https://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#define IN_C32TOLOWER
|
||||
/* Specification. */
|
||||
#include <uchar.h>
|
||||
|
||||
#define FUNC c32tolower
|
||||
#define WCHAR_FUNC towlower
|
||||
#define UCS_FUNC uc_tolower
|
||||
#include "c32to-impl.h"
|
||||
102
gl/c32width.c
Normal file
102
gl/c32width.c
Normal file
|
|
@ -0,0 +1,102 @@
|
|||
/* Determine the number of screen columns needed for a 32-bit wide character.
|
||||
Copyright (C) 2020-2025 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 <https://www.gnu.org/licenses/>. */
|
||||
|
||||
/* Written by Bruno Haible <bruno@clisp.org>, 2023. */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#define IN_C32WIDTH
|
||||
/* Specification. */
|
||||
#include <uchar.h>
|
||||
|
||||
#include <wchar.h>
|
||||
|
||||
#ifdef __CYGWIN__
|
||||
# include <cygwin/version.h>
|
||||
#endif
|
||||
|
||||
#if GNULIB_defined_mbstate_t
|
||||
# include "streq.h"
|
||||
#endif
|
||||
|
||||
#include "localcharset.h"
|
||||
|
||||
#if GL_CHAR32_T_IS_UNICODE
|
||||
# include "lc-charset-unicode.h"
|
||||
#endif
|
||||
|
||||
#include "uniwidth.h"
|
||||
|
||||
#if _GL_WCHAR_T_IS_UCS4 && !GNULIB_defined_mbstate_t
|
||||
_GL_EXTERN_INLINE
|
||||
#endif
|
||||
int
|
||||
c32width (char32_t wc)
|
||||
{
|
||||
/* The char32_t encoding of a multibyte character is defined by the way
|
||||
mbrtoc32() is defined. */
|
||||
|
||||
#if GNULIB_defined_mbstate_t /* AIX, IRIX */
|
||||
/* mbrtoc32() is defined on top of mbtowc() for the non-UTF-8 locales
|
||||
and directly for the UTF-8 locales. */
|
||||
const char *encoding = locale_charset ();
|
||||
if (STREQ_OPT (encoding, "UTF-8", 'U', 'T', 'F', '-', '8', 0, 0, 0, 0))
|
||||
return uc_width (wc, encoding);
|
||||
else
|
||||
return wcwidth (wc);
|
||||
|
||||
#elif HAVE_WORKING_MBRTOC32 && HAVE_WORKING_C32RTOMB /* glibc, Android */
|
||||
/* mbrtoc32() is essentially defined by the system libc. */
|
||||
|
||||
# if _GL_WCHAR_T_IS_UCS4
|
||||
/* The char32_t encoding of a multibyte character is known to be the same as
|
||||
the wchar_t encoding. */
|
||||
return wcwidth (wc);
|
||||
# else
|
||||
/* The char32_t encoding of a multibyte character is known to be UCS-4,
|
||||
different from the wchar_t encoding. */
|
||||
return uc_width (wc, locale_charset ());
|
||||
# endif
|
||||
|
||||
#elif _GL_SMALL_WCHAR_T /* Cygwin, mingw, MSVC */
|
||||
/* The wchar_t encoding is UTF-16.
|
||||
The char32_t encoding is UCS-4. */
|
||||
|
||||
# if defined __CYGWIN__ && CYGWIN_VERSION_DLL_MAJOR >= 1007 && 0
|
||||
/* As an extension to POSIX, the wcwidth() function of Cygwin >= 1.7
|
||||
supports also wc arguments outside the Unicode BMP, that is, outside
|
||||
the 'wchar_t' range. See
|
||||
<https://www.cygwin.com/cgit/newlib-cygwin/commit/?id=098a75dc51caa98f369d98a9809d773bc45329aa>.
|
||||
But the resulting values for these characters are not of good quality. */
|
||||
return wcwidth (wc);
|
||||
# else
|
||||
if (wc == (wchar_t) wc)
|
||||
/* wc is in the range for the wcwidth function. */
|
||||
return wcwidth (wc);
|
||||
else
|
||||
return uc_width (wc, locale_charset ());
|
||||
# endif
|
||||
|
||||
#else /* macOS, FreeBSD, NetBSD, OpenBSD, HP-UX, Solaris, Minix, Android */
|
||||
/* char32_t and wchar_t are equivalent. */
|
||||
static_assert (sizeof (char32_t) == sizeof (wchar_t));
|
||||
|
||||
# if GL_CHAR32_T_IS_UNICODE && GL_CHAR32_T_VS_WCHAR_T_NEEDS_CONVERSION
|
||||
return uc_width (wc, locale_charset ());
|
||||
# endif
|
||||
return wcwidth (wc);
|
||||
#endif
|
||||
}
|
||||
17
gl/calloc.c
17
gl/calloc.c
|
|
@ -1,6 +1,6 @@
|
|||
/* calloc() function that is glibc compatible.
|
||||
This wrapper function is required at least on Tru64 UNIX 5.1 and mingw.
|
||||
Copyright (C) 2004-2007, 2009-2024 Free Software Foundation, Inc.
|
||||
Copyright (C) 2004-2007, 2009-2025 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
|
||||
|
|
@ -17,17 +17,15 @@
|
|||
|
||||
/* written by Jim Meyering and Bruno Haible */
|
||||
|
||||
/* Ensure that we call the system's calloc() below. */
|
||||
#define _GL_USE_STDLIB_ALLOC 1
|
||||
#include <config.h>
|
||||
|
||||
/* Specification. */
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
#include "xalloc-oversized.h"
|
||||
|
||||
/* Call the system's calloc below. */
|
||||
#undef calloc
|
||||
#include <stdckdint.h>
|
||||
|
||||
/* Allocate and zero-fill an NxS-byte block of memory from the heap,
|
||||
even if N or S is zero. */
|
||||
|
|
@ -35,14 +33,19 @@
|
|||
void *
|
||||
rpl_calloc (size_t n, size_t s)
|
||||
{
|
||||
#if !HAVE_MALLOC_0_NONNULL
|
||||
if (n == 0 || s == 0)
|
||||
n = s = 1;
|
||||
#endif
|
||||
|
||||
if (xalloc_oversized (n, s))
|
||||
#if !HAVE_MALLOC_PTRDIFF
|
||||
ptrdiff_t signed_n;
|
||||
if (ckd_mul (&signed_n, n, s))
|
||||
{
|
||||
errno = ENOMEM;
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
void *result = calloc (n, s);
|
||||
|
||||
|
|
|
|||
16
gl/cdefs.h
16
gl/cdefs.h
|
|
@ -1,4 +1,4 @@
|
|||
/* Copyright (C) 1992-2024 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1992-2025 Free Software Foundation, Inc.
|
||||
Copyright The GNU Toolchain Authors.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
|
|
@ -83,7 +83,7 @@
|
|||
# define __NTH(fct) __attribute__ ((__nothrow__ __LEAF)) fct
|
||||
# define __NTHNL(fct) __attribute__ ((__nothrow__)) fct
|
||||
# else
|
||||
# if defined __cplusplus && (__GNUC_PREREQ (2,8) || __clang_major >= 4)
|
||||
# if defined __cplusplus && (__GNUC_PREREQ (2,8) || __clang_major__ >= 4)
|
||||
# if __cplusplus >= 201103L
|
||||
# define __THROW noexcept (true)
|
||||
# else
|
||||
|
|
@ -277,10 +277,10 @@
|
|||
*/
|
||||
#endif
|
||||
|
||||
/* GCC and clang have various useful declarations that can be made with
|
||||
the '__attribute__' syntax. All of the ways we use this do fine if
|
||||
they are omitted for compilers that don't understand it. */
|
||||
#if !(defined __GNUC__ || defined __clang__)
|
||||
/* GCC, clang, and compatible compilers have various useful declarations
|
||||
that can be made with the '__attribute__' syntax. All of the ways we use
|
||||
this do fine if they are omitted for compilers that don't understand it. */
|
||||
#if !(defined __GNUC__ || defined __clang__ || defined __TINYC__)
|
||||
# define __attribute__(xyz) /* Ignore */
|
||||
#endif
|
||||
|
||||
|
|
@ -482,7 +482,7 @@
|
|||
run in pedantic mode if the uses are carefully marked using the
|
||||
`__extension__' keyword. But this is not generally available before
|
||||
version 2.8. */
|
||||
#if !(__GNUC_PREREQ (2,8) || defined __clang__)
|
||||
#if ! (__GNUC_PREREQ (2,8) || defined __clang__ || 0x5150 <= __SUNPRO_C)
|
||||
# define __extension__ /* Ignore */
|
||||
#endif
|
||||
|
||||
|
|
@ -497,7 +497,7 @@
|
|||
# endif
|
||||
#endif
|
||||
|
||||
/* ISO C99 also allows to declare arrays as non-overlapping. The syntax is
|
||||
/* ISO C99 also allows declaring arrays as non-overlapping. The syntax is
|
||||
array_name[restrict]
|
||||
GCC 3.1 and clang support this.
|
||||
This syntax is not usable in C++ mode. */
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/* cloexec.c - set or clear the close-on-exec descriptor flag
|
||||
|
||||
Copyright (C) 1991, 2004-2006, 2009-2024 Free Software Foundation, Inc.
|
||||
Copyright (C) 1991, 2004-2006, 2009-2025 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
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/* cloexec.c - set or clear the close-on-exec descriptor flag
|
||||
|
||||
Copyright (C) 2004, 2009-2024 Free Software Foundation, Inc.
|
||||
Copyright (C) 2004, 2009-2025 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
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* close replacement.
|
||||
Copyright (C) 2008-2024 Free Software Foundation, Inc.
|
||||
Copyright (C) 2008-2025 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
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/* dirname.c -- return all but the last element in a file name
|
||||
|
||||
Copyright (C) 1990, 1998, 2000-2001, 2003-2006, 2009-2024 Free Software
|
||||
Copyright (C) 1990, 1998, 2000-2001, 2003-2006, 2009-2025 Free Software
|
||||
Foundation, Inc.
|
||||
|
||||
This file is free software: you can redistribute it and/or modify
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/* dirname.c -- return all but the last element in a file name
|
||||
|
||||
Copyright (C) 1990, 1998, 2000-2001, 2003-2006, 2009-2024 Free Software
|
||||
Copyright (C) 1990, 1998, 2000-2001, 2003-2006, 2009-2025 Free Software
|
||||
Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/* Take file names apart into directory and base names.
|
||||
|
||||
Copyright (C) 1998, 2001, 2003-2006, 2009-2024 Free Software Foundation,
|
||||
Copyright (C) 1998, 2001, 2003-2006, 2009-2025 Free Software Foundation,
|
||||
Inc.
|
||||
|
||||
This file is free software: you can redistribute it and/or modify
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/* Duplicate an open file descriptor to a specified file descriptor.
|
||||
|
||||
Copyright (C) 1999, 2004-2007, 2009-2024 Free Software Foundation, Inc.
|
||||
Copyright (C) 1999, 2004-2007, 2009-2025 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
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* Type-safe arrays which grow dynamically.
|
||||
Copyright 2021-2024 Free Software Foundation, Inc.
|
||||
Copyright 2021-2025 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
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/* A POSIX-like <errno.h>.
|
||||
|
||||
Copyright (C) 2008-2024 Free Software Foundation, Inc.
|
||||
Copyright (C) 2008-2025 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
|
||||
|
|
@ -133,7 +133,7 @@
|
|||
|
||||
/* These are intentionally the same values as the WSA* error numbers, defined
|
||||
in <winsock2.h>. */
|
||||
# define ESOCKTNOSUPPORT 10044 /* not required by POSIX */
|
||||
# define ESOCKTNOSUPPORT 10044
|
||||
# define EPFNOSUPPORT 10046 /* not required by POSIX */
|
||||
# define ESHUTDOWN 10058 /* not required by POSIX */
|
||||
# define ETOOMANYREFS 10059 /* not required by POSIX */
|
||||
|
|
@ -270,10 +270,17 @@
|
|||
# define GNULIB_defined_ENOTRECOVERABLE 1
|
||||
# endif
|
||||
|
||||
/* On LynxOS, the macro EILSEQ is not defined. */
|
||||
# ifndef EILSEQ
|
||||
# define EILSEQ 2015
|
||||
# define GNULIB_defined_EILSEQ 1
|
||||
# endif
|
||||
|
||||
/* On Haiku, the macro ESOCKTNOSUPPORT is not defined. */
|
||||
# ifndef ESOCKTNOSUPPORT
|
||||
# define ESOCKTNOSUPPORT 2016
|
||||
# define GNULIB_defined_ESOCKTNOSUPPORT 1
|
||||
# endif
|
||||
|
||||
#endif /* _@GUARD_PREFIX@_ERRNO_H */
|
||||
#endif /* _@GUARD_PREFIX@_ERRNO_H */
|
||||
|
|
|
|||
177
gl/error.c
177
gl/error.c
|
|
@ -1,25 +1,32 @@
|
|||
/* Error handler for noninteractive utilities
|
||||
Copyright (C) 1990-1998, 2000-2007, 2009-2024 Free Software Foundation, Inc.
|
||||
Copyright (C) 1990-2025 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
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.
|
||||
The GNU C Library 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,
|
||||
The GNU C Library 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.
|
||||
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 <https://www.gnu.org/licenses/>. */
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with the GNU C Library; if not, see
|
||||
<https://www.gnu.org/licenses/>. */
|
||||
|
||||
/* Written by David MacKenzie <djm@gnu.ai.mit.edu>. */
|
||||
|
||||
#if !_LIBC
|
||||
# include <config.h>
|
||||
# define _GL_NO_INLINE_ERROR
|
||||
# define __error_internal(status, err, fmt, args, flags) \
|
||||
verror (status, err, fmt, args)
|
||||
# define __error_at_line_internal(status, err, file, line, fmt, args, flags) \
|
||||
verror_at_line (status, err, file, line, fmt, args)
|
||||
# define error_tail(status, err, fmt, args, flags) \
|
||||
error_tail (status, err, fmt, args)
|
||||
#endif
|
||||
|
||||
#include <error.h>
|
||||
|
|
@ -31,7 +38,7 @@
|
|||
|
||||
#if !_LIBC && ENABLE_NLS
|
||||
# include "gettext.h"
|
||||
# define _(msgid) gettext (msgid)
|
||||
# define _(msgid) dgettext ("gnulib", msgid)
|
||||
#endif
|
||||
|
||||
#ifdef _LIBC
|
||||
|
|
@ -85,7 +92,7 @@ extern void __error_at_line (int status, int errnum, const char *file_name,
|
|||
# undef putc
|
||||
# define putc(c, fp) _IO_putc (c, fp)
|
||||
|
||||
# include <bits/libc-lock.h>
|
||||
# include <libc-lock.h>
|
||||
|
||||
#else /* not _LIBC */
|
||||
|
||||
|
|
@ -123,6 +130,13 @@ int strerror_r (int errnum, char *buf, size_t buflen);
|
|||
# if GNULIB_STRERROR_R_POSIX || HAVE_STRERROR_R || defined strerror_r
|
||||
# define __strerror_r strerror_r
|
||||
# endif /* GNULIB_STRERROR_R_POSIX || HAVE_STRERROR_R || defined strerror_r */
|
||||
|
||||
# if GNULIB_defined_verror
|
||||
# undef verror
|
||||
# endif
|
||||
# if GNULIB_defined_verror_at_line
|
||||
# undef verror_at_line
|
||||
# endif
|
||||
#endif /* not _LIBC */
|
||||
|
||||
#if !_LIBC
|
||||
|
|
@ -151,8 +165,8 @@ flush_stdout (void)
|
|||
#if !_LIBC
|
||||
int stdout_fd;
|
||||
|
||||
# if GNULIB_FREOPEN_SAFER
|
||||
/* Use of gnulib's freopen-safer module normally ensures that
|
||||
# if GNULIB_FREOPEN_SAFER || GNULIB_XSTDOPEN
|
||||
/* Gnulib's freopen-safer and/or xstdopen modules normally ensure that
|
||||
fileno (stdout) == 1
|
||||
whenever stdout is open. */
|
||||
stdout_fd = STDOUT_FILENO;
|
||||
|
|
@ -183,7 +197,7 @@ print_errno_message (int errnum)
|
|||
if (__strerror_r (errnum, errbuf, sizeof errbuf) == 0)
|
||||
s = errbuf;
|
||||
else
|
||||
s = 0;
|
||||
s = NULL;
|
||||
# endif
|
||||
#else
|
||||
s = strerror (errnum);
|
||||
|
|
@ -202,75 +216,18 @@ print_errno_message (int errnum)
|
|||
}
|
||||
|
||||
static void _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (3, 0) _GL_ARG_NONNULL ((3))
|
||||
error_tail (int status, int errnum, const char *message, va_list args)
|
||||
error_tail (int status, int errnum, const char *message, va_list args,
|
||||
unsigned int mode_flags)
|
||||
{
|
||||
#if _LIBC
|
||||
if (_IO_fwide (stderr, 0) > 0)
|
||||
{
|
||||
size_t len = strlen (message) + 1;
|
||||
wchar_t *wmessage = NULL;
|
||||
mbstate_t st;
|
||||
size_t res;
|
||||
const char *tmp;
|
||||
bool use_malloc = false;
|
||||
|
||||
while (1)
|
||||
{
|
||||
if (__libc_use_alloca (len * sizeof (wchar_t)))
|
||||
wmessage = (wchar_t *) alloca (len * sizeof (wchar_t));
|
||||
else
|
||||
{
|
||||
if (!use_malloc)
|
||||
wmessage = NULL;
|
||||
|
||||
wchar_t *p = (wchar_t *) realloc (wmessage,
|
||||
len * sizeof (wchar_t));
|
||||
if (p == NULL)
|
||||
{
|
||||
free (wmessage);
|
||||
fputws_unlocked (L"out of memory\n", stderr);
|
||||
return;
|
||||
}
|
||||
wmessage = p;
|
||||
use_malloc = true;
|
||||
}
|
||||
|
||||
memset (&st, '\0', sizeof (st));
|
||||
tmp = message;
|
||||
|
||||
res = mbsrtowcs (wmessage, &tmp, len, &st);
|
||||
if (res != len)
|
||||
break;
|
||||
|
||||
if (__builtin_expect (len >= SIZE_MAX / sizeof (wchar_t) / 2, 0))
|
||||
{
|
||||
/* This really should not happen if everything is fine. */
|
||||
res = (size_t) -1;
|
||||
break;
|
||||
}
|
||||
|
||||
len *= 2;
|
||||
}
|
||||
|
||||
if (res == (size_t) -1)
|
||||
{
|
||||
/* The string cannot be converted. */
|
||||
if (use_malloc)
|
||||
{
|
||||
free (wmessage);
|
||||
use_malloc = false;
|
||||
}
|
||||
wmessage = (wchar_t *) L"???";
|
||||
}
|
||||
|
||||
__vfwprintf (stderr, wmessage, args);
|
||||
|
||||
if (use_malloc)
|
||||
free (wmessage);
|
||||
}
|
||||
else
|
||||
int ret = __vfxprintf (stderr, message, args, mode_flags);
|
||||
if (ret < 0 && errno == ENOMEM && _IO_fwide (stderr, 0) > 0)
|
||||
/* Leave a trace in case the heap allocation of the message string
|
||||
failed. */
|
||||
fputws_unlocked (L"out of memory\n", stderr);
|
||||
#else
|
||||
vfprintf (stderr, message, args);
|
||||
#endif
|
||||
vfprintf (stderr, message, args);
|
||||
|
||||
++error_message_count;
|
||||
if (errnum)
|
||||
|
|
@ -291,16 +248,14 @@ error_tail (int status, int errnum, const char *message, va_list args)
|
|||
If ERRNUM is nonzero, print its corresponding system error message.
|
||||
Exit with status STATUS if it is nonzero. */
|
||||
void
|
||||
error (int status, int errnum, const char *message, ...)
|
||||
__error_internal (int status, int errnum, const char *message,
|
||||
va_list args, unsigned int mode_flags)
|
||||
{
|
||||
va_list args;
|
||||
|
||||
#if defined _LIBC && defined __libc_ptf_call
|
||||
#if defined _LIBC
|
||||
/* We do not want this call to be cut short by a thread
|
||||
cancellation. Therefore disable cancellation for now. */
|
||||
int state = PTHREAD_CANCEL_ENABLE;
|
||||
__libc_ptf_call (pthread_setcancelstate, (PTHREAD_CANCEL_DISABLE, &state),
|
||||
0);
|
||||
__pthread_setcancelstate (PTHREAD_CANCEL_DISABLE, &state);
|
||||
#endif
|
||||
|
||||
flush_stdout ();
|
||||
|
|
@ -318,28 +273,32 @@ error (int status, int errnum, const char *message, ...)
|
|||
#endif
|
||||
}
|
||||
|
||||
va_start (args, message);
|
||||
error_tail (status, errnum, message, args);
|
||||
va_end (args);
|
||||
error_tail (status, errnum, message, args, mode_flags);
|
||||
|
||||
#ifdef _LIBC
|
||||
_IO_funlockfile (stderr);
|
||||
# ifdef __libc_ptf_call
|
||||
__libc_ptf_call (pthread_setcancelstate, (state, NULL), 0);
|
||||
# endif
|
||||
__pthread_setcancelstate (state, NULL);
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
error (int status, int errnum, const char *message, ...)
|
||||
{
|
||||
va_list ap;
|
||||
va_start (ap, message);
|
||||
__error_internal (status, errnum, message, ap, 0);
|
||||
va_end (ap);
|
||||
}
|
||||
|
||||
/* Sometimes we want to have at most one error per line. This
|
||||
variable controls whether this mode is selected or not. */
|
||||
int error_one_per_line;
|
||||
|
||||
void
|
||||
error_at_line (int status, int errnum, const char *file_name,
|
||||
unsigned int line_number, const char *message, ...)
|
||||
__error_at_line_internal (int status, int errnum, const char *file_name,
|
||||
unsigned int line_number, const char *message,
|
||||
va_list args, unsigned int mode_flags)
|
||||
{
|
||||
va_list args;
|
||||
|
||||
if (error_one_per_line)
|
||||
{
|
||||
static const char *old_file_name;
|
||||
|
|
@ -358,12 +317,11 @@ error_at_line (int status, int errnum, const char *file_name,
|
|||
old_line_number = line_number;
|
||||
}
|
||||
|
||||
#if defined _LIBC && defined __libc_ptf_call
|
||||
#if defined _LIBC
|
||||
/* We do not want this call to be cut short by a thread
|
||||
cancellation. Therefore disable cancellation for now. */
|
||||
int state = PTHREAD_CANCEL_ENABLE;
|
||||
__libc_ptf_call (pthread_setcancelstate, (PTHREAD_CANCEL_DISABLE, &state),
|
||||
0);
|
||||
__pthread_setcancelstate (PTHREAD_CANCEL_DISABLE, &state);
|
||||
#endif
|
||||
|
||||
flush_stdout ();
|
||||
|
|
@ -389,18 +347,25 @@ error_at_line (int status, int errnum, const char *file_name,
|
|||
file_name, line_number);
|
||||
#endif
|
||||
|
||||
va_start (args, message);
|
||||
error_tail (status, errnum, message, args);
|
||||
va_end (args);
|
||||
error_tail (status, errnum, message, args, mode_flags);
|
||||
|
||||
#ifdef _LIBC
|
||||
_IO_funlockfile (stderr);
|
||||
# ifdef __libc_ptf_call
|
||||
__libc_ptf_call (pthread_setcancelstate, (state, NULL), 0);
|
||||
# endif
|
||||
__pthread_setcancelstate (state, NULL);
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
error_at_line (int status, int errnum, const char *file_name,
|
||||
unsigned int line_number, const char *message, ...)
|
||||
{
|
||||
va_list ap;
|
||||
va_start (ap, message);
|
||||
__error_at_line_internal (status, errnum, file_name, line_number,
|
||||
message, ap, 0);
|
||||
va_end (ap);
|
||||
}
|
||||
|
||||
#ifdef _LIBC
|
||||
/* Make the weak alias. */
|
||||
# undef error
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* Declarations for error-reporting functions.
|
||||
Copyright (C) 1995-1997, 2003, 2006, 2008-2024 Free Software Foundation,
|
||||
Copyright (C) 1995-1997, 2003, 2006, 2008-2025 Free Software Foundation,
|
||||
Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
|
|
@ -23,20 +23,23 @@
|
|||
or error_at_line(...) invocations. */
|
||||
|
||||
/* The include_next requires a split double-inclusion guard. */
|
||||
#if @HAVE_ERROR_H@
|
||||
#if @HAVE_ERROR_H@ && !defined __MINGW32__
|
||||
# @INCLUDE_NEXT@ @NEXT_ERROR_H@
|
||||
#endif
|
||||
|
||||
#ifndef _@GUARD_PREFIX@_ERROR_H
|
||||
#define _@GUARD_PREFIX@_ERROR_H
|
||||
|
||||
/* This file uses _GL_ATTRIBUTE_ALWAYS_INLINE, _GL_ATTRIBUTE_FORMAT,
|
||||
_GL_ATTRIBUTE_MAYBE_UNUSED. */
|
||||
/* This file uses _GL_ATTRIBUTE_ALWAYS_INLINE, _GL_ATTRIBUTE_COLD,
|
||||
_GL_ATTRIBUTE_FORMAT, _GL_ATTRIBUTE_MAYBE_UNUSED. */
|
||||
#if !_GL_CONFIG_H_INCLUDED
|
||||
#error "Please include config.h first."
|
||||
#endif
|
||||
|
||||
/* Get 'unreachable'. */
|
||||
/* Get va_list. */
|
||||
#include <stdarg.h>
|
||||
|
||||
/* Get 'gl_unreachable'. */
|
||||
#include <stddef.h>
|
||||
|
||||
/* Get _GL_ATTRIBUTE_SPEC_PRINTF_STANDARD, _GL_ATTRIBUTE_SPEC_PRINTF_SYSTEM. */
|
||||
|
|
@ -54,11 +57,11 @@
|
|||
It evaluates its arguments only once.
|
||||
Test case: Compile copy-file.c with "gcc -Wimplicit-fallthrough". */
|
||||
#if defined __GNUC__ || defined __clang__
|
||||
/* Use 'unreachable' to tell the compiler when the function call does not
|
||||
/* Use 'gl_unreachable' to tell the compiler when the function call does not
|
||||
return. */
|
||||
# define __gl_error_call1(function, status, ...) \
|
||||
((function) (status, __VA_ARGS__), \
|
||||
(status) != 0 ? unreachable () : (void) 0)
|
||||
(status) != 0 ? gl_unreachable () : (void) 0)
|
||||
/* If STATUS is a not a constant, the function call may or may not return;
|
||||
therefore -Wimplicit-fallthrough will produce a warning. Use a compound
|
||||
statement in order to evaluate STATUS only once.
|
||||
|
|
@ -92,7 +95,8 @@ extern "C" {
|
|||
# define error rpl_error
|
||||
# endif
|
||||
_GL_FUNCDECL_RPL (error, void,
|
||||
(int __status, int __errnum, const char *__format, ...)
|
||||
(int __status, int __errnum, const char *__format, ...),
|
||||
_GL_ATTRIBUTE_COLD
|
||||
_GL_ATTRIBUTE_FORMAT ((_GL_ATTRIBUTE_SPEC_PRINTF_ERROR, 3, 4)));
|
||||
_GL_CXXALIAS_RPL (error, void,
|
||||
(int __status, int __errnum, const char *__format, ...));
|
||||
|
|
@ -104,7 +108,8 @@ _GL_CXXALIAS_RPL (error, void,
|
|||
#else
|
||||
# if ! @HAVE_ERROR@
|
||||
_GL_FUNCDECL_SYS (error, void,
|
||||
(int __status, int __errnum, const char *__format, ...)
|
||||
(int __status, int __errnum, const char *__format, ...),
|
||||
_GL_ATTRIBUTE_COLD
|
||||
_GL_ATTRIBUTE_FORMAT ((_GL_ATTRIBUTE_SPEC_PRINTF_ERROR, 3, 4)));
|
||||
# endif
|
||||
_GL_CXXALIAS_SYS (error, void,
|
||||
|
|
@ -117,7 +122,7 @@ _GL_CXXALIAS_SYS (error, void,
|
|||
# pragma GCC diagnostic ignored "-Wattributes"
|
||||
_GL_ATTRIBUTE_MAYBE_UNUSED
|
||||
static void
|
||||
_GL_ATTRIBUTE_ALWAYS_INLINE
|
||||
_GL_ATTRIBUTE_ALWAYS_INLINE _GL_ATTRIBUTE_COLD
|
||||
_GL_ATTRIBUTE_FORMAT ((_GL_ATTRIBUTE_SPEC_PRINTF_ERROR, 3, 4))
|
||||
_gl_inline_error (int __status, int __errnum, const char *__format, ...)
|
||||
{
|
||||
|
|
@ -147,7 +152,8 @@ _GL_CXXALIASWARN (error);
|
|||
# endif
|
||||
_GL_FUNCDECL_RPL (error_at_line, void,
|
||||
(int __status, int __errnum, const char *__filename,
|
||||
unsigned int __lineno, const char *__format, ...)
|
||||
unsigned int __lineno, const char *__format, ...),
|
||||
_GL_ATTRIBUTE_COLD
|
||||
_GL_ATTRIBUTE_FORMAT ((_GL_ATTRIBUTE_SPEC_PRINTF_ERROR, 5, 6)));
|
||||
_GL_CXXALIAS_RPL (error_at_line, void,
|
||||
(int __status, int __errnum, const char *__filename,
|
||||
|
|
@ -161,7 +167,8 @@ _GL_CXXALIAS_RPL (error_at_line, void,
|
|||
# if ! @HAVE_ERROR_AT_LINE@
|
||||
_GL_FUNCDECL_SYS (error_at_line, void,
|
||||
(int __status, int __errnum, const char *__filename,
|
||||
unsigned int __lineno, const char *__format, ...)
|
||||
unsigned int __lineno, const char *__format, ...),
|
||||
_GL_ATTRIBUTE_COLD
|
||||
_GL_ATTRIBUTE_FORMAT ((_GL_ATTRIBUTE_SPEC_PRINTF_ERROR, 5, 6)));
|
||||
# endif
|
||||
_GL_CXXALIAS_SYS (error_at_line, void,
|
||||
|
|
@ -175,7 +182,7 @@ _GL_CXXALIAS_SYS (error_at_line, void,
|
|||
# pragma GCC diagnostic ignored "-Wattributes"
|
||||
_GL_ATTRIBUTE_MAYBE_UNUSED
|
||||
static void
|
||||
_GL_ATTRIBUTE_ALWAYS_INLINE
|
||||
_GL_ATTRIBUTE_ALWAYS_INLINE _GL_ATTRIBUTE_COLD
|
||||
_GL_ATTRIBUTE_FORMAT ((_GL_ATTRIBUTE_SPEC_PRINTF_ERROR, 5, 6))
|
||||
_gl_inline_error_at_line (int __status, int __errnum, const char *__filename,
|
||||
unsigned int __lineno, const char *__format, ...)
|
||||
|
|
@ -196,6 +203,44 @@ _gl_inline_error_at_line (int __status, int __errnum, const char *__filename,
|
|||
#endif
|
||||
_GL_CXXALIASWARN (error_at_line);
|
||||
|
||||
/* Print a message with 'vfprintf (stderr, FORMAT, ARGS)';
|
||||
if ERRNUM is nonzero, follow it with ": " and strerror (ERRNUM).
|
||||
If STATUS is nonzero, terminate the program with 'exit (STATUS)'.
|
||||
Use the globals error_print_progname and error_message_count similarly
|
||||
to error(). */
|
||||
|
||||
extern void verror (int __status, int __errnum, const char *__format,
|
||||
va_list __args)
|
||||
_GL_ATTRIBUTE_COLD
|
||||
_GL_ATTRIBUTE_FORMAT ((_GL_ATTRIBUTE_SPEC_PRINTF_STANDARD, 3, 0));
|
||||
#ifndef _GL_NO_INLINE_ERROR
|
||||
# ifndef verror
|
||||
# define verror(status, ...) \
|
||||
__gl_error_call (verror, status, __VA_ARGS__)
|
||||
# define GNULIB_defined_verror 1
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Print a message with 'vfprintf (stderr, FORMAT, ARGS)';
|
||||
if ERRNUM is nonzero, follow it with ": " and strerror (ERRNUM).
|
||||
If STATUS is nonzero, terminate the program with 'exit (STATUS)'.
|
||||
If FNAME is not NULL, prepend the message with "FNAME:LINENO:".
|
||||
Use the globals error_print_progname, error_message_count, and
|
||||
error_one_per_line similarly to error_at_line(). */
|
||||
|
||||
extern void verror_at_line (int __status, int __errnum, const char *__fname,
|
||||
unsigned int __lineno, const char *__format,
|
||||
va_list __args)
|
||||
_GL_ATTRIBUTE_COLD
|
||||
_GL_ATTRIBUTE_FORMAT ((_GL_ATTRIBUTE_SPEC_PRINTF_STANDARD, 5, 0));
|
||||
#ifdef _GL_NO_INLINE_ERROR
|
||||
# ifndef verror_at_line
|
||||
# define verror_at_line(status, ...) \
|
||||
__gl_error_call (verror_at_line, status, __VA_ARGS__)
|
||||
# define GNULIB_defined_verror_at_line 1
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* If NULL, error will flush stdout, then print on stderr the program
|
||||
name, a colon and a space. Otherwise, error will call this
|
||||
function without parameters instead. */
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/* Failure exit status
|
||||
|
||||
Copyright (C) 2002-2003, 2005-2007, 2009-2024 Free Software Foundation, Inc.
|
||||
Copyright (C) 2002-2003, 2005-2007, 2009-2025 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
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/* Failure exit status
|
||||
|
||||
Copyright (C) 2002, 2009-2024 Free Software Foundation, Inc.
|
||||
Copyright (C) 2002, 2009-2025 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
|
||||
|
|
|
|||
47
gl/fcntl.c
47
gl/fcntl.c
|
|
@ -1,6 +1,6 @@
|
|||
/* Provide file descriptor control.
|
||||
|
||||
Copyright (C) 2009-2024 Free Software Foundation, Inc.
|
||||
Copyright (C) 2009-2025 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
|
||||
|
|
@ -29,8 +29,7 @@
|
|||
#include <unistd.h>
|
||||
|
||||
#ifdef __KLIBC__
|
||||
# define INCL_DOS
|
||||
# include <os2.h>
|
||||
# include <emx/io.h>
|
||||
#endif
|
||||
|
||||
#if defined _WIN32 && ! defined __CYGWIN__
|
||||
|
|
@ -562,7 +561,8 @@ klibc_fcntl (int fd, int action, /* arg */...)
|
|||
if (result == -1 && (errno == EPERM || errno == ENOTSUP)
|
||||
&& !fstat (fd, &sbuf) && S_ISDIR (sbuf.st_mode))
|
||||
{
|
||||
ULONG ulMode;
|
||||
PLIBCFH pFH;
|
||||
unsigned fFlags;
|
||||
|
||||
switch (action)
|
||||
{
|
||||
|
|
@ -574,34 +574,41 @@ klibc_fcntl (int fd, int action, /* arg */...)
|
|||
result = dup2 (fd, arg);
|
||||
break;
|
||||
|
||||
/* Using underlying APIs is right ? */
|
||||
case F_GETFD:
|
||||
if (DosQueryFHState (fd, &ulMode))
|
||||
break;
|
||||
pFH = __libc_FH (fd);
|
||||
if (!pFH)
|
||||
{
|
||||
errno = EBADF;
|
||||
break;
|
||||
}
|
||||
|
||||
result = (ulMode & OPEN_FLAGS_NOINHERIT) ? FD_CLOEXEC : 0;
|
||||
result = (pFH->fFlags & ((FD_CLOEXEC << __LIBC_FH_FDFLAGS_SHIFT )
|
||||
| O_NOINHERIT)) ? FD_CLOEXEC : 0;
|
||||
break;
|
||||
|
||||
case F_SETFD:
|
||||
if (arg & ~FD_CLOEXEC)
|
||||
break;
|
||||
|
||||
if (DosQueryFHState (fd, &ulMode))
|
||||
break;
|
||||
pFH = __libc_FH (fd);
|
||||
if (!pFH)
|
||||
{
|
||||
errno = EBADF;
|
||||
break;
|
||||
}
|
||||
|
||||
fFlags = pFH->fFlags;
|
||||
if (arg & FD_CLOEXEC)
|
||||
ulMode |= OPEN_FLAGS_NOINHERIT;
|
||||
fFlags |= (FD_CLOEXEC << __LIBC_FH_FDFLAGS_SHIFT) | O_NOINHERIT;
|
||||
else
|
||||
ulMode &= ~OPEN_FLAGS_NOINHERIT;
|
||||
fFlags &= ~((FD_CLOEXEC << __LIBC_FH_FDFLAGS_SHIFT) | O_NOINHERIT);
|
||||
|
||||
/* Filter supported flags. */
|
||||
ulMode &= (OPEN_FLAGS_WRITE_THROUGH | OPEN_FLAGS_FAIL_ON_ERROR
|
||||
| OPEN_FLAGS_NO_CACHE | OPEN_FLAGS_NOINHERIT);
|
||||
|
||||
if (DosSetFHState (fd, ulMode))
|
||||
break;
|
||||
|
||||
result = 0;
|
||||
result = __libc_FHSetFlags (pFH, fd, fFlags);
|
||||
if (result < 0)
|
||||
{
|
||||
errno = -result;
|
||||
result = -1;
|
||||
}
|
||||
break;
|
||||
|
||||
case F_GETFL:
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/* Like <fcntl.h>, but with non-working flags defined to 0.
|
||||
|
||||
Copyright (C) 2006-2024 Free Software Foundation, Inc.
|
||||
Copyright (C) 2006-2025 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
|
||||
|
|
@ -22,8 +22,12 @@
|
|||
#endif
|
||||
@PRAGMA_COLUMNS@
|
||||
|
||||
#if defined __need_system_fcntl_h
|
||||
/* Special invocation convention. */
|
||||
#if defined __need_system_fcntl_h || defined _@GUARD_PREFIX@_ALREADY_INCLUDING_FCNTL_H
|
||||
/* Special invocation convention:
|
||||
- On Haiku we have a sequence of nested includes
|
||||
<fcntl.h> -> <unistd.h> -> <fcntl.h>
|
||||
In this situation, GNULIB_defined_O_NONBLOCK gets defined before the
|
||||
system's definition of O_NONBLOCK is processed. */
|
||||
|
||||
/* Needed before <sys/stat.h>.
|
||||
May also define off_t to a 64-bit type on native Windows. */
|
||||
|
|
@ -50,8 +54,11 @@
|
|||
|
||||
#ifndef _@GUARD_PREFIX@_FCNTL_H
|
||||
|
||||
#define _@GUARD_PREFIX@_ALREADY_INCLUDING_FCNTL_H
|
||||
|
||||
/* Needed before <sys/stat.h>.
|
||||
May also define off_t to a 64-bit type on native Windows. */
|
||||
May also define off_t to a 64-bit type on native Windows.
|
||||
Also defines off64_t on macOS, NetBSD, OpenBSD, MSVC, Cygwin, Haiku. */
|
||||
#include <sys/types.h>
|
||||
/* On some systems other than glibc, <sys/stat.h> is a prerequisite of
|
||||
<fcntl.h>. On glibc systems, we would like to avoid namespace pollution.
|
||||
|
|
@ -71,6 +78,8 @@
|
|||
# include <io.h>
|
||||
#endif
|
||||
|
||||
#undef _@GUARD_PREFIX@_ALREADY_INCLUDING_FCNTL_H
|
||||
|
||||
#ifndef _@GUARD_PREFIX@_FCNTL_H
|
||||
#define _@GUARD_PREFIX@_FCNTL_H
|
||||
|
||||
|
|
@ -99,7 +108,7 @@
|
|||
# undef creat
|
||||
# define creat rpl_creat
|
||||
# endif
|
||||
_GL_FUNCDECL_RPL (creat, int, (const char *filename, mode_t mode)
|
||||
_GL_FUNCDECL_RPL (creat, int, (const char *filename, mode_t mode),
|
||||
_GL_ARG_NONNULL ((1)));
|
||||
_GL_CXXALIAS_RPL (creat, int, (const char *filename, mode_t mode));
|
||||
# elif defined _WIN32 && !defined __CYGWIN__
|
||||
|
|
@ -140,14 +149,14 @@ _GL_CXXALIASWARN (creat);
|
|||
# undef fcntl
|
||||
# define fcntl rpl_fcntl
|
||||
# endif
|
||||
_GL_FUNCDECL_RPL (fcntl, int, (int fd, int action, ...));
|
||||
_GL_FUNCDECL_RPL (fcntl, int, (int fd, int action, ...), );
|
||||
_GL_CXXALIAS_RPL (fcntl, int, (int fd, int action, ...));
|
||||
# if !GNULIB_defined_rpl_fcntl
|
||||
# define GNULIB_defined_rpl_fcntl 1
|
||||
# endif
|
||||
# else
|
||||
# if !@HAVE_FCNTL@
|
||||
_GL_FUNCDECL_SYS (fcntl, int, (int fd, int action, ...));
|
||||
_GL_FUNCDECL_SYS (fcntl, int, (int fd, int action, ...), );
|
||||
# if !GNULIB_defined_fcntl
|
||||
# define GNULIB_defined_fcntl 1
|
||||
# endif
|
||||
|
|
@ -169,7 +178,7 @@ _GL_WARN_ON_USE (fcntl, "fcntl is not always POSIX compliant - "
|
|||
# undef open
|
||||
# define open rpl_open
|
||||
# endif
|
||||
_GL_FUNCDECL_RPL (open, int, (const char *filename, int flags, ...)
|
||||
_GL_FUNCDECL_RPL (open, int, (const char *filename, int flags, ...),
|
||||
_GL_ARG_NONNULL ((1)));
|
||||
_GL_CXXALIAS_RPL (open, int, (const char *filename, int flags, ...));
|
||||
# elif defined _WIN32 && !defined __CYGWIN__
|
||||
|
|
@ -200,7 +209,9 @@ _GL_WARN_ON_USE (open, "open is not always POSIX compliant - "
|
|||
# undef open
|
||||
# define open _open
|
||||
# endif
|
||||
_GL_CXXALIAS_MDA (open, int, (const char *filename, int flags, ...));
|
||||
/* Need to cast, because in MSVC the parameter list of _open as a C++ function
|
||||
is (const char *, int, int = 0). */
|
||||
_GL_CXXALIAS_MDA_CAST (open, int, (const char *filename, int flags, ...));
|
||||
# else
|
||||
_GL_CXXALIAS_SYS (open, int, (const char *filename, int flags, ...));
|
||||
# endif
|
||||
|
|
@ -216,14 +227,14 @@ _GL_CXXALIASWARN (open);
|
|||
# define openat rpl_openat
|
||||
# endif
|
||||
_GL_FUNCDECL_RPL (openat, int,
|
||||
(int fd, char const *file, int flags, /* mode_t mode */ ...)
|
||||
(int fd, char const *file, int flags, /* mode_t mode */ ...),
|
||||
_GL_ARG_NONNULL ((2)));
|
||||
_GL_CXXALIAS_RPL (openat, int,
|
||||
(int fd, char const *file, int flags, /* mode_t mode */ ...));
|
||||
# else
|
||||
# if !@HAVE_OPENAT@
|
||||
_GL_FUNCDECL_SYS (openat, int,
|
||||
(int fd, char const *file, int flags, /* mode_t mode */ ...)
|
||||
(int fd, char const *file, int flags, /* mode_t mode */ ...),
|
||||
_GL_ARG_NONNULL ((2)));
|
||||
# endif
|
||||
_GL_CXXALIAS_SYS (openat, int,
|
||||
|
|
@ -304,7 +315,7 @@ _GL_WARN_ON_USE (openat, "openat is not portable - "
|
|||
#endif
|
||||
|
||||
#ifndef O_DIRECTORY
|
||||
# define O_DIRECTORY 0
|
||||
# define O_DIRECTORY 0x20000000 /* Try to not collide with system O_* flags. */
|
||||
#endif
|
||||
|
||||
#ifndef O_DSYNC
|
||||
|
|
@ -368,8 +379,12 @@ _GL_WARN_ON_USE (openat, "openat is not portable - "
|
|||
# define O_RSYNC 0
|
||||
#endif
|
||||
|
||||
#if defined O_SEARCH && defined O_PATH && O_SEARCH == O_PATH
|
||||
# undef O_SEARCH /* musl mistakenly #defines O_SEARCH to O_PATH. */
|
||||
#endif
|
||||
|
||||
#ifndef O_SEARCH
|
||||
# define O_SEARCH O_RDONLY /* This is often close enough in older systems. */
|
||||
# define O_SEARCH O_RDONLY /* Often close enough in non-POSIX systems. */
|
||||
#endif
|
||||
|
||||
#ifndef O_SYNC
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* Hook for making file descriptor functions close(), ioctl() extensible.
|
||||
Copyright (C) 2009-2024 Free Software Foundation, Inc.
|
||||
Copyright (C) 2009-2025 Free Software Foundation, Inc.
|
||||
Written by Bruno Haible <bruno@clisp.org>, 2009.
|
||||
|
||||
This file is free software: you can redistribute it and/or modify
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* Hook for making file descriptor functions close(), ioctl() extensible.
|
||||
Copyright (C) 2009-2024 Free Software Foundation, Inc.
|
||||
Copyright (C) 2009-2025 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
|
||||
|
|
|
|||
15
gl/fflush.c
15
gl/fflush.c
|
|
@ -1,5 +1,5 @@
|
|||
/* fflush.c -- allow flushing input streams
|
||||
Copyright (C) 2007-2024 Free Software Foundation, Inc.
|
||||
Copyright (C) 2007-2025 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
|
||||
|
|
@ -33,12 +33,15 @@
|
|||
|
||||
#if defined _IO_EOF_SEEN || defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1
|
||||
/* GNU libc, BeOS, Haiku, Linux libc5 */
|
||||
# if !defined __HAIKU__
|
||||
# define fp_ fp
|
||||
# endif
|
||||
|
||||
/* Clear the stream's ungetc buffer, preserving the value of ftello (fp). */
|
||||
static void
|
||||
clear_ungetc_buffer_preserving_position (FILE *fp)
|
||||
{
|
||||
if (fp->_flags & _IO_IN_BACKUP)
|
||||
if (fp_->_flags & _IO_IN_BACKUP)
|
||||
/* _IO_free_backup_area is a bit complicated. Simply call fseek. */
|
||||
fseeko (fp, 0, SEEK_CUR);
|
||||
}
|
||||
|
|
@ -50,7 +53,7 @@ static void
|
|||
clear_ungetc_buffer (FILE *fp)
|
||||
{
|
||||
# if defined __sferror || defined __DragonFly__ || defined __ANDROID__
|
||||
/* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Minix 3, Android */
|
||||
/* FreeBSD, NetBSD, OpenBSD <= 7.7, DragonFly, Mac OS X, Cygwin, Minix 3, Android */
|
||||
if (HASUB (fp))
|
||||
{
|
||||
fp_->_p += fp_->_r;
|
||||
|
|
@ -75,7 +78,7 @@ clear_ungetc_buffer (FILE *fp)
|
|||
/* GNU libc, BeOS, Haiku, Linux libc5 */
|
||||
|
||||
# if (defined __sferror || defined __DragonFly__ || defined __ANDROID__) && defined __SNPT
|
||||
/* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Minix 3, Android */
|
||||
/* FreeBSD, NetBSD, OpenBSD <= 7.7, DragonFly, Mac OS X, Cygwin, Minix 3, Android */
|
||||
|
||||
static int
|
||||
disable_seek_optimization (FILE *fp)
|
||||
|
|
@ -98,7 +101,7 @@ update_fpos_cache (_GL_ATTRIBUTE_MAYBE_UNUSED FILE *fp,
|
|||
_GL_ATTRIBUTE_MAYBE_UNUSED off_t pos)
|
||||
{
|
||||
# if defined __sferror || defined __DragonFly__ || defined __ANDROID__
|
||||
/* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Minix 3, Android */
|
||||
/* FreeBSD, NetBSD, OpenBSD <= 7.7, DragonFly, Mac OS X, Cygwin, Minix 3, Android */
|
||||
# if defined __CYGWIN__ || defined __ANDROID__
|
||||
/* fp_->_offset is typed as an integer. */
|
||||
fp_->_offset = pos;
|
||||
|
|
@ -203,7 +206,7 @@ rpl_fflush (FILE *stream)
|
|||
}
|
||||
|
||||
# if (defined __sferror || defined __DragonFly__ || defined __ANDROID__) && defined __SNPT
|
||||
/* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Minix 3, Android */
|
||||
/* FreeBSD, NetBSD, OpenBSD <= 7.7, DragonFly, Mac OS X, Cygwin, Minix 3, Android */
|
||||
|
||||
{
|
||||
/* Disable seek optimization for the next fseeko call. This tells the
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* Basic filename support macros.
|
||||
Copyright (C) 2001-2024 Free Software Foundation, Inc.
|
||||
Copyright (C) 2001-2025 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* Supplemental information about the floating-point formats.
|
||||
Copyright (C) 2007, 2009-2024 Free Software Foundation, Inc.
|
||||
Copyright (C) 2007, 2009-2025 Free Software Foundation, Inc.
|
||||
Written by Bruno Haible <bruno@clisp.org>, 2007.
|
||||
|
||||
This file is free software: you can redistribute it and/or modify
|
||||
|
|
|
|||
99
gl/float.c
99
gl/float.c
|
|
@ -1,5 +1,5 @@
|
|||
/* Auxiliary definitions for <float.h>.
|
||||
Copyright (C) 2011-2024 Free Software Foundation, Inc.
|
||||
Copyright (C) 2011-2025 Free Software Foundation, Inc.
|
||||
Written by Bruno Haible <bruno@clisp.org>, 2011.
|
||||
|
||||
This file is free software: you can redistribute it and/or modify
|
||||
|
|
@ -20,14 +20,101 @@
|
|||
/* Specification. */
|
||||
#include <float.h>
|
||||
|
||||
#if (defined _ARCH_PPC || defined _POWER) && (defined _AIX || defined __linux__) && (LDBL_MANT_DIG == 106) && defined __GNUC__
|
||||
#if GNULIB_defined_long_double_union
|
||||
# if (defined _ARCH_PPC || defined _POWER) && (defined _AIX || defined __linux__) && (LDBL_MANT_DIG == 106) && defined __GNUC__
|
||||
const union gl_long_double_union gl_LDBL_MAX =
|
||||
{ { DBL_MAX, DBL_MAX / (double)134217728UL / (double)134217728UL } };
|
||||
#elif defined __i386__
|
||||
{ { DBL_MAX, DBL_MAX / 0x1p53 } };
|
||||
# elif defined __i386__
|
||||
const union gl_long_double_union gl_LDBL_MAX =
|
||||
{ { 0xFFFFFFFF, 0xFFFFFFFF, 32766 } };
|
||||
#else
|
||||
# endif
|
||||
# if defined __i386__ && (defined __FreeBSD__ || defined __DragonFly__)
|
||||
/* We can't even simply evaluate the formula (LDBL_MIN / 9223372036854775808.0L)
|
||||
at run time, because it would require BEGIN_LONG_DOUBLE_ROUNDING /
|
||||
END_LONG_DOUBLE_ROUNDING invocations. It simpler to just write down the
|
||||
representation of LDBL_TRUE_MIN, based on
|
||||
<https://en.wikipedia.org/wiki/Extended_precision#x86_extended_precision_format>. */
|
||||
const union gl_long_double_union gl_LDBL_TRUE_MIN =
|
||||
{ { 0x00000001, 0x00000000, 0 } };
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if GNULIB_defined_FLT_SNAN
|
||||
/* Define like memory_positive_SNaNf(), see signed-snan.h and snan.h,
|
||||
or like setpayloadsigf() with an arbitrary payload. */
|
||||
gl_FLT_SNAN_t gl_FLT_SNAN =
|
||||
# if FLT_MANT_DIG == 24
|
||||
# if defined __hppa || (defined __mips__ && !MIPS_NAN2008_FLOAT) || defined __sh__
|
||||
/* sign bit: 0, 8 exponent bits: all 1, next bit: 1, payload: 0b10...0 */
|
||||
{ { 0x7FE00000U } }
|
||||
# else
|
||||
/* sign bit: 0, 8 exponent bits: all 1, next bit: 0, payload: 0b10...0 */
|
||||
{ { 0x7FA00000U } }
|
||||
# endif
|
||||
# endif
|
||||
;
|
||||
#endif
|
||||
|
||||
#if GNULIB_defined_DBL_SNAN
|
||||
/* Define like memory_positive_SNaNd(), see signed-snan.h and snan.h,
|
||||
or like setpayloadsig() with an arbitrary payload. */
|
||||
gl_DBL_SNAN_t gl_DBL_SNAN =
|
||||
# if DBL_MANT_DIG == 53
|
||||
# if defined __hppa || (defined __mips__ && !MIPS_NAN2008_FLOAT) || defined __sh__
|
||||
/* sign bit: 0, 11 exponent bits: all 1, next bit: 1, payload: 0b10...0 */
|
||||
{ { 0x7FFC000000000000ULL } }
|
||||
# else
|
||||
/* sign bit: 0, 11 exponent bits: all 1, next bit: 0, payload: 0b10...0 */
|
||||
{ { 0x7FF4000000000000ULL } }
|
||||
# endif
|
||||
# endif
|
||||
;
|
||||
#endif
|
||||
|
||||
#if GNULIB_defined_LDBL_SNAN
|
||||
# ifdef WORDS_BIGENDIAN
|
||||
# define TWO(hi,lo) { hi, lo }
|
||||
# else
|
||||
# define TWO(hi,lo) { lo, hi }
|
||||
# endif
|
||||
/* Define like memory_positive_SNaNl(), see signed-snan.h and snan.h,
|
||||
or like setpayloadsigl() with an arbitrary payload. */
|
||||
gl_LDBL_SNAN_t gl_LDBL_SNAN =
|
||||
# if LDBL_MANT_DIG == 53 /* on arm, hppa, mips, sh, but also MSVC */
|
||||
# if defined __hppa || (defined __mips__ && !MIPS_NAN2008_FLOAT) || defined __sh__
|
||||
/* sign bit: 0, 11 exponent bits: all 1, next bit: 1, payload: 0b10...0 */
|
||||
{ { 0x7FFC000000000000ULL } }
|
||||
# else
|
||||
/* sign bit: 0, 11 exponent bits: all 1, next bit: 0, payload: 0b10...0 */
|
||||
{ { 0x7FF4000000000000ULL } }
|
||||
# endif
|
||||
# elif LDBL_MANT_DIG == 64 /* on i386, x86_64, ia64, m68k */
|
||||
# if defined __m68k__
|
||||
/* sign bit: 0, 15 exponent bits: all 1, 16 gap bits: all 0,
|
||||
always=1 bit: 1, next bit: 0, payload: 0b10...0 */
|
||||
{ { 0x7FFF0000ULL, 0xA0000000ULL, 0x00000000ULL } }
|
||||
# else
|
||||
/* sign bit: 0, 15 exponent bits: all 1, always=1 bit: 1, next bit: 0, payload: 0b10...0
|
||||
(see <https://en.wikipedia.org/wiki/Extended_precision#x86_extended_precision_format>) */
|
||||
{ TWO (0x00007FFFULL, 0xA000000000000000ULL) }
|
||||
# endif
|
||||
# elif LDBL_MANT_DIG == 106 /* on powerpc, powerpc64, powerpc64le */
|
||||
/* most-significant double:
|
||||
sign bit: 0, 11 exponent bits: all 1, next bit: 0, payload: 0b10...0,
|
||||
least-significant double: 0.0 */
|
||||
{ { 0x7FF4000000000000ULL, 0ULL } }
|
||||
# elif LDBL_MANT_DIG == 113 /* on alpha, arm64, loongarch64, mips64, riscv64, s390x, sparc64 */
|
||||
# if (defined __mips__ && !MIPS_NAN2008_FLOAT)
|
||||
/* sign bit: 0, 15 exponent bits: all 1, next bit: 1, payload: 0b10...0 */
|
||||
{ TWO (0x7FFFC00000000000ULL, 0ULL) }
|
||||
# else
|
||||
/* sign bit: 0, 15 exponent bits: all 1, next bit: 0, payload: 0b10...0 */
|
||||
{ TWO (0x7FFF400000000000ULL, 0ULL) }
|
||||
# endif
|
||||
# endif
|
||||
;
|
||||
#endif
|
||||
|
||||
/* This declaration is solely to ensure that after preprocessing
|
||||
this file is never empty. */
|
||||
typedef int dummy;
|
||||
#endif
|
||||
|
|
|
|||
221
gl/float.in.h
221
gl/float.in.h
|
|
@ -1,6 +1,6 @@
|
|||
/* A correct <float.h>.
|
||||
|
||||
Copyright (C) 2007-2024 Free Software Foundation, Inc.
|
||||
Copyright (C) 2007-2025 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
|
||||
|
|
@ -28,6 +28,8 @@
|
|||
#ifndef _@GUARD_PREFIX@_FLOAT_H
|
||||
#define _@GUARD_PREFIX@_FLOAT_H
|
||||
|
||||
/* ============================ ISO C99 support ============================ */
|
||||
|
||||
/* 'long double' properties. */
|
||||
|
||||
#if defined __i386__ && (defined __BEOS__ || defined __OpenBSD__)
|
||||
|
|
@ -111,44 +113,38 @@ extern const union gl_long_double_union gl_LDBL_MAX;
|
|||
# define LDBL_MAX_10_EXP 4932
|
||||
#endif
|
||||
|
||||
/* On AIX 7.1 with gcc 4.2, the values of LDBL_MIN_EXP, LDBL_MIN, LDBL_MAX are
|
||||
wrong.
|
||||
On Linux/PowerPC with gcc 4.4, the value of LDBL_MAX is wrong. */
|
||||
#if (defined _ARCH_PPC || defined _POWER) && defined _AIX && (LDBL_MANT_DIG == 106) && defined __GNUC__
|
||||
/* On PowerPC with gcc 15 when using __ibm128 long double, the value of
|
||||
LDBL_MIN_EXP, LDBL_MIN, LDBL_MAX, and LDBL_NORM_MAX are wrong. */
|
||||
#if (defined _ARCH_PPC && LDBL_MANT_DIG == 106 \
|
||||
&& defined __GNUC__)
|
||||
# undef LDBL_MIN_EXP
|
||||
# define LDBL_MIN_EXP DBL_MIN_EXP
|
||||
# undef LDBL_MIN_10_EXP
|
||||
# define LDBL_MIN_10_EXP DBL_MIN_10_EXP
|
||||
# undef LDBL_MIN
|
||||
# define LDBL_MIN 2.22507385850720138309023271733240406422e-308L /* DBL_MIN = 2^-1022 */
|
||||
#endif
|
||||
#if (defined _ARCH_PPC || defined _POWER) && (defined _AIX || defined __linux__) && (LDBL_MANT_DIG == 106) && defined __GNUC__
|
||||
# undef LDBL_MAX
|
||||
/* LDBL_MAX is represented as { 0x7FEFFFFF, 0xFFFFFFFF, 0x7C8FFFFF, 0xFFFFFFFF }.
|
||||
It is not easy to define:
|
||||
#define LDBL_MAX 1.79769313486231580793728971405302307166e308L
|
||||
is too small, whereas
|
||||
#define LDBL_MAX 1.79769313486231580793728971405302307167e308L
|
||||
is too large. Apparently a bug in GCC decimal-to-binary conversion.
|
||||
Also, I can't get values larger than
|
||||
#define LDBL63 ((long double) (1ULL << 63))
|
||||
#define LDBL882 (LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63)
|
||||
#define LDBL945 (LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63)
|
||||
#define LDBL1008 (LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63)
|
||||
#define LDBL_MAX (LDBL1008 * 65535.0L + LDBL945 * (long double) 9223372036821221375ULL + LDBL882 * (long double) 4611686018427387904ULL)
|
||||
which is represented as { 0x7FEFFFFF, 0xFFFFFFFF, 0x7C8FFFFF, 0xF8000000 }.
|
||||
So, define it like this through a reference to an external variable
|
||||
/* LDBL_MAX is 2**1024 - 2**918, represented as: { 0x7FEFFFFF, 0xFFFFFFFF,
|
||||
0x7C9FFFFF, 0xFFFFFFFF }.
|
||||
|
||||
const double LDBL_MAX[2] = { DBL_MAX, DBL_MAX / (double)134217728UL / (double)134217728UL };
|
||||
Do not write it as a constant expression, as GCC would likely treat
|
||||
that as infinity due to the vagaries of this platform's funky arithmetic.
|
||||
Instead, define it through a reference to an external variable.
|
||||
Like the following, but using a union to avoid type mismatches:
|
||||
|
||||
const double LDBL_MAX[2] = { DBL_MAX, DBL_MAX / 0x1p53 };
|
||||
extern const long double LDBL_MAX;
|
||||
|
||||
or through a pointer cast
|
||||
The following alternative would not work as well when GCC is optimizing:
|
||||
|
||||
#define LDBL_MAX \
|
||||
(*(const long double *) (double[]) { DBL_MAX, DBL_MAX / (double)134217728UL / (double)134217728UL })
|
||||
#define LDBL_MAX (*(long double const *) (double[])
|
||||
{ DBL_MAX, DBL_MAX / 0x1p53 })
|
||||
|
||||
Unfortunately, this is not a constant expression, and the latter expression
|
||||
does not work well when GCC is optimizing.. */
|
||||
The following alternative would require GCC 6 or later:
|
||||
|
||||
#define LDBL_MAX __builtin_pack_longdouble (DBL_MAX, DBL_MAX / 0x1p53)
|
||||
|
||||
Unfortunately none of the alternatives are constant expressions. */
|
||||
# if !GNULIB_defined_long_double_union
|
||||
union gl_long_double_union
|
||||
{
|
||||
|
|
@ -159,6 +155,8 @@ union gl_long_double_union
|
|||
# endif
|
||||
extern const union gl_long_double_union gl_LDBL_MAX;
|
||||
# define LDBL_MAX (gl_LDBL_MAX.ld)
|
||||
# undef LDBL_NORM_MAX
|
||||
# define LDBL_NORM_MAX LDBL_MAX
|
||||
#endif
|
||||
|
||||
/* On IRIX 6.5, with cc, the value of LDBL_MANT_DIG is wrong.
|
||||
|
|
@ -179,6 +177,175 @@ extern const union gl_long_double_union gl_LDBL_MAX;
|
|||
# endif
|
||||
#endif
|
||||
|
||||
/* On PowerPC platforms, 'long double' has a double-double representation.
|
||||
Up to ISO C 17, this was outside the scope of ISO C because it can represent
|
||||
numbers with mantissas of the form 1.<52 bits><many zeroes><52 bits>, such as
|
||||
1.0L + 4.94065645841246544176568792868221e-324L = 1 + 2^-1074; see
|
||||
ISO C 17 § 5.2.4.2.2.(3).
|
||||
In ISO C 23, wording has been included that makes this 'long double'
|
||||
representation compliant; see ISO C 23 § 5.2.5.3.3.(8)-(9). In this setting,
|
||||
numbers with mantissas of the form 1.<52 bits><many zeroes><52 bits> are
|
||||
called "unnormalized". And since LDBL_EPSILON must be normalized (per
|
||||
ISO C 23 § 5.2.5.3.3.(33)), it must be 2^-105. */
|
||||
#if defined __powerpc__ && LDBL_MANT_DIG == 106
|
||||
# undef LDBL_EPSILON
|
||||
# define LDBL_EPSILON 2.46519032881566189191165176650870696773e-32L /* 2^-105 */
|
||||
#endif
|
||||
|
||||
/* ============================ ISO C11 support ============================ */
|
||||
|
||||
/* 'float' properties */
|
||||
|
||||
#ifndef FLT_HAS_SUBNORM
|
||||
# define FLT_HAS_SUBNORM 1
|
||||
#endif
|
||||
#ifndef FLT_DECIMAL_DIG
|
||||
/* FLT_MANT_DIG = 24 => FLT_DECIMAL_DIG = 9 */
|
||||
# define FLT_DECIMAL_DIG ((int)(FLT_MANT_DIG * 0.3010299956639812 + 2))
|
||||
#endif
|
||||
#if defined _AIX && !defined __GNUC__
|
||||
/* On AIX, the value of FLT_TRUE_MIN in /usr/include/float.h is a 'double',
|
||||
not a 'float'. */
|
||||
# undef FLT_TRUE_MIN
|
||||
#endif
|
||||
#ifndef FLT_TRUE_MIN
|
||||
/* FLT_MIN / 2^(FLT_MANT_DIG-1) */
|
||||
# define FLT_TRUE_MIN (FLT_MIN / 8388608.0f)
|
||||
#endif
|
||||
|
||||
/* 'double' properties */
|
||||
|
||||
#ifndef DBL_HAS_SUBNORM
|
||||
# define DBL_HAS_SUBNORM 1
|
||||
#endif
|
||||
#ifndef DBL_DECIMAL_DIG
|
||||
/* DBL_MANT_DIG = 53 => DBL_DECIMAL_DIG = 17 */
|
||||
# define DBL_DECIMAL_DIG ((int)(DBL_MANT_DIG * 0.3010299956639812 + 2))
|
||||
#endif
|
||||
#ifndef DBL_TRUE_MIN
|
||||
/* DBL_MIN / 2^(DBL_MANT_DIG-1) */
|
||||
# define DBL_TRUE_MIN (DBL_MIN / 4503599627370496.0)
|
||||
#endif
|
||||
|
||||
/* 'long double' properties */
|
||||
|
||||
#ifndef LDBL_HAS_SUBNORM
|
||||
# define LDBL_HAS_SUBNORM 1
|
||||
#endif
|
||||
#ifndef LDBL_DECIMAL_DIG
|
||||
/* LDBL_MANT_DIG = 53 => LDBL_DECIMAL_DIG = 17 */
|
||||
/* LDBL_MANT_DIG = 64 => LDBL_DECIMAL_DIG = 21 */
|
||||
/* LDBL_MANT_DIG = 106 => LDBL_DECIMAL_DIG = 33 */
|
||||
/* LDBL_MANT_DIG = 113 => LDBL_DECIMAL_DIG = 36 */
|
||||
# define LDBL_DECIMAL_DIG ((int)(LDBL_MANT_DIG * 0.3010299956639812 + 2))
|
||||
#endif
|
||||
#ifndef LDBL_TRUE_MIN
|
||||
/* LDBL_MIN / 2^(LDBL_MANT_DIG-1) */
|
||||
# if LDBL_MANT_DIG == 53
|
||||
# define LDBL_TRUE_MIN (LDBL_MIN / 4503599627370496.0L)
|
||||
# elif LDBL_MANT_DIG == 64
|
||||
# if defined __i386__ && (defined __FreeBSD__ || defined __DragonFly__)
|
||||
/* Work around FreeBSD/x86 problem mentioned above. */
|
||||
extern const union gl_long_double_union gl_LDBL_TRUE_MIN;
|
||||
# define LDBL_TRUE_MIN (gl_LDBL_TRUE_MIN.ld)
|
||||
# else
|
||||
# define LDBL_TRUE_MIN (LDBL_MIN / 9223372036854775808.0L)
|
||||
# endif
|
||||
# elif LDBL_MANT_DIG == 106
|
||||
# define LDBL_TRUE_MIN (LDBL_MIN / 40564819207303340847894502572032.0L)
|
||||
# elif LDBL_MANT_DIG == 113
|
||||
# define LDBL_TRUE_MIN (LDBL_MIN / 5192296858534827628530496329220096.0L)
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* ============================ ISO C23 support ============================ */
|
||||
|
||||
/* 'float' properties */
|
||||
|
||||
#ifndef FLT_IS_IEC_60559
|
||||
# if defined __m68k__
|
||||
# define FLT_IS_IEC_60559 0
|
||||
# else
|
||||
# define FLT_IS_IEC_60559 1
|
||||
# endif
|
||||
#endif
|
||||
#ifndef FLT_NORM_MAX
|
||||
# define FLT_NORM_MAX FLT_MAX
|
||||
#endif
|
||||
#ifndef FLT_SNAN
|
||||
/* For sh, beware of <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111814>. */
|
||||
# if ((__GNUC__ + (__GNUC_MINOR__ >= 3) > 3) || defined __clang__) && !defined __sh__
|
||||
# define FLT_SNAN __builtin_nansf ("")
|
||||
# else
|
||||
typedef union { unsigned int word[1]; float value; } gl_FLT_SNAN_t;
|
||||
extern gl_FLT_SNAN_t gl_FLT_SNAN;
|
||||
# define FLT_SNAN (gl_FLT_SNAN.value)
|
||||
# define GNULIB_defined_FLT_SNAN 1
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* 'double' properties */
|
||||
|
||||
#ifndef DBL_IS_IEC_60559
|
||||
# if defined __m68k__
|
||||
# define DBL_IS_IEC_60559 0
|
||||
# else
|
||||
# define DBL_IS_IEC_60559 1
|
||||
# endif
|
||||
#endif
|
||||
#ifndef DBL_NORM_MAX
|
||||
# define DBL_NORM_MAX DBL_MAX
|
||||
#endif
|
||||
#ifndef DBL_SNAN
|
||||
/* For sh, beware of <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111814>. */
|
||||
# if ((__GNUC__ + (__GNUC_MINOR__ >= 3) > 3) || defined __clang__) && !defined __sh__
|
||||
# define DBL_SNAN __builtin_nans ("")
|
||||
# else
|
||||
typedef union { unsigned long long word[1]; double value; } gl_DBL_SNAN_t;
|
||||
extern gl_DBL_SNAN_t gl_DBL_SNAN;
|
||||
# define DBL_SNAN (gl_DBL_SNAN.value)
|
||||
# define GNULIB_defined_DBL_SNAN 1
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* 'long double' properties */
|
||||
|
||||
#ifndef LDBL_IS_IEC_60559
|
||||
# if defined __m68k__
|
||||
# define LDBL_IS_IEC_60559 0
|
||||
# elif LDBL_MANT_DIG == 53 || LDBL_MANT_DIG == 113
|
||||
# define LDBL_IS_IEC_60559 1
|
||||
# else
|
||||
# define LDBL_IS_IEC_60559 0
|
||||
# endif
|
||||
#endif
|
||||
#ifndef LDBL_NORM_MAX
|
||||
# ifdef __LDBL_NORM_MAX__
|
||||
# define LDBL_NORM_MAX __LDBL_NORM_MAX__
|
||||
# else
|
||||
# define LDBL_NORM_MAX LDBL_MAX
|
||||
# endif
|
||||
#endif
|
||||
#ifndef LDBL_SNAN
|
||||
/* For sh, beware of <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111814>. */
|
||||
# if ((__GNUC__ + (__GNUC_MINOR__ >= 3) > 3) || defined __clang__) && !defined __sh__
|
||||
# define LDBL_SNAN __builtin_nansl ("")
|
||||
# else
|
||||
# if LDBL_MANT_DIG == 53
|
||||
typedef union { unsigned long long word[1]; long double value; } gl_LDBL_SNAN_t;
|
||||
# elif defined __m68k__
|
||||
typedef union { unsigned int word[3]; long double value; } gl_LDBL_SNAN_t;
|
||||
# else
|
||||
typedef union { unsigned long long word[2]; long double value; } gl_LDBL_SNAN_t;
|
||||
# endif
|
||||
extern gl_LDBL_SNAN_t gl_LDBL_SNAN;
|
||||
# define LDBL_SNAN (gl_LDBL_SNAN.value)
|
||||
# define GNULIB_defined_LDBL_SNAN 1
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* ================================= Other ================================= */
|
||||
|
||||
#if @REPLACE_ITOLD@
|
||||
/* Pull in a function that fixes the 'int' to 'long double' conversion
|
||||
of glibc 2.7. */
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* Round towards negative infinity.
|
||||
Copyright (C) 2007, 2010-2024 Free Software Foundation, Inc.
|
||||
Copyright (C) 2007, 2010-2025 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
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* Round towards negative infinity.
|
||||
Copyright (C) 2007, 2009-2024 Free Software Foundation, Inc.
|
||||
Copyright (C) 2007, 2009-2025 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
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* Open a stream to a file.
|
||||
Copyright (C) 2007-2024 Free Software Foundation, Inc.
|
||||
Copyright (C) 2007-2025 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
|
||||
|
|
@ -19,12 +19,12 @@
|
|||
/* If the user's config.h happens to include <stdio.h>, let it include only
|
||||
the system's <stdio.h> here, so that orig_fopen doesn't recurse to
|
||||
rpl_fopen. */
|
||||
#define _GL_ALREADY_INCLUDING_STDIO_H
|
||||
#define _GL_SKIP_GNULIB_STDIO_H
|
||||
#include <config.h>
|
||||
|
||||
/* Get the original definition of fopen. It might be defined as a macro. */
|
||||
#include <stdio.h>
|
||||
#undef _GL_ALREADY_INCLUDING_STDIO_H
|
||||
#undef _GL_SKIP_GNULIB_STDIO_H
|
||||
|
||||
static FILE *
|
||||
orig_fopen (const char *filename, const char *mode)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* Flushing buffers of a FILE stream.
|
||||
Copyright (C) 2007-2024 Free Software Foundation, Inc.
|
||||
Copyright (C) 2007-2025 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
|
||||
|
|
@ -37,7 +37,7 @@ fpurge (FILE *fp)
|
|||
/* The __fpurge function does not have a return value. */
|
||||
return 0;
|
||||
|
||||
#elif HAVE_FPURGE /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin >= 1.7 */
|
||||
#elif HAVE_FPURGE /* FreeBSD, NetBSD, 2.0 <= OpenBSD <= 7.7, DragonFly, Mac OS X, Cygwin >= 1.7 */
|
||||
|
||||
/* Call the system's fpurge function. */
|
||||
# undef fpurge
|
||||
|
|
@ -46,7 +46,7 @@ fpurge (FILE *fp)
|
|||
# endif
|
||||
int result = fpurge (fp);
|
||||
# if defined __sferror || defined __DragonFly__ || defined __ANDROID__
|
||||
/* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Minix 3, Android */
|
||||
/* FreeBSD, NetBSD, OpenBSD <= 7.7, DragonFly, Mac OS X, Cygwin, Minix 3, Android */
|
||||
if (result == 0)
|
||||
/* Correct the invariants that fpurge broke.
|
||||
<stdio.h> on BSD systems says:
|
||||
|
|
@ -76,7 +76,7 @@ fpurge (FILE *fp)
|
|||
}
|
||||
return 0;
|
||||
# elif defined __sferror || defined __DragonFly__ || defined __ANDROID__
|
||||
/* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Minix 3, Android */
|
||||
/* FreeBSD, NetBSD, OpenBSD < 2.0, DragonFly, Mac OS X, Cygwin, Minix 3, Android */
|
||||
fp_->_p = fp_->_bf._base;
|
||||
fp_->_r = 0;
|
||||
fp_->_w = ((fp_->_flags & (__SLBF | __SNBF | __SRD)) == 0 /* fully buffered and not currently reading? */
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* Retrieve information about a FILE stream.
|
||||
Copyright (C) 2007-2024 Free Software Foundation, Inc.
|
||||
Copyright (C) 2007-2025 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
|
||||
|
|
@ -25,6 +25,10 @@
|
|||
<https://sourceware.org/bugzilla/show_bug.cgi?id=4359> */
|
||||
#if !(HAVE___FREADING && (!defined __GLIBC__ || defined __UCLIBC__ || __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 7)))
|
||||
|
||||
/* This code is not compiled on systems that have a working __freading function,
|
||||
namely glibc >= 2.7, OpenBSD >= 7.6, Solaris >= 7, UnixWare >= 7.1.4.MP4,
|
||||
Cygwin >= 1.7.34, Android API >= 28, musl libc, Haiku >= hrev58760. */
|
||||
|
||||
bool
|
||||
freading (FILE *fp)
|
||||
{
|
||||
|
|
@ -37,7 +41,7 @@ freading (FILE *fp)
|
|||
|| ((fp->_flags & (_IO_NO_READS | _IO_CURRENTLY_PUTTING)) == 0
|
||||
&& fp->_IO_read_base != NULL));
|
||||
# elif defined __sferror || defined __DragonFly__ || defined __ANDROID__
|
||||
/* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin < 1.7.34, Minix 3, Android */
|
||||
/* FreeBSD, NetBSD, OpenBSD < 7.6, DragonFly, Mac OS X, Cygwin < 1.7.34, Minix 3, Android */
|
||||
return (fp_->_flags & __SRD) != 0;
|
||||
# elif defined __EMX__ /* emx+gcc */
|
||||
return (fp->_flags & _IOREAD) != 0;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* Retrieve information about a FILE stream.
|
||||
Copyright (C) 2007-2024 Free Software Foundation, Inc.
|
||||
Copyright (C) 2007-2025 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
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/* Make free() preserve errno.
|
||||
|
||||
Copyright (C) 2003, 2006, 2009-2024 Free Software Foundation, Inc.
|
||||
Copyright (C) 2003, 2006, 2009-2025 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
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* An fseek() function that, together with fflush(), is POSIX compliant.
|
||||
Copyright (C) 2007, 2009-2024 Free Software Foundation, Inc.
|
||||
Copyright (C) 2007, 2009-2025 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
|
||||
|
|
|
|||
24
gl/fseeko.c
24
gl/fseeko.c
|
|
@ -1,5 +1,5 @@
|
|||
/* An fseeko() function that, together with fflush(), is POSIX compliant.
|
||||
Copyright (C) 2007-2024 Free Software Foundation, Inc.
|
||||
Copyright (C) 2007-2025 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
|
||||
|
|
@ -48,12 +48,15 @@ fseeko (FILE *fp, off_t offset, int whence)
|
|||
|
||||
/* These tests are based on fpurge.c. */
|
||||
#if defined _IO_EOF_SEEN || defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1
|
||||
# if !defined __HAIKU__
|
||||
# define fp_ fp
|
||||
# endif
|
||||
/* GNU libc, BeOS, Haiku, Linux libc5 */
|
||||
if (fp->_IO_read_end == fp->_IO_read_ptr
|
||||
&& fp->_IO_write_ptr == fp->_IO_write_base
|
||||
&& fp->_IO_save_base == NULL)
|
||||
if (fp_->_IO_read_end == fp_->_IO_read_ptr
|
||||
&& fp_->_IO_write_ptr == fp_->_IO_write_base
|
||||
&& fp_->_IO_save_base == NULL)
|
||||
#elif defined __sferror || defined __DragonFly__ || defined __ANDROID__
|
||||
/* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Minix 3, Android */
|
||||
/* FreeBSD, NetBSD, OpenBSD <= 7.7, DragonFly, Mac OS X, Cygwin, Minix 3, Android */
|
||||
# if defined __SL64 && defined __SCLE /* Cygwin */
|
||||
if ((fp->_flags & __SL64) == 0)
|
||||
{
|
||||
|
|
@ -101,6 +104,9 @@ fseeko (FILE *fp, off_t offset, int whence)
|
|||
#elif defined EPLAN9 /* Plan9 */
|
||||
if (fp->rp == fp->buf
|
||||
&& fp->wp == fp->buf)
|
||||
#elif defined __OpenBSD__ && !defined __sferror /* OpenBSD >= 7.8 */
|
||||
/* fseeko and fflush work as advertised. */
|
||||
if (0)
|
||||
#elif FUNC_FFLUSH_STDIN < 0 && 200809 <= _POSIX_VERSION
|
||||
/* Cross-compiling to some other system advertising conformance to
|
||||
POSIX.1-2008 or later. Assume fseeko and fflush work as advertised.
|
||||
|
|
@ -118,7 +124,7 @@ fseeko (FILE *fp, off_t offset, int whence)
|
|||
if (pos == -1)
|
||||
{
|
||||
#if defined __sferror || defined __DragonFly__ || defined __ANDROID__
|
||||
/* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Minix 3, Android */
|
||||
/* FreeBSD, NetBSD, OpenBSD <= 7.7, DragonFly, Mac OS X, Cygwin, Minix 3, Android */
|
||||
fp_->_flags &= ~__SOFF;
|
||||
#endif
|
||||
return -1;
|
||||
|
|
@ -126,10 +132,10 @@ fseeko (FILE *fp, off_t offset, int whence)
|
|||
|
||||
#if defined _IO_EOF_SEEN || defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1
|
||||
/* GNU libc, BeOS, Haiku, Linux libc5 */
|
||||
fp->_flags &= ~_IO_EOF_SEEN;
|
||||
fp->_offset = pos;
|
||||
fp_->_flags &= ~_IO_EOF_SEEN;
|
||||
fp_->_offset = pos;
|
||||
#elif defined __sferror || defined __DragonFly__ || defined __ANDROID__
|
||||
/* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Minix 3, Android */
|
||||
/* FreeBSD, NetBSD, OpenBSD <= 7.7, DragonFly, Mac OS X, Cygwin, Minix 3, Android */
|
||||
# if defined __CYGWIN__ || (defined __NetBSD__ && __NetBSD_Version__ >= 600000000) || defined __minix
|
||||
/* fp_->_offset is typed as an integer. */
|
||||
fp_->_offset = pos;
|
||||
|
|
|
|||
84
gl/fseterr.c
Normal file
84
gl/fseterr.c
Normal file
|
|
@ -0,0 +1,84 @@
|
|||
/* Set the error indicator of a stream.
|
||||
Copyright (C) 2007-2025 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 <https://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
/* Specification. */
|
||||
#include "fseterr.h"
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
#include "stdio-impl.h"
|
||||
|
||||
/* This file is not used on systems that have the __fseterr function,
|
||||
namely OpenBSD >= 7.6, musl libc, Haiku >= hrev58760. */
|
||||
|
||||
void
|
||||
fseterr (FILE *fp)
|
||||
{
|
||||
/* Most systems provide FILE as a struct and the necessary bitmask in
|
||||
<stdio.h>, because they need it for implementing getc() and putc() as
|
||||
fast macros. */
|
||||
#if defined _IO_EOF_SEEN || defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1
|
||||
/* GNU libc, BeOS, Haiku, Linux libc5 */
|
||||
fp->_flags |= _IO_ERR_SEEN;
|
||||
#elif defined __sferror || defined __DragonFly__ || defined __ANDROID__
|
||||
/* FreeBSD, NetBSD, OpenBSD < 7.6, DragonFly, Mac OS X, Cygwin, Minix 3, Android */
|
||||
fp_->_flags |= __SERR;
|
||||
#elif defined __EMX__ /* emx+gcc */
|
||||
fp->_flags |= _IOERR;
|
||||
#elif defined __minix /* Minix */
|
||||
fp->_flags |= _IOERR;
|
||||
#elif defined _IOERR /* AIX, HP-UX, IRIX, OSF/1, Solaris, OpenServer, UnixWare, mingw, MSVC, NonStop Kernel, OpenVMS */
|
||||
fp_->_flag |= _IOERR;
|
||||
#elif defined __UCLIBC__ /* uClibc */
|
||||
fp->__modeflags |= __FLAG_ERROR;
|
||||
#elif defined __QNX__ /* QNX */
|
||||
fp->_Mode |= 0x200 /* _MERR */;
|
||||
#elif defined __MINT__ /* Atari FreeMiNT */
|
||||
fp->__error = 1;
|
||||
#elif defined EPLAN9 /* Plan9 */
|
||||
if (fp->state != 0 /* CLOSED */)
|
||||
fp->state = 5 /* ERR */;
|
||||
#elif 0 /* unknown */
|
||||
/* Portable fallback, based on an idea by Rich Felker.
|
||||
Wow! 6 system calls for something that is just a bit operation!
|
||||
Not activated on any system, because there is no way to repair FP when
|
||||
the sequence of system calls fails, and library code should not call
|
||||
abort(). */
|
||||
int saved_errno;
|
||||
int fd;
|
||||
int fd2;
|
||||
|
||||
saved_errno = errno;
|
||||
fflush (fp);
|
||||
fd = fileno (fp);
|
||||
fd2 = dup (fd);
|
||||
if (fd2 >= 0)
|
||||
{
|
||||
close (fd);
|
||||
fputc ('\0', fp); /* This should set the error indicator. */
|
||||
fflush (fp); /* Or this. */
|
||||
if (dup2 (fd2, fd) < 0)
|
||||
/* Whee... we botched the stream and now cannot restore it! */
|
||||
abort ();
|
||||
close (fd2);
|
||||
}
|
||||
errno = saved_errno;
|
||||
#else
|
||||
#error "Please port gnulib fseterr.c to your platform! Look at the definitions of ferror and clearerr on your system, then report this to bug-gnulib."
|
||||
#endif
|
||||
}
|
||||
55
gl/fseterr.h
Normal file
55
gl/fseterr.h
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
/* Set the error indicator of a stream.
|
||||
Copyright (C) 2007, 2009-2025 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 <https://www.gnu.org/licenses/>. */
|
||||
|
||||
#ifndef _FSETERR_H
|
||||
#define _FSETERR_H
|
||||
|
||||
/* This file uses HAVE___FSETERR. */
|
||||
#if !_GL_CONFIG_H_INCLUDED
|
||||
#error "Please include config.h first."
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
/* Set the error indicator of the stream FP.
|
||||
The "error indicator" is set when an I/O operation on the stream fails, and
|
||||
is cleared (together with the "end-of-file" indicator) by clearerr (FP). */
|
||||
|
||||
#if HAVE___FSETERR /* musl libc */
|
||||
|
||||
/* Haiku has __fseterr but does not declare it. */
|
||||
# if defined __HAIKU__
|
||||
extern void __fseterr (FILE *fp);
|
||||
# endif
|
||||
|
||||
# include <stdio_ext.h>
|
||||
# define fseterr(fp) __fseterr (fp)
|
||||
|
||||
#else
|
||||
|
||||
# ifdef __cplusplus
|
||||
extern "C" {
|
||||
# endif
|
||||
|
||||
extern void fseterr (FILE *fp);
|
||||
|
||||
# ifdef __cplusplus
|
||||
}
|
||||
# endif
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* _FSETERR_H */
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
/* fstat() replacement.
|
||||
Copyright (C) 2011-2024 Free Software Foundation, Inc.
|
||||
Copyright (C) 2011-2025 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
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/* fsusage.c -- return space usage of mounted file systems
|
||||
|
||||
Copyright (C) 1991-1992, 1996, 1998-1999, 2002-2006, 2009-2024 Free Software
|
||||
Copyright (C) 1991-1992, 1996, 1998-1999, 2002-2006, 2009-2025 Free Software
|
||||
Foundation, Inc.
|
||||
|
||||
This file is free software: you can redistribute it and/or modify
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/* fsusage.h -- declarations for file system space usage info
|
||||
|
||||
Copyright (C) 1991-1992, 1997, 2003-2006, 2009-2024 Free Software
|
||||
Copyright (C) 1991-1992, 1997, 2003-2006, 2009-2025 Free Software
|
||||
Foundation, Inc.
|
||||
|
||||
This file is free software: you can redistribute it and/or modify
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* An ftell() function that works around platform bugs.
|
||||
Copyright (C) 2007-2024 Free Software Foundation, Inc.
|
||||
Copyright (C) 2007-2025 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
|
||||
|
|
|
|||
11
gl/ftello.c
11
gl/ftello.c
|
|
@ -1,5 +1,5 @@
|
|||
/* An ftello() function that works around platform bugs.
|
||||
Copyright (C) 2007, 2009-2024 Free Software Foundation, Inc.
|
||||
Copyright (C) 2007, 2009-2025 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
|
||||
|
|
@ -20,7 +20,7 @@
|
|||
#include <stdio.h>
|
||||
|
||||
#include <errno.h>
|
||||
#include "intprops.h"
|
||||
#include <stdckdint.h>
|
||||
|
||||
/* Get lseek. */
|
||||
#include <unistd.h>
|
||||
|
|
@ -34,7 +34,10 @@ ftello (FILE *fp)
|
|||
# undef ftell
|
||||
# define ftello ftell
|
||||
#endif
|
||||
#if _GL_WINDOWS_64_BIT_OFF_T
|
||||
#if (defined _WIN32 && !defined __CYGWIN__) \
|
||||
/* We need to test _FILE_OFFSET_BITS for mingw-w64 */ \
|
||||
/* and _GL_WINDOWS_64_BIT_OFF_T for MSVC. */ \
|
||||
&& (_FILE_OFFSET_BITS == 64 || _GL_WINDOWS_64_BIT_OFF_T)
|
||||
# undef ftello
|
||||
# if HAVE__FTELLI64 /* msvc, mingw64 */
|
||||
# define ftello _ftelli64
|
||||
|
|
@ -97,7 +100,7 @@ ftello (FILE *fp)
|
|||
|
||||
/* Compute pos + buffered, with overflow check. */
|
||||
off_t sum;
|
||||
if (! INT_ADD_OK (pos, buffered, &sum))
|
||||
if (ckd_add (&sum, pos, buffered))
|
||||
{
|
||||
errno = EOVERFLOW;
|
||||
return -1;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
/* Copyright (C) 1997, 2001-2002, 2004-2006, 2008-2024 Free Software
|
||||
/* Copyright (C) 1997, 2001-2002, 2004-2006, 2008-2025 Free Software
|
||||
Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
Contributed by Philip Blundell <pjb27@cam.ac.uk>, 1997.
|
||||
|
|
@ -27,8 +27,8 @@
|
|||
# include <libintl.h>
|
||||
#else
|
||||
# include "gettext.h"
|
||||
# define _(String) gettext (String)
|
||||
# define N_(String) String
|
||||
# define _(msgid) dgettext ("gnulib", msgid)
|
||||
# define N_(msgid) msgid
|
||||
#endif
|
||||
|
||||
#if HAVE_DECL_GAI_STRERROR
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* Get address information (partial implementation).
|
||||
Copyright (C) 1997, 2001-2002, 2004-2024 Free Software Foundation, Inc.
|
||||
Copyright (C) 1997, 2001-2002, 2004-2025 Free Software Foundation, Inc.
|
||||
Contributed by Simon Josefsson <simon@josefsson.org>.
|
||||
|
||||
This file is free software: you can redistribute it and/or modify
|
||||
|
|
@ -40,8 +40,8 @@
|
|||
#include <stdio.h>
|
||||
|
||||
#include "gettext.h"
|
||||
#define _(String) gettext (String)
|
||||
#define N_(String) String
|
||||
#define _(msgid) dgettext ("gnulib", msgid)
|
||||
#define N_(msgid) msgid
|
||||
|
||||
/* BeOS has AF_INET, but not PF_INET. */
|
||||
#ifndef PF_INET
|
||||
|
|
@ -54,7 +54,7 @@
|
|||
|
||||
#if HAVE_GETADDRINFO
|
||||
|
||||
/* Override with cdecl calling convention. */
|
||||
/* Override with cdecl calling convention and mingw fix. */
|
||||
|
||||
int
|
||||
getaddrinfo (const char *restrict nodename,
|
||||
|
|
@ -63,6 +63,10 @@ getaddrinfo (const char *restrict nodename,
|
|||
struct addrinfo **restrict res)
|
||||
# undef getaddrinfo
|
||||
{
|
||||
if (hints && (hints->ai_flags & AI_NUMERICSERV) != 0
|
||||
&& servname && !(*servname >= '0' && *servname <= '9'))
|
||||
return EAI_NONAME;
|
||||
|
||||
return getaddrinfo (nodename, servname, hints, res);
|
||||
}
|
||||
|
||||
|
|
@ -169,16 +173,43 @@ validate_family (int family)
|
|||
{
|
||||
/* FIXME: Support more families. */
|
||||
# if HAVE_IPV4
|
||||
if (family == PF_INET)
|
||||
return true;
|
||||
if (family == PF_INET)
|
||||
return true;
|
||||
# endif
|
||||
# if HAVE_IPV6
|
||||
if (family == PF_INET6)
|
||||
return true;
|
||||
if (family == PF_INET6)
|
||||
return true;
|
||||
# endif
|
||||
if (family == PF_UNSPEC)
|
||||
return true;
|
||||
return false;
|
||||
if (family == PF_UNSPEC)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool
|
||||
is_numeric_host (const char *host, int family)
|
||||
{
|
||||
# if HAVE_IPV4
|
||||
if (family == PF_INET || family == PF_UNSPEC)
|
||||
{
|
||||
/* glibc supports IPv4 addresses in numbers-and-dots notation, that is,
|
||||
also hexadecimal and octal number formats and formats that don't
|
||||
require all four bytes to be explicitly written, via inet_aton().
|
||||
But POSIX doesn't require support for these legacy formats. Therefore
|
||||
we are free to use inet_pton() instead of inet_aton(). */
|
||||
struct in_addr addr;
|
||||
if (inet_pton (AF_INET, host, &addr))
|
||||
return true;
|
||||
}
|
||||
# endif
|
||||
# if HAVE_IPV6
|
||||
if (family == PF_INET6 || family == PF_UNSPEC)
|
||||
{
|
||||
struct in6_addr addr;
|
||||
if (inet_pton (AF_INET6, host, &addr))
|
||||
return true;
|
||||
}
|
||||
# endif
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Translate name of a service location and/or a service name to set of
|
||||
|
|
@ -210,10 +241,17 @@ getaddrinfo (const char *restrict nodename,
|
|||
|
||||
# ifdef WINDOWS_NATIVE
|
||||
if (use_win32_p ())
|
||||
return getaddrinfo_ptr (nodename, servname, hints, res);
|
||||
{
|
||||
if (hints && (hints->ai_flags & AI_NUMERICSERV) != 0
|
||||
&& servname && !(*servname >= '0' && *servname <= '9'))
|
||||
return EAI_NONAME;
|
||||
return getaddrinfo_ptr (nodename, servname, hints, res);
|
||||
}
|
||||
# endif
|
||||
|
||||
if (hints && (hints->ai_flags & ~(AI_CANONNAME|AI_PASSIVE)))
|
||||
if (hints
|
||||
&& (hints->ai_flags
|
||||
& ~(AI_CANONNAME | AI_PASSIVE | AI_NUMERICHOST | AI_NUMERICSERV)))
|
||||
/* FIXME: Support more flags. */
|
||||
return EAI_BADFLAGS;
|
||||
|
||||
|
|
@ -225,12 +263,18 @@ getaddrinfo (const char *restrict nodename,
|
|||
/* FIXME: Support other socktype. */
|
||||
return EAI_SOCKTYPE; /* FIXME: Better return code? */
|
||||
|
||||
if (!nodename)
|
||||
if (nodename != NULL)
|
||||
{
|
||||
if (hints && (hints->ai_flags & AI_NUMERICHOST) != 0
|
||||
&& !is_numeric_host (nodename, hints->ai_family))
|
||||
return EAI_NONAME;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!(hints->ai_flags & AI_PASSIVE))
|
||||
return EAI_NONAME;
|
||||
|
||||
# ifdef HAVE_IPV6
|
||||
# if HAVE_IPV6
|
||||
nodename = (hints->ai_family == AF_INET6) ? "::" : "0.0.0.0";
|
||||
# else
|
||||
nodename = "0.0.0.0";
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* getdelim.c --- Implementation of replacement getdelim function.
|
||||
Copyright (C) 1994, 1996-1998, 2001, 2003, 2005-2024 Free Software
|
||||
Copyright (C) 1994, 1996-1998, 2001, 2003, 2005-2025 Free Software
|
||||
Foundation, Inc.
|
||||
|
||||
This file is free software: you can redistribute it and/or modify
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* getdtablesize() function: Return maximum possible file descriptor value + 1.
|
||||
Copyright (C) 2008-2024 Free Software Foundation, Inc.
|
||||
Copyright (C) 2008-2025 Free Software Foundation, Inc.
|
||||
Written by Bruno Haible <bruno@clisp.org>, 2008.
|
||||
|
||||
This file is free software: you can redistribute it and/or modify
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/* gethostname emulation for SysV and POSIX.1.
|
||||
|
||||
Copyright (C) 1992, 2003, 2006, 2008-2024 Free Software Foundation, Inc.
|
||||
Copyright (C) 1992, 2003, 2006, 2008-2025 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
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* getline.c --- Implementation of replacement getline function.
|
||||
Copyright (C) 2005-2007, 2009-2024 Free Software Foundation, Inc.
|
||||
Copyright (C) 2005-2007, 2009-2025 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
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/* Get the system load averages.
|
||||
|
||||
Copyright (C) 1985-1989, 1991-1995, 1997, 1999-2000, 2003-2024 Free Software
|
||||
Copyright (C) 1985-1989, 1991-1995, 1997, 1999-2000, 2003-2025 Free Software
|
||||
Foundation, Inc.
|
||||
|
||||
NOTE: The canonical source of this file is maintained with gnulib.
|
||||
|
|
@ -47,8 +47,6 @@
|
|||
N_NAME_POINTER The nlist n_name element is a pointer,
|
||||
not an array.
|
||||
HAVE_STRUCT_NLIST_N_UN_N_NAME 'n_un.n_name' is member of 'struct nlist'.
|
||||
LINUX_LDAV_FILE [__linux__, __ANDROID__, __CYGWIN__]: File
|
||||
containing load averages.
|
||||
|
||||
Specific system predefines this file uses, aside from setting
|
||||
default values if not emacs:
|
||||
|
|
@ -65,8 +63,7 @@
|
|||
UMAX4_3
|
||||
VMS
|
||||
_WIN32 Native Windows (possibly also defined on Cygwin)
|
||||
__linux__, __ANDROID__ Linux: assumes /proc file system mounted.
|
||||
Support from Michael K. Johnson.
|
||||
__linux__, __ANDROID__ Linux: assumes sysinfo() call.
|
||||
__CYGWIN__ Cygwin emulates linux /proc/loadavg.
|
||||
__NetBSD__ NetBSD: assumes /kern file system mounted.
|
||||
|
||||
|
|
@ -108,10 +105,10 @@
|
|||
# endif
|
||||
|
||||
/* Same issues as for NeXT apply to the HURD-based GNU system. */
|
||||
# ifdef __GNU__
|
||||
# if defined __gnu_hurd__ || defined NeXT
|
||||
# undef BSD
|
||||
# undef FSCALE
|
||||
# endif /* __GNU__ */
|
||||
# endif /* __gnu_hurd__ || NeXT */
|
||||
|
||||
/* Set values that are different from the defaults, which are
|
||||
set a little farther down with #ifndef. */
|
||||
|
|
@ -143,7 +140,7 @@
|
|||
# define SUNOS_5
|
||||
# endif
|
||||
|
||||
# if defined (__osf__) && (defined (__alpha) || defined (__alpha__))
|
||||
# if defined (__osf__) && defined (__alpha)
|
||||
# define OSF_ALPHA
|
||||
# include <sys/mbuf.h>
|
||||
# include <sys/socket.h>
|
||||
|
|
@ -312,8 +309,7 @@
|
|||
# endif
|
||||
# endif
|
||||
|
||||
# if defined (__GNU__) && !defined (NeXT)
|
||||
/* Note that NeXT Openstep defines __GNU__ even though it should not. */
|
||||
# if defined __gnu_hurd__ && !defined NeXT
|
||||
/* GNU system acts much like NeXT, for load average purposes,
|
||||
but not exactly. */
|
||||
# define NeXT
|
||||
|
|
@ -358,6 +354,11 @@
|
|||
# include <sys/dg_sys_info.h>
|
||||
# endif
|
||||
|
||||
# if defined __linux__ || defined __ANDROID__
|
||||
# include <sys/param.h>
|
||||
# include <sys/sysinfo.h>
|
||||
# endif
|
||||
|
||||
# if (defined __linux__ || defined __ANDROID__ \
|
||||
|| defined __CYGWIN__ || defined SUNOS_5 \
|
||||
|| (defined LOAD_AVE_TYPE && ! defined __VMS))
|
||||
|
|
@ -498,20 +499,33 @@ getloadavg (double loadavg[], int nelem)
|
|||
}
|
||||
# endif
|
||||
|
||||
# if !defined (LDAV_DONE) && (defined __linux__ || defined __ANDROID__ || defined __CYGWIN__)
|
||||
/* Linux without glibc, Android, Cygwin */
|
||||
# if (!defined LDAV_DONE \
|
||||
&& (defined __ANDROID__ ? 13 <= __ANDROID_API__ : defined __linux__))
|
||||
/* non-Android Linux without glibc, Android 3.2+, Cygwin */
|
||||
# define LDAV_DONE
|
||||
# undef LOAD_AVE_TYPE
|
||||
|
||||
# ifndef LINUX_LDAV_FILE
|
||||
# define LINUX_LDAV_FILE "/proc/loadavg"
|
||||
# endif
|
||||
{
|
||||
struct sysinfo info;
|
||||
if (sysinfo (&info) < 0)
|
||||
return -1;
|
||||
loadavg[0] = info.loads[0] / (double)(1U << SI_LOAD_SHIFT);
|
||||
loadavg[1] = info.loads[1] / (double)(1U << SI_LOAD_SHIFT);
|
||||
loadavg[2] = info.loads[2] / (double)(1U << SI_LOAD_SHIFT);
|
||||
elem = 3;
|
||||
}
|
||||
# endif /* __ANDROID__ ? 13 <= __ANDROID_API__ : __linux__ */
|
||||
|
||||
# if !defined (LDAV_DONE) && defined __CYGWIN__
|
||||
/* Cygwin */
|
||||
# define LDAV_DONE
|
||||
# undef LOAD_AVE_TYPE
|
||||
|
||||
char ldavgbuf[3 * (INT_STRLEN_BOUND (int) + sizeof ".00 ")];
|
||||
char const *ptr = ldavgbuf;
|
||||
int fd, count, saved_errno;
|
||||
|
||||
fd = open (LINUX_LDAV_FILE, O_RDONLY | O_CLOEXEC);
|
||||
fd = open ("/proc/loadavg", O_RDONLY | O_CLOEXEC);
|
||||
if (fd == -1)
|
||||
return -1;
|
||||
count = read (fd, ldavgbuf, sizeof ldavgbuf - 1);
|
||||
|
|
@ -554,7 +568,7 @@ getloadavg (double loadavg[], int nelem)
|
|||
|
||||
return elem;
|
||||
|
||||
# endif /* __linux__ || __ANDROID__ || __CYGWIN__ */
|
||||
# endif /* __CYGWIN__ */
|
||||
|
||||
# if !defined (LDAV_DONE) && defined (__NetBSD__) /* NetBSD < 0.9 */
|
||||
# define LDAV_DONE
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* getopt-on-non-glibc compatibility macros.
|
||||
Copyright (C) 1989-2024 Free Software Foundation, Inc.
|
||||
Copyright (C) 1989-2025 Free Software Foundation, Inc.
|
||||
This file is part of gnulib.
|
||||
Unlike most of the getopt implementation, it is NOT shared
|
||||
with the GNU C Library.
|
||||
|
|
@ -46,10 +46,14 @@
|
|||
# endif
|
||||
#endif
|
||||
|
||||
#if defined __clang__
|
||||
/* clang really only groks GNU C 4.2, regardless of its value of __GNUC__. */
|
||||
# undef __GNUC_PREREQ
|
||||
# define __GNUC_PREREQ(maj, min) ((maj) < 4 + ((min) <= 2))
|
||||
#endif
|
||||
#ifndef __GNUC_PREREQ
|
||||
# if defined __GNUC__ && defined __GNUC_VERSION__
|
||||
# define __GNUC_PREREQ(maj, min) \
|
||||
((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
|
||||
# if defined __GNUC__ && defined __GNUC_MINOR__
|
||||
# define __GNUC_PREREQ(maj, min) ((maj) < __GNUC__ + ((min) <= __GNUC_MINOR__))
|
||||
# else
|
||||
# define __GNUC_PREREQ(maj, min) 0
|
||||
# endif
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* Declarations for getopt (basic, portable features only).
|
||||
Copyright (C) 1989-2024 Free Software Foundation, Inc.
|
||||
Copyright (C) 1989-2025 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library and is also part of gnulib.
|
||||
Patches to this file should be submitted to both projects.
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* Declarations for getopt (GNU extensions).
|
||||
Copyright (C) 1989-2024 Free Software Foundation, Inc.
|
||||
Copyright (C) 1989-2025 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library and is also part of gnulib.
|
||||
Patches to this file should be submitted to both projects.
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* getopt (basic, portable features) gnulib wrapper header.
|
||||
Copyright (C) 1989-2024 Free Software Foundation, Inc.
|
||||
Copyright (C) 1989-2025 Free Software Foundation, Inc.
|
||||
This file is part of gnulib.
|
||||
Unlike most of the getopt implementation, it is NOT shared
|
||||
with the GNU C Library.
|
||||
|
|
@ -31,6 +31,16 @@
|
|||
functions and variables. Renaming avoids problems with some
|
||||
compilers and linkers. */
|
||||
#ifdef __GETOPT_PREFIX
|
||||
|
||||
/* Include platform-dependent header files that may declare getopt() and
|
||||
friends. */
|
||||
# if defined _AIX || defined __hpux || defined __sun || defined __QNX__
|
||||
# include <stdio.h>
|
||||
# endif
|
||||
# if defined MUSL_LIBC || (defined __FreeBSD__ || defined __DragonFly__) || defined __NetBSD__ || defined __OpenBSD__ || (defined __APPLE__ && defined __MACH__) || defined _AIX || defined __sun || defined __minix || defined __HAIKU__
|
||||
# include <unistd.h>
|
||||
# endif
|
||||
|
||||
# ifndef __GETOPT_ID
|
||||
# define __GETOPT_CONCAT(x, y) x ## y
|
||||
# define __GETOPT_XCONCAT(x, y) __GETOPT_CONCAT (x, y)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* getopt (GNU extensions) gnulib wrapper header.
|
||||
Copyright (C) 1989-2024 Free Software Foundation, Inc.
|
||||
Copyright (C) 1989-2025 Free Software Foundation, Inc.
|
||||
This file is part of gnulib.
|
||||
Unlike most of the getopt implementation, it is NOT shared
|
||||
with the GNU C Library.
|
||||
|
|
@ -38,11 +38,9 @@
|
|||
# endif
|
||||
# undef getopt_long
|
||||
# undef getopt_long_only
|
||||
# undef option
|
||||
# undef _getopt_internal
|
||||
# define getopt_long __GETOPT_ID (getopt_long)
|
||||
# define getopt_long_only __GETOPT_ID (getopt_long_only)
|
||||
# define option __GETOPT_ID (option)
|
||||
# define _getopt_internal __GETOPT_ID (getopt_internal)
|
||||
|
||||
/* The system's getopt.h may have already included getopt-ext.h to
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* Getopt for GNU.
|
||||
Copyright (C) 1987-2024 Free Software Foundation, Inc.
|
||||
Copyright (C) 1987-2025 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library and is also part of gnulib.
|
||||
Patches to this file should be submitted to both projects.
|
||||
|
||||
|
|
@ -42,7 +42,7 @@
|
|||
# define funlockfile(fp) _IO_funlockfile (fp)
|
||||
#else
|
||||
# include "gettext.h"
|
||||
# define _(msgid) gettext (msgid)
|
||||
# define _(msgid) dgettext ("gnulib", msgid)
|
||||
/* When used standalone, flockfile and funlockfile might not be
|
||||
available. */
|
||||
# if (!defined _POSIX_THREAD_SAFE_FUNCTIONS \
|
||||
|
|
@ -723,7 +723,7 @@ _getopt_internal (int argc, char **argv, const char *optstring,
|
|||
return result;
|
||||
}
|
||||
|
||||
/* glibc gets a LSB-compliant getopt and a POSIX-complaint __posix_getopt.
|
||||
/* glibc gets a LSB-compliant getopt and a POSIX-compliant __posix_getopt.
|
||||
Standalone applications just get a POSIX-compliant getopt.
|
||||
POSIX and LSB both require these functions to take 'char *const *argv'
|
||||
even though this is incorrect (because of the permutation). */
|
||||
|
|
@ -732,7 +732,7 @@ _getopt_internal (int argc, char **argv, const char *optstring,
|
|||
NAME (int argc, char *const *argv, const char *optstring) \
|
||||
{ \
|
||||
return _getopt_internal (argc, (char **)argv, optstring, \
|
||||
0, 0, 0, POSIXLY_CORRECT); \
|
||||
NULL, NULL, 0, POSIXLY_CORRECT); \
|
||||
}
|
||||
|
||||
#ifdef _LIBC
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* Declarations for getopt.
|
||||
Copyright (C) 1989-2024 Free Software Foundation, Inc.
|
||||
Copyright (C) 1989-2025 Free Software Foundation, Inc.
|
||||
This file is part of gnulib.
|
||||
Unlike most of the getopt implementation, it is NOT shared
|
||||
with the GNU C Library, which supplies a different version of
|
||||
|
|
@ -30,7 +30,12 @@
|
|||
<getopt.h>; our definitions will be present soon enough. */
|
||||
#if @HAVE_GETOPT_H@
|
||||
# define _GL_SYSTEM_GETOPT
|
||||
/* Rename the system's 'struct option' to 'struct sys_option',
|
||||
so that we don't have to rename ours to 'struct rpl_option'
|
||||
(which would cause significant trouble in C++ mode). */
|
||||
# define option sys_option
|
||||
# @INCLUDE_NEXT@ @NEXT_GETOPT_H@
|
||||
# undef option
|
||||
# undef _GL_SYSTEM_GETOPT
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* getopt_long and getopt_long_only entry points for GNU getopt.
|
||||
Copyright (C) 1987-2024 Free Software Foundation, Inc.
|
||||
Copyright (C) 1987-2025 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library and is also part of gnulib.
|
||||
Patches to this file should be submitted to both projects.
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* Internal declarations for getopt.
|
||||
Copyright (C) 1989-2024 Free Software Foundation, Inc.
|
||||
Copyright (C) 1989-2025 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library and is also part of gnulib.
|
||||
Patches to this file should be submitted to both projects.
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* Program name management.
|
||||
Copyright (C) 2016-2024 Free Software Foundation, Inc.
|
||||
Copyright (C) 2016-2025 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* Program name management.
|
||||
Copyright (C) 2016-2024 Free Software Foundation, Inc.
|
||||
Copyright (C) 2016-2025 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
|
|
|
|||
114
gl/gettext.h
114
gl/gettext.h
|
|
@ -1,6 +1,5 @@
|
|||
/* Convenience header for conditional use of GNU <libintl.h>.
|
||||
Copyright (C) 1995-1998, 2000-2002, 2004-2006, 2009-2024 Free Software
|
||||
Foundation, Inc.
|
||||
Copyright (C) 1995-2025 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
|
||||
|
|
@ -18,6 +17,7 @@
|
|||
#ifndef _LIBGETTEXT_H
|
||||
#define _LIBGETTEXT_H 1
|
||||
|
||||
|
||||
/* NLS can be disabled through the configure --disable-nls option
|
||||
or through "#define ENABLE NLS 0" before including this file. */
|
||||
#if defined ENABLE_NLS && ENABLE_NLS
|
||||
|
|
@ -45,32 +45,90 @@
|
|||
as well because people using "gettext.h" will not include <libintl.h>,
|
||||
and also including <libintl.h> would fail on SunOS 4, whereas <locale.h>
|
||||
is OK. */
|
||||
#if defined(__sun)
|
||||
# include <locale.h>
|
||||
#endif
|
||||
# if defined(__sun)
|
||||
# include <locale.h>
|
||||
# endif
|
||||
|
||||
/* Many header files from the libstdc++ coming with g++ 3.3 or newer include
|
||||
<libintl.h>, which chokes if dcgettext is defined as a macro. So include
|
||||
it now, to make later inclusions of <libintl.h> a NOP. */
|
||||
#if defined(__cplusplus) && defined(__GNUG__) && (__GNUC__ >= 3)
|
||||
# include <cstdlib>
|
||||
# if (__GLIBC__ >= 2 && !defined __UCLIBC__) || _GLIBCXX_HAVE_LIBINTL_H
|
||||
# include <libintl.h>
|
||||
# if defined(__cplusplus) && defined(__GNUG__) && (__GNUC__ >= 3)
|
||||
# include <cstdlib>
|
||||
# if (__GLIBC__ >= 2 && !defined __UCLIBC__) || _GLIBCXX_HAVE_LIBINTL_H
|
||||
# include <libintl.h>
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Disabled NLS.
|
||||
The casts to 'const char *' serve the purpose of producing warnings
|
||||
for invalid uses of the value returned from these functions.
|
||||
On pre-ANSI systems without 'const', the config.h file is supposed to
|
||||
contain "#define const". */
|
||||
# undef gettext
|
||||
# define gettext(Msgid) ((const char *) (Msgid))
|
||||
# undef dgettext
|
||||
# define dgettext(Domainname, Msgid) ((void) (Domainname), gettext (Msgid))
|
||||
# undef dcgettext
|
||||
# define dcgettext(Domainname, Msgid, Category) \
|
||||
((void) (Category), dgettext (Domainname, Msgid))
|
||||
/* Disabled NLS. */
|
||||
# if defined __GNUC__ && !defined __clang__ && !defined __cplusplus
|
||||
/* Use inline functions, to avoid warnings
|
||||
warning: format not a string literal and no format arguments
|
||||
that don't occur with enabled NLS. */
|
||||
/* The return type 'const char *' serves the purpose of producing warnings
|
||||
for invalid uses of the value returned from these functions. */
|
||||
# if __GNUC__ >= 9
|
||||
# pragma GCC diagnostic push
|
||||
# pragma GCC diagnostic ignored "-Wbuiltin-declaration-mismatch"
|
||||
# endif
|
||||
# if __GNUC__ + (__GNUC_MINOR__ >= 2) > 4
|
||||
__attribute__ ((__always_inline__, __gnu_inline__))
|
||||
# else
|
||||
__attribute__ ((__always_inline__))
|
||||
# endif
|
||||
extern inline
|
||||
# if !defined(__sun)
|
||||
const
|
||||
# endif
|
||||
char *
|
||||
gettext (const char *msgid)
|
||||
{
|
||||
return msgid;
|
||||
}
|
||||
# if __GNUC__ + (__GNUC_MINOR__ >= 2) > 4
|
||||
__attribute__ ((__always_inline__, __gnu_inline__))
|
||||
# else
|
||||
__attribute__ ((__always_inline__))
|
||||
# endif
|
||||
extern inline
|
||||
# if !defined(__sun)
|
||||
const
|
||||
# endif
|
||||
char *
|
||||
dgettext (const char *domain, const char *msgid)
|
||||
{
|
||||
(void) domain;
|
||||
return msgid;
|
||||
}
|
||||
# if __GNUC__ + (__GNUC_MINOR__ >= 2) > 4
|
||||
__attribute__ ((__always_inline__, __gnu_inline__))
|
||||
# else
|
||||
__attribute__ ((__always_inline__))
|
||||
# endif
|
||||
extern inline
|
||||
# if !defined(__sun)
|
||||
const
|
||||
# endif
|
||||
char *
|
||||
dcgettext (const char *domain, const char *msgid, int category)
|
||||
{
|
||||
(void) domain;
|
||||
(void) category;
|
||||
return msgid;
|
||||
}
|
||||
# if __GNUC__ >= 9
|
||||
# pragma GCC diagnostic pop
|
||||
# endif
|
||||
# else
|
||||
/* The casts to 'const char *' serve the purpose of producing warnings
|
||||
for invalid uses of the value returned from these functions. */
|
||||
# undef gettext
|
||||
# define gettext(Msgid) ((const char *) (Msgid))
|
||||
# undef dgettext
|
||||
# define dgettext(Domainname, Msgid) ((void) (Domainname), gettext (Msgid))
|
||||
# undef dcgettext
|
||||
# define dcgettext(Domainname, Msgid, Category) \
|
||||
((void) (Category), dgettext (Domainname, Msgid))
|
||||
# endif
|
||||
# undef ngettext
|
||||
# define ngettext(Msgid1, Msgid2, N) \
|
||||
((N) == 1 \
|
||||
|
|
@ -93,12 +151,14 @@
|
|||
|
||||
#endif
|
||||
|
||||
|
||||
/* Prefer gnulib's setlocale override over libintl's setlocale override. */
|
||||
#ifdef GNULIB_defined_setlocale
|
||||
# undef setlocale
|
||||
# define setlocale rpl_setlocale
|
||||
#endif
|
||||
|
||||
|
||||
/* A pseudo function call that serves as a marker for the automated
|
||||
extraction of messages, but does not call gettext(). The run-time
|
||||
translation is done at a different place in the code.
|
||||
|
|
@ -108,6 +168,7 @@
|
|||
initializer for static 'char[]' or 'const char[]' variables. */
|
||||
#define gettext_noop(String) String
|
||||
|
||||
|
||||
/* The separator between msgctxt and msgid in a .mo file. */
|
||||
#define GETTEXT_CONTEXT_GLUE "\004"
|
||||
|
||||
|
|
@ -115,6 +176,9 @@
|
|||
MSGID. MSGCTXT and MSGID must be string literals. MSGCTXT should be
|
||||
short and rarely need to change.
|
||||
The letter 'p' stands for 'particular' or 'special'. */
|
||||
|
||||
#include <locale.h> /* for LC_MESSAGES */
|
||||
|
||||
#ifdef DEFAULT_TEXT_DOMAIN
|
||||
# define pgettext(Msgctxt, Msgid) \
|
||||
pgettext_aux (DEFAULT_TEXT_DOMAIN, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, LC_MESSAGES)
|
||||
|
|
@ -178,11 +242,12 @@ npgettext_aux (const char *domain,
|
|||
return translation;
|
||||
}
|
||||
|
||||
|
||||
/* The same thing extended for non-constant arguments. Here MSGCTXT and MSGID
|
||||
can be arbitrary expressions. But for string literals these macros are
|
||||
less efficient than those above. */
|
||||
|
||||
#include <string.h>
|
||||
#include <string.h> /* for memcpy */
|
||||
|
||||
/* GNULIB_NO_VLA can be defined to disable use of VLAs even if supported.
|
||||
This relates to the -Wvla and -Wvla-larger-than warnings, enabled in
|
||||
|
|
@ -199,7 +264,7 @@ npgettext_aux (const char *domain,
|
|||
#endif
|
||||
|
||||
#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
|
||||
#include <stdlib.h>
|
||||
# include <stdlib.h> /* for malloc, free */
|
||||
#endif
|
||||
|
||||
#define pgettext_expr(Msgctxt, Msgid) \
|
||||
|
|
@ -297,4 +362,5 @@ dcnpgettext_expr (const char *domain,
|
|||
return (n == 1 ? msgid : msgid_plural);
|
||||
}
|
||||
|
||||
|
||||
#endif /* _LIBGETTEXT_H */
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/* Wrap openssl crypto hash routines in gnulib interface. -*- coding: utf-8 -*-
|
||||
|
||||
Copyright (C) 2013-2024 Free Software Foundation, Inc.
|
||||
Copyright (C) 2013-2025 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
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue