File tree 3 files changed +19
-8
lines changed
3 files changed +19
-8
lines changed Original file line number Diff line number Diff line change @@ -534,13 +534,15 @@ static struct {
534
534
REBINT n = 0 ;
535
535
536
536
/* Issues!!!
537
- a/1.3
538
537
a/not-found: 10 error or append?
539
538
a/not-followed: 10 error or append?
540
539
*/
541
540
542
- if (IS_INTEGER (pvs -> select )) {
543
- n = Int32 (pvs -> select ) + VAL_INDEX (pvs -> value ) - 1 ;
541
+ if (IS_INTEGER (pvs -> select ) || IS_DECIMAL (pvs -> select )) {
542
+ REBINT i = Int32 (pvs -> select );
543
+ if (i == 0 ) return PE_NONE ; // like in case: path/0
544
+ if (i < 0 ) i ++ ;
545
+ n = i + VAL_INDEX (pvs -> value ) - 1 ;
544
546
}
545
547
else if (IS_WORD (pvs -> select )) {
546
548
n = Find_Word (VAL_SERIES (pvs -> value ), VAL_INDEX (pvs -> value ), VAL_WORD_CANON (pvs -> select ));
@@ -573,6 +575,8 @@ static struct {
573
575
REBINT n = 0 ;
574
576
575
577
n = Get_Num_Arg (selector );
578
+ if (n == 0 ) return 0 ;
579
+ if (n < 0 ) n ++ ;
576
580
n += VAL_INDEX (block ) - 1 ;
577
581
if (n < 0 || (REBCNT )n >= VAL_TAIL (block )) return 0 ;
578
582
return VAL_BLK_SKIP (block , n );
Original file line number Diff line number Diff line change @@ -354,7 +354,10 @@ static REBSER *make_binary(REBVAL *arg, REBOOL make)
354
354
REBSER * ser = VAL_SERIES (data );
355
355
356
356
if (IS_INTEGER (pvs -> select )) {
357
- n = Int32 (pvs -> select ) + VAL_INDEX (data ) - 1 ;
357
+ i = Int32 (pvs -> select );
358
+ if (i == 0 ) return PE_NONE ; // like in case: path/0
359
+ if (i < 0 ) i ++ ;
360
+ n = i + VAL_INDEX (data ) - 1 ;
358
361
}
359
362
else return PE_BAD_SELECT ;
360
363
@@ -542,8 +545,9 @@ static REBSER *make_binary(REBVAL *arg, REBOOL make)
542
545
case A_PICK :
543
546
case A_POKE :
544
547
len = Get_Num_Arg (arg ); // Position
545
- //if (len > 0) index--;
546
- if (REB_I32_SUB_OF (len , 1 , & len )
548
+ if (len < 0 ) REB_I32_ADD_OF (index , 1 , & index );
549
+ if (len == 0
550
+ || REB_I32_SUB_OF (len , 1 , & len )
547
551
|| REB_I32_ADD_OF (index , len , & index )
548
552
|| index < 0 || index >= tail ) {
549
553
if (action == A_PICK ) goto is_none ;
Original file line number Diff line number Diff line change @@ -468,10 +468,13 @@ void Set_Vector_Row(REBSER *ser, REBVAL *blk)
468
468
REBINT bits ;
469
469
REBYTE * vp ;
470
470
REBI64 i ;
471
- REBDEC f ;
471
+ REBDEC f = 0.0 ;
472
472
473
- if (IS_INTEGER (pvs -> select ) || IS_DECIMAL (pvs -> select ))
473
+ if (IS_INTEGER (pvs -> select ) || IS_DECIMAL (pvs -> select )) {
474
474
n = Int32 (pvs -> select );
475
+ if (n == 0 ) return PE_NONE ;
476
+ if (n < 0 ) n ++ ;
477
+ }
475
478
else return PE_BAD_SELECT ;
476
479
477
480
n += VAL_INDEX (pvs -> value );
You can’t perform that action at this time.
0 commit comments