Fix #6162 - Renames r_str_concat to r_str_append

This commit is contained in:
davidpolverari 2017-03-16 18:29:49 -03:00 committed by radare
parent 8f98c048c6
commit 1fb422b532
34 changed files with 274 additions and 274 deletions

View File

@ -848,7 +848,7 @@ int main(int argc, char **argv, char **envp) {
}
}
escaped_path = r_str_arg_escape (path);
pfile = r_str_concat (pfile, escaped_path);
pfile = r_str_append (pfile, escaped_path);
file = pfile; // probably leaks
R_FREE (escaped_path);
R_FREE (path);
@ -856,16 +856,16 @@ int main(int argc, char **argv, char **envp) {
#else
{
char *escaped_path = r_str_arg_escape (f);
pfile = r_str_concat (pfile, escaped_path);
file = pfile; // r_str_concat (file, escaped_path);
pfile = r_str_append (pfile, escaped_path);
file = pfile; // r_str_append (file, escaped_path);
free (escaped_path);
}
#endif
optind++;
while (optind < argc) {
char *escaped_arg = r_str_arg_escape (argv[optind]);
file = r_str_concat (file, " ");
file = r_str_concat (file, escaped_arg);
file = r_str_append (file, " ");
file = r_str_append (file, escaped_arg);
free (escaped_arg);
optind++;
}

View File

@ -146,7 +146,7 @@ int main(int argc, char **argv) {
bits = atoi (optarg);
break;
case 'B':
bytes = r_str_concat (bytes, optarg);
bytes = r_str_append (bytes, optarg);
break;
case 'C':
contents = optarg;

View File

@ -478,7 +478,7 @@ R_API char* r_anal_reflines_str(void *_core, ut64 addr, int opts) {
}
}
}
str = r_str_concat (str, (dir == 1) ? "-> "
str = r_str_append (str, (dir == 1) ? "-> "
: (dir == 2) ? "=< " : " ");
if (core->cons->use_utf8 || opts & R_ANAL_REFLINE_TYPE_UTF8) {

View File

@ -203,14 +203,14 @@ static int zignListCB(void *user, const char *k, const char *v) {
for (i = 0; i < it->size; i++) {
if (it->mask[i] & 0xf0) {
bytes = r_str_concatf (bytes, "%x", (it->bytes[i] & 0xf0) >> 4);
bytes = r_str_appendf (bytes, "%x", (it->bytes[i] & 0xf0) >> 4);
} else {
bytes = r_str_concatf (bytes, ".");
bytes = r_str_appendf (bytes, ".");
}
if (it->mask[i] & 0xf) {
bytes = r_str_concatf (bytes, "%x", it->bytes[i] & 0xf);
bytes = r_str_appendf (bytes, "%x", it->bytes[i] & 0xf);
} else {
bytes = r_str_concatf (bytes, ".");
bytes = r_str_appendf (bytes, ".");
}
}

View File

@ -194,9 +194,9 @@ R_API char *r_anal_type_format(RAnal *anal, const char *t) {
char* struct_name = type + 7;
// TODO: iterate over all the struct fields, and format the format and vars
snprintf (var3, sizeof (var3), "struct.%s", struct_name);
fmt = r_str_concat (fmt, "?");
vars = r_str_concatf (vars, "(%s)%s", struct_name, p);
vars = r_str_concat (vars, " ");
fmt = r_str_append (fmt, "?");
vars = r_str_appendf (vars, "(%s)%s", struct_name, p);
vars = r_str_append (vars, " ");
} else {
elements = sdb_array_get_num (DB, var2, 2, NULL);
// special case for char[]. Use char* format type without *
@ -220,20 +220,20 @@ R_API char *r_anal_type_format(RAnal *anal, const char *t) {
if (tfmt) {
filter_type (type);
if (elements > 0) {
fmt = r_str_concatf (fmt, "[%d]", elements);
fmt = r_str_appendf (fmt, "[%d]", elements);
}
if (isStruct) {
fmt = r_str_concat (fmt, "?");
vars = r_str_concatf (vars, "(%s)%s", p, p);
vars = r_str_concat (vars, " ");
fmt = r_str_append (fmt, "?");
vars = r_str_appendf (vars, "(%s)%s", p, p);
vars = r_str_append (vars, " ");
} else if (isEnum) {
fmt = r_str_concat (fmt, "E");
vars = r_str_concatf (vars, "(%s)%s", type + 5, p);
vars = r_str_concat (vars, " ");
fmt = r_str_append (fmt, "E");
vars = r_str_appendf (vars, "(%s)%s", type + 5, p);
vars = r_str_append (vars, " ");
} else {
fmt = r_str_concat (fmt, tfmt);
vars = r_str_concat (vars, p);
vars = r_str_concat (vars, " ");
fmt = r_str_append (fmt, tfmt);
vars = r_str_append (vars, p);
vars = r_str_append (vars, " ");
}
} else {
eprintf ("Cannot resolve type '%s'\n", var3);
@ -243,8 +243,8 @@ R_API char *r_anal_type_format(RAnal *anal, const char *t) {
free (type);
free (p);
}
fmt = r_str_concat (fmt, " ");
fmt = r_str_concat (fmt, vars);
fmt = r_str_append (fmt, " ");
fmt = r_str_append (fmt, vars);
free (vars);
return fmt;
}

View File

@ -74,25 +74,25 @@ R_API char *r_anal_value_to_string (RAnalValue *value) {
out = r_str_new ("");
if (!value->base && !value->reg) {
if (value->imm != -1LL)
out = r_str_concatf (out, "0x%"PFMT64x, value->imm);
else out = r_str_concat (out, "-1");
out = r_str_appendf (out, "0x%"PFMT64x, value->imm);
else out = r_str_append (out, "-1");
} else {
if (value->memref) {
switch (value->memref) {
case 1: out = r_str_concat (out, "(char)"); break;
case 2: out = r_str_concat (out, "(short)"); break;
case 4: out = r_str_concat (out, "(word)"); break;
case 8: out = r_str_concat (out, "(dword)"); break;
case 1: out = r_str_append (out, "(char)"); break;
case 2: out = r_str_append (out, "(short)"); break;
case 4: out = r_str_append (out, "(word)"); break;
case 8: out = r_str_append (out, "(dword)"); break;
}
out = r_str_concat (out, "[");
out = r_str_append (out, "[");
}
if (value->mul) out = r_str_concatf (out, "%d*", value->mul);
if (value->reg) out = r_str_concatf (out, "%s", value->reg->name);
if (value->regdelta) out = r_str_concatf (out, "+%s", value->regdelta->name);
if (value->base!=0) out = r_str_concatf (out, "0x%"PFMT64x, value->base);
if (value->delta>0) out = r_str_concatf (out, "+0x%"PFMT64x, value->delta);
else if (value->delta<0) out = r_str_concatf (out, "-0x%"PFMT64x, -value->delta);
if (value->memref) out = r_str_concat (out, "]");
if (value->mul) out = r_str_appendf (out, "%d*", value->mul);
if (value->reg) out = r_str_appendf (out, "%s", value->reg->name);
if (value->regdelta) out = r_str_appendf (out, "+%s", value->regdelta->name);
if (value->base!=0) out = r_str_appendf (out, "0x%"PFMT64x, value->base);
if (value->delta>0) out = r_str_appendf (out, "+0x%"PFMT64x, value->delta);
else if (value->delta<0) out = r_str_appendf (out, "-0x%"PFMT64x, -value->delta);
if (value->memref) out = r_str_append (out, "]");
}
}
return out;

View File

@ -74,7 +74,7 @@ static ut32 arm_disasm_branch(struct winedbg_arm_insn *arminsn, ut32 inst) {
if (offset & 0x02000000) offset |= 0xfc000000;
offset += 8;
arminsn->str_asm = r_str_concatf(arminsn->str_asm, "b%s%s 0x%"PFMT64x, link ? "l" : "", get_cond(inst), arminsn->pc+offset);
arminsn->str_asm = r_str_appendf(arminsn->str_asm, "b%s%s 0x%"PFMT64x, link ? "l" : "", get_cond(inst), arminsn->pc+offset);
arminsn->jmp = arminsn->pc+offset;
arminsn->fail = arminsn->pc+4;
@ -86,11 +86,11 @@ static ut32 arm_disasm_mul(struct winedbg_arm_insn *arminsn, ut32 inst) {
short condcodes = (inst >> 20) & 0x01;
if (accu)
arminsn->str_asm = r_str_concatf(arminsn->str_asm, "mla%s%s %s, %s, %s, %s", get_cond(inst), condcodes ? "s" : "",
arminsn->str_asm = r_str_appendf(arminsn->str_asm, "mla%s%s %s, %s, %s, %s", get_cond(inst), condcodes ? "s" : "",
tbl_regs[get_nibble(inst, 4)], tbl_regs[get_nibble(inst, 0)],
tbl_regs[get_nibble(inst, 2)], tbl_regs[get_nibble(inst, 3)]);
else
arminsn->str_asm = r_str_concatf(arminsn->str_asm, "mul%s%s %s, %s, %s", get_cond(inst), condcodes ? "s" : "",
arminsn->str_asm = r_str_appendf(arminsn->str_asm, "mul%s%s %s, %s, %s", get_cond(inst), condcodes ? "s" : "",
tbl_regs[get_nibble(inst, 4)], tbl_regs[get_nibble(inst, 0)],
tbl_regs[get_nibble(inst, 2)]);
return 0;
@ -101,7 +101,7 @@ static ut32 arm_disasm_longmul(struct winedbg_arm_insn *arminsn, ut32 inst) {
short accu = (inst >> 21) & 0x01;
short condcodes = (inst >> 20) & 0x01;
arminsn->str_asm = r_str_concatf(arminsn->str_asm, "%s%s%s%s %s, %s, %s, %s", sign ? "s" : "u", accu ? "mlal" : "mull",
arminsn->str_asm = r_str_appendf(arminsn->str_asm, "%s%s%s%s %s, %s, %s, %s", sign ? "s" : "u", accu ? "mlal" : "mull",
get_cond(inst), condcodes ? "s" : "",
tbl_regs[get_nibble(inst, 3)], tbl_regs[get_nibble(inst, 4)],
tbl_regs[get_nibble(inst, 0)], tbl_regs[get_nibble(inst, 2)]);
@ -111,26 +111,26 @@ static ut32 arm_disasm_longmul(struct winedbg_arm_insn *arminsn, ut32 inst) {
static ut32 arm_disasm_swp(struct winedbg_arm_insn *arminsn, ut32 inst) {
short byte = (inst >> 22) & 0x01;
arminsn->str_asm = r_str_concatf(arminsn->str_asm, "swp%s%s %s, %s, [%s]", get_cond(inst), byte ? "b" : "",
arminsn->str_asm = r_str_appendf(arminsn->str_asm, "swp%s%s %s, %s, [%s]", get_cond(inst), byte ? "b" : "",
tbl_regs[get_nibble(inst, 3)], tbl_regs[get_nibble(inst, 0)],
tbl_regs[get_nibble(inst, 4)]);
return 0;
}
static ut32 arm_disasm_branchreg(struct winedbg_arm_insn *arminsn, ut32 inst) {
arminsn->str_asm = r_str_concatf(arminsn->str_asm, "b%s %s", get_cond(inst), tbl_regs[get_nibble(inst, 0)]);
arminsn->str_asm = r_str_appendf(arminsn->str_asm, "b%s %s", get_cond(inst), tbl_regs[get_nibble(inst, 0)]);
return 0;
}
static ut32 arm_disasm_branchxchg(struct winedbg_arm_insn *arminsn, ut32 inst) {
arminsn->str_asm = r_str_concatf(arminsn->str_asm, "bx%s %s", get_cond(inst), tbl_regs[get_nibble(inst, 0)]);
arminsn->str_asm = r_str_appendf(arminsn->str_asm, "bx%s %s", get_cond(inst), tbl_regs[get_nibble(inst, 0)]);
return 0;
}
static ut32 arm_disasm_mrstrans(struct winedbg_arm_insn *arminsn, ut32 inst) {
short src = (inst >> 22) & 0x01;
arminsn->str_asm = r_str_concatf(arminsn->str_asm, "mrs%s %s, %s", get_cond(inst), tbl_regs[get_nibble(inst, 3)],
arminsn->str_asm = r_str_appendf(arminsn->str_asm, "mrs%s %s, %s", get_cond(inst), tbl_regs[get_nibble(inst, 3)],
src ? "spsr" : "cpsr");
return 0;
}
@ -141,11 +141,11 @@ static ut32 arm_disasm_msrtrans(struct winedbg_arm_insn *arminsn, ut32 inst) {
short simple = (inst >> 16) & 0x01;
if (simple || !immediate) {
arminsn->str_asm = r_str_concatf(arminsn->str_asm, "msr%s %s, %s", get_cond(inst), dst ? "spsr" : "cpsr",
arminsn->str_asm = r_str_appendf(arminsn->str_asm, "msr%s %s, %s", get_cond(inst), dst ? "spsr" : "cpsr",
tbl_regs[get_nibble(inst, 0)]);
return 0;
}
arminsn->str_asm = r_str_concatf(arminsn->str_asm, "msr%s %s, #%u", get_cond(inst), dst ? "spsr" : "cpsr",
arminsn->str_asm = r_str_appendf(arminsn->str_asm, "msr%s %s, #%u", get_cond(inst), dst ? "spsr" : "cpsr",
ROR32(inst & 0xff, 2 * get_nibble(inst, 2)));
return 0;
}
@ -153,14 +153,14 @@ static ut32 arm_disasm_msrtrans(struct winedbg_arm_insn *arminsn, ut32 inst) {
static ut32 arm_disasm_wordmov(struct winedbg_arm_insn *arminsn, ut32 inst) {
short top = (inst >> 22) & 0x01;
arminsn->str_asm = r_str_concatf(arminsn->str_asm, "mov%s%s %s, #%u", top ? "t" : "w", get_cond(inst),
arminsn->str_asm = r_str_appendf(arminsn->str_asm, "mov%s%s %s, #%u", top ? "t" : "w", get_cond(inst),
tbl_regs[get_nibble(inst, 3)],
(get_nibble(inst, 4) << 12) | (inst & 0x0fff));
return 0;
}
static ut32 arm_disasm_nop(struct winedbg_arm_insn *arminsn, ut32 inst) {
arminsn->str_asm = r_str_concatf(arminsn->str_asm, "nop%s", get_cond(inst));
arminsn->str_asm = r_str_appendf(arminsn->str_asm, "nop%s", get_cond(inst));
return 0;
}
@ -171,27 +171,27 @@ static ut32 arm_disasm_dataprocessing(struct winedbg_arm_insn *arminsn, ut32 ins
short no_op1 = (opcode & 0x0d) == 0x0d;
short no_dst = (opcode & 0x0c) == 0x08;
arminsn->str_asm = r_str_concatf(arminsn->str_asm, "%s%s%s", tbl_dataops[opcode], condcodes ? "s" : "", get_cond(inst));
if (!no_dst) arminsn->str_asm = r_str_concatf(arminsn->str_asm, " %s, ", tbl_regs[get_nibble(inst, 3)]);
else arminsn->str_asm = r_str_concatf(arminsn->str_asm, " ");
arminsn->str_asm = r_str_appendf(arminsn->str_asm, "%s%s%s", tbl_dataops[opcode], condcodes ? "s" : "", get_cond(inst));
if (!no_dst) arminsn->str_asm = r_str_appendf(arminsn->str_asm, " %s, ", tbl_regs[get_nibble(inst, 3)]);
else arminsn->str_asm = r_str_appendf(arminsn->str_asm, " ");
if (no_op1) {
if (immediate)
arminsn->str_asm = r_str_concatf(arminsn->str_asm, "#%u", ROR32(inst & 0xff, 2 * get_nibble(inst, 2)));
arminsn->str_asm = r_str_appendf(arminsn->str_asm, "#%u", ROR32(inst & 0xff, 2 * get_nibble(inst, 2)));
else
arminsn->str_asm = r_str_concatf(arminsn->str_asm, "%s", tbl_regs[get_nibble(inst, 0)]);
arminsn->str_asm = r_str_appendf(arminsn->str_asm, "%s", tbl_regs[get_nibble(inst, 0)]);
} else {
if (immediate)
arminsn->str_asm = r_str_concatf(arminsn->str_asm, "%s, #%u", tbl_regs[get_nibble(inst, 4)],
arminsn->str_asm = r_str_appendf(arminsn->str_asm, "%s, #%u", tbl_regs[get_nibble(inst, 4)],
ROR32(inst & 0xff, 2 * get_nibble(inst, 2)));
else if (((inst >> 4) & 0xff) == 0x00) /* no shift */
arminsn->str_asm = r_str_concatf(arminsn->str_asm, "%s, %s", tbl_regs[get_nibble(inst, 4)],
arminsn->str_asm = r_str_appendf(arminsn->str_asm, "%s, %s", tbl_regs[get_nibble(inst, 4)],
tbl_regs[get_nibble(inst, 0)]);
else if (((inst >> 4) & 0x09) == 0x01) /* register shift */
arminsn->str_asm = r_str_concatf(arminsn->str_asm, "%s, %s, %s %s", tbl_regs[get_nibble(inst, 4)],
arminsn->str_asm = r_str_appendf(arminsn->str_asm, "%s, %s, %s %s", tbl_regs[get_nibble(inst, 4)],
tbl_regs[get_nibble(inst, 0)],
tbl_shifts[(inst >> 5) & 0x03], tbl_regs[(inst >> 8) & 0x0f]);
else if (((inst >> 4) & 0x01) == 0x00) /* immediate shift */
arminsn->str_asm = r_str_concatf(arminsn->str_asm, "%s, %s, %s #%d", tbl_regs[get_nibble(inst, 4)],
arminsn->str_asm = r_str_appendf(arminsn->str_asm, "%s, %s, %s #%d", tbl_regs[get_nibble(inst, 4)],
tbl_regs[get_nibble(inst, 0)], tbl_shifts[(inst >> 5) & 0x03],
(inst >> 7) & 0x1f);
else
@ -211,29 +211,29 @@ static ut32 arm_disasm_singletrans(struct winedbg_arm_insn *arminsn, ut32 inst)
if (!direction) offset *= -1;
arminsn->str_asm = r_str_concatf(arminsn->str_asm, "%s%s%s%s", load ? "ldr" : "str", byte ? "b" : "", writeback ? "t" : "",
arminsn->str_asm = r_str_appendf(arminsn->str_asm, "%s%s%s%s", load ? "ldr" : "str", byte ? "b" : "", writeback ? "t" : "",
get_cond(inst));
arminsn->str_asm = r_str_concatf(arminsn->str_asm, " %s, ", tbl_regs[get_nibble(inst, 3)]);
arminsn->str_asm = r_str_appendf(arminsn->str_asm, " %s, ", tbl_regs[get_nibble(inst, 3)]);
if (indexing) {
if (immediate)
arminsn->str_asm = r_str_concatf(arminsn->str_asm, "[%s, #%d]", tbl_regs[get_nibble(inst, 4)], offset);
arminsn->str_asm = r_str_appendf(arminsn->str_asm, "[%s, #%d]", tbl_regs[get_nibble(inst, 4)], offset);
else if (((inst >> 4) & 0xff) == 0x00) /* no shift */
arminsn->str_asm = r_str_concatf(arminsn->str_asm, "[%s, %s]", tbl_regs[get_nibble(inst, 4)],
arminsn->str_asm = r_str_appendf(arminsn->str_asm, "[%s, %s]", tbl_regs[get_nibble(inst, 4)],
tbl_regs[get_nibble(inst, 0)]);
else if (((inst >> 4) & 0x01) == 0x00) /* immediate shift (there's no register shift) */
arminsn->str_asm = r_str_concatf(arminsn->str_asm, "[%s, %s, %s #%d]", tbl_regs[get_nibble(inst, 4)],
arminsn->str_asm = r_str_appendf(arminsn->str_asm, "[%s, %s, %s #%d]", tbl_regs[get_nibble(inst, 4)],
tbl_regs[get_nibble(inst, 0)], tbl_shifts[(inst >> 5) & 0x03],
(inst >> 7) & 0x1f);
else
return inst;
} else {
if (immediate)
arminsn->str_asm = r_str_concatf(arminsn->str_asm, "[%s], #%d", tbl_regs[get_nibble(inst, 4)], offset);
arminsn->str_asm = r_str_appendf(arminsn->str_asm, "[%s], #%d", tbl_regs[get_nibble(inst, 4)], offset);
else if (((inst >> 4) & 0xff) == 0x00) /* no shift */
arminsn->str_asm = r_str_concatf(arminsn->str_asm, "[%s], %s", tbl_regs[get_nibble(inst, 4)],
arminsn->str_asm = r_str_appendf(arminsn->str_asm, "[%s], %s", tbl_regs[get_nibble(inst, 4)],
tbl_regs[get_nibble(inst, 0)]);
else if (((inst >> 4) & 0x01) == 0x00) /* immediate shift (there's no register shift) */
arminsn->str_asm = r_str_concatf(arminsn->str_asm, "[%s], %s, %s #%d", tbl_regs[get_nibble(inst, 4)],
arminsn->str_asm = r_str_appendf(arminsn->str_asm, "[%s], %s, %s #%d", tbl_regs[get_nibble(inst, 4)],
tbl_regs[get_nibble(inst, 0)], tbl_shifts[(inst >> 5) & 0x03],
(inst >> 7) & 0x1f);
else
@ -254,20 +254,20 @@ static ut32 arm_disasm_halfwordtrans(struct winedbg_arm_insn *arminsn, ut32 inst
if (!direction) offset *= -1;
arminsn->str_asm = r_str_concatf(arminsn->str_asm, "%s%s%s%s%s", load ? "ldr" : "str", sign ? "s" : "",
arminsn->str_asm = r_str_appendf(arminsn->str_asm, "%s%s%s%s%s", load ? "ldr" : "str", sign ? "s" : "",
halfword ? "h" : (sign ? "b" : ""), writeback ? "t" : "", get_cond(inst));
arminsn->str_asm = r_str_concatf(arminsn->str_asm, " %s, ", tbl_regs[get_nibble(inst, 3)]);
arminsn->str_asm = r_str_appendf(arminsn->str_asm, " %s, ", tbl_regs[get_nibble(inst, 3)]);
if (indexing) {
if (immediate)
arminsn->str_asm = r_str_concatf(arminsn->str_asm, "[%s, #%d]", tbl_regs[get_nibble(inst, 4)], offset);
arminsn->str_asm = r_str_appendf(arminsn->str_asm, "[%s, #%d]", tbl_regs[get_nibble(inst, 4)], offset);
else
arminsn->str_asm = r_str_concatf(arminsn->str_asm, "[%s, %s]", tbl_regs[get_nibble(inst, 4)],
arminsn->str_asm = r_str_appendf(arminsn->str_asm, "[%s, %s]", tbl_regs[get_nibble(inst, 4)],
tbl_regs[get_nibble(inst, 0)]);
} else {
if (immediate)
arminsn->str_asm = r_str_concatf(arminsn->str_asm, "[%s], #%d", tbl_regs[get_nibble(inst, 4)], offset);
arminsn->str_asm = r_str_appendf(arminsn->str_asm, "[%s], #%d", tbl_regs[get_nibble(inst, 4)], offset);
else
arminsn->str_asm = r_str_concatf(arminsn->str_asm, "[%s], %s", tbl_regs[get_nibble(inst, 4)],
arminsn->str_asm = r_str_appendf(arminsn->str_asm, "[%s], %s", tbl_regs[get_nibble(inst, 4)],
tbl_regs[get_nibble(inst, 0)]);
}
return 0;
@ -287,20 +287,20 @@ static ut32 arm_disasm_blocktrans(struct winedbg_arm_insn *arminsn, ut32 inst) {
break;
}
arminsn->str_asm = r_str_concatf(arminsn->str_asm, "%s%s%s %s%s, {", load ? "ldm" : "stm", tbl_addrmode[addrmode],
arminsn->str_asm = r_str_appendf(arminsn->str_asm, "%s%s%s %s%s, {", load ? "ldm" : "stm", tbl_addrmode[addrmode],
get_cond(inst), tbl_regs[get_nibble(inst, 4)], writeback ? "!" : "");
for (i=0;i<=15;i++)
if ((inst>>i) & 1) {
if (i == last) arminsn->str_asm = r_str_concatf(arminsn->str_asm, "%s", tbl_regs[i]);
else arminsn->str_asm = r_str_concatf(arminsn->str_asm, "%s, ", tbl_regs[i]);
if (i == last) arminsn->str_asm = r_str_appendf(arminsn->str_asm, "%s", tbl_regs[i]);
else arminsn->str_asm = r_str_appendf(arminsn->str_asm, "%s, ", tbl_regs[i]);
}
arminsn->str_asm = r_str_concatf(arminsn->str_asm, "}%s", psr ? "^" : "");
arminsn->str_asm = r_str_appendf(arminsn->str_asm, "}%s", psr ? "^" : "");
return 0;
}
static ut32 arm_disasm_swi(struct winedbg_arm_insn *arminsn, ut32 inst) {
ut32 comment = inst & 0x00ffffff;
arminsn->str_asm = r_str_concatf(arminsn->str_asm, "swi%s #%d", get_cond(inst), comment);
arminsn->str_asm = r_str_appendf(arminsn->str_asm, "swi%s #%d", get_cond(inst), comment);
return 0;
}
@ -312,7 +312,7 @@ static ut32 arm_disasm_coproctrans(struct winedbg_arm_insn *arminsn, ut32 inst)
ut16 load = (inst >> 20) & 0x01;
ut16 CP_Opc = (inst >> 21) & 0x07;
arminsn->str_asm = r_str_concatf(arminsn->str_asm, "%s%s %u, %u, %s, cr%u, cr%u, {%u}", load ? "mrc" : "mcr",
arminsn->str_asm = r_str_appendf(arminsn->str_asm, "%s%s %u, %u, %s, cr%u, cr%u, {%u}", load ? "mrc" : "mcr",
get_cond(inst), CPnum, CP, tbl_regs[get_nibble(inst, 3)], CRn, CRm, CP_Opc);
return 0;
}
@ -325,7 +325,7 @@ static ut32 arm_disasm_coprocdataop(struct winedbg_arm_insn *arminsn, ut32 inst)
ut16 CRn = (inst >> 16) & 0x0f;
ut16 CP_Opc = (inst >> 20) & 0x0f;
arminsn->str_asm = r_str_concatf(arminsn->str_asm, "cdp%s %u, %u, cr%u, cr%u, cr%u, {%u}", get_cond(inst),
arminsn->str_asm = r_str_appendf(arminsn->str_asm, "cdp%s %u, %u, cr%u, cr%u, cr%u, {%u}", get_cond(inst),
CPnum, CP, CRd, CRn, CRm, CP_Opc);
return 0;
}
@ -342,12 +342,12 @@ static ut32 arm_disasm_coprocdatatrans(struct winedbg_arm_insn *arminsn, ut32 in
if (!direction) offset *= -1;
arminsn->str_asm = r_str_concatf(arminsn->str_asm, "%s%s%s", load ? "ldc" : "stc", translen ? "l" : "", get_cond(inst));
arminsn->str_asm = r_str_appendf(arminsn->str_asm, "%s%s%s", load ? "ldc" : "stc", translen ? "l" : "", get_cond(inst));
if (indexing)
arminsn->str_asm = r_str_concatf(arminsn->str_asm, " %u, cr%u, [%s, #%d]%s", CPnum, CRd, tbl_regs[get_nibble(inst, 4)],
arminsn->str_asm = r_str_appendf(arminsn->str_asm, " %u, cr%u, [%s, #%d]%s", CPnum, CRd, tbl_regs[get_nibble(inst, 4)],
offset, writeback?"!":"");
else
arminsn->str_asm = r_str_concatf(arminsn->str_asm, " %u, cr%u, [%s], #%d", CPnum, CRd, tbl_regs[get_nibble(inst, 4)],
arminsn->str_asm = r_str_appendf(arminsn->str_asm, " %u, cr%u, [%s], #%d", CPnum, CRd, tbl_regs[get_nibble(inst, 4)],
offset);
return 0;
}
@ -363,14 +363,14 @@ static ut16 thumb_disasm_hireg(struct winedbg_arm_insn *arminsn, ut16 inst) {
if (h2) src += 8;
if (op == 2 && dst == src) { /* mov rx, rx */
arminsn->str_asm = r_str_concatf(arminsn->str_asm, "nop");
arminsn->str_asm = r_str_appendf(arminsn->str_asm, "nop");
return 0;
}
if (op == 3)
arminsn->str_asm = r_str_concatf(arminsn->str_asm, "b%sx %s", h1?"l":"", tbl_regs[src]);
arminsn->str_asm = r_str_appendf(arminsn->str_asm, "b%sx %s", h1?"l":"", tbl_regs[src]);
else
arminsn->str_asm = r_str_concatf(arminsn->str_asm, "%s %s, %s", tbl_hiops_t[op], tbl_regs[dst], tbl_regs[src]);
arminsn->str_asm = r_str_appendf(arminsn->str_asm, "%s %s, %s", tbl_hiops_t[op], tbl_regs[dst], tbl_regs[src]);
return 0;
}
@ -380,7 +380,7 @@ static ut16 thumb_disasm_aluop(struct winedbg_arm_insn *arminsn, ut16 inst) {
short src = (inst >> 3) & 0x07;
short op = (inst >> 6) & 0x0f;
arminsn->str_asm = r_str_concatf(arminsn->str_asm, "%s %s, %s", tbl_aluops_t[op], tbl_regs[dst], tbl_regs[src]);
arminsn->str_asm = r_str_appendf(arminsn->str_asm, "%s %s, %s", tbl_aluops_t[op], tbl_regs[dst], tbl_regs[src]);
return 0;
}
@ -394,17 +394,17 @@ static ut16 thumb_disasm_pushpop(struct winedbg_arm_insn *arminsn, ut16 inst) {
if ((inst>>i) & 1) break;
last = i;
arminsn->str_asm = r_str_concatf(arminsn->str_asm, "%s {", load ? "pop" : "push");
arminsn->str_asm = r_str_appendf(arminsn->str_asm, "%s {", load ? "pop" : "push");
for (i=0;i<=7;i++)
if ((inst>>i) & 1) {
if (i == last) arminsn->str_asm = r_str_concatf(arminsn->str_asm, "%s", tbl_regs[i]);
else arminsn->str_asm = r_str_concatf(arminsn->str_asm, "%s, ", tbl_regs[i]);
if (i == last) arminsn->str_asm = r_str_appendf(arminsn->str_asm, "%s", tbl_regs[i]);
else arminsn->str_asm = r_str_appendf(arminsn->str_asm, "%s, ", tbl_regs[i]);
}
if (lrpc)
arminsn->str_asm = r_str_concatf(arminsn->str_asm, "%s%s", last ? ", " : "", load ? "pc" : "lr");
arminsn->str_asm = r_str_appendf(arminsn->str_asm, "%s%s", last ? ", " : "", load ? "pc" : "lr");
arminsn->str_asm = r_str_concatf(arminsn->str_asm, "}");
arminsn->str_asm = r_str_appendf(arminsn->str_asm, "}");
return 0;
}
@ -417,21 +417,21 @@ static ut16 thumb_disasm_blocktrans(struct winedbg_arm_insn *arminsn, ut16 inst)
if ((inst>>i) & 1) break;
last = i;
arminsn->str_asm = r_str_concatf(arminsn->str_asm, "%s %s!, {", load ? "ldmia" : "stmia", tbl_regs[(inst >> 8) & 0x07]);
arminsn->str_asm = r_str_appendf(arminsn->str_asm, "%s %s!, {", load ? "ldmia" : "stmia", tbl_regs[(inst >> 8) & 0x07]);
for (i=0;i<=7;i++)
if ((inst>>i) & 1) {
if (i == last) arminsn->str_asm = r_str_concatf(arminsn->str_asm, "%s", tbl_regs[i]);
else arminsn->str_asm = r_str_concatf(arminsn->str_asm, "%s, ", tbl_regs[i]);
if (i == last) arminsn->str_asm = r_str_appendf(arminsn->str_asm, "%s", tbl_regs[i]);
else arminsn->str_asm = r_str_appendf(arminsn->str_asm, "%s, ", tbl_regs[i]);
}
arminsn->str_asm = r_str_concatf(arminsn->str_asm, "}");
arminsn->str_asm = r_str_appendf(arminsn->str_asm, "}");
return 0;
}
static ut16 thumb_disasm_condbranch(struct winedbg_arm_insn *arminsn, ut16 inst) {
ut16 offset = inst & 0x00ff;
arminsn->str_asm = r_str_concatf(arminsn->str_asm, "b%s 0x%"PFMT64x, tbl_cond[(inst >> 8) & 0x0f], arminsn->pc+offset);
arminsn->str_asm = r_str_appendf(arminsn->str_asm, "b%s 0x%"PFMT64x, tbl_cond[(inst >> 8) & 0x0f], arminsn->pc+offset);
arminsn->jmp = arminsn->pc+offset;
arminsn->fail = arminsn->pc+4;
@ -443,7 +443,7 @@ static ut16 thumb_disasm_uncondbranch(struct winedbg_arm_insn *arminsn, ut16 ins
if (offset & 0x0800) offset |= 0xf000;
offset += 4;
arminsn->str_asm = r_str_concatf(arminsn->str_asm, "b 0x%"PFMT64x, arminsn->pc+offset);
arminsn->str_asm = r_str_appendf(arminsn->str_asm, "b 0x%"PFMT64x, arminsn->pc+offset);
arminsn->jmp = arminsn->pc+offset;
return 0;
@ -453,31 +453,31 @@ static ut16 thumb_disasm_loadadr(struct winedbg_arm_insn *arminsn, ut16 inst) {
ut16 src = (inst >> 11) & 0x01;
ut16 offset = (inst & 0xff) << 2;
arminsn->str_asm = r_str_concatf(arminsn->str_asm, "add %s, %s, #%d", tbl_regs[(inst >> 8) & 0x07], src ? "sp" : "pc",
arminsn->str_asm = r_str_appendf(arminsn->str_asm, "add %s, %s, #%d", tbl_regs[(inst >> 8) & 0x07], src ? "sp" : "pc",
offset);
return 0;
}
static ut16 thumb_disasm_swi(struct winedbg_arm_insn *arminsn, ut16 inst) {
ut16 comment = inst & 0x00ff;
arminsn->str_asm = r_str_concatf(arminsn->str_asm, "swi #%d", comment);
arminsn->str_asm = r_str_appendf(arminsn->str_asm, "swi #%d", comment);
return 0;
}
static ut16 thumb_disasm_nop(struct winedbg_arm_insn *arminsn, ut16 inst) {
arminsn->str_asm = r_str_concatf(arminsn->str_asm, "nop");
arminsn->str_asm = r_str_appendf(arminsn->str_asm, "nop");
return 0;
}
static ut16 thumb_disasm_ldrpcrel(struct winedbg_arm_insn *arminsn, ut16 inst) {
ut16 offset = (inst & 0xff) << 2;
arminsn->str_asm = r_str_concatf(arminsn->str_asm, "ldr %s, [pc, #%u]", tbl_regs[(inst >> 8) & 0x07], offset);
arminsn->str_asm = r_str_appendf(arminsn->str_asm, "ldr %s, [pc, #%u]", tbl_regs[(inst >> 8) & 0x07], offset);
return 0;
}
static ut16 thumb_disasm_ldrsprel(struct winedbg_arm_insn *arminsn, ut16 inst) {
ut16 offset = (inst & 0xff) << 2;
arminsn->str_asm = r_str_concatf(arminsn->str_asm, "%s %s, [sp, #%u]", (inst & 0x0800)?"ldr":"str",
arminsn->str_asm = r_str_appendf(arminsn->str_asm, "%s %s, [sp, #%u]", (inst & 0x0800)?"ldr":"str",
tbl_regs[(inst >> 8) & 0x07], offset);
return 0;
}
@ -485,15 +485,15 @@ static ut16 thumb_disasm_ldrsprel(struct winedbg_arm_insn *arminsn, ut16 inst) {
static ut16 thumb_disasm_addsprel(struct winedbg_arm_insn *arminsn, ut16 inst) {
ut16 offset = (inst & 0x7f) << 2;
if ((inst >> 7) & 0x01)
arminsn->str_asm = r_str_concatf(arminsn->str_asm, "sub sp, sp, #%u", offset);
arminsn->str_asm = r_str_appendf(arminsn->str_asm, "sub sp, sp, #%u", offset);
else
arminsn->str_asm = r_str_concatf(arminsn->str_asm, "add sp, sp, #%u", offset);
arminsn->str_asm = r_str_appendf(arminsn->str_asm, "add sp, sp, #%u", offset);
return 0;
}
static ut16 thumb_disasm_ldrimm(struct winedbg_arm_insn *arminsn, ut16 inst) {
ut16 offset = (inst & 0x07c0) >> 6;
arminsn->str_asm = r_str_concatf(arminsn->str_asm, "%s%s %s, [%s, #%u]",
arminsn->str_asm = r_str_appendf(arminsn->str_asm, "%s%s %s, [%s, #%u]",
(inst & 0x0800)?"ldr":"str", (inst & 0x1000)?"b":"",
tbl_regs[inst & 0x07], tbl_regs[(inst >> 3) & 0x07],
(inst & 0x1000)?offset:(offset << 2));
@ -502,13 +502,13 @@ static ut16 thumb_disasm_ldrimm(struct winedbg_arm_insn *arminsn, ut16 inst) {
static ut16 thumb_disasm_ldrhimm(struct winedbg_arm_insn *arminsn, ut16 inst) {
ut16 offset = (inst & 0x07c0) >> 5;
arminsn->str_asm = r_str_concatf(arminsn->str_asm, "%s %s, [%s, #%u]", (inst & 0x0800)?"ldrh":"strh",
arminsn->str_asm = r_str_appendf(arminsn->str_asm, "%s %s, [%s, #%u]", (inst & 0x0800)?"ldrh":"strh",
tbl_regs[inst & 0x07], tbl_regs[(inst >> 3) & 0x07], offset);
return 0;
}
static ut16 thumb_disasm_ldrreg(struct winedbg_arm_insn *arminsn, ut16 inst) {
arminsn->str_asm = r_str_concatf(arminsn->str_asm, "%s%s %s, [%s, %s]",
arminsn->str_asm = r_str_appendf(arminsn->str_asm, "%s%s %s, [%s, %s]",
(inst & 0x0800)?"ldr":"str", (inst & 0x0400)?"b":"",
tbl_regs[inst & 0x07], tbl_regs[(inst >> 3) & 0x07],
tbl_regs[(inst >> 6) & 0x07]);
@ -516,7 +516,7 @@ static ut16 thumb_disasm_ldrreg(struct winedbg_arm_insn *arminsn, ut16 inst) {
}
static ut16 thumb_disasm_ldrsreg(struct winedbg_arm_insn *arminsn, ut16 inst) {
arminsn->str_asm = r_str_concatf(arminsn->str_asm, "%s %s, [%s, %s]",
arminsn->str_asm = r_str_appendf(arminsn->str_asm, "%s %s, [%s, %s]",
tbl_sregops_t[(inst >> 10) & 0x03], tbl_regs[inst & 0x07],
tbl_regs[(inst >> 3) & 0x07], tbl_regs[(inst >> 6) & 0x07]);
return 0;
@ -524,7 +524,7 @@ static ut16 thumb_disasm_ldrsreg(struct winedbg_arm_insn *arminsn, ut16 inst) {
static ut16 thumb_disasm_immop(struct winedbg_arm_insn *arminsn, ut16 inst) {
ut16 op = (inst >> 11) & 0x03;
arminsn->str_asm = r_str_concatf(arminsn->str_asm, "%s %s, #%u", tbl_immops_t[op], tbl_regs[(inst >> 8) & 0x07],
arminsn->str_asm = r_str_appendf(arminsn->str_asm, "%s %s, #%u", tbl_immops_t[op], tbl_regs[(inst >> 8) & 0x07],
inst & 0xff);
return 0;
}
@ -533,25 +533,25 @@ static ut16 thumb_disasm_addsub(struct winedbg_arm_insn *arminsn, ut16 inst) {
ut16 op = (inst >> 9) & 0x01;
ut16 immediate = (inst >> 10) & 0x01;
arminsn->str_asm = r_str_concatf(arminsn->str_asm, "%s %s, %s, ", op ? "sub" : "add",
arminsn->str_asm = r_str_appendf(arminsn->str_asm, "%s %s, %s, ", op ? "sub" : "add",
tbl_regs[inst & 0x07], tbl_regs[(inst >> 3) & 0x07]);
if (immediate)
arminsn->str_asm = r_str_concatf(arminsn->str_asm, "#%d", (inst >> 6) & 0x07);
arminsn->str_asm = r_str_appendf(arminsn->str_asm, "#%d", (inst >> 6) & 0x07);
else
arminsn->str_asm = r_str_concatf(arminsn->str_asm, "%s", tbl_regs[(inst >> 6) & 0x07]);
arminsn->str_asm = r_str_appendf(arminsn->str_asm, "%s", tbl_regs[(inst >> 6) & 0x07]);
return 0;
}
static ut16 thumb_disasm_movshift(struct winedbg_arm_insn *arminsn, ut16 inst) {
ut16 op = (inst >> 11) & 0x03;
arminsn->str_asm = r_str_concatf(arminsn->str_asm, "%s %s, %s, #%u", tbl_shifts[op],
arminsn->str_asm = r_str_appendf(arminsn->str_asm, "%s %s, %s, #%u", tbl_shifts[op],
tbl_regs[inst & 0x07], tbl_regs[(inst >> 3) & 0x07], (inst >> 6) & 0x1f);
return 0;
}
static ut32 thumb2_disasm_branchlinked(struct winedbg_arm_insn *arminsn, ut32 inst) {
ut32 offset = (((inst & 0x07ff0000) >> 4) | ((inst & 0x000007ff) << 1)) + 4;
arminsn->str_asm = r_str_concatf(arminsn->str_asm, "bl 0x%"PFMT64x, arminsn->pc+offset);
arminsn->str_asm = r_str_appendf(arminsn->str_asm, "bl 0x%"PFMT64x, arminsn->pc+offset);
arminsn->jmp = arminsn->pc+offset;
return 0;
@ -565,7 +565,7 @@ static ut32 thumb2_disasm_misc(struct winedbg_arm_insn *arminsn, ut32 inst) {
return inst;
if (op1 == 3 && op2 == 0) {
arminsn->str_asm = r_str_concatf(arminsn->str_asm, "clz %s, %s ", tbl_regs[get_nibble(inst, 2)],
arminsn->str_asm = r_str_appendf(arminsn->str_asm, "clz %s, %s ", tbl_regs[get_nibble(inst, 2)],
tbl_regs[get_nibble(inst, 0)]);
return 0;
}
@ -573,19 +573,19 @@ static ut32 thumb2_disasm_misc(struct winedbg_arm_insn *arminsn, ut32 inst) {
if (op1 == 1) {
switch (op2) {
case 0:
arminsn->str_asm = r_str_concatf(arminsn->str_asm, "rev ");
arminsn->str_asm = r_str_appendf(arminsn->str_asm, "rev ");
break;
case 1:
arminsn->str_asm = r_str_concatf(arminsn->str_asm, "rev16 ");
arminsn->str_asm = r_str_appendf(arminsn->str_asm, "rev16 ");
break;
case 2:
arminsn->str_asm = r_str_concatf(arminsn->str_asm, "rbit ");
arminsn->str_asm = r_str_appendf(arminsn->str_asm, "rbit ");
break;
case 3:
arminsn->str_asm = r_str_concatf(arminsn->str_asm, "revsh ");
arminsn->str_asm = r_str_appendf(arminsn->str_asm, "revsh ");
break;
}
arminsn->str_asm = r_str_concatf(arminsn->str_asm, "%s, %s ", tbl_regs[get_nibble(inst, 2)], tbl_regs[get_nibble(inst, 0)]);
arminsn->str_asm = r_str_appendf(arminsn->str_asm, "%s, %s ", tbl_regs[get_nibble(inst, 2)], tbl_regs[get_nibble(inst, 0)]);
return 0;
}
@ -600,7 +600,7 @@ static ut32 thumb2_disasm_mul(struct winedbg_arm_insn *arminsn, ut32 inst) {
return inst;
if (op2 == 0 && get_nibble(inst, 3) != 0xf) {
arminsn->str_asm = r_str_concatf(arminsn->str_asm, "mla %s, %s, %s, %s ", tbl_regs[get_nibble(inst, 2)],
arminsn->str_asm = r_str_appendf(arminsn->str_asm, "mla %s, %s, %s, %s ", tbl_regs[get_nibble(inst, 2)],
tbl_regs[get_nibble(inst, 4)],
tbl_regs[get_nibble(inst, 0)],
tbl_regs[get_nibble(inst, 3)]);
@ -608,14 +608,14 @@ static ut32 thumb2_disasm_mul(struct winedbg_arm_insn *arminsn, ut32 inst) {
}
if (op2 == 0 && get_nibble(inst, 3) == 0xf) {
arminsn->str_asm = r_str_concatf(arminsn->str_asm, "mul %s, %s, %s ", tbl_regs[get_nibble(inst, 2)],
arminsn->str_asm = r_str_appendf(arminsn->str_asm, "mul %s, %s, %s ", tbl_regs[get_nibble(inst, 2)],
tbl_regs[get_nibble(inst, 4)],
tbl_regs[get_nibble(inst, 0)]);
return 0;
}
if (op2 == 1) {
arminsn->str_asm = r_str_concatf(arminsn->str_asm, "mls %s, %s, %s, %s ", tbl_regs[get_nibble(inst, 2)],
arminsn->str_asm = r_str_appendf(arminsn->str_asm, "mls %s, %s, %s, %s ", tbl_regs[get_nibble(inst, 2)],
tbl_regs[get_nibble(inst, 4)],
tbl_regs[get_nibble(inst, 0)],
tbl_regs[get_nibble(inst, 3)]);
@ -632,21 +632,21 @@ static ut32 thumb2_disasm_longmuldiv(struct winedbg_arm_insn *arminsn, ut32 inst
if (op2 == 0) {
switch (op1) {
case 0:
arminsn->str_asm = r_str_concatf(arminsn->str_asm, "smull ");
arminsn->str_asm = r_str_appendf(arminsn->str_asm, "smull ");
break;
case 2:
arminsn->str_asm = r_str_concatf(arminsn->str_asm, "umull ");
arminsn->str_asm = r_str_appendf(arminsn->str_asm, "umull ");
break;
case 4:
arminsn->str_asm = r_str_concatf(arminsn->str_asm, "smlal ");
arminsn->str_asm = r_str_appendf(arminsn->str_asm, "smlal ");
break;
case 6:
arminsn->str_asm = r_str_concatf(arminsn->str_asm, "umlal ");
arminsn->str_asm = r_str_appendf(arminsn->str_asm, "umlal ");
break;
default:
return inst;
}
arminsn->str_asm = r_str_concatf(arminsn->str_asm, "%s, %s, %s, %s ",
arminsn->str_asm = r_str_appendf(arminsn->str_asm, "%s, %s, %s, %s ",
tbl_regs[get_nibble(inst, 3)], tbl_regs[get_nibble(inst, 2)],
tbl_regs[get_nibble(inst, 4)], tbl_regs[get_nibble(inst, 0)]);
return 0;
@ -655,15 +655,15 @@ static ut32 thumb2_disasm_longmuldiv(struct winedbg_arm_insn *arminsn, ut32 inst
if (op2 == 0xffff) {
switch (op1) {
case 1:
arminsn->str_asm = r_str_concatf(arminsn->str_asm, "sdiv ");
arminsn->str_asm = r_str_appendf(arminsn->str_asm, "sdiv ");
break;
case 3:
arminsn->str_asm = r_str_concatf(arminsn->str_asm, "udiv ");
arminsn->str_asm = r_str_appendf(arminsn->str_asm, "udiv ");
break;
default:
return inst;
}
arminsn->str_asm = r_str_concatf(arminsn->str_asm, "%s, %s, %s ", tbl_regs[get_nibble(inst, 2)], tbl_regs[get_nibble(inst, 4)],
arminsn->str_asm = r_str_appendf(arminsn->str_asm, "%s, %s, %s ", tbl_regs[get_nibble(inst, 2)], tbl_regs[get_nibble(inst, 4)],
tbl_regs[get_nibble(inst, 0)]);
return 0;
}
@ -676,12 +676,12 @@ static ut32 thumb2_disasm_coprocmov1(struct winedbg_arm_insn *arminsn, ut32 inst
ut16 opc2 = (inst >> 5) & 0x07;
if (opc2)
arminsn->str_asm = r_str_concatf(arminsn->str_asm,
arminsn->str_asm = r_str_appendf(arminsn->str_asm,
"%s%s\tp%u, #%u, %s, cr%u, cr%u, #%u", (inst & 0x00100000)?"mrc":"mcr",
(inst & 0x10000000)?"2":"", get_nibble(inst, 2), opc1,
tbl_regs[get_nibble(inst, 3)], get_nibble(inst, 4), get_nibble(inst, 0), opc2);
else
arminsn->str_asm = r_str_concatf(arminsn->str_asm,
arminsn->str_asm = r_str_appendf(arminsn->str_asm,
"%s%s\tp%u, #%u, %s, cr%u, cr%u", (inst & 0x00100000)?"mrc":"mcr",
(inst & 0x10000000)?"2":"", get_nibble(inst, 2), opc1,
tbl_regs[get_nibble(inst, 3)], get_nibble(inst, 4), get_nibble(inst, 0));
@ -815,9 +815,9 @@ int arm_disasm_one_insn(struct winedbg_arm_insn *arminsn) {
}
if (!matched)
arminsn->str_asm = r_str_concatf(arminsn->str_asm, "Unknown ARM Instruction: %08x", inst);
arminsn->str_asm = r_str_appendf(arminsn->str_asm, "Unknown ARM Instruction: %08x", inst);
else a_ptr->func(arminsn, inst);
arminsn->str_hex = r_str_concatf(arminsn->str_hex, "%02x%02x%02x%02x",
arminsn->str_hex = r_str_appendf(arminsn->str_hex, "%02x%02x%02x%02x",
*((ut8*)(&inst)), *((ut8*)(&inst)+1), *((ut8*)(&inst)+2), *((ut8*)(&inst)+3));
return size;
} else {
@ -839,9 +839,9 @@ int arm_disasm_one_insn(struct winedbg_arm_insn *arminsn) {
}
if (!matched)
arminsn->str_asm = r_str_concatf(arminsn->str_asm, "Unknown Thumb2 Instruction: %08x", inst);
arminsn->str_asm = r_str_appendf(arminsn->str_asm, "Unknown Thumb2 Instruction: %08x", inst);
else t2_ptr->func(arminsn, inst);
arminsn->str_hex = r_str_concatf(arminsn->str_hex, "%02x%02x%02x%02x",
arminsn->str_hex = r_str_appendf(arminsn->str_hex, "%02x%02x%02x%02x",
*((ut8*)(&inst)), *((ut8*)(&inst)+1), *((ut8*)(&inst)+2), *((ut8*)(&inst)+3));
return size;
default:
@ -858,9 +858,9 @@ int arm_disasm_one_insn(struct winedbg_arm_insn *arminsn) {
}
if (!matched)
arminsn->str_asm = r_str_concatf(arminsn->str_asm, "Unknown Thumb Instruction: %04x", tinst);
arminsn->str_asm = r_str_appendf(arminsn->str_asm, "Unknown Thumb Instruction: %04x", tinst);
else t_ptr->func(arminsn, tinst);
arminsn->str_hex = r_str_concatf(arminsn->str_hex, "%02x%02x", *((ut8*)(&tinst)), *((ut8*)(&tinst)+1));
arminsn->str_hex = r_str_appendf(arminsn->str_hex, "%02x%02x", *((ut8*)(&tinst)), *((ut8*)(&tinst)+1));
return size;
}
return size;

View File

@ -75,37 +75,37 @@ static int dalvik_disassemble (RAsm *a, RAsmOp *op, const ut8 *buf, int len) {
vA = buf[1] & 0x0f;
vB = (buf[1] & 0xf0) >> 4;
snprintf (str, sizeof (str), " v%i, v%i", vA, vB);
strasm = r_str_concat (strasm, str);
strasm = r_str_append (strasm, str);
break;
case fmtopvAAvBBBB:
vA = (int) buf[1];
vB = (buf[3] << 8) | buf[2];
snprintf (str, sizeof (str), " v%i, v%i", vA, vB);
strasm = r_str_concat (strasm, str);
strasm = r_str_append (strasm, str);
break;
case fmtopvAAAAvBBBB: // buf[1] seems useless :/
vA = (buf[3] << 8) | buf[2];
vB = (buf[5] << 8) | buf[4];
snprintf (str, sizeof (str), " v%i, v%i", vA, vB);
strasm = r_str_concat (strasm, str);
strasm = r_str_append (strasm, str);
break;
case fmtopvAA:
vA = (int) buf[1];
snprintf (str, sizeof (str), " v%i", vA);
strasm = r_str_concat (strasm, str);
strasm = r_str_append (strasm, str);
break;
case fmtopvAcB:
vA = buf[1] & 0x0f;
vB = (buf[1] & 0xf0) >> 4;
snprintf (str, sizeof (str), " v%i, %#x", vA, vB);
strasm = r_str_concat (strasm, str);
strasm = r_str_append (strasm, str);
break;
case fmtopvAAcBBBB:
vA = (int) buf[1];
{
short sB = (buf[3] << 8) | buf[2];
snprintf (str, sizeof (str), " v%i, %#04hx", vA, sB);
strasm = r_str_concat (strasm, str);
strasm = r_str_append (strasm, str);
}
break;
case fmtopvAAcBBBBBBBB:
@ -116,7 +116,7 @@ static int dalvik_disassemble (RAsm *a, RAsmOp *op, const ut8 *buf, int len) {
} else { //const
snprintf (str, sizeof (str), " v%i, 0x%08x", vA, vB);
}
strasm = r_str_concat (strasm, str);
strasm = r_str_append (strasm, str);
break;
case fmtopvAAcBBBB0000:
vA = (int) buf[1];
@ -127,7 +127,7 @@ static int dalvik_disassemble (RAsm *a, RAsmOp *op, const ut8 *buf, int len) {
} else {
snprintf (str, sizeof (str), " v%i, 0x%08x", vA, vB);
}
strasm = r_str_concat (strasm, str);
strasm = r_str_append (strasm, str);
break;
case fmtopvAAcBBBBBBBBBBBBBBBB:
vA = (int) buf[1];
@ -138,52 +138,52 @@ static int dalvik_disassemble (RAsm *a, RAsmOp *op, const ut8 *buf, int len) {
((llint)buf[8] << 48) | ((llint)buf[9] << 56);
#undef llint
snprintf (str, sizeof (str), " v%i:v%i, 0x%"PFMT64x, vA, vA + 1, lB);
strasm = r_str_concat (strasm, str);
strasm = r_str_append (strasm, str);
break;
case fmtopvAAvBBvCC:
vA = (int) buf[1];
vB = (int) buf[2];
vC = (int) buf[3];
snprintf (str, sizeof (str), " v%i, v%i, v%i", vA, vB, vC);
strasm = r_str_concat (strasm, str);
strasm = r_str_append (strasm, str);
break;
case fmtopvAAvBBcCC:
vA = (int) buf[1];
vB = (int) buf[2];
vC = (int) buf[3];
snprintf (str, sizeof (str), " v%i, v%i, %#x", vA, vB, vC);
strasm = r_str_concat (strasm, str);
strasm = r_str_append (strasm, str);
break;
case fmtopvAvBcCCCC:
vA = buf[1] & 0x0f;
vB = (buf[1] & 0xf0) >> 4;
vC = (buf[3] << 8) | buf[2];
snprintf (str, sizeof (str), " v%i, v%i, %#x", vA, vB, vC);
strasm = r_str_concat (strasm, str);
strasm = r_str_append (strasm, str);
break;
case fmtoppAA:
vA = (char) buf[1];
//snprintf (str, sizeof (str), " %i", vA*2); // vA : word -> byte
snprintf (str, sizeof (str), " 0x%08"PFMT64x, a->pc + (vA * 2)); // vA : word -> byte
strasm = r_str_concat (strasm, str);
strasm = r_str_append (strasm, str);
break;
case fmtoppAAAA:
vA = (short) (buf[3] << 8 | buf[2]);
snprintf (str, sizeof (str), " 0x%08"PFMT64x, a->pc + (vA * 2)); // vA : word -> byte
strasm = r_str_concat (strasm, str);
strasm = r_str_append (strasm, str);
break;
case fmtopvAApBBBB: // if-*z
vA = (int) buf[1];
vB = (int) (buf[3] << 8 | buf[2]);
//snprintf (str, sizeof (str), " v%i, %i", vA, vB);
snprintf (str, sizeof (str), " v%i, 0x%08"PFMT64x, vA, a->pc + (vB * 2));
strasm = r_str_concat (strasm, str);
strasm = r_str_append (strasm, str);
break;
case fmtoppAAAAAAAA:
vA = (int) (buf[2] | (buf[3] << 8) | (buf[4] << 16) | (buf[5] << 24));
//snprintf (str, sizeof (str), " %#08x", vA*2); // vA: word -> byte
snprintf (str, sizeof (str), " 0x%08"PFMT64x, a->pc + (vA*2)); // vA : word -> byte
strasm = r_str_concat (strasm, str);
strasm = r_str_append (strasm, str);
break;
case fmtopvAvBpCCCC: // if-*
vA = buf[1] & 0x0f;
@ -191,13 +191,13 @@ static int dalvik_disassemble (RAsm *a, RAsmOp *op, const ut8 *buf, int len) {
vC = (int) (buf[3] << 8 | buf[2]);
//snprintf (str, sizeof (str), " v%i, v%i, %i", vA, vB, vC);
snprintf (str, sizeof (str)," v%i, v%i, 0x%08"PFMT64x, vA, vB, a->pc + (vC * 2));
strasm = r_str_concat (strasm, str);
strasm = r_str_append (strasm, str);
break;
case fmtopvAApBBBBBBBB:
vA = (int) buf[1];
vB = (int) (buf[2] | (buf[3] << 8) | (buf[4] << 16) | (buf[5] << 24));
snprintf (str, sizeof (str), " v%i, 0x%08"PFMT64x, vA, a->pc + vB); // + (vB*2));
strasm = r_str_concat (strasm, str);
strasm = r_str_append (strasm, str);
break;
case fmtoptinlineI:
vA = (int) (buf[1] & 0x0f);
@ -220,9 +220,9 @@ static int dalvik_disassemble (RAsm *a, RAsmOp *op, const ut8 *buf, int len) {
default:
snprintf (str, sizeof (str), " {}");
}
strasm = r_str_concat (strasm, str);
strasm = r_str_append (strasm, str);
snprintf (str, sizeof (str), ", [%04x]", vB);
strasm = r_str_concat (strasm, str);
strasm = r_str_append (strasm, str);
break;
case fmtoptinlineIR:
case fmtoptinvokeVSR:
@ -230,7 +230,7 @@ static int dalvik_disassemble (RAsm *a, RAsmOp *op, const ut8 *buf, int len) {
vB = (buf[3] << 8) | buf[2];
vC = (buf[5] << 8) | buf[4];
snprintf (str, sizeof (str), " {v%i..v%i}, [%04x]", vC, vC + vA - 1, vB);
strasm = r_str_concat (strasm, str);
strasm = r_str_append (strasm, str);
break;
case fmtoptinvokeVS:
vA = (int) (buf[1] & 0xf0) >> 4;
@ -254,9 +254,9 @@ static int dalvik_disassemble (RAsm *a, RAsmOp *op, const ut8 *buf, int len) {
snprintf (str, sizeof (str), " {}");
break;
}
strasm = r_str_concat (strasm, str);
strasm = r_str_append (strasm, str);
snprintf (str, sizeof (str), ", [%04x]", vB);
strasm = r_str_concat (strasm, str);
strasm = r_str_append (strasm, str);
break;
case fmtopvAAtBBBB: // "sput-*"
vA = (int) buf[1];
@ -283,7 +283,7 @@ static int dalvik_disassemble (RAsm *a, RAsmOp *op, const ut8 *buf, int len) {
snprintf (str, sizeof (str), " v%i, %s", vA, flag_str);
}
}
strasm = r_str_concat (strasm, str);
strasm = r_str_append (strasm, str);
break;
case fmtoptopvAvBoCCCC:
vA = (buf[1] & 0x0f);
@ -295,7 +295,7 @@ static int dalvik_disassemble (RAsm *a, RAsmOp *op, const ut8 *buf, int len) {
} else {
snprintf (str, sizeof (str), " v%i, v%i, [0x%"PFMT64x"]", vA, vB, offset);
}
strasm = r_str_concat (strasm, str);
strasm = r_str_append (strasm, str);
break;
case fmtopAAtBBBB:
vA = (int) buf[1];
@ -306,7 +306,7 @@ static int dalvik_disassemble (RAsm *a, RAsmOp *op, const ut8 *buf, int len) {
} else {
snprintf (str, sizeof (str), " v%i, 0x%"PFMT64x, vA, offset);
}
strasm = r_str_concat (strasm, str);
strasm = r_str_append (strasm, str);
break;
case fmtopvAvBtCCCC:
vA = (buf[1] & 0x0f);
@ -329,7 +329,7 @@ static int dalvik_disassemble (RAsm *a, RAsmOp *op, const ut8 *buf, int len) {
snprintf (str, sizeof (str), " v%i, v%i, field+%i", vA, vB, vC);
}
}
strasm = r_str_concat (strasm, str);
strasm = r_str_append (strasm, str);
break;
case fmtopvAAtBBBBBBBB:
vA = (int) buf[1];
@ -341,7 +341,7 @@ static int dalvik_disassemble (RAsm *a, RAsmOp *op, const ut8 *buf, int len) {
else {
snprintf (str, sizeof (str), " v%i, 0x%"PFMT64x, vA, offset);
}
strasm = r_str_concat (strasm, str);
strasm = r_str_append (strasm, str);
break;
case fmtopvCCCCmBBBB:
vA = (int) buf[1];
@ -364,7 +364,7 @@ static int dalvik_disassemble (RAsm *a, RAsmOp *op, const ut8 *buf, int len) {
snprintf (str, sizeof (str), " {v%i..v%i}, method+%i", vC, vC + vA - 1, vB);
}
}
strasm = r_str_concat (strasm, str);
strasm = r_str_append (strasm, str);
break;
case fmtopvXtBBBB:
vA = (int) (buf[1] & 0xf0) >> 4;
@ -391,7 +391,7 @@ static int dalvik_disassemble (RAsm *a, RAsmOp *op, const ut8 *buf, int len) {
default:
snprintf (str, sizeof (str), " {}");
}
strasm = r_str_concat (strasm, str);
strasm = r_str_append (strasm, str);
if (buf[0] == 0x24) { // filled-new-array
flag_str = R_ASM_GET_NAME (a, 'c', vB);
if (flag_str) {
@ -408,7 +408,7 @@ static int dalvik_disassemble (RAsm *a, RAsmOp *op, const ut8 *buf, int len) {
}
}
strasm = r_str_concat (strasm, str);
strasm = r_str_append (strasm, str);
break;
case fmtoptinvokeI: // Any opcode has this formats
case fmtoptinvokeIR:

View File

@ -281,8 +281,8 @@ R_API char *r_cons_hud_path(const char *path, int dir) {
if (files) {
ret = r_cons_hud (files, tmp);
if (ret) {
tmp = r_str_concat (tmp, "/");
tmp = r_str_concat (tmp, ret);
tmp = r_str_append (tmp, "/");
tmp = r_str_append (tmp, ret);
ret = r_file_abspath (tmp);
free (tmp);
tmp = ret;

View File

@ -138,7 +138,7 @@ R_API RList *r_core_asm_strsearch(RCore *core, const char *input, ut64 from, ut6
}
}
if (matches) {
code = r_str_concatf (code, "%s; ", op.buf_asm);
code = r_str_appendf (code, "%s; ", op.buf_asm);
if (matchcount == tokcount - 1) {
if (tokcount == 1) {
tidx = idx;

View File

@ -1852,7 +1852,7 @@ static char *build_hash_string(int mode, const char *chksum, ut8 *data, ut32 dat
} else {
aux = r_str_newf ("%s=%s ", tmp, chkstr);
}
ret = r_str_concat (ret, aux);
ret = r_str_append (ret, aux);
free (chkstr);
free (aux);
if (*ptr && *ptr == ',') ptr++;

View File

@ -661,7 +661,7 @@ static int cmd_interpret(void *data, const char *input) {
eol = strchr (ptr, '\n');
if (eol) *eol = '\0';
if (*ptr) {
char *p = r_str_concat (strdup (ptr), filter);
char *p = r_str_append (strdup (ptr), filter);
r_core_cmd0 (core, p);
free (p);
}
@ -1782,8 +1782,8 @@ next2:
}
}
}
str = r_str_concat (str, ptr2 + 1);
cmd = r_str_concat (strdup (cmd), str);
str = r_str_append (str, ptr2 + 1);
cmd = r_str_append (strdup (cmd), str);
core->num->value = value;
ret = r_core_cmd_subst (core, cmd);
free (cmd);

View File

@ -492,10 +492,10 @@ R_API char *cmd_syscall_dostr(RCore *core, int n) {
}
RSyscallItem *item = r_syscall_get (core->anal->syscall, n, -1);
if (!item) {
res = r_str_concatf (res, "%d = unknown ()", n);
res = r_str_appendf (res, "%d = unknown ()", n);
return res;
}
res = r_str_concatf (res, "%d = %s (", item->num, item->name);
res = r_str_appendf (res, "%d = %s (", item->num, item->name);
// TODO: move this to r_syscall
for (i = 0; i < item->args; i++) {
//TODO replace the hardcoded CC with the sdb ones
@ -504,17 +504,17 @@ R_API char *cmd_syscall_dostr(RCore *core, int n) {
if (item->sargs) {
switch (item->sargs[i]) {
case 'p': // pointer
res = r_str_concatf (res, "0x%08" PFMT64x "", arg);
res = r_str_appendf (res, "0x%08" PFMT64x "", arg);
break;
case 'i':
res = r_str_concatf (res, "%" PFMT64d "", arg);
res = r_str_appendf (res, "%" PFMT64d "", arg);
break;
case 'z':
r_io_read_at (core->io, arg, (ut8 *)str, sizeof (str));
// TODO: filter zero terminated string
str[63] = '\0';
r_str_filter (str, strlen (str));
res = r_str_concatf (res, "\"%s\"", str);
res = r_str_appendf (res, "\"%s\"", str);
break;
case 'Z': {
//TODO replace the hardcoded CC with the sdb ones
@ -526,20 +526,20 @@ R_API char *cmd_syscall_dostr(RCore *core, int n) {
(void)r_io_read_at (core->io, arg, (ut8 *)str, len);
str[len] = 0;
r_str_filter (str, -1);
res = r_str_concatf (res, "\"%s\"", str);
res = r_str_appendf (res, "\"%s\"", str);
} break;
default:
res = r_str_concatf (res, "0x%08" PFMT64x "", arg);
res = r_str_appendf (res, "0x%08" PFMT64x "", arg);
break;
}
} else {
res = r_str_concatf (res, "0x%08" PFMT64x "", arg);
res = r_str_appendf (res, "0x%08" PFMT64x "", arg);
}
if (i + 1 < item->args) {
res = r_str_concatf (res, ", ");
res = r_str_appendf (res, ", ");
}
}
res = r_str_concatf (res, ")");
res = r_str_appendf (res, ")");
return res;
}
@ -4443,14 +4443,14 @@ static void cmd_agraph_node(RCore *core, const char *input) {
}
body = newbody;
}
body = r_str_concat (body, "\n");
body = r_str_append (body, "\n");
} else {
body = strdup ("");
}
r_agraph_add_node (core->graph, args[0], body);
r_str_argv_free (args);
free (body);
//free newbody it's not necessary since r_str_concat reallocate the space
//free newbody it's not necessary since r_str_append reallocate the space
break;
}
case '-': {

View File

@ -23,7 +23,7 @@ static char *filterFlags(RCore *core, const char *msg) {
if (!dollar) {
break;
}
buf = r_str_concatlen (buf, msg, dollar-msg);
buf = r_str_appendlen (buf, msg, dollar-msg);
if (dollar[1]=='{') {
// find }
end = strchr (dollar+2, '}');
@ -32,7 +32,7 @@ static char *filterFlags(RCore *core, const char *msg) {
end++;
} else {
msg = dollar+1;
buf = r_str_concat (buf, "$");
buf = r_str_append (buf, "$");
continue;
}
} else {
@ -46,14 +46,14 @@ static char *filterFlags(RCore *core, const char *msg) {
ut64 val = r_num_math (core->num, word);
char num[32];
snprintf (num, sizeof (num), "0x%"PFMT64x, val);
buf = r_str_concat (buf, num);
buf = r_str_append (buf, num);
msg = end;
} else {
break;
}
free (word);
}
buf = r_str_concat (buf, msg);
buf = r_str_append (buf, msg);
return buf;
}

View File

@ -288,7 +288,7 @@ static char* rop_classify_constant(RCore *core, RList *ropList) {
if (value_dst != diff_dst) {
r_list_foreach (constants, iter_const, constant) {
if (value_dst == r_num_get (NULL, constant)) {
ct = r_str_concatf (ct, "%s <-- 0x%"PFMT64x";", item_dst->name, value_dst);
ct = r_str_appendf (ct, "%s <-- 0x%"PFMT64x";", item_dst->name, value_dst);
}
}
}
@ -386,7 +386,7 @@ static char* rop_classify_mov(RCore *core, RList *ropList) {
//restore initial value
r_reg_set_value (core->dbg->reg, item_src, diff_src);
if (value_dst == value_src && value_dst != diff_dst) {
mov = r_str_concatf (mov, "%s <-- %s;",
mov = r_str_appendf (mov, "%s <-- %s;",
item_dst->name, item_src->name);
}
}
@ -496,9 +496,9 @@ static char* rop_classify_arithmetic(RCore *core, RList *ropList) {
// r_cons_println ("Debug: FOUND ONE !");
char *tmp = r_str_newf ("%s <-- %s %s %s;", item_dst->name, item_src1->name, op, item_src2->name);
if (arithmetic && !strstr (arithmetic, tmp)) {
arithmetic = r_str_concat (arithmetic, tmp);
arithmetic = r_str_append (arithmetic, tmp);
} else if (!arithmetic) {
arithmetic = r_str_concat (arithmetic, tmp);
arithmetic = r_str_append (arithmetic, tmp);
}
free (tmp);
redundant = true;
@ -506,9 +506,9 @@ static char* rop_classify_arithmetic(RCore *core, RList *ropList) {
// r_cons_println ("Debug: FOUND ONE reversed!");
char *tmp = r_str_newf ("%s <-- %s %s %s;", item_dst->name, item_src2->name, op, item_src1->name);
if (arithmetic && !strstr (arithmetic, tmp)) {
arithmetic = r_str_concat (arithmetic, tmp);
arithmetic = r_str_append (arithmetic, tmp);
} else if (!arithmetic) {
arithmetic = r_str_concat (arithmetic, tmp);
arithmetic = r_str_append (arithmetic, tmp);
}
free (tmp);
}
@ -623,18 +623,18 @@ static char* rop_classify_arithmetic_const(RCore *core, RList *ropList) {
if (simulate && value_dst == *op_result) {
char *tmp = r_str_newf ("%s <-- %s %s %s;", item_dst->name, item_src1->name, op, constant);
if (arithmetic && !strstr (arithmetic, tmp)) {
arithmetic = r_str_concat (arithmetic, tmp);
arithmetic = r_str_append (arithmetic, tmp);
} else if (!arithmetic) {
arithmetic = r_str_concat (arithmetic, tmp);
arithmetic = r_str_append (arithmetic, tmp);
}
free (tmp);
redundant = true;
} else if (!redundant && simulate_r && value_dst == *op_result_r) {
char *tmp = r_str_newf ("%s <-- %s %s %s;", item_dst->name, constant, op, item_src1->name);
if (arithmetic && !strstr (arithmetic, tmp)) {
arithmetic = r_str_concat (arithmetic, tmp);
arithmetic = r_str_append (arithmetic, tmp);
} else if (!arithmetic) {
arithmetic = r_str_concat (arithmetic, tmp);
arithmetic = r_str_append (arithmetic, tmp);
}
free (tmp);
}

View File

@ -1249,7 +1249,7 @@ static char *getbitfield(void *_core, const char *name, ut64 val) {
isenum = sdb_const_get (core->anal->sdb_types, name, 0);
if (isenum && !strcmp (isenum, "enum")) {
int isFirst = true;
ret = r_str_concatf (ret, "0x%08"PFMT64x" : ", val);
ret = r_str_appendf (ret, "0x%08"PFMT64x" : ", val);
for (i = 0; i < 32; i++) {
if (!(val & (1 << i))) {
continue;
@ -1259,12 +1259,12 @@ static char *getbitfield(void *_core, const char *name, ut64 val) {
if (isFirst) {
isFirst = false;
} else {
ret = r_str_concat (ret, " | ");
ret = r_str_append (ret, " | ");
}
if (res) {
ret = r_str_concat (ret, res);
ret = r_str_append (ret, res);
} else {
ret = r_str_concatf (ret, "0x%x", (1<<i));
ret = r_str_appendf (ret, "0x%x", (1<<i));
}
}
} else {

View File

@ -821,7 +821,7 @@ static void ds_pre_xrefs(RDisasmState *ds) {
ds_setup_pre (ds, false, false);
if (*ds->pre != ' ') {
ds_set_pre (ds, core->cons->vline[LINE_VERT]);
ds->pre = r_str_concat (ds->pre, " ");
ds->pre = r_str_append (ds->pre, " ");
}
}
ds_print_pre (ds);
@ -1161,7 +1161,7 @@ static void ds_show_functions(RDisasmState *ds) {
R_FREE (sign);
ds_set_pre (ds, core->cons->vline[LINE_VERT]);
if (ds->show_fcnlines) {
ds->pre = r_str_concat (ds->pre, " ");
ds->pre = r_str_append (ds->pre, " ");
}
ds->stackptr = core->anal->stackptr;
if (ds->show_vars) {
@ -1320,7 +1320,7 @@ static void ds_setup_pre(RDisasmState *ds, bool tail, bool middle) {
ds_set_pre (ds, core->cons->vline[LINE_VERT]);
}
if (ds->show_fcnlines) {
ds->pre = r_str_concat (ds->pre, " ");
ds->pre = r_str_append (ds->pre, " ");
}
if (tail) {
r_str_replace_char (ds->pre, '\\', ' ');
@ -2899,7 +2899,7 @@ static int myregwrite(RAnalEsil *esil, const char *name, ut64 *val) {
}
RFlagItem *fi = r_flag_get_i (esil->anal->flb.f, *val);
if (fi) {
msg = r_str_concatf (msg, "%s", fi->name);
msg = r_str_appendf (msg, "%s", fi->name);
}
}
if (ds) {

View File

@ -2432,9 +2432,9 @@ static void agraph_merge_child(RAGraph *g, int idx) {
if (cn && nn) {
RANode *ann = get_anode (nn);
RANode *acn = get_anode (cn);
acn->body = r_str_concat (acn->body, ann->title);
acn->body = r_str_concat (acn->body, "\n");
acn->body = r_str_concat (acn->body, ann->body);
acn->body = r_str_append (acn->body, ann->title);
acn->body = r_str_append (acn->body, "\n");
acn->body = r_str_append (acn->body, ann->body);
/* remove node from the graph */
acn->h += ann->h - 3;
free (ann->body);

View File

@ -262,7 +262,7 @@ static bool GH(r_resolve_main_arena)(RCore *core, GHT *m_arena, GH(RHeap_MallocS
if (r_file_exists (path)) {
goto arena;
}
path = r_str_concat (path, ".debug");
path = r_str_append (path, ".debug");
if (r_file_exists (path)) {
goto arena;
}

View File

@ -45,10 +45,10 @@ static char *projectScriptPath(RCore *core, const char *file) {
}
prjfile = r_file_abspath (r_config_get (
core->config, "dir.projects"));
prjfile = r_str_concat (prjfile, R_SYS_DIR);
prjfile = r_str_concat (prjfile, file);
prjfile = r_str_append (prjfile, R_SYS_DIR);
prjfile = r_str_append (prjfile, file);
if (!r_file_exists (prjfile) || r_file_is_directory (prjfile)) {
prjfile = r_str_concat (prjfile, R_SYS_DIR "rc");
prjfile = r_str_append (prjfile, R_SYS_DIR "rc");
}
}
data = r_file_slurp (prjfile, NULL);
@ -82,7 +82,7 @@ static bool r_core_is_project(RCore *core, const char *name) {
if (r_str_endswith (path, R_SYS_DIR "rc") && r_file_exists (path)) {
ret = true;
} else {
path = r_str_concat (path, ".d");
path = r_str_append (path, ".d");
if (r_file_is_directory (path)) {
ret = true;
}
@ -156,14 +156,14 @@ R_API int r_core_project_delete(RCore *core, const char *prjfile) {
// rm project file
r_file_rm (path);
eprintf ("rm %s\n", path);
path = r_str_concat (path, ".d");
path = r_str_append (path, ".d");
if (r_file_is_directory (path)) {
char *f;
RListIter *iter;
RList *files = r_sys_dir (path);
r_list_foreach (files, iter, f) {
char *filepath = r_str_concat (strdup (path), R_SYS_DIR);
filepath =r_str_concat (filepath, f);
char *filepath = r_str_append (strdup (path), R_SYS_DIR);
filepath =r_str_append (filepath, f);
if (!r_file_is_directory (filepath)) {
eprintf ("rm %s\n", filepath);
r_file_rm (filepath);
@ -257,7 +257,7 @@ static bool projectLoadRop(RCore *core, const char *prjfile) {
path_ns = r_str_newf ("%s" R_SYS_DIR "rop", prjDir);
if (!r_file_exists (path_ns)) {
path_ns = r_str_concat (path_ns, ".sdb");
path_ns = r_str_append (path_ns, ".sdb");
}
nop_db = sdb_new (path_ns, "nop", 0);
sdb_ns_set (rop_db, "nop", nop_db);
@ -752,7 +752,7 @@ static bool projectLoadXrefs(RCore *core, const char *prjName) {
return false;
}
if (!r_file_is_directory (db)) {
db = r_str_concat (db, ".d");
db = r_str_append (db, ".d");
}
if (!sdb_ns_unset (core->anal->sdb, NULL, DB)) {

View File

@ -356,11 +356,11 @@ static char *rtr_dir_files (const char *path) {
eprintf ("Listing directory %s\n", path);
r_list_foreach (files, iter, file) {
if (file[0] == '.') continue;
ptr = r_str_concatf (ptr, "<a href=\"%s%s\">%s</a><br />\n",
ptr = r_str_appendf (ptr, "<a href=\"%s%s\">%s</a><br />\n",
path, file, file);
}
r_list_free (files);
return r_str_concat (ptr, "</body></html>\n");
return r_str_append (ptr, "</body></html>\n");
}
#if __UNIX__
@ -708,8 +708,8 @@ static int r_core_rtr_http_run(RCore *core, int launch, const char *path) {
}
// FD IS OK HERE
if (rs->path [strlen (rs->path) - 1] == '/') {
path = r_str_concat (path, "index.html");
//rs->path = r_str_concat (rs->path, "index.html");
path = r_str_append (path, "index.html");
//rs->path = r_str_append (rs->path, "index.html");
} else {
//snprintf (path, sizeof (path), "%s/%s", root, rs->path);
if (r_file_is_directory (path)) {
@ -1385,7 +1385,7 @@ R_API char *r_core_rtr_cmds_query (RCore *core, const char *host, const char *po
int ret = r_socket_read (s, buf, sizeof (buf));
if (ret < 1) break;
buf[ret] = 0;
rbuf = r_str_concat (rbuf, (const char *)buf);
rbuf = r_str_append (rbuf, (const char *)buf);
}
} else {
eprintf ("Cannot connect\n");

View File

@ -90,9 +90,9 @@ static char *colorize_asm_string(RCore *core, const char *buf_asm, int optype) {
return source;
}
char *res = strdup("");
res = r_str_concat (res, r_print_color_op_type (core->print, optype));
res = r_str_append (res, r_print_color_op_type (core->print, optype));
tmp = r_print_colorize_opcode (source, color_reg, color_num);
res = r_str_concat (res, tmp);
res = r_str_append (res, tmp);
free (tmp);
return res;
}
@ -894,7 +894,7 @@ R_API int r_core_visual_classes(RCore *core) {
break;
default:
grep = grep
? r_str_concatf (grep, "%c", ch)
? r_str_appendf (grep, "%c", ch)
: r_str_newf ("%c", ch);
break;
}

View File

@ -83,7 +83,7 @@ int linux_handle_signals (RDebug *dbg, bool self_signalled) {
} else {
name = r_reg_get_name (dbg->reg, R_REG_NAME_A1);
}
b->data = r_str_concatf (b->data, ";ps@r:%s", name);
b->data = r_str_appendf (b->data, ";ps@r:%s", name);
dbg->reason.type = R_DEBUG_REASON_NEW_LIB;
} else if (r_str_startswith (p, "dbg.unlibs")) {
dbg->reason.type = R_DEBUG_REASON_EXIT_LIB;

View File

@ -116,9 +116,9 @@ static char *find_include(const char *prefix, const char *file) {
if (ptr)
*ptr = 0;
free (ret);
ret = r_str_concatf (NULL, "%s/%s", pfx, file);
ret = r_str_appendf (NULL, "%s/%s", pfx, file);
{
char *filepath = r_str_concatf (NULL, "%s/%s/%s", str, pfx, file);
char *filepath = r_str_appendf (NULL, "%s/%s/%s", str, pfx, file);
// eprintf ("try (%s)\n", filepath);
if (r_file_exists (filepath)) {
free (env);
@ -133,7 +133,7 @@ static char *find_include(const char *prefix, const char *file) {
ptr = strchr (str, ':');
}
free (env);
} else ret = r_str_concatf (NULL, "%s/%s", pfx, file);
} else ret = r_str_appendf (NULL, "%s/%s", pfx, file);
free (pfx);
return ret;
}
@ -147,7 +147,7 @@ R_API void r_egg_lang_include_path (REgg *egg, const char *path) {
env = r_sys_getenv (R_EGG_INCDIR_ENV);
tmp_ptr = env;
}
env = r_str_concatf (NULL, "%s:%s", path, env);
env = r_str_appendf (NULL, "%s:%s", path, env);
free (tmp_ptr);
r_sys_setenv (R_EGG_INCDIR_ENV, env);
free (env);

View File

@ -400,7 +400,7 @@ R_API char *r_flag_get_liststr(RFlag *f, ut64 off) {
const RList *list = r_flag_get_list (f, off);
char *p = NULL;
r_list_foreach (list, iter, fi) {
p = r_str_concatf (p, "%s%s",
p = r_str_appendf (p, "%s%s",
fi->realname, iter->n ? "," : ":");
}
return p;

View File

@ -44,7 +44,7 @@ R_API void r_str_argv_free(char **argv);
R_API char *r_str_new(const char *str);
R_API int r_str_is_printable(const char *str);
R_API bool r_str_is_printable_incl_newlines(const char *str);
R_API char *r_str_concatlen(char *ptr, const char *string, int slen);
R_API char *r_str_appendlen(char *ptr, const char *string, int slen);
R_API char *r_str_newf(const char *fmt, ...);
R_API char *r_str_newlen(const char *str, int len);
R_API const char *r_str_bool(int b);
@ -110,9 +110,9 @@ R_API int r_str_nlen_w(const char *s, int n);
R_API int r_wstr_clen(const char *s);
R_API char *r_str_prefix(char *ptr, const char *string);
R_API char *r_str_prefix_all(char *s, const char *pfx);
R_API char *r_str_concat(char *ptr, const char *string);
R_API char *r_str_concatf(char *ptr, const char *fmt, ...);
R_API char *r_str_concatch(char *x, char y);
R_API char *r_str_append(char *ptr, const char *string);
R_API char *r_str_appendf(char *ptr, const char *fmt, ...);
R_API char *r_str_appendch(char *x, char y);
R_API void r_str_case(char *str, bool up);
R_API void r_str_chop_path(char *s);
R_API ut8 r_str_contains_macro(const char *input_value);

View File

@ -101,7 +101,7 @@ static int fork_and_ptraceme(RIO *io, int bits, const char *cmd) {
HANDLE th = INVALID_HANDLE_VALUE;
if (!*cmd) return -1;
setup_tokens ();
char *_cmd = io->args ? r_str_concatf (strdup (cmd), " %s", io->args) :
char *_cmd = io->args ? r_str_appendf (strdup (cmd), " %s", io->args) :
strdup (cmd);
char **argv = r_str_argv (_cmd, NULL);
// We need to build a command line with quoted argument and escaped quotes
@ -218,7 +218,7 @@ static int fork_and_ptraceme(RIO *io, int bits, const char *cmd) {
pid_t p = -1;
int ret, useASLR = io->aslr;
char *_cmd = io->args
? r_str_concatf (strdup (cmd), " %s", io->args)
? r_str_appendf (strdup (cmd), " %s", io->args)
: strdup (cmd);
argv = r_str_argv (_cmd, NULL);
if (!argv) {
@ -328,7 +328,7 @@ static int fork_and_ptraceme(RIO *io, int bits, const char *cmd) {
exit (1);
} else {
char *_cmd = io->args ?
r_str_concatf (strdup (cmd), " %s", io->args) :
r_str_appendf (strdup (cmd), " %s", io->args) :
strdup (cmd);
trace_me ();

View File

@ -19,7 +19,7 @@ static int lang_lib_file_run (RLang *user, const char *file) {
}
if (!r_file_exists (libpath)) {
if (!r_str_endswith(libpath, R_LIB_EXT)) {
libpath = r_str_concatf (libpath, ".%s", R_LIB_EXT);
libpath = r_str_appendf (libpath, ".%s", R_LIB_EXT);
}
}
if (!r_file_exists (libpath)) {

View File

@ -150,7 +150,7 @@ R_API int r_reg_set_profile_string(RReg *reg, const char *str) {
while (*q != '\n') {
q++;
}
reg->reg_profile_cmt = r_str_concatlen (
reg->reg_profile_cmt = r_str_appendlen (
reg->reg_profile_cmt, p, (int)(q - p) + 1);
p = q;
continue;
@ -235,7 +235,7 @@ R_API int r_reg_set_profile(RReg *reg, const char *profile) {
if (!str) {
base = r_sys_getenv (R_LIB_ENV);
if (base) {
file = r_str_concat (base, profile);
file = r_str_append (base, profile);
str = r_file_slurp (file, NULL);
free (file);
}

View File

@ -490,8 +490,8 @@ R_API char *r_file_root(const char *root, const char *path) {
while (strstr (s, "//")) {
s = r_str_replace (s, "//", "", 1);
}
ret = r_str_concat (strdup (root), R_SYS_DIR);
ret = r_str_concat (ret, s);
ret = r_str_append (strdup (root), R_SYS_DIR);
ret = r_str_append (ret, s);
free (s);
return ret;
}

View File

@ -91,11 +91,11 @@ R_API char *r_lib_path(const char *libname) {
#if __APPLE__
char *env = r_sys_getenv ("DYLD_LIBRARY_PATH");
const char *ext = ".dylib";
env = r_str_concat (env, ":/lib:/usr/lib:/usr/local/lib");
env = r_str_append (env, ":/lib:/usr/lib:/usr/local/lib");
#elif __UNIX__
char *env = r_sys_getenv ("LD_LIBRARY_PATH");
const char *ext = ".so";
env = r_str_concat (env, ":/lib:/usr/lib:/usr/local/lib");
env = r_str_append (env, ":/lib:/usr/lib:/usr/local/lib");
#else
char *env = strdup (".:../../../../../../../windows/system32");
const char *ext = ".dll";

View File

@ -909,9 +909,9 @@ R_API char *r_str_prefix(char *ptr, const char *string) {
return ptr;
}
R_API char *r_str_concatlen(char *ptr, const char *string, int slen) {
R_API char *r_str_appendlen(char *ptr, const char *string, int slen) {
char *msg = r_str_newlen (string, slen);
char *ret = r_str_concat (ptr, msg);
char *ret = r_str_append (ptr, msg);
free (msg);
return ret;
}
@ -920,7 +920,7 @@ R_API char *r_str_concatlen(char *ptr, const char *string, int slen) {
* first argument must be allocated
* return: the pointer ptr resized to string size.
*/
R_API char *r_str_concat(char *ptr, const char *string) {
R_API char *r_str_append(char *ptr, const char *string) {
int slen, plen;
if (!string && !ptr) {
return NULL;
@ -941,7 +941,7 @@ R_API char *r_str_concat(char *ptr, const char *string) {
return ptr;
}
R_API char *r_str_concatf(char *ptr, const char *fmt, ...) {
R_API char *r_str_appendf(char *ptr, const char *fmt, ...) {
int ret;
char string[4096];
va_list ap;
@ -954,18 +954,18 @@ R_API char *r_str_concatf(char *ptr, const char *fmt, ...) {
return NULL;
}
vsnprintf (p, ret + 1, fmt, ap);
ptr = r_str_concat (ptr, p);
ptr = r_str_append (ptr, p);
free (p);
} else {
ptr = r_str_concat (ptr, string);
ptr = r_str_append (ptr, string);
}
va_end (ap);
return ptr;
}
R_API char *r_str_concatch(char *x, char y) {
R_API char *r_str_appendch(char *x, char y) {
char b[2] = { y, 0 };
return r_str_concat (x,b);
return r_str_append (x,b);
}
// XXX: wtf must deprecate

View File

@ -446,13 +446,13 @@ R_API int r_sys_cmd_str_full(const char *cmd, const char *input, char **output,
if (len) {
*len += bytes;
}
outputptr = r_str_concat (outputptr, buffer);
outputptr = r_str_append (outputptr, buffer);
} else if (FD_ISSET (sh_err[0], &rfds) && sterr) {
if (!read (sh_err[0], buffer, sizeof (buffer)-1)) {
break;
}
buffer[sizeof(buffer) - 1] = '\0';
*sterr = r_str_concat (*sterr, buffer);
*sterr = r_str_append (*sterr, buffer);
} else if (FD_ISSET (sh_in[1], &wfds) && inputptr && *inputptr) {
int inputptr_len = strlen (inputptr);
bytes = write (sh_in[1], inputptr, inputptr_len);

View File

@ -23,7 +23,7 @@ static char *showfile(char *res, const int nth, const char *fpath, const char *n
}
const bool isdir = r_file_is_directory (n);
if (isdir) {
nn = r_str_concat (strdup (fpath), "/");
nn = r_str_append (strdup (fpath), "/");
} else {
nn = strdup (fpath);
}
@ -34,7 +34,7 @@ static char *showfile(char *res, const int nth, const char *fpath, const char *n
perm = isdir? 0755: 0644;
if (!printfmt) {
needs_newline = ((nth + 1) % 4)? 1: 0;
res = r_str_concatf (res, "%18s%s", nn, needs_newline? " ": "\n");
res = r_str_appendf (res, "%18s%s", nn, needs_newline? " ": "\n");
free (nn);
return res;
}
@ -73,7 +73,7 @@ static char *showfile(char *res, const int nth, const char *fpath, const char *n
fch = isdir? 'd': '-';
#endif
if (printfmt == FMT_RAW) {
res = r_str_concatf (res, "%c%s%s%s 1 %4d:%-4d %-10d %s\n",
res = r_str_appendf (res, "%c%s%s%s 1 %4d:%-4d %-10d %s\n",
isdir?'d': fch,
u_rwx? u_rwx: "-",
r_str_rwx_i ((perm >> 3) & 7),
@ -81,9 +81,9 @@ static char *showfile(char *res, const int nth, const char *fpath, const char *n
uid, gid, sz, nn);
} else if (printfmt == FMT_JSON) {
if (nth > 0) {
res = r_str_concat (res, ",");
res = r_str_append (res, ",");
}
res = r_str_concatf (res, "{\"name\":\"%s\",\"size\":%d,\"uid\":%d,"
res = r_str_appendf (res, "{\"name\":\"%s\",\"size\":%d,\"uid\":%d,"
"\"gid\":%d,\"perm\":%d,\"isdir\":%s}",
name, sz, uid, gid, perm, isdir?"true":"false");
}
@ -183,7 +183,7 @@ R_API char *r_syscmd_ls(const char *input) {
if (path[strlen (path) - 1] == '/') {
dir = strdup (path);
} else {
dir = r_str_concat (strdup (path), "/");
dir = r_str_append (strdup (path), "/");
}
int nth = 0;
if (printfmt == FMT_JSON) {
@ -191,7 +191,7 @@ R_API char *r_syscmd_ls(const char *input) {
}
needs_newline = 0;
r_list_foreach (files, iter, name) {
char *n = r_str_concat (strdup (dir), name);
char *n = r_str_append (strdup (dir), name);
if (!n) {
break;
}
@ -204,10 +204,10 @@ R_API char *r_syscmd_ls(const char *input) {
free (n);
}
if (printfmt == FMT_JSON) {
res = r_str_concat (res, "]");
res = r_str_append (res, "]");
}
if (needs_newline) {
res = r_str_concat (res, "\n");
res = r_str_append (res, "\n");
}
free (dir);
free (d);