Hi Bruno,

Unrelated to the original patch, but something I noticed...

Bruno Haible via Gnulib discussion list <bug-gnulib@gnu.org> writes:

> +#if defined _WIN32 && !defined __CYGWIN__
> +    fd = open ("NUL", O_RDWR);
> +#else
> +    fd = open ("/dev/null", O_RDWR);
> +#endif

Perhaps it is worth adding a macro for this file? I was going to suggest
NULL_DEVICE as a module like ROOT_UID in lib/root-uid.h.

But there is already the following in lib/spawn-pipe.h:

    /* The name of the "always silent" device.  */
    #if defined _WIN32 && ! defined __CYGWIN__
    /* Native Windows API.  */
    # define DEV_NULL "NUL"
    #else
    /* Unix API.  */
    # define DEV_NULL "/dev/null"
    #endif

It would remove the need for some repeated conditionals:

    $ grep -rl '"NUL"' lib/ tests/
    lib/dup2.c
    lib/execute.c
    lib/fopen.c
    lib/freopen.c
    lib/open.c
    lib/spawn-pipe.c
    lib/spawn-pipe.h
    lib/spawni.c
    lib/supersede.c
    tests/test-execute-main.c
    tests/test-isatty.c
    tests/test-supersede.c
    tests/test-fstat.c
    tests/test-lstat.h
    tests/test-stat.h

Collin

Reply via email to