`[...]` at p against c; *end past the class. A malformed class matches * nothing. */
| 41 | /* `[...]` at p against c; *end past the class. A malformed class matches |
| 42 | * nothing. */ |
| 43 | static bool ej_class(const char *p, char c, const char **end) { |
| 44 | const char *q = p + SKIP_ONE; |
| 45 | bool neg = *q == '^' || *q == '!'; |
| 46 | q += neg; |
| 47 | bool hit = false; |
| 48 | for (bool first = true; *q && (first || *q != ']'); first = false) { |
| 49 | char lo = *q == '\\' && q[SKIP_ONE] ? *++q : *q; |
| 50 | q++; |
| 51 | char hi = lo; |
| 52 | if (q[0] == '-' && q[SKIP_ONE] && q[SKIP_ONE] != ']') { |
| 53 | q++; |
| 54 | hi = *q == '\\' && q[SKIP_ONE] ? *++q : *q; |
| 55 | q++; |
| 56 | } |
| 57 | hit = hit || (c >= lo && c <= hi); |
| 58 | } |
| 59 | if (*q != ']') { |
| 60 | *end = NULL; |
| 61 | return false; |
| 62 | } |
| 63 | *end = q + SKIP_ONE; |
| 64 | return hit != neg; |
| 65 | } |
| 66 | |
| 67 | /* Docker's pattern syntax over a whole repository path: `**` any run (`**` |
| 68 | * followed by `/`: whole segments only), `*` a run inside one segment, `?` |