Export originals with LF line endings

Ghidra on Windows returns CRLF from the decompiler and listing; stored rows then render double-spaced in the review view.
This commit is contained in:
ragnarok-clanker 2026-10-28 19:40:06 +01:00
commit 7952a0a650

View file

@ -41,12 +41,12 @@ public class ExportOriginals extends GhidraScript {
String c;
DecompileResults r = ifc.decompileFunction(f, timeout, monitor);
if (r.decompileCompleted() && r.getDecompiledFunction() != null) {
c = r.getDecompiledFunction().getC();
c = r.getDecompiledFunction().getC().replace("\r\n", "\n");
} else {
c = null;
failed++;
}
out.write("{\"addr\":\"0x" + Long.toHexString(f.getEntryPoint().getOffset()) + "\",\"asm\":" + json(disassemble(f)) + ",\"c\":" + (c == null ? "null" : json(c)) + "}\n");
out.write("{\"addr\":\"0x" + Long.toHexString(f.getEntryPoint().getOffset()) + "\",\"asm\":" + json(disassemble(f).replace("\r\n", "\n")) + ",\"c\":" + (c == null ? "null" : json(c)) + "}\n");
if (++n % 1000 == 0) {
println("exported " + n + " functions");
}