MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / op_match

Function op_match

src/pipeline/pass_operator.c:804–857  ·  view source on GitHub ↗

Go's path.Match for one segment: '*', '?', '[...]', '\\' escapes. */

Source from the content-addressed store, hash-verified

802
803/* Go's path.Match for one segment: '*', '?', '[...]', '\\' escapes. */
804static bool op_match(const char *pat, const char *s) {
805 while (*pat) {
806 if (*pat == '*') {
807 pat++;
808 for (const char *t = s;; t++) {
809 if (op_match(pat, t)) {
810 return true;
811 }
812 if (!*t) {
813 return false;
814 }
815 }
816 }
817 if (!*s) {
818 return false;
819 }
820 if (*pat == '?') {
821 pat++;
822 s++;
823 continue;
824 }
825 if (*pat == '[') {
826 const char *q = pat + SKIP_ONE;
827 bool neg = *q == '^';
828 q += neg;
829 bool hit = false;
830 while (*q && *q != ']') {
831 char lo = *q;
832 char hi = lo;
833 if (q[SKIP_ONE] == '-' && q[PAIR_LEN] && q[PAIR_LEN] != ']') {
834 hi = q[PAIR_LEN];
835 q += PAIR_LEN;
836 }
837 hit = hit || (*s >= lo && *s <= hi);
838 q++;
839 }
840 if (*q != ']' || hit == neg) {
841 return false;
842 }
843 pat = q + SKIP_ONE;
844 s++;
845 continue;
846 }
847 if (*pat == '\\' && pat[SKIP_ONE]) {
848 pat++;
849 }
850 if (*pat != *s) {
851 return false;
852 }
853 pat++;
854 s++;
855 }
856 return *s == '\0';
857}
858
859/* Does `rel` (a path below the Go file's directory) match the embed
860 * pattern: segment by segment, a matched directory taking its files except

Callers 1

op_embedsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected