diff options
-rw-r--r-- | auto.def | 10 | ||||
-rw-r--r-- | jim-file.c | 6 | ||||
-rw-r--r-- | jimiocompat.h | 22 |
3 files changed, 31 insertions, 7 deletions
@@ -257,7 +257,7 @@ if {[cc-check-function-in-lib socket socket]} { define-append LDLIBS [get-define lib_socket] } -cc-check-functions ualarm lstat fork system select execvpe +cc-check-functions ualarm fork system select execvpe cc-check-functions geteuid mkstemp isatty cc-check-functions regcomp waitpid sigaction sys_signame sys_siglist isascii cc-check-functions syslog opendir readlink sleep usleep pipe getaddrinfo utimes @@ -301,6 +301,14 @@ cc-with {-includes fcntl.h} { } cc-check-lfs + +if {[get-define _FILE_OFFSET_BITS] != 64 || ![cc-check-functions stat64]} { + # Modern systems and really old systems have plain stat, fstat, lstat + cc-check-functions fstat lstat +} else { + # But perhaps some 32 bit systems still require explicit use of the 64 bit versions + cc-check-functions fstat64 lstat64 +} cc-check-functions fseeko ftello define TCL_LIBRARY [get-define libdir]/jim @@ -700,12 +700,12 @@ static int file_stat(Jim_Interp *interp, Jim_Obj *filename, jim_stat_t *sb) return JIM_OK; } -#ifdef HAVE_LSTAT +#ifdef Jim_LinkStat static int file_lstat(Jim_Interp *interp, Jim_Obj *filename, jim_stat_t *sb) { const char *path = Jim_String(filename); - if (lstat(path, sb) == -1) { + if (Jim_LinkStat(path, sb) == -1) { Jim_SetResultFormatted(interp, "could not read \"%#s\": %s", filename, strerror(errno)); return JIM_ERR; } @@ -870,7 +870,7 @@ static int file_cmd_type(Jim_Interp *interp, int argc, Jim_Obj *const *argv) return JIM_OK; } -#ifdef HAVE_LSTAT +#ifdef Jim_LinkStat static int file_cmd_lstat(Jim_Interp *interp, int argc, Jim_Obj *const *argv) { jim_stat_t sb; diff --git a/jimiocompat.h b/jimiocompat.h index 1f0507e..64aa4ff 100644 --- a/jimiocompat.h +++ b/jimiocompat.h @@ -70,9 +70,25 @@ int Jim_OpenForRead(const char *filename); #define Jim_FileStat _fstat64 #else - typedef struct stat jim_stat_t; - #define Jim_Stat stat - #define Jim_FileStat fstat + #if defined(HAVE_STAT64) + typedef struct stat64 jim_stat_t; + #define Jim_Stat stat64 + #if defined(HAVE_FSTAT64) + #define Jim_FileStat fstat64 + #endif + #if defined(HAVE_LSTAT64) + #define Jim_LinkStat lstat64 + #endif + #else + typedef struct stat jim_stat_t; + #define Jim_Stat stat + #if defined(HAVE_FSTAT) + #define Jim_FileStat fstat + #endif + #if defined(HAVE_LSTAT) + #define Jim_LinkStat lstat + #endif + #endif #if defined(HAVE_UNISTD_H) #include <unistd.h> |