From 5c76e784a094df25af3d5884c4623de454bceea7 Mon Sep 17 00:00:00 2001 From: Col-E Date: Wed, 23 Dec 2020 03:19:52 -0500 Subject: [PATCH] fix: Value search not supporting negative or hex values --- pom.xml | 2 +- src/main/java/me/coley/recaf/Recaf.java | 2 +- .../coley/recaf/ui/controls/NumericText.java | 19 +++++++++++++++---- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/pom.xml b/pom.xml index 5e43d6336..ef3b4c3b1 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ me.coley recaf https://github.com/Col-E/Recaf/ - 2.16.3 + 2.16.4 Recaf A modern java bytecode editor diff --git a/src/main/java/me/coley/recaf/Recaf.java b/src/main/java/me/coley/recaf/Recaf.java index 4a0719125..a4cf7793b 100644 --- a/src/main/java/me/coley/recaf/Recaf.java +++ b/src/main/java/me/coley/recaf/Recaf.java @@ -30,7 +30,7 @@ * @author Matt */ public class Recaf { - public static final String VERSION = "2.16.3"; + public static final String VERSION = "2.16.4"; public static final String DOC_URL = "https://col-e.github.io/Recaf/documentation.html"; public static final int ASM_VERSION = Opcodes.ASM9; private static Controller currentController; diff --git a/src/main/java/me/coley/recaf/ui/controls/NumericText.java b/src/main/java/me/coley/recaf/ui/controls/NumericText.java index d4ab97600..b802d9b8f 100644 --- a/src/main/java/me/coley/recaf/ui/controls/NumericText.java +++ b/src/main/java/me/coley/recaf/ui/controls/NumericText.java @@ -13,17 +13,28 @@ public class NumericText extends TextField { */ public Number get() { String text = getText(); - if(text.matches("\\d+")) + // Normal int + if(text.matches("-?\\d+")) return Integer.parseInt(text); - else if(text.matches("\\d+\\.?\\d*[dD]?")) { + // Double + else if(text.matches("-?\\d+\\.?\\d*[dD]?")) { if(text.toLowerCase().contains("d")) return Double.parseDouble(text.substring(0, text.length() - 1)); else return Double.parseDouble(text); - } else if(text.matches("\\d+\\.?\\d*[fF]")) + } + // Float + else if(text.matches("-?\\d+\\.?\\d*[fF]")) return Float.parseFloat(text.substring(0, text.length() - 1)); - else if(text.matches("\\d+\\.?\\d*[lL]")) + // Long + else if(text.matches("-?\\d+\\.?\\d*[lL]")) return Long.parseLong(text.substring(0, text.length() - 1)); + // Hex int + else if(text.matches("-?0x\\d+")) + return (int) Long.parseLong(text.replace("0x", ""), 16); + // Hex long + else if(text.matches("-?0x\\d+[lL]")) + return Long.parseLong(text.substring(0, text.length() - 1).replace("0x", ""), 16); return null; } }