[Ooc-checkins] ooc2/lib/src/Object BigInt.Mod,1.7,1.8
Brought to you by:
mva
From: Michael v. A. <mv...@us...> - 2005-01-18 09:26:45
|
Update of /cvsroot/ooc/ooc2/lib/src/Object In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12530 Modified Files: BigInt.Mod Log Message: (NewLatin1Region) Return NIL if there is a syntax error. Index: BigInt.Mod =================================================================== RCS file: /cvsroot/ooc/ooc2/lib/src/Object/BigInt.Mod,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- BigInt.Mod 23 May 2004 18:25:26 -0000 1.7 +++ BigInt.Mod 18 Jan 2005 09:26:34 -0000 1.8 @@ -1,7 +1,7 @@ (* $Id$ *) MODULE Object:BigInt [OOC_EXTENSIONS]; (* Implements integer values of arbitrary magnitude. - Copyright (C) 2002-2004 Michael van Acken + Copyright (C) 2002-2005 Michael van Acken This module is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License @@ -794,9 +794,12 @@ RETURN a.Format(10); END ToString; -PROCEDURE NewLatin1Region* (str[NO_COPY]: ARRAY OF CHAR; start, end: LONGINT; - inputBase: LONGINT): BigInt; -(* @precond +PROCEDURE NewLatin1Region*(str[NO_COPY]: ARRAY OF CHAR; start, end: LONGINT; + inputBase: LONGINT): BigInt; +(**Result is @code{NIL} if the string interval does not match the syntax for + integer numbers. + + @precond @samp{@oparam{start} <= @oparam{end}} @end precond *) VAR @@ -832,13 +835,19 @@ ELSIF (d >= ORD("A")) THEN DEC(d, ORD("A")-10); END; - ASSERT((d >= 0) & (d < base)); - z := MulAdd1(z, SHORT(inputBase), SHORT(d)); + IF ((d >= 0) & (d < base)) THEN + z := MulAdd1(z, SHORT(inputBase), SHORT(d)); + ELSE (* error: bail out *) + RETURN NIL; + END; INC (start); END; z.size := sign*z.size; - ASSERT(start # firstDigit); - RETURN z; + IF (start # firstDigit) THEN + RETURN z; + ELSE (* no digits, then no number *) + RETURN NIL; + END; END NewLatin1Region; PROCEDURE NewLatin1* (str[NO_COPY]: ARRAY OF CHAR; inputBase: LONGINT): BigInt; |