merged with master
Some checks failed
Spellcheck / codespell (push) Has been cancelled
Tests / Running unit and integrationt tests (push) Has been cancelled
Tests / Running rpm build test on almalinux:9 (push) Has been cancelled
Tests / Running rpm build test on fedora:latest (push) Has been cancelled
Tests / Running rpm build test on rockylinux:8 (push) Has been cancelled

This commit is contained in:
Andreas Baumann 2026-03-27 11:14:20 +01:00
commit 1113bbcd92
562 changed files with 5102 additions and 7340 deletions

View file

@ -19,6 +19,13 @@
'NP_HOST_TCP_HPJD' => '',
'NP_HOST_TCP_HTTP2' => 'test.monitoring-plugins.org',
'NP_HOST_TCP_HTTP' => 'localhost',
'NP_HOST_TCP_HTTP_IPV4' => '127.0.0.1',
'NP_HOST_TCP_HTTP_IPV4_CIDR_1' => '127.0.0.0/28',
'NP_HOST_TCP_HTTP_IPV4_CIDR_2' => '127.0.0.1/32',
'NP_HOST_TCP_HTTP_IPV6' => '::1',
'NP_HOST_TCP_HTTP_IPV6_CIDR_1' => '0000:0000:0000::0000:0000:0000/16',
'NP_HOST_TCP_HTTP_IPV6_CIDR_2' => '::1234:5678/16',
'NP_HOST_TCP_HTTP_SUBDOMAIN' => 'subdomain1.localhost',
'NP_HOST_TCP_IMAP' => 'imap.web.de',
'NP_HOST_TCP_JABBER' => 'jabber.org',
'NP_HOST_TCP_LDAP' => 'localhost',

View file

@ -67,10 +67,10 @@ apt-get -y install perl \
libjson-perl
# remove ipv6 interface from hosts
sed '/^::1/d' /etc/hosts > /tmp/hosts
cp -f /tmp/hosts /etc/hosts
ip addr show
cat /etc/hosts
# sed '/^::1/d' /etc/hosts > /tmp/hosts
# cp -f /tmp/hosts /etc/hosts
# ip addr show
# cat /etc/hosts
# apache
a2enmod ssl
@ -80,6 +80,19 @@ a2ensite default-ssl
rm /etc/ssl/certs/ssl-cert-snakeoil.pem
rm /etc/ssl/private/ssl-cert-snakeoil.key
openssl req -nodes -newkey rsa:2048 -x509 -sha256 -days 365 -nodes -keyout /etc/ssl/private/ssl-cert-snakeoil.key -out /etc/ssl/certs/ssl-cert-snakeoil.pem -subj "/C=GB/ST=London/L=London/O=Global Security/OU=IT Department/CN=$(hostname)"
# add a subdomain for testing
cp tools/subdomain1/subdomain1.conf /etc/apache2/sites-available/
mkdir -p /var/www/subdomain1
cp tools/subdomain1/index.php /var/www/subdomain1/
echo '127.0.0.1 subdomain1.localhost' >> /etc/hosts
echo '127.0.0.1 subdomain1.localhost.com' >> /etc/hosts
apache2ctl configtest
a2ensite subdomain1.conf
# Make it listen to both IPv4 on IPv6 on localhost
sed -i 's/^Listen 80/Listen 0.0.0.0:80\nListen [::1]:80/' /etc/apache2/ports.conf
sed -i 's/^[[:space:]]*Listen 443/Listen 0.0.0.0:443\nListen [::1]:443/' /etc/apache2/ports.conf
service apache2 restart
# squid

11
.gitignore vendored
View file

@ -52,6 +52,7 @@ NP-VERSION-FILE
# /gl/
/gl/.deps
/gl/*/.deps
/gl/alloca.h
/gl/arpa
/gl/arpa_inet.h
@ -93,9 +94,17 @@ NP-VERSION-FILE
/gl/wctype.h
/gl/inttypes.h
/gl/limits.h
/gl/pthread.h
/gl/sched.h
/gl/uchar.h
/gl/unicase.h
/gl/unictype.h
/gl/uninorm.h
/gl/unitypes.h
/gl/uniwidth.h
/gl/stdckdint.h
/gl/malloc/dynarray-skeleton.gl.h
/gl/malloc/dynarray.gl.h
/gl/stdckdint.h
# /lib/
/lib/.deps

View file

@ -475,30 +475,6 @@ AC_ARG_WITH([ipv6],
[AS_HELP_STRING([--with-ipv6], [support IPv6 @<:@default=check@:>@])],
[], [with_ipv6=check])
dnl Check for AF_INET6 support - unistd.h required for Darwin
if test "$with_ipv6" != "no"; then
AC_CACHE_CHECK([for IPv6 support], np_cv_sys_ipv6, [
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <netinet/in.h>
#include <sys/socket.h>]], [[struct sockaddr_in6 sin6;
void *p;
sin6.sin6_family = AF_INET6;
sin6.sin6_port = 587;
p = &sin6.sin6_addr;]])],[np_cv_sys_ipv6=yes],[np_cv_sys_ipv6=no])
])
if test "$np_cv_sys_ipv6" = "no" -a "$with_ipv6" != "check"; then
AC_MSG_FAILURE([--with-ipv6 was given, but test for IPv6 support failed])
fi
if test "$np_cv_sys_ipv6" = "yes"; then
AC_DEFINE(USE_IPV6,1,[Enable IPv6 support])
fi
with_ipv6="$np_cv_sys_ipv6"
fi
dnl Checks for Kerberos. Must come before openssl checks for Redhat EL 3
AC_CHECK_HEADERS(krb5.h,FOUNDINCLUDE=yes,FOUNDINCLUDE=no)
if test "$FOUNDINCLUDE" = "no"; then

View file

@ -10,7 +10,7 @@ Need to know:
1. Add member to team mailing list (https://www.monitoring-plugins.org/list/listinfo/team/)
and to the commits mailing list (https://www.monitoring-plugins.org/list/listinfo/commits/),
add sourceforge email address via Privacy Options->Sender filters)
add sourceforge email address via Privacy Options->Sender filters
2. Add Sourceforge access:
- Translator: CVS access, Shell access, Release Tech (no)
- Developer: Project role: Developer, CVS access, Shell access, Release Tech (no), Task Manager (A&T),

View file

@ -9,7 +9,7 @@ using the remote name `monitoring-plugins` (rather than `origin`).
Before you start
----------------
- Check Github Actions status.
- Check GitHub Actions status.
- Update local Git repository to the current `master` tip. For a
maintenance release (e.g., version 2.4.1), update to the current
`maint-2.4` tip, instead.

View file

@ -23,9 +23,9 @@
<preface id="preface"><title>Preface</title>
<para>The purpose of this guidelines is to provide a reference for
<para>The purpose of these guidelines is to provide a reference for
the plugin developers and encourage the standardization of the
different kind of plugins: C, shell, perl, python, etc.</para>
different kinds of plugins: C, shell, perl, python, etc.</para>
<para>Monitoring Plugins Development Guidelines Copyright (C) 2000-2024
(Monitoring Plugins Team)</para>
@ -68,7 +68,7 @@
<para>You should always print something to STDOUT that tells if the
service is working or why it is failing. Try to keep the output short -
probably less that 80 characters. Remember that you ideally would like
probably less than 80 characters. Remember that you ideally would like
the entire output to appear in a pager message, which will get chopped
off after a certain length.</para>
@ -214,7 +214,7 @@
back a numerical value, or metric, which is then compared to the warning and
critical thresholds. Use the get_status(double, thresholds *) function to
compare the value against the thresholds.</para>
<para>This is the generalised format for ranges:</para>
<para>This is the generalized format for ranges:</para>
<literallayout>
[@]start:end
@ -474,7 +474,7 @@
</listitem>
<listitem><para>If writing to a file (perhaps recording
performance data) explicitly close close it. The plugin never
performance data) explicitly close it. The plugin never
calls <emphasis role="strong">exit</emphasis>; that is caught by
p1.pl, so output streams are never closed.</para>
</listitem>

View file

@ -1,6 +1,6 @@
## DO NOT EDIT! GENERATED AUTOMATICALLY!
## Process this file with automake to produce Makefile.in.
# Copyright (C) 2002-2025 Free Software Foundation, Inc.
# Copyright (C) 2002-2026 Free Software Foundation, Inc.
#
# This file is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@ -59,6 +59,7 @@
AUTOMAKE_OPTIONS = 1.14 gnits subdir-objects
SUBDIRS =
TESTS_ENVIRONMENT =
noinst_HEADERS =
noinst_LIBRARIES =
noinst_LTLIBRARIES =
@ -449,12 +450,6 @@ errno.h: errno.in.h $(top_builddir)/config.status
-e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
-e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
-e 's|@''NEXT_ERRNO_H''@|$(NEXT_ERRNO_H)|g' \
-e 's|@''EMULTIHOP_HIDDEN''@|$(EMULTIHOP_HIDDEN)|g' \
-e 's|@''EMULTIHOP_VALUE''@|$(EMULTIHOP_VALUE)|g' \
-e 's|@''ENOLINK_HIDDEN''@|$(ENOLINK_HIDDEN)|g' \
-e 's|@''ENOLINK_VALUE''@|$(ENOLINK_VALUE)|g' \
-e 's|@''EOVERFLOW_HIDDEN''@|$(EOVERFLOW_HIDDEN)|g' \
-e 's|@''EOVERFLOW_VALUE''@|$(EOVERFLOW_VALUE)|g' \
$(srcdir)/errno.in.h > $@-t
$(AM_V_at)mv $@-t $@
else
@ -533,10 +528,12 @@ fcntl.h: fcntl.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H)
-e 's/@''GNULIB_NONBLOCKING''@/$(GL_GNULIB_NONBLOCKING)/g' \
-e 's/@''GNULIB_OPEN''@/$(GL_GNULIB_OPEN)/g' \
-e 's/@''GNULIB_OPENAT''@/$(GL_GNULIB_OPENAT)/g' \
-e 's/@''GNULIB_OPENAT2''@/$(GL_GNULIB_OPENAT2)/g' \
-e 's/@''GNULIB_MDA_CREAT''@/$(GL_GNULIB_MDA_CREAT)/g' \
-e 's/@''GNULIB_MDA_OPEN''@/$(GL_GNULIB_MDA_OPEN)/g' \
-e 's|@''HAVE_FCNTL''@|$(HAVE_FCNTL)|g' \
-e 's|@''HAVE_OPENAT''@|$(HAVE_OPENAT)|g' \
-e 's|@''HAVE_OPENAT2''@|$(HAVE_OPENAT2)|g' \
-e 's|@''REPLACE_CREAT''@|$(REPLACE_CREAT)|g' \
-e 's|@''REPLACE_FCNTL''@|$(REPLACE_FCNTL)|g' \
-e 's|@''REPLACE_OPEN''@|$(REPLACE_OPEN)|g' \
@ -1055,11 +1052,9 @@ langinfo.h: langinfo.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(WARN_ON_U
-e 's|@''NEXT_LANGINFO_H''@|$(NEXT_LANGINFO_H)|g' \
-e 's/@''GNULIB_NL_LANGINFO''@/$(GL_GNULIB_NL_LANGINFO)/g' \
-e 's|@''HAVE_LANGINFO_CODESET''@|$(HAVE_LANGINFO_CODESET)|g' \
-e 's|@''HAVE_LANGINFO_T_FMT_AMPM''@|$(HAVE_LANGINFO_T_FMT_AMPM)|g' \
-e 's|@''HAVE_LANGINFO_ALTMON''@|$(HAVE_LANGINFO_ALTMON)|g' \
-e 's|@''HAVE_LANGINFO_ABALTMON''@|$(HAVE_LANGINFO_ABALTMON)|g' \
-e 's|@''HAVE_LANGINFO_ERA''@|$(HAVE_LANGINFO_ERA)|g' \
-e 's|@''HAVE_LANGINFO_YESEXPR''@|$(HAVE_LANGINFO_YESEXPR)|g' \
-e 's|@''HAVE_NL_LANGINFO''@|$(HAVE_NL_LANGINFO)|g' \
-e 's|@''REPLACE_NL_LANGINFO''@|$(REPLACE_NL_LANGINFO)|g' \
-e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
@ -1284,8 +1279,11 @@ math.h: math.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(
-e 's/@''GNULIB_ILOGBF''@/$(GL_GNULIB_ILOGBF)/g' \
-e 's/@''GNULIB_ILOGBL''@/$(GL_GNULIB_ILOGBL)/g' \
-e 's/@''GNULIB_ISFINITE''@/$(GL_GNULIB_ISFINITE)/g' \
-e 's/@''GNULIB_ISFINITE_NO_CXX''@/$(GL_GNULIB_ISFINITE_NO_CXX)/g' \
-e 's/@''GNULIB_ISINF''@/$(GL_GNULIB_ISINF)/g' \
-e 's/@''GNULIB_ISINF_NO_CXX''@/$(GL_GNULIB_ISINF_NO_CXX)/g' \
-e 's/@''GNULIB_ISNAN''@/$(GL_GNULIB_ISNAN)/g' \
-e 's/@''GNULIB_ISNAN_NO_CXX''@/$(GL_GNULIB_ISNAN_NO_CXX)/g' \
-e 's/@''GNULIB_ISNANF''@/$(GL_GNULIB_ISNANF)/g' \
-e 's/@''GNULIB_ISNAND''@/$(GL_GNULIB_ISNAND)/g' \
-e 's/@''GNULIB_ISNANL''@/$(GL_GNULIB_ISNANL)/g' \
@ -1330,6 +1328,7 @@ math.h: math.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(
-e 's/@''GNULIB_SETPAYLOADSIGF''@/$(GL_GNULIB_SETPAYLOADSIGF)/g' \
-e 's/@''GNULIB_SETPAYLOADSIGL''@/$(GL_GNULIB_SETPAYLOADSIGL)/g' \
-e 's/@''GNULIB_SIGNBIT''@/$(GL_GNULIB_SIGNBIT)/g' \
-e 's/@''GNULIB_SIGNBIT_NO_CXX''@/$(GL_GNULIB_SIGNBIT_NO_CXX)/g' \
-e 's/@''GNULIB_SINF''@/$(GL_GNULIB_SINF)/g' \
-e 's/@''GNULIB_SINL''@/$(GL_GNULIB_SINL)/g' \
-e 's/@''GNULIB_SINHF''@/$(GL_GNULIB_SINHF)/g' \
@ -1366,14 +1365,19 @@ math.h: math.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(
-e 's|@''HAVE_CBRTF''@|$(HAVE_CBRTF)|g' \
-e 's|@''HAVE_CBRTL''@|$(HAVE_CBRTL)|g' \
-e 's|@''HAVE_COPYSIGN''@|$(HAVE_COPYSIGN)|g' \
-e 's|@''HAVE_COPYSIGNF''@|$(HAVE_COPYSIGNF)|g' \
-e 's|@''HAVE_COPYSIGNL''@|$(HAVE_COPYSIGNL)|g' \
-e 's|@''HAVE_COSF''@|$(HAVE_COSF)|g' \
-e 's|@''HAVE_COSL''@|$(HAVE_COSL)|g' \
-e 's|@''HAVE_COSHF''@|$(HAVE_COSHF)|g' \
-e 's|@''HAVE_EXPF''@|$(HAVE_EXPF)|g' \
-e 's|@''HAVE_EXPL''@|$(HAVE_EXPL)|g' \
-e 's|@''HAVE_EXP2''@|$(HAVE_EXP2)|g' \
-e 's|@''HAVE_EXP2F''@|$(HAVE_EXP2F)|g' \
-e 's|@''HAVE_EXP2L''@|$(HAVE_EXP2L)|g' \
-e 's|@''HAVE_EXPM1''@|$(HAVE_EXPM1)|g' \
-e 's|@''HAVE_EXPM1F''@|$(HAVE_EXPM1F)|g' \
-e 's|@''HAVE_EXPM1L''@|$(HAVE_EXPM1L)|g' \
-e 's|@''HAVE_FABSF''@|$(HAVE_FABSF)|g' \
-e 's|@''HAVE_FABSL''@|$(HAVE_FABSL)|g' \
-e 's|@''HAVE_FMA''@|$(HAVE_FMA)|g' \
@ -1401,6 +1405,9 @@ math.h: math.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(
-e 's|@''HAVE_LOG1P''@|$(HAVE_LOG1P)|g' \
-e 's|@''HAVE_LOG1PF''@|$(HAVE_LOG1PF)|g' \
-e 's|@''HAVE_LOG1PL''@|$(HAVE_LOG1PL)|g' \
-e 's|@''HAVE_LOG2''@|$(HAVE_LOG2)|g' \
-e 's|@''HAVE_LOG2F''@|$(HAVE_LOG2F)|g' \
-e 's|@''HAVE_LOG2L''@|$(HAVE_LOG2L)|g' \
-e 's|@''HAVE_LOGBF''@|$(HAVE_LOGBF)|g' \
-e 's|@''HAVE_LOGBL''@|$(HAVE_LOGBL)|g' \
-e 's|@''HAVE_LOGP1''@|$(HAVE_LOGP1)|g' \
@ -1411,8 +1418,13 @@ math.h: math.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(
-e 's|@''HAVE_POWF''@|$(HAVE_POWF)|g' \
-e 's|@''HAVE_REMAINDER''@|$(HAVE_REMAINDER)|g' \
-e 's|@''HAVE_REMAINDERF''@|$(HAVE_REMAINDERF)|g' \
-e 's|@''HAVE_REMAINDERL''@|$(HAVE_REMAINDERL)|g' \
-e 's|@''HAVE_RINT''@|$(HAVE_RINT)|g' \
-e 's|@''HAVE_RINTF''@|$(HAVE_RINTF)|g' \
-e 's|@''HAVE_RINTL''@|$(HAVE_RINTL)|g' \
-e 's|@''HAVE_ROUND''@|$(HAVE_ROUND)|g' \
-e 's|@''HAVE_ROUNDF''@|$(HAVE_ROUNDF)|g' \
-e 's|@''HAVE_ROUNDL''@|$(HAVE_ROUNDL)|g' \
-e 's|@''HAVE_SETPAYLOAD''@|$(HAVE_SETPAYLOAD)|g' \
-e 's|@''HAVE_SETPAYLOADF''@|$(HAVE_SETPAYLOADF)|g' \
-e 's|@''HAVE_SETPAYLOADL''@|$(HAVE_SETPAYLOADL)|g' \
@ -1438,33 +1450,17 @@ math.h: math.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(
-e 's|@''HAVE_DECL_ACOSL''@|$(HAVE_DECL_ACOSL)|g' \
-e 's|@''HAVE_DECL_ASINL''@|$(HAVE_DECL_ASINL)|g' \
-e 's|@''HAVE_DECL_ATANL''@|$(HAVE_DECL_ATANL)|g' \
-e 's|@''HAVE_DECL_CBRTF''@|$(HAVE_DECL_CBRTF)|g' \
-e 's|@''HAVE_DECL_CBRTL''@|$(HAVE_DECL_CBRTL)|g' \
-e 's|@''HAVE_DECL_CEILF''@|$(HAVE_DECL_CEILF)|g' \
-e 's|@''HAVE_DECL_CEILL''@|$(HAVE_DECL_CEILL)|g' \
-e 's|@''HAVE_DECL_COPYSIGNF''@|$(HAVE_DECL_COPYSIGNF)|g' \
-e 's|@''HAVE_DECL_COSL''@|$(HAVE_DECL_COSL)|g' \
-e 's|@''HAVE_DECL_EXPL''@|$(HAVE_DECL_EXPL)|g' \
-e 's|@''HAVE_DECL_EXP2''@|$(HAVE_DECL_EXP2)|g' \
-e 's|@''HAVE_DECL_EXP2F''@|$(HAVE_DECL_EXP2F)|g' \
-e 's|@''HAVE_DECL_EXP2L''@|$(HAVE_DECL_EXP2L)|g' \
-e 's|@''HAVE_DECL_EXPM1L''@|$(HAVE_DECL_EXPM1L)|g' \
-e 's|@''HAVE_DECL_FLOORF''@|$(HAVE_DECL_FLOORF)|g' \
-e 's|@''HAVE_DECL_FLOORL''@|$(HAVE_DECL_FLOORL)|g' \
-e 's|@''HAVE_DECL_FREXPL''@|$(HAVE_DECL_FREXPL)|g' \
-e 's|@''HAVE_DECL_LDEXPL''@|$(HAVE_DECL_LDEXPL)|g' \
-e 's|@''HAVE_DECL_LOGL''@|$(HAVE_DECL_LOGL)|g' \
-e 's|@''HAVE_DECL_LOG10L''@|$(HAVE_DECL_LOG10L)|g' \
-e 's|@''HAVE_DECL_LOG2''@|$(HAVE_DECL_LOG2)|g' \
-e 's|@''HAVE_DECL_LOG2F''@|$(HAVE_DECL_LOG2F)|g' \
-e 's|@''HAVE_DECL_LOG2L''@|$(HAVE_DECL_LOG2L)|g' \
-e 's|@''HAVE_DECL_LOGB''@|$(HAVE_DECL_LOGB)|g' \
-e 's|@''HAVE_DECL_REMAINDER''@|$(HAVE_DECL_REMAINDER)|g' \
-e 's|@''HAVE_DECL_REMAINDERL''@|$(HAVE_DECL_REMAINDERL)|g' \
-e 's|@''HAVE_DECL_RINTF''@|$(HAVE_DECL_RINTF)|g' \
-e 's|@''HAVE_DECL_ROUND''@|$(HAVE_DECL_ROUND)|g' \
-e 's|@''HAVE_DECL_ROUNDF''@|$(HAVE_DECL_ROUNDF)|g' \
-e 's|@''HAVE_DECL_ROUNDL''@|$(HAVE_DECL_ROUNDL)|g' \
-e 's|@''HAVE_DECL_SINL''@|$(HAVE_DECL_SINL)|g' \
-e 's|@''HAVE_DECL_SQRTL''@|$(HAVE_DECL_SQRTL)|g' \
-e 's|@''HAVE_DECL_TANL''@|$(HAVE_DECL_TANL)|g' \
@ -2395,9 +2391,6 @@ stdio.h: stdio.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H)
$(AM_V_at)mv $@-t3 $@
MOSTLYCLEANFILES += stdio.h stdio.h-t1 stdio.h-t2 stdio.h-t3
if GL_COND_OBJ_STDIO_CONSOLESAFE
libgnu_a_SOURCES += stdio-consolesafe.c
endif
if GL_COND_OBJ_STDIO_READ
libgnu_a_SOURCES += stdio-read.c
endif
@ -2409,6 +2402,14 @@ EXTRA_DIST += stdio.in.h
## end gnulib module stdio-h
## begin gnulib module stdio-windows
if GL_COND_OBJ_STDIO_CONSOLESAFE
libgnu_a_SOURCES += stdio-consolesafe.c
endif
## end gnulib module stdio-windows
## begin gnulib module stdlib-h
BUILT_SOURCES += stdlib.h
@ -2503,7 +2504,6 @@ stdlib.h: stdlib.in.h $(top_builddir)/config.status $(CXXDEFS_H) \
-e 's|@''HAVE_PTSNAME_R''@|$(HAVE_PTSNAME_R)|g' \
-e 's|@''HAVE_QSORT_R''@|$(HAVE_QSORT_R)|g' \
-e 's|@''HAVE_RANDOM''@|$(HAVE_RANDOM)|g' \
-e 's|@''HAVE_RANDOM_H''@|$(HAVE_RANDOM_H)|g' \
-e 's|@''HAVE_RANDOM_R''@|$(HAVE_RANDOM_R)|g' \
-e 's|@''HAVE_REALLOCARRAY''@|$(HAVE_REALLOCARRAY)|g' \
-e 's|@''HAVE_REALPATH''@|$(HAVE_REALPATH)|g' \
@ -2521,6 +2521,7 @@ stdlib.h: stdlib.in.h $(top_builddir)/config.status $(CXXDEFS_H) \
-e 's|@''HAVE_STRTOULL''@|$(HAVE_STRTOULL)|g' \
-e 's|@''HAVE_STRUCT_RANDOM_DATA''@|$(HAVE_STRUCT_RANDOM_DATA)|g' \
-e 's|@''HAVE_SYS_LOADAVG_H''@|$(HAVE_SYS_LOADAVG_H)|g' \
-e 's|@''HAVE_SYS_PROCESS_H''@|$(HAVE_SYS_PROCESS_H)|g' \
-e 's|@''HAVE_UNLOCKPT''@|$(HAVE_UNLOCKPT)|g' \
-e 's|@''HAVE_DECL_UNSETENV''@|$(HAVE_DECL_UNSETENV)|g' \
< $@-t1 > $@-t2
@ -2674,6 +2675,7 @@ string.h: string.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H
-e 's/@''GNULIB_STPNCPY''@/$(GL_GNULIB_STPNCPY)/g' \
-e 's/@''GNULIB_STRCHRNUL''@/$(GL_GNULIB_STRCHRNUL)/g' \
-e 's/@''GNULIB_STRDUP''@/$(GL_GNULIB_STRDUP)/g' \
-e 's/@''GNULIB_STRINGEQ''@/$(GL_GNULIB_STRINGEQ)/g' \
-e 's/@''GNULIB_STRNCAT''@/$(GL_GNULIB_STRNCAT)/g' \
-e 's/@''GNULIB_STRNCPY''@/$(GL_GNULIB_STRNCPY)/g' \
-e 's/@''GNULIB_STRNDUP''@/$(GL_GNULIB_STRNDUP)/g' \
@ -2702,6 +2704,7 @@ string.h: string.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H
-e 's|@''HAVE_FFSL''@|$(HAVE_FFSL)|g' \
-e 's|@''HAVE_FFSLL''@|$(HAVE_FFSLL)|g' \
-e 's|@''HAVE_MBSLEN''@|$(HAVE_MBSLEN)|g' \
-e 's|@''HAVE_DECL_MEMEQ''@|$(HAVE_DECL_MEMEQ)|g' \
-e 's|@''HAVE_DECL_MEMMEM''@|$(HAVE_DECL_MEMMEM)|g' \
-e 's|@''HAVE_MEMPCPY''@|$(HAVE_MEMPCPY)|g' \
-e 's|@''HAVE_DECL_MEMRCHR''@|$(HAVE_DECL_MEMRCHR)|g' \
@ -2711,6 +2714,7 @@ string.h: string.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H
-e 's|@''HAVE_STPNCPY''@|$(HAVE_STPNCPY)|g' \
-e 's|@''HAVE_STRCHRNUL''@|$(HAVE_STRCHRNUL)|g' \
-e 's|@''HAVE_DECL_STRDUP''@|$(HAVE_DECL_STRDUP)|g' \
-e 's|@''HAVE_DECL_STREQ''@|$(HAVE_DECL_STREQ)|g' \
-e 's|@''HAVE_DECL_STRNDUP''@|$(HAVE_DECL_STRNDUP)|g' \
-e 's|@''HAVE_DECL_STRNLEN''@|$(HAVE_DECL_STRNLEN)|g' \
-e 's|@''HAVE_STRPBRK''@|$(HAVE_STRPBRK)|g' \
@ -2760,6 +2764,12 @@ EXTRA_DIST += string.in.h
## end gnulib module string-h
## begin gnulib module stringeq
libgnu_a_SOURCES += string.c
## end gnulib module stringeq
## begin gnulib module strings-h
BUILT_SOURCES += strings.h
@ -3918,7 +3928,7 @@ wchar.h: wchar.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H)
-e 's|@''HAVE_WCSTOK''@|$(HAVE_WCSTOK)|g' \
-e 's|@''HAVE_WCSWIDTH''@|$(HAVE_WCSWIDTH)|g' \
-e 's|@''HAVE_WCSFTIME''@|$(HAVE_WCSFTIME)|g' \
-e 's|@''HAVE_DECL_WCTOB''@|$(HAVE_DECL_WCTOB)|g' \
-e 's|@''HAVE_WCTOB''@|$(HAVE_WCTOB)|g' \
-e 's|@''HAVE_DECL_WCSDUP''@|$(HAVE_DECL_WCSDUP)|g' \
-e 's|@''HAVE_DECL_WCWIDTH''@|$(HAVE_DECL_WCWIDTH)|g' \
< $@-t1 > $@-t2

View file

@ -1,5 +1,5 @@
/* A C macro for declaring that a function does not return.
Copyright (C) 2011-2025 Free Software Foundation, Inc.
Copyright (C) 2011-2026 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

View file

@ -1,5 +1,5 @@
/* af_alg.c - Compute message digests from file streams and buffers.
Copyright (C) 2018-2025 Free Software Foundation, Inc.
Copyright (C) 2018-2026 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
@ -112,100 +112,102 @@ afalg_stream (FILE *stream, const char *alg,
read-write loop work around an empty-input bug noted below. */
int fd = fileno (stream);
int result;
struct stat st;
off_t off = ftello (stream);
if (0 <= off && fstat (fd, &st) == 0
&& (S_ISREG (st.st_mode) || S_TYPEISSHM (&st) || S_TYPEISTMO (&st))
&& off < st.st_size && st.st_size - off < SYS_BUFSIZE_MAX)
{
/* Make sure the offset of fileno (stream) reflects how many bytes
have been read from stream before this function got invoked.
Note: fflush on an input stream after ungetc does not work as expected
on some platforms. Therefore this situation is not supported here. */
if (fflush (stream))
result = -EIO;
else
{
off_t nbytes = st.st_size - off;
if (sendfile (ofd, fd, &off, nbytes) == nbytes)
{
if (read (ofd, resblock, hashlen) == hashlen)
{
/* The input buffers of stream are no longer valid. */
if (lseek (fd, off, SEEK_SET) != (off_t)-1)
result = 0;
else
/* The file position of fd has not changed. */
result = -EAFNOSUPPORT;
}
else
/* The file position of fd has not changed. */
result = -EAFNOSUPPORT;
}
else
/* The file position of fd has not changed. */
result = -EAFNOSUPPORT;
}
}
else
{
/* sendfile not possible, do a classic read-write loop. */
/* Number of bytes to seek (backwards) in case of error. */
off_t nseek = 0;
for (;;)
{
char buf[BLOCKSIZE];
/* When the stream is not seekable, start with a single-byte block,
so that we can use ungetc() in the case that send() fails. */
size_t blocksize = (nseek == 0 && off < 0 ? 1 : BLOCKSIZE);
ssize_t size = fread (buf, 1, blocksize, stream);
if (size == 0)
{
/* On Linux < 4.9, the value for an empty stream is wrong (all 0).
See <https://patchwork.kernel.org/patch/9308641/>.
This was not fixed properly until November 2016,
see <https://patchwork.kernel.org/patch/9434741/>. */
result = ferror (stream) ? -EIO : nseek == 0 ? -EAFNOSUPPORT : 0;
break;
}
nseek -= size;
if (send (ofd, buf, size, MSG_MORE) != size)
{
if (nseek == -1)
{
/* 1 byte of pushback buffer is guaranteed on stream, even
if stream is not seekable. */
ungetc ((unsigned char) buf[0], stream);
{
struct stat st;
off_t off = ftello (stream);
if (0 <= off && fstat (fd, &st) == 0
&& (S_ISREG (st.st_mode) || S_TYPEISSHM (&st) || S_TYPEISTMO (&st))
&& off < st.st_size && st.st_size - off < SYS_BUFSIZE_MAX)
{
/* Make sure the offset of fileno (stream) reflects how many bytes
have been read from stream before this function got invoked.
Note: fflush on an input stream after ungetc does not work as expected
on some platforms. Therefore this situation is not supported here. */
if (fflush (stream))
result = -EIO;
else
{
off_t nbytes = st.st_size - off;
if (sendfile (ofd, fd, &off, nbytes) == nbytes)
{
if (read (ofd, resblock, hashlen) == hashlen)
{
/* The input buffers of stream are no longer valid. */
if (lseek (fd, off, SEEK_SET) != (off_t)-1)
result = 0;
else
/* The file position of fd has not changed. */
result = -EAFNOSUPPORT;
}
else
/* The file position of fd has not changed. */
result = -EAFNOSUPPORT;
}
else if (fseeko (stream, nseek, SEEK_CUR) == 0)
/* The position of stream has been restored. */
result = -EAFNOSUPPORT;
else
result = -EIO;
break;
}
}
else
/* The file position of fd has not changed. */
result = -EAFNOSUPPORT;
}
}
else
{
/* sendfile not possible, do a classic read-write loop. */
/* Don't assume that EOF is sticky. See:
<https://sourceware.org/bugzilla/show_bug.cgi?id=19476>. */
if (feof (stream))
{
result = 0;
break;
}
}
/* Number of bytes to seek (backwards) in case of error. */
off_t nseek = 0;
if (result == 0 && read (ofd, resblock, hashlen) != hashlen)
{
if (nseek == 0 || fseeko (stream, nseek, SEEK_CUR) == 0)
/* The position of stream has been restored. */
result = -EAFNOSUPPORT;
else
result = -EIO;
}
}
for (;;)
{
char buf[BLOCKSIZE];
/* When the stream is not seekable, start with a single-byte block,
so that we can use ungetc() in the case that send() fails. */
size_t blocksize = (nseek == 0 && off < 0 ? 1 : BLOCKSIZE);
ssize_t size = fread (buf, 1, blocksize, stream);
if (size == 0)
{
/* On Linux < 4.9, the value for an empty stream is wrong (all 0).
See <https://patchwork.kernel.org/patch/9308641/>.
This was not fixed properly until November 2016,
see <https://patchwork.kernel.org/patch/9434741/>. */
result = ferror (stream) ? -EIO : nseek == 0 ? -EAFNOSUPPORT : 0;
break;
}
nseek -= size;
if (send (ofd, buf, size, MSG_MORE) != size)
{
if (nseek == -1)
{
/* 1 byte of pushback buffer is guaranteed on stream, even
if stream is not seekable. */
ungetc ((unsigned char) buf[0], stream);
result = -EAFNOSUPPORT;
}
else if (fseeko (stream, nseek, SEEK_CUR) == 0)
/* The position of stream has been restored. */
result = -EAFNOSUPPORT;
else
result = -EIO;
break;
}
/* Don't assume that EOF is sticky. See:
<https://sourceware.org/PR19476>. */
if (feof (stream))
{
result = 0;
break;
}
}
if (result == 0 && read (ofd, resblock, hashlen) != hashlen)
{
if (nseek == 0 || fseeko (stream, nseek, SEEK_CUR) == 0)
/* The position of stream has been restored. */
result = -EAFNOSUPPORT;
else
result = -EIO;
}
}
}
close (ofd);
return result;
}

