diff options
author | Arnold D. Robbins <arnold@skeeve.com> | 2013-03-11 22:45:22 +0200 |
---|---|---|
committer | Arnold D. Robbins <arnold@skeeve.com> | 2013-03-11 22:45:22 +0200 |
commit | a7c502a756732ec9a1773d6169376bb7b25f4308 (patch) | |
tree | 75dd7a168a4e695438fdc2ba4d5959fd24ff2217 /re.c | |
parent | 2b02c5c64a93608c347ffaa312d88d52f93888da (diff) | |
download | egawk-a7c502a756732ec9a1773d6169376bb7b25f4308.tar.gz egawk-a7c502a756732ec9a1773d6169376bb7b25f4308.tar.bz2 egawk-a7c502a756732ec9a1773d6169376bb7b25f4308.zip |
Fix a bug with ] as real char in regexps.
Diffstat (limited to 're.c')
-rw-r--r-- | re.c | 18 |
1 files changed, 16 insertions, 2 deletions
@@ -564,8 +564,22 @@ again: if (*sp == '[') count++; - else if (*sp == ']') - count--; + /* + * ] as first char after open [ is skipped + * \] is skipped + * [^]] is skipped + */ + if (*sp == ']' && sp > sp2) { + if (sp[-1] != '[' + && sp[-1] != '\\') + ; + else if ((sp - sp2) >= 2 + && sp[-1] == '^' && sp[-2] == '[') + ; + else + count--; + } + if (*sp == '-' && do_lint && ! range_warned && count == 1 && sp[-1] != '[' && sp[1] != ']' && ! isdigit((unsigned char) sp[-1]) && ! isdigit((unsigned char) sp[1]) |