Skip to content

Commit

Permalink
FIX: MOLD/FLAT on binary values does not remove line breaks
Browse files Browse the repository at this point in the history
  • Loading branch information
Oldes committed Sep 24, 2019
1 parent f38d499 commit e03b3ba
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
7 changes: 4 additions & 3 deletions src/core/s-mold.c
Original file line number Diff line number Diff line change
Expand Up @@ -552,19 +552,20 @@ STOID Mold_Handle(REBVAL *value, REB_MOLD *mold)
{
REBCNT len = VAL_LEN(value);
REBSER *out;
REBOOL indented = !GET_MOPT(mold, MOPT_INDENT);

switch (Get_System_Int(SYS_OPTIONS, OPTIONS_BINARY_BASE, 16)) {
default:
case 16:
out = Encode_Base16(value, 0, len > 32);
out = Encode_Base16(value, 0, indented && len > 32);
break;
case 64:
Append_Bytes(mold->series, "64");
out = Encode_Base64(value, 0, len > 64, FALSE);
out = Encode_Base64(value, 0, indented && len > 64, FALSE);
break;
case 2:
Append_Byte(mold->series, '2');
out = Encode_Base2(value, 0, len > 8);
out = Encode_Base2(value, 0, indented && len > 8);
break;
}

Expand Down
16 changes: 15 additions & 1 deletion src/tests/units/mold-test.r3
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,20 @@ Rebol [

===end-group===

===start-group=== "mold binary!"
bb: system/options/binary-base ;store original value
bin: #{FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF}
--test-- "mold/flat binary!"
system/options/binary-base: 2
--assert (mold/flat bin) = {2#{11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111}}
system/options/binary-base: 16
--assert (mold/flat bin) = {#{FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF}}
system/options/binary-base: 64
--assert (mold/flat bin) = {64#{/////////////////////////////////////////////w==}}
; restore options
system/options/binary-base: bb

===end-group===

===start-group=== "mold image!"

Expand All @@ -277,7 +291,7 @@ Rebol [
--test-- "mold/flat/all image!"
--assert (mold/all/flat make image! 8x1) = {#[image! 8x1 #{FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF}]}
--assert (mold/all/flat next make image! 8x1) = {#[image! 8x1 #{FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF} 2]}

===end-group===

~~~end-file~~~

0 comments on commit e03b3ba

Please sign in to comment.