Re: stdio-safer and tmpfile

2006-07-28 Thread Paul Eggert
Eric Blake [EMAIL PROTECTED] writes:

 m4/ChangeLog:
 2006-07-23  Eric Blake  [EMAIL PROTECTED]

   * unistd-safer.m4 (gl_UNISTD_SAFER): Check for missing pipe.

 2006-07-23  Eric Blake  [EMAIL PROTECTED]

   * pipe-safer.c (pipe_safer) [!HAVE_FUNC_PIPE]: Provide fallback to
   avoid compilation warning on mingw.

That looks fine, thanks.




Re: stdio-safer and tmpfile

2006-07-26 Thread Eric Blake
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

According to Eric Blake on 7/23/2006 7:23 AM:
 
 m4/ChangeLog:
 2006-07-23  Eric Blake  [EMAIL PROTECTED]
 
   * unistd-safer.m4 (gl_UNISTD_SAFER): Check for missing pipe.
 
 2006-07-23  Eric Blake  [EMAIL PROTECTED]
 
   * pipe-safer.c (pipe_safer) [!HAVE_FUNC_PIPE]: Provide fallback to
   avoid compilation warning on mingw.

To get a clean compile of m4 on mingw, I checked this in, as well as the
following:

2006-07-26  Eric Blake  [EMAIL PROTECTED]

* mkstemp-safer.c [! HAVE_MKSTEMP]: Add prototype for platforms
like mingw that lack mkstemp.

$ cvs diff lib/mkstemp-safer.c
Index: lib/mkstemp-safer.c
===
RCS file: /sources/gnulib/gnulib/lib/mkstemp-safer.c,v
retrieving revision 1.2
diff -u -p -r1.2 mkstemp-safer.c
- --- lib/mkstemp-safer.c 14 Nov 2005 07:50:32 -  1.2
+++ lib/mkstemp-safer.c 27 Jul 2006 04:30:49 -
@@ -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.  */


- --
Life is short - so eat dessert first!

Eric Blake [EMAIL PROTECTED]
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.2.1 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFEyEHu84KuGfSFAYARAqtZAKDQ+MnNiRHGWDr39dj8smiLA2MTiwCeNK/I
e3YZFWq1Ay3iqaxSUXMvcvs=
=zFfI
-END PGP SIGNATURE-




Re: stdio-safer and tmpfile

2006-07-23 Thread Eric Blake
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

According to Eric Blake on 7/21/2006 9:51 AM:
 
 Okay to install?
 
 ChangeLog:
 2006-07-21  Eric Blake  [EMAIL PROTECTED]
 
   * modules/stdio-safer (Files): Add tmpfile-safer.c.
   (Depends-on): Add binary-io.
 
   * stdio-safer.m4 (gl_STDIO_SAFER): Add tmpfile-safer.c.
 
   * tmpfile-safer.c: New file.
   * stdio-safer.h (tmpfile_safer): Add prototype.
   * stdio--.h (tmpfile): Make safer.

Checked in, with additional documentation in tmpfile_safer that tmpfile is
incompatible with close_stdout.  However, using stdio-safer on mingw
(which lacks pipe, even though it has popen) evokes a compiler warning due
to the unconditional use of pipe within unistd-safer.  Is it okay to add
this followon that neutralizes pipe_safer on platforms lacking pipe?  For
now, this approach is easier than trying to implement pipe using either
Bruno's pipe module or trying to figure out if the Windows API can create
pipes.

m4/ChangeLog:
2006-07-23  Eric Blake  [EMAIL PROTECTED]

* unistd-safer.m4 (gl_UNISTD_SAFER): Check for missing pipe.

2006-07-23  Eric Blake  [EMAIL PROTECTED]

* pipe-safer.c (pipe_safer) [!HAVE_FUNC_PIPE]: Provide fallback to
avoid compilation warning on mingw.

- --
Life is short - so eat dessert first!

Eric Blake [EMAIL PROTECTED]
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.2.1 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFEw3hC84KuGfSFAYARAl5WAKCPEfm51Kut3hdELH/IR29LB2hbNwCcDzOC
e4LjPkaSlwU7ohKLQyZcnBU=
=CNzJ
-END PGP SIGNATURE-
Index: lib/pipe-safer.c
===
RCS file: /sources/gnulib/gnulib/lib/pipe-safer.c,v
retrieving revision 1.2
diff -u -p -r1.2 pipe-safer.c
--- lib/pipe-safer.c19 Sep 2005 17:28:14 -  1.2
+++ lib/pipe-safer.c23 Jul 2006 13:20:58 -
@@ -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 @@ pipe_safer (int fd[2])
   }
 
   return 0;
+#else /* ! HAVE_FUNC_PIPE */
+  errno = ENOSYS;
+  return -1;
+#endif
 }
Index: m4/unistd-safer.m4
===
RCS file: /sources/gnulib/gnulib/m4/unistd-safer.m4,v
retrieving revision 1.7
diff -u -p -r1.7 unistd-safer.m4
--- m4/unistd-safer.m4  23 Sep 2005 04:15:13 -  1.7
+++ m4/unistd-safer.m4  23 Jul 2006 13:20:58 -
@@ -1,11 +1,12 @@
-#serial 7
-dnl Copyright (C) 2002, 2005 Free Software Foundation, Inc.
+#serial 8
+dnl Copyright (C) 2002, 2005, 2006 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
 
 AC_DEFUN([gl_UNISTD_SAFER],
 [
+  AC_CHECK_FUNCS_ONCE([pipe])
   AC_LIBSOURCES([dup-safer.c, fd-safer.c, pipe-safer.c, unistd-safer.h, 
unistd--.h])
   AC_LIBOBJ([dup-safer])
   AC_LIBOBJ([fd-safer])