Github messages for voidlinux
 help / color / mirror / Atom feed
* [PR PATCH] musl: backport patch to fix fgetws
@ 2023-08-15 20:35 balejk
  2023-08-17 14:22 ` [PR PATCH] [Updated] " balejk
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: balejk @ 2023-08-15 20:35 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 1231 bytes --]

There is a new pull request by balejk against master on the void-packages repository

https://github.com/balejk/void-packages musl-fgetws
https://github.com/void-linux/void-packages/pull/45617

musl: backport patch to fix fgetws
<!-- Uncomment relevant sections and delete options which are not applicable -->

#### Testing the changes
- I tested the changes in this PR: **briefly**

<!--
#### New package
- This new package conforms to the [package requirements](https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#package-requirements): **YES**|**NO**
-->

<!-- Note: If the build is likely to take more than 2 hours, please add ci skip tag as described in
https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#continuous-integration
and test at least one native build and, if supported, at least one cross build.
Ignore this section if this PR is not skipping CI.
-->
#### Local build testing
- I built this PR locally for my native architecture, (x86_64-musl)
<!--
- I built this PR locally for these architectures (if supported. mark crossbuilds):
  - aarch64-musl
  - armv7l
  - armv6l-musl
-->


A patch file from https://github.com/void-linux/void-packages/pull/45617.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-musl-fgetws-45617.patch --]
[-- Type: text/x-diff, Size: 2992 bytes --]

From 3f0d038d68e6418a5329eb504479f00225f88e61 Mon Sep 17 00:00:00 2001
From: Karel Balej <balejk@matfyz.cz>
Date: Tue, 15 Aug 2023 22:21:18 +0200
Subject: [PATCH] musl: backport patch to fix fgetws

---
 srcpkgs/musl/patches/fgetws.patch | 55 +++++++++++++++++++++++++++++++
 srcpkgs/musl/template             |  2 +-
 2 files changed, 56 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/musl/patches/fgetws.patch

diff --git a/srcpkgs/musl/patches/fgetws.patch b/srcpkgs/musl/patches/fgetws.patch
new file mode 100644
index 0000000000000..86354f918a5ca
--- /dev/null
+++ b/srcpkgs/musl/patches/fgetws.patch
@@ -0,0 +1,55 @@
+commit f8bdc3048216f41eaaf655524fa286cfb1184a70
+Author: Rich Felker <dalias@aerifal.cx>
+Date:   Sun Feb 20 20:11:14 2022 -0500
+
+    fix spurious failures by fgetws when buffer ends with partial character
+    
+    commit a90d9da1d1b14d81c4f93e1a6d1a686c3312e4ba made fgetws look for
+    changes to errno by fgetwc to detect encoding errors, since ISO C did
+    not allow the implementation to set the stream's error flag in this
+    case, and the fgetwc interface did not admit any other way to detect
+    the error. however, the possibility of fgetwc setting errno to EILSEQ
+    in the success path was overlooked, and in fact this can happen if the
+    buffer ends with a partial character, causing mbtowc to be called with
+    only part of the character available.
+    
+    since that change was made, the C standard was amended to specify that
+    fgetwc set the stream error flag on encoding errors, and commit
+    511d70738bce11a67219d0132ce725c323d00e4e made it do so. thus, there is
+    no longer any need for fgetws to poke at errno to handle encoding
+    errors.
+    
+    this commit reverts commit a90d9da1d1b14d81c4f93e1a6d1a686c3312e4ba
+    and thereby fixes the problem.
+
+diff --git a/src/stdio/fgetws.c b/src/stdio/fgetws.c
+index b08b3049..195cb435 100644
+--- a/src/stdio/fgetws.c
++++ b/src/stdio/fgetws.c
+@@ -1,6 +1,5 @@
+ #include "stdio_impl.h"
+ #include <wchar.h>
+-#include <errno.h>
+ 
+ wint_t __fgetwc_unlocked(FILE *);
+ 
+@@ -12,10 +11,6 @@ wchar_t *fgetws(wchar_t *restrict s, int n, FILE *restrict f)
+ 
+ 	FLOCK(f);
+ 
+-	/* Setup a dummy errno so we can detect EILSEQ. This is
+-	 * the only way to catch encoding errors in the form of a
+-	 * partial character just before EOF. */
+-	errno = EAGAIN;
+ 	for (; n; n--) {
+ 		wint_t c = __fgetwc_unlocked(f);
+ 		if (c == WEOF) break;
+@@ -23,7 +18,7 @@ wchar_t *fgetws(wchar_t *restrict s, int n, FILE *restrict f)
+ 		if (c == '\n') break;
+ 	}
+ 	*p = 0;
+-	if (ferror(f) || errno==EILSEQ) p = s;
++	if (ferror(f)) p = s;
+ 
+ 	FUNLOCK(f);
+ 
diff --git a/srcpkgs/musl/template b/srcpkgs/musl/template
index e0e05c2df0995..6c98fac0962e9 100644
--- a/srcpkgs/musl/template
+++ b/srcpkgs/musl/template
@@ -2,7 +2,7 @@
 pkgname=musl
 reverts="1.2.0_1"
 version=1.1.24
-revision=17
+revision=18
 archs="*-musl"
 bootstrap=yes
 build_style=gnu-configure

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2024-04-27  1:45 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-15 20:35 [PR PATCH] musl: backport patch to fix fgetws balejk
2023-08-17 14:22 ` [PR PATCH] [Updated] " balejk
2023-08-30 17:36 ` balejk
2023-09-10 10:52 ` balejk
2023-12-10  1:48 ` github-actions
2023-12-15 20:31 ` balejk
2024-01-13 17:37 ` [PR PATCH] [Updated] " balejk
2024-04-13  1:39 ` github-actions
2024-04-27  1:45 ` [PR PATCH] [Closed]: " github-actions

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).