Skip to content

Commit e03b3ba

Browse files
committed
FIX: MOLD/FLAT on binary values does not remove line breaks
fixes: metaeducation/rebol-issues#2390
1 parent f38d499 commit e03b3ba

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

src/core/s-mold.c

+4-3
Original file line numberDiff line numberDiff line change
@@ -552,19 +552,20 @@ STOID Mold_Handle(REBVAL *value, REB_MOLD *mold)
552552
{
553553
REBCNT len = VAL_LEN(value);
554554
REBSER *out;
555+
REBOOL indented = !GET_MOPT(mold, MOPT_INDENT);
555556

556557
switch (Get_System_Int(SYS_OPTIONS, OPTIONS_BINARY_BASE, 16)) {
557558
default:
558559
case 16:
559-
out = Encode_Base16(value, 0, len > 32);
560+
out = Encode_Base16(value, 0, indented && len > 32);
560561
break;
561562
case 64:
562563
Append_Bytes(mold->series, "64");
563-
out = Encode_Base64(value, 0, len > 64, FALSE);
564+
out = Encode_Base64(value, 0, indented && len > 64, FALSE);
564565
break;
565566
case 2:
566567
Append_Byte(mold->series, '2');
567-
out = Encode_Base2(value, 0, len > 8);
568+
out = Encode_Base2(value, 0, indented && len > 8);
568569
break;
569570
}
570571

src/tests/units/mold-test.r3

+15-1
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,20 @@ Rebol [
261261

262262
===end-group===
263263

264+
===start-group=== "mold binary!"
265+
bb: system/options/binary-base ;store original value
266+
bin: #{FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF}
267+
--test-- "mold/flat binary!"
268+
system/options/binary-base: 2
269+
--assert (mold/flat bin) = {2#{11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111}}
270+
system/options/binary-base: 16
271+
--assert (mold/flat bin) = {#{FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF}}
272+
system/options/binary-base: 64
273+
--assert (mold/flat bin) = {64#{/////////////////////////////////////////////w==}}
274+
; restore options
275+
system/options/binary-base: bb
276+
277+
===end-group===
264278

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

@@ -277,7 +291,7 @@ Rebol [
277291
--test-- "mold/flat/all image!"
278292
--assert (mold/all/flat make image! 8x1) = {#[image! 8x1 #{FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF}]}
279293
--assert (mold/all/flat next make image! 8x1) = {#[image! 8x1 #{FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF} 2]}
280-
294+
281295
===end-group===
282296

283297
~~~end-file~~~

0 commit comments

Comments
 (0)