~ubuntu-branches/ubuntu/trusty/gnutls26/trusty-security

« back to all changes in this revision

Viewing changes to lib/gl/stdio-write.c

  • Committer: Bazaar Package Importer
  • Author(s): Andreas Metzler
  • Date: 2010-04-22 19:29:52 UTC
  • mto: (12.4.3 experimental) (1.5.1)
  • mto: This revision was merged to the branch mainline in revision 26.
  • Revision ID: james.westby@ubuntu.com-20100422192952-gbj6cvaan8e4ejck
Tags: upstream-2.9.10
ImportĀ upstreamĀ versionĀ 2.9.10

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* POSIX compatible FILE stream write function.
2
 
   Copyright (C) 2008-2009 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 */