Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 29 additions & 4 deletions src/psl.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,16 @@
# define GCC_VERSION_AT_LEAST(major, minor) 0
#endif

/* Must be defined before <sys/stat.h> */
#if defined(_MSC_VER) || defined(__MINGW32__)
# define USE_WIN32_LARGE_FILES
# ifdef __MINGW32__
# ifndef _FILE_OFFSET_BITS
# define _FILE_OFFSET_BITS 64
# endif
# endif
#endif

#include <sys/types.h>
#include <sys/stat.h>

Expand All @@ -48,6 +58,21 @@
# include <windows.h> /* for GetACP() */
#endif

#if defined(_WIN32)
# ifdef USE_WIN32_LARGE_FILES
# define struct_stat struct _stati64
# define func_sys_stat _stati64
# else
# define struct_stat struct _stat
# define func_sys_stat _stat
# endif
#endif

#ifndef struct_stat
# define struct_stat struct stat
# define func_sys_stat stat
#endif

#if defined(_MSC_VER) && ! defined(ssize_t)
# include <basetsd.h>
typedef SSIZE_T ssize_t;
Expand Down Expand Up @@ -1512,9 +1537,9 @@ const char *psl_builtin_filename(void)
*/
int psl_builtin_outdated(void)
{
struct stat st;
struct_stat st;

if (stat(_psl_filename, &st) == 0 && st.st_mtime > _psl_file_time)
if (func_sys_stat(_psl_filename, &st) == 0 && st.st_mtime > _psl_file_time)
return 1;

return 0;
Expand Down Expand Up @@ -1983,10 +2008,10 @@ psl_error_t psl_str_to_utf8lower(const char *str, const char *encoding, const ch
/* if file is newer than the builtin data, insert it reverse sorted by mtime */
static int insert_file(const char *fname, const char **psl_fname, time_t *psl_mtime, int n)
{
struct stat st;
struct_stat st;
int it;

if (fname && *fname && stat(fname, &st) == 0 && st.st_mtime > _psl_file_time) {
if (fname && *fname && func_sys_stat(fname, &st) == 0 && st.st_mtime > _psl_file_time) {
/* add file name and mtime to end of array */
psl_fname[n] = fname;
psl_mtime[n++] = st.st_mtime;
Expand Down
Loading