mirror of
https://github.com/radareorg/radare2.git
synced 2024-11-24 05:40:10 +00:00
Fix pxj-X, and add tests ##print
This commit is contained in:
parent
97c594d009
commit
8ddc8844bd
@ -5171,7 +5171,8 @@ static int cmd_print(void *data, const char *input) {
|
||||
RCore *core = (RCore *) data;
|
||||
st64 l;
|
||||
int i, len, ret;
|
||||
ut8* block;
|
||||
ut8* block = NULL;
|
||||
bool myblock = false;
|
||||
ut32 tbs = core->blocksize;
|
||||
ut64 n, off, from, to, at, ate, piece;
|
||||
ut64 tmpseek = UT64_MAX;
|
||||
@ -5183,7 +5184,7 @@ static int cmd_print(void *data, const char *input) {
|
||||
/* !strncmp (input, "du", 2) */
|
||||
if (input[0] == 'd' && input[1] == 'u') { // "pdu"
|
||||
/* hijack here for now, idk how to more cleanly integrate it */
|
||||
return cmd_pdu (core, input+2);
|
||||
return cmd_pdu (core, input + 2);
|
||||
}
|
||||
|
||||
r_print_init_rowoffsets (core->print);
|
||||
@ -5192,6 +5193,12 @@ static int cmd_print(void *data, const char *input) {
|
||||
if (input[0] && input[1]) {
|
||||
int idx = (input[0] == 'h')? 2: 1;
|
||||
const char *p = off? strchr (input + idx, ' '): NULL;
|
||||
if (!p) {
|
||||
p = strchr (input, '-');
|
||||
if (p) {
|
||||
p--;
|
||||
}
|
||||
}
|
||||
if (p) {
|
||||
l = (int) r_num_math (core->num, p + 1);
|
||||
/* except disasm and memoryfmt (pd, pm) and overlay (po) */
|
||||
@ -5217,7 +5224,16 @@ static int cmd_print(void *data, const char *input) {
|
||||
}
|
||||
|
||||
if (len > core->blocksize) {
|
||||
len = core->blocksize;
|
||||
block = calloc (1, len);
|
||||
if (block) {
|
||||
r_io_read_at (core->io, core->offset - len, block, len);
|
||||
myblock = true;
|
||||
} else {
|
||||
len = core->blocksize;
|
||||
block = core->block;
|
||||
}
|
||||
} else {
|
||||
block = core->block;
|
||||
}
|
||||
|
||||
if (input[0] != 'd' && input[0] != 'm' && input[0] != 'a' && input[0] != 'f' && input[0] != 'i') {
|
||||
@ -5263,7 +5279,6 @@ static int cmd_print(void *data, const char *input) {
|
||||
r_core_seek (core, off, SEEK_SET);
|
||||
r_core_block_read (core);
|
||||
}
|
||||
block = core->block;
|
||||
switch (*input) {
|
||||
case 'w': // "pw"
|
||||
if (input[1] == 'n') {
|
||||
@ -7351,6 +7366,9 @@ static int cmd_print(void *data, const char *input) {
|
||||
break;
|
||||
}
|
||||
beach:
|
||||
if (myblock) {
|
||||
free (block);
|
||||
}
|
||||
if (tmpseek != UT64_MAX) {
|
||||
r_core_seek (core, tmpseek, SEEK_SET);
|
||||
r_core_block_read (core);
|
||||
|
@ -1,3 +1,25 @@
|
||||
NAME=pxj
|
||||
FILE=-
|
||||
CMDS=<<EOF
|
||||
woe 1
|
||||
pxj 10
|
||||
pxj -10
|
||||
b 16
|
||||
pxj
|
||||
pxj 32
|
||||
pxj -32
|
||||
pxj-32
|
||||
EOF
|
||||
EXPECT=<<EOF
|
||||
[0,1,2,3,4,5,6,7,8,9]
|
||||
[255,255,255,255,255,255,255,255,255,255]
|
||||
[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]
|
||||
[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31]
|
||||
[255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255]
|
||||
[255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255]
|
||||
EOF
|
||||
RUN
|
||||
|
||||
NAME=pv3
|
||||
FILE=malloc://1024
|
||||
CMDS=<<EOF
|
||||
|
Loading…
Reference in New Issue
Block a user