5 .param pmc argv :slurpy
9 if argc < 2 goto badargs
12 options = get_root_global ['_tcl'; 'helpers'; 'regexp'], 'options'
14 .local pmc select_switches, switches
15 select_switches = get_root_global ['_tcl'], 'select_switches'
16 switches = select_switches(options, argv, 1, 1)
18 .local string exp, a_string, original_string
21 original_string = a_string
23 .local pmc tclARE, rule, match
25 # RT#40774: use tcl-regexps
26 tclARE = compreg 'PGE::P5Regex'
27 $I0 = exists switches['nocase']
30 a_string = downcase a_string
34 match = rule(a_string)
39 .local string matchStr, matchVar
41 setVar = get_root_global [ '_tcl' ], 'setVar'
47 $I0 = exists switches['indices']
48 if $I0 goto matches_ind
50 # Do this in case there was a -nocase
54 matchStr = substr original_string, $I0, $I1
56 setVar(matchVar, matchStr)
58 matches = match.'get_array'()
59 .local string subMatchStr, subMatchVar
65 subMatchVar = shift argv
67 if_null matches, set_it
68 $I0 = elements matches
69 unless $I0 goto set_it
75 subMatchStr = substr original_string, $I0, $I1
78 setVar(subMatchVar,subMatchStr)
85 matchList = new 'TclList'
93 setVar(matchVar, matchList)
95 matches = match.'get_array'()
98 .local pmc subMatchList
101 unless argc goto done
103 subMatchVar = shift argv
104 subMatchList = new 'TclList'
107 if_null matches, set_it_ind
108 $I0 = elements matches
109 unless $I0 goto set_it_ind
111 if_null $P0, set_it_ind
115 subMatchList[0] = $I0
116 subMatchList[1] = $I1
119 setVar(subMatchVar,subMatchList)
122 goto subMatches_ind_loop
129 die 'wrong # args: should be "regexp ?switches? exp string ?matchVar? ?subMatchVar subMatchVar ...?"'
133 .sub 'anon' :anon :load
135 options = new 'TclList'
137 push options, 'about'
138 push options, 'indices'
139 push options, 'inline'
140 push options, 'expanded' # RT#40774: use tcl-regexps
142 push options, 'linestop'
143 push options, 'lineanchor'
144 push options, 'nocase'
145 push options, 'start'
147 set_root_global ['_tcl'; 'helpers'; 'regexp'], 'options', options
154 # vim: expandtab shiftwidth=4 ft=pir: