Skip to content

Commit

Permalink
FIX: optimized (and fixed regression) when appending char on string
Browse files Browse the repository at this point in the history
  • Loading branch information
Oldes committed May 28, 2020
1 parent 360256f commit 4475252
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/core/f-modify.c
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,15 @@
else Trap_Arg(src_val);
}
else if (IS_CHAR(src_val)) {
src_ser = BUF_FORM;
RESET_TAIL(src_ser);
src_ser = Append_Byte(src_ser, VAL_CHAR(src_val)); // unicode ok too
if (VAL_CHAR(src_val) < 256) {
src_ser = BUF_FORM;
*SERIES_DATA(src_ser) = (REBYTE)VAL_CHAR(src_val);
}
else {
src_ser = BUF_UTF8;
*(REBUNI*)SERIES_DATA(src_ser) = (REBUNI)VAL_CHAR(src_val);
}
SERIES_TAIL(src_ser) = 1;
}
else if (IS_BLOCK(src_val)) {
src_ser = Form_Tight_Block(src_val);
Expand Down
8 changes: 8 additions & 0 deletions src/tests/units/series-test.r3
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,14 @@ Rebol [

===end-group===


===start-group=== "APPEND string!"
--test-- "APPEND string! char!"
--assert "a" = append "" #"a"
--assert "←" = append "" #"^(2190)" ; wide char
===end-group===


;@@ https://github.com/Oldes/Rebol-issues/issues/1791
===start-group=== "APPEND binary!"
--test-- "APPEND binary! binary!"
Expand Down

0 comments on commit 4475252

Please sign in to comment.