Commit 0f8c4c4f authored by Kenichi Handa's avatar Kenichi Handa

Include "character.h".

(x_encode_text): Adjusted for the new code-conversion API.
parent 81b39386
...@@ -42,6 +42,7 @@ Boston, MA 02111-1307, USA. */ ...@@ -42,6 +42,7 @@ Boston, MA 02111-1307, USA. */
#include "keyboard.h" #include "keyboard.h"
#include "blockinput.h" #include "blockinput.h"
#include <epaths.h> #include <epaths.h>
#include "character.h"
#include "charset.h" #include "charset.h"
#include "coding.h" #include "coding.h"
#include "fontset.h" #include "fontset.h"
...@@ -2362,46 +2363,27 @@ x_encode_text (string, coding_system, selectionp, text_bytes, stringp) ...@@ -2362,46 +2363,27 @@ x_encode_text (string, coding_system, selectionp, text_bytes, stringp)
int *text_bytes, *stringp; int *text_bytes, *stringp;
int selectionp; int selectionp;
{ {
unsigned char *str = XSTRING (string)->data; int result = string_xstring_p (string);
int chars = XSTRING (string)->size;
int bytes = STRING_BYTES (XSTRING (string));
int charset_info;
int bufsize;
unsigned char *buf;
struct coding_system coding; struct coding_system coding;
charset_info = find_charset_in_text (str, chars, bytes, NULL, Qnil); if (result == 0)
if (charset_info == 0)
{ {
/* No multibyte character in OBJ. We need not encode it. */ /* No multibyte character in OBJ. We need not encode it. */
*text_bytes = bytes; *text_bytes = STRING_BYTES (XSTRING (string));
*stringp = 1; *stringp = 1;
return str; return XSTRING (string)->data;
} }
setup_coding_system (coding_system, &coding); setup_coding_system (coding_system, &coding);
if (selectionp coding.mode |= (CODING_MODE_SAFE_ENCODING | CODING_MODE_LAST_BLOCK);
&& SYMBOLP (coding.pre_write_conversion)
&& !NILP (Ffboundp (coding.pre_write_conversion)))
{
string = run_pre_post_conversion_on_str (string, &coding, 1);
str = XSTRING (string)->data;
chars = XSTRING (string)->size;
bytes = STRING_BYTES (XSTRING (string));
}
coding.src_multibyte = 1;
coding.dst_multibyte = 0;
coding.mode |= CODING_MODE_LAST_BLOCK;
if (coding.type == coding_type_iso2022)
coding.flags |= CODING_FLAG_ISO_SAFE;
/* We suppress producing escape sequences for composition. */ /* We suppress producing escape sequences for composition. */
coding.composing = COMPOSITION_DISABLED; coding.common_flags &= ~CODING_ANNOTATION_MASK;
bufsize = encoding_buffer_size (&coding, bytes); encode_coding_object (&coding, string, 0, 0,
buf = (unsigned char *) xmalloc (bufsize); XSTRING (string)->size,
encode_coding (&coding, str, buf, bytes, bufsize); STRING_BYTES (XSTRING (string)), Qt);
*text_bytes = coding.produced; *text_bytes = coding.produced;
*stringp = (charset_info == 1 || !EQ (coding_system, Qcompound_text)); *stringp = (result == 1 || !EQ (coding_system, Qcompound_text));
return buf; return XSTRING (coding.dst_object)->data;
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment