From ab98db9aeab2186fab7b1c552cb1262550da9146 Mon Sep 17 00:00:00 2001 From: Matthew Khouzam Date: Tue, 3 Dec 2013 16:41:41 -0500 Subject: [PATCH] ctf: Improve int decoding in IOStructGen Now handles "0x10" and "010" better, by using Long.decode() instead of Long.parseLong(). Change-Id: I25d9cd239063674d52a73f00b3f4af90e1ddff33 Signed-off-by: Matthew Khouzam Reviewed-on: https://git.eclipse.org/r/19272 Reviewed-by: Alexandre Montplaisir IP-Clean: Alexandre Montplaisir Tested-by: Hudson CI --- .../internal/ctf/core/event/metadata/IOStructGen.java | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/internal/ctf/core/event/metadata/IOStructGen.java b/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/internal/ctf/core/event/metadata/IOStructGen.java index ed4d4093c5..4150b9c54b 100644 --- a/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/internal/ctf/core/event/metadata/IOStructGen.java +++ b/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/internal/ctf/core/event/metadata/IOStructGen.java @@ -2070,7 +2070,6 @@ public class IOStructGen { private void parseVariantDeclaration(CommonTree declaration, VariantDeclaration variant) throws ParseException { - /* Get the type specifier list node */ CommonTree typeSpecifierListNode = (CommonTree) declaration.getFirstChildWithType(CTFParser.TYPE_SPECIFIER_LIST); @@ -2323,13 +2322,7 @@ public class IOStructGen { long intval; try { - if (unaryInteger.getType() == CTFParser.UNARY_EXPRESSION_DEC) { - intval = Long.parseLong(strval, 10); - } else if (unaryInteger.getType() == CTFParser.UNARY_EXPRESSION_HEX) { - intval = Long.parseLong(strval, 0x10); - } else { /* unaryInteger.getType() == CTFParser.UNARY_EXPRESSION_OCT */ - intval = Long.parseLong(strval, 010); // 010 == 0x08 == 8 - } + intval = Long.decode(strval); } catch (NumberFormatException e) { throw new ParseException("Invalid integer format: " + strval); //$NON-NLS-1$ } -- 2.34.1