View file

@ -1,5 +1,5 @@
/* af_alg.h - Compute message digests from file streams and buffers.
Copyright (C) 2018-2025 Free Software Foundation, Inc.
Copyright (C) 2018-2026 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

View file

@ -1,6 +1,6 @@
/* Memory allocation on the stack.
Copyright (C) 1995, 1999, 2001-2004, 2006-2025 Free Software Foundation,
Copyright (C) 1995, 1999, 2001-2004, 2006-2026 Free Software Foundation,
Inc.
This file is free software: you can redistribute it and/or modify

View file

@ -1,5 +1,5 @@
/* A C macro for declaring that specific arguments must not be NULL.
Copyright (C) 2009-2025 Free Software Foundation, Inc.
Copyright (C) 2009-2026 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

View file

@ -1,6 +1,6 @@
/* Inline functions for <arpa/inet.h>.
Copyright (C) 2024-2025 Free Software Foundation, Inc.
Copyright (C) 2024-2026 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,7 +15,6 @@
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 <config.h>
#include <arpa/inet.h>

View file

@ -1,6 +1,6 @@
/* A GNU-like <arpa/inet.h>.
Copyright (C) 2005-2006, 2008-2025 Free Software Foundation, Inc.
Copyright (C) 2005-2006, 2008-2026 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
@ -159,7 +159,6 @@ _GL_CXXALIAS_SYS_CAST (inet_ntop, const char *,
_GL_CXXALIASWARN (inet_ntop);
# endif
#elif defined GNULIB_POSIXCHECK
# undef inet_ntop
# if HAVE_RAW_DECL_INET_NTOP
_GL_WARN_ON_USE (inet_ntop, "inet_ntop is unportable - "
"use gnulib module inet_ntop for portability");
@ -190,7 +189,6 @@ _GL_CXXALIAS_SYS (inet_pton, int,
_GL_CXXALIASWARN (inet_pton);
# endif
#elif defined GNULIB_POSIXCHECK
# undef inet_pton
# if HAVE_RAW_DECL_INET_PTON
_GL_WARN_ON_USE (inet_pton, "inet_pton is unportable - "
"use gnulib module inet_pton for portability");

View file

@ -1,5 +1,5 @@
/* Formatted output to strings.
Copyright (C) 1999, 2002, 2006, 2009-2025 Free Software Foundation, Inc.
Copyright (C) 1999, 2002, 2006, 2009-2026 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,10 +25,8 @@ char *
asnprintf (char *resultbuf, size_t *lengthp, const char *format, ...)
{
va_list args;
char *result;
va_start (args, format);
result = vasnprintf (resultbuf, lengthp, format, args);
char *result = vasnprintf (resultbuf, lengthp, format, args);
va_end (args);
return result;
}

View file

@ -1,5 +1,5 @@
/* Formatted output to strings.
Copyright (C) 1999, 2002, 2006-2007, 2009-2025 Free Software Foundation,
Copyright (C) 1999, 2002, 2006-2007, 2009-2026 Free Software Foundation,
Inc.
This file is free software: you can redistribute it and/or modify
@ -30,10 +30,8 @@ int
asprintf (char **resultp, const char *format, ...)
{
va_list args;
int result;
va_start (args, format);
result = vasprintf (resultp, format, args);
int result = vasprintf (resultp, format, args);
va_end (args);
return result;
}

View file

@ -1,5 +1,5 @@
/* Substitute for and wrapper around <assert.h>
Copyright (C) 2011-2025 Free Software Foundation, Inc.
Copyright (C) 2011-2026 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

View file

@ -1,6 +1,6 @@
/* ATTRIBUTE_* macros for using attributes in GCC and similar compilers
Copyright 2020-2025 Free Software Foundation, Inc.
Copyright 2020-2026 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
@ -89,7 +89,7 @@
_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. */
_GL_ATTRIBUTE_SENTINEL, _GL_ATTRIBUTE_UNSEQUENCED, _GL_UNNAMED. */
#if !_GL_CONFIG_H_INCLUDED
#error "Please include config.h first."
#endif
@ -240,62 +240,68 @@
/* Applies to: functions. */
#define ATTRIBUTE_ALWAYS_INLINE _GL_ATTRIBUTE_ALWAYS_INLINE
/* 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 state, and always returns exactly once -
/* It is OK for a compiler to move a call, or omit a duplicate call
and reuse a cached return value, even if the state changes between calls.
It is also OK to omit a call if the result is not used.
This attribute is safe if the function does not change observable state,
returns a value determined solely by its arguments' values
without examining 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.) */
(This attribute is stricter than _GL_ATTRIBUTE_PURE because the
function cannot observe state. Unlike _GL_ATTRIBUTE_UNSEQUENCED
the function must return exactly once and cannot access state
addressed by its pointer arguments or that happens to have the same
value for all calls to the function, but the function is allowed to
return a pointer to storage that can be modified later. */
/* Applies to: functions. */
#define ATTRIBUTE_CONST _GL_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.
/* It is OK for a compiler to move a call, or omit a duplicate call
and reuse a cached value returned either directly or indirectly via
a pointer, if the state addressed by its pointer arguments is the same;
however, pointer arguments cannot alias.
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
stateless, and independent; see ISO C 23 § 6.7.13.8 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.)
(This attribute is stricter than _GL_ATTRIBUTE_REPRODUCIBLE because
the function must be stateless and independent. Unlike
_GL_ATTRIBUTE_CONST the function need not return exactly once, and
can depend on state accessed via its pointer arguments or that
happens to have the same value for all calls to the function, but
the function cannot return a pointer to storage whose contents
change later.)
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>. */
<https://stackoverflow.com/questions/76847905/>. */
/* 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.) */
/* It is OK for a compiler to move a call, or omit a duplicate call
and reuse a cached return value, if observable state is the same.
It is also OK to omit a call if the return value is not used.
This attribute is safe if the function does not change observable state,
returns a value determined solely by its arguments's values
together with observable state, and always returns exactly once.
(This attribute is looser than _GL_ATTRIBUTE_CONST because the function
can depend on observable state.
Unlike _GL_ATTRIBUTE_REPRODUCIBLE the function must return exactly
once and cannot change state addressed by its arguments, but the
function can return a pointer to storage whose contents change later.) */
/* 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.)
/* It is OK for a compiler to move a call, or omit a duplicate call
and reuse a cached value returned either directly or indirectly via
a pointer, if other observable state is the same;
however, pointer arguments cannot alias.
This attribute is safe for a function that is effectless and idempotent;
see ISO C 23 § 6.7.13.8 for a definition of these terms.
(This attribute is looser than _GL_ATTRIBUTE_UNSEQUENCED because
the function need not be stateless or independent.
Unlike _GL_ATTRIBUTE_PURE the function need not return exactly once
and can change state addressed by its pointer arguments, but the
function cannot return a pointer to storage whose contents change later.)
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>. */
<https://stackoverflow.com/questions/76847905/>. */
/* Applies to: functions, pointer to functions, function type. */
#define REPRODUCIBLE _GL_ATTRIBUTE_REPRODUCIBLE
@ -328,4 +334,18 @@
#define ATTRIBUTE_MAY_ALIAS _GL_ATTRIBUTE_MAY_ALIAS
/* ==================== Unnamed function parameters ======================== */
/* Although UNNAMED is not an attribute, it is related to MAYBE_UNUSED
and so is defined here for convenience. */
/* UNNAMED (ID) is the "name" of an unnamed function parameter.
Each of the function's unnamed parameters should have a unique "name".
The "name" cannot be used. This ports both to C17 and earlier, which
lack unnamed parameters, and to C++ and later C, which have them. */
/* Applies to:
- function parameters. */
#define UNNAMED(id) _GL_UNNAMED (id)
#endif /* _GL_ATTRIBUTE_H */

View file

@ -1,5 +1,5 @@
/* base64.c -- Encode binary data using printable characters.
Copyright (C) 1999-2001, 2004-2006, 2009-2025 Free Software Foundation, Inc.
Copyright (C) 1999-2001, 2004-2006, 2009-2026 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
@ -39,10 +39,10 @@
*
*/
#define BASE64_INLINE _GL_EXTERN_INLINE
#include <config.h>
/* Get prototype. */
#define BASE64_INLINE _GL_EXTERN_INLINE
#include "base64.h"
/* Get imalloc. */
@ -372,13 +372,14 @@ static bool
decode_4 (char const *restrict in, idx_t inlen,
char *restrict *outp, idx_t *outleft)
{
char *out = *outp;
if (inlen < 2)
return false;
if (!isbase64 (in[0]) || !isbase64 (in[1]))
return false;
char *out = *outp;
if (*outleft)
{
*out++ = ((base64_to_int[to_uchar (in[0])] << 2)
@ -466,7 +467,6 @@ base64_decode_ctx (struct base64_decode_context *ctx,
const char *restrict in, idx_t inlen,
char *restrict out, idx_t *outlen)
{
idx_t outleft = *outlen;
bool ignore_newlines = ctx != NULL;
bool flush_ctx = false;
unsigned int ctx_i = 0;
@ -477,6 +477,7 @@ base64_decode_ctx (struct base64_decode_context *ctx,
flush_ctx = inlen == 0;
}
idx_t outleft = *outlen;
while (true)
{
@ -505,35 +506,36 @@ base64_decode_ctx (struct base64_decode_context *ctx,
{
++in;
--inlen;
continue;
}
else
{
/* Restore OUT and OUTLEFT. */
out -= outleft_save - outleft;
outleft = outleft_save;
/* Restore OUT and OUTLEFT. */
out -= outleft_save - outleft;
outleft = outleft_save;
{
char const *in_end = in + inlen;
char const *non_nl;
if (ignore_newlines)
non_nl = get_4 (ctx, &in, in_end, &inlen);
else
non_nl = in; /* Might have nl in this case. */
/* If the input is empty or consists solely of newlines (0 non-newlines),
then we're done. Likewise if there are fewer than 4 bytes when not
flushing context and not treating newlines as garbage. */
if (inlen == 0 || (inlen < 4 && !flush_ctx && ignore_newlines))
{
inlen = 0;
break;
}
if (!decode_4 (non_nl, inlen, &out, &outleft))
break;
char const *in_end = in + inlen;
inlen = in_end - in;
}
char const *non_nl;
if (ignore_newlines)
non_nl = get_4 (ctx, &in, in_end, &inlen);
else
non_nl = in; /* Might have nl in this case. */
/* If the input is empty or consists solely of newlines (0 non-newlines),
then we're done. Likewise if there are fewer than 4 bytes when not
flushing context and not treating newlines as garbage. */
if (inlen == 0 || (inlen < 4 && !flush_ctx && ignore_newlines))
{
inlen = 0;
break;
}
if (!decode_4 (non_nl, inlen, &out, &outleft))
break;
inlen = in_end - in;
}
}
}
*outlen -= outleft;

View file

@ -1,5 +1,5 @@
/* base64.h -- Encode binary data using printable characters.
Copyright (C) 2004-2006, 2009-2025 Free Software Foundation, Inc.
Copyright (C) 2004-2006, 2009-2026 Free Software Foundation, Inc.
Written by Simon Josefsson.
This file is free software: you can redistribute it and/or modify

View file

@ -1,6 +1,6 @@
/* basename.c -- return the last element in a file name
Copyright (C) 1990, 1998-2001, 2003-2006, 2009-2025 Free Software
Copyright (C) 1990, 1998-2001, 2003-2006, 2009-2026 Free Software
Foundation, Inc.
This file is free software: you can redistribute it and/or modify
@ -29,13 +29,11 @@ char *
last_component (char const *name)
{
char const *base = name + FILE_SYSTEM_PREFIX_LEN (name);
char const *p;
bool last_was_slash = false;
while (ISSLASH (*base))
base++;
for (p = base; *p; p++)
bool last_was_slash = false;
for (char const *p = base; *p; p++)
{
if (ISSLASH (*p))
last_was_slash = true;
@ -53,8 +51,6 @@ size_t
base_len (char const *name)
{
size_t len;
size_t prefix_len = FILE_SYSTEM_PREFIX_LEN (name);
for (len = strlen (name); 1 < len && ISSLASH (name[len - 1]); len--)
continue;
@ -62,6 +58,7 @@ base_len (char const *name)
&& ISSLASH (name[0]) && ISSLASH (name[1]) && ! name[2])
return 2;
size_t prefix_len = FILE_SYSTEM_PREFIX_LEN (name);
if (FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE && prefix_len
&& len == prefix_len && ISSLASH (name[prefix_len]))
return prefix_len + 1;

View file

@ -1,6 +1,6 @@
/* Extract the last component (base name) of a file name.
Copyright (C) 1998, 2001, 2003-2006, 2009-2025 Free Software Foundation,
Copyright (C) 1998, 2001, 2003-2006, 2009-2026 Free Software Foundation,
Inc.
This file is free software: you can redistribute it and/or modify

View file

@ -1,6 +1,6 @@
/* basename.c -- return the last element in a file name
Copyright (C) 1990, 1998-2001, 2003-2006, 2009-2025 Free Software
Copyright (C) 1990, 1998-2001, 2003-2006, 2009-2026 Free Software
Foundation, Inc.
This program is free software: you can redistribute it and/or modify

View file

@ -1,5 +1,5 @@
/* Convert unibyte character to wide character.
Copyright (C) 2008, 2010-2025 Free Software Foundation, Inc.
Copyright (C) 2008, 2010-2026 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2008.
This file is free software: you can redistribute it and/or modify

View file

@ -1,6 +1,6 @@
/* Inline functions for <byteswap.h>.
Copyright 2024-2025 Free Software Foundation, Inc.
Copyright 2024-2026 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,7 +15,6 @@
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 <config.h>
#include <byteswap.h>

View file

@ -1,5 +1,5 @@
/* byteswap.h - Byte swapping
Copyright (C) 2005, 2007, 2009-2025 Free Software Foundation, Inc.
Copyright (C) 2005, 2007, 2009-2026 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

View file

@ -1,5 +1,5 @@
/* C++ compatible function declaration macros.
Copyright (C) 2010-2025 Free Software Foundation, Inc.
Copyright (C) 2010-2026 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
@ -127,6 +127,16 @@
#define _GL_FUNCDECL_RPL_1(rpl_func,rettype,parameters,...) \
_GL_EXTERN_C_FUNC __VA_ARGS__ rettype rpl_func parameters
/* _GL_FUNCDECL_SYS_NAME (func) expands to plain func if C++, and to
parenthesized func otherwise. Parenthesization is needed in C23 if
the function is like strchr and so is a qualifier-generic macro
that expands to something more complicated. */
#ifdef __cplusplus
# define _GL_FUNCDECL_SYS_NAME(func) func
#else
# define _GL_FUNCDECL_SYS_NAME(func) (func)
#endif
/* _GL_FUNCDECL_SYS (func, rettype, parameters, [attributes]);
declares the system function, named func, with the given prototype,
consisting of return type, parameters, and attributes.
@ -139,7 +149,7 @@
_GL_FUNCDECL_SYS (posix_openpt, int, (int flags), _GL_ATTRIBUTE_NODISCARD);
*/
#define _GL_FUNCDECL_SYS(func,rettype,parameters,...) \
_GL_EXTERN_C_FUNC __VA_ARGS__ rettype func parameters
_GL_EXTERN_C_FUNC __VA_ARGS__ rettype _GL_FUNCDECL_SYS_NAME (func) parameters
/* _GL_CXXALIAS_RPL (func, rettype, parameters);
declares a C++ alias called GNULIB_NAMESPACE::func
@ -310,7 +320,7 @@
_GL_CXXALIASWARN_1 (func, GNULIB_NAMESPACE)
# define _GL_CXXALIASWARN_1(func,namespace) \
_GL_CXXALIASWARN_2 (func, namespace)
/* To work around GCC bug <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>,
/* To work around GCC bug <https://gcc.gnu.org/PR43881>,
we enable the warning only when not optimizing. */
# if !(defined __GNUC__ && !defined __clang__ && __OPTIMIZE__)
# define _GL_CXXALIASWARN_2(func,namespace) \
@ -338,7 +348,7 @@
GNULIB_NAMESPACE)
# define _GL_CXXALIASWARN1_1(func,rettype,parameters_and_attributes,namespace) \
_GL_CXXALIASWARN1_2 (func, rettype, parameters_and_attributes, namespace)
/* To work around GCC bug <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>,
/* To work around GCC bug <https://gcc.gnu.org/PR43881>,
we enable the warning only when not optimizing. */
# if !(defined __GNUC__ && !defined __clang__ && __OPTIMIZE__)
# define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \

View file

@ -1,6 +1,6 @@
/* Character handling in C locale.
Copyright (C) 2003-2025 Free Software Foundation, Inc.
Copyright (C) 2003-2026 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,7 +15,6 @@
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 <config.h>
#include "c-ctype.h"

View file

@ -5,7 +5,7 @@
<ctype.h> functions' behaviour depends on the current locale set via
setlocale.
Copyright (C) 2000-2003, 2006, 2008-2025 Free Software Foundation, Inc.
Copyright (C) 2000-2003, 2006, 2008-2026 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

View file

@ -1,5 +1,5 @@
/* Test whether a 32-bit wide character belongs to a specific character class.
Copyright (C) 2020-2025 Free Software Foundation, Inc.
Copyright (C) 2020-2026 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
@ -43,7 +43,7 @@ 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 */
#if GNULIB_defined_mbstate_t /* AIX */
/* mbrtoc32() is defined on top of mbtowc() for the non-UTF-8 locales
and directly for the UTF-8 locales. */
if (wc != WEOF)

View file

@ -1,5 +1,5 @@
/* Test 32-bit wide character for being alphanumeric.
Copyright (C) 2020-2025 Free Software Foundation, Inc.
Copyright (C) 2020-2026 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

View file

@ -1,5 +1,5 @@
/* Test 32-bit wide character for being alphabetic.
Copyright (C) 2020-2025 Free Software Foundation, Inc.
Copyright (C) 2020-2026 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

View file

@ -1,5 +1,5 @@
/* Test 32-bit wide character for being blank.
Copyright (C) 2020-2025 Free Software Foundation, Inc.
Copyright (C) 2020-2026 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

View file

@ -1,5 +1,5 @@
/* Test 32-bit wide character for being a control character.
Copyright (C) 2020-2025 Free Software Foundation, Inc.
Copyright (C) 2020-2026 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

View file

@ -1,5 +1,5 @@
/* Test 32-bit wide character for being a digit.
Copyright (C) 2020-2025 Free Software Foundation, Inc.
Copyright (C) 2020-2026 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

View file

@ -1,5 +1,5 @@
/* Test 32-bit wide character for being graphic.
Copyright (C) 2020-2025 Free Software Foundation, Inc.
Copyright (C) 2020-2026 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

View file

@ -1,5 +1,5 @@
/* Test 32-bit wide character for being lowercase.
Copyright (C) 2020-2025 Free Software Foundation, Inc.
Copyright (C) 2020-2026 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

View file

@ -1,5 +1,5 @@
/* Test 32-bit wide character for being printable.
Copyright (C) 2020-2025 Free Software Foundation, Inc.
Copyright (C) 2020-2026 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

View file

@ -1,5 +1,5 @@
/* Test 32-bit wide character for being a punctuation or symbol character.
Copyright (C) 2020-2025 Free Software Foundation, Inc.
Copyright (C) 2020-2026 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

View file

@ -1,5 +1,5 @@
/* Test 32-bit wide character for being white-space.
Copyright (C) 2020-2025 Free Software Foundation, Inc.
Copyright (C) 2020-2026 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

View file

@ -1,5 +1,5 @@
/* Test 32-bit wide character for being uppercase.
Copyright (C) 2020-2025 Free Software Foundation, Inc.
Copyright (C) 2020-2026 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

View file

@ -1,5 +1,5 @@
/* Test 32-bit wide character for being a hexadecimal digit.
Copyright (C) 2020-2025 Free Software Foundation, Inc.
Copyright (C) 2020-2026 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

View file

@ -1,5 +1,5 @@
/* Case mapping of a 32-bit wide character.
Copyright (C) 2020-2025 Free Software Foundation, Inc.
Copyright (C) 2020-2026 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
@ -39,7 +39,7 @@ 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 */
#if GNULIB_defined_mbstate_t /* AIX */
/* mbrtoc32() is defined on top of mbtowc() for the non-UTF-8 locales
and directly for the UTF-8 locales. */
if (wc != WEOF)

View file

@ -1,5 +1,5 @@
/* Map a 32-bit wide character to lowercase.
Copyright (C) 2023-2025 Free Software Foundation, Inc.
Copyright (C) 2023-2026 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

View file

@ -1,5 +1,5 @@
/* Determine the number of screen columns needed for a 32-bit wide character.
Copyright (C) 2020-2025 Free Software Foundation, Inc.
Copyright (C) 2020-2026 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
@ -49,7 +49,7 @@ 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 */
#if GNULIB_defined_mbstate_t /* AIX */
/* 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 ();

View file

@ -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-2025 Free Software Foundation, Inc.
This wrapper function is required at least on mingw.
Copyright (C) 2004-2007, 2009-2026 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

View file

@ -1,4 +1,4 @@
/* Copyright (C) 1992-2025 Free Software Foundation, Inc.
/* Copyright (C) 1992-2026 Free Software Foundation, Inc.
Copyright The GNU Toolchain Authors.
This file is part of the GNU C Library.

View file

@ -1,6 +1,6 @@
/* cloexec.c - set or clear the close-on-exec descriptor flag
Copyright (C) 1991, 2004-2006, 2009-2025 Free Software Foundation, Inc.
Copyright (C) 1991, 2004-2006, 2009-2026 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

View file

@ -1,6 +1,6 @@
/* cloexec.c - set or clear the close-on-exec descriptor flag
Copyright (C) 2004, 2009-2025 Free Software Foundation, Inc.
Copyright (C) 2004, 2009-2026 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

View file

@ -1,5 +1,5 @@
/* close replacement.
Copyright (C) 2008-2025 Free Software Foundation, Inc.
Copyright (C) 2008-2026 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

View file

@ -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-2025 Free Software
Copyright (C) 1990, 1998, 2000-2001, 2003-2006, 2009-2026 Free Software
Foundation, Inc.
This file is free software: you can redistribute it and/or modify
@ -32,7 +32,6 @@ size_t
dir_len (char const *file)
{
size_t prefix_length = FILE_SYSTEM_PREFIX_LEN (file);
size_t length;
/* Advance prefix_length beyond important leading slashes. */
prefix_length += (prefix_length != 0
@ -45,8 +44,10 @@ dir_len (char const *file)
: 0));
/* Strip the basename and any redundant slashes before it. */
size_t length;
for (length = last_component (file) - file;
prefix_length < length; length--)
prefix_length < length;
length--)
if (! ISSLASH (file[length - 1]))
break;
return length;

View file

@ -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-2025 Free Software
Copyright (C) 1990, 1998, 2000-2001, 2003-2006, 2009-2026 Free Software
Foundation, Inc.
This program is free software: you can redistribute it and/or modify

View file

@ -1,6 +1,6 @@
/* Take file names apart into directory and base names.
Copyright (C) 1998, 2001, 2003-2006, 2009-2025 Free Software Foundation,
Copyright (C) 1998, 2001, 2003-2006, 2009-2026 Free Software Foundation,
Inc.
This file is free software: you can redistribute it and/or modify

View file

@ -1,6 +1,6 @@
/* Duplicate an open file descriptor to a specified file descriptor.
Copyright (C) 1999, 2004-2007, 2009-2025 Free Software Foundation, Inc.
Copyright (C) 1999, 2004-2007, 2009-2026 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
@ -70,8 +70,6 @@ dup2_nothrow (int fd, int desired_fd)
static int
ms_windows_dup2 (int fd, int desired_fd)
{
int result;
/* If fd is closed, mingw hangs on dup2 (fd, fd). If fd is open,
dup2 (fd, fd) returns 0, but all further attempts to use fd in
future dup2 calls will hang. */
@ -93,7 +91,7 @@ ms_windows_dup2 (int fd, int desired_fd)
return -1;
}
result = dup2_nothrow (fd, desired_fd);
int result = dup2_nothrow (fd, desired_fd);
if (result == 0)
result = desired_fd;
@ -110,14 +108,11 @@ ms_windows_dup2 (int fd, int desired_fd)
static int
klibc_dup2dirfd (int fd, int desired_fd)
{
int tempfd;
int dupfd;
int tempfd = open ("NUL", O_RDONLY);
if (tempfd < 0)
return tempfd;
tempfd = open ("NUL", O_RDONLY);
if (tempfd == -1)
return -1;
if (tempfd == desired_fd)
if (tempfd >= desired_fd)
{
close (tempfd);
@ -125,10 +120,32 @@ klibc_dup2dirfd (int fd, int desired_fd)
if (__libc_Back_ioFHToPath (fd, path, sizeof (path)))
return -1;
return open(path, O_RDONLY);
for (;;)
{
close (desired_fd);
int dupfd = open (path, O_RDONLY);
if (dupfd < 0)
return dupfd;
if (dupfd == desired_fd)
return dupfd;
/* If lower FD was closed by other threads, fill again. */
if (dupfd < desired_fd)
{
tempfd = dupfd;
break;
}
/* desired_fd was opened by other threads. Try again. */
/* FIXME: Closing desired_fd opened by other threads may lead to
unexpected behavior. */
close (dupfd);
}
}
dupfd = klibc_dup2dirfd (fd, desired_fd);
int dupfd = klibc_dup2dirfd (fd, desired_fd);
close (tempfd);
@ -138,16 +155,16 @@ klibc_dup2dirfd (int fd, int desired_fd)
static int
klibc_dup2 (int fd, int desired_fd)
{
int dupfd;
struct stat sbuf;
dupfd = dup2 (fd, desired_fd);
if (dupfd == -1 && errno == ENOTSUP \
&& !fstat (fd, &sbuf) && S_ISDIR (sbuf.st_mode))
int dupfd = dup2 (fd, desired_fd);
if (dupfd < 0 && errno == ENOTSUP)
{
close (desired_fd);
struct stat sbuf;
if (!fstat (fd, &sbuf) && S_ISDIR (sbuf.st_mode))
{
close (desired_fd);
return klibc_dup2dirfd (fd, desired_fd);
return klibc_dup2dirfd (fd, desired_fd);
}
}
return dupfd;
@ -159,8 +176,6 @@ klibc_dup2 (int fd, int desired_fd)
int
rpl_dup2 (int fd, int desired_fd)
{
int result;
#ifdef F_GETFL
/* On Linux kernels 2.6.26-2.6.29, dup2 (fd, fd) returns -EBADF.
On Cygwin 1.5.x, dup2 (1, 1) returns 0.
@ -176,13 +191,14 @@ rpl_dup2 (int fd, int desired_fd)
return fcntl (fd, F_GETFL) == -1 ? -1 : fd;
#endif
result = dup2 (fd, desired_fd);
int result = dup2 (fd, desired_fd);
/* Correct an errno value on FreeBSD 6.1 and Cygwin 1.5.x. */
if (result == -1 && errno == EMFILE)
if (result < 0 && errno == EMFILE)
errno = EBADF;
#if REPLACE_FCHDIR
if (fd != desired_fd && result != -1)
if (! (result < 0 || fd == desired_fd))
result = _gl_register_dup (fd, result);
#endif
return result;

View file

@ -1,5 +1,5 @@
/* Type-safe arrays which grow dynamically.
Copyright 2021-2025 Free Software Foundation, Inc.
Copyright 2021-2026 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

View file

@ -1,6 +1,6 @@
/* A POSIX-like <errno.h>.
Copyright (C) 2008-2025 Free Software Foundation, Inc.
Copyright (C) 2008-2026 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
@ -148,27 +148,11 @@
# endif
/* On OSF/1 5.1, when _XOPEN_SOURCE_EXTENDED is not defined, the macros
EMULTIHOP, ENOLINK, EOVERFLOW are not defined. */
# if @EMULTIHOP_HIDDEN@
# define EMULTIHOP @EMULTIHOP_VALUE@
# define GNULIB_defined_EMULTIHOP 1
# endif
# if @ENOLINK_HIDDEN@
# define ENOLINK @ENOLINK_VALUE@
# define GNULIB_defined_ENOLINK 1
# endif
# if @EOVERFLOW_HIDDEN@
# define EOVERFLOW @EOVERFLOW_VALUE@
# define GNULIB_defined_EOVERFLOW 1
# endif
/* On OpenBSD 4.0 and on native Windows, the macros ENOMSG, EIDRM, ENOLINK,
EPROTO, EMULTIHOP, EBADMSG, EOVERFLOW, ENOTSUP, ECANCELED are not defined.
Likewise, on NonStop Kernel, EDQUOT is not defined.
Define them here. Values >= 2000 seem safe to use: Solaris ESTALE = 151,
HP-UX EWOULDBLOCK = 246, IRIX EDQUOT = 1133.
HP-UX EWOULDBLOCK = 246.
Note: When one of these systems defines some of these macros some day,
binaries will have to be recompiled so that they recognizes the new

View file

@ -1,5 +1,5 @@
/* Error handler for noninteractive utilities
Copyright (C) 1990-2025 Free Software Foundation, Inc.
Copyright (C) 1990-2026 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
@ -38,7 +38,7 @@
#if !_LIBC && ENABLE_NLS
# include "gettext.h"
# define _(msgid) dgettext ("gnulib", msgid)
# define _(msgid) dgettext (GNULIB_TEXT_DOMAIN, msgid)
#endif
#ifdef _LIBC

View file

@ -1,5 +1,5 @@
/* Declarations for error-reporting functions.
Copyright (C) 1995-1997, 2003, 2006, 2008-2025 Free Software Foundation,
Copyright (C) 1995-1997, 2003, 2006, 2008-2026 Free Software Foundation,
Inc.
This file is part of the GNU C Library.

View file

@ -1,6 +1,6 @@
/* Failure exit status
Copyright (C) 2002-2003, 2005-2007, 2009-2025 Free Software Foundation, Inc.
Copyright (C) 2002-2003, 2005-2007, 2009-2026 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

View file

@ -1,6 +1,6 @@
/* Failure exit status
Copyright (C) 2002, 2009-2025 Free Software Foundation, Inc.
Copyright (C) 2002, 2009-2026 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

View file

@ -1,6 +1,6 @@
/* Provide file descriptor control.
Copyright (C) 2009-2025 Free Software Foundation, Inc.
Copyright (C) 2009-2026 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
@ -30,6 +30,7 @@
#ifdef __KLIBC__
# include <emx/io.h>
# include <InnoTekLIBC/backend.h>
#endif
#if defined _WIN32 && ! defined __CYGWIN__
@ -55,19 +56,15 @@ dupfd (int oldfd, int newfd, int flags)
{
/* Mingw has no way to create an arbitrary fd. Iterate until all
file descriptors less than newfd are filled up. */
HANDLE curr_process = GetCurrentProcess ();
HANDLE old_handle = (HANDLE) _get_osfhandle (oldfd);
unsigned char fds_to_close[OPEN_MAX_MAX / CHAR_BIT];
unsigned int fds_to_close_bound = 0;
int result;
BOOL inherit = flags & O_CLOEXEC ? FALSE : TRUE;
int mode;
if (newfd < 0 || getdtablesize () <= newfd)
{
errno = EINVAL;
return -1;
}
HANDLE old_handle = (HANDLE) _get_osfhandle (oldfd);
int mode;
if (old_handle == INVALID_HANDLE_VALUE
|| (mode = _setmode (oldfd, O_BINARY)) == -1)
{
@ -79,6 +76,11 @@ dupfd (int oldfd, int newfd, int flags)
_setmode (oldfd, mode);
flags |= mode;
HANDLE curr_process = GetCurrentProcess ();
BOOL inherit = flags & O_CLOEXEC ? FALSE : TRUE;
unsigned char fds_to_close[OPEN_MAX_MAX / CHAR_BIT];
unsigned int fds_to_close_bound = 0;
int result;
for (;;)
{
HANDLE new_handle;
@ -145,9 +147,8 @@ dupfd (int oldfd, int newfd, int flags)
/* Close the previous fds that turned out to be too small. */
{
int saved_errno = errno;
unsigned int duplicated_fd;
for (duplicated_fd = 0;
for (unsigned int duplicated_fd = 0;
duplicated_fd < fds_to_close_bound * CHAR_BIT;
duplicated_fd++)
if ((fds_to_close[duplicated_fd / CHAR_BIT]
@ -205,8 +206,9 @@ fcntl (int fd, int action, /* arg */...)
#endif
{
va_list arg;
int result = -1;
va_start (arg, action);
int result = -1;
switch (action)
{
case F_DUPFD:
@ -375,12 +377,6 @@ fcntl (int fd, int action, /* arg */...)
#ifdef F_NOTIFY /* Linux */
case F_NOTIFY:
#endif
#ifdef F_OPLKACK /* IRIX */
case F_OPLKACK:
#endif
#ifdef F_OPLKREG /* IRIX */
case F_OPLKREG:
#endif
#ifdef F_RDAHEAD /* macOS */
case F_RDAHEAD:
#endif
@ -438,7 +434,9 @@ fcntl (int fd, int action, /* arg */...)
break;
}
}
va_end (arg);
return result;
}
@ -545,86 +543,115 @@ rpl_fcntl_DUPFD_CLOEXEC (int fd, int target)
#undef fcntl
#ifdef __KLIBC__
static int
klibc_dupdirfd (int fd, int minfd)
{
int tempfd = open ("NUL", O_RDONLY);
if (tempfd == -1)
return -1;
if (tempfd >= minfd)
{
close (tempfd);
char path[_MAX_PATH];
if (__libc_Back_ioFHToPath (fd, path, sizeof (path)))
return -1;
int dupfd = open (path, O_RDONLY);
if (dupfd == -1)
return -1;
if (dupfd >= minfd)
return dupfd;
/* Lower FD was closed by other threads. Fill again. */
tempfd = dupfd;
}
int dupfd = klibc_dupdirfd (fd, minfd);
close (tempfd);
return dupfd;
}
static int
klibc_fcntl (int fd, int action, /* arg */...)
{
va_list arg_ptr;
int arg;
struct stat sbuf;
int result;
va_start (arg_ptr, action);
arg = va_arg (arg_ptr, int);
result = fcntl (fd, action, arg);
int arg = va_arg (arg_ptr, int);
int result = fcntl (fd, action, arg);
/* EPERM for F_DUPFD, ENOTSUP for others */
if (result == -1 && (errno == EPERM || errno == ENOTSUP)
&& !fstat (fd, &sbuf) && S_ISDIR (sbuf.st_mode))
if (result == -1 && (errno == EPERM || errno == ENOTSUP))
{
PLIBCFH pFH;
unsigned fFlags;
switch (action)
struct stat sbuf;
if (!fstat (fd, &sbuf) && S_ISDIR (sbuf.st_mode))
{
case F_DUPFD:
/* Find available fd */
while (fcntl (arg, F_GETFL) != -1 || errno != EBADF)
arg++;
result = dup2 (fd, arg);
break;
case F_GETFD:
pFH = __libc_FH (fd);
if (!pFH)
switch (action)
{
errno = EBADF;
case F_DUPFD:
result = klibc_dupdirfd (fd, arg);
break;
case F_GETFD:
{
PLIBCFH pFH = __libc_FH (fd);
if (!pFH)
{
errno = EBADF;
break;
}
result = (pFH->fFlags & ((FD_CLOEXEC << __LIBC_FH_FDFLAGS_SHIFT )
| O_NOINHERIT)) ? FD_CLOEXEC : 0;
}
break;
case F_SETFD:
{
if (arg & ~FD_CLOEXEC)
break;
PLIBCFH pFH = __libc_FH (fd);
if (!pFH)
{
errno = EBADF;
break;
}
unsigned fFlags = pFH->fFlags;
if (arg & FD_CLOEXEC)
fFlags |= (FD_CLOEXEC << __LIBC_FH_FDFLAGS_SHIFT) | O_NOINHERIT;
else
fFlags &= ~((FD_CLOEXEC << __LIBC_FH_FDFLAGS_SHIFT) | O_NOINHERIT);
result = __libc_FHSetFlags (pFH, fd, fFlags);
if (result < 0)
{
errno = -result;
result = -1;
}
}
break;
case F_GETFL:
result = 0;
break;
case F_SETFL:
if (arg != 0)
break;
result = 0;
break;
default:
errno = EINVAL;
break;
}
result = (pFH->fFlags & ((FD_CLOEXEC << __LIBC_FH_FDFLAGS_SHIFT )
| O_NOINHERIT)) ? FD_CLOEXEC : 0;
break;
case F_SETFD:
if (arg & ~FD_CLOEXEC)
break;
pFH = __libc_FH (fd);
if (!pFH)
{
errno = EBADF;
break;
}
fFlags = pFH->fFlags;
if (arg & FD_CLOEXEC)
fFlags |= (FD_CLOEXEC << __LIBC_FH_FDFLAGS_SHIFT) | O_NOINHERIT;
else
fFlags &= ~((FD_CLOEXEC << __LIBC_FH_FDFLAGS_SHIFT) | O_NOINHERIT);
result = __libc_FHSetFlags (pFH, fd, fFlags);
if (result < 0)
{
errno = -result;
result = -1;
}
break;
case F_GETFL:
result = 0;
break;
case F_SETFL:
if (arg != 0)
break;
result = 0;
break;
default:
errno = EINVAL;
break;
}
}

View file

@ -1,6 +1,6 @@
/* Like <fcntl.h>, but with non-working flags defined to 0.
Copyright (C) 2006-2025 Free Software Foundation, Inc.
Copyright (C) 2006-2026 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
@ -122,7 +122,6 @@ _GL_CXXALIAS_SYS (creat, int, (const char *filename, mode_t mode));
# endif
_GL_CXXALIASWARN (creat);
#elif defined GNULIB_POSIXCHECK
# undef creat
/* Assume creat is always declared. */
_GL_WARN_ON_USE (creat, "creat is not always POSIX compliant - "
"use gnulib module creat for portability");
@ -165,7 +164,6 @@ _GL_CXXALIAS_SYS (fcntl, int, (int fd, int action, ...));
# endif
_GL_CXXALIASWARN (fcntl);
#elif defined GNULIB_POSIXCHECK
# undef fcntl
# if HAVE_RAW_DECL_FCNTL
_GL_WARN_ON_USE (fcntl, "fcntl is not always POSIX compliant - "
"use gnulib module fcntl for portability");
@ -196,7 +194,6 @@ _GL_CXXALIAS_SYS (open, int, (const char *filename, int flags, ...));
_GL_CXXALIASWARN (open);
# endif
#elif defined GNULIB_POSIXCHECK
# undef open
/* Assume open is always declared. */
_GL_WARN_ON_USE (open, "open is not always POSIX compliant - "
"use gnulib module open for portability");
@ -242,13 +239,51 @@ _GL_CXXALIAS_SYS (openat, int,
# endif
_GL_CXXALIASWARN (openat);
#elif defined GNULIB_POSIXCHECK
# undef openat
# if HAVE_RAW_DECL_OPENAT
_GL_WARN_ON_USE (openat, "openat is not portable - "
"use gnulib module openat for portability");
# endif
#endif
#if @GNULIB_OPENAT2@
# if !defined RESOLVE_NO_XDEV && defined __has_include
# if __has_include (<linux/openat2.h>)
# include <linux/openat2.h>
# endif
# endif
# ifndef RESOLVE_NO_XDEV
struct open_how
{
# ifdef __UINT64_TYPE__
__UINT64_TYPE__ flags, mode, resolve;
# else
unsigned long long int flags, mode, resolve;
# endif
};
# define RESOLVE_NO_XDEV 0x01
# define RESOLVE_NO_MAGICLINKS 0x02
# define RESOLVE_NO_SYMLINKS 0x04
# define RESOLVE_BENEATH 0x08
# define RESOLVE_IN_ROOT 0x10
# define RESOLVE_CACHED 0x20
# endif
# if !@HAVE_OPENAT2@
_GL_FUNCDECL_SYS (openat2, int,
(int fd, char const *file, struct open_how const *how,
size_t size),
_GL_ARG_NONNULL ((2, 3)));
# endif
_GL_CXXALIAS_SYS (openat2, int,
(int fd, char const *file, struct open_how const *how,
size_t size));
_GL_CXXALIASWARN (openat2);
#elif defined GNULIB_POSIXCHECK
# if HAVE_RAW_DECL_OPENAT2
_GL_WARN_ON_USE (openat2, "openat2 is not portable - "
"use gnulib module openat2 for portability");
# endif
#endif
/* Fix up the FD_* macros, only known to be missing on mingw. */
@ -293,11 +328,6 @@ _GL_WARN_ON_USE (openat, "openat is not portable - "
# endif
#endif
#if !defined O_DIRECT && defined O_DIRECTIO
/* Tru64 spells it 'O_DIRECTIO'. */
# define O_DIRECT O_DIRECTIO
#endif
#if !defined O_CLOEXEC && defined O_NOINHERIT
/* Mingw spells it 'O_NOINHERIT'. */
# define O_CLOEXEC O_NOINHERIT
@ -460,6 +490,15 @@ _GL_WARN_ON_USE (openat, "openat is not portable - "
# define AT_NO_AUTOMOUNT 0
#endif
/* errno when openat+O_NOFOLLOW fails because the file is a symlink. */
#if defined __FreeBSD__ || defined __FreeBSD_kernel__ || defined __DragonFly__
# define _GL_OPENAT_ESYMLINK EMLINK
#elif defined __NetBSD__
# define _GL_OPENAT_ESYMLINK EFTYPE
#else
# define _GL_OPENAT_ESYMLINK ELOOP
#endif
#endif /* _@GUARD_PREFIX@_FCNTL_H */
#endif /* _@GUARD_PREFIX@_FCNTL_H */
#endif

View file

@ -1,5 +1,5 @@
/* Hook for making file descriptor functions close(), ioctl() extensible.
Copyright (C) 2009-2025 Free Software Foundation, Inc.
Copyright (C) 2009-2026 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2009.
This file is free software: you can redistribute it and/or modify

View file

@ -1,5 +1,5 @@
/* Hook for making file descriptor functions close(), ioctl() extensible.
Copyright (C) 2009-2025 Free Software Foundation, Inc.
Copyright (C) 2009-2026 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

View file

@ -1,5 +1,5 @@
/* fflush.c -- allow flushing input streams
Copyright (C) 2007-2025 Free Software Foundation, Inc.
Copyright (C) 2007-2026 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
@ -65,7 +65,7 @@ clear_ungetc_buffer (FILE *fp)
fp->_ungetc_count = 0;
fp->_rcount = - fp->_rcount;
}
# elif defined _IOERR /* Minix, AIX, HP-UX, IRIX, OSF/1, Solaris, OpenServer, UnixWare, mingw, MSVC, NonStop Kernel, OpenVMS */
# elif defined _IOERR /* Minix, AIX, HP-UX, Solaris, OpenServer, UnixWare, mingw, MSVC, NonStop Kernel, OpenVMS */
/* Nothing to do. */
# else /* other implementations */
fseeko (fp, 0, SEEK_CUR);

View file

@ -1,5 +1,5 @@
/* Supplemental information about the floating-point formats.
Copyright (C) 2007, 2009-2025 Free Software Foundation, Inc.
Copyright (C) 2007, 2009-2026 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2007.
This file is free software: you can redistribute it and/or modify

View file

@ -1,5 +1,5 @@
/* Auxiliary definitions for <float.h>.
Copyright (C) 2011-2025 Free Software Foundation, Inc.
Copyright (C) 2011-2026 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2011.
This file is free software: you can redistribute it and/or modify
@ -21,10 +21,7 @@
#include <float.h>
#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 / 0x1p53 } };
# elif defined __i386__
# ifdef __i386__
const union gl_long_double_union gl_LDBL_MAX =
{ { 0xFFFFFFFF, 0xFFFFFFFF, 32766 } };
# endif

View file

@ -1,6 +1,6 @@
/* A correct <float.h>.
Copyright (C) 2007-2025 Free Software Foundation, Inc.
Copyright (C) 2007-2026 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
@ -113,69 +113,31 @@ extern const union gl_long_double_union gl_LDBL_MAX;
# define LDBL_MAX_10_EXP 4932
#endif
/* 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. */
/* 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 8.3, the values of LDBL_MAX and LDBL_EPSILON are
wrong.
Assume these bugs are fixed in any GCC new enough
to define __LDBL_NORM_MAX__. */
#if (defined _ARCH_PPC && LDBL_MANT_DIG == 106 \
&& defined __GNUC__)
&& defined __GNUC__ && !defined __LDBL_NORM_MAX__)
# undef LDBL_MIN_EXP
# define LDBL_MIN_EXP DBL_MIN_EXP
# define LDBL_MIN_EXP (-968)
# undef LDBL_MIN_10_EXP
# define LDBL_MIN_10_EXP DBL_MIN_10_EXP
# define LDBL_MIN_10_EXP (-291)
# undef LDBL_MIN
# define LDBL_MIN 2.22507385850720138309023271733240406422e-308L /* DBL_MIN = 2^-1022 */
# define LDBL_MIN 0x1p-969L
/* IBM long double is tricky: it is represented as the sum of two doubles,
and the high double must equal the sum of the two parts rounded to nearest.
The maximum finite value for which this is true is
{ 0x1.fffffffffffffp+1023, 0x1.ffffffffffffep+969 },
which represents 0x1.fffffffffffff7ffffffffffff8p+1023L.
Although computations can yield representations of numbers larger than this,
these computations are considered to have overflowed and behavior is undefined.
See <https://gcc.gnu.org/PR120993>. */
# undef LDBL_MAX
/* LDBL_MAX is 2**1024 - 2**918, represented as: { 0x7FEFFFFF, 0xFFFFFFFF,
0x7C9FFFFF, 0xFFFFFFFF }.
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;
The following alternative would not work as well when GCC is optimizing:
#define LDBL_MAX (*(long double const *) (double[])
{ DBL_MAX, DBL_MAX / 0x1p53 })
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
{
struct { double hi; double lo; } dd;
long double ld;
};
# define GNULIB_defined_long_double_union 1
# 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.
On IRIX 6.5, with gcc 4.2, the values of LDBL_MIN_EXP, LDBL_MIN, LDBL_EPSILON
are wrong. */
#if defined __sgi && (LDBL_MANT_DIG >= 106)
# undef LDBL_MANT_DIG
# define LDBL_MANT_DIG 106
# if 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 */
# undef LDBL_EPSILON
# define LDBL_EPSILON 2.46519032881566189191165176650870696773e-32L /* 2^-105 */
# endif
#endif
# define LDBL_MAX 0x1.fffffffffffff7ffffffffffff8p+1023L
/* 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
@ -187,9 +149,8 @@ extern const union gl_long_double_union gl_LDBL_MAX;
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 */
# define LDBL_EPSILON 0x1p-105L
#endif
/* ============================ ISO C11 support ============================ */
@ -273,7 +234,7 @@ extern const union gl_long_double_union gl_LDBL_TRUE_MIN;
# define FLT_NORM_MAX FLT_MAX
#endif
#ifndef FLT_SNAN
/* For sh, beware of <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111814>. */
/* For sh, beware of <https://gcc.gnu.org/PR111814>. */
# if ((__GNUC__ + (__GNUC_MINOR__ >= 3) > 3) || defined __clang__) && !defined __sh__
# define FLT_SNAN __builtin_nansf ("")
# else
@ -297,7 +258,7 @@ extern gl_FLT_SNAN_t gl_FLT_SNAN;
# define DBL_NORM_MAX DBL_MAX
#endif
#ifndef DBL_SNAN
/* For sh, beware of <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111814>. */
/* For sh, beware of <https://gcc.gnu.org/PR111814>. */
# if ((__GNUC__ + (__GNUC_MINOR__ >= 3) > 3) || defined __clang__) && !defined __sh__
# define DBL_SNAN __builtin_nans ("")
# else
@ -322,12 +283,14 @@ extern gl_DBL_SNAN_t gl_DBL_SNAN;
#ifndef LDBL_NORM_MAX
# ifdef __LDBL_NORM_MAX__
# define LDBL_NORM_MAX __LDBL_NORM_MAX__
# elif FLT_RADIX == 2 && LDBL_MAX_EXP == 1024 && LDBL_MANT_DIG == 106
# define LDBL_NORM_MAX 0x1.ffffffffffffffffffffffffff8p+1022L
# 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>. */
/* For sh, beware of <https://gcc.gnu.org/PR111814>. */
# if ((__GNUC__ + (__GNUC_MINOR__ >= 3) > 3) || defined __clang__) && !defined __sh__
# define LDBL_SNAN __builtin_nansl ("")
# else

View file

@ -1,5 +1,5 @@
/* Round towards negative infinity.
Copyright (C) 2007, 2010-2025 Free Software Foundation, Inc.
Copyright (C) 2007, 2010-2026 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

View file

@ -1,5 +1,5 @@
/* Round towards negative infinity.
Copyright (C) 2007, 2009-2025 Free Software Foundation, Inc.
Copyright (C) 2007, 2009-2026 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

View file

@ -1,5 +1,5 @@
/* Open a stream to a file.
Copyright (C) 2007-2025 Free Software Foundation, Inc.
Copyright (C) 2007-2026 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,13 +33,7 @@ orig_fopen (const char *filename, const char *mode)
}
/* Specification. */
#ifdef __osf__
/* Write "stdio.h" here, not <stdio.h>, otherwise OSF/1 5.1 DTK cc eliminates
this include because of the preliminary #include <stdio.h> above. */
# include "stdio.h"
#else
# include <stdio.h>
#endif
#include <stdio.h>
#include <errno.h>
#include <fcntl.h>
@ -51,24 +45,18 @@ orig_fopen (const char *filename, const char *mode)
FILE *
rpl_fopen (const char *filename, const char *mode)
{
int open_direction;
int open_flags;
#if GNULIB_FOPEN_GNU
bool open_flags_gnu;
# define BUF_SIZE 80
char fdopen_mode_buf[BUF_SIZE + 1];
#endif
#if defined _WIN32 && ! defined __CYGWIN__
if (strcmp (filename, "/dev/null") == 0)
if (streq (filename, "/dev/null"))
filename = "NUL";
#endif
/* Parse the mode. */
open_direction = 0;
open_flags = 0;
int open_direction = 0;
int open_flags = 0;
#if GNULIB_FOPEN_GNU
open_flags_gnu = false;
bool open_flags_gnu = false;
# define BUF_SIZE 80
char fdopen_mode_buf[BUF_SIZE + 1];
#endif
{
const char *p = mode;
@ -169,21 +157,18 @@ rpl_fopen (const char *filename, const char *mode)
size_t len = strlen (filename);
if (len > 0 && filename[len - 1] == '/')
{
int fd;
struct stat statbuf;
FILE *fp;
if (open_direction != O_RDONLY)
{
errno = EISDIR;
return NULL;
}
fd = open (filename, open_direction | open_flags,
S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);
int fd = open (filename, open_direction | open_flags,
S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);
if (fd < 0)
return NULL;
struct stat statbuf;
if (fstat (fd, &statbuf) >= 0 && !S_ISDIR (statbuf.st_mode))
{
close (fd);
@ -191,6 +176,7 @@ rpl_fopen (const char *filename, const char *mode)
return NULL;
}
FILE *fp;
# if GNULIB_FOPEN_GNU
fp = fdopen (fd, fdopen_mode_buf);
# else
@ -210,15 +196,12 @@ rpl_fopen (const char *filename, const char *mode)
#if GNULIB_FOPEN_GNU
if (open_flags_gnu)
{
int fd;
FILE *fp;
fd = open (filename, open_direction | open_flags,
S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);
int fd = open (filename, open_direction | open_flags,
S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);
if (fd < 0)
return NULL;
fp = fdopen (fd, fdopen_mode_buf);
FILE *fp = fdopen (fd, fdopen_mode_buf);
if (fp == NULL)
{
int saved_errno = errno;

View file

@ -1,5 +1,5 @@
/* Flushing buffers of a FILE stream.
Copyright (C) 2007-2025 Free Software Foundation, Inc.
Copyright (C) 2007-2026 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
@ -101,7 +101,7 @@ fpurge (FILE *fp)
if (fp->_ptr != NULL)
fp->_count = 0;
return 0;
# elif defined _IOERR /* AIX, HP-UX, IRIX, OSF/1, Solaris, OpenServer, UnixWare, mingw, MSVC, NonStop Kernel, OpenVMS */
# elif defined _IOERR /* AIX, HP-UX, Solaris, OpenServer, UnixWare, mingw, MSVC, NonStop Kernel, OpenVMS */
fp_->_ptr = fp_->_base;
if (fp_->_ptr != NULL)
fp_->_cnt = 0;

View file

@ -1,5 +1,5 @@
/* Retrieve information about a FILE stream.
Copyright (C) 2007-2025 Free Software Foundation, Inc.
Copyright (C) 2007-2026 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,7 +22,7 @@
#include "stdio-impl.h"
/* Don't use glibc's __freading function in glibc < 2.7, see
<https://sourceware.org/bugzilla/show_bug.cgi?id=4359> */
<https://sourceware.org/PR4359> */
#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,
@ -47,7 +47,7 @@ freading (FILE *fp)
return (fp->_flags & _IOREAD) != 0;
# elif defined __minix /* Minix */
return (fp->_flags & _IOREADING) != 0;
# elif defined _IOERR /* AIX, HP-UX, IRIX, OSF/1, Solaris, OpenServer, UnixWare, mingw, MSVC, NonStop Kernel, OpenVMS */
# elif defined _IOERR /* AIX, HP-UX, Solaris, OpenServer, UnixWare, mingw, MSVC, NonStop Kernel, OpenVMS */
# if defined __sun /* Solaris */
return (fp_->_flag & _IOREAD) != 0 && (fp_->_flag & _IOWRT) == 0;
# else

View file

@ -1,5 +1,5 @@
/* Retrieve information about a FILE stream.
Copyright (C) 2007-2025 Free Software Foundation, Inc.
Copyright (C) 2007-2026 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

View file

@ -1,6 +1,6 @@
/* Make free() preserve errno.
Copyright (C) 2003, 2006, 2009-2025 Free Software Foundation, Inc.
Copyright (C) 2003, 2006, 2009-2026 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,7 +33,7 @@ rpl_free (void *p)
{
# if defined __GNUC__ && !defined __clang__
/* An invalid GCC optimization
<https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98396>
<https://gcc.gnu.org/PR98396>
would optimize away the assignments in the code below, when link-time
optimization (LTO) is enabled. Make the code more complicated, so that
GCC does not grok how to optimize it. */
@ -44,9 +44,9 @@ rpl_free (void *p)
free (p);
errno = err[errno == 0];
# else
int err = errno;
int saved_errno = errno;
free (p);
errno = err;
errno = saved_errno;
# endif
}

View file

@ -1,5 +1,5 @@
/* An fseek() function that, together with fflush(), is POSIX compliant.
Copyright (C) 2007, 2009-2025 Free Software Foundation, Inc.
Copyright (C) 2007, 2009-2026 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

View file

@ -1,5 +1,5 @@
/* An fseeko() function that, together with fflush(), is POSIX compliant.
Copyright (C) 2007-2025 Free Software Foundation, Inc.
Copyright (C) 2007-2026 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
@ -84,7 +84,7 @@ fseeko (FILE *fp, off_t offset, int whence)
#elif defined __minix /* Minix */
if (fp_->_ptr == fp_->_buf
&& (fp_->_ptr == NULL || fp_->_count == 0))
#elif defined _IOERR /* AIX, HP-UX, IRIX, OSF/1, Solaris, OpenServer, UnixWare, mingw, MSVC, NonStop Kernel, OpenVMS */
#elif defined _IOERR /* AIX, HP-UX, Solaris, OpenServer, UnixWare, mingw, MSVC, NonStop Kernel, OpenVMS */
if (fp_->_ptr == fp_->_base
&& (fp_->_ptr == NULL || fp_->_cnt == 0))
#elif defined __UCLIBC__ /* uClibc */
@ -158,7 +158,7 @@ fseeko (FILE *fp, off_t offset, int whence)
fp_->_flags &= ~__SEOF;
#elif defined __EMX__ /* emx+gcc */
fp->_flags &= ~_IOEOF;
#elif defined _IOERR /* AIX, HP-UX, IRIX, OSF/1, Solaris, OpenServer, UnixWare, mingw, MSVC, NonStop Kernel, OpenVMS */
#elif defined _IOERR /* AIX, HP-UX, Solaris, OpenServer, UnixWare, mingw, MSVC, NonStop Kernel, OpenVMS */
fp_->_flag &= ~_IOEOF;
#elif defined __MINT__ /* Atari FreeMiNT */
fp->__offset = pos;

View file

@ -1,5 +1,5 @@
/* Set the error indicator of a stream.
Copyright (C) 2007-2025 Free Software Foundation, Inc.
Copyright (C) 2007-2026 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
@ -42,7 +42,7 @@ fseterr (FILE *fp)
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 */
#elif defined _IOERR /* AIX, HP-UX, Solaris, OpenServer, UnixWare, mingw, MSVC, NonStop Kernel, OpenVMS */
fp_->_flag |= _IOERR;
#elif defined __UCLIBC__ /* uClibc */
fp->__modeflags |= __FLAG_ERROR;
@ -59,14 +59,10 @@ fseterr (FILE *fp)
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;
int saved_errno = errno;
fflush (fp);
fd = fileno (fp);
fd2 = dup (fd);
int fd = fileno (fp);
int fd2 = dup (fd);
if (fd2 >= 0)
{
close (fd);

View file

@ -1,5 +1,5 @@
/* Set the error indicator of a stream.
Copyright (C) 2007, 2009-2025 Free Software Foundation, Inc.
Copyright (C) 2007, 2009-2026 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

View file

@ -1,5 +1,5 @@
/* fstat() replacement.
Copyright (C) 2011-2025 Free Software Foundation, Inc.
Copyright (C) 2011-2026 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
@ -40,14 +40,7 @@ orig_fstat (int fd, struct stat *buf)
#endif
/* Specification. */
#ifdef __osf__
/* Write "sys/stat.h" here, not <sys/stat.h>, otherwise OSF/1 5.1 DTK cc
eliminates this include because of the preliminary #include <sys/stat.h>
above. */
# include "sys/stat.h"
#else
# include <sys/stat.h>
#endif
#include <sys/stat.h>
#include "stat-time.h"

View file

@ -1,6 +1,6 @@
/* fsusage.c -- return space usage of mounted file systems
Copyright (C) 1991-1992, 1996, 1998-1999, 2002-2006, 2009-2025 Free Software
Copyright (C) 1991-1992, 1996, 1998-1999, 2002-2006, 2009-2026 Free Software
Foundation, Inc.
This file is free software: you can redistribute it and/or modify
@ -91,10 +91,12 @@ static int
statvfs_works (void)
{
static int statvfs_works_cache = -1;
struct utsname name;
if (statvfs_works_cache < 0)
statvfs_works_cache = (uname (&name) == 0
&& 0 <= strverscmp (name.release, "2.6.36"));
{
struct utsname name;
statvfs_works_cache = (uname (&name) == 0
&& 0 <= strverscmp (name.release, "2.6.36"));
}
return statvfs_works_cache;
}
# endif
@ -148,15 +150,6 @@ get_fs_usage (char const *file, char const *disk, struct fs_usage *fsp)
? PROPAGATE_ALL_ONES (fsd.f_frsize)
: PROPAGATE_ALL_ONES (fsd.f_bsize));
#elif defined STAT_STATFS3_OSF1 /* OSF/1 */
struct statfs fsd;
if (statfs (file, &fsd, sizeof (struct statfs)) != 0)
return -1;
fsp->fsu_blocksize = PROPAGATE_ALL_ONES (fsd.f_fsize);
#elif defined STAT_STATFS2_FRSIZE /* 2.6 < glibc/Linux < 2.6.36 */
struct statfs fsd;
@ -201,7 +194,7 @@ get_fs_usage (char const *file, char const *disk, struct fs_usage *fsp)
fsp->fsu_blocksize = PROPAGATE_ALL_ONES (fsd.f_fsize);
#elif defined STAT_STATFS4 /* SVR3, old Irix */
#elif defined STAT_STATFS4 /* SVR3 */
struct statfs fsd;

View file

@ -1,6 +1,6 @@
/* fsusage.h -- declarations for file system space usage info
Copyright (C) 1991-1992, 1997, 2003-2006, 2009-2025 Free Software
Copyright (C) 1991-1992, 1997, 2003-2006, 2009-2026 Free Software
Foundation, Inc.
This file is free software: you can redistribute it and/or modify

View file

@ -1,5 +1,5 @@
/* An ftell() function that works around platform bugs.
Copyright (C) 2007-2025 Free Software Foundation, Inc.
Copyright (C) 2007-2026 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

View file

@ -1,5 +1,5 @@
/* An ftello() function that works around platform bugs.
Copyright (C) 2007, 2009-2025 Free Software Foundation, Inc.
Copyright (C) 2007, 2009-2026 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
@ -124,13 +124,11 @@ ftello (FILE *fp)
gets confused by this. */
if (fp_->_flag & _IOWRT)
{
off_t pos;
/* Call ftello nevertheless, for the side effects that it does on fp. */
ftello (fp);
/* Compute the file position ourselves. */
pos = lseek (fileno (fp), (off_t) 0, SEEK_CUR);
off_t pos = lseek (fileno (fp), (off_t) 0, SEEK_CUR);
if (pos >= 0)
{
if ((fp_->_flag & _IONBF) == 0 && fp_->_base != NULL)

View file

@ -1,4 +1,4 @@
/* Copyright (C) 1997, 2001-2002, 2004-2006, 2008-2025 Free Software
/* Copyright (C) 1997, 2001-2002, 2004-2006, 2008-2026 Free Software
Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Philip Blundell <pjb27@cam.ac.uk>, 1997.
@ -27,7 +27,7 @@
# include <libintl.h>
#else
# include "gettext.h"
# define _(msgid) dgettext ("gnulib", msgid)
# define _(msgid) dgettext (GNULIB_TEXT_DOMAIN, msgid)
# define N_(msgid) msgid
#endif
@ -79,8 +79,7 @@ values[] =
const char *
gai_strerror (int code)
{
size_t i;
for (i = 0; i < sizeof (values) / sizeof (values[0]); ++i)
for (size_t i = 0; i < sizeof (values) / sizeof (values[0]); ++i)
if (values[i].code == code)
return _(values[i].msg);

View file

@ -1,5 +1,5 @@
/* Get address information (partial implementation).
Copyright (C) 1997, 2001-2002, 2004-2025 Free Software Foundation, Inc.
Copyright (C) 1997, 2001-2002, 2004-2026 Free Software Foundation, Inc.
Contributed by Simon Josefsson <simon@josefsson.org>.
This file is free software: you can redistribute it and/or modify
@ -40,7 +40,7 @@
#include <stdio.h>
#include "gettext.h"
#define _(msgid) dgettext ("gnulib", msgid)
#define _(msgid) dgettext (GNULIB_TEXT_DOMAIN, msgid)
#define N_(msgid) msgid
/* BeOS has AF_INET, but not PF_INET. */
@ -52,9 +52,40 @@
# define PF_UNSPEC 0
#endif
#if defined __sun || !HAVE_GETADDRINFO
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;
}
#endif
#if HAVE_GETADDRINFO
/* Override with cdecl calling convention and mingw fix. */
/* Override with cdecl calling convention and Windows and Solaris 10 fixes. */
int
getaddrinfo (const char *restrict nodename,
@ -63,10 +94,18 @@ getaddrinfo (const char *restrict nodename,
struct addrinfo **restrict res)
# undef getaddrinfo
{
/* Workaround for native Windows. */
if (hints && (hints->ai_flags & AI_NUMERICSERV) != 0
&& servname && !(*servname >= '0' && *servname <= '9'))
return EAI_NONAME;
# ifdef __sun
/* Workaround for Solaris 10. */
if (hints && (hints->ai_flags & AI_NUMERICHOST)
&& nodename && !is_numeric_host (nodename, hints->ai_family))
return EAI_NONAME;
# endif
return getaddrinfo (nodename, servname, hints, res);
}
@ -114,14 +153,13 @@ static int
use_win32_p (void)
{
static int done = 0;
HMODULE h;
if (done)
return getaddrinfo_ptr ? 1 : 0;
done = 1;
h = GetModuleHandle ("ws2_32.dll");
HMODULE h = GetModuleHandle ("ws2_32.dll");
if (h)
{
@ -185,33 +223,6 @@ validate_family (int family)
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
socket addresses. */
int
@ -221,11 +232,6 @@ getaddrinfo (const char *restrict nodename,
struct addrinfo **restrict res)
#undef getaddrinfo
{
struct addrinfo *tmp;
int port = 0;
struct hostent *he;
void *storage;
size_t size;
# if HAVE_IPV6
struct v6_pair {
struct addrinfo addrinfo;
@ -281,6 +287,7 @@ getaddrinfo (const char *restrict nodename,
# endif
}
int port = 0;
if (servname)
{
struct servent *se = NULL;
@ -306,10 +313,11 @@ getaddrinfo (const char *restrict nodename,
}
/* FIXME: Use gethostbyname_r if available. */
he = gethostbyname (nodename);
struct hostent *he = gethostbyname (nodename);
if (!he || he->h_addr_list[0] == NULL)
return EAI_NONAME;
size_t size;
switch (he->h_addrtype)
{
# if HAVE_IPV6
@ -328,10 +336,11 @@ getaddrinfo (const char *restrict nodename,
return EAI_NODATA;
}
storage = calloc (1, size);
void *storage = calloc (1, size);
if (!storage)
return EAI_MEMORY;
struct addrinfo *tmp;
switch (he->h_addrtype)
{
# if HAVE_IPV6
@ -446,9 +455,7 @@ freeaddrinfo (struct addrinfo *ai)
while (ai)
{
struct addrinfo *cur;
cur = ai;
struct addrinfo *cur = ai;
ai = ai->ai_next;
free (cur->ai_canonname);

View file

@ -1,5 +1,5 @@
/* getdelim.c --- Implementation of replacement getdelim function.
Copyright (C) 1994, 1996-1998, 2001, 2003, 2005-2025 Free Software
Copyright (C) 1994, 1996-1998, 2001, 2003, 2005-2026 Free Software
Foundation, Inc.
This file is free software: you can redistribute it and/or modify
@ -62,10 +62,13 @@ alloc_failed (void)
ssize_t
getdelim (char **lineptr, size_t *n, int delimiter, FILE *fp)
{
ssize_t result;
size_t cur_len = 0;
if (lineptr == NULL || n == NULL || fp == NULL)
if (lineptr == NULL || n == NULL
/* glibc already declares this function as __nonnull ((4)).
Avoid a gcc warning "nonnull argument fp compared to NULL". */
#if !(__GLIBC__ >= 2)
|| fp == NULL
#endif
)
{
errno = EINVAL;
return -1;
@ -73,6 +76,8 @@ getdelim (char **lineptr, size_t *n, int delimiter, FILE *fp)
flockfile (fp);
ssize_t result;
if (*lineptr == NULL || *n == 0)
{
char *new_lineptr;
@ -87,54 +92,56 @@ getdelim (char **lineptr, size_t *n, int delimiter, FILE *fp)
*lineptr = new_lineptr;
}
for (;;)
{
int i;
{
size_t cur_len = 0;
for (;;)
{
int i;
i = getc_maybe_unlocked (fp);
if (i == EOF)
{
result = -1;
i = getc_maybe_unlocked (fp);
if (i == EOF)
{
result = -1;
break;
}
/* Make enough space for len+1 (for final NUL) bytes. */
if (cur_len + 1 >= *n)
{
size_t needed_max =
SSIZE_MAX < SIZE_MAX ? (size_t) SSIZE_MAX + 1 : SIZE_MAX;
size_t needed = 2 * *n + 1; /* Be generous. */
if (needed_max < needed)
needed = needed_max;
if (cur_len + 1 >= needed)
{
result = -1;
errno = EOVERFLOW;
goto unlock_return;
}
char *new_lineptr = (char *) realloc (*lineptr, needed);
if (new_lineptr == NULL)
{
alloc_failed ();
result = -1;
goto unlock_return;
}
*lineptr = new_lineptr;
*n = needed;
}
(*lineptr)[cur_len] = i;
cur_len++;
if (i == delimiter)
break;
}
/* Make enough space for len+1 (for final NUL) bytes. */
if (cur_len + 1 >= *n)
{
size_t needed_max =
SSIZE_MAX < SIZE_MAX ? (size_t) SSIZE_MAX + 1 : SIZE_MAX;
size_t needed = 2 * *n + 1; /* Be generous. */
char *new_lineptr;
if (needed_max < needed)
needed = needed_max;
if (cur_len + 1 >= needed)
{
result = -1;
errno = EOVERFLOW;
goto unlock_return;
}
new_lineptr = (char *) realloc (*lineptr, needed);
if (new_lineptr == NULL)
{
alloc_failed ();
result = -1;
goto unlock_return;
}
*lineptr = new_lineptr;
*n = needed;
}
(*lineptr)[cur_len] = i;
cur_len++;
if (i == delimiter)
break;
}
(*lineptr)[cur_len] = '\0';
result = cur_len ? cur_len : result;
}
(*lineptr)[cur_len] = '\0';
result = cur_len ? cur_len : result;
}
unlock_return:
funlockfile (fp); /* doesn't set errno */

View file

@ -1,5 +1,5 @@
/* getdtablesize() function: Return maximum possible file descriptor value + 1.
Copyright (C) 2008-2025 Free Software Foundation, Inc.
Copyright (C) 2008-2026 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2008.
This file is free software: you can redistribute it and/or modify
@ -61,13 +61,10 @@ getdtablesize (void)
{
/* We are looking for the number N such that the valid file descriptors
are 0..N-1. It can be obtained through a loop as follows:
{
int fd;
for (fd = 3; fd < 65536; fd++)
if (dup2 (0, fd) == -1)
break;
return fd;
}
for (int fd = 3; fd < 65536; fd++)
if (dup2 (0, fd) == -1)
break;
return fd;
On Windows XP, the result is 2048.
The drawback of this loop is that it allocates memory for a libc
internal array that is never freed.

View file

@ -1,6 +1,6 @@
/* gethostname emulation for SysV and POSIX.1.
Copyright (C) 1992, 2003, 2006, 2008-2025 Free Software Foundation, Inc.
Copyright (C) 1992, 2003, 2006, 2008-2026 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
@ -89,12 +89,10 @@ gethostname (char *name, size_t len)
int
rpl_gethostname (char *name, size_t len)
{
int r;
if (len > INT_MAX)
len = INT_MAX;
gl_sockets_startup (SOCKETS_1_1);
r = gethostname (name, (int) len);
int r = gethostname (name, (int) len);
if (r < 0)
set_winsock_errno ();

View file

@ -1,5 +1,5 @@
/* getline.c --- Implementation of replacement getline function.
Copyright (C) 2005-2007, 2009-2025 Free Software Foundation, Inc.
Copyright (C) 2005-2007, 2009-2026 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

View file

@ -1,6 +1,6 @@
/* Get the system load averages.
Copyright (C) 1985-1989, 1991-1995, 1997, 1999-2000, 2003-2025 Free Software
Copyright (C) 1985-1989, 1991-1995, 1997, 1999-2000, 2003-2026 Free Software
Foundation, Inc.
NOTE: The canonical source of this file is maintained with gnulib.
@ -140,21 +140,6 @@
# define SUNOS_5
# endif
# if defined (__osf__) && defined (__alpha)
# define OSF_ALPHA
# include <sys/mbuf.h>
# include <sys/socket.h>
# include <net/route.h>
# include <sys/table.h>
/* Tru64 4.0D's table.h redefines sys */
# undef sys
# endif
# if defined (__osf__) && (defined (mips) || defined (__mips__))
# define OSF_MIPS
# include <sys/table.h>
# endif
/* VAX C can't handle multi-line #ifs, or lines longer than 256 chars. */
# ifndef LOAD_AVE_TYPE
@ -167,31 +152,16 @@
# define LOAD_AVE_TYPE long
# endif
# ifdef sgi
# define LOAD_AVE_TYPE long
# endif
# ifdef SVR4
# define LOAD_AVE_TYPE long
# endif
# ifdef OSF_ALPHA
# define LOAD_AVE_TYPE long
# endif
# if defined _AIX && ! defined HAVE_LIBPERFSTAT
# define LOAD_AVE_TYPE long
# endif
# endif /* No LOAD_AVE_TYPE. */
# ifdef OSF_ALPHA
/* <sys/param.h> defines an incorrect value for FSCALE on Alpha OSF/1,
according to ghazi@noc.rutgers.edu. */
# undef FSCALE
# define FSCALE 1024.0
# endif
# ifndef FSCALE
@ -324,10 +294,6 @@
# endif
# endif /* NeXT */
# ifdef sgi
# include <sys/sysmp.h>
# endif /* sgi */
# ifdef UMAX
# include <signal.h>
# include <sys/time.h>
@ -389,7 +355,7 @@ static bool getloadavg_initialized;
/* Offset in kmem to seek to read load average, or 0 means invalid. */
static long offset;
# if ! defined __VMS && ! defined sgi && ! (defined __linux__ || defined __ANDROID__)
# if ! defined __VMS && ! (defined __linux__ || defined __ANDROID__)
static struct nlist name_list[2];
# endif
@ -418,51 +384,47 @@ getloadavg (double loadavg[], int nelem)
# if !defined (LDAV_DONE) && defined (HAVE_LIBKSTAT) /* Solaris <= 2.6 */
/* Use libkstat because we don't have to be root. */
# define LDAV_DONE
kstat_ctl_t *kc;
kstat_t *ksp;
kstat_named_t *kn;
int saved_errno;
{
kstat_ctl_t *kc = kstat_open ();
if (kc == NULL)
return -1;
kstat_t *ksp = kstat_lookup (kc, "unix", 0, "system_misc");
if (ksp == NULL)
return -1;
if (kstat_read (kc, ksp, 0) == -1)
return -1;
kc = kstat_open ();
if (kc == NULL)
return -1;
ksp = kstat_lookup (kc, "unix", 0, "system_misc");
if (ksp == NULL)
return -1;
if (kstat_read (kc, ksp, 0) == -1)
return -1;
kstat_named_t *kn = kstat_data_lookup (ksp, "avenrun_1min");
if (kn == NULL)
{
/* Return -1 if no load average information is available. */
nelem = 0;
elem = -1;
}
if (nelem >= 1)
loadavg[elem++] = (double) kn->value.ul / FSCALE;
kn = kstat_data_lookup (ksp, "avenrun_1min");
if (kn == NULL)
{
/* Return -1 if no load average information is available. */
nelem = 0;
elem = -1;
}
if (nelem >= 2)
{
kn = kstat_data_lookup (ksp, "avenrun_5min");
if (kn != NULL)
{
loadavg[elem++] = (double) kn->value.ul / FSCALE;
if (nelem >= 1)
loadavg[elem++] = (double) kn->value.ul / FSCALE;
if (nelem >= 3)
{
kn = kstat_data_lookup (ksp, "avenrun_15min");
if (kn != NULL)
loadavg[elem++] = (double) kn->value.ul / FSCALE;
}
}
}
if (nelem >= 2)
{
kn = kstat_data_lookup (ksp, "avenrun_5min");
if (kn != NULL)
{
loadavg[elem++] = (double) kn->value.ul / FSCALE;
if (nelem >= 3)
{
kn = kstat_data_lookup (ksp, "avenrun_15min");
if (kn != NULL)
loadavg[elem++] = (double) kn->value.ul / FSCALE;
}
}
}
saved_errno = errno;
kstat_close (kc);
errno = saved_errno;
int saved_errno = errno;
kstat_close (kc);
errno = saved_errno;
}
# endif /* HAVE_LIBKSTAT */
# if !defined (LDAV_DONE) && defined (hpux) && defined (HAVE_PSTAT_GETDYNAMIC)
@ -523,13 +485,12 @@ getloadavg (double loadavg[], int nelem)
char ldavgbuf[3 * (INT_STRLEN_BOUND (int) + sizeof ".00 ")];
char const *ptr = ldavgbuf;
int fd, count, saved_errno;
fd = open ("/proc/loadavg", O_RDONLY | O_CLOEXEC);
int fd = open ("/proc/loadavg", O_RDONLY | O_CLOEXEC);
if (fd == -1)
return -1;
count = read (fd, ldavgbuf, sizeof ldavgbuf - 1);
saved_errno = errno;
int count = read (fd, ldavgbuf, sizeof ldavgbuf - 1);
int saved_errno = errno;
(void) close (fd);
errno = saved_errno;
if (count <= 0)
@ -538,9 +499,6 @@ getloadavg (double loadavg[], int nelem)
for (elem = 0; elem < nelem; elem++)
{
double numerator = 0;
double denominator = 1;
while (*ptr == ' ')
ptr++;
@ -556,6 +514,9 @@ getloadavg (double loadavg[], int nelem)
break;
}
double numerator = 0;
double denominator = 1;
while ('0' <= *ptr && *ptr <= '9')
numerator = 10 * numerator + (*ptr++ - '0');
@ -578,24 +539,25 @@ getloadavg (double loadavg[], int nelem)
# define NETBSD_LDAV_FILE "/kern/loadavg"
# endif
unsigned long int load_ave[3], scale;
int count;
char readbuf[4 * INT_BUFSIZE_BOUND (unsigned long int) + 1];
int fd = open (NETBSD_LDAV_FILE, O_RDONLY | O_CLOEXEC);
if (fd < 0)
return fd;
char readbuf[4 * INT_BUFSIZE_BOUND (unsigned long int) + 1];
int nread = read (fd, readbuf, sizeof readbuf - 1);
int err = errno;
int saved_errno = errno;
close (fd);
if (nread < 0)
{
errno = err;
errno = saved_errno;
return -1;
}
readbuf[nread] = '\0';
count = sscanf (readbuf, "%lu %lu %lu %lu\n",
&load_ave[0], &load_ave[1], &load_ave[2],
&scale);
unsigned long int load_ave[3], scale;
int count = sscanf (readbuf, "%lu %lu %lu %lu\n",
&load_ave[0], &load_ave[1], &load_ave[2],
&scale);
if (count != 4)
{
errno = ENOTSUP;
@ -613,10 +575,6 @@ getloadavg (double loadavg[], int nelem)
# define LDAV_DONE
/* The NeXT code was adapted from iscreen 3.2. */
host_t host;
struct processor_set_basic_info info;
unsigned int info_count;
/* We only know how to get the 1-minute average for this system,
so even if the caller asks for more than 1, we only return 1. */
@ -628,7 +586,9 @@ getloadavg (double loadavg[], int nelem)
if (getloadavg_initialized)
{
info_count = PROCESSOR_SET_BASIC_INFO_COUNT;
host_t host;
struct processor_set_basic_info info;
unsigned int info_count = PROCESSOR_SET_BASIC_INFO_COUNT;
if (processor_set_info (default_set, PROCESSOR_SET_BASIC_INFO, &host,
(processor_set_info_t) &info, &info_count)
!= KERN_SUCCESS)
@ -654,14 +614,9 @@ getloadavg (double loadavg[], int nelem)
can be gathered with inq_stats system calls.
We only know how to get the 1-minute average for this system. */
struct proc_summary proc_sum_data;
struct stat_descr proc_info;
double load;
register unsigned int i, j;
if (cpus == 0)
{
register unsigned int c, i;
register unsigned int c;
struct cpu_config conf;
struct stat_descr desc;
@ -675,7 +630,7 @@ getloadavg (double loadavg[], int nelem)
return -1;
c = 0;
for (i = 0; i < conf.config_maxclass; ++i)
for (unsigned int i = 0; i < conf.config_maxclass; ++i)
{
struct class_stats stats;
memset (&stats, 0, sizeof stats);
@ -694,6 +649,9 @@ getloadavg (double loadavg[], int nelem)
samples = cpus < 2 ? 3 : (2 * cpus / 3);
}
struct proc_summary proc_sum_data;
struct stat_descr proc_info;
proc_info.sd_next = 0;
proc_info.sd_subsys = SUBSYS_PROC;
proc_info.sd_type = PROCTYPE_SUMMARY;
@ -704,9 +662,9 @@ getloadavg (double loadavg[], int nelem)
if (inq_stats (1, &proc_info) != 0)
return -1;
load = proc_sum_data.ps_nrunnable;
j = 0;
for (i = samples - 1; i > 0; --i)
double load = proc_sum_data.ps_nrunnable;
register unsigned int j = 0;
for (unsigned int i = samples - 1; i > 0; --i)
{
load += proc_sum_data.ps_nrun[j];
if (j++ == PS_NRUNSIZE)
@ -781,18 +739,6 @@ getloadavg (double loadavg[], int nelem)
}
# endif /* __MSDOS__ || WINDOWS32 */
# if !defined (LDAV_DONE) && defined (OSF_ALPHA) /* OSF/1 */
# define LDAV_DONE
struct tbl_loadavg load_ave;
table (TBL_LOADAVG, 0, &load_ave, 1, sizeof (load_ave));
for (elem = 0; elem < nelem; elem++)
loadavg[elem]
= (load_ave.tl_lscale == 0
? load_ave.tl_avenrun.d[elem]
: (load_ave.tl_avenrun.l[elem] / (double) load_ave.tl_lscale));
# endif /* OSF_ALPHA */
# if ! defined LDAV_DONE && defined __VMS /* VMS */
/* VMS specific code -- read from the Load Ave driver. */
@ -837,52 +783,44 @@ getloadavg (double loadavg[], int nelem)
# endif /* ! defined LDAV_DONE && defined __VMS */
# if ! defined LDAV_DONE && defined LOAD_AVE_TYPE && ! defined __VMS
/* IRIX, other old systems */
/* other old systems */
/* UNIX-specific code -- read the average from /dev/kmem. */
# define LDAV_PRIVILEGED /* This code requires special installation. */
LOAD_AVE_TYPE load_ave[3];
/* Get the address of LDAV_SYMBOL. */
if (offset == 0)
{
# ifndef sgi
# if ! defined NLIST_STRUCT || ! defined N_NAME_POINTER
# if ! defined NLIST_STRUCT || ! defined N_NAME_POINTER
strcpy (name_list[0].n_name, LDAV_SYMBOL);
strcpy (name_list[1].n_name, "");
# else /* NLIST_STRUCT */
# ifdef HAVE_STRUCT_NLIST_N_UN_N_NAME
# else /* NLIST_STRUCT */
# ifdef HAVE_STRUCT_NLIST_N_UN_N_NAME
name_list[0].n_un.n_name = LDAV_SYMBOL;
name_list[1].n_un.n_name = 0;
# else /* not HAVE_STRUCT_NLIST_N_UN_N_NAME */
# else /* not HAVE_STRUCT_NLIST_N_UN_N_NAME */
name_list[0].n_name = LDAV_SYMBOL;
name_list[1].n_name = 0;
# endif /* not HAVE_STRUCT_NLIST_N_UN_N_NAME */
# endif /* NLIST_STRUCT */
# endif /* not HAVE_STRUCT_NLIST_N_UN_N_NAME */
# endif /* NLIST_STRUCT */
# ifndef SUNOS_5
# ifndef SUNOS_5
if (
# if !defined (_AIX)
# if !defined (_AIX)
nlist (KERNEL_FILE, name_list)
# else /* _AIX */
# else /* _AIX */
knlist (name_list, 1, sizeof (name_list[0]))
# endif
# endif
>= 0)
/* Omit "&& name_list[0].n_type != 0 " -- it breaks on Sun386i. */
{
# ifdef FIXUP_KERNEL_SYMBOL_ADDR
# ifdef FIXUP_KERNEL_SYMBOL_ADDR
FIXUP_KERNEL_SYMBOL_ADDR (name_list);
# endif
# endif
offset = name_list[0].n_value;
}
# endif /* !SUNOS_5 */
# else /* sgi */
ptrdiff_t ldav_off = sysmp (MP_KERNADDR, MPKA_AVENRUN);
if (ldav_off != -1)
offset = (long int) ldav_off & 0x7fffffff;
# endif /* sgi */
# endif /* !SUNOS_5 */
}
/* Make sure we have /dev/kmem open. */
@ -909,6 +847,8 @@ getloadavg (double loadavg[], int nelem)
# endif /* SUNOS_5 */
}
LOAD_AVE_TYPE load_ave[3];
/* If we can, get the load average values. */
if (offset && getloadavg_initialized)
{

View file

@ -1,5 +1,5 @@
/* getopt-on-non-glibc compatibility macros.
Copyright (C) 1989-2025 Free Software Foundation, Inc.
Copyright (C) 1989-2026 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.

View file

@ -1,5 +1,5 @@
/* Declarations for getopt (basic, portable features only).
Copyright (C) 1989-2025 Free Software Foundation, Inc.
Copyright (C) 1989-2026 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.

View file

@ -1,5 +1,5 @@
/* Declarations for getopt (GNU extensions).
Copyright (C) 1989-2025 Free Software Foundation, Inc.
Copyright (C) 1989-2026 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.

View file

@ -1,5 +1,5 @@
/* getopt (basic, portable features) gnulib wrapper header.
Copyright (C) 1989-2025 Free Software Foundation, Inc.
Copyright (C) 1989-2026 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.

View file

@ -1,5 +1,5 @@
/* getopt (GNU extensions) gnulib wrapper header.
Copyright (C) 1989-2025 Free Software Foundation, Inc.
Copyright (C) 1989-2026 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.

View file

@ -1,5 +1,5 @@
/* Getopt for GNU.
Copyright (C) 1987-2025 Free Software Foundation, Inc.
Copyright (C) 1987-2026 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) dgettext ("gnulib", msgid)
# define _(msgid) dgettext (GNULIB_TEXT_DOMAIN, msgid)
/* When used standalone, flockfile and funlockfile might not be
available. */
# if (!defined _POSIX_THREAD_SAFE_FUNCTIONS \
@ -133,7 +133,6 @@ exchange (char **argv, struct _getopt_data *d)
int bottom = d->__first_nonopt;
int middle = d->__last_nonopt;
int top = d->optind;
char *tem;
/* Exchange the shorter segment with the far end of the longer segment.
That puts the shorter segment into the right place.
@ -151,7 +150,7 @@ exchange (char **argv, struct _getopt_data *d)
/* Swap it with the top part of the top segment. */
for (i = 0; i < len; i++)
{
tem = argv[bottom + i];
char *tem = argv[bottom + i];
argv[bottom + i] = argv[top - (middle - bottom) + i];
argv[top - (middle - bottom) + i] = tem;
}
@ -167,7 +166,7 @@ exchange (char **argv, struct _getopt_data *d)
/* Swap it with the bottom part of the bottom segment. */
for (i = 0; i < len; i++)
{
tem = argv[bottom + i];
char *tem = argv[bottom + i];
argv[bottom + i] = argv[middle + i];
argv[middle + i] = tem;
}
@ -196,28 +195,29 @@ process_long_option (int argc, char **argv, const char *optstring,
int long_only, struct _getopt_data *d,
int print_errors, const char *prefix)
{
char *nameend;
size_t namelen;
const struct option *p;
const struct option *pfound = NULL;
int n_options;
int option_index;
char *nameend;
for (nameend = d->__nextchar; *nameend && *nameend != '='; nameend++)
/* Do nothing. */ ;
namelen = nameend - d->__nextchar;
size_t namelen = nameend - d->__nextchar;
/* First look for an exact match, counting the options as a side
effect. */
for (p = longopts, n_options = 0; p->name; p++, n_options++)
if (!strncmp (p->name, d->__nextchar, namelen)
&& namelen == strlen (p->name))
{
/* Exact match found. */
pfound = p;
option_index = n_options;
break;
}
const struct option *pfound = NULL;
int n_options;
int option_index;
{
const struct option *p;
for (p = longopts, n_options = 0; p->name; p++, n_options++)
if (!strncmp (p->name, d->__nextchar, namelen)
&& namelen == strlen (p->name))
{
/* Exact match found. */
pfound = p;
option_index = n_options;
break;
}
}
if (pfound == NULL)
{
@ -227,6 +227,7 @@ process_long_option (int argc, char **argv, const char *optstring,
unsigned char ambig_fallback;
void *ambig_malloced = NULL;
int indfound = -1;
const struct option *p;
for (p = longopts, option_index = 0; p->name; p++, option_index++)
if (!strncmp (p->name, d->__nextchar, namelen))
@ -475,11 +476,11 @@ _getopt_internal_r (int argc, char **argv, const char *optstring,
const struct option *longopts, int *longind,
int long_only, struct _getopt_data *d, int posixly_correct)
{
int print_errors = d->opterr;
if (argc < 1)
return -1;
int print_errors = d->opterr;
d->optarg = NULL;
if (d->optind == 0 || !d->__initialized)
@ -594,11 +595,10 @@ _getopt_internal_r (int argc, char **argv, const char *optstring,
if (long_only && (argv[d->optind][2]
|| !strchr (optstring, argv[d->optind][1])))
{
int code;
d->__nextchar = argv[d->optind] + 1;
code = process_long_option (argc, argv, optstring, longopts,
longind, long_only, d,
print_errors, "-");
int code = process_long_option (argc, argv, optstring, longopts,
longind, long_only, d,
print_errors, "-");
if (code != -1)
return code;
}
@ -707,14 +707,12 @@ _getopt_internal (int argc, char **argv, const char *optstring,
const struct option *longopts, int *longind, int long_only,
int posixly_correct)
{
int result;
getopt_data.optind = optind;
getopt_data.opterr = opterr;
result = _getopt_internal_r (argc, argv, optstring, longopts,
longind, long_only, &getopt_data,
posixly_correct);
int result = _getopt_internal_r (argc, argv, optstring, longopts,
longind, long_only, &getopt_data,
posixly_correct);
optind = getopt_data.optind;
optarg = getopt_data.optarg;
@ -751,14 +749,13 @@ GETOPT_ENTRY(getopt, 1)
int
main (int argc, char **argv)
{
int c;
int digit_optind = 0;
while (1)
{
int this_option_optind = optind ? optind : 1;
c = getopt (argc, argv, "abc:d:0123456789");
int c = getopt (argc, argv, "abc:d:0123456789");
if (c == -1)
break;

View file

@ -1,5 +1,5 @@
/* Declarations for getopt.
Copyright (C) 1989-2025 Free Software Foundation, Inc.
Copyright (C) 1989-2026 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

View file

@ -1,5 +1,5 @@
/* getopt_long and getopt_long_only entry points for GNU getopt.
Copyright (C) 1987-2025 Free Software Foundation, Inc.
Copyright (C) 1987-2026 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.
@ -73,7 +73,6 @@ _getopt_long_only_r (int argc, char **argv, const char *options,
int
main (int argc, char **argv)
{
int c;
int digit_optind = 0;
while (1)
@ -91,8 +90,8 @@ main (int argc, char **argv)
{0, 0, 0, 0}
};
c = getopt_long (argc, argv, "abc:d:0123456789",
long_options, &option_index);
int c = getopt_long (argc, argv, "abc:d:0123456789",
long_options, &option_index);
if (c == -1)
break;

Some files were not shown because too many files have changed in this diff Show more