diff options
| author | Kenichi Handa | 2002-03-01 01:50:19 +0000 |
|---|---|---|
| committer | Kenichi Handa | 2002-03-01 01:50:19 +0000 |
| commit | 0f8c4c4fede7393e9f0c24514845738837ca6fca (patch) | |
| tree | ecbf0389a90de885bd0924b3ba736aba7adc292a /src | |
| parent | 81b39386f6522ac95b329270ba72d733958baa46 (diff) | |
| download | emacs-0f8c4c4fede7393e9f0c24514845738837ca6fca.tar.gz emacs-0f8c4c4fede7393e9f0c24514845738837ca6fca.zip | |
Include "character.h".
(x_encode_text): Adjusted for the new code-conversion API.
Diffstat (limited to 'src')
| -rw-r--r-- | src/xfns.c | 42 |
1 files changed, 12 insertions, 30 deletions
diff --git a/src/xfns.c b/src/xfns.c index 748d8925a53..b393578d52c 100644 --- a/src/xfns.c +++ b/src/xfns.c | |||
| @@ -42,6 +42,7 @@ Boston, MA 02111-1307, USA. */ | |||
| 42 | #include "keyboard.h" | 42 | #include "keyboard.h" |
| 43 | #include "blockinput.h" | 43 | #include "blockinput.h" |
| 44 | #include <epaths.h> | 44 | #include <epaths.h> |
| 45 | #include "character.h" | ||
| 45 | #include "charset.h" | 46 | #include "charset.h" |
| 46 | #include "coding.h" | 47 | #include "coding.h" |
| 47 | #include "fontset.h" | 48 | #include "fontset.h" |
| @@ -2362,46 +2363,27 @@ x_encode_text (string, coding_system, selectionp, text_bytes, stringp) | |||
| 2362 | int *text_bytes, *stringp; | 2363 | int *text_bytes, *stringp; |
| 2363 | int selectionp; | 2364 | int selectionp; |
| 2364 | { | 2365 | { |
| 2365 | unsigned char *str = XSTRING (string)->data; | 2366 | int result = string_xstring_p (string); |
| 2366 | int chars = XSTRING (string)->size; | ||
| 2367 | int bytes = STRING_BYTES (XSTRING (string)); | ||
| 2368 | int charset_info; | ||
| 2369 | int bufsize; | ||
| 2370 | unsigned char *buf; | ||
| 2371 | struct coding_system coding; | 2367 | struct coding_system coding; |
| 2372 | 2368 | ||
| 2373 | charset_info = find_charset_in_text (str, chars, bytes, NULL, Qnil); | 2369 | if (result == 0) |
| 2374 | if (charset_info == 0) | ||
| 2375 | { | 2370 | { |
| 2376 | /* No multibyte character in OBJ. We need not encode it. */ | 2371 | /* No multibyte character in OBJ. We need not encode it. */ |
| 2377 | *text_bytes = bytes; | 2372 | *text_bytes = STRING_BYTES (XSTRING (string)); |
| 2378 | *stringp = 1; | 2373 | *stringp = 1; |
| 2379 | return str; | 2374 | return XSTRING (string)->data; |
| 2380 | } | 2375 | } |
| 2381 | 2376 | ||
| 2382 | setup_coding_system (coding_system, &coding); | 2377 | setup_coding_system (coding_system, &coding); |
| 2383 | if (selectionp | 2378 | coding.mode |= (CODING_MODE_SAFE_ENCODING | CODING_MODE_LAST_BLOCK); |
| 2384 | && SYMBOLP (coding.pre_write_conversion) | ||
| 2385 | && !NILP (Ffboundp (coding.pre_write_conversion))) | ||
| 2386 | { | ||
| 2387 | string = run_pre_post_conversion_on_str (string, &coding, 1); | ||
| 2388 | str = XSTRING (string)->data; | ||
| 2389 | chars = XSTRING (string)->size; | ||
| 2390 | bytes = STRING_BYTES (XSTRING (string)); | ||
| 2391 | } | ||
| 2392 | coding.src_multibyte = 1; | ||
| 2393 | coding.dst_multibyte = 0; | ||
| 2394 | coding.mode |= CODING_MODE_LAST_BLOCK; | ||
| 2395 | if (coding.type == coding_type_iso2022) | ||
| 2396 | coding.flags |= CODING_FLAG_ISO_SAFE; | ||
| 2397 | /* We suppress producing escape sequences for composition. */ | 2379 | /* We suppress producing escape sequences for composition. */ |
| 2398 | coding.composing = COMPOSITION_DISABLED; | 2380 | coding.common_flags &= ~CODING_ANNOTATION_MASK; |
| 2399 | bufsize = encoding_buffer_size (&coding, bytes); | 2381 | encode_coding_object (&coding, string, 0, 0, |
| 2400 | buf = (unsigned char *) xmalloc (bufsize); | 2382 | XSTRING (string)->size, |
| 2401 | encode_coding (&coding, str, buf, bytes, bufsize); | 2383 | STRING_BYTES (XSTRING (string)), Qt); |
| 2402 | *text_bytes = coding.produced; | 2384 | *text_bytes = coding.produced; |
| 2403 | *stringp = (charset_info == 1 || !EQ (coding_system, Qcompound_text)); | 2385 | *stringp = (result == 1 || !EQ (coding_system, Qcompound_text)); |
| 2404 | return buf; | 2386 | return XSTRING (coding.dst_object)->data; |
| 2405 | } | 2387 | } |
| 2406 | 2388 | ||
| 2407 | 2389 | ||