xref: /onnv-gate/usr/src/cmd/perl/5.8.4/distrib/t/lib/warnings/regcomp (revision 0:68f95e015346)
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] belongs inside character classes	[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]
42use warnings 'regexp' ;
43my $a = "ABC123" ;
44$a =~ /(?=a)*/ ;
45no warnings 'regexp' ;
46$a =~ /(?=a)*/ ;
47EXPECT
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' ;
52use warnings 'regexp' ;
53$a =~ /a$x/ ;
54no warnings 'regexp' ;
55$a =~ /a$x/ ;
56EXPECT
57Unrecognized 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#
61use warnings 'regexp' ;
62$_ = "" ;
63/[:alpha:]/;
64/[:zog:]/;
65no warnings 'regexp' ;
66/[:alpha:]/;
67/[:zog:]/;
68EXPECT
69POSIX syntax [: :] belongs inside character classes in regex; marked by <-- HERE in m/[:alpha:] <-- HERE / at - line 5.
70POSIX syntax [: :] belongs inside character classes in regex; marked by <-- HERE in m/[:zog:] <-- HERE / at - line 6.
71########
72# regcomp.c [S_checkposixcc]
73#
74use warnings 'regexp' ;
75$_ = "" ;
76/[.zog.]/;
77no warnings 'regexp' ;
78/[.zog.]/;
79EXPECT
80POSIX syntax [. .] belongs inside character classes in regex; marked by <-- HERE in m/[.zog.] <-- HERE / at - line 5.
81POSIX syntax [. .] is reserved for future extensions in regex; marked by <-- HERE in m/[.zog.] <-- HERE / at - line 5.
82########
83# regcomp.c [S_regclass]
84$_ = "";
85use warnings 'regexp' ;
86/[a-b]/;
87/[a-\d]/;
88/[\d-b]/;
89/[\s-\d]/;
90/[\d-\s]/;
91/[a-[:digit:]]/;
92/[[:digit:]-b]/;
93/[[:alpha:]-[:digit:]]/;
94/[[:digit:]-[:alpha:]]/;
95no warnings 'regexp' ;
96/[a-b]/;
97/[a-\d]/;
98/[\d-b]/;
99/[\s-\d]/;
100/[\d-\s]/;
101/[a-[:digit:]]/;
102/[[:digit:]-b]/;
103/[[:alpha:]-[:digit:]]/;
104/[[:digit:]-[:alpha:]]/;
105EXPECT
106False [] range "a-\d" in regex; marked by <-- HERE in m/[a-\d <-- HERE ]/ at - line 5.
107False [] range "\d-" in regex; marked by <-- HERE in m/[\d- <-- HERE b]/ at - line 6.
108False [] range "\s-" in regex; marked by <-- HERE in m/[\s- <-- HERE \d]/ at - line 7.
109False [] range "\d-" in regex; marked by <-- HERE in m/[\d- <-- HERE \s]/ at - line 8.
110False [] range "a-[:digit:]" in regex; marked by <-- HERE in m/[a-[:digit:] <-- HERE ]/ at - line 9.
111False [] range "[:digit:]-" in regex; marked by <-- HERE in m/[[:digit:]- <-- HERE b]/ at - line 10.
112False [] range "[:alpha:]-" in regex; marked by <-- HERE in m/[[:alpha:]- <-- HERE [:digit:]]/ at - line 11.
113False [] range "[:digit:]-" in regex; marked by <-- HERE in m/[[:digit:]- <-- HERE [:alpha:]]/ at - line 12.
114########
115# regcomp.c [S_regclassutf8]
116BEGIN {
117    if (ord("\t") == 5) {
118        print "SKIPPED\n# ebcdic regular expression ranges differ.";
119        exit 0;
120    }
121}
122use utf8;
123$_ = "";
124use warnings 'regexp' ;
125/[a-b]/;
126/[a-\d]/;
127/[\d-b]/;
128/[\s-\d]/;
129/[\d-\s]/;
130/[a-[:digit:]]/;
131/[[:digit:]-b]/;
132/[[:alpha:]-[:digit:]]/;
133/[[:digit:]-[:alpha:]]/;
134no warnings 'regexp' ;
135/[a-b]/;
136/[a-\d]/;
137/[\d-b]/;
138/[\s-\d]/;
139/[\d-\s]/;
140/[a-[:digit:]]/;
141/[[:digit:]-b]/;
142/[[:alpha:]-[:digit:]]/;
143/[[:digit:]-[:alpha:]]/;
144EXPECT
145False [] range "a-\d" in regex; marked by <-- HERE in m/[a-\d <-- HERE ]/ at - line 12.
146False [] range "\d-" in regex; marked by <-- HERE in m/[\d- <-- HERE b]/ at - line 13.
147False [] range "\s-" in regex; marked by <-- HERE in m/[\s- <-- HERE \d]/ at - line 14.
148False [] range "\d-" in regex; marked by <-- HERE in m/[\d- <-- HERE \s]/ at - line 15.
149False [] range "a-[:digit:]" in regex; marked by <-- HERE in m/[a-[:digit:] <-- HERE ]/ at - line 16.
150False [] range "[:digit:]-" in regex; marked by <-- HERE in m/[[:digit:]- <-- HERE b]/ at - line 17.
151False [] range "[:alpha:]-" in regex; marked by <-- HERE in m/[[:alpha:]- <-- HERE [:digit:]]/ at - line 18.
152False [] range "[:digit:]-" in regex; marked by <-- HERE in m/[[:digit:]- <-- HERE [:alpha:]]/ at - line 19.
153########
154# regcomp.c [S_regclass S_regclassutf8]
155use warnings 'regexp' ;
156$a =~ /[a\zb]/ ;
157no warnings 'regexp' ;
158$a =~ /[a\zb]/ ;
159EXPECT
160Unrecognized escape \z in character class passed through in regex; marked by <-- HERE in m/[a\z <-- HERE b]/ at - line 3.
161
162########
163# regcomp.c [S_study_chunk]
164use warnings 'deprecated' ;
165$a = "xx" ;
166$a =~ /(?p{'x'})/ ;
167no warnings ;
168use warnings 'regexp' ;
169$a =~ /(?p{'x'})/ ;
170use warnings;
171no warnings 'deprecated' ;
172no warnings 'regexp' ;
173no warnings 'syntax' ;
174$a =~ /(?p{'x'})/ ;
175EXPECT
176(?p{}) is deprecated - use (??{}) in regex; marked by <-- HERE in m/(?p <-- HERE {'x'})/ at - line 4.
177(?p{}) is deprecated - use (??{}) in regex; marked by <-- HERE in m/(?p <-- HERE {'x'})/ at - line 7.
178########
179# regcomp.c [S_reg]
180use warnings 'regexp' ;
181$a = qr/(?c)/;
182$a = qr/(?-c)/;
183$a = qr/(?g)/;
184$a = qr/(?-g)/;
185$a = qr/(?o)/;
186$a = qr/(?-o)/;
187$a = qr/(?g-o)/;
188$a = qr/(?g-c)/;
189$a = qr/(?o-cg)/;  # (?c) means (?g) error won't be thrown
190$a = qr/(?ogc)/;
191no warnings 'regexp' ;
192$a = qr/(?c)/;
193$a = qr/(?-c)/;
194$a = qr/(?g)/;
195$a = qr/(?-g)/;
196$a = qr/(?o)/;
197$a = qr/(?-o)/;
198$a = qr/(?g-o)/;
199$a = qr/(?g-c)/;
200$a = qr/(?o-cg)/;  # (?c) means (?g) error won't be thrown
201$a = qr/(?ogc)/;
202#EXPECT
203EXPECT
204Useless (?c) - use /gc modifier in regex; marked by <-- HERE in m/(?c <-- HERE )/ at - line 3.
205Useless (?-c) - don't use /gc modifier in regex; marked by <-- HERE in m/(?-c <-- HERE )/ at - line 4.
206Useless (?g) - use /g modifier in regex; marked by <-- HERE in m/(?g <-- HERE )/ at - line 5.
207Useless (?-g) - don't use /g modifier in regex; marked by <-- HERE in m/(?-g <-- HERE )/ at - line 6.
208Useless (?o) - use /o modifier in regex; marked by <-- HERE in m/(?o <-- HERE )/ at - line 7.
209Useless (?-o) - don't use /o modifier in regex; marked by <-- HERE in m/(?-o <-- HERE )/ at - line 8.
210Useless (?g) - use /g modifier in regex; marked by <-- HERE in m/(?g <-- HERE -o)/ at - line 9.
211Useless (?-o) - don't use /o modifier in regex; marked by <-- HERE in m/(?g-o <-- HERE )/ at - line 9.
212Useless (?g) - use /g modifier in regex; marked by <-- HERE in m/(?g <-- HERE -c)/ at - line 10.
213Useless (?-c) - don't use /gc modifier in regex; marked by <-- HERE in m/(?g-c <-- HERE )/ at - line 10.
214Useless (?o) - use /o modifier in regex; marked by <-- HERE in m/(?o <-- HERE -cg)/ at - line 11.
215Useless (?-c) - don't use /gc modifier in regex; marked by <-- HERE in m/(?o-c <-- HERE g)/ at - line 11.
216Useless (?o) - use /o modifier in regex; marked by <-- HERE in m/(?o <-- HERE gc)/ at - line 12.
217Useless (?g) - use /g modifier in regex; marked by <-- HERE in m/(?og <-- HERE c)/ at - line 12.
218Useless (?c) - use /gc modifier in regex; marked by <-- HERE in m/(?ogc <-- HERE )/ at - line 12.
219