aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorPo Lu2023-02-21 16:29:57 +0800
committerPo Lu2023-02-21 16:29:57 +0800
commit8ca4162ecdb174e59d59fc127a1bc4fef7b89fa2 (patch)
tree7af0e3cbc48c5bba714d68ba05885a4bd0e1da52 /lib
parent7aa4ffddd842e495d1ae388afff12075317ecb07 (diff)
downloademacs-8ca4162ecdb174e59d59fc127a1bc4fef7b89fa2.tar.gz
emacs-8ca4162ecdb174e59d59fc127a1bc4fef7b89fa2.zip
Update from gnulib
* admin/merge-gnulib (GNULIB_MODULES): * cross/lib/getopt-pfx-core.h (optind): * cross/lib/limits.in.h (BOOL_WIDTH): * cross/lib/math.in.h: * cross/lib/stpncpy.c (__stpncpy): * cross/lib/string.in.h: * lib/getopt-pfx-core.h (optind): * lib/gnulib.mk.in (ANDROID_MIN_SDK): (GL_COND_OBJ_STDIO_READ_CONDITION): (LIBS): (NDK_BUILD_AR): (REPLACE__EXIT): (libgnu_a_SOURCES): * lib/limits.in.h (BOOL_WIDTH): * lib/math.in.h: * lib/stpncpy.c (__stpncpy): * lib/string.in.h: * m4/assert_h.m4 (gl_ASSERT_H): * m4/fdopendir.m4 (gl_FUNC_FDOPENDIR): * m4/getdelim.m4 (gl_FUNC_GETDELIM): * m4/getline.m4 (gl_FUNC_GETLINE): * m4/gnulib-common.m4 (gl_COMMON_BODY): (gl_CONDITIONAL_HEADER): (gl_CHECK_FUNCS_ANDROID): * m4/gnulib-comp.m4 (gl_EARLY): (gl_INIT): (gl_FILE_LIST): * m4/limits-h.m4: * m4/lstat.m4 (gl_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK): * m4/malloc.m4 (_AC_FUNC_MALLOC_IF): * m4/printf.m4 (gl_PRINTF_SIZES_C99): (gl_PRINTF_INFINITE): (gl_PRINTF_INFINITE_LONG_DOUBLE): (gl_PRINTF_DIRECTIVE_A): (gl_PRINTF_DIRECTIVE_F): (gl_PRINTF_FLAG_ZERO): (gl_SNPRINTF_PRESENCE): (gl_SNPRINTF_DIRECTIVE_N): (gl_VSNPRINTF_ZEROSIZE_C99): * m4/pselect.m4 (gl_FUNC_PSELECT): * m4/readlink.m4 (gl_FUNC_READLINK): * m4/realloc.m4 (_AC_FUNC_REALLOC_IF): * m4/signbit.m4 (gl_SIGNBIT): * m4/stpncpy.m4 (gl_FUNC_STPNCPY): * m4/symlink.m4 (gl_FUNC_SYMLINK): Add gnulib module stpncpy. * src/android.c: Include string.h.
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 @@
47# define optind __GETOPT_ID (optind) 47# define optind __GETOPT_ID (optind)
48# define optopt __GETOPT_ID (optopt) 48# define optopt __GETOPT_ID (optopt)
49 49
50/* Work around a a problem on macOS, which declares getopt with a 50/* Work around a problem on macOS, which declares getopt with a
51 trailing __DARWIN_ALIAS(getopt) that would expand to something like 51 trailing __DARWIN_ALIAS(getopt) that would expand to something like
52 __asm("_" "rpl_getopt" "$UNIX2003") were it not for the following 52 __asm("_" "rpl_getopt" "$UNIX2003") were it not for the following
53 hack to suppress the macOS declaration <https://bugs.gnu.org/40205>. */ 53 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 @@
152# stddef \ 152# stddef \
153# stdio \ 153# stdio \
154# stpcpy \ 154# stpcpy \
155# stpncpy \
155# strnlen \ 156# strnlen \
156# strtoimax \ 157# strtoimax \
157# symlink \ 158# symlink \
@@ -191,6 +192,7 @@ ANDROID_LIBS = @ANDROID_LIBS@
191ANDROID_MIN_SDK = @ANDROID_MIN_SDK@ 192ANDROID_MIN_SDK = @ANDROID_MIN_SDK@
192ANDROID_OBJ = @ANDROID_OBJ@ 193ANDROID_OBJ = @ANDROID_OBJ@
193ANDROID_SDK_18_OR_EARLIER = @ANDROID_SDK_18_OR_EARLIER@ 194ANDROID_SDK_18_OR_EARLIER = @ANDROID_SDK_18_OR_EARLIER@
195ANDROID_SDK_8_OR_EARLIER = @ANDROID_SDK_8_OR_EARLIER@
194APKSIGNER = @APKSIGNER@ 196APKSIGNER = @APKSIGNER@
195APPLE_UNIVERSAL_BUILD = @APPLE_UNIVERSAL_BUILD@ 197APPLE_UNIVERSAL_BUILD = @APPLE_UNIVERSAL_BUILD@
196AR = @AR@ 198AR = @AR@
@@ -330,6 +332,7 @@ GL_COND_OBJ_SIGNBIT3_CONDITION = @GL_COND_OBJ_SIGNBIT3_CONDITION@
330GL_COND_OBJ_STDIO_READ_CONDITION = @GL_COND_OBJ_STDIO_READ_CONDITION@ 332GL_COND_OBJ_STDIO_READ_CONDITION = @GL_COND_OBJ_STDIO_READ_CONDITION@
331GL_COND_OBJ_STDIO_WRITE_CONDITION = @GL_COND_OBJ_STDIO_WRITE_CONDITION@ 333GL_COND_OBJ_STDIO_WRITE_CONDITION = @GL_COND_OBJ_STDIO_WRITE_CONDITION@
332GL_COND_OBJ_STPCPY_CONDITION = @GL_COND_OBJ_STPCPY_CONDITION@ 334GL_COND_OBJ_STPCPY_CONDITION = @GL_COND_OBJ_STPCPY_CONDITION@
335GL_COND_OBJ_STPNCPY_CONDITION = @GL_COND_OBJ_STPNCPY_CONDITION@
333GL_COND_OBJ_STRNLEN_CONDITION = @GL_COND_OBJ_STRNLEN_CONDITION@ 336GL_COND_OBJ_STRNLEN_CONDITION = @GL_COND_OBJ_STRNLEN_CONDITION@
334GL_COND_OBJ_STRTOIMAX_CONDITION = @GL_COND_OBJ_STRTOIMAX_CONDITION@ 337GL_COND_OBJ_STRTOIMAX_CONDITION = @GL_COND_OBJ_STRTOIMAX_CONDITION@
335GL_COND_OBJ_STRTOLL_CONDITION = @GL_COND_OBJ_STRTOLL_CONDITION@ 338GL_COND_OBJ_STRTOLL_CONDITION = @GL_COND_OBJ_STRTOLL_CONDITION@
@@ -1150,6 +1153,7 @@ LIBRESOLV = @LIBRESOLV@
1150LIBS = @LIBS@ 1153LIBS = @LIBS@
1151LIBSECCOMP_CFLAGS = @LIBSECCOMP_CFLAGS@ 1154LIBSECCOMP_CFLAGS = @LIBSECCOMP_CFLAGS@
1152LIBSECCOMP_LIBS = @LIBSECCOMP_LIBS@ 1155LIBSECCOMP_LIBS = @LIBSECCOMP_LIBS@
1156LIBSELINUX_CFLAGS = @LIBSELINUX_CFLAGS@
1153LIBSELINUX_LIBS = @LIBSELINUX_LIBS@ 1157LIBSELINUX_LIBS = @LIBSELINUX_LIBS@
1154LIBSOUND = @LIBSOUND@ 1158LIBSOUND = @LIBSOUND@
1155LIBSYSTEMD_CFLAGS = @LIBSYSTEMD_CFLAGS@ 1159LIBSYSTEMD_CFLAGS = @LIBSYSTEMD_CFLAGS@
@@ -1203,6 +1207,7 @@ NDK_BUILD_ANY_CXX_MODULE = @NDK_BUILD_ANY_CXX_MODULE@
1203NDK_BUILD_AR = @NDK_BUILD_AR@ 1207NDK_BUILD_AR = @NDK_BUILD_AR@
1204NDK_BUILD_ARCH = @NDK_BUILD_ARCH@ 1208NDK_BUILD_ARCH = @NDK_BUILD_ARCH@
1205NDK_BUILD_CC = @NDK_BUILD_CC@ 1209NDK_BUILD_CC = @NDK_BUILD_CC@
1210NDK_BUILD_CFLAGS = @NDK_BUILD_CFLAGS@
1206NDK_BUILD_CXX_SHARED = @NDK_BUILD_CXX_SHARED@ 1211NDK_BUILD_CXX_SHARED = @NDK_BUILD_CXX_SHARED@
1207NDK_BUILD_MODULES = @NDK_BUILD_MODULES@ 1212NDK_BUILD_MODULES = @NDK_BUILD_MODULES@
1208NDK_BUILD_NASM = @NDK_BUILD_NASM@ 1213NDK_BUILD_NASM = @NDK_BUILD_NASM@
@@ -1554,7 +1559,7 @@ REPLACE_WRITE = @REPLACE_WRITE@
1554REPLACE__EXIT = @REPLACE__EXIT@ 1559REPLACE__EXIT = @REPLACE__EXIT@
1555RSVG_CFLAGS = @RSVG_CFLAGS@ 1560RSVG_CFLAGS = @RSVG_CFLAGS@
1556RSVG_LIBS = @RSVG_LIBS@ 1561RSVG_LIBS = @RSVG_LIBS@
1557SDK_BULD_TOOLS = @SDK_BULD_TOOLS@ 1562SDK_BUILD_TOOLS = @SDK_BUILD_TOOLS@
1558SEPCHAR = @SEPCHAR@ 1563SEPCHAR = @SEPCHAR@
1559SETFATTR = @SETFATTR@ 1564SETFATTR = @SETFATTR@
1560SETTINGS_CFLAGS = @SETTINGS_CFLAGS@ 1565SETTINGS_CFLAGS = @SETTINGS_CFLAGS@
@@ -4184,6 +4189,16 @@ endif
4184endif 4189endif
4185## end gnulib module stpcpy 4190## end gnulib module stpcpy
4186 4191
4192## begin gnulib module stpncpy
4193ifeq (,$(OMIT_GNULIB_MODULE_stpncpy))
4194
4195ifneq (,$(GL_COND_OBJ_STPNCPY_CONDITION))
4196libgnu_a_SOURCES += stpncpy.c
4197endif
4198
4199endif
4200## end gnulib module stpncpy
4201
4187## begin gnulib module string 4202## begin gnulib module string
4188ifeq (,$(OMIT_GNULIB_MODULE_string)) 4203ifeq (,$(OMIT_GNULIB_MODULE_string))
4189 4204
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 @@
119 119
120/* Macros specified by C23. */ 120/* Macros specified by C23. */
121 121
122#if (! defined BOOL_WIDTH \ 122#if (defined _GNU_SOURCE \
123 && (defined _GNU_SOURCE \ 123 || (defined __STDC_VERSION__ && 201710 < __STDC_VERSION__))
124 || (defined __STDC_VERSION__ && 201710 < __STDC_VERSION__))) 124# if ! defined BOOL_WIDTH
125# define BOOL_MAX 1 125# define BOOL_WIDTH 1
126# define BOOL_WIDTH 1 126# define BOOL_MAX 1
127# elif ! defined BOOL_MAX
128# define BOOL_MAX ((((1U << (BOOL_WIDTH - 1)) - 1) << 1) + 1)
129# endif
127#endif 130#endif
128 131
129#endif /* _@GUARD_PREFIX@_LIMITS_H */ 132#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;
2624# if defined isnan || defined GNULIB_NAMESPACE 2624# if defined isnan || defined GNULIB_NAMESPACE
2625_GL_MATH_CXX_REAL_FLOATING_DECL_1 (isnan) 2625_GL_MATH_CXX_REAL_FLOATING_DECL_1 (isnan)
2626# undef isnan 2626# undef isnan
2627# 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__))) 2627# 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__)))
2628 /* This platform's <cmath> possibly defines isnan through a set of inline 2628 /* This platform's <cmath> possibly defines isnan through a set of inline
2629 functions. */ 2629 functions. */
2630_GL_MATH_CXX_REAL_FLOATING_DECL_2 (isnan, rpl_isnan, bool) 2630_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 @@
1/* Copyright (C) 1993, 1995-1997, 2002-2003, 2005-2007, 2009-2023 Free Software
2 * Foundation, Inc.
3
4 NOTE: The canonical source of this file is maintained with the GNU C Library.
5 Bugs can be reported to bug-glibc@gnu.org.
6
7 This file is free software: you can redistribute it and/or modify
8 it under the terms of the GNU Lesser General Public License as
9 published by the Free Software Foundation; either version 2.1 of the
10 License, or (at your option) any later version.
11
12 This file is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public License
18 along with this program. If not, see <https://www.gnu.org/licenses/>. */
19
20/* This is almost copied from strncpy.c, written by Torbjorn Granlund. */
21
22#include <config.h>
23
24/* Specification. */
25#include <string.h>
26
27#ifndef weak_alias
28# define __stpncpy stpncpy
29#endif
30
31/* Copy no more than N bytes of SRC to DST, returning a pointer past the
32 last non-NUL byte written into DST. */
33char *
34(__stpncpy) (char *dest, const char *src, size_t n)
35{
36 char c;
37 char *s = dest;
38
39 if (n >= 4)
40 {
41 size_t n4 = n >> 2;
42
43 for (;;)
44 {
45 c = *src++;
46 *dest++ = c;
47 if (c == '\0')
48 break;
49 c = *src++;
50 *dest++ = c;
51 if (c == '\0')
52 break;
53 c = *src++;
54 *dest++ = c;
55 if (c == '\0')
56 break;
57 c = *src++;
58 *dest++ = c;
59 if (c == '\0')
60 break;
61 if (--n4 == 0)
62 goto last_chars;
63 }
64 n -= dest - s;
65 goto zero_fill;
66 }
67
68 last_chars:
69 n &= 3;
70 if (n == 0)
71 return dest;
72
73 for (;;)
74 {
75 c = *src++;
76 --n;
77 *dest++ = c;
78 if (c == '\0')
79 break;
80 if (n == 0)
81 return dest;
82 }
83
84 zero_fill:
85 while (n-- > 0)
86 dest[n] = '\0';
87
88 return dest - 1;
89}
90#ifdef weak_alias
91weak_alias (__stpncpy, stpncpy)
92#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 @@
126# if (@REPLACE_FREE@ && !defined free \ 126# if (@REPLACE_FREE@ && !defined free \
127 && !(defined __cplusplus && defined GNULIB_NAMESPACE)) 127 && !(defined __cplusplus && defined GNULIB_NAMESPACE))
128/* We can't do '#define free rpl_free' here. */ 128/* We can't do '#define free rpl_free' here. */
129# if defined __cplusplus && (__GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2)
130_GL_EXTERN_C void rpl_free (void *) throw ();
131# else
129_GL_EXTERN_C void rpl_free (void *); 132_GL_EXTERN_C void rpl_free (void *);
133# endif
130# undef _GL_ATTRIBUTE_DEALLOC_FREE 134# undef _GL_ATTRIBUTE_DEALLOC_FREE
131# define _GL_ATTRIBUTE_DEALLOC_FREE _GL_ATTRIBUTE_DEALLOC (rpl_free, 1) 135# define _GL_ATTRIBUTE_DEALLOC_FREE _GL_ATTRIBUTE_DEALLOC (rpl_free, 1)
132# else 136# else