From: Colin P. A. <co...@co...> - 2007-11-10 11:41:58
|
In this routine, if_subject_end is zero, and subject_start is 1, then the pre-condition of {KL_STRING_ROUTINES}.new_empty_string is violated. Accordingly, I have re-coded it to read: replace_all (a_replacement: STRING): STRING is -- Substring of `subject' between `subject_start' and `subject_end' -- where the whole matched string has been repeatedly replaced by -- `a_replacement'; All occurrences of \n\ in `a_replacement' will -- have been replaced by the corresponding n-th captured substrings -- if any require is_matching: is_matching a_replacement_not_void: a_replacement /= Void same_type: ANY_.same_types (a_replacement, subject) do if subject_end = subject_start then Result := STRING_.new_empty_string (subject, subject_end - subject_start) append_replace_all_to_string (Result, a_replacement) else Result := subject end ensure all_matched: not has_matched replace_not_void: Result /= Void same_type: ANY_.same_types (Result, subject) end I don't know if that is the correct result to return, but I can't think of any other at the moment. -- Colin Adams Preston Lancashire |