diff options
author | A. Wilcox <AWilcox@Wilcox-Tech.com> | 2024-05-30 20:20:51 -0500 |
---|---|---|
committer | A. Wilcox <AWilcox@Wilcox-Tech.com> | 2024-08-07 10:08:18 -0500 |
commit | ffded033eb67c0027d650c0a2a0ebaa58f53c94f (patch) | |
tree | b8db4bca8f3217947b30e7aff5fcd65566dbae9d | |
parent | 4bdc6432893e9ea94a651c61b456c4ad8e063d78 (diff) | |
download | packages-ffded033eb67c0027d650c0a2a0ebaa58f53c94f.tar.gz packages-ffded033eb67c0027d650c0a2a0ebaa58f53c94f.tar.bz2 packages-ffded033eb67c0027d650c0a2a0ebaa58f53c94f.tar.xz packages-ffded033eb67c0027d650c0a2a0ebaa58f53c94f.zip |
user/the_silver_searcher: Patches
* Fix when reading symlinks to pipes.
* Fix build with newer GCC.
-rw-r--r-- | user/the_silver_searcher/APKBUILD | 14 | ||||
-rw-r--r-- | user/the_silver_searcher/no-common.patch | 207 | ||||
-rw-r--r-- | user/the_silver_searcher/pattern-fix.patch | 78 | ||||
-rw-r--r-- | user/the_silver_searcher/pipe-symlink.patch | 26 |
4 files changed, 321 insertions, 4 deletions
diff --git a/user/the_silver_searcher/APKBUILD b/user/the_silver_searcher/APKBUILD index e906445e6..7c504dc9e 100644 --- a/user/the_silver_searcher/APKBUILD +++ b/user/the_silver_searcher/APKBUILD @@ -2,7 +2,7 @@ # Maintainer: A. Wilcox <awilfox@adelielinux.org> pkgname=the_silver_searcher pkgver=2.2.0 -pkgrel=0 +pkgrel=1 pkgdesc="Tool for very fast searching of text in documents and code" url="https://geoff.greer.fm/ag/" arch="all" @@ -12,8 +12,11 @@ depends="" checkdepends="cram" makedepends="pcre-dev xz-dev zlib-dev" subpackages="$pkgname-doc" -source="https://geoff.greer.fm/ag/releases/the_silver_searcher-$pkgver.tar.gz" -builddir="$srcdir/the_silver_searcher-$pkgver" +source="https://geoff.greer.fm/ag/releases/the_silver_searcher-$pkgver.tar.gz + pipe-symlink.patch + pattern-fix.patch + no-common.patch + " build() { ./configure \ @@ -34,4 +37,7 @@ package() { make DESTDIR="$pkgdir" install } -sha512sums="89d4e4f7f34c0d57aa880e7c3466f0373b961744a89ad30541e89e2d614322ab46c8044ec458406a117f74b0fea14cd3063fa4e0624a96526aa23eaccd6f1141 the_silver_searcher-2.2.0.tar.gz" +sha512sums="89d4e4f7f34c0d57aa880e7c3466f0373b961744a89ad30541e89e2d614322ab46c8044ec458406a117f74b0fea14cd3063fa4e0624a96526aa23eaccd6f1141 the_silver_searcher-2.2.0.tar.gz +4c7af6c22cb01d09070d642c2e1ace969ddbfc60750dba7ffa2f38cb960b68c01ffaa0edbbafe11cbc30805bd8f845bae1ea7863b181e55fc4263b4fe0b95fb4 pipe-symlink.patch +8cce44cc3d1b9732fa616ad34ccca3292dddbc45280c64434aaae5ce5bb14cb9847fb4ff584b3042215d3adef6460c6f74a64f6eabe583fa440d89fc74b39feb pattern-fix.patch +b7d0c96bfd8a9984b0082fac2530826cd3fb5f98ca957c03d628ed7f908f5e27108a18c00813fcb498ec12aa47b82fffc1d48b9d0ffaa5dd36960d7063c09a9e no-common.patch" diff --git a/user/the_silver_searcher/no-common.patch b/user/the_silver_searcher/no-common.patch new file mode 100644 index 000000000..50f1fa6a9 --- /dev/null +++ b/user/the_silver_searcher/no-common.patch @@ -0,0 +1,207 @@ +From 21eaa1c4160b868b0c5bbf59da17974429f30055 Mon Sep 17 00:00:00 2001 +From: Shlomi Fish <shlomif@shlomifish.org> +Date: Wed, 15 Apr 2020 20:23:52 +0300 +Subject: [PATCH] Fix multiple global symbols definitions. + +See the use of extern here: + +* https://www.geeksforgeeks.org/understanding-extern-keyword-in-c/ + +* https://en.wikipedia.org/wiki/External_variable + +* +https://stackoverflow.com/questions/496448/how-to-correctly-use-the-extern-keyword-in-c +--- + src/ignore.c | 2 ++ + src/ignore.h | 2 +- + src/log.c | 1 + + src/log.h | 2 +- + src/options.c | 2 ++ + src/options.h | 2 +- + src/search.c | 13 +++++++++++++ + src/search.h | 20 ++++++++++---------- + src/util.c | 2 ++ + src/util.h | 4 ++-- + 10 files changed, 35 insertions(+), 15 deletions(-) + +diff --git a/src/ignore.c b/src/ignore.c +index 7ae83f3ee..88036eff4 100644 +--- a/src/ignore.c ++++ b/src/ignore.c +@@ -20,6 +20,8 @@ + const int fnmatch_flags = FNM_PATHNAME; + #endif + ++ignores *root_ignores; ++ + /* TODO: build a huge-ass list of files we want to ignore by default (build cache stuff, pyc files, etc) */ + + const char *evil_hardcoded_ignore_files[] = { +diff --git a/src/ignore.h b/src/ignore.h +index 20d5a6af8..8db0f3772 100644 +--- a/src/ignore.h ++++ b/src/ignore.h +@@ -29,7 +29,7 @@ struct ignores { + }; + typedef struct ignores ignores; + +-ignores *root_ignores; ++extern ignores *root_ignores; + + extern const char *evil_hardcoded_ignore_files[]; + extern const char *ignore_pattern_files[]; +diff --git a/src/log.c b/src/log.c +index 1481b6d02..f6f4e9a83 100644 +--- a/src/log.c ++++ b/src/log.c +@@ -4,6 +4,7 @@ + #include "log.h" + #include "util.h" + ++pthread_mutex_t print_mtx = PTHREAD_MUTEX_INITIALIZER; + static enum log_level log_threshold = LOG_LEVEL_ERR; + + void set_log_level(enum log_level threshold) { +diff --git a/src/log.h b/src/log.h +index 85847ee7b..318622c3c 100644 +--- a/src/log.h ++++ b/src/log.h +@@ -9,7 +9,7 @@ + #include <pthread.h> + #endif + +-pthread_mutex_t print_mtx; ++extern pthread_mutex_t print_mtx; + + enum log_level { + LOG_LEVEL_DEBUG = 10, +diff --git a/src/options.c b/src/options.c +index 4abf4dcd3..699530138 100644 +--- a/src/options.c ++++ b/src/options.c +@@ -20,6 +20,8 @@ const char *color_line_number = "\033[1;33m"; /* bold yellow */ + const char *color_match = "\033[30;43m"; /* black with yellow background */ + const char *color_path = "\033[1;32m"; /* bold green */ + ++cli_options opts; ++ + /* TODO: try to obey out_fd? */ + void usage(void) { + printf("\n"); +diff --git a/src/options.h b/src/options.h +index aae930936..0d852167e 100644 +--- a/src/options.h ++++ b/src/options.h +@@ -91,7 +91,7 @@ typedef struct { + } cli_options; + + /* global options. parse_options gives it sane values, everything else reads from it */ +-cli_options opts; ++extern cli_options opts; + + typedef struct option option_t; + +diff --git a/src/search.c b/src/search.c +index 0f4ae2113..0dad3c072 100644 +--- a/src/search.c ++++ b/src/search.c +@@ -2,6 +2,19 @@ + #include "print.h" + #include "scandir.h" + ++size_t alpha_skip_lookup[256]; ++size_t *find_skip_lookup; ++uint8_t h_table[H_SIZE] __attribute__((aligned(64))); ++ ++work_queue_t *work_queue = NULL; ++work_queue_t *work_queue_tail = NULL; ++int done_adding_files = 0; ++pthread_cond_t files_ready = PTHREAD_COND_INITIALIZER; ++pthread_mutex_t stats_mtx = PTHREAD_MUTEX_INITIALIZER; ++pthread_mutex_t work_queue_mtx = PTHREAD_MUTEX_INITIALIZER; ++ ++symdir_t *symhash = NULL; ++ + void search_buf(const char *buf, const size_t buf_len, + const char *dir_full_path) { + int binary = -1; /* 1 = yes, 0 = no, -1 = don't know */ +diff --git a/src/search.h b/src/search.h +index 6bac42038..00aa018dd 100644 +--- a/src/search.h ++++ b/src/search.h +@@ -31,9 +31,9 @@ + #include "uthash.h" + #include "util.h" + +-size_t alpha_skip_lookup[256]; +-size_t *find_skip_lookup; +-uint8_t h_table[H_SIZE] __attribute__((aligned(64))); ++extern size_t alpha_skip_lookup[256]; ++extern size_t *find_skip_lookup; ++extern uint8_t h_table[H_SIZE] __attribute__((aligned(64))); + + struct work_queue_t { + char *path; +@@ -41,12 +41,12 @@ struct work_queue_t { + }; + typedef struct work_queue_t work_queue_t; + +-work_queue_t *work_queue; +-work_queue_t *work_queue_tail; +-int done_adding_files; +-pthread_cond_t files_ready; +-pthread_mutex_t stats_mtx; +-pthread_mutex_t work_queue_mtx; ++extern work_queue_t *work_queue; ++extern work_queue_t *work_queue_tail; ++extern int done_adding_files; ++extern pthread_cond_t files_ready; ++extern pthread_mutex_t stats_mtx; ++extern pthread_mutex_t work_queue_mtx; + + + /* For symlink loop detection */ +@@ -64,7 +64,7 @@ typedef struct { + UT_hash_handle hh; + } symdir_t; + +-symdir_t *symhash; ++extern symdir_t *symhash; + + ssize_t search_buf(const char *buf, const size_t buf_len, + const char *dir_full_path); +diff --git a/src/util.c b/src/util.c +index 3949477b2..90ffb6f1d 100644 +--- a/src/util.c ++++ b/src/util.c +@@ -21,6 +21,8 @@ + } \ + return ptr; + ++FILE *out_fd = NULL; ++ag_stats stats; + void *ag_malloc(size_t size) { + void *ptr = malloc(size); + CHECK_AND_RETURN(ptr) +diff --git a/src/util.h b/src/util.h +index 0c9b9b112..338b05f45 100644 +--- a/src/util.h ++++ b/src/util.h +@@ -12,7 +12,7 @@ + #include "log.h" + #include "options.h" + +-FILE *out_fd; ++extern FILE *out_fd; + + #ifndef TRUE + #define TRUE 1 +@@ -51,7 +51,7 @@ typedef struct { + } ag_stats; + + +-ag_stats stats; ++extern ag_stats stats; + + /* Union to translate between chars and words without violating strict aliasing */ + typedef union { diff --git a/user/the_silver_searcher/pattern-fix.patch b/user/the_silver_searcher/pattern-fix.patch new file mode 100644 index 000000000..6489e2c7c --- /dev/null +++ b/user/the_silver_searcher/pattern-fix.patch @@ -0,0 +1,78 @@ +From 755c6e5c06fc38903fa0d66be68a9c8ffa525c1b Mon Sep 17 00:00:00 2001 +From: Evan Moses <evan@emoses.org> +Date: Thu, 9 Jan 2020 17:34:44 -0800 +Subject: [PATCH] Fix ignore patterns in subdirectories with leading slashes + +Currenetly if you have an ignore file in a subdirectory "sub" with a pattern +like + /ignorethis +The directory sub/ignorethis will be ignored if you run ag from +within sub, but it won't be ignored if you run it from sub's parent. +that is + + $ ag needle + +will search files in sub/ignorethis, but + + $ cd sub + $ ag needle + +Will not. This is a bug +--- + src/ignore.c | 8 ++++++-- + tests/ignore_slash_in_subdir.t | 19 +++++++++++++++++++ + 2 files changed, 25 insertions(+), 2 deletions(-) + create mode 100644 tests/ignore_slash_in_subdir.t + +diff --git a/src/ignore.c b/src/ignore.c +index fa4188919..1d1c07b13 100644 +--- a/src/ignore.c ++++ b/src/ignore.c +@@ -206,6 +206,7 @@ static int ackmate_dir_match(const char *dir_name) { + /* This is the hottest code in Ag. 10-15% of all execution time is spent here */ + static int path_ignore_search(const ignores *ig, const char *path, const char *filename) { + char *temp; ++ int temp_start_pos; + size_t i; + int match_pos; + +@@ -216,9 +217,12 @@ static int path_ignore_search(const ignores *ig, const char *path, const char *f + } + + ag_asprintf(&temp, "%s/%s", path[0] == '.' ? path + 1 : path, filename); ++ //ig->abs_path has its leading slash stripped, so we have to strip the leading slash ++ //of temp as well ++ temp_start_pos = (temp[0] == '/') ? 1 : 0; + +- if (strncmp(temp, ig->abs_path, ig->abs_path_len) == 0) { +- char *slash_filename = temp + ig->abs_path_len; ++ if (strncmp(temp+temp_start_pos, ig->abs_path, ig->abs_path_len) == 0) { ++ char *slash_filename = temp + temp_start_pos + ig->abs_path_len; + if (slash_filename[0] == '/') { + slash_filename++; + } +diff --git a/tests/ignore_slash_in_subdir.t b/tests/ignore_slash_in_subdir.t +new file mode 100644 +index 000000000..167d6ffb4 +--- /dev/null ++++ b/tests/ignore_slash_in_subdir.t +@@ -0,0 +1,19 @@ ++Setup: ++ ++ $ . $TESTDIR/setup.sh ++ $ mkdir -p subdir/ignoredir ++ $ mkdir ignoredir ++ $ printf 'match1\n' > subdir/ignoredir/file1.txt ++ $ printf 'match1\n' > ignoredir/file1.txt ++ $ printf '/ignoredir\n' > subdir/.ignore ++ ++Ignore file in subdir/ignoredir, but not in ignoredir: ++ ++ $ ag match ++ ignoredir/file1.txt:1:match1 ++ ++From subdir, ignore file in subdir/ignoredir: ++ ++ $ cd subdir ++ $ ag match ++ [1] diff --git a/user/the_silver_searcher/pipe-symlink.patch b/user/the_silver_searcher/pipe-symlink.patch new file mode 100644 index 000000000..ee47f9439 --- /dev/null +++ b/user/the_silver_searcher/pipe-symlink.patch @@ -0,0 +1,26 @@ +From 095c3f091e23fda1d9d00bd42c38cf81bba1c14f Mon Sep 17 00:00:00 2001 +From: Jacob Wahlgren <jacob@dstsrc.net> +Date: Wed, 28 Nov 2018 23:35:52 +0100 +Subject: [PATCH] Skip symlinks to named pipes + +The d_type field contains the type as lstat would put it, but when +checking for a named pipe we need the stat behavior. + +Fixes https://github.com/ggreer/the_silver_searcher/issues/1272 +--- + src/util.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/util.c b/src/util.c +index cb23914d3..3949477b2 100644 +--- a/src/util.c ++++ b/src/util.c +@@ -516,7 +516,7 @@ int is_symlink(const char *path, const struct dirent *d) { + + int is_named_pipe(const char *path, const struct dirent *d) { + #ifdef HAVE_DIRENT_DTYPE +- if (d->d_type != DT_UNKNOWN) { ++ if (d->d_type != DT_UNKNOWN && d->d_type != DT_LNK) { + return d->d_type == DT_FIFO || d->d_type == DT_SOCK; + } + #endif |