summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/getopt-pfx-core.h2
-rw-r--r--lib/gnulib.mk.in17
-rw-r--r--lib/limits.in.h13
-rw-r--r--lib/math.in.h2
-rw-r--r--lib/stpncpy.c92
-rw-r--r--lib/string.in.h4
6 files changed, 122 insertions, 8 deletions
diff --git a/lib/getopt-pfx-core.h b/lib/getopt-pfx-core.h
index 3a2fde5ad4f..095e3930feb 100644
--- a/lib/getopt-pfx-core.h
+++ b/lib/getopt-pfx-core.h
@@ -47,7 +47,7 @@
# define optind __GETOPT_ID (optind)
# define optopt __GETOPT_ID (optopt)
-/* Work around a a problem on macOS, which declares getopt with a
+/* Work around a problem on macOS, which declares getopt with a
trailing __DARWIN_ALIAS(getopt) that would expand to something like
__asm("_" "rpl_getopt" "$UNIX2003") were it not for the following
hack to suppress the macOS declaration <https://bugs.gnu.org/40205>. */
diff --git a/lib/gnulib.mk.in b/lib/gnulib.mk.in
index 4746f5f86f2..e577d8063fd 100644
--- a/lib/gnulib.mk.in
+++ b/lib/gnulib.mk.in
@@ -152,6 +152,7 @@
# stddef \
# stdio \
# stpcpy \
+# stpncpy \
# strnlen \
# strtoimax \
# symlink \
@@ -191,6 +192,7 @@ ANDROID_LIBS = @ANDROID_LIBS@
ANDROID_MIN_SDK = @ANDROID_MIN_SDK@
ANDROID_OBJ = @ANDROID_OBJ@
ANDROID_SDK_18_OR_EARLIER = @ANDROID_SDK_18_OR_EARLIER@
+ANDROID_SDK_8_OR_EARLIER = @ANDROID_SDK_8_OR_EARLIER@
APKSIGNER = @APKSIGNER@
APPLE_UNIVERSAL_BUILD = @APPLE_UNIVERSAL_BUILD@
AR = @AR@
@@ -330,6 +332,7 @@ GL_COND_OBJ_SIGNBIT3_CONDITION = @GL_COND_OBJ_SIGNBIT3_CONDITION@
GL_COND_OBJ_STDIO_READ_CONDITION = @GL_COND_OBJ_STDIO_READ_CONDITION@
GL_COND_OBJ_STDIO_WRITE_CONDITION = @GL_COND_OBJ_STDIO_WRITE_CONDITION@
GL_COND_OBJ_STPCPY_CONDITION = @GL_COND_OBJ_STPCPY_CONDITION@
+GL_COND_OBJ_STPNCPY_CONDITION = @GL_COND_OBJ_STPNCPY_CONDITION@
GL_COND_OBJ_STRNLEN_CONDITION = @GL_COND_OBJ_STRNLEN_CONDITION@
GL_COND_OBJ_STRTOIMAX_CONDITION = @GL_COND_OBJ_STRTOIMAX_CONDITION@
GL_COND_OBJ_STRTOLL_CONDITION = @GL_COND_OBJ_STRTOLL_CONDITION@
@@ -1150,6 +1153,7 @@ LIBRESOLV = @LIBRESOLV@
LIBS = @LIBS@
LIBSECCOMP_CFLAGS = @LIBSECCOMP_CFLAGS@
LIBSECCOMP_LIBS = @LIBSECCOMP_LIBS@
+LIBSELINUX_CFLAGS = @LIBSELINUX_CFLAGS@
LIBSELINUX_LIBS = @LIBSELINUX_LIBS@
LIBSOUND = @LIBSOUND@
LIBSYSTEMD_CFLAGS = @LIBSYSTEMD_CFLAGS@
@@ -1203,6 +1207,7 @@ NDK_BUILD_ANY_CXX_MODULE = @NDK_BUILD_ANY_CXX_MODULE@
NDK_BUILD_AR = @NDK_BUILD_AR@
NDK_BUILD_ARCH = @NDK_BUILD_ARCH@
NDK_BUILD_CC = @NDK_BUILD_CC@
+NDK_BUILD_CFLAGS = @NDK_BUILD_CFLAGS@
NDK_BUILD_CXX_SHARED = @NDK_BUILD_CXX_SHARED@
NDK_BUILD_MODULES = @NDK_BUILD_MODULES@
NDK_BUILD_NASM = @NDK_BUILD_NASM@
@@ -1554,7 +1559,7 @@ REPLACE_WRITE = @REPLACE_WRITE@
REPLACE__EXIT = @REPLACE__EXIT@
RSVG_CFLAGS = @RSVG_CFLAGS@
RSVG_LIBS = @RSVG_LIBS@
-SDK_BULD_TOOLS = @SDK_BULD_TOOLS@
+SDK_BUILD_TOOLS = @SDK_BUILD_TOOLS@
SEPCHAR = @SEPCHAR@
SETFATTR = @SETFATTR@
SETTINGS_CFLAGS = @SETTINGS_CFLAGS@
@@ -4184,6 +4189,16 @@ endif
endif
## end gnulib module stpcpy
+## begin gnulib module stpncpy
+ifeq (,$(OMIT_GNULIB_MODULE_stpncpy))
+
+ifneq (,$(GL_COND_OBJ_STPNCPY_CONDITION))
+libgnu_a_SOURCES += stpncpy.c
+endif
+
+endif
+## end gnulib module stpncpy
+
## begin gnulib module string
ifeq (,$(OMIT_GNULIB_MODULE_string))
diff --git a/lib/limits.in.h b/lib/limits.in.h
index eaeac472299..a01b4c6a280 100644
--- a/lib/limits.in.h
+++ b/lib/limits.in.h
@@ -119,11 +119,14 @@
/* Macros specified by C23. */
-#if (! defined BOOL_WIDTH \
- && (defined _GNU_SOURCE \
- || (defined __STDC_VERSION__ && 201710 < __STDC_VERSION__)))
-# define BOOL_MAX 1
-# define BOOL_WIDTH 1
+#if (defined _GNU_SOURCE \
+ || (defined __STDC_VERSION__ && 201710 < __STDC_VERSION__))
+# if ! defined BOOL_WIDTH
+# define BOOL_WIDTH 1
+# define BOOL_MAX 1
+# elif ! defined BOOL_MAX
+# define BOOL_MAX ((((1U << (BOOL_WIDTH - 1)) - 1) << 1) + 1)
+# endif
#endif
#endif /* _@GUARD_PREFIX@_LIMITS_H */
diff --git a/lib/math.in.h b/lib/math.in.h
index 70b75e2399e..76d48a44437 100644
--- a/lib/math.in.h
+++ b/lib/math.in.h
@@ -2624,7 +2624,7 @@ _GL_EXTERN_C int rpl_isnanl (long double x) _GL_ATTRIBUTE_CONST;
# if defined isnan || defined GNULIB_NAMESPACE
_GL_MATH_CXX_REAL_FLOATING_DECL_1 (isnan)
# undef isnan
-# if __GNUC__ >= 6 || (defined __clang__ && !((defined __APPLE__ && defined __MACH__ && __clang_major__ < 12) || (defined __FreeBSD__ && (__clang_major__ < 7 || __clang_major__ >= 11)) || defined __OpenBSD__ || (defined _WIN32 && !defined __CYGWIN__)))
+# if __GNUC__ >= 6 || (defined __clang__ && !((defined __APPLE__ && defined __MACH__ && __clang_major__ != 12) || (defined __FreeBSD__ && (__clang_major__ < 7 || __clang_major__ >= 11)) || defined __OpenBSD__ || (defined _WIN32 && !defined __CYGWIN__)))
/* This platform's <cmath> possibly defines isnan through a set of inline
functions. */
_GL_MATH_CXX_REAL_FLOATING_DECL_2 (isnan, rpl_isnan, bool)
diff --git a/lib/stpncpy.c b/lib/stpncpy.c
new file mode 100644
index 00000000000..d1422a927df
--- /dev/null
+++ b/lib/stpncpy.c
@@ -0,0 +1,92 @@
+/* Copyright (C) 1993, 1995-1997, 2002-2003, 2005-2007, 2009-2023 Free Software
+ * Foundation, Inc.
+
+ NOTE: The canonical source of this file is maintained with the GNU C Library.
+ Bugs can be reported to bug-glibc@gnu.org.
+
+ 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/>. */
+
+/* This is almost copied from strncpy.c, written by Torbjorn Granlund. */
+
+#include <config.h>
+
+/* Specification. */
+#include <string.h>
+
+#ifndef weak_alias
+# define __stpncpy stpncpy
+#endif
+
+/* Copy no more than N bytes of SRC to DST, returning a pointer past the
+ last non-NUL byte written into DST. */
+char *
+(__stpncpy) (char *dest, const char *src, size_t n)
+{
+ char c;
+ char *s = dest;
+
+ if (n >= 4)
+ {
+ size_t n4 = n >> 2;
+
+ for (;;)
+ {
+ c = *src++;
+ *dest++ = c;
+ if (c == '\0')
+ break;
+ c = *src++;
+ *dest++ = c;
+ if (c == '\0')
+ break;
+ c = *src++;
+ *dest++ = c;
+ if (c == '\0')
+ break;
+ c = *src++;
+ *dest++ = c;
+ if (c == '\0')
+ break;
+ if (--n4 == 0)
+ goto last_chars;
+ }
+ n -= dest - s;
+ goto zero_fill;
+ }
+
+ last_chars:
+ n &= 3;
+ if (n == 0)
+ return dest;
+
+ for (;;)
+ {
+ c = *src++;
+ --n;
+ *dest++ = c;
+ if (c == '\0')
+ break;
+ if (n == 0)
+ return dest;
+ }
+
+ zero_fill:
+ while (n-- > 0)
+ dest[n] = '\0';
+
+ return dest - 1;
+}
+#ifdef weak_alias
+weak_alias (__stpncpy, stpncpy)
+#endif
diff --git a/lib/string.in.h b/lib/string.in.h
index aa088213927..b6bf432e1f1 100644
--- a/lib/string.in.h
+++ b/lib/string.in.h
@@ -126,7 +126,11 @@
# if (@REPLACE_FREE@ && !defined free \
&& !(defined __cplusplus && defined GNULIB_NAMESPACE))
/* We can't do '#define free rpl_free' here. */
+# if defined __cplusplus && (__GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2)
+_GL_EXTERN_C void rpl_free (void *) throw ();
+# else
_GL_EXTERN_C void rpl_free (void *);
+# endif
# undef _GL_ATTRIBUTE_DEALLOC_FREE
# define _GL_ATTRIBUTE_DEALLOC_FREE _GL_ATTRIBUTE_DEALLOC (rpl_free, 1)
# else