mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-01-19 11:31:26 +01:00
36982: Fix bug with (#cN) patterns and remove redundant description.
We need to restore the current count of matches when returning to match at the point where we previously matched.
This commit is contained in:
parent
63fd71f171
commit
b498bd7ce5
5 changed files with 22 additions and 10 deletions
|
@ -1,5 +1,9 @@
|
|||
2015-10-27 Peter Stephenson <p.stephenson@samsung.com>
|
||||
|
||||
* 36982: Doc/Zsh/expn.yo, Src/pattern.c, Test/D02glob.ztst,
|
||||
Test/D04parameter.ztst: fix actual bug with (#cN) and back off
|
||||
previous change.
|
||||
|
||||
* 36977: Doc/Zsh/expn.yo: note about complications of pattern
|
||||
repetitions (#cN).
|
||||
|
||||
|
|
|
@ -2192,16 +2192,6 @@ inclusive. The form tt(LPAR()#c)var(N)tt(RPAR()) requires exactly tt(N)
|
|||
matches; tt(LPAR()#c,)var(M)tt(RPAR()) is equivalent to specifying var(N)
|
||||
as 0; tt(LPAR()#c)var(N)tt(,RPAR()) specifies that there is no maximum
|
||||
limit on the number of matches.
|
||||
|
||||
Note that if the previous group of characters contains wildcards,
|
||||
results can be unpredictable to the point of being logically incorrect.
|
||||
It is recommended that the pattern be trimmed to match the minimum
|
||||
possible. For example, to match a string of the form `tt(1_2_3_)', use
|
||||
a pattern of the form `tt(LPAR()[[:digit:]]##_+RPAR()LPAR()#c3+RPAR())', not
|
||||
`tt(LPAR()*_+RPAR()LPAR()#c3+RPAR())'. This arises from the
|
||||
complicated interaction between attempts to match a number of
|
||||
repetitions of the whole pattern and attempts to match the wildcard
|
||||
`tt(*)'.
|
||||
)
|
||||
vindex(MATCH)
|
||||
vindex(MBEGIN)
|
||||
|
|
|
@ -3376,6 +3376,7 @@ patmatch(Upat prog)
|
|||
scan[P_CT_CURRENT].l = cur + 1;
|
||||
if (patmatch(scan + P_CT_OPERAND))
|
||||
return 1;
|
||||
scan[P_CT_CURRENT].l = cur;
|
||||
patinput = patinput_thistime;
|
||||
}
|
||||
if (cur < min)
|
||||
|
|
|
@ -574,3 +574,11 @@
|
|||
0:Optimisation to squeeze multiple *'s used as ordinary glob wildcards.
|
||||
>glob.tmp/ra=1.0_et=3.5
|
||||
>glob.tmp/ra=1.0_et=3.5
|
||||
|
||||
[[ 1_2_ = (*_)(#c1) ]] && print 1 OK # because * matches 1_2
|
||||
[[ 1_2_ = (*_)(#c2) ]] && print 2 OK
|
||||
[[ 1_2_ = (*_)(#c3) ]] || print 3 OK
|
||||
0:Some more complicated backtracking with match counts.
|
||||
>1 OK
|
||||
>2 OK
|
||||
>3 OK
|
||||
|
|
|
@ -1735,3 +1735,12 @@
|
|||
0:History modifier works the same for scalar and array substitution
|
||||
>ddd bdb cdc
|
||||
>ddd bdb cdc
|
||||
|
||||
a=1_2_3_4_5_6
|
||||
print ${a#(*_)(#c2)}
|
||||
print ${a#(*_)(#c5)}
|
||||
print ${a#(*_)(#c7)}
|
||||
0:Complicated backtracking with match counts
|
||||
>3_4_5_6
|
||||
>6
|
||||
>1_2_3_4_5_6
|
||||
|
|
Loading…
Reference in a new issue