Skip to content

Commit b7d6dbe

Browse files
committed
CHANGE: decoration removed by form and to-string from (lit/set/get)-words and (lit/set/get)-paths
related to: Oldes/Rebol-issues#2073
1 parent 1093ae1 commit b7d6dbe

File tree

3 files changed

+105
-17
lines changed

3 files changed

+105
-17
lines changed

src/core/s-mold.c

+6-6
Original file line numberDiff line numberDiff line change
@@ -725,7 +725,7 @@ STOID Mold_Block_Series(REB_MOLD *mold, REBSER *series, REBCNT index, REBYTE *se
725725
Remove_Last(MOLD_LOOP);
726726
}
727727

728-
STOID Mold_Block(REBVAL *value, REB_MOLD *mold)
728+
STOID Mold_Block(REBVAL *value, REB_MOLD *mold, REBFLG molded)
729729
{
730730
REBYTE *sep = NULL;
731731
REBOOL all = GET_MOPT(mold, MOPT_MOLD_ALL);
@@ -772,12 +772,12 @@ STOID Mold_Block(REBVAL *value, REB_MOLD *mold)
772772
break;
773773

774774
case REB_GET_PATH:
775-
series = Append_Byte(series, ':');
775+
if (molded) series = Append_Byte(series, ':');
776776
sep = b_cast("/");
777777
break;
778778

779779
case REB_LIT_PATH:
780-
series = Append_Byte(series, '\'');
780+
if (molded) series = Append_Byte(series, '\'');
781781
/* fall through */
782782
case REB_PATH:
783783
case REB_SET_PATH:
@@ -789,7 +789,7 @@ STOID Mold_Block(REBVAL *value, REB_MOLD *mold)
789789
else Mold_Block_Series(mold, VAL_SERIES(value), VAL_INDEX(value), sep);
790790

791791
if (VAL_TYPE(value) == REB_SET_PATH)
792-
Append_Byte(series, ':');
792+
if (molded) Append_Byte(series, ':');
793793
}
794794
}
795795

@@ -1272,7 +1272,7 @@ STOID Mold_Error(REBVAL *value, REB_MOLD *mold, REBFLG molded)
12721272
case REB_BLOCK:
12731273
case REB_PAREN:
12741274
if (molded)
1275-
Mold_Block(value, mold);
1275+
Mold_Block(value, mold, molded);
12761276
else
12771277
Form_Block_Series(VAL_SERIES(value), VAL_INDEX(value), mold, 0);
12781278
break;
@@ -1281,7 +1281,7 @@ STOID Mold_Error(REBVAL *value, REB_MOLD *mold, REBFLG molded)
12811281
case REB_SET_PATH:
12821282
case REB_GET_PATH:
12831283
case REB_LIT_PATH:
1284-
Mold_Block(value, mold);
1284+
Mold_Block(value, mold, molded);
12851285
break;
12861286

12871287
case REB_VECTOR:

