changeset 7052:9c66c4fabeaf

* mkstemp-safer.c [! HAVE_MKSTEMP]: Add prototype for platforms like mingw that lack mkstemp. * pipe-safer.c (pipe_safer) [!HAVE_FUNC_PIPE]: Provide fallback to avoid compilation warning on mingw.
author Eric Blake <ebb9@byu.net>
date Thu, 27 Jul 2006 04:34:16 +0000
parents 9f1099d5f664
children 8a261680f8ca
files lib/ChangeLog lib/mkstemp-safer.c lib/pipe-safer.c
diffstat 3 files changed, 22 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/lib/ChangeLog
+++ b/lib/ChangeLog
@@ -1,3 +1,11 @@
+2006-07-26  Eric Blake  <ebb9@byu.net>
+
+	* mkstemp-safer.c [! HAVE_MKSTEMP]: Add prototype for platforms
+	like mingw that lack mkstemp.
+	* pipe-safer.c (pipe_safer) [!HAVE_FUNC_PIPE]: Provide fallback to
+	avoid compilation warning on mingw.
+
+
 2006-07-25  Bruno Haible  <bruno@clisp.org>
 
 	* version-etc.c (version_etc_va): Use va_copy, assumed to be defined in
--- a/lib/mkstemp-safer.c
+++ b/lib/mkstemp-safer.c
@@ -1,6 +1,6 @@
 /* Invoke mkstemp, but avoid some glitches.
 
-   Copyright (C) 2005 Free Software Foundation, Inc.
+   Copyright (C) 2005, 2006 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
@@ -27,6 +27,10 @@
 #include <stdlib.h>
 #include "unistd-safer.h"
 
+#if ! HAVE_MKSTEMP
+int mkstemp (char *)
+#endif
+
 /* Like mkstemp, but do not return STDIN_FILENO, STDOUT_FILENO, or
    STDERR_FILENO.  */
 
--- a/lib/pipe-safer.c
+++ b/lib/pipe-safer.c
@@ -1,5 +1,5 @@
 /* Invoke pipe, but avoid some glitches.
-   Copyright (C) 2005 Free Software Foundation, Inc.
+   Copyright (C) 2005, 2006 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
@@ -24,13 +24,16 @@
 #include "unistd-safer.h"
 
 #include <unistd.h>
+#include <errno.h>
 
 /* Like pipe, but ensure that neither of the file descriptors is
-   STDIN_FILENO, STDOUT_FILENO, or STDERR_FILENO.  */
+   STDIN_FILENO, STDOUT_FILENO, or STDERR_FILENO.  Fail with ENOSYS on
+   platforms that lack pipe.  */
 
 int
 pipe_safer (int fd[2])
 {
+#if HAVE_FUNC_PIPE
   int fail = pipe (fd);
   if (fail)
     return fail;
@@ -47,4 +50,8 @@
   }
 
   return 0;
+#else /* ! HAVE_FUNC_PIPE */
+  errno = ENOSYS;
+  return -1;
+#endif
 }