X-Git-Url: http://git.hcoop.net/bpt/guile.git/blobdiff_plain/e42573315bd70d514b92458a7644057cd3ac5757..7f1ea859ee33383db29e38dec5802ee0f21b09bc:/lib/stat.c diff --git a/lib/stat.c b/lib/stat.c index 8502ad2f9..075e79e47 100644 --- a/lib/stat.c +++ b/lib/stat.c @@ -1,5 +1,5 @@ /* Work around platform bugs in stat. - Copyright (C) 2009 Free Software Foundation, Inc. + Copyright (C) 2009-2011 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by @@ -16,10 +16,13 @@ /* written by Eric Blake */ +/* If the user's config.h happens to include , let it include only + the system's here, so that orig_stat doesn't recurse to + rpl_stat. */ +#define __need_system_sys_stat_h #include /* Get the original definition of stat. It might be defined as a macro. */ -#define __need_system_sys_stat_h #include #include #undef __need_system_sys_stat_h @@ -31,12 +34,26 @@ orig_stat (const char *filename, struct stat *buf) } /* Specification. */ -#include +/* Write "sys/stat.h" here, not , otherwise OSF/1 5.1 DTK cc + eliminates this include because of the preliminary #include + above. */ +#include "sys/stat.h" #include #include #include #include +#include "dosname.h" +#include "verify.h" + +#if REPLACE_FUNC_STAT_DIR +# include "pathmax.h" + /* The only known systems where REPLACE_FUNC_STAT_DIR is needed also + have a constant PATH_MAX. */ +# ifndef PATH_MAX +# error "Please port this replacement to your platform" +# endif +#endif /* Store information about NAME into ST. Work around bugs with trailing slashes. Mingw has other bugs (such as st_ino always @@ -55,13 +72,14 @@ rpl_stat (char const *name, struct stat *st) { size_t len = strlen (name); if (ISSLASH (name[len - 1])) - { - errno = ENOTDIR; - return -1; - } + { + errno = ENOTDIR; + return -1; + } } #endif /* REPLACE_FUNC_STAT_FILE */ #if REPLACE_FUNC_STAT_DIR + if (result == -1 && errno == ENOENT) { /* Due to mingw's oddities, there are some directories (like @@ -76,6 +94,7 @@ rpl_stat (char const *name, struct stat *st) char fixed_name[PATH_MAX + 1] = {0}; size_t len = strlen (name); bool check_dir = false; + verify (PATH_MAX <= 4096); if (PATH_MAX <= len) errno = ENAMETOOLONG; else if (len)