bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

new modules 'open', 'fopen', 'freopen'


From: Bruno Haible
Subject: new modules 'open', 'fopen', 'freopen'
Date: Sun, 7 Oct 2007 04:50:36 +0200
User-agent: KMail/1.5.4

On mingw, the open(), fopen(), freopen() calls have the problem that they
do not recognize the filename "/dev/null" under some circumstances.

This is a problem because there are Cygwin shell scripts (such as configure
files) which pass filenames like /dev/null to programs. The shell calling
such a program does not know whether it is calling a Cygwin program or a
Woe32/mingw program.

This was reported in
  http://lists.gnu.org/archive/html/bug-gnu-utils/2007-10/msg00010.html

The precise circumstances are not clear to me. When I run, from an rxvt
running the msys /bin/sh,

  $ H:/msys/local/bin/msgfmt.exe --statistics /dev/null

it succeeds. When from this shell, I run "cmd" (the Microsoft command
interpreter), and from there

  H:...> H:/msys/local/bin/msgfmt.exe --statistics /dev/null

it fails:

  H:/msys/local/bin/msgfmt.exe: error while opening "/dev/null" for reading: No 
such file or directory

OTOH, a test program that does open("/dev/null", O_RDONLY) and 
fopen("/dev/null","r"),
when run from the shell in rxvt, gets the results -1 and NULL.

Anyway, the precise circumstances are irrelevant.

The fix is that mingw built programs must recognize "/dev/null" when
accessing files. The native Woe32 name for it is "NUL".

Should the stat() and creat() calls treated the same? Maybe, probably, but
in gettext I don't need this.

Should other Cygwin syntaxes, like "/cygdrive/c/autoexec.bat", be converted
to native Woe32 syntax as well? Maybe. It has not been reported so far.

2007-10-06  Bruno Haible  <address@hidden>

        * modules/open: New file.
        * lib/open.c: New file.
        * m4/open.m4: New file.
        * lib/fchdir.c (open): If the gnulib module 'open' is used, do what
        lib/open.c does.
        * lib/fcntl.in.h (open): Declare also if replaced by the 'open' module.
        * m4/fcntl_h.m4 (gl_FCNTL_MODULE_INDICATOR, gl_FCNTL_H_DEFAULTS): New
        macros.
        (gl_FCNTL_H): Require gl_FCNTL_H_DEFAULTS.
        * modules/fcntl (Makefile.am): Also substitute GNULIB_OPEN and
        REPLACE_OPEN.
        * doc/functions/open.texi: Mention the 'open' module.

http://git.sv.gnu.org/gitweb/?p=gnulib.git;a=commitdiff;h=5e6b92bb993a0e913877c495687556df918d7d86

2007-10-06  Bruno Haible  <address@hidden>

        * modules/fopen: New file.
        * lib/fopen.c: New file.
        * m4/fopen.m4: New file.
        * modules/freopen: New file.
        * lib/freopen.c: New file.
        * m4/freopen.m4: New file.
        * lib/stdio.in.h (fopen, freopen): New declarations.
        * m4/stdio_h.m4 (gl_STDIO_H_DEFAULTS): Initialize also GNULIB_FOPEN,
        GNULIB_FREOPEN, REPLACE_FOPEN, REPLACE_FREOPEN.
        * modules/stdio (Makefile.am): Substitute also GNULIB_FOPEN,
        GNULIB_FREOPEN, REPLACE_FOPEN, REPLACE_FREOPEN.
        * doc/functions/fopen.texi: Mention the 'fopen' module.
        * doc/functions/freopen.texi: Mention the 'freopen' module.

http://git.sv.gnu.org/gitweb/?p=gnulib.git;a=commitdiff;h=86f87b4967587bcac4fae90ee86c6fce24e3a4f3





reply via email to

[Prev in Thread] Current Thread [Next in Thread]