commit:     cd306dc1d9273c423759a74166f9805ac8e8b5dd
Author:     Mike Gilbert <floppym <AT> gentoo <DOT> org>
AuthorDate: Wed Oct 15 19:10:49 2025 +0000
Commit:     Mike Gilbert <floppym <AT> gentoo <DOT> org>
CommitDate: Wed Oct 15 19:10:49 2025 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=cd306dc1

app-shells/zsh: update fpurge patch

Bug: https://bugs.gentoo.org/963567
Signed-off-by: Mike Gilbert <floppym <AT> gentoo.org>

 ....3-Use-__fpurge-when-fpurge-is-undeclared.patch | 116 ---------------------
 app-shells/zsh/files/zsh-5.9.0.3-musl-fpurge.patch |  53 ++++++++++
 ...zsh-5.9.0.3-r1.ebuild => zsh-5.9.0.3-r2.ebuild} |   3 +-
 3 files changed, 54 insertions(+), 118 deletions(-)

diff --git 
a/app-shells/zsh/files/zsh-5.9.0.3-Use-__fpurge-when-fpurge-is-undeclared.patch 
b/app-shells/zsh/files/zsh-5.9.0.3-Use-__fpurge-when-fpurge-is-undeclared.patch
deleted file mode 100644
index cc00cc9a5684..000000000000
--- 
a/app-shells/zsh/files/zsh-5.9.0.3-Use-__fpurge-when-fpurge-is-undeclared.patch
+++ /dev/null
@@ -1,116 +0,0 @@
-From 0f573edc898fd00de3cf6e3271a6ea6cdd4ff8f8 Mon Sep 17 00:00:00 2001
-From: Mike Gilbert <[email protected]>
-Date: Tue, 30 Sep 2025 12:37:33 -0400
-Subject: [PATCH] Use __fpurge when fpurge is undeclared
-
-glibc neither declares nor defines fpurge(). Instead, it provides an
-equivalent function __fpurge() in stdio_ext.h.
-
-musl defines fpurge as an alias for __fpurge, but does not declare the
-former in stdio.h.
-
-Checking for the fpurge symbol breaks building on musl since the
-function is not declared in headers. Check for the declaration instead.
-
-Bug: https://bugs.gentoo.org/963567
----
- Src/utils.c      | 23 ++++++++++++++++-------
- Src/zsh_system.h |  3 +++
- configure.ac     |  6 +++++-
- 3 files changed, 24 insertions(+), 8 deletions(-)
-
-diff --git a/Src/utils.c b/Src/utils.c
-index 4ea7b8e93..332d5db66 100644
---- a/Src/utils.c
-+++ b/Src/utils.c
-@@ -2011,6 +2011,17 @@ movefd(int fd)
-     return fd;
- }
- 
-+static void
-+invoke_fpurge(FILE *fp)
-+{
-+#if HAVE_DECL_FPURGE
-+    fpurge(fp);
-+#elif HAVE_DECL___FPURGE
-+    /* glibc and musl do not declare fpurge, use __fpurge instead */
-+    __fpurge(fp);
-+#endif
-+}
-+
- /*
-  * Move fd x to y.  If x == -1, fd y is closed.
-  * Returns y for success, -1 for failure.
-@@ -2022,7 +2033,6 @@ redup(int x, int y)
- {
-     int ret = y;
- 
--#ifdef HAVE_FPURGE
-     /* Make sure buffers are cleared when changing descriptor for a
-      * FILE object.  No fflush() here because the only way anything
-      * can legitimately be left in the buffer is when an error has
-@@ -2030,18 +2040,17 @@ redup(int x, int y)
-      * and at worst squirt out something unexpected.
-      */
-     if (stdout && y == fileno(stdout))
--      fpurge(stdout);
-+      invoke_fpurge(stdout);
-     if (stderr && y == fileno(stderr))
--      fpurge(stderr);
-+      invoke_fpurge(stderr);
-     if (shout && y == fileno(shout))
--      fpurge(shout);
-+      invoke_fpurge(shout);
-     if (xtrerr && y == fileno(xtrerr))
--      fpurge(xtrerr);
-+      invoke_fpurge(xtrerr);
- #ifndef _IONBF
-     /* See init.c setupshin() -- stdin otherwise unbuffered */
-     if (stdin && y == fileno(stdin))
--      fpurge(stdin);
--#endif
-+      invoke_fpurge(stdin);
- #endif
- 
-     if(x < 0)
-diff --git a/Src/zsh_system.h b/Src/zsh_system.h
-index 21446a9b1..2b9e9deee 100644
---- a/Src/zsh_system.h
-+++ b/Src/zsh_system.h
-@@ -136,6 +136,9 @@ char *alloca (size_t);
- #endif
- 
- #include <stdio.h>
-+#ifdef HAVE_STDIO_EXT_H
-+# include <stdio_ext.h>
-+#endif
- #include <ctype.h>
- #include <sys/stat.h>
- #include <signal.h>
-diff --git a/configure.ac b/configure.ac
-index 13895bb1d..8d9198a4d 100644
---- a/configure.ac
-+++ b/configure.ac
-@@ -1250,7 +1250,7 @@ AC_CHECK_FUNCS(strftime strptime mktime timelocal \
-              select poll \
-              readlink faccessx fchdir ftruncate \
-              fstat lstat lchown fchown fchmod \
--             fpurge fseeko ftello \
-+             fseeko ftello \
-              mkfifo _mktemp mkstemp \
-              waitpid wait3 \
-              sigqueue \
-@@ -1292,6 +1292,10 @@ AC_CHECK_FUNCS(strftime strptime mktime timelocal \
-              setutxent getutxent endutxent getutent)
- AC_FUNC_STRCOLL
- 
-+AC_CHECK_DECLS([fpurge])
-+AC_CHECK_HEADERS([stdio_ext.h])
-+AC_CHECK_DECLS([__fpurge], , , [#include <stdio_ext.h>])
-+
- # isinf() and isnan() can exist as either functions or macros.
- AH_TEMPLATE([HAVE_ISINF],
-   [Define to 1 if you have the `isinf' macro or function.])
--- 
-2.51.0
-

diff --git a/app-shells/zsh/files/zsh-5.9.0.3-musl-fpurge.patch 
b/app-shells/zsh/files/zsh-5.9.0.3-musl-fpurge.patch
new file mode 100644
index 000000000000..146ff4e0e3e2
--- /dev/null
+++ b/app-shells/zsh/files/zsh-5.9.0.3-musl-fpurge.patch
@@ -0,0 +1,53 @@
+From 31d360646d7c1866a6ca1ee4b452b2c19940d028 Mon Sep 17 00:00:00 2001
+From: Mike Gilbert <[email protected]>
+Date: Wed, 15 Oct 2025 14:26:43 -0400
+Subject: [PATCH] Check for fpurge declaration
+
+musl libc defines fpurge, but does not declare it in stdio.h.
+It seems to be unnecessary to call fpurge on musl.
+
+Bug: https://bugs.gentoo.org/963567
+---
+ Src/utils.c  | 2 +-
+ configure.ac | 5 ++++-
+ 2 files changed, 5 insertions(+), 2 deletions(-)
+
+diff --git a/Src/utils.c b/Src/utils.c
+index 4ea7b8e93..5e41b712b 100644
+--- a/Src/utils.c
++++ b/Src/utils.c
+@@ -2022,7 +2022,7 @@ redup(int x, int y)
+ {
+     int ret = y;
+ 
+-#ifdef HAVE_FPURGE
++#if HAVE_DECL_FPURGE
+     /* Make sure buffers are cleared when changing descriptor for a
+      * FILE object.  No fflush() here because the only way anything
+      * can legitimately be left in the buffer is when an error has
+diff --git a/configure.ac b/configure.ac
+index 13895bb1d..1f035bc0d 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -1250,7 +1250,7 @@ AC_CHECK_FUNCS(strftime strptime mktime timelocal \
+              select poll \
+              readlink faccessx fchdir ftruncate \
+              fstat lstat lchown fchown fchmod \
+-             fpurge fseeko ftello \
++             fseeko ftello \
+              mkfifo _mktemp mkstemp \
+              waitpid wait3 \
+              sigqueue \
+@@ -1292,6 +1292,9 @@ AC_CHECK_FUNCS(strftime strptime mktime timelocal \
+              setutxent getutxent endutxent getutent)
+ AC_FUNC_STRCOLL
+ 
++# fpurge exists on musl, but is undeclared in stdio.h and isn't actually 
required
++AC_CHECK_DECLS([fpurge])
++
+ # isinf() and isnan() can exist as either functions or macros.
+ AH_TEMPLATE([HAVE_ISINF],
+   [Define to 1 if you have the `isinf' macro or function.])
+-- 
+2.51.0
+

diff --git a/app-shells/zsh/zsh-5.9.0.3-r1.ebuild 
b/app-shells/zsh/zsh-5.9.0.3-r2.ebuild
similarity index 98%
rename from app-shells/zsh/zsh-5.9.0.3-r1.ebuild
rename to app-shells/zsh/zsh-5.9.0.3-r2.ebuild
index c48727c58008..1f886446bd72 100644
--- a/app-shells/zsh/zsh-5.9.0.3-r1.ebuild
+++ b/app-shells/zsh/zsh-5.9.0.3-r2.ebuild
@@ -55,8 +55,7 @@ fi
 PATCHES=(
        # Add openrc specific options for init.d completion
        "${FILESDIR}"/${PN}-5.3-init.d-gentoo.diff
-
-       "${FILESDIR}"/zsh-5.9.0.3-Use-__fpurge-when-fpurge-is-undeclared.patch
+       "${FILESDIR}"/zsh-5.9.0.3-musl-fpurge.patch
 )
 
 src_prepare() {

Reply via email to