aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJason Rumney2003-10-11 22:41:38 +0000
committerJason Rumney2003-10-11 22:41:38 +0000
commitbf2133d71eabe273bb81e641472205f5780f38f5 (patch)
tree02c911fe8d82138de20d4c9daabec429a0b01f0c /src
parent10b4bc332e02b5aec49dd0cac84eb61642924568 (diff)
downloademacs-bf2133d71eabe273bb81e641472205f5780f38f5.tar.gz
emacs-bf2133d71eabe273bb81e641472205f5780f38f5.zip
(Fw32_set_clipboard_data): Use string_x_string_p in place of
find_charset_in_text. Use encode_coding_object in place of encode_coding. (Fw32_get_clipboard_data): Use decode_coding_c_string in place of decode_coding.
Diffstat (limited to 'src')
-rw-r--r--src/w32select.c56
1 files changed, 23 insertions, 33 deletions
diff --git a/src/w32select.c b/src/w32select.c
index d44ebcbb270..a9cae2a3fe4 100644
--- a/src/w32select.c
+++ b/src/w32select.c
@@ -146,10 +146,9 @@ DEFUN ("w32-set-clipboard-data", Fw32_set_clipboard_data,
146 { 146 {
147 /* Since we are now handling multilingual text, we must consider 147 /* Since we are now handling multilingual text, we must consider
148 encoding text for the clipboard. */ 148 encoding text for the clipboard. */
149 int charset_info = find_charset_in_text (src, SCHARS (string), 149 int result = string_xstring_p (string);
150 nbytes, NULL, Qnil);
151 150
152 if (charset_info == 0) 151 if (result == 0)
153 { 152 {
154 /* No multibyte character in OBJ. We need not encode it. */ 153 /* No multibyte character in OBJ. We need not encode it. */
155 154
@@ -195,7 +194,6 @@ DEFUN ("w32-set-clipboard-data", Fw32_set_clipboard_data,
195 { 194 {
196 /* We must encode contents of OBJ to the selection coding 195 /* We must encode contents of OBJ to the selection coding
197 system. */ 196 system. */
198 int bufsize;
199 struct coding_system coding; 197 struct coding_system coding;
200 HANDLE htext2; 198 HANDLE htext2;
201 199
@@ -203,24 +201,20 @@ DEFUN ("w32-set-clipboard-data", Fw32_set_clipboard_data,
203 Vnext_selection_coding_system = Vselection_coding_system; 201 Vnext_selection_coding_system = Vselection_coding_system;
204 setup_coding_system 202 setup_coding_system
205 (Fcheck_coding_system (Vnext_selection_coding_system), &coding); 203 (Fcheck_coding_system (Vnext_selection_coding_system), &coding);
206 if (SYMBOLP (coding.pre_write_conversion) 204 coding.mode |= (CODING_MODE_SAFE_ENCODING | CODING_MODE_LAST_BLOCK);
207 && !NILP (Ffboundp (coding.pre_write_conversion))) 205
208 {
209 string = run_pre_post_conversion_on_str (string, &coding, 1);
210 src = SDATA (string);
211 nbytes = SBYTES (string);
212 }
213 coding.src_multibyte = 1;
214 coding.dst_multibyte = 0;
215 Vnext_selection_coding_system = Qnil; 206 Vnext_selection_coding_system = Qnil;
216 coding.mode |= CODING_MODE_LAST_BLOCK; 207
217 bufsize = encoding_buffer_size (&coding, nbytes); 208 /* We suppress producing escape sequences for composition. */
218 if ((htext = GlobalAlloc (GMEM_MOVEABLE | GMEM_DDESHARE, bufsize)) == NULL) 209 coding.common_flags &= ~CODING_ANNOTATION_MASK;
210 coding.dst_bytes = SCHARS (string) * 2;
211 if ((htext = GlobalAlloc (GMEM_MOVEABLE | GMEM_DDESHARE, coding.dst_bytes)) == NULL)
219 goto error; 212 goto error;
220 if ((dst = (unsigned char *) GlobalLock (htext)) == NULL) 213 if ((coding.destination = (unsigned char *) GlobalLock (htext)) == NULL)
221 goto error; 214 goto error;
222 encode_coding (&coding, src, dst, nbytes, bufsize); 215 encode_coding_object (&coding, string, 0, 0,
223 Vlast_coding_system_used = coding.symbol; 216 SCHARS (string), SBYTES (string), Qnil);
217 Vlast_coding_system_used = CODING_ID_NAME (coding.id);
224 218
225 /* If clipboard sequence numbers are not supported, keep a copy for 219 /* If clipboard sequence numbers are not supported, keep a copy for
226 later comparison. */ 220 later comparison. */
@@ -237,7 +231,8 @@ DEFUN ("w32-set-clipboard-data", Fw32_set_clipboard_data,
237 clipboard_storage_size); 231 clipboard_storage_size);
238 } 232 }
239 if (last_clipboard_text) 233 if (last_clipboard_text)
240 memcpy (last_clipboard_text, dst, coding.produced); 234 memcpy (last_clipboard_text, coding.destination,
235 coding.produced);
241 } 236 }
242 237
243 GlobalUnlock (htext); 238 GlobalUnlock (htext);
@@ -337,8 +332,6 @@ DEFUN ("w32-get-clipboard-data", Fw32_get_clipboard_data,
337 332
338 if (require_decoding) 333 if (require_decoding)
339 { 334 {
340 int bufsize;
341 unsigned char *buf;
342 struct coding_system coding; 335 struct coding_system coding;
343 336
344 if (NILP (Vnext_selection_coding_system)) 337 if (NILP (Vnext_selection_coding_system))
@@ -349,20 +342,17 @@ DEFUN ("w32-get-clipboard-data", Fw32_get_clipboard_data,
349 coding.dst_multibyte = 1; 342 coding.dst_multibyte = 1;
350 Vnext_selection_coding_system = Qnil; 343 Vnext_selection_coding_system = Qnil;
351 coding.mode |= CODING_MODE_LAST_BLOCK; 344 coding.mode |= CODING_MODE_LAST_BLOCK;
352 /* We explicitely disable composition handling because 345 /* We explicitly disable composition handling because
353 selection data should not contain any composition 346 selection data should not contain any composition
354 sequence. */ 347 sequence. */
355 coding.composing = COMPOSITION_DISABLED; 348 coding.common_flags &= ~CODING_ANNOTATION_MASK;
356 bufsize = decoding_buffer_size (&coding, nbytes); 349 coding.dst_bytes = nbytes * 2;
357 buf = (unsigned char *) xmalloc (bufsize); 350 coding.destination = (unsigned char *) xmalloc (coding.dst_bytes);
358 decode_coding (&coding, src, buf, nbytes, bufsize); 351 decode_coding_c_string (&coding, src, nbytes, Qnil);
359 Vlast_coding_system_used = coding.symbol; 352 Vlast_coding_system_used = CODING_ID_NAME (coding.id);
360 ret = make_string_from_bytes ((char *) buf, 353 ret = make_string_from_bytes ((char *) coding.destination,
361 coding.produced_char, coding.produced); 354 coding.produced_char, coding.produced);
362 xfree (buf); 355 xfree (coding.destination);
363 if (SYMBOLP (coding.post_read_conversion)
364 && !NILP (Ffboundp (coding.post_read_conversion)))
365 ret = run_pre_post_conversion_on_str (ret, &coding, 0);
366 } 356 }
367 else 357 else
368 { 358 {