NEWS.stable: log cherry-pick [e446f25]->[c092018] relocatable-shell: Update suggested...
[gnulib.git] / lib / isapipe.c
index 495cba6..b59e235 100644 (file)
@@ -1,6 +1,6 @@
 /* Test whether a file descriptor is a pipe.
 
-   Copyright (C) 2006, 2008 Free Software Foundation, Inc.
+   Copyright (C) 2006, 2008-2014 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
 #if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
 /* Windows platforms.  */
 
-/* Get _get_osfhandle.  */
-# include <io.h>
-
 /* Get GetFileType.  */
 # include <windows.h>
 
+/* Get _get_osfhandle.  */
+# include "msvc-nothrow.h"
+
 int
 isapipe (int fd)
 {
@@ -87,28 +87,28 @@ isapipe (int fd)
      On Darwin 7.7, pipes are sockets, so check for those instead.  */
 
   if (! ((HAVE_FIFO_PIPES == 0 || HAVE_FIFO_PIPES == 1)
-        && PIPE_LINK_COUNT_MAX != (nlink_t) -1)
+         && PIPE_LINK_COUNT_MAX != (nlink_t) -1)
       && (S_ISFIFO (st.st_mode) | S_ISSOCK (st.st_mode)))
     {
       int fd_pair[2];
       int pipe_result = pipe (fd_pair);
       if (pipe_result != 0)
-       return pipe_result;
+        return pipe_result;
       else
-       {
-         struct stat pipe_st;
-         int fstat_pipe_result = fstat (fd_pair[0], &pipe_st);
-         int fstat_pipe_errno = errno;
-         close (fd_pair[0]);
-         close (fd_pair[1]);
-         if (fstat_pipe_result != 0)
-           {
-             errno = fstat_pipe_errno;
-             return fstat_pipe_result;
-           }
-         check_for_fifo = (S_ISFIFO (pipe_st.st_mode) != 0);
-         pipe_link_count_max = pipe_st.st_nlink;
-       }
+        {
+          struct stat pipe_st;
+          int fstat_pipe_result = fstat (fd_pair[0], &pipe_st);
+          int fstat_pipe_errno = errno;
+          close (fd_pair[0]);
+          close (fd_pair[1]);
+          if (fstat_pipe_result != 0)
+            {
+              errno = fstat_pipe_errno;
+              return fstat_pipe_result;
+            }
+          check_for_fifo = (S_ISFIFO (pipe_st.st_mode) != 0);
+          pipe_link_count_max = pipe_st.st_nlink;
+        }
     }
 
   return