1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
/*
* Copyright (c) 2025-2026 Anton Kundenko <singaraiona@gmail.com>
* All rights reserved.
*/
/* Glob pattern match, iterative two-pointer (no catastrophic backtracking).
* Worst case O(n*m); typical case linear.
*
* Supported metacharacters:
* * — matches zero or more characters
* ? — matches exactly one character
* [abc] — character class: matches any of a, b, c
* [a-z] — range
* [!abc] — negated class
*
* Matching a literal metacharacter — there is no backslash escape; wrap
* the character in a one-element class instead:
* [*] matches a literal '*'
* [?] matches a literal '?'
* [[] matches a literal '['
* []] matches a literal ']' (']' as first char inside [...] is literal)
* [-] matches a literal '-' (as the sole char, no range to form)
*
* `glob_match` is case-sensitive. `glob_match_ci` lowercases ASCII letters
* on both sides before comparing (so it matches 'A' against 'a', 'A-Z'
* range matches both case forms, etc.).
*
* Lenient parsing policy: an unterminated character class (e.g. pattern
* "abc[def" with no closing `]`) is accepted — the class consumes input
* up to the end of the pattern and the match continues with whatever
* `matched` flag accumulated. This matches glibc fnmatch's permissive
* behaviour and avoids surprising `error: parse` mid-search. Callers
* that want strict validation should pre-validate the pattern. */
bool ;
bool ;
/* ---- Pre-compiled pattern fast path -------------------------------------
* Many LIKE workloads have very simple patterns (e.g. `*google*`). When
* the pattern has no metacharacters except (optionally) a leading `*`
* and/or a trailing `*`, the match collapses to a literal substring /
* prefix / suffix / equality test that we can drive with memcmp /
* memmem — both libc-vectorised on modern glibc. Detect the shape once
* up front, then run the entire dictionary (or row vector) through a
* single tight loop.
*
* Shapes:
* RAY_GLOB_SHAPE_NONE — pattern needs the full glob matcher
* RAY_GLOB_SHAPE_EXACT — no `*`/`?`/`[` — literal equality
* RAY_GLOB_SHAPE_PREFIX — `<lit>*` — strncmp prefix
* RAY_GLOB_SHAPE_SUFFIX — `*<lit>` — tail equality
* RAY_GLOB_SHAPE_CONTAINS — `*<lit>*` — memmem
* RAY_GLOB_SHAPE_ANY — pattern is "*" — always true
* The compiled struct caches a pointer/length into the original
* pattern buffer, so the caller must keep the pattern alive while the
* compiled view is in use. */
typedef enum ray_glob_shape_t;
typedef struct ray_glob_compiled_t;
/* Classify a pattern. Returns the simplest matching shape; falls back
* to RAY_GLOB_SHAPE_NONE when the pattern needs the general matcher. */
ray_glob_compiled_t ;
/* Match a single string against a compiled simple-shape pattern.
* Caller must guarantee shape != RAY_GLOB_SHAPE_NONE. */
bool ;
typedef struct ray_strpat_t;
/* Compile a search pattern using literals, `?`, and character classes.
* `*` is not a search wildcard; match a literal star with `[*]`. */
bool ;
/* Find the first byte offset whose substring matches a search pattern.
* The empty pattern matches at offset 0. */
bool ;
bool ;
/* RAY_OPS_GLOB_H */