Instead of putting back that comment about the bug,
how about fixing the bug?  Something like the following.

Or perhaps a fix should be put into stdio.in.h so that
all gnulib programs can assume glibc behavior here,
for fwrite?  Though this would mean using an extern
function, something that caused trouble with libvirt...

diff --git a/lib/strftime.c b/lib/strftime.c
index 213ced8..b27b739 100644
--- a/lib/strftime.c
+++ b/lib/strftime.c
@@ -208,7 +208,7 @@ extern char *tzname[];
          else if (to_uppcase)                                                 \
            fwrite_uppcase (p, (s), _n);                                       \
          else                                                                 \
-           fwrite (s, _n, 1, p);                                              \
+           fwrite_asis (p, s, _n);                                            \
        }                                                                      \
      while (0)                                                                \
     )
@@ -306,6 +306,23 @@ fwrite_uppcase (FILE *fp, const CHAR_T *src, size_t len)
       ++src;
     }
 }
+
+static void
+fwrite_asis (FILE *fp, const CHAR_T *src, size_t len)
+{
+  /* POSIX and ISO C allow fwrite to fail due to ENOMEM *without*
+     setting the stream's error indicator.  Work around the problem
+     by invoking fwrite only on platforms we know are safe.  */
+#ifdef __GLIBC__
+  fwrite (src, len, 1, fp);
+#else
+  while (len-- > 0)
+    {
+      fputc (*src, fp);
+      ++src;
+    }
+#endif
+}
 #else
 static CHAR_T *
 memcpy_lowcase (CHAR_T *dest, const CHAR_T *src,

Reply via email to