diff --git a/sysutils/fsearch/distinfo b/sysutils/fsearch/distinfo index e468d1fcf2f6..17b0c6f0ba0e 100644 --- a/sysutils/fsearch/distinfo +++ b/sysutils/fsearch/distinfo @@ -1,7 +1,7 @@ TIMESTAMP = 1643482609 SHA256 (cboxdoerfer-fsearch-0.1.2_GH0.tar.gz) = f80e10922812169e8437476d5fbe6d05249997c49b98f991d382a6d5566551b4 SIZE (cboxdoerfer-fsearch-0.1.2_GH0.tar.gz) = 504787 -SHA256 (7f602118e0de9f524e71.diff) = cd24cf0cc3f07c3135d0cdb6981784b8bb254c12f8d0d7aabfe068417c17b36b -SIZE (7f602118e0de9f524e71.diff) = 693 -SHA256 (f0ee01b40156ddb36651.diff) = 75f01513f0c88e61715097495b22f920c5131b2c03956d54d5b94e53e7ec5a7a -SIZE (f0ee01b40156ddb36651.diff) = 1741 +SHA256 (7f602118e0de9f524e71.diff) = e8450734c460fc837dbde12e15f97dcb4fb4af376516acbae9cf7874bc07f531 +SIZE (7f602118e0de9f524e71.diff) = 695 +SHA256 (f0ee01b40156ddb36651.diff) = ce12c4b2212189abe2d8a8839c81d3105be71781aa7fce30851dcac7f9ef9beb +SIZE (f0ee01b40156ddb36651.diff) = 1747 diff --git a/sysutils/fsearch/files/patch-src_fsearch__string__utils.c b/sysutils/fsearch/files/patch-src_fsearch__string__utils.c index d57fb73a7f75..6f847df9fe24 100644 --- a/sysutils/fsearch/files/patch-src_fsearch__string__utils.c +++ b/sysutils/fsearch/files/patch-src_fsearch__string__utils.c @@ -1,94 +1,94 @@ --- src/fsearch_string_utils.c.orig 2022-01-29 18:56:49 UTC +++ src/fsearch_string_utils.c @@ -214,3 +214,91 @@ fs_str_split(const char *src) { return (char **)g_ptr_array_free(new, FALSE); } + +/* Compare strings while treating digits characters numerically. + Copyright (C) 1997-2022 Free Software Foundation, Inc. + Contributed by Jean-François Bignolles , + 1997. */ + +#include + +/* states: S_N: normal, S_I: comparing integral part, S_F: comparing + fractional parts, S_Z: idem but with leading Zeroes only */ +#define S_N 0x0 +#define S_I 0x3 +#define S_F 0x6 +#define S_Z 0x9 + +/* result_type: CMP: return diff; LEN: compare using len_diff/diff */ +#define CMP 2 +#define LEN 3 + +/* Compare S1 and S2 as strings holding indices/version numbers, -+ returning less than, equal to or greater than zero if S1 is less than, -+ equal to, or greater than S2. */ ++ returning less than, equal to, or greater than zero if S1 is less ++ than, equal to, or greater than S2. */ + +int +strverscmp (const char *s1, const char *s2) +{ + const unsigned char *p1 = (const unsigned char *) s1; + const unsigned char *p2 = (const unsigned char *) s2; + + /* Symbol(s) 0 [1-9] others + Transition (10) 0 (01) d (00) x */ + static const uint_least8_t next_state[] = + { + /* state x d 0 */ + /* S_N */ S_N, S_I, S_Z, + /* S_I */ S_N, S_I, S_I, + /* S_F */ S_N, S_F, S_F, + /* S_Z */ S_N, S_F, S_Z + }; + + static const int_least8_t result_type[] = + { + /* state x/x x/d x/0 d/x d/d d/0 0/x 0/d 0/0 */ + + /* S_N */ CMP, CMP, CMP, CMP, LEN, CMP, CMP, CMP, CMP, + /* S_I */ CMP, -1, -1, +1, LEN, LEN, +1, LEN, LEN, + /* S_F */ CMP, CMP, CMP, CMP, CMP, CMP, CMP, CMP, CMP, + /* S_Z */ CMP, +1, +1, -1, CMP, CMP, -1, CMP, CMP + }; + + if (p1 == p2) + return 0; + + unsigned char c1 = *p1++; + unsigned char c2 = *p2++; + /* Hint: '0' is a digit too. */ + int state = S_N + ((c1 == '0') + (isdigit (c1) != 0)); + + int diff; + while ((diff = c1 - c2) == 0) + { + if (c1 == '\0') + return diff; + + state = next_state[state]; + c1 = *p1++; + c2 = *p2++; + state += (c1 == '0') + (isdigit (c1) != 0); + } + + state = result_type[state * 3 + (((c2 == '0') + (isdigit (c2) != 0)))]; + + switch (state) + { + case CMP: + return diff; + + case LEN: + while (isdigit (*p1++)) + if (!isdigit (*p2++)) + return 1; + + return isdigit (*p2) ? -1 : diff; + + default: + return state; + } +} diff --git a/sysutils/fsearch/pkg-descr b/sysutils/fsearch/pkg-descr index 01dffd0d0a84..00d105f9411e 100644 --- a/sysutils/fsearch/pkg-descr +++ b/sysutils/fsearch/pkg-descr @@ -1,11 +1,11 @@ FSearch is a fast file search utility, inspired by Everything Search -Engine. It is written in C and based on GTK+3. It features: +Engine. It is written in plain C and based on GTK 3. It features: - Instant (as you type) results - - Wildcard support and regular expression support - - Filter support (only search for files, folders or everything) + - Wildcard and regular expression support + - Filters (only search for files, folders, or everything) - Include and exclude specific folders to be indexed - Fast sort by file name, path, size, or modification time - - Customizable interface + - Customizable user interface WWW: http://cboxdoerfer.github.io/fsearch/