File tree 2 files changed +38
-1
lines changed
2 files changed +38
-1
lines changed Original file line number Diff line number Diff line change 3
3
** REBOL [R3] Language Interpreter and Run-time Environment
4
4
**
5
5
** Copyright 2012 REBOL Technologies
6
- ** Copyright 2012-2018 Rebol Open Source Developers
6
+ ** Copyright 2012-2022 Rebol Open Source Developers
7
7
** REBOL is a trademark of REBOL Technologies
8
8
**
9
9
** Licensed under the Apache License, Version 2.0 (the "License");
@@ -1639,6 +1639,14 @@ static REBCNT EncodedU32_Size(u32 value) {
1639
1639
+ mst -> time .minute * 60
1640
1640
+ mst -> time .hour * 3600 );
1641
1641
break ;
1642
+ case SYM_CROP :
1643
+ n = 0 ;
1644
+ if (IS_PROTECT_SERIES (bin )) Trap0 (RE_PROTECTED );
1645
+ Remove_Series (VAL_SERIES (buffer_read ), 0 , VAL_INDEX (buffer_read ));
1646
+ cp = VAL_BIN_HEAD (buffer_read );
1647
+ VAL_INDEX (buffer_write ) = MAX (0 , (REBI64 )VAL_INDEX (buffer_write ) - VAL_INDEX (buffer_read ));
1648
+ VAL_INDEX (buffer_read ) = 0 ;
1649
+ continue ;
1642
1650
default :
1643
1651
Trap1 (RE_INVALID_SPEC , value );
1644
1652
}
Original file line number Diff line number Diff line change @@ -484,6 +484,35 @@ is-protected-error?: func[code][
484
484
485
485
===end-group===
486
486
487
+ ===start-group=== "BinCode special read/write functions"
487
488
489
+ --test-- "BinCode - CROP"
490
+ ;; CROP shrinks buffers from the left side at the position of the read buffer
491
+ b: binary #{ 010203 }
492
+ --assert [1 ] = binary/read b [UI8 CROP]
493
+ --assert all [
494
+ #{ 0203 } = b/buffer
495
+ #{ 0203 } = b/buffer-write
496
+ ]
497
+ --assert b = binary/write b [UI8 4 ]
498
+ --assert all [
499
+ #{ 0403 } = b/buffer
500
+ #{ 03 } = b/buffer-write
501
+ ]
502
+ --assert [4 ] = binary/read b [UI8 CROP]
503
+ --assert all [
504
+ #{ 03 } = b/buffer
505
+ #{ 03 } = b/buffer-write
506
+ ]
507
+ --assert b = binary/write b [AT 2 UI8 5 ]
508
+ --assert all [
509
+ #{ 0305 } = b/buffer
510
+ #{} = b/buffer-write
511
+ ]
512
+ --assert [3 5 ] = binary/read b [UI8 UI8 CROP]
513
+ --assert all [
514
+ empty? head b/buffer
515
+ empty? head b/buffer-write
516
+ ]
488
517
489
518
~~~end-file~~~
You can’t perform that action at this time.
0 commit comments