[prev in list] [next in list] [prev in thread] [next in thread] 

List:       ast-developers
Subject:    Re: [ast-developers] Bug in ~(X) and .sh.match
From:       Glenn Fowler <gsf () research ! att ! com>
Date:       2013-08-21 21:35:53
Message-ID: 201308212135.r7LLZrNQ016030 () terra ! research ! att ! com
[Download RAW message or body]

This is a multipart message in MIME format.


attached are some ast testregex tests that examine the pattern in your example
in the tests ~(A) is equivalent to ~(X)

testregex is in the ast-open package in src/cmd/re
the man page is online at www.research.att.com/sw/download/

testregex input data documents patterns, subject strings, and the expected outcome,
including sub-group matches

the tests exposed a bug in ast:regsubcomp() that will be fixed in the next alpha

On Tue, 20 Aug 2013 22:31:38 +0200 Dan Shelton wrote:
> I may have found a bug in ~(X). AFAIK the first index (.sh.match[0])
> in .sh.match always lists all patterns for which matches have been
> found, and all following indexes (.sh.match[0..inf]) store the
> captured matches for a specific bracket pair, right?

> If that's correct, why does '15' appear in .sh.match[0][0] but no
> other match has '15' later?

> ksh -c 'x="a15 b2 c3" ; d="${x//~(X)(([[:alnum:]])&([[:digit:]]))+/}"
> ; print -v .sh.match'
> (
>         (
>                 15
>                 2
>                 3
>         )
>         (
>                 5
>                 2
>                 3
>         )
>         (
>                 5
>                 2
>                 3
>         )
>         (
>                 5
>                 2
>                 3
>         )
> )

> Dan
> _______________________________________________
> ast-developers mailing list
> ast-developers@lists.research.att.com
> http://lists.research.att.com/mailman/listinfo/ast-developers


["conjunction.dat" (text/plain)]

# regex conjunction tests

A	[[:alnum:]]+				a15 b2 c3	(0,3)
A	([[:alnum:]])+				a15 b2 c3	(0,3)(2,3)
A	(([[:alnum:]]))+			a15 b2 c3	(0,3)(2,3)(2,3)

A	[[:digit:]]+				a15 b2 c3	(1,3)
A	([[:digit:]])+				a15 b2 c3	(1,3)(2,3)
A	(([[:digit:]]))+			a15 b2 c3	(1,3)(2,3)(2,3)

K	+([[:alnum:]])				a15 b2 c3	(0,3)(0,3)
K	+(([[:alnum:]]))			a15 b2 c3	(0,3)(0,3)(2,3)

K	+([[:digit:]])				a15 b2 c3	(1,3)(1,3)
K	+(([[:digit:]]))			a15 b2 c3	(1,3)(1,3)(2,3)

# the following group shows the difference between +(...) and (...)+ subgroup reporting

A	(([[:alnum:]])&([[:digit:]]))+		a15 b2 c3	(1,3)(2,3)(2,3)(2,3)
K	~(A)(([[:alnum:]])&([[:digit:]]))+	a15 b2 c3	(1,3)(2,3)(2,3)(2,3)

A	(?K-a)+(([[:alnum:]])&([[:digit:]]))	a15 b2 c3	(1,3)(1,3)(2,3)(2,3)
K	+(([[:alnum:]])&([[:digit:]]))		a15 b2 c3	(1,3)(1,3)(2,3)(2,3)

# the following group should be the equivalent

A/	/(([[:alnum:]])&([[:digit:]]))+/X/g		a15 b2 c3	aX bX cX
K/	/~(A)(([[:alnum:]])&([[:digit:]]))+/X/g		a15 b2 c3	aX bX cX	# regsubexec() BUG fixed #
A/	/(?K-a)+(([[:alnum:]])&([[:digit:]]))/X/g	a15 b2 c3	aX bX cX	# regsubexec() BUG fixed #
K/	/+(([[:alnum:]])&([[:digit:]]))/X/g		a15 b2 c3	aX bX cX


_______________________________________________
ast-developers mailing list
ast-developers@lists.research.att.com
http://lists.research.att.com/mailman/listinfo/ast-developers


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic