about summary refs log tree commit diff
path: root/libio/iofwrite_u.c
diff options
context:
space:
mode:
Diffstat (limited to 'libio/iofwrite_u.c')
-rw-r--r--libio/iofwrite_u.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/libio/iofwrite_u.c b/libio/iofwrite_u.c
index 38d1bd08a3..acb5b2f527 100644
--- a/libio/iofwrite_u.c
+++ b/libio/iofwrite_u.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1993, 1996, 1997, 1998 Free Software Foundation, Inc.
+/* Copyright (C) 1993, 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
    This file is part of the GNU IO Library.
 
    This library is free software; you can redistribute it and/or
@@ -36,15 +36,18 @@ fwrite_unlocked (buf, size, count, fp)
      _IO_FILE *fp;
 {
   _IO_size_t request = size * count;
-  _IO_size_t written;
+  _IO_size_t written = 0;
   CHECK_FILE (fp, 0);
   /* Many traditional implementations return 0 if size==0 && count > 0,
      but ANSI requires us to return count in this case. */
   if (request == 0)
     return count;
-  written = _IO_sputn (fp, (const char *) buf, request);
-  if (written == request)
-    return count;
-  else
-    return written / size;
+  if (_IO_fwide (fp, -1) == -1)
+    {
+      written = _IO_sputn (fp, (const char *) buf, request);
+      if (written == request)
+	return count;
+    }
+
+  return written / size;
 }