From 2e2ab76c4abd3e3138e463290e0b31ec39fab01d Mon Sep 17 00:00:00 2001
From: Jason Hiser <jdhiser@gmail.com>
Date: Sat, 27 Feb 2021 22:00:51 -0500
Subject: [PATCH] Fixed odd prefixing + sign before memop strings

---
 irdb-libs/libIRDB-core/src/operand_csx86.cpp | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/irdb-libs/libIRDB-core/src/operand_csx86.cpp b/irdb-libs/libIRDB-core/src/operand_csx86.cpp
index 6b7fa57a2..84e1eadb5 100644
--- a/irdb-libs/libIRDB-core/src/operand_csx86.cpp
+++ b/irdb-libs/libIRDB-core/src/operand_csx86.cpp
@@ -247,17 +247,22 @@ string DecodedOperandCapstoneX86_t::getString() const
 			else
 			{
 				string ret_val;
+				const auto doPlus = [&]() -> string 
+				{
+					return ret_val == "" ? "" : " + ";
+				};
+
 				if (op.mem.base != X86_REG_INVALID)
 					ret_val+=cs_reg_name(handle, op.mem.base);
 
 				if (op.mem.index != X86_REG_INVALID)
-					ret_val+=string(" + ") +cs_reg_name(handle, op.mem.index);
+					ret_val+=doPlus() +cs_reg_name(handle, op.mem.index);
 
 				if (op.mem.scale != 1)
-					ret_val+=string(" * ") + to_string(op.mem.scale);
+					ret_val+=doPlus() + to_string(op.mem.scale);
 
 				if (op.mem.disp != 0)
-					ret_val+=" + 0x"+ IRDB_SDK::to_hex_string(op.mem.disp);
+					ret_val+=doPlus() + " 0x"+ IRDB_SDK::to_hex_string(op.mem.disp);
 
 				if(ret_val=="")
 					return "0";
-- 
GitLab