diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2024-06-07 14:58:50 -0400 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2024-06-07 14:58:50 -0400 |
| commit | 46c2edd4d1c2c5d0244ea8e216299d4e6db60a6b (patch) | |
| tree | 085927ea67cb173c5ec1afba859eb2e8490d9df9 /pattern.c | |
| parent | 31e414af503cbbc29f40ab6127073be939ffada1 (diff) | |
Change parsing so that `...foo` parses as `(.)(..foo)` instead of
`(..(.))(foo)`
Diffstat (limited to 'pattern.c')
| -rw-r--r-- | pattern.c | 6 |
1 files changed, 5 insertions, 1 deletions
@@ -224,7 +224,11 @@ static bp_pat_t *_bp_simplepattern(const char *str, const char *end, bool inside switch (c) { // Any char (dot) case '.': { - if (*str == '.') { // ".." + // As a special case, 3+ dots is parsed as a series of "any char" followed by a single "upto" + // In other words, `...foo` parses as `(.)(..foo)` instead of `(..(.)) (foo)` + // This is so that `...` can mean "at least one character upto" instead of "upto any character", + // which is tautologically the same as matching any single character. + if (*str == '.' && (str+1 >= end || str[1] != '.')) { // ".." str = next_char(str, end); enum bp_pattype_e type = BP_UPTO; bp_pat_t *extra_arg = NULL; |
