Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Str matching fails on long strings #3218

Closed
vicuna opened this issue Feb 24, 2002 · 1 comment
Closed

Str matching fails on long strings #3218

vicuna opened this issue Feb 24, 2002 · 1 comment
Labels

Comments

@vicuna
Copy link

vicuna commented Feb 24, 2002

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

@vicuna
Copy link
Author

vicuna commented Dec 14, 2002

Comment author: administrator

Works OK with the new implementation of Str (2002-12-13, XL)

@vicuna vicuna closed this as completed Dec 14, 2002
@vicuna vicuna added the bug label Mar 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant