SHA256
1
0
forked from pool/coreutils
Ana Guerrero 2024-07-12 15:04:18 +00:00 committed by Git OBS Bridge
commit 9740f8f158
2 changed files with 25 additions and 15 deletions

View File

@ -1541,12 +1541,13 @@ Index: coreutils-9.5/src/fold.c
- saved_errno = errno; - saved_errno = errno;
+ *saved_errno = errno; + *saved_errno = errno;
+ if (!ferror (istream)) if (!ferror (istream))
- saved_errno = 0;
+ *saved_errno = 0; + *saved_errno = 0;
+
+ if (offset_out) if (offset_out)
+ fwrite (line_out, sizeof (char), (size_t) offset_out, stdout); fwrite (line_out, sizeof (char), (size_t) offset_out, stdout);
+
+} +}
+ +
+#if HAVE_MBRTOWC +#if HAVE_MBRTOWC
@ -1718,19 +1719,18 @@ Index: coreutils-9.5/src/fold.c
+ } + }
+ +
+ *saved_errno = errno; + *saved_errno = errno;
if (!ferror (istream)) + if (!ferror (istream))
- saved_errno = 0;
+ *saved_errno = 0; + *saved_errno = 0;
+
if (offset_out) + if (offset_out)
fwrite (line_out, sizeof (char), (size_t) offset_out, stdout); + fwrite (line_out, sizeof (char), (size_t) offset_out, stdout);
+
+} +}
+#endif +#endif
+ +
+/* Fold file FILENAME, or standard input if FILENAME is "-", +/* Fold file FILENAME, or standard input if FILENAME is "-",
+ to stdout, with maximum line length WIDTH. + to stdout, with maximum line length WIDTH.
+ Return 0 if successful, 1 if an error occurs. */ + Return true if successful. */
+ +
+static bool +static bool
+fold_file (char const *filename, size_t width) +fold_file (char const *filename, size_t width)
@ -1741,15 +1741,15 @@ Index: coreutils-9.5/src/fold.c
+ if (STREQ (filename, "-")) + if (STREQ (filename, "-"))
+ { + {
+ istream = stdin; + istream = stdin;
+ have_read_stdin = 1; + have_read_stdin = true;
+ } + }
+ else + else
+ istream = fopen (filename, "r"); + istream = fopen (filename, "r");
+ +
+ if (istream == NULL) + if (istream == nullptr)
+ { + {
+ error (0, errno, "%s", filename); + error (0, errno, "%s", filename);
+ return 1; + return false;
+ } + }
+ +
+ /* Define how ISTREAM is being folded. */ + /* Define how ISTREAM is being folded. */

View File

@ -1,3 +1,13 @@
-------------------------------------------------------------------
Tue Jul 9 20:22:23 UTC 2024 - Bernhard Voelker <mail@bernhard-voelker.de>
- coreutils-i18n.patch: fold(1): fix exit code for non-existent file.
The exit code of fold(1) was zero for non-existent file:
$ fold badfile; echo $?
fold: badfile: No such file or directory
0
The bug was introduced by the downstrean I18N patch. (rhbz#2296201)
------------------------------------------------------------------- -------------------------------------------------------------------
Mon Apr 1 18:07:16 UTC 2024 - Bernhard Voelker <mail@bernhard-voelker.de> Mon Apr 1 18:07:16 UTC 2024 - Bernhard Voelker <mail@bernhard-voelker.de>