@@ -5710,22 +5710,21 @@ static int cmd_print(void *data, const char *input) {
5710
5710
r_print_init_rowoffsets (core -> print );
5711
5711
tmpseek = core -> offset ;
5712
5712
l = len = core -> blocksize ;
5713
+ bool must_read = false;
5713
5714
if (input [0 ] && input [1 ]) {
5714
5715
int idx = (input [0 ] == 'h' )? 2 : 1 ;
5715
5716
const char * p = strchr (input + idx , ' ' );
5716
5717
if (!p ) {
5717
5718
p = strchr (input , '-' );
5718
- if (p ) {
5719
- p -- ;
5720
- }
5721
5719
}
5722
5720
if (p ) {
5723
- l = (int ) r_num_math (core -> num , p + 1 );
5721
+ l = (int ) r_num_math (core -> num , p );
5724
5722
/* except disasm and memoryfmt (pd, pm) and overlay (po) */
5725
5723
if (input [0 ] != 'd' && input [0 ] != 't' && input [0 ] != 'D' && input [0 ] != 'm' &&
5726
5724
input [0 ] != 'a' && input [0 ] != 'f' && input [0 ] != 'i' &&
5727
5725
input [0 ] != 'I' && input [0 ] != 'o' ) {
5728
5726
if (l < 0 ) {
5727
+ must_read = true;
5729
5728
off = core -> offset + l ;
5730
5729
len = l = - l ;
5731
5730
} else {
@@ -5737,34 +5736,37 @@ static int cmd_print(void *data, const char *input) {
5737
5736
}
5738
5737
}
5739
5738
} else {
5740
- len = l ;
5741
5739
if (l < 0 ) {
5740
+ must_read = true;
5742
5741
off = core -> offset + l ;
5742
+ len = - len ;
5743
+ } else {
5744
+ len = l ;
5743
5745
}
5744
5746
}
5745
5747
}
5746
5748
}
5747
5749
int olen = len ;
5748
5750
at = off ;
5749
- if (len < 0 ) {
5750
- len = - len ;
5751
- }
5752
5751
const int padding = core -> blocksize + 256 ;
5753
5752
block = malloc (len + padding );
5754
5753
// if (!block) die
5755
5754
if (block ) {
5756
- if (len > core -> blocksize ) {
5755
+ if (! must_read && len > core -> blocksize ) {
5757
5756
memset (block , core -> io -> Oxff , len + padding );
5758
5757
r_io_read_at (core -> io , off , block , len );
5759
5758
} else {
5760
5759
block = calloc (1 , len + padding );
5761
5760
if (block ) {
5761
+ ut64 oo = core -> offset ;
5762
+ core -> offset = at ;
5762
5763
r_core_block_read (core );
5763
5764
memset (block , core -> io -> Oxff , len + padding );
5764
5765
r_io_read_at (core -> io , off , block , len );
5765
5766
if (off == core -> offset ) {
5766
5767
memcpy (block , core -> block , R_MIN (core -> blocksize , len ));
5767
5768
}
5769
+ core -> offset = oo ;
5768
5770
}
5769
5771
}
5770
5772
} else {
0 commit comments