-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
pdfgrep: Update to 2.1.2 and fix build on <= 10.7
- Loading branch information
1 parent
575a4ff
commit 2c827c6
Showing
2 changed files
with
60 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
The prototype of scandir changed in the 10.8 SDK. Use the old prototype on old SDKs. | ||
https://gitlab.com/pdfgrep/pdfgrep/-/merge_requests/14 | ||
--- src/cache.cc.orig 2018-11-19 05:44:28.000000000 -0600 | ||
+++ src/cache.cc 2021-12-02 18:31:06.000000000 -0600 | ||
@@ -35,6 +35,15 @@ | ||
#include <errno.h> | ||
#include <string.h> | ||
|
||
+#ifdef __APPLE__ | ||
+#include <AvailabilityMacros.h> | ||
+#endif | ||
+ | ||
+#define HAVE_NEW_SCANDIR | ||
+#if (defined(MAC_OS_X_VERSION_MAX_ALLOWED) && MAC_OS_X_VERSION_MAX_ALLOWED < 1080) | ||
+#undef HAVE_NEW_SCANDIR | ||
+#endif | ||
+ | ||
using namespace std; | ||
|
||
Cache::Cache(string cache_file) | ||
@@ -86,9 +95,13 @@ | ||
|
||
// I feel so bad... | ||
static const char *cache_directory; | ||
-static int agesort(const struct dirent ** a, const struct dirent **b) { | ||
- std::string A = string(cache_directory) + "/" + (*a)->d_name; | ||
- std::string B = string(cache_directory) + "/" + (*b)->d_name; | ||
+#ifdef HAVE_NEW_SCANDIR | ||
+static int agesort(const struct dirent **a, const struct dirent **b) { | ||
+#else | ||
+static int agesort(const void *a, const void *b) { | ||
+#endif | ||
+ std::string A = string(cache_directory) + "/" + (*(const struct dirent **)a)->d_name; | ||
+ std::string B = string(cache_directory) + "/" + (*(const struct dirent **)b)->d_name; | ||
|
||
struct stat bufa, bufb; | ||
if (stat(A.c_str(), &bufa) != 0) return 0; | ||
@@ -97,7 +110,11 @@ | ||
return bufb.st_mtime - bufa.st_mtime; | ||
} | ||
|
||
-static int agefilter(const struct dirent * a) { | ||
+#ifdef HAVE_NEW_SCANDIR | ||
+static int agefilter(const struct dirent *a) { | ||
+#else | ||
+static int agefilter(struct dirent *a) { | ||
+#endif | ||
if (a->d_name[0] == '.') return false; | ||
std::string A = string(cache_directory) + "/" + a->d_name; | ||
struct stat bufa; |