X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=lib%2Fopen.c;h=13af274602661bb5b628c6d225d51ad2f4673007;hb=217969cf220de4c0515eccd614de1640c3f46bcf;hp=9a35f5b2a6add92db03e40da7b7c63a70f0d894a;hpb=e2600ffdcf6c35561545d553e07e52e0db8f9a38;p=gnulib.git diff --git a/lib/open.c b/lib/open.c index 9a35f5b2a..13af27460 100644 --- a/lib/open.c +++ b/lib/open.c @@ -33,14 +33,11 @@ orig_open (const char *filename, int flags, mode_t mode) /* Specification. */ #include -/* If the fchdir replacement is used, open() is defined in fchdir.c. */ -#ifndef FCHDIR_REPLACEMENT - -# include -# include -# include -# include -# include +#include +#include +#include +#include +#include int open (const char *filename, int flags, ...) @@ -64,12 +61,12 @@ open (const char *filename, int flags, ...) va_end (arg); } -# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ +#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ if (strcmp (filename, "/dev/null") == 0) filename = "NUL"; -# endif +#endif -# if OPEN_TRAILING_SLASH_BUG +#if OPEN_TRAILING_SLASH_BUG /* If the filename ends in a slash and one of O_CREAT, O_WRONLY, O_RDWR is specified, then fail. Rationale: POSIX @@ -100,11 +97,11 @@ open (const char *filename, int flags, ...) return -1; } } -# endif +#endif fd = orig_open (filename, flags, mode); -# if OPEN_TRAILING_SLASH_BUG +#if OPEN_TRAILING_SLASH_BUG /* If the filename ends in a slash and fd does not refer to a directory, then fail. Rationale: POSIX @@ -132,8 +129,12 @@ open (const char *filename, int flags, ...) } } } -# endif +#endif + +#ifdef FCHDIR_REPLACEMENT + if (fd >= 0) + _gl_register_fd (fd, filename); +#endif return fd; } -#endif