~ubuntu-branches/ubuntu/quantal/gnutls26/quantal

« back to all changes in this revision

Viewing changes to gl/stdio-write.c

  • Committer: Bazaar Package Importer
  • Author(s): Steve Langasek
  • Date: 2011-05-20 13:07:18 UTC
  • mfrom: (12.1.11 sid)
  • Revision ID: james.westby@ubuntu.com-20110520130718-db41dybbanzfvlji
Tags: 2.10.5-1ubuntu1
* Merge from Debian unstable, remaining changes:
  - Fix build failure with --no-add-needed.
  - Build for multiarch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
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
3
   Written by Bruno Haible <bruno@clisp.org>, 2008.
4
4
 
5
5
   This program is free software: you can redistribute it and/or modify
39
39
#  include <windows.h>
40
40
 
41
41
#  define CALL_WITH_SIGPIPE_EMULATION(RETTYPE, EXPRESSION, FAILED) \
42
 
  if (ferror (stream))                                                        \
43
 
    return (EXPRESSION);                                                      \
44
 
  else                                                                        \
45
 
    {                                                                         \
46
 
      RETTYPE ret;                                                            \
47
 
      SetLastError (0);                                                       \
48
 
      ret = (EXPRESSION);                                                     \
 
42
  if (ferror (stream))                                                        \
 
43
    return (EXPRESSION);                                                      \
 
44
  else                                                                        \
 
45
    {                                                                         \
 
46
      RETTYPE ret;                                                            \
 
47
      SetLastError (0);                                                       \
 
48
      ret = (EXPRESSION);                                                     \
49
49
      if (FAILED && GetLastError () == ERROR_NO_DATA && ferror (stream))      \
50
 
        {                                                                     \
51
 
          int fd = fileno (stream);                                           \
52
 
          if (fd >= 0                                                         \
53
 
              && GetFileType ((HANDLE) _get_osfhandle (fd)) == FILE_TYPE_PIPE)\
54
 
            {                                                                 \
55
 
              /* Try to raise signal SIGPIPE.  */                             \
56
 
              raise (SIGPIPE);                                                \
57
 
              /* If it is currently blocked or ignored, change errno from     \
58
 
                 EINVAL to EPIPE.  */                                         \
59
 
              errno = EPIPE;                                                  \
60
 
            }                                                                 \
61
 
        }                                                                     \
62
 
      return ret;                                                             \
 
50
        {                                                                     \
 
51
          int fd = fileno (stream);                                           \
 
52
          if (fd >= 0                                                         \
 
53
              && GetFileType ((HANDLE) _get_osfhandle (fd)) == FILE_TYPE_PIPE)\
 
54
            {                                                                 \
 
55
              /* Try to raise signal SIGPIPE.  */                             \
 
56
              raise (SIGPIPE);                                                \
 
57
              /* If it is currently blocked or ignored, change errno from     \
 
58
                 EINVAL to EPIPE.  */                                         \
 
59
              errno = EPIPE;                                                  \
 
60
            }                                                                 \
 
61
        }                                                                     \
 
62
      return ret;                                                             \
63
63
    }
64
64
 
65
65
#  if !REPLACE_PRINTF_POSIX /* avoid collision with printf.c */
92
92
}
93
93
#  endif
94
94
 
95
 
#  if !REPLACE_VFPRINTF_POSIX /* avoid collision with vprintf.c */
 
95
#  if !REPLACE_VPRINTF_POSIX /* avoid collision with vprintf.c */
96
96
int
97
97
vprintf (const char *format, va_list args)
98
98
{
100
100
}
101
101
#  endif
102
102
 
103
 
#  if !REPLACE_VPRINTF_POSIX /* avoid collision with vfprintf.c */
 
103
#  if !REPLACE_VFPRINTF_POSIX /* avoid collision with vfprintf.c */
104
104
int
105
105
vfprintf (FILE *stream, const char *format, va_list args)
106
106
#undef vfprintf