Skip to content

Commit 6ca57f4

Browse files
committed
FIX: correct width expansion when appending char in range 128-255
resolves: Oldes/Rebol-issues#2486
1 parent a1638d1 commit 6ca57f4

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

src/core/f-modify.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
** REBOL [R3] Language Interpreter and Run-time Environment
44
**
55
** Copyright 2012 REBOL Technologies
6+
** Copyright 2012-2022 Rebol Open Source Contributors
67
** REBOL is a trademark of REBOL Technologies
78
**
89
** Licensed under the Apache License, Version 2.0 (the "License");
@@ -157,7 +158,7 @@
157158
else Trap_Arg(src_val);
158159
}
159160
else if (IS_CHAR(src_val)) {
160-
if (VAL_CHAR(src_val) < 256) {
161+
if (VAL_CHAR(src_val) < 128) {
161162
src_ser = BUF_FORM;
162163
*SERIES_DATA(src_ser) = (REBYTE)VAL_CHAR(src_val);
163164
}

src/core/s-make.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
** REBOL [R3] Language Interpreter and Run-time Environment
44
**
55
** Copyright 2012 REBOL Technologies
6+
** Copyright 2012-2022 Rebol Open Source Contributors
67
** REBOL is a trademark of REBOL Technologies
78
**
89
** Licensed under the Apache License, Version 2.0 (the "License");
@@ -246,7 +247,7 @@
246247
bp = BIN_SKIP(dst, idx);
247248
up = UNI_SKIP(src, pos);
248249
for (n = 0; n < len; n++) {
249-
if (up[n] > 0xFF) {
250+
if (up[n] >= 0x80) {
250251
//Debug_Num("##Widen-series because char value is:", up[n]);
251252
// Expand dst and restart:
252253
idx += n;

src/tests/units/port-test.r3

+7
Original file line numberDiff line numberDiff line change
@@ -490,6 +490,13 @@ if system/platform = 'Windows [
490490
not error? try [write clipboard:// c]
491491
strict-equal? c try [read clipboard://]
492492
]
493+
--test-- "issue-2486"
494+
;@@ https://github.com/Oldes/Rebol-issues/issues/2486
495+
foreach ch [#"a" #"^(7F)" #"^(80)" #"^(A0)"][
496+
write clipboard:// append copy "" ch
497+
--assert (to binary! ch) = to binary! read clipboard://
498+
]
499+
493500
===end-group===
494501
]
495502

0 commit comments

Comments
 (0)