You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Original bug ID: 923 Reporter: administrator Status: closed Resolution: fixed Priority: normal Severity: minor Category: ~DO NOT USE (was: OCaml general)
Bug description
Hi.
I have encountered strange problem using Str module. Quite simple
patterns fail on long (10240 characters) strings.
By failure I mean that Failure("Str.string_match") exception is raised.
If this is a known issue, maybe it should be noted in the documentation.
let testre s r =
let prn msg = Printf.printf "%-16s: %s\n" r msg in
let re = Str.regexp r in
try
let (_ : bool) = Str.string_match re s 0 in
prn "OK"
with
_ ->
prn "FAILURE"
let testsize n =
Printf.printf "\nString length: %d\n\n" n;
List.iter (testre (String.make n 'a')) regexps
let () = List.iter testsize [ 10239 ; 10240 ; ]
(*************)
With ocaml-3.04 on x86 and alpha I get the following results:
String length: 10239
.+ : OK
^.+ : OK
.+$ : OK
^.+$ : OK
.* : OK
^.* : OK
.$ : OK
^.$ : OK
[^ ]* : OK
[^ ]* [^ ] : OK
String length: 10240
.+ : OK
^.+ : OK
.+$ : FAILURE
^.+$ : FAILURE
.* : OK
^.* : OK
.$ : FAILURE
^.$ : FAILURE
[^ ]* : OK
[^ ]* [^ ] : FAILURE
Original bug ID: 923
Reporter: administrator
Status: closed
Resolution: fixed
Priority: normal
Severity: minor
Category: ~DO NOT USE (was: OCaml general)
Bug description
Hi.
I have encountered strange problem using Str module. Quite simple
patterns fail on long (10240 characters) strings.
By failure I mean that Failure("Str.string_match") exception is raised.
If this is a known issue, maybe it should be noted in the documentation.
Following code will help reproduce the error.
(*************)
let regexps = [
".+" ; "^.+" ; ".+$" ; "^.+$" ; "." ; "^." ; ".$" ; "^.$" ; "[^ ]" ;
"[^ ] [^ ]" ;
]
let testre s r =
let prn msg = Printf.printf "%-16s: %s\n" r msg in
let re = Str.regexp r in
try
let (_ : bool) = Str.string_match re s 0 in
prn "OK"
with
_ ->
prn "FAILURE"
let testsize n =
Printf.printf "\nString length: %d\n\n" n;
List.iter (testre (String.make n 'a')) regexps
let () = List.iter testsize [ 10239 ; 10240 ; ]
(*************)
With ocaml-3.04 on x86 and alpha I get the following results:
String length: 10239
.+ : OK
^.+ : OK
.+$ : OK
^.+$ : OK
.* : OK
^.* : OK
.$ : OK
^.$ : OK
[^ ]* : OK
[^ ]* [^ ] : OK
String length: 10240
.+ : OK
^.+ : OK
.+$ : FAILURE
^.+$ : FAILURE
.* : OK
^.* : OK
.$ : FAILURE
^.$ : FAILURE
[^ ]* : OK
[^ ]* [^ ] : FAILURE
best regards,
tom
--
.-. Tomasz Zielonka CYBER SERVICE
oo| programista http://www.cs.net.pl
/`'\ zielony@cs.net.pl
(_;/) tel: [48] (22) 723-06-79 | tel/fax: [48] (22) 723-01-75
The text was updated successfully, but these errors were encountered: