copy mnemonic in the same loop of searching for mnemonic/opstring delimiter
diff --git a/cs.c b/cs.c
index 40d2d23..740268f 100644
--- a/cs.c
+++ b/cs.c
@@ -258,6 +258,7 @@
#ifndef CAPSTONE_DIET
char *sp;
#endif
+ char *mnem;
if (handle->detail) {
// avoiding copy insn->detail
@@ -294,6 +295,7 @@
// fill in mnemonic & operands
// find first space or tab
sp = buffer;
+ mnem = insn->mnemonic;
if (mci->x86_prefix[0]) {
for (sp = buffer; *sp; sp++) {
//if (*sp == ' '||*sp == '\t')
@@ -301,14 +303,23 @@
break;
if (*sp == '|') // lock|rep prefix for x86
*sp = ' ';
+ // copy to @mnemonic
+ *mnem = *sp;
+ mnem++;
}
} else {
for (sp = buffer; *sp; sp++) {
if (*sp == ' '||*sp == '\t')
break;
+ // copy to @mnemonic
+ *mnem = *sp;
+ mnem++;
}
}
+ *mnem = '\0';
+
+ // copy @op_str
if (*sp) {
*sp = '\0';
// find the next non-space char
@@ -318,8 +329,6 @@
insn->op_str[sizeof(insn->op_str) - 1] = '\0';
} else
insn->op_str[0] = '\0';
-
- strcpy(insn->mnemonic, buffer);
#endif
}