Changeset 564 for trunk/src/sh_files.c


Ignore:
Timestamp:
Jun 30, 2021, 10:29:32 PM (3 years ago)
Author:
katerina
Message:

Fix for ticket #452 (reproducible database generation).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/sh_files.c

    r543 r564  
    2020#include "config_xor.h"
    2121
    22 #if defined(HAVE_PTHREAD_MUTEX_RECURSIVE)
     22#if defined(HAVE_PTHREAD_MUTEX_RECURSIVE) && defined(HAVE_DIRENT_H) && defined(HAVE_SCANDIR)
     23
     24/* Linux */
     25#if defined(__linux__)
     26#define _XOPEN_SOURCE 700
     27#define SH_USE_SCANDIR 1
     28
     29/* FreeBSD */
     30#elif defined(__FreeBSD__)
     31
     32#if __FreeBSD__ >= 8
     33#define __XSI_VISIBLE 700
     34#define SH_USE_SCANDIR 1
     35#endif
     36
     37/* OpenBSD */
     38#elif defined(__OpenBSD__)
     39#define __POSIX_VISIBLE 200809
     40#define SH_USE_SCANDIR 1
     41
     42#elif defined(__NetBSD__)
     43#define _NETBSD_SOURCE
     44#define SH_USE_SCANDIR 1
     45
     46/* other os */
     47#else
     48#define _XOPEN_SOURCE 500
     49
     50#endif
     51
     52#elif defined(HAVE_PTHREAD_MUTEX_RECURSIVE)
    2353#define _XOPEN_SOURCE 500
    2454#endif
     
    3666#include <sys/types.h>
    3767#include <unistd.h>
    38 #include <sys/types.h>
    3968#include <sys/stat.h>
    4069#include <fcntl.h>
     
    20812110  DIR *           thisDir = NULL;
    20822111  struct dirent * thisEntry;
     2112#if defined(SH_USE_SCANDIR)
     2113  struct dirent **entryList;
     2114  int             entry;
     2115#endif
    20832116  int             status;
    20842117  int             dummy = S_FALSE;
     
    22672300  dirlist_orig = NULL;
    22682301
     2302#if defined(SH_USE_SCANDIR)
     2303  entry = scandir(iname, &entryList, 0, alphasort);
     2304  while(entry > 0) { /* scandir() may return -1 on error! */
     2305      entry--;
     2306      thisEntry = entryList[entry];
     2307#else
    22692308  do {
    22702309      thisEntry = readdir (thisDir);
     2310#endif
    22712311      if (thisEntry != NULL)
    22722312        {
     
    22842324          dirlist = addto_sh_dirlist (thisEntry, dirlist);
    22852325        }
    2286   } while (thisEntry != NULL);
    2287 
     2326  }
     2327#if !defined(SH_USE_SCANDIR) 
     2328  while (thisEntry != NULL);
     2329#endif
     2330 
    22882331  SH_MUTEX_UNLOCK(mutex_readdir);
    22892332
Note: See TracChangeset for help on using the changeset viewer.