src/core/t-string.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,8 @@ static REBSER *make_string(REBVAL *arg, REBOOL make)
167167
ser = Copy_String(VAL_SERIES(arg), VAL_INDEX(arg), VAL_LEN(arg));
168168
}
169169
// MAKE/TO <type> <any-word>
170-
else if (ANY_WORD(arg)) {
171-
ser = Copy_Mold_Value(arg, TRUE);
170+
else if (ANY_WORD(arg) || ANY_PATH(arg)) {
171+
ser = Copy_Form_Value(arg, TRUE);
172172
//ser = Append_UTF8(0, Get_Word_Name(arg), -1);
173173
}
174174
// MAKE/TO <type> #"A"

src/tests/units/make-test.r3

+97-9
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ Rebol [
9898
--assert 9223372036854775807 = to integer! "9'223'372'036'854'775'807"
9999
--assert all [error? e: try [to integer! "9'223'372'036'854'775'808"] e/id = 'bad-make-arg]
100100
;@@ https://github.com/Oldes/Rebol-issues/issues/2099
101-
--assert 302961000000 = to integer! "3.02961E+11"
101+
--assert 302961000000 = to integer! "3.02961E+11" ;-> KNOWN ISSUE!
102102
;@@ https://github.com/Oldes/Rebol-issues/issues/2504
103103
--assert 0 = to integer! "0"
104104
--assert 0 = to integer! "00"
@@ -598,6 +598,92 @@ Rebol [
598598
--assert error? try [to map! quote #[typeset! [#[datatype! integer! ]#[datatype! percent! ]]] ] ; typeset!
599599
===end-group===
600600

601+
===start-group=== "make/to string"
602+
;@@ https://github.com/Oldes/Rebol-issues/issues/2073
603+
--test-- "make string! ..."
604+
--assert "" = try [make string! quote #[unset!] ] ; unset!
605+
--assert error? try [make string! quote #[none] ] ; none!
606+
--assert "true" = try [make string! quote #[true] ] ; logic!
607+
--assert "" = try [make string! quote 1 ] ; integer!
608+
--assert "" = try [make string! quote 0 ] ; integer!
609+
--assert "" = try [make string! quote 4 ] ; integer!
610+
--assert "" = try [make string! quote 4.0 ] ; decimal!
611+
--assert "4%" = try [make string! quote 4.0% ] ; percent!
612+
--assert "$4" = try [make string! quote $4 ] ; money!
613+
--assert "a" = try [make string! quote #"a" ] ; char!
614+
--assert "2x2" = try [make string! quote 2x2 ] ; pair!
615+
--assert "1.1.1" = try [make string! quote 1.1.1 ] ; tuple!
616+
--assert "10:00" = try [make string! quote 10:00 ] ; time!
617+
--assert "1-Jan-2000" = try [make string! quote 2000-01-01 ] ; date!
618+
--assert "^@" = try [make string! quote #{00} ] ; binary!
619+
--assert "1 2" = try [make string! quote #{312032} ] ; binary!
620+
--assert "" = try [make string! quote "" ] ; string!
621+
--assert "1 2" = try [make string! quote "1 2" ] ; string!
622+
--assert "file" = try [make string! quote %file ] ; file!
623+
--assert "u@email" = try [make string! quote u@email ] ; email!
624+
--assert "ref" = try [make string! quote @ref ] ; ref!
625+
--assert "http://aa" = try [make string! quote http://aa ] ; url!
626+
--assert "tag" = try [make string! quote <tag> ] ; tag!
627+
--assert "12" = try [make string! quote [1 2] ] ; block!
628+
--assert "12" = try [make string! quote (1 2) ] ; paren!
629+
--assert "a" = try [make string! quote a ] ; word!
630+
--assert "a" = try [make string! quote a: ] ; set-word!
631+
--assert "a" = try [make string! quote :a ] ; get-word!
632+
--assert "a" = try [make string! quote 'a ] ; lit-word!
633+
--assert "a/b" = try [make string! quote a/b ] ; path!
634+
--assert "a/b" = try [make string! quote a/b: ] ; set-path!
635+
--assert "a/b" = try [make string! quote :a/b ] ; get-path!
636+
--assert "a/b" = try [make string! quote 'a/b ] ; lit-path!
637+
--assert "ref" = try [make string! quote /ref ] ; refinement!
638+
--assert "FF" = try [make string! quote #FF ] ; issue!
639+
--assert "0 0" = try [make string! quote #[vector! integer! 32 2 [0 0]] ] ; vector!
640+
--assert "a: 1" = try [make string! quote #[object! [a: 1]] ] ; object!
641+
--assert "make bitset! #{FF}" = try [make string! quote #[bitset! #{FF}] ] ; bitset!
642+
--assert "make image! [1x1 #{FFFFFF}]" = try [make string! quote #[image! 1x1 #{FFFFFF}] ] ; image!
643+
--assert "integer! percent!" = try [make string! quote #[typeset! [integer! percent!]] ] ; typeset!
644+
--test-- "to string! ..."
645+
--assert "" = try [to string! quote #[unset!] ] ; unset!
646+
--assert error? try [to string! quote #[none] ] ; none!
647+
--assert "true" = try [to string! quote #[true] ] ; logic!
648+
--assert "1" = try [to string! quote 1 ] ; integer!
649+
--assert "0" = try [to string! quote 0 ] ; integer!
650+
--assert "4" = try [to string! quote 4 ] ; integer!
651+
--assert "4.0" = try [to string! quote 4.0 ] ; decimal!
652+
--assert "4%" = try [to string! quote 4.0% ] ; percent!
653+
--assert "$4" = try [to string! quote $4 ] ; money!
654+
--assert "a" = try [to string! quote #"a" ] ; char!
655+
--assert "2x2" = try [to string! quote 2x2 ] ; pair!
656+
--assert "1.1.1" = try [to string! quote 1.1.1 ] ; tuple!
657+
--assert "10:00" = try [to string! quote 10:00 ] ; time!
658+
--assert "1-Jan-2000" = try [to string! quote 2000-01-01 ] ; date!
659+
--assert "^@" = try [to string! quote #{00} ] ; binary!
660+
--assert "1 2" = try [to string! quote #{312032} ] ; binary!
661+
--assert "" = try [to string! quote "" ] ; string!
662+
--assert "1 2" = try [to string! quote "1 2" ] ; string!
663+
--assert "file" = try [to string! quote %file ] ; file!
664+
--assert "u@email" = try [to string! quote u@email ] ; email!
665+
--assert "ref" = try [to string! quote @ref ] ; ref!
666+
--assert "http://aa" = try [to string! quote http://aa ] ; url!
667+
--assert "tag" = try [to string! quote <tag> ] ; tag!
668+
--assert "12" = try [to string! quote [1 2] ] ; block!
669+
--assert "12" = try [to string! quote (1 2) ] ; paren!
670+
--assert "a" = try [to string! quote a ] ; word!
671+
--assert "a" = try [to string! quote a: ] ; set-word!
672+
--assert "a" = try [to string! quote :a ] ; get-word!
673+
--assert "a" = try [to string! quote 'a ] ; lit-word!
674+
--assert "a/b" = try [to string! quote a/b ] ; path!
675+
--assert "a/b" = try [to string! quote a/b: ] ; set-path!
676+
--assert "a/b" = try [to string! quote :a/b ] ; get-path!
677+
--assert "a/b" = try [to string! quote 'a/b ] ; lit-path!
678+
--assert "ref" = try [to string! quote /ref ] ; refinement!
679+
--assert "FF" = try [to string! quote #FF ] ; issue!
680+
--assert "0 0" = try [to string! quote #[vector! integer! 32 2 [0 0]] ] ; vector!
681+
--assert "a: 1" = try [to string! quote #[object! [a: 1]] ] ; object!
682+
--assert "make bitset! #{FF}" = try [to string! quote #[bitset! #{FF}] ] ; bitset!
683+
--assert "make image! [1x1 #{FFFFFF}]" = try [to string! quote #[image! 1x1 #{FFFFFF}] ] ; image!
684+
--assert "integer! percent!" = try [to string! quote #[typeset! [#[datatype! integer! ]#[datatype! percent! ]]] ] ; typeset!
685+
===end-group===
686+
601687
===start-group=== "make/to tag"
602688
;@@ https://github.com/Oldes/Rebol-issues/issues/1215
603689
--test-- "make tag! .."
@@ -627,10 +713,11 @@ Rebol [
627713
--assert <12> = try [make tag! quote [1 2] ] ; block!
628714
--assert <12> = try [make tag! quote (1 2) ] ; paren!
629715
--assert <a/b> = try [make tag! quote a/b ] ; path!
630-
--assert <a/b:> = try [make tag! quote a/b: ] ; set-path!
631-
--assert <:a/b> = try [make tag! quote :a/b ] ; get-path!
632-
--assert </ref> = try [make tag! quote /ref ] ; refinement!
633-
--assert <#FF> = try [make tag! quote #FF ] ; issue!
716+
--assert <a/b> = try [make tag! quote a/b: ] ; set-path!
717+
--assert <a/b> = try [make tag! quote :a/b ] ; get-path!
718+
--assert <a/b> = try [make tag! quote 'a/b ] ; lit-path!
719+
--assert <ref> = try [make tag! quote /ref ] ; refinement!
720+
--assert <FF> = try [make tag! quote #FF ] ; issue!
634721
--assert <make bitset! #{FF}> = try [make tag! quote #[bitset! #{FF}] ] ; bitset!
635722
--assert <make image! [1x1 #{FFFFFF}]> = try [make tag! quote #[image! 1x1 #{FFFFFF}] ] ; image!
636723
--assert <0 0> = try [make tag! quote #[vector! integer! 32 2 [0 0]] ] ; vector!
@@ -663,10 +750,11 @@ Rebol [
663750
--assert <12> = try [to tag! quote [1 2] ] ; block!
664751
--assert <12> = try [to tag! quote (1 2) ] ; paren!
665752
--assert <a/b> = try [to tag! quote a/b ] ; path!
666-
--assert <a/b:> = try [to tag! quote a/b: ] ; set-path!
667-
--assert <:a/b> = try [to tag! quote :a/b ] ; get-path!
668-
--assert </ref> = try [to tag! quote /ref ] ; refinement!
669-
--assert <#FF> = try [to tag! quote #FF ] ; issue!
753+
--assert <a/b> = try [to tag! quote a/b: ] ; set-path!
754+
--assert <a/b> = try [to tag! quote :a/b ] ; get-path!
755+
--assert <a/b> = try [to tag! quote 'a/b ] ; lit-path!
756+
--assert <ref> = try [to tag! quote /ref ] ; refinement!
757+
--assert <FF> = try [to tag! quote #FF ] ; issue!
670758
--assert <make bitset! #{FF}> = try [to tag! quote #[bitset! #{FF}] ] ; bitset!
671759
--assert <make image! [1x1 #{FFFFFF}]> = try [to tag! quote #[image! 1x1 #{FFFFFF}] ] ; image!
672760
--assert <0 0> = try [to tag! quote #[vector! integer! 32 2 [0 0]] ] ; vector!

0 commit comments

Comments
 (0)