File tree 3 files changed +10
-2
lines changed
3 files changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -761,7 +761,8 @@ static struct {
761
761
762
762
case A_TAKE :
763
763
if (D_REF (ARG_TAKE_ALL )) {
764
- len = tail > index ? tail - index : 0 ;
764
+ if (tail <= index ) goto zero_blk ;
765
+ len = tail - index ;
765
766
SET_TRUE (D_ARG (ARG_TAKE_PART ));
766
767
}
767
768
else if (D_REF (ARG_TAKE_PART )) {
Original file line number Diff line number Diff line change @@ -714,7 +714,8 @@ static struct {
714
714
715
715
case A_TAKE :
716
716
if (D_REF (ARG_TAKE_ALL )) {
717
- len = tail > index ? tail - index : 0 ;
717
+ if (tail <= index ) goto zero_str ;
718
+ len = tail - index ;
718
719
SET_TRUE (D_ARG (ARG_TAKE_PART ));
719
720
}
720
721
else if (D_REF (ARG_TAKE_PART )) {
Original file line number Diff line number Diff line change @@ -987,18 +987,24 @@ Rebol [
987
987
--assert all [#{ 010203040506 } == take/all s empty? s]
988
988
s: skip #{ 010203040506 } 3
989
989
--assert all [#{ 040506 } == take/all s #{ 010203 } == head s]
990
+ s: next #{ 0102 } clear head s ;; tail over index
991
+ --assert all [#{} == take/all s #{} == head s]
990
992
991
993
--test-- "take/all block!"
992
994
s: [1 2 3 4 5 6 ]
993
995
--assert all [[1 2 3 4 5 6 ] == take/all s empty? s]
994
996
s: skip [1 2 3 4 5 6 ] 3
995
997
--assert all [[4 5 6 ] == take/all s [1 2 3 ] == head s]
998
+ s: next [1 2 ] clear head s ;; tail over index
999
+ --assert all [[] == take/all s [] == head s]
996
1000
997
1001
--test-- "take/all string!"
998
1002
s: "123456"
999
1003
--assert all ["123456" == take/all s empty? s]
1000
1004
s: skip "123456" 3
1001
1005
--assert all ["456" == take/all s "123" == head s]
1006
+ s: next "12" clear head s ;; tail over index
1007
+ --assert all ["" == take/all s "" == head s]
1002
1008
1003
1009
===end-group===
1004
1010
You can’t perform that action at this time.
0 commit comments