aboutsummaryrefslogtreecommitdiffstats
path: root/re.c
diff options
context:
space:
mode:
authorArnold D. Robbins <arnold@skeeve.com>2013-03-11 22:50:11 +0200
committerArnold D. Robbins <arnold@skeeve.com>2013-03-11 22:50:11 +0200
commit891b30a5417f93c3fc5e5aa4d54e270282bea380 (patch)
tree149a8e67e1df432845988a04669f677a77392d25 /re.c
parent840661815d5063942b4475a908af423cf6bc813c (diff)
parenta7c502a756732ec9a1773d6169376bb7b25f4308 (diff)
downloadegawk-891b30a5417f93c3fc5e5aa4d54e270282bea380.tar.gz
egawk-891b30a5417f93c3fc5e5aa4d54e270282bea380.tar.bz2
egawk-891b30a5417f93c3fc5e5aa4d54e270282bea380.zip
Merge branch 'gawk-4.0-stable'
Diffstat (limited to 're.c')
-rw-r--r--re.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/re.c b/re.c
index b81cf62d..e5492919 100644
--- a/re.c
+++ b/re.c
@@ -559,8 +559,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])