Commit: 68ac5f38afff8b682e4e1aa953aab6e712e584ce
Parent: 7420859c76ac53f1693944921719ad11b0bc2830
Author: Randy Palamar
Date: Sun, 15 Oct 2023 08:49:07 -0600
add the_silver_searcher from oasis
Diffstat:
10 files changed, 340 insertions(+), 0 deletions(-)
diff --git a/.gitmodules b/.gitmodules
@@ -20,6 +20,10 @@
[submodule "pkg/devel/samurai/src"]
path = pkg/devel/samurai/src
url = https://github.com/michaelforney/samurai.git
+[submodule "pkg/devel/the_silver_searcher/src"]
+ path = pkg/devel/the_silver_searcher/src
+ url = https://github.com/ggreer/the_silver_searcher.git
+ ignore = all
[submodule "pkg/editors/vis/src"]
path = pkg/editors/vis/src
url = https://github.com/martanne/vis.git
diff --git a/pkg/devel/gen.lua b/pkg/devel/gen.lua
@@ -4,3 +4,4 @@ subgen('linux-headers')
subgen('man-pages-posix')
subgen('samurai')
subgen('strace')
+subgen('the_silver_searcher')
diff --git a/pkg/devel/the_silver_searcher/config.h b/pkg/devel/the_silver_searcher/config.h
@@ -0,0 +1,39 @@
+/* #undef HAVE_DIRENT_DNAMLEN */
+#define HAVE_DIRENT_DTYPE /**/
+#define HAVE_ERR_H 1
+#define HAVE_FGETLN 1
+/* #undef HAVE_FOPENCOOKIE */
+#define HAVE_GETLINE 1
+#define HAVE_INTTYPES_H 1
+/* #undef HAVE_LIBSHLWAPI */
+/* #undef HAVE_LZMA_H */
+#define HAVE_MADVISE 1
+#define HAVE_MEMORY_H 1
+/* #undef HAVE_PLEDGE */
+#define HAVE_POSIX_FADVISE 1
+#define HAVE_PTHREAD_H 1
+#define HAVE_PTHREAD_PRIO_INHERIT 1
+#define HAVE_PTHREAD_SETAFFINITY_NP 1
+#define HAVE_REALPATH 1
+#define HAVE_STDINT_H 1
+#define HAVE_STDLIB_H 1
+#define HAVE_STRINGS_H 1
+#define HAVE_STRING_H 1
+#define HAVE_STRLCPY 1
+#define HAVE_STRNDUP 1
+/* #undef HAVE_SYS_CPUSET_H */
+#define HAVE_SYS_STAT_H 1
+#define HAVE_SYS_TYPES_H 1
+#define HAVE_UNISTD_H 1
+#define HAVE_VASPRINTF 1
+#define HAVE_ZLIB_H 1
+#define PACKAGE_BUGREPORT "https://github.com/ggreer/the_silver_searcher/issues"
+#define PACKAGE_NAME "the_silver_searcher"
+#define PACKAGE_STRING "the_silver_searcher 2.2.0"
+#define PACKAGE_TARNAME "the_silver_searcher"
+#define PACKAGE_URL "https://github.com/ggreer/the_silver_searcher"
+#define PACKAGE_VERSION "2.2.0"
+/* #undef PTHREAD_CREATE_JOINABLE */
+#define STDC_HEADERS 1
+#define USE_CPU_SET /**/
+#define USE_PCRE_JIT /**/
diff --git a/pkg/devel/the_silver_searcher/gen.lua b/pkg/devel/the_silver_searcher/gen.lua
@@ -0,0 +1,24 @@
+cflags{
+ '-D _GNU_SOURCE',
+ '-I $dir',
+ '-isystem $builddir/pkg/libs/pcre/include',
+ '-isystem $builddir/pkg/libs/zlib/include',
+}
+
+pkg.deps = {
+ 'pkg/libs/pcre/headers',
+ 'pkg/libs/zlib/headers',
+}
+
+exe('ag', [[
+ src/(
+ ignore.c log.c options.c print.c print_w32.c scandir.c search.c lang.c
+ util.c decompress.c main.c
+ )
+ $builddir/pkg/libs/pcre/libpcre.a
+ $builddir/pkg/libs/zlib/libz.a
+]])
+file('bin/ag', '755', '$outdir/ag')
+man({'doc/ag.1'})
+
+fetch('git')
diff --git a/pkg/devel/the_silver_searcher/patch/0001-Remove-after-function-definition.patch b/pkg/devel/the_silver_searcher/patch/0001-Remove-after-function-definition.patch
@@ -0,0 +1,26 @@
+From 76adb32c89184406278fd51a3fe138314b134a12 Mon Sep 17 00:00:00 2001
+From: Michael Forney <mforney@mforney.org>
+Date: Sat, 15 Jun 2019 20:58:00 -0700
+Subject: [PATCH] Remove `;` after function definition
+Upstream: https://github.com/ggreer/the_silver_searcher/pull/1324
+
+---
+ src/ignore.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/src/ignore.c b/src/ignore.c
+index fa41889..bdb03b4 100644
+--- a/src/ignore.c
++++ b/src/ignore.c
+@@ -39,7 +39,7 @@ const char *ignore_pattern_files[] = {
+
+ int is_empty(ignores *ig) {
+ return (ig->extensions_len + ig->names_len + ig->slash_names_len + ig->regexes_len + ig->slash_regexes_len == 0);
+-};
++}
+
+ ignores *init_ignore(ignores *parent, const char *dirname, const size_t dirname_len) {
+ ignores *ig = ag_malloc(sizeof(ignores));
+--
+2.20.1
+
diff --git a/pkg/devel/the_silver_searcher/patch/0002-Use-inline-function-for-min-instead-of-statement-exp.patch b/pkg/devel/the_silver_searcher/patch/0002-Use-inline-function-for-min-instead-of-statement-exp.patch
@@ -0,0 +1,33 @@
+From dc1be161f9155e92367714b38f6a45d05d4f90cd Mon Sep 17 00:00:00 2001
+From: Michael Forney <mforney@mforney.org>
+Date: Sat, 15 Jun 2019 20:58:46 -0700
+Subject: [PATCH] Use inline function for min instead of statement expression
+Upstream: https://github.com/ggreer/the_silver_searcher/pull/1324
+
+---
+ src/zfile.c | 9 +++++----
+ 1 file changed, 5 insertions(+), 4 deletions(-)
+
+diff --git a/src/zfile.c b/src/zfile.c
+index e4b7566..29fbb07 100644
+--- a/src/zfile.c
++++ b/src/zfile.c
+@@ -33,10 +33,11 @@ typedef _off64_t off64_t;
+
+ #if HAVE_FOPENCOOKIE
+
+-#define min(a, b) ({ \
+- __typeof (a) _a = (a); \
+- __typeof (b) _b = (b); \
+- _a < _b ? _a : _b; })
++static inline size_t
++min(size_t a, size_t b)
++{
++ return a < b ? a : b;
++}
+
+ static cookie_read_function_t zfile_read;
+ static cookie_seek_function_t zfile_seek;
+--
+2.20.1
+
diff --git a/pkg/devel/the_silver_searcher/patch/0003-Prevent-duplicate-definitions-of-global-variables.patch b/pkg/devel/the_silver_searcher/patch/0003-Prevent-duplicate-definitions-of-global-variables.patch
@@ -0,0 +1,210 @@
+From 159e026212ba551981dc522690901b9291b8e235 Mon Sep 17 00:00:00 2001
+From: Michael Forney <mforney@mforney.org>
+Date: Sun, 16 Jun 2019 01:49:32 -0700
+Subject: [PATCH] Prevent duplicate definitions of global variables
+Upstream: https://github.com/ggreer/the_silver_searcher/pull/1324
+
+Multiple external definitions of an object is invalid in ISO C[0].
+
+These are visible when linking with -Wl,--warn-common.
+
+[0] http://port70.net/~nsz/c/c11/n1570.html#6.9p5
+---
+ src/ignore.c | 2 ++
+ src/ignore.h | 2 +-
+ src/log.c | 2 ++
+ src/log.h | 2 +-
+ src/options.c | 2 ++
+ src/options.h | 2 +-
+ src/search.c | 13 +++++++++++++
+ src/search.h | 20 ++++++++++----------
+ src/util.c | 3 +++
+ src/util.h | 4 ++--
+ 10 files changed, 37 insertions(+), 15 deletions(-)
+
+diff --git a/src/ignore.c b/src/ignore.c
+index bdb03b4..56c102a 100644
+--- a/src/ignore.c
++++ b/src/ignore.c
+@@ -22,6 +22,8 @@ const int fnmatch_flags = FNM_PATHNAME;
+
+ /* TODO: build a huge-ass list of files we want to ignore by default (build cache stuff, pyc files, etc) */
+
++ignores *root_ignores;
++
+ const char *evil_hardcoded_ignore_files[] = {
+ ".",
+ "..",
+diff --git a/src/ignore.h b/src/ignore.h
+index 20d5a6a..8db0f37 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 1481b6d..aef0b54 100644
+--- a/src/log.c
++++ b/src/log.c
+@@ -4,6 +4,8 @@
+ #include "log.h"
+ #include "util.h"
+
++pthread_mutex_t print_mtx;
++
+ 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 85847ee..318622c 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 e63985e..70ef448 100644
+--- a/src/options.c
++++ b/src/options.c
+@@ -16,6 +16,8 @@
+ #include "print.h"
+ #include "util.h"
+
++cli_options opts;
++
+ 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 */
+diff --git a/src/options.h b/src/options.h
+index db3e896..fd7d1f0 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 ff5e386..2245818 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;
++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;
++
++symdir_t *symhash;
++
+ 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 1071114..a1bc5d7 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;
+
+ void 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 cb23914..103be46 100644
+--- a/src/util.c
++++ b/src/util.c
+@@ -21,6 +21,9 @@
+ } \
+ return ptr;
+
++FILE *out_fd;
++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 0c9b9b1..338b05f 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 {
+--
+2.20.1
+
diff --git a/pkg/devel/the_silver_searcher/src b/pkg/devel/the_silver_searcher/src
@@ -0,0 +1 @@
+Subproject commit 520ff29c528503668020c8cbedb5b03bccf4c7e0
diff --git a/pkg/devel/the_silver_searcher/ver b/pkg/devel/the_silver_searcher/ver
@@ -0,0 +1 @@
+2.2.0 r2
diff --git a/sets.lua b/sets.lua
@@ -18,6 +18,7 @@ S.bin = {
'spm',
'stagit',
'strace',
+ 'the_silver_searcher',
'vis',
}