mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2026-05-31 20:50:59 +08:00
Merge remote-tracking branch 'origin/GP-1868_ghidra1_CorrectedTextHtmlOperandSeprators' into patch
This commit is contained in:
+43
-34
@@ -284,7 +284,7 @@ class ProgramTextWriter {
|
|||||||
processAddress(currentCodeUnit.getMinAddress(), null);
|
processAddress(currentCodeUnit.getMinAddress(), null);
|
||||||
processBytes(currentCodeUnit);
|
processBytes(currentCodeUnit);
|
||||||
processMnemonic(currentCodeUnit);
|
processMnemonic(currentCodeUnit);
|
||||||
processOperand(currentCodeUnit, cuFormat);
|
processOperands(currentCodeUnit, cuFormat);
|
||||||
|
|
||||||
//// End of Line Area //////////////////////////////////////////
|
//// End of Line Area //////////////////////////////////////////
|
||||||
|
|
||||||
@@ -582,7 +582,7 @@ class ProgramTextWriter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void processOperand(CodeUnit cu, CodeUnitFormat cuFormat) {
|
private void processOperands(CodeUnit cu, CodeUnitFormat cuFormat) {
|
||||||
|
|
||||||
int width = options.getOperandWidth();
|
int width = options.getOperandWidth();
|
||||||
if (width < 1) {
|
if (width < 1) {
|
||||||
@@ -596,40 +596,49 @@ class ProgramTextWriter {
|
|||||||
Instruction inst = (Instruction) cu;
|
Instruction inst = (Instruction) cu;
|
||||||
|
|
||||||
int opCnt = inst.getNumOperands();
|
int opCnt = inst.getNumOperands();
|
||||||
int opLens = opCnt - 1; // factor-in operand separators
|
String firstSeparator = ((Instruction) cu).getSeparator(0);
|
||||||
if (opCnt > 0) {
|
|
||||||
|
|
||||||
String[] opReps = new String[opCnt];
|
int opLens = 0;
|
||||||
for (int i = 0; i < opCnt; ++i) {
|
int sepLens = firstSeparator != null ? firstSeparator.length() : 0;
|
||||||
opReps[i] = cuFormat.getOperandRepresentationString(cu, i);
|
String[] opSeparators = new String[opCnt];
|
||||||
opLens += opReps[i].length();
|
String[] opReps = new String[opCnt];
|
||||||
}
|
for (int i = 0; i < opCnt; ++i) {
|
||||||
boolean clipRequired = (opLens > width);
|
opReps[i] = cuFormat.getOperandRepresentationString(cu, i);
|
||||||
|
opLens += opReps[i].length();
|
||||||
opLens = opCnt - 1; // reset - factor-in operand separators
|
opSeparators[i] = ((Instruction) cu).getSeparator(i + 1);
|
||||||
for (int i = 0; i < opCnt; ++i) {
|
if (opSeparators[i] == null) {
|
||||||
if (i > 0) {
|
opSeparators[i] = "";
|
||||||
buffy.append(",");
|
|
||||||
}
|
|
||||||
if (clipRequired) {
|
|
||||||
opReps[i] = clip(opReps[i], (width - opLens) / (opCnt - i), false, true);
|
|
||||||
}
|
|
||||||
opLens += opReps[i].length();
|
|
||||||
|
|
||||||
if (options.isHTML()) {
|
|
||||||
Reference ref =
|
|
||||||
cu.getProgram()
|
|
||||||
.getReferenceManager()
|
|
||||||
.getPrimaryReferenceFrom(cuAddress,
|
|
||||||
i);
|
|
||||||
addReferenceLinkedText(ref, opReps[i], true);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
buffy.append(opReps[i]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
sepLens += opSeparators[i].length();
|
||||||
}
|
}
|
||||||
String fill = genFill(width - opLens);
|
boolean clipRequired = (opLens + sepLens) > width;
|
||||||
|
|
||||||
|
// NOTE: Use InstructionDB.toString() as formatting guide
|
||||||
|
int len = sepLens; // reserve space for separator pieces
|
||||||
|
if (firstSeparator != null) {
|
||||||
|
buffy.append(firstSeparator);
|
||||||
|
}
|
||||||
|
for (int i = 0; i < opCnt; ++i) {
|
||||||
|
if (clipRequired) {
|
||||||
|
opReps[i] = clip(opReps[i], (width - len) / (opCnt - i), false, true);
|
||||||
|
}
|
||||||
|
len += opReps[i].length();
|
||||||
|
|
||||||
|
if (options.isHTML()) {
|
||||||
|
Reference ref =
|
||||||
|
cu.getProgram()
|
||||||
|
.getReferenceManager()
|
||||||
|
.getPrimaryReferenceFrom(cuAddress,
|
||||||
|
i);
|
||||||
|
addReferenceLinkedText(ref, opReps[i], true);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
buffy.append(opReps[i]);
|
||||||
|
}
|
||||||
|
buffy.append(opSeparators[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
String fill = genFill(width - len);
|
||||||
buffy.append(fill);
|
buffy.append(fill);
|
||||||
}
|
}
|
||||||
else if (cu instanceof Data) {
|
else if (cu instanceof Data) {
|
||||||
@@ -660,7 +669,7 @@ class ProgramTextWriter {
|
|||||||
processAddress(component.getMinAddress(), fill + STRUCT_PREFIX);
|
processAddress(component.getMinAddress(), fill + STRUCT_PREFIX);
|
||||||
processDataFieldName(component);
|
processDataFieldName(component);
|
||||||
processMnemonic(component);
|
processMnemonic(component);
|
||||||
processOperand(component, cuFormat);
|
processOperands(component, cuFormat);
|
||||||
//processEOLComment();
|
//processEOLComment();
|
||||||
//processXREFs();
|
//processXREFs();
|
||||||
writer.println(buffy.toString());
|
writer.println(buffy.toString());
|
||||||
|
|||||||
Reference in New Issue
Block a user