bug-gnu-utils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] gawk 3.1.2, set match() subexpressions


From: Stepan Kasal
Subject: [PATCH] gawk 3.1.2, set match() subexpressions
Date: Mon, 12 May 2003 00:19:30 +0200
User-agent: Mutt/1.2.5.1i

Greetings to all!

I have discovered a bug in match() builtin of GNU awk (verified for
versions 3.1.1 and 3.1.2).  The call:

        match("y",/(x)?(y)/,a)

sets a[0]=="y" and doesn't set a[1].   But it should also set a[2]=="y".

Patch (one-liner) is below.

Have a nice fortnight,
        Stepan


Mon May 12 00:09:12 CEST 2003  Stepan Kasal  <address@hidden>

        * builtin.c (do_match): if third parameter to match() is supplied,
          store all subexpressions which are applicable, even though there
          are some unused between them.

diff -urpN gawk-3.1.2b.a3/builtin.c gawk-3.1.2b.a4/builtin.c
--- gawk-3.1.2b.a3/builtin.c    Wed Apr 30 10:53:09 2003
+++ gawk-3.1.2b.a4/builtin.c    Mon May 12 00:04:39 2003
@@ -1799,8 +1799,8 @@ do_match(NODE *tree)
                        subsepstr = SUBSEP_node->var_value->stptr;
                        subseplen = SUBSEP_node->var_value->stlen;
 
-                       for (ii = 0; ii < NUMSUBPATS(rp, t1->stptr)
-                            && (s = SUBPATSTART(rp, t1->stptr, ii)) != -1; 
ii++) {
+                       for (ii = 0; ii < NUMSUBPATS(rp, t1->stptr); ii++)
+                            if ((s = SUBPATSTART(rp, t1->stptr, ii)) != -1) {
                                start = t1->stptr + s;
                                len = SUBPATEND(rp, t1->stptr, ii) - s;
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]