[m-rev.] Trivial diff: bugfix for string.base_string_to_int
Ralph Becket
rafe at cs.mu.OZ.AU
Thu Jul 1 11:36:55 AEST 2004
Estimated hours taken: 0.1
Branches: main
Fixed a bug in string.base_string_to_int/3.
library/string.m:
Bugfix for string.base_string_to_int/3 (and consequently
string.to_int/2 and string.det_to_int/1) preventing the strings "+" and
"-" being interpreted as 0. string.base_string_to_int/3 now requires
the string to contain at least one digit.
I accidentally checked this on in before taking a diff, but the change
is to add the two `Len > 1' subgoals:
string__base_string_to_int(Base, String, Int) :-
string__index(String, 0, Char),
Len = string__length(String),
( Char = ('-') ->
Len > 1,
foldl_substring(accumulate_int(Base), String, 1, Len - 1, 0, N),
Int = -N
; Char = ('+') ->
Len > 1,
foldl_substring(accumulate_int(Base), String, 1, Len - 1, 0, N),
Int = N
;
foldl_substring(accumulate_int(Base), String, 0, Len, 0, N),
Int = N
).
-- Ralph
--------------------------------------------------------------------------
mercury-reviews mailing list
post: mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------
More information about the reviews
mailing list