[PATCH regcomp.c] zero-width assertions CAN be ?'d
[p5sagit/p5-mst-13.2.git] / t / lib / warnings / regcomp
1   regcomp.c     AOK
2
3   Quantifier unexpected on zero-length expression [S_study_chunk] 
4
5   (?p{}) is deprecated - use (??{})  [S_reg]
6     $a =~ /(?p{'x'})/ ;
7     
8
9   Useless (%s%c) - %suse /%c modifier [S_reg] 
10   Useless (%sc) - %suse /gc modifier [S_reg] 
11
12
13
14   Strange *+?{} on zero-length expression       [S_study_chunk]
15         /(?=a)?/
16
17   %.*s matches null string many times           [S_regpiece]
18         $a = "ABC123" ; $a =~ /(?=a)*/'
19
20   /%.127s/: Unrecognized escape \\%c passed through     [S_regatom] 
21         $x = '\m' ; /$x/
22
23   POSIX syntax [%c %c] is reserved for future extensions [S_checkposixcc] 
24
25
26   Character class [:%.*s:] unknown      [S_regpposixcc]
27
28   Character class syntax [%c %c] belongs inside character classes [S_checkposixcc] 
29   
30   /%.127s/: false [] range \"%*.*s\" in regexp [S_regclass]
31
32   /%.127s/: false [] range \"%*.*s\" in regexp [S_regclassutf8]
33
34   /%.127s/: Unrecognized escape \\%c in character class passed through" [S_regclass] 
35
36   /%.127s/: Unrecognized escape \\%c in character class passed through" [S_regclassutf8] 
37
38   False [] range \"%*.*s\" [S_regclass]
39
40 __END__
41 # regcomp.c [S_regpiece]
42 use warnings 'regexp' ;
43 my $a = "ABC123" ; 
44 $a =~ /(?=a)*/ ;
45 no warnings 'regexp' ;
46 $a =~ /(?=a)*/ ;
47 EXPECT
48 (?=a)* matches null string many times in regex; marked by <-- HERE in m/(?=a)* <-- HERE / at - line 4.
49 ########
50 # regcomp.c [S_regatom]
51 $x = '\m' ;
52 use warnings 'regexp' ;
53 $a =~ /a$x/ ;
54 no warnings 'regexp' ;
55 $a =~ /a$x/ ;
56 EXPECT
57 Unrecognized escape \m passed through in regex; marked by <-- HERE in m/a\m <-- HERE / at - line 4.
58 ########
59 # regcomp.c [S_regpposixcc S_checkposixcc]
60 #
61 use warnings 'regexp' ;
62 $_ = "" ;
63 /[:alpha:]/;
64 /[:zog:]/;
65 /[[:zog:]]/;
66 no warnings 'regexp' ;
67 /[:alpha:]/;
68 /[:zog:]/;
69 /[[:zog:]]/;
70 EXPECT
71 POSIX syntax [: :] belongs inside character classes in regex; marked by <-- HERE in m/[:alpha:] <-- HERE / at - line 5.
72 POSIX syntax [: :] belongs inside character classes in regex; marked by <-- HERE in m/[:zog:] <-- HERE / at - line 6.
73 POSIX class [:zog:] unknown in regex; marked by <-- HERE in m/[[:zog:] <-- HERE ]/
74 ########
75 # regcomp.c [S_checkposixcc]
76 #
77 use warnings 'regexp' ;
78 $_ = "" ;
79 /[.zog.]/;
80 no warnings 'regexp' ;
81 /[.zog.]/;
82 EXPECT
83 POSIX syntax [. .] belongs inside character classes in regex; marked by <-- HERE in m/[.zog.] <-- HERE / at - line 5.
84 POSIX syntax [. .] is reserved for future extensions in regex; marked by <-- HERE in m/[.zog.] <-- HERE /
85 ########
86 # regcomp.c [S_checkposixcc]
87 #
88 use warnings 'regexp' ;
89 $_ = "" ;
90 /[[.zog.]]/;
91 no warnings 'regexp' ;
92 /[[.zog.]]/;
93 EXPECT
94 POSIX syntax [. .] is reserved for future extensions in regex; marked by <-- HERE in m/[[.zog.] <-- HERE ]/
95 ########
96 # regcomp.c [S_regclass]
97 $_ = "";
98 use warnings 'regexp' ;
99 /[a-b]/;
100 /[a-\d]/;
101 /[\d-b]/;
102 /[\s-\d]/;
103 /[\d-\s]/;
104 /[a-[:digit:]]/;
105 /[[:digit:]-b]/;
106 /[[:alpha:]-[:digit:]]/;
107 /[[:digit:]-[:alpha:]]/;
108 no warnings 'regexp' ;
109 /[a-b]/;
110 /[a-\d]/;
111 /[\d-b]/;
112 /[\s-\d]/;
113 /[\d-\s]/;
114 /[a-[:digit:]]/;
115 /[[:digit:]-b]/;
116 /[[:alpha:]-[:digit:]]/;
117 /[[:digit:]-[:alpha:]]/;
118 EXPECT
119 False [] range "a-\d" in regex; marked by <-- HERE in m/[a-\d <-- HERE ]/ at - line 5.
120 False [] range "\d-" in regex; marked by <-- HERE in m/[\d- <-- HERE b]/ at - line 6.
121 False [] range "\s-" in regex; marked by <-- HERE in m/[\s- <-- HERE \d]/ at - line 7.
122 False [] range "\d-" in regex; marked by <-- HERE in m/[\d- <-- HERE \s]/ at - line 8.
123 False [] range "a-[:digit:]" in regex; marked by <-- HERE in m/[a-[:digit:] <-- HERE ]/ at - line 9.
124 False [] range "[:digit:]-" in regex; marked by <-- HERE in m/[[:digit:]- <-- HERE b]/ at - line 10.
125 False [] range "[:alpha:]-" in regex; marked by <-- HERE in m/[[:alpha:]- <-- HERE [:digit:]]/ at - line 11.
126 False [] range "[:digit:]-" in regex; marked by <-- HERE in m/[[:digit:]- <-- HERE [:alpha:]]/ at - line 12.
127 ########
128 # regcomp.c [S_regclassutf8]
129 BEGIN {
130     if (ord("\t") == 5) {
131         print "SKIPPED\n# ebcdic regular expression ranges differ.";
132         exit 0;
133     }
134 }
135 use utf8;
136 $_ = "";
137 use warnings 'regexp' ;
138 /[a-b]/;
139 /[a-\d]/;
140 /[\d-b]/;
141 /[\s-\d]/;
142 /[\d-\s]/;
143 /[a-[:digit:]]/;
144 /[[:digit:]-b]/;
145 /[[:alpha:]-[:digit:]]/;
146 /[[:digit:]-[:alpha:]]/;
147 no warnings 'regexp' ;
148 /[a-b]/;
149 /[a-\d]/;
150 /[\d-b]/;
151 /[\s-\d]/;
152 /[\d-\s]/;
153 /[a-[:digit:]]/;
154 /[[:digit:]-b]/;
155 /[[:alpha:]-[:digit:]]/;
156 /[[:digit:]-[:alpha:]]/;
157 EXPECT
158 False [] range "a-\d" in regex; marked by <-- HERE in m/[a-\d <-- HERE ]/ at - line 12.
159 False [] range "\d-" in regex; marked by <-- HERE in m/[\d- <-- HERE b]/ at - line 13.
160 False [] range "\s-" in regex; marked by <-- HERE in m/[\s- <-- HERE \d]/ at - line 14.
161 False [] range "\d-" in regex; marked by <-- HERE in m/[\d- <-- HERE \s]/ at - line 15.
162 False [] range "a-[:digit:]" in regex; marked by <-- HERE in m/[a-[:digit:] <-- HERE ]/ at - line 16.
163 False [] range "[:digit:]-" in regex; marked by <-- HERE in m/[[:digit:]- <-- HERE b]/ at - line 17.
164 False [] range "[:alpha:]-" in regex; marked by <-- HERE in m/[[:alpha:]- <-- HERE [:digit:]]/ at - line 18.
165 False [] range "[:digit:]-" in regex; marked by <-- HERE in m/[[:digit:]- <-- HERE [:alpha:]]/ at - line 19.
166 ########
167 # regcomp.c [S_regclass S_regclassutf8]
168 use warnings 'regexp' ;
169 $a =~ /[a\zb]/ ;
170 no warnings 'regexp' ;
171 $a =~ /[a\zb]/ ;
172 EXPECT
173 Unrecognized escape \z in character class passed through in regex; marked by <-- HERE in m/[a\z <-- HERE b]/ at - line 3.
174
175 ########
176 # regcomp.c [S_study_chunk]
177 use warnings 'deprecated' ;
178 $a = "xx" ;
179 $a =~ /(?p{'x'})/ ;
180 no warnings ;
181 use warnings 'regexp' ;
182 $a =~ /(?p{'x'})/ ;
183 use warnings;
184 no warnings 'deprecated' ;
185 no warnings 'regexp' ;
186 $a =~ /(?p{'x'})/ ;
187 EXPECT
188 (?p{}) is deprecated - use (??{}) in regex; marked by <-- HERE in m/(?p <-- HERE {'x'})/ at - line 4.
189 (?p{}) is deprecated - use (??{}) in regex; marked by <-- HERE in m/(?p <-- HERE {'x'})/ at - line 7.
190 ########
191 # regcomp.c [S_reg]
192 use warnings 'regexp' ;
193 $a = qr/(?c)/;
194 $a = qr/(?-c)/;
195 $a = qr/(?g)/;
196 $a = qr/(?-g)/;
197 $a = qr/(?o)/;
198 $a = qr/(?-o)/;
199 $a = qr/(?g-o)/;
200 $a = qr/(?g-c)/;
201 $a = qr/(?o-cg)/;  # (?c) means (?g) error won't be thrown
202 $a = qr/(?ogc)/;
203 no warnings 'regexp' ;
204 $a = qr/(?c)/;
205 $a = qr/(?-c)/;
206 $a = qr/(?g)/;
207 $a = qr/(?-g)/;
208 $a = qr/(?o)/;
209 $a = qr/(?-o)/;
210 $a = qr/(?g-o)/;
211 $a = qr/(?g-c)/;
212 $a = qr/(?o-cg)/;  # (?c) means (?g) error won't be thrown
213 $a = qr/(?ogc)/;
214 #EXPECT
215 EXPECT
216 Useless (?c) - use /gc modifier in regex; marked by <-- HERE in m/(?c <-- HERE )/ at - line 3.
217 Useless (?-c) - don't use /gc modifier in regex; marked by <-- HERE in m/(?-c <-- HERE )/ at - line 4.
218 Useless (?g) - use /g modifier in regex; marked by <-- HERE in m/(?g <-- HERE )/ at - line 5.
219 Useless (?-g) - don't use /g modifier in regex; marked by <-- HERE in m/(?-g <-- HERE )/ at - line 6.
220 Useless (?o) - use /o modifier in regex; marked by <-- HERE in m/(?o <-- HERE )/ at - line 7.
221 Useless (?-o) - don't use /o modifier in regex; marked by <-- HERE in m/(?-o <-- HERE )/ at - line 8.
222 Useless (?g) - use /g modifier in regex; marked by <-- HERE in m/(?g <-- HERE -o)/ at - line 9.
223 Useless (?-o) - don't use /o modifier in regex; marked by <-- HERE in m/(?g-o <-- HERE )/ at - line 9.
224 Useless (?g) - use /g modifier in regex; marked by <-- HERE in m/(?g <-- HERE -c)/ at - line 10.
225 Useless (?-c) - don't use /gc modifier in regex; marked by <-- HERE in m/(?g-c <-- HERE )/ at - line 10.
226 Useless (?o) - use /o modifier in regex; marked by <-- HERE in m/(?o <-- HERE -cg)/ at - line 11.
227 Useless (?-c) - don't use /gc modifier in regex; marked by <-- HERE in m/(?o-c <-- HERE g)/ at - line 11.
228 Useless (?o) - use /o modifier in regex; marked by <-- HERE in m/(?o <-- HERE gc)/ at - line 12.
229 Useless (?g) - use /g modifier in regex; marked by <-- HERE in m/(?og <-- HERE c)/ at - line 12.
230 Useless (?c) - use /gc modifier in regex; marked by <-- HERE in m/(?ogc <-- HERE )/ at - line 12.