parsing long primitives
Philippe Faes <Philippe.Faes-GoS/[email protected]> Tue, 09 Aug 2005 14:37:50 +0200
| Newsgroups | gmane.comp.java.beanshell.devel |
|---|---|
| Message-ID | <[email protected]> |
Hi,
In src/bsh/Parser.java it says:
<quote>
// This really should be Long.decode, but there isn't one. As a result,
// hex and octal literals ending in 'l' or 'L' don't work.
</quote>
But I've noticed that Long.decode has existed since 1.2
http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Long.html#decode
(java.lang.String)
I propose we use Long.decode instead of Integer.decode for long numbers.
Patch attached.
grtz
Ph
--
ir. Philippe Faes
Ghent University - Department ELIS
Sint-Pietersnieuwstraat 41 -- B-9000 Gent
Tel:+32 9 264 95 25 - Fax:+32 9 264 35 94
http://www.elis.UGent.be/~pfaes
ON5DEU -- LPIC1 -- gpg-key:173720B6
long_decode.patch
(text/x-patch, 636 B)
Index: src/bsh/Parser.java
===================================================================
--- src/bsh/Parser.java (revision 34)
+++ src/bsh/Parser.java (working copy)
@@ -2280,10 +2280,7 @@
if(ch == 'l' || ch == 'L')
{
literal = literal.substring(0,literal.length()-1);
-
- // This really should be Long.decode, but there isn't one. As a result,
- // hex and octal literals ending in 'l' or 'L' don't work.
- jjtn000.value = new Primitive( new Long( literal ).longValue() );
+ jjtn000.value = new Primitive( Long.decode(literal).longValue() );
}
else
try {