X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=gettext-tools%2Flibgettextpo%2Fopen.c;h=a0c43eadf9745f686ec74231e8379715fa504080;hb=5d61132f836323aaf2879e04abc9d4056db248a2;hp=f612b802d2185505b2aa19cc72290ab790190cba;hpb=90a3363ce7c017439e9953fd5e832fbef8db0dd5;p=platform%2Fupstream%2Fgettext.git diff --git a/gettext-tools/libgettextpo/open.c b/gettext-tools/libgettextpo/open.c index f612b80..a0c43ea 100644 --- a/gettext-tools/libgettextpo/open.c +++ b/gettext-tools/libgettextpo/open.c @@ -1,5 +1,5 @@ /* Open a descriptor to a file. - Copyright (C) 2007-2010 Free Software Foundation, Inc. + Copyright (C) 2007-2013 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 @@ -16,22 +16,27 @@ /* Written by Bruno Haible , 2007. */ +/* If the user's config.h happens to include , let it include only + the system's here, so that orig_open doesn't recurse to + rpl_open. */ +#define __need_system_fcntl_h #include /* Get the original definition of open. It might be defined as a macro. */ -#define __need_system_fcntl_h #include -#undef __need_system_fcntl_h #include +#undef __need_system_fcntl_h -static inline int +static int orig_open (const char *filename, int flags, mode_t mode) { return open (filename, flags, mode); } /* Specification. */ -#include +/* Write "fcntl.h" here, not , otherwise OSF/1 5.1 DTK cc eliminates + this include because of the preliminary #include above. */ +#include "fcntl.h" #include #include @@ -63,6 +68,15 @@ open (const char *filename, int flags, ...) va_end (arg); } +#if GNULIB_defined_O_NONBLOCK + /* The only known platform that lacks O_NONBLOCK is mingw, but it + also lacks named pipes and Unix sockets, which are the only two + file types that require non-blocking handling in open(). + Therefore, it is safe to ignore O_NONBLOCK here. It is handy + that mingw also lacks openat(), so that is also covered here. */ + flags &= ~O_NONBLOCK; +#endif + #if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ if (strcmp (filename, "/dev/null") == 0) filename = "NUL"; @@ -111,7 +125,8 @@ open (const char *filename, int flags, ...) override fstat() in fchdir.c to hide the fact that we have a dummy. */ if (REPLACE_OPEN_DIRECTORY && fd < 0 && errno == EACCES - && (flags & O_ACCMODE) == O_RDONLY) + && ((flags & O_ACCMODE) == O_RDONLY + || (O_SEARCH != O_RDONLY && (flags & O_ACCMODE) == O_SEARCH))) { struct stat statbuf; if (stat (filename, &statbuf) == 0 && S_ISDIR (statbuf.st_mode))