copy mnemonic in the same loop of searching for mnemonic/opstring delimiter
This commit is contained in:
parent
07e84a2094
commit
7566a2d9dd
13
cs.c
13
cs.c
|
@ -258,6 +258,7 @@ static void fill_insn(struct cs_struct *handle, cs_insn *insn, char *buffer, MCI
|
|||
#ifndef CAPSTONE_DIET
|
||||
char *sp;
|
||||
#endif
|
||||
char *mnem;
|
||||
|
||||
if (handle->detail) {
|
||||
// avoiding copy insn->detail
|
||||
|
@ -294,6 +295,7 @@ static void fill_insn(struct cs_struct *handle, cs_insn *insn, char *buffer, MCI
|
|||
// 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 @@ static void fill_insn(struct cs_struct *handle, cs_insn *insn, char *buffer, MCI
|
|||
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 @@ static void fill_insn(struct cs_struct *handle, cs_insn *insn, char *buffer, MCI
|
|||
insn->op_str[sizeof(insn->op_str) - 1] = '\0';
|
||||
} else
|
||||
insn->op_str[0] = '\0';
|
||||
|
||||
strcpy(insn->mnemonic, buffer);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue