Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0001333OCamlOCaml generalpublic2002-08-17 11:492002-08-19 11:13
Reporteradministrator 
Assigned To 
PrioritynormalSeverityminorReproducibilityalways
StatusclosedResolutionno change required 
PlatformOSOS Version
Product Version 
Target VersionFixed in Version 
Summary0001333: Str partial match problem
DescriptionFull_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";;

        Objective Caml version 3.05

# #use "regexp-bug.ml";;
val reg : Str.regexp = <abstr>
val test : Str.regexp -> string -> string * bool * int * bool = <fun>
- : string * bool * int * bool = ("aa", true, 1, true)
- : string * bool * int * bool = ("ab", true, 1, true)
#




TagsNo tags attached.
Attached Files

- Relationships

-  Notes
(0002557)
administrator (administrator)
2002-08-19 11:12

> 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.

- Xavier Leroy

(0002558)
administrator (administrator)
2002-08-19 11:13

Normal behavior of Str.string_partial_match.

- Issue History
Date Modified Username Field Change
2005-11-18 10:14 administrator New Issue


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker