@@ -5491,22 +5491,21 @@ static int cmd_print(void *data, const char *input) {
5491
5491
r_print_init_rowoffsets (core -> print );
5492
5492
tmpseek = core -> offset ;
5493
5493
l = len = core -> blocksize ;
5494
+ bool must_read = false;
5494
5495
if (input [0 ] && input [1 ]) {
5495
5496
int idx = (input [0 ] == 'h' )? 2 : 1 ;
5496
5497
const char * p = strchr (input + idx , ' ' );
5497
5498
if (!p ) {
5498
5499
p = strchr (input , '-' );
5499
- if (p ) {
5500
- p -- ;
5501
- }
5502
5500
}
5503
5501
if (p ) {
5504
- l = (int ) r_num_math (core -> num , p + 1 );
5502
+ l = (int ) r_num_math (core -> num , p );
5505
5503
/* except disasm and memoryfmt (pd, pm) and overlay (po) */
5506
5504
if (input [0 ] != 'd' && input [0 ] != 't' && input [0 ] != 'D' && input [0 ] != 'm' &&
5507
5505
input [0 ] != 'a' && input [0 ] != 'f' && input [0 ] != 'i' &&
5508
5506
input [0 ] != 'I' && input [0 ] != 'o' ) {
5509
5507
if (l < 0 ) {
5508
+ must_read = true;
5510
5509
off = core -> offset + l ;
5511
5510
len = l = - l ;
5512
5511
} else {
@@ -5518,34 +5517,37 @@ static int cmd_print(void *data, const char *input) {
5518
5517
}
5519
5518
}
5520
5519
} else {
5521
- len = l ;
5522
5520
if (l < 0 ) {
5521
+ must_read = true;
5523
5522
off = core -> offset + l ;
5523
+ len = - len ;
5524
+ } else {
5525
+ len = l ;
5524
5526
}
5525
5527
}
5526
5528
}
5527
5529
}
5528
5530
int olen = len ;
5529
5531
at = off ;
5530
- if (len < 0 ) {
5531
- len = - len ;
5532
- }
5533
5532
const int padding = core -> blocksize + 256 ;
5534
5533
block = malloc (len + padding );
5535
5534
// if (!block) die
5536
5535
if (block ) {
5537
- if (len > core -> blocksize ) {
5536
+ if (! must_read && len > core -> blocksize ) {
5538
5537
memset (block , core -> io -> Oxff , len + padding );
5539
5538
r_io_read_at (core -> io , off , block , len );
5540
5539
} else {
5541
5540
block = calloc (1 , len + padding );
5542
5541
if (block ) {
5542
+ ut64 oo = core -> offset ;
5543
+ core -> offset = at ;
5543
5544
r_core_block_read (core );
5544
5545
memset (block , core -> io -> Oxff , len + padding );
5545
5546
r_io_read_at (core -> io , off , block , len );
5546
5547
if (off == core -> offset ) {
5547
5548
memcpy (block , core -> block , R_MIN (core -> blocksize , len ));
5548
5549
}
5550
+ core -> offset = oo ;
5549
5551
}
5550
5552
}
5551
5553
} else {
0 commit comments