Skip to content

Commit

Permalink
fix: Value search not supporting negative or hex values
Browse files Browse the repository at this point in the history
  • Loading branch information
Col-E committed Dec 23, 2020
1 parent b61a54e commit 5c76e78
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<groupId>me.coley</groupId>
<artifactId>recaf</artifactId>
<url>https://github.com/Col-E/Recaf/</url>
<version>2.16.3</version>
<version>2.16.4</version>
<name>Recaf</name>
<description>A modern java bytecode editor</description>
<!-- Variables -->
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/me/coley/recaf/Recaf.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
19 changes: 15 additions & 4 deletions src/main/java/me/coley/recaf/ui/controls/NumericText.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

0 comments on commit 5c76e78

Please sign in to comment.