summaryrefslogtreecommitdiffstats
path: root/gl/stdio-write.c
diff options
context:
space:
mode:
Diffstat (limited to 'gl/stdio-write.c')
-rw-r--r--gl/stdio-write.c48
1 files changed, 25 insertions, 23 deletions
diff --git a/gl/stdio-write.c b/gl/stdio-write.c
index f1d0fcb..f7da9e4 100644
--- a/gl/stdio-write.c
+++ b/gl/stdio-write.c
@@ -1,5 +1,5 @@
1/* POSIX compatible FILE stream write function. 1/* POSIX compatible FILE stream write function.
2 Copyright (C) 2008 Free Software Foundation, Inc. 2 Copyright (C) 2008-2010 Free Software Foundation, Inc.
3 Written by Bruno Haible <bruno@clisp.org>, 2008. 3 Written by Bruno Haible <bruno@clisp.org>, 2008.
4 4
5 This program is free software: you can redistribute it and/or modify 5 This program is free software: you can redistribute it and/or modify
@@ -39,30 +39,31 @@
39# include <windows.h> 39# include <windows.h>
40 40
41# define CALL_WITH_SIGPIPE_EMULATION(RETTYPE, EXPRESSION, FAILED) \ 41# define CALL_WITH_SIGPIPE_EMULATION(RETTYPE, EXPRESSION, FAILED) \
42 if (ferror (stream)) \ 42 if (ferror (stream)) \
43 return (EXPRESSION); \ 43 return (EXPRESSION); \
44 else \ 44 else \
45 { \ 45 { \
46 RETTYPE ret; \ 46 RETTYPE ret; \
47 SetLastError (0); \ 47 SetLastError (0); \
48 ret = (EXPRESSION); \ 48 ret = (EXPRESSION); \
49 if (FAILED && GetLastError () == ERROR_NO_DATA && ferror (stream)) \ 49 if (FAILED && GetLastError () == ERROR_NO_DATA && ferror (stream)) \
50 { \ 50 { \
51 int fd = fileno (stream); \ 51 int fd = fileno (stream); \
52 if (fd >= 0 \ 52 if (fd >= 0 \
53 && GetFileType ((HANDLE) _get_osfhandle (fd)) == FILE_TYPE_PIPE)\ 53 && GetFileType ((HANDLE) _get_osfhandle (fd)) == FILE_TYPE_PIPE)\
54 { \ 54 { \
55 /* Try to raise signal SIGPIPE. */ \ 55 /* Try to raise signal SIGPIPE. */ \
56 raise (SIGPIPE); \ 56 raise (SIGPIPE); \
57 /* If it is currently blocked or ignored, change errno from \ 57 /* If it is currently blocked or ignored, change errno from \
58 EINVAL to EPIPE. */ \ 58 EINVAL to EPIPE. */ \
59 errno = EPIPE; \ 59 errno = EPIPE; \
60 } \ 60 } \
61 } \ 61 } \
62 return ret; \ 62 return ret; \
63 } 63 }
64 64
65# if !REPLACE_PRINTF_POSIX /* avoid collision with printf.c */ 65# if !REPLACE_PRINTF_POSIX /* avoid collision with printf.c */
66# if !DEPENDS_ON_LIBINTL /* avoid collision with intl/printf.c */
66int 67int
67printf (const char *format, ...) 68printf (const char *format, ...)
68{ 69{
@@ -75,6 +76,7 @@ printf (const char *format, ...)
75 76
76 return retval; 77 return retval;
77} 78}
79# endif
78# endif 80# endif
79 81
80# if !REPLACE_FPRINTF_POSIX /* avoid collision with fprintf.c */ 82# if !REPLACE_FPRINTF_POSIX /* avoid collision with fprintf.c */
@@ -92,7 +94,7 @@ fprintf (FILE *stream, const char *format, ...)
92} 94}
93# endif 95# endif
94 96
95# if !REPLACE_VFPRINTF_POSIX /* avoid collision with vprintf.c */ 97# if !REPLACE_VPRINTF_POSIX /* avoid collision with vprintf.c */
96int 98int
97vprintf (const char *format, va_list args) 99vprintf (const char *format, va_list args)
98{ 100{
@@ -100,7 +102,7 @@ vprintf (const char *format, va_list args)
100} 102}
101# endif 103# endif
102 104
103# if !REPLACE_VPRINTF_POSIX /* avoid collision with vfprintf.c */ 105# if !REPLACE_VFPRINTF_POSIX /* avoid collision with vfprintf.c */
104int 106int
105vfprintf (FILE *stream, const char *format, va_list args) 107vfprintf (FILE *stream, const char *format, va_list args)
106#undef vfprintf 108#undef vfprintf