Formatting, fix some bugs

This commit is contained in:
Maschell 2019-11-22 11:49:20 +01:00
parent d1819ad7c1
commit 64d89ee4a5

View File

@ -8,10 +8,6 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
/**
* Hello world!
*
*/
public class App { public class App {
static String[] templatePrefixes = new String[] { "tm", "ps", "pt" /* XXX from libiberty cplus-dem.c */ }; static String[] templatePrefixes = new String[] { "tm", "ps", "pt" /* XXX from libiberty cplus-dem.c */ };
@ -25,32 +21,25 @@ public class App {
init(); init();
demangle("__sti___17_RZApplication_cpp_8fdb2739");
BufferedReader reader; BufferedReader reader;
try { try {
reader = new BufferedReader(new FileReader("functions.txt")); reader = new BufferedReader(new FileReader(args[0]));
String line = reader.readLine(); String line = reader.readLine();
while (line != null) { while (line != null) {
String newStr = line; String newStr = line;
try { try {
newStr = demangle(line); newStr = demangle(line);
System.out.println(newStr);
// System.out.println(newStr);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
System.out.println(line);
System.out.println(newStr);
} }
// read next line
line = reader.readLine(); line = reader.readLine();
} }
reader.close(); reader.close();
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
private static void init() { private static void init() {
@ -128,7 +117,7 @@ public class App {
} }
private static String demangle(String name) { private static String demangle(String name) {
if(name.startsWith("__sti__")) { if (name.startsWith("__sti__")) {
return name; return name;
} }
name = Decompress(name); name = Decompress(name);
@ -232,9 +221,8 @@ public class App {
if (end == -1) throw new IllegalArgumentException("Unexpected end of string. Expected \"Z\"."); if (end == -1) throw new IllegalArgumentException("Unexpected end of string. Expected \"Z\".");
current = remainder.getValue().substring(0, end); current = remainder.getValue().substring(0, end);
remainder.setValue(name.substring(end + 1)); remainder.setValue(name.substring(end + 2));
} else { } else {
current = ReadString(remainder.getValue(), remainder); current = ReadString(remainder.getValue(), remainder);
} }
@ -415,7 +403,11 @@ public class App {
name = name.substring(0, mstart); name = name.substring(0, mstart);
while (true) { while (true) {
if (!StartsWithAny(remainder, templatePrefixes)) throw new IllegalArgumentException("Unexpected template argument prefix."); if (!StartsWithAny(remainder, templatePrefixes)) {
// throw new IllegalArgumentException("Unexpected template argument prefix. " + remainder);
return name;
}
/* format of remainder should be <type>__<len>_<arg> */ /* format of remainder should be <type>__<len>_<arg> */
int lstart = remainder.indexOf("__"); int lstart = remainder.indexOf("__");
@ -569,7 +561,7 @@ public class App {
break; break;
} }
if (end > start) valid = false; if (end < start) valid = false;
if (valid) { if (valid) {