summaryrefslogtreecommitdiff
path: root/t/lib/warnings/regexec
blob: 6635142dea80488cba6593870f39ab77a787fcbc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
  regexec.c	

  This test generates "bad free" warnings when run under
  PERL_DESTRUCT_LEVEL.  This file merely serves as a placeholder
  for investigation.

  Complex regular subexpression recursion limit (%d) exceeded

        $_ = 'a' x (2**15+1); /^()(a\1)*$/ ;
  Complex regular subexpression recursion limit (%d) exceeded

        $_ = 'a' x (2**15+1); /^()(a\1)*?$/ ;

  (The actual value substituted for %d is masked in the tests so that
  REG_INFTY configuration variable value does not affect outcome.)
__END__
# regexec.c
print("SKIPPED\n# most systems run into stacksize limits\n"),exit;
use warnings 'regexp' ;
$SIG{__WARN__} = sub{local ($m) = shift;
                 $m =~ s/\(\d+\)/(*MASKED*)/;
                 print STDERR $m};
$_ = 'a' x (2**15+1); 
/^()(a\1)*$/ ;
#
# If this test fails with a segmentation violation or similar,
# you may have to increase the default stacksize limit in your
# shell.  You may need superuser privileges.
#
# Under the sh, ksh, zsh:
#    $ ulimit -s
#    8192
#    $ ulimit -s 16000
#
# Under the csh:
#    % limit stacksize
#    stacksize        8192 kbytes
#    % limit stacksize 16000
#
EXPECT
Complex regular subexpression recursion limit (*MASKED*) exceeded at - line 9.
########
# regexec.c
print("SKIPPED\n# most systems run into stacksize limits\n"),exit;
no warnings 'regexp' ;
$SIG{__WARN__} = sub{local ($m) = shift;
                 $m =~ s/\(\d+\)/(*MASKED*)/;
                 print STDERR $m};
$_ = 'a' x (2**15+1); 
/^()(a\1)*$/ ;
#
# If this test fails with a segmentation violation or similar,
# you may have to increase the default stacksize limit in your
# shell.  You may need superuser privileges.
#
# Under the sh, ksh, zsh:
#    $ ulimit -s
#    8192
#    $ ulimit -s 16000
#
# Under the csh:
#    % limit stacksize
#    stacksize        8192 kbytes
#    % limit stacksize 16000
#
EXPECT

########
# regexec.c
print("SKIPPED\n# most systems run into stacksize limits\n"),exit;
use warnings 'regexp' ;
$SIG{__WARN__} = sub{local ($m) = shift;
                 $m =~ s/\(\d+\)/(*MASKED*)/;
                 print STDERR $m};
$_ = 'a' x (2**15+1);
/^()(a\1)*?$/ ;
#
# If this test fails with a segmentation violation or similar,
# you may have to increase the default stacksize limit in your
# shell.  You may need superuser privileges.
#
# Under the sh, ksh, zsh:
#    $ ulimit -s
#    8192
#    $ ulimit -s 16000
#
# Under the csh:
#    % limit stacksize
#    stacksize        8192 kbytes
#    % limit stacksize 16000
#
EXPECT
Complex regular subexpression recursion limit (*MASKED*) exceeded at - line 9.
########
# regexec.c
print("SKIPPED\n# most systems run into stacksize limits\n"),exit;
no warnings 'regexp' ;
$SIG{__WARN__} = sub{local ($m) = shift;
                 $m =~ s/\(\d+\)/(*MASKED*)/;
                 print STDERR $m};
$_ = 'a' x (2**15+1);
/^()(a\1)*?$/ ;
#
# If this test fails with a segmentation violation or similar,
# you may have to increase the default stacksize limit in your
# shell.  You may need superuser privileges.
#
# Under the sh, ksh, zsh:
#    $ ulimit -s
#    8192
#    $ ulimit -s 16000
#
# Under the csh:
#    % limit stacksize
#    stacksize        8192 kbytes
#    % limit stacksize 16000
#
EXPECT

########
# NAME Wide character in non-UTF-8 locale
require '../loc_tools.pl';
unless (locales_enabled()) {
    print("SKIPPED\n# locales not available\n"),exit;
}
eval { require POSIX; POSIX->import("locale_h") };
if ($@) {
    print("SKIPPED\n# no POSIX\n"),exit;
}
use warnings 'locale';
use locale;
setlocale(&POSIX::LC_CTYPE, "C");
"\x{100}" =~ /\x{100}|\x{101}/il;
"\x{100}" =~ /\x{100}|\x{101}/l;
"\x{100}" =~ /\w/l;
"\x{100}" =~ /\x{100}+/l;
"\x{100}" =~ /[\x{100}\x{102}]/l;
no warnings 'locale';
EXPECT
Wide character (U+100) in pattern match (m//) at - line 12.
Wide character (U+100) in pattern match (m//) at - line 12.
Wide character (U+100) in pattern match (m//) at - line 13.
Wide character (U+100) in pattern match (m//) at - line 13.
Wide character (U+100) in pattern match (m//) at - line 13.
Wide character (U+100) in pattern match (m//) at - line 14.
Wide character (U+100) in pattern match (m//) at - line 14.
Wide character (U+100) in pattern match (m//) at - line 15.
Wide character (U+100) in pattern match (m//) at - line 16.
Wide character (U+100) in pattern match (m//) at - line 16.
########
# NAME Wide character in UTF-8 locale
require '../loc_tools.pl';
unless (locales_enabled()) {
    print("SKIPPED\n# locales not available\n"),exit;
}
eval { require POSIX; POSIX->import("locale_h") };
if ($@) {
    print("SKIPPED\n# no POSIX\n"),exit;
}
my @utf8_locales = find_utf8_ctype_locale();
unless (@utf8_locales) {
    print("SKIPPED\n# no UTF-8 locales\n"),exit;
}
use warnings 'locale';
use locale;
setlocale(&POSIX::LC_CTYPE, $utf8_locales[0]);
"\x{100}" =~ /\x{100}|\x{101}/il;
"\x{100}" =~ /\x{100}|\x{101}/l;
"\x{100}" =~ /\w/l;
"\x{100}" =~ /\x{100}+/l;
"\x{100}" =~ /[\x{100}\x{102}]/l;
EXPECT
########
# NAME \b{} in non-UTF-8 locale
eval { require POSIX; POSIX->import("locale_h") };
if ($@) {
    print("SKIPPED\n# no POSIX\n"),exit;
}
use warnings 'locale';
use locale;
setlocale(&POSIX::LC_CTYPE, "C");
"a" =~ /\b{gcb}/l;
no warnings 'locale';
"a" =~ /\b{gcb}/l;
EXPECT
Use of \b{} or \B{} for non-UTF-8 locale is wrong.  Assuming a UTF-8 locale at - line 8.
Use of \b{} or \B{} for non-UTF-8 locale is wrong.  Assuming a UTF-8 locale at - line 8.
########
# NAME \b{} in UTF-8 locale
require '../loc_tools.pl';
unless (locales_enabled()) {
    print("SKIPPED\n# locales not available\n"),exit;
}
eval { require POSIX; POSIX->import("locale_h") };
if ($@) {
    print("SKIPPED\n# no POSIX\n"),exit;
}
my $utf8_locale = find_utf8_ctype_locale();
unless ($utf8_locale) {
    print("SKIPPED\n# No UTF-8 locale available\n"),exit;
}
use warnings 'locale';
use locale;
setlocale(&POSIX::LC_CTYPE, "C");
 "abc def" =~ /\b{wb}.*?/;
 "abc def" =~ /\B{wb}.*?/;
setlocale(&POSIX::LC_CTYPE, $utf8_locale);
 "abc def" =~ /\b{wb}.*?/;
 "abc def" =~ /\B{wb}.*?/;
EXPECT
Use of \b{} or \B{} for non-UTF-8 locale is wrong.  Assuming a UTF-8 locale at - line 16.
Use of \b{} or \B{} for non-UTF-8 locale is wrong.  Assuming a UTF-8 locale at - line 16.
Use of \b{} or \B{} for non-UTF-8 locale is wrong.  Assuming a UTF-8 locale at - line 17.
Use of \b{} or \B{} for non-UTF-8 locale is wrong.  Assuming a UTF-8 locale at - line 17.
Use of \b{} or \B{} for non-UTF-8 locale is wrong.  Assuming a UTF-8 locale at - line 17.
########
# NAME (?[ ]) in non-UTF-8 locale
eval { require POSIX; POSIX->import("locale_h") };
if ($@) {
    print("SKIPPED\n# no POSIX\n"),exit;
}
no warnings 'experimental::regex_sets';
use warnings 'locale';
use locale;
setlocale(&POSIX::LC_CTYPE, "C");
"\N{KELVIN SIGN}" =~ /(?[ \N{KELVIN SIGN} ])/i;
"K" =~ /(?[ \N{KELVIN SIGN} ])/i;
"k" =~ /(?[ \N{KELVIN SIGN} ])/i;
":" =~ /(?[ \: ])/;
no warnings 'locale';
EXPECT
Use of (?[ ]) for non-UTF-8 locale is wrong.  Assuming a UTF-8 locale at - line 9.
Use of (?[ ]) for non-UTF-8 locale is wrong.  Assuming a UTF-8 locale at - line 9.
Use of (?[ ]) for non-UTF-8 locale is wrong.  Assuming a UTF-8 locale at - line 10.
Use of (?[ ]) for non-UTF-8 locale is wrong.  Assuming a UTF-8 locale at - line 10.
Use of (?[ ]) for non-UTF-8 locale is wrong.  Assuming a UTF-8 locale at - line 11.
Use of (?[ ]) for non-UTF-8 locale is wrong.  Assuming a UTF-8 locale at - line 11.
Use of (?[ ]) for non-UTF-8 locale is wrong.  Assuming a UTF-8 locale at - line 12.
Use of (?[ ]) for non-UTF-8 locale is wrong.  Assuming a UTF-8 locale at - line 12.
########
# NAME (?[ ]) in UTF-8 locale
require '../loc_tools.pl';
unless (locales_enabled()) {
    print("SKIPPED\n# locales not available\n"),exit;
}
eval { require POSIX; POSIX->import("locale_h") };
if ($@) {
    print("SKIPPED\n# no POSIX\n"),exit;
}
my $utf8_locale = find_utf8_ctype_locale();
unless ($utf8_locale) {
    print("SKIPPED\n# No UTF-8 locale available\n"),exit;
}
no warnings 'experimental::regex_sets';
use warnings 'locale';
use locale;
setlocale(&POSIX::LC_CTYPE, $utf8_locale);
"\N{KELVIN SIGN}" =~ /(?[ \N{KELVIN SIGN} ])/i;
"K" =~ /(?[ \N{KELVIN SIGN} ])/i;
"k" =~ /(?[ \N{KELVIN SIGN} ])/i;
":" =~ /(?[ \: ])/;
EXPECT
########
# NAME perl #132063, read beyond buffer end
# OPTION fatal
"\xff" =~ /(?il)\x{100}|\x{100}/;
EXPECT
Malformed UTF-8 character: \xff (too short; 1 byte available, need 13) in pattern match (m//) at - line 2.
Malformed UTF-8 character (fatal) at - line 2.