mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-05 10:49:34 +02:00
Merge remote-tracking branch 'origin/GP-1868_ghidra1_CorrectedTextHtmlOperandSeprators' into patch
This commit is contained in:
commit
6f80f8bd3c
1 changed files with 43 additions and 34 deletions
|
@ -284,7 +284,7 @@ class ProgramTextWriter {
|
|||
processAddress(currentCodeUnit.getMinAddress(), null);
|
||||
processBytes(currentCodeUnit);
|
||||
processMnemonic(currentCodeUnit);
|
||||
processOperand(currentCodeUnit, cuFormat);
|
||||
processOperands(currentCodeUnit, cuFormat);
|
||||
|
||||
//// 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();
|
||||
if (width < 1) {
|
||||
|
@ -596,40 +596,49 @@ class ProgramTextWriter {
|
|||
Instruction inst = (Instruction) cu;
|
||||
|
||||
int opCnt = inst.getNumOperands();
|
||||
int opLens = opCnt - 1; // factor-in operand separators
|
||||
if (opCnt > 0) {
|
||||
String firstSeparator = ((Instruction) cu).getSeparator(0);
|
||||
|
||||
String[] opReps = new String[opCnt];
|
||||
for (int i = 0; i < opCnt; ++i) {
|
||||
opReps[i] = cuFormat.getOperandRepresentationString(cu, i);
|
||||
opLens += opReps[i].length();
|
||||
}
|
||||
boolean clipRequired = (opLens > width);
|
||||
|
||||
opLens = opCnt - 1; // reset - factor-in operand separators
|
||||
for (int i = 0; i < opCnt; ++i) {
|
||||
if (i > 0) {
|
||||
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]);
|
||||
}
|
||||
int opLens = 0;
|
||||
int sepLens = firstSeparator != null ? firstSeparator.length() : 0;
|
||||
String[] opSeparators = new String[opCnt];
|
||||
String[] opReps = new String[opCnt];
|
||||
for (int i = 0; i < opCnt; ++i) {
|
||||
opReps[i] = cuFormat.getOperandRepresentationString(cu, i);
|
||||
opLens += opReps[i].length();
|
||||
opSeparators[i] = ((Instruction) cu).getSeparator(i + 1);
|
||||
if (opSeparators[i] == null) {
|
||||
opSeparators[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);
|
||||
}
|
||||
else if (cu instanceof Data) {
|
||||
|
@ -660,7 +669,7 @@ class ProgramTextWriter {
|
|||
processAddress(component.getMinAddress(), fill + STRUCT_PREFIX);
|
||||
processDataFieldName(component);
|
||||
processMnemonic(component);
|
||||
processOperand(component, cuFormat);
|
||||
processOperands(component, cuFormat);
|
||||
//processEOLComment();
|
||||
//processXREFs();
|
||||
writer.println(buffy.toString());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue