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: 1333 Reporter: administrator Status: closed Resolution: not a bug Priority: normal Severity: minor Category: ~DO NOT USE (was: OCaml general)
Str.string_partial_match returns true whenever Str.string_match succeeds on a
starting sub-string. This can mask the failure of string_partial_match, making
it impossible to detect a partial match in all cases.
Code example:
(* problem with partial matching of a regular expression *)
#load "str.cma";;
let reg = Str.regexp "a\(bc\)";; ( a, abc, abcbc, ... *)
let test reg str =
str, (Str.string_match reg str 0), Str.match_end (), (Str.string_partial_match
reg str 0);;
(* Both aa and ab return the same results. ab is a partial match but aa is not
*)
test reg "aa";;
test reg "ab";;
Objective Caml version 3.05
#use "regexp-bug.ml";;
val reg : Str.regexp =
val test : Str.regexp -> string -> string * bool * int * bool =
Str.string_partial_match returns true whenever Str.string_match
succeeds on a starting sub-string. This can mask the failure of
string_partial_match, making it impossible to detect a partial match
in all cases.
string_partial_match is a weird operation, and will probably be
removed in the future. This said, I'm afraid there is a
misunderstanding on its specification. Basically,
Str.string_partial_match re txt ofs
succeeds if and only if there exists a string "suff" such that
Str.string_match re (txt ^ suff) ofs
succeeds.
It follows that string_partial_match will always succeed when
string_match succeeds -- which is the case in your "aa" and "ab"
examples.
Original bug ID: 1333
Reporter: administrator
Status: closed
Resolution: not a bug
Priority: normal
Severity: minor
Category: ~DO NOT USE (was: OCaml general)
Bug description
Full_Name: Gene Saunders
Version: 3.05
OS: Windows 2000
Submission from: curie.noos.net (212.198.0.93)
Str.string_partial_match returns true whenever Str.string_match succeeds on a
starting sub-string. This can mask the failure of string_partial_match, making
it impossible to detect a partial match in all cases.
Code example:
(* problem with partial matching of a regular expression *)
#load "str.cma";;
let reg = Str.regexp "a\(bc\)";; ( a, abc, abcbc, ... *)
let test reg str =
str, (Str.string_match reg str 0), Str.match_end (), (Str.string_partial_match
reg str 0);;
(* Both aa and ab return the same results. ab is a partial match but aa is not
*)
test reg "aa";;
test reg "ab";;
#use "regexp-bug.ml";;
val reg : Str.regexp =
val test : Str.regexp -> string -> string * bool * int * bool =
The text was updated successfully, but these errors were encountered: