Skip to content

Commit 7717d75

Browse files
committed
Merge remote-tracking branch 'origin/master'
2 parents 1d56a21 + 3e9dce6 commit 7717d75

File tree

4 files changed

+56
-18
lines changed

4 files changed

+56
-18
lines changed

make/Rebol3.xcworkspace/contents.xcworkspacedata

+7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/core/p-clipboard.c

+26-6
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,24 @@
5050
req = Use_Port_State(port, RDI_CLIPBOARD, sizeof(REBREQ));
5151

5252
switch (action) {
53+
case A_UPDATE:
54+
// Update the port object after a READ or WRITE operation.
55+
// This is normally called by the WAKE-UP function.
56+
arg = OFV(port, STD_PORT_DATA);
57+
if (req->command == RDC_READ) {
58+
len = req->actual;
59+
if (GET_FLAG(req->flags, RRF_WIDE)) {
60+
len /= sizeof(REBUNI); //correct length
61+
// Copy the string (convert to latin-8 if it fits):
62+
Set_Binary(arg, Copy_Wide_Str(req->data, len));
63+
} else {
64+
Set_Binary(arg, Copy_OS_Str(req->data, len));
65+
}
66+
}
67+
else if (req->command == RDC_WRITE) {
68+
SET_NONE(arg); // Write is done.
69+
}
70+
return R_NONE;
5371

5472
case A_READ:
5573
// This device is opened on the READ:
@@ -63,13 +81,15 @@
6381

6482
// Copy and set the string result:
6583
arg = OFV(port, STD_PORT_DATA);
66-
67-
// If wide, correct length:
84+
6885
len = req->actual;
69-
if (GET_FLAG(req->flags, RRF_WIDE)) len /= sizeof(REBUNI);
70-
71-
// Copy the string (convert to latin-8 if it fits):
72-
Set_String(arg, Copy_OS_Str(req->data, len));
86+
if (GET_FLAG(req->flags, RRF_WIDE)) {
87+
len /= sizeof(REBUNI); //correct length
88+
// Copy the string (convert to latin-8 if it fits):
89+
Set_String(arg, Copy_Wide_Str(req->data, len));
90+
} else {
91+
Set_String(arg, Copy_OS_Str(req->data, len));
92+
}
7393

7494
OS_FREE(req->data); // release the copy buffer
7595
req->data = 0;

src/core/s-make.c

+23-12
Original file line numberDiff line numberDiff line change
@@ -113,21 +113,14 @@
113113

114114
/***********************************************************************
115115
**
116-
*/ REBSER *Copy_OS_Str(void *src, REBINT len)
116+
*/ REBSER *Copy_Wide_Str(void *src, REBINT len)
117117
/*
118-
** Create a REBOL string series from an OS native string.
119-
**
120-
** For example, in Win32 with the wide char interface, we must
121-
** convert wide char strings, minimizing to bytes if possible.
122-
**
123-
** For Linux the char string could be UTF-8, so that must be
124-
** converted to REBOL Unicode or Latin byte strings.
125-
**
126-
***********************************************************************/
118+
** Create a REBOL string series from a wide char string.
119+
** Minimize to bytes if possible
120+
*/
127121
{
128-
#ifdef OS_WIDE_CHAR
129122
REBSER *dst;
130-
REBUNI *str = (REBUNI*)src;
123+
REBUNI *str = (REBUNI*)src;
131124
if (Is_Wide(str, len)) {
132125
REBUNI *up;
133126
dst = Make_Unicode(len);
@@ -145,6 +138,24 @@
145138
*bp = 0;
146139
}
147140
return dst;
141+
}
142+
143+
/***********************************************************************
144+
**
145+
*/ REBSER *Copy_OS_Str(void *src, REBINT len)
146+
/*
147+
** Create a REBOL string series from an OS native string.
148+
**
149+
** For example, in Win32 with the wide char interface, we must
150+
** convert wide char strings, minimizing to bytes if possible.
151+
**
152+
** For Linux the char string could be UTF-8, so that must be
153+
** converted to REBOL Unicode or Latin byte strings.
154+
**
155+
***********************************************************************/
156+
{
157+
#ifdef OS_WIDE_CHAR
158+
return Copy_Wide_Str(src, len);
148159
#else
149160
return Decode_UTF_String((REBYTE*)src, len, 8, FALSE);
150161
#endif

0 commit comments

Comments
 (0)