]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
tests: fix test failure on FreeBSD 12
authorBruno Haible <bruno@clisp.org>
Sat, 29 Feb 2020 21:33:04 +0000 (22:33 +0100)
committerPádraig Brady <P@draigBrady.com>
Sat, 29 Feb 2020 22:39:47 +0000 (22:39 +0000)
* tests/misc/csplit-io-err.sh: Limit the effect of the fwrite
override to streams != stderr, as fwrite is in the error() path there.

tests/misc/csplit-io-err.sh

index 683a9e4f8fc651785147ed27f446a3f8d581bd5f..f1e622901097e68f4690dbba7427bf95d47ce3ab 100755 (executable)
@@ -39,9 +39,23 @@ cat > k.c <<'EOF' || framework_failure_
 size_t
 fwrite (const void *ptr, size_t size, size_t nitems, FILE *stream)
 {
-  fclose (fopen ("preloaded","w")); /* marker for preloaded interception */
-  errno = ENOSPC;
-  return 0;
+  if (stream == stderr)
+    {
+      /* Perform the normal operation of fwrite.  */
+      const char *p = ptr;
+      size_t count = size * nitems;
+      size_t i;
+      for (i = 0; i < count; i++)
+        if (putc ((unsigned char) *p++, stream) == EOF)
+          break;
+      return i / size;
+    }
+  else
+    {
+      fclose (fopen ("preloaded","w")); /* marker for preloaded interception */
+      errno = ENOSPC;
+      return 0;
+    }
 }
 
 size_t