701 |
Nth coding category. */ |
Nth coding category. */ |
702 |
static struct coding_system coding_categories[coding_category_max]; |
static struct coding_system coding_categories[coding_category_max]; |
703 |
|
|
|
static int detected_mask[coding_category_raw_text] = |
|
|
{ CATEGORY_MASK_ISO, |
|
|
CATEGORY_MASK_ISO, |
|
|
CATEGORY_MASK_ISO, |
|
|
CATEGORY_MASK_ISO, |
|
|
CATEGORY_MASK_ISO, |
|
|
CATEGORY_MASK_ISO, |
|
|
CATEGORY_MASK_UTF_8, |
|
|
CATEGORY_MASK_UTF_16, |
|
|
CATEGORY_MASK_UTF_16, |
|
|
CATEGORY_MASK_UTF_16, |
|
|
CATEGORY_MASK_UTF_16, |
|
|
CATEGORY_MASK_UTF_16, |
|
|
CATEGORY_MASK_CHARSET, |
|
|
CATEGORY_MASK_SJIS, |
|
|
CATEGORY_MASK_BIG5, |
|
|
CATEGORY_MASK_CCL, |
|
|
CATEGORY_MASK_EMACS_MULE |
|
|
}; |
|
|
|
|
704 |
/*** Commonly used macros and functions ***/ |
/*** Commonly used macros and functions ***/ |
705 |
|
|
706 |
#ifndef min |
#ifndef min |
3060 |
} |
} |
3061 |
continue; |
continue; |
3062 |
|
|
3063 |
|
case '%': |
3064 |
|
ONE_MORE_BYTE (c1); |
3065 |
|
if (c1 == '/') |
3066 |
|
{ |
3067 |
|
/* CTEXT extended segment: |
3068 |
|
ESC % / [0-4] M L --ENCODING-NAME-- \002 --BYTES-- |
3069 |
|
We keep these bytes as is for the moment. |
3070 |
|
They may be decoded by post-read-conversion. */ |
3071 |
|
int dim, M, L; |
3072 |
|
int size; |
3073 |
|
|
3074 |
|
ONE_MORE_BYTE (dim); |
3075 |
|
ONE_MORE_BYTE (M); |
3076 |
|
ONE_MORE_BYTE (L); |
3077 |
|
size = ((M - 128) * 128) + (L - 128); |
3078 |
|
if (charbuf + 8 + size > charbuf_end) |
3079 |
|
goto break_loop; |
3080 |
|
*charbuf++ = ISO_CODE_ESC; |
3081 |
|
*charbuf++ = '%'; |
3082 |
|
*charbuf++ = '/'; |
3083 |
|
*charbuf++ = dim; |
3084 |
|
*charbuf++ = BYTE8_TO_CHAR (M); |
3085 |
|
*charbuf++ = BYTE8_TO_CHAR (L); |
3086 |
|
while (size-- > 0) |
3087 |
|
{ |
3088 |
|
ONE_MORE_BYTE (c1); |
3089 |
|
*charbuf++ = ASCII_BYTE_P (c1) ? c1 : BYTE8_TO_CHAR (c1); |
3090 |
|
} |
3091 |
|
} |
3092 |
|
else if (c1 == 'G') |
3093 |
|
{ |
3094 |
|
/* XFree86 extension for embedding UTF-8 in CTEXT: |
3095 |
|
ESC % G --UTF-8-BYTES-- ESC % @ |
3096 |
|
We keep these bytes as is for the moment. |
3097 |
|
They may be decoded by post-read-conversion. */ |
3098 |
|
int *p = charbuf; |
3099 |
|
|
3100 |
|
if (p + 6 > charbuf_end) |
3101 |
|
goto break_loop; |
3102 |
|
*p++ = ISO_CODE_ESC; |
3103 |
|
*p++ = '%'; |
3104 |
|
*p++ = 'G'; |
3105 |
|
while (p < charbuf_end) |
3106 |
|
{ |
3107 |
|
ONE_MORE_BYTE (c1); |
3108 |
|
if (c1 == ISO_CODE_ESC |
3109 |
|
&& src + 1 < src_end |
3110 |
|
&& src[0] == '%' |
3111 |
|
&& src[1] == '@') |
3112 |
|
break; |
3113 |
|
*p++ = ASCII_BYTE_P (c1) ? c1 : BYTE8_TO_CHAR (c1); |
3114 |
|
} |
3115 |
|
if (p + 3 > charbuf_end) |
3116 |
|
goto break_loop; |
3117 |
|
*p++ = ISO_CODE_ESC; |
3118 |
|
*p++ = '%'; |
3119 |
|
*p++ = '@'; |
3120 |
|
charbuf = p; |
3121 |
|
} |
3122 |
|
else |
3123 |
|
goto invalid_code; |
3124 |
|
continue; |
3125 |
|
break; |
3126 |
|
|
3127 |
default: |
default: |
3128 |
if (! (CODING_ISO_FLAGS (coding) & CODING_ISO_FLAG_DESIGNATION)) |
if (! (CODING_ISO_FLAGS (coding) & CODING_ISO_FLAG_DESIGNATION)) |
3129 |
goto invalid_code; |
goto invalid_code; |
3212 |
*charbuf++ = ASCII_BYTE_P (c) ? c : BYTE8_TO_CHAR (c); |
*charbuf++ = ASCII_BYTE_P (c) ? c : BYTE8_TO_CHAR (c); |
3213 |
char_offset++; |
char_offset++; |
3214 |
coding->errors++; |
coding->errors++; |
3215 |
|
continue; |
3216 |
|
|
3217 |
|
break_loop: |
3218 |
|
break; |
3219 |
} |
} |
3220 |
|
|
3221 |
no_more_source: |
no_more_source: |
4335 |
struct ccl_program ccl; |
struct ccl_program ccl; |
4336 |
int source_charbuf[1024]; |
int source_charbuf[1024]; |
4337 |
int source_byteidx[1024]; |
int source_byteidx[1024]; |
4338 |
Lisp_Object attrs, eol_type, charset_list, valids; |
Lisp_Object attrs, eol_type, charset_list; |
4339 |
|
|
4340 |
CODING_GET_INFO (coding, attrs, eol_type, charset_list); |
CODING_GET_INFO (coding, attrs, eol_type, charset_list); |
4341 |
setup_ccl_program (&ccl, CODING_CCL_DECODER (coding)); |
setup_ccl_program (&ccl, CODING_CCL_DECODER (coding)); |
4841 |
{ |
{ |
4842 |
int i; |
int i; |
4843 |
int flags = XINT (AREF (attrs, coding_attr_iso_flags)); |
int flags = XINT (AREF (attrs, coding_attr_iso_flags)); |
|
enum coding_category category = XINT (CODING_ATTR_CATEGORY (attrs)); |
|
4844 |
|
|
4845 |
/* Invoke graphic register 0 to plane 0. */ |
/* Invoke graphic register 0 to plane 0. */ |
4846 |
CODING_ISO_INVOCATION (coding, 0) = 0; |
CODING_ISO_INVOCATION (coding, 0) = 0; |
5995 |
int *buf = coding->charbuf; |
int *buf = coding->charbuf; |
5996 |
int *buf_end = coding->charbuf + coding->charbuf_size; |
int *buf_end = coding->charbuf + coding->charbuf_size; |
5997 |
const unsigned char *src = coding->source + coding->consumed; |
const unsigned char *src = coding->source + coding->consumed; |
5998 |
|
const unsigned char *src_end = coding->source + coding->src_bytes; |
5999 |
EMACS_INT pos = coding->src_pos + coding->consumed_char; |
EMACS_INT pos = coding->src_pos + coding->consumed_char; |
6000 |
EMACS_INT end_pos = coding->src_pos + coding->src_chars; |
EMACS_INT end_pos = coding->src_pos + coding->src_chars; |
6001 |
int multibytep = coding->src_multibyte; |
int multibytep = coding->src_multibyte; |
6002 |
Lisp_Object eol_type; |
Lisp_Object eol_type; |
6003 |
int c; |
int c; |
6004 |
EMACS_INT stop, stop_composition, stop_charset; |
EMACS_INT stop, stop_composition, stop_charset; |
|
int id; |
|
6005 |
|
|
6006 |
eol_type = CODING_ID_EOL_TYPE (coding->id); |
eol_type = CODING_ID_EOL_TYPE (coding->id); |
6007 |
if (VECTORP (eol_type)) |
if (VECTORP (eol_type)) |
6025 |
{ |
{ |
6026 |
if (pos == stop) |
if (pos == stop) |
6027 |
{ |
{ |
|
int *p; |
|
|
|
|
6028 |
if (pos == end_pos) |
if (pos == end_pos) |
6029 |
break; |
break; |
6030 |
if (pos == stop_composition) |
if (pos == stop_composition) |
6038 |
} |
} |
6039 |
|
|
6040 |
if (! multibytep) |
if (! multibytep) |
6041 |
c = *src++; |
{ |
6042 |
|
EMACS_INT bytes = MULTIBYTE_LENGTH (src, src_end); |
6043 |
|
|
6044 |
|
if (bytes > 0) |
6045 |
|
c = STRING_CHAR_ADVANCE (src), pos += bytes; |
6046 |
|
else |
6047 |
|
c = *src++, pos++; |
6048 |
|
} |
6049 |
else |
else |
6050 |
c = STRING_CHAR_ADVANCE (src); |
c = STRING_CHAR_ADVANCE (src), pos++; |
6051 |
if ((c == '\r') && (coding->mode & CODING_MODE_SELECTIVE_DISPLAY)) |
if ((c == '\r') && (coding->mode & CODING_MODE_SELECTIVE_DISPLAY)) |
6052 |
c = '\n'; |
c = '\n'; |
6053 |
if (! EQ (eol_type, Qunix)) |
if (! EQ (eol_type, Qunix)) |
6061 |
} |
} |
6062 |
} |
} |
6063 |
*buf++ = c; |
*buf++ = c; |
|
pos++; |
|
6064 |
} |
} |
6065 |
|
|
6066 |
coding->consumed = src - coding->source; |
coding->consumed = src - coding->source; |
6132 |
return (coding->result); |
return (coding->result); |
6133 |
} |
} |
6134 |
|
|
|
/* Work buffer */ |
|
6135 |
|
|
6136 |
/* List of currently used working buffer. */ |
/* Stack of working buffers used in code conversion. An nil element |
6137 |
|
means that the code conversion of that level is not using a working |
6138 |
|
buffer. */ |
6139 |
Lisp_Object Vcode_conversion_work_buf_list; |
Lisp_Object Vcode_conversion_work_buf_list; |
6140 |
|
|
6141 |
/* A working buffer used by the top level conversion. */ |
/* A working buffer used by the top level conversion. */ |
6147 |
buffer. */ |
buffer. */ |
6148 |
|
|
6149 |
Lisp_Object |
Lisp_Object |
6150 |
make_conversion_work_buffer (multibytep) |
make_conversion_work_buffer (multibytep, depth) |
6151 |
int multibytep; |
int multibytep, depth; |
6152 |
{ |
{ |
6153 |
struct buffer *current = current_buffer; |
struct buffer *current = current_buffer; |
6154 |
Lisp_Object buf; |
Lisp_Object buf, name; |
6155 |
|
|
6156 |
if (NILP (Vcode_conversion_work_buf_list)) |
if (depth == 0) |
6157 |
{ |
{ |
6158 |
if (NILP (Vcode_conversion_reused_work_buf)) |
if (NILP (Vcode_conversion_reused_work_buf)) |
6159 |
Vcode_conversion_reused_work_buf |
Vcode_conversion_reused_work_buf |
6160 |
= Fget_buffer_create (build_string (" *code-conversion-work*")); |
= Fget_buffer_create (build_string (" *code-conversion-work<0>*")); |
6161 |
Vcode_conversion_work_buf_list |
buf = Vcode_conversion_reused_work_buf; |
|
= Fcons (Vcode_conversion_reused_work_buf, Qnil); |
|
6162 |
} |
} |
6163 |
else |
else |
6164 |
{ |
{ |
6165 |
int depth = XINT (Flength (Vcode_conversion_work_buf_list)); |
if (depth < 0) |
6166 |
char str[128]; |
{ |
6167 |
|
name = build_string (" *code-conversion-work*"); |
6168 |
|
name = Fgenerate_new_buffer_name (name, Qnil); |
6169 |
|
} |
6170 |
|
else |
6171 |
|
{ |
6172 |
|
char str[128]; |
6173 |
|
|
6174 |
sprintf (str, " *code-conversion-work*<%d>", depth); |
sprintf (str, " *code-conversion-work*<%d>", depth); |
6175 |
Vcode_conversion_work_buf_list |
name = build_string (str); |
6176 |
= Fcons (Fget_buffer_create (build_string (str)), |
} |
6177 |
Vcode_conversion_work_buf_list); |
buf = Fget_buffer_create (name); |
6178 |
} |
} |
|
|
|
|
buf = XCAR (Vcode_conversion_work_buf_list); |
|
6179 |
set_buffer_internal (XBUFFER (buf)); |
set_buffer_internal (XBUFFER (buf)); |
6180 |
current_buffer->undo_list = Qt; |
current_buffer->undo_list = Qt; |
6181 |
Ferase_buffer (); |
Ferase_buffer (); |
6184 |
return buf; |
return buf; |
6185 |
} |
} |
6186 |
|
|
6187 |
static struct coding_system *saved_coding; |
static Lisp_Object |
6188 |
|
code_conversion_restore (buffer) |
6189 |
|
Lisp_Object buffer; |
6190 |
|
{ |
6191 |
|
Lisp_Object workbuf; |
6192 |
|
|
6193 |
Lisp_Object |
workbuf = XCAR (Vcode_conversion_work_buf_list); |
6194 |
code_conversion_restore (info) |
if (! NILP (workbuf) |
6195 |
Lisp_Object info; |
&& ! EQ (workbuf, Vcode_conversion_reused_work_buf) |
6196 |
|
&& ! NILP (Fbuffer_live_p (workbuf))) |
6197 |
|
Fkill_buffer (workbuf); |
6198 |
|
Vcode_conversion_work_buf_list = XCDR (Vcode_conversion_work_buf_list); |
6199 |
|
set_buffer_internal (XBUFFER (buffer)); |
6200 |
|
return Qnil; |
6201 |
|
} |
6202 |
|
|
6203 |
|
static Lisp_Object |
6204 |
|
code_conversion_save (buffer, with_work_buf, multibyte) |
6205 |
|
Lisp_Object buffer; |
6206 |
|
int with_work_buf, multibyte; |
6207 |
{ |
{ |
6208 |
int depth = XINT (Flength (Vcode_conversion_work_buf_list)); |
Lisp_Object workbuf; |
|
Lisp_Object buf; |
|
6209 |
|
|
6210 |
if (depth > 0) |
if (with_work_buf) |
6211 |
{ |
{ |
6212 |
buf = XCAR (Vcode_conversion_work_buf_list); |
int depth = XINT (Flength (Vcode_conversion_work_buf_list)); |
|
Vcode_conversion_work_buf_list = XCDR (Vcode_conversion_work_buf_list); |
|
|
if (depth > 1 && !NILP (Fbuffer_live_p (buf))) |
|
|
Fkill_buffer (buf); |
|
|
} |
|
|
|
|
|
if (EQ (saved_coding->dst_object, Qt) |
|
|
&& saved_coding->destination) |
|
|
xfree (saved_coding->destination); |
|
6213 |
|
|
6214 |
return save_excursion_restore (info); |
workbuf = make_conversion_work_buffer (multibyte, depth); |
6215 |
|
} |
6216 |
|
else |
6217 |
|
workbuf = Qnil; |
6218 |
|
Vcode_conversion_work_buf_list |
6219 |
|
= Fcons (workbuf, Vcode_conversion_work_buf_list); |
6220 |
|
record_unwind_protect (code_conversion_restore, buffer); |
6221 |
|
return workbuf; |
6222 |
} |
} |
6223 |
|
|
|
|
|
6224 |
int |
int |
6225 |
decode_coding_gap (coding, chars, bytes) |
decode_coding_gap (coding, chars, bytes) |
6226 |
struct coding_system *coding; |
struct coding_system *coding; |
6227 |
EMACS_INT chars, bytes; |
EMACS_INT chars, bytes; |
6228 |
{ |
{ |
6229 |
int count = specpdl_ptr - specpdl; |
int count = specpdl_ptr - specpdl; |
6230 |
|
Lisp_Object buffer; |
6231 |
|
|
6232 |
saved_coding = coding; |
buffer = Fcurrent_buffer (); |
6233 |
record_unwind_protect (code_conversion_restore, save_excursion_save ()); |
code_conversion_save (buffer, 0, 0); |
6234 |
|
|
6235 |
coding->src_object = Fcurrent_buffer (); |
coding->src_object = buffer; |
6236 |
coding->src_chars = chars; |
coding->src_chars = chars; |
6237 |
coding->src_bytes = bytes; |
coding->src_bytes = bytes; |
6238 |
coding->src_pos = -chars; |
coding->src_pos = -chars; |
6261 |
int count = specpdl_ptr - specpdl; |
int count = specpdl_ptr - specpdl; |
6262 |
Lisp_Object buffer; |
Lisp_Object buffer; |
6263 |
|
|
|
saved_coding = coding; |
|
|
record_unwind_protect (code_conversion_restore, save_excursion_save ()); |
|
|
|
|
6264 |
buffer = Fcurrent_buffer (); |
buffer = Fcurrent_buffer (); |
6265 |
|
code_conversion_save (buffer, 0, 0); |
6266 |
|
|
6267 |
coding->src_object = buffer; |
coding->src_object = buffer; |
6268 |
coding->src_chars = chars; |
coding->src_chars = chars; |
6269 |
coding->src_bytes = bytes; |
coding->src_bytes = bytes; |
6324 |
EMACS_INT chars = to - from; |
EMACS_INT chars = to - from; |
6325 |
EMACS_INT bytes = to_byte - from_byte; |
EMACS_INT bytes = to_byte - from_byte; |
6326 |
Lisp_Object attrs; |
Lisp_Object attrs; |
6327 |
|
Lisp_Object buffer; |
6328 |
|
int saved_pt = -1, saved_pt_byte; |
6329 |
|
|
6330 |
saved_coding = coding; |
buffer = Fcurrent_buffer (); |
|
record_unwind_protect (code_conversion_restore, save_excursion_save ()); |
|
6331 |
|
|
6332 |
if (NILP (dst_object)) |
if (NILP (dst_object)) |
6333 |
{ |
{ |
6352 |
move_gap_both (from, from_byte); |
move_gap_both (from, from_byte); |
6353 |
if (EQ (src_object, dst_object)) |
if (EQ (src_object, dst_object)) |
6354 |
{ |
{ |
6355 |
|
saved_pt = PT, saved_pt_byte = PT_BYTE; |
6356 |
TEMP_SET_PT_BOTH (from, from_byte); |
TEMP_SET_PT_BOTH (from, from_byte); |
6357 |
del_range_both (from, from_byte, to, to_byte, 1); |
del_range_both (from, from_byte, to, to_byte, 1); |
6358 |
coding->src_pos = -chars; |
coding->src_pos = -chars; |
6373 |
|| (! NILP (CODING_ATTR_POST_READ (attrs)) |
|| (! NILP (CODING_ATTR_POST_READ (attrs)) |
6374 |
&& NILP (dst_object))) |
&& NILP (dst_object))) |
6375 |
{ |
{ |
6376 |
coding->dst_object = make_conversion_work_buffer (1); |
coding->dst_object = code_conversion_save (buffer, 1, 1); |
6377 |
coding->dst_pos = BEG; |
coding->dst_pos = BEG; |
6378 |
coding->dst_pos_byte = BEG_BYTE; |
coding->dst_pos_byte = BEG_BYTE; |
6379 |
coding->dst_multibyte = 1; |
coding->dst_multibyte = 1; |
6380 |
} |
} |
6381 |
else if (BUFFERP (dst_object)) |
else if (BUFFERP (dst_object)) |
6382 |
{ |
{ |
6383 |
|
code_conversion_save (buffer, 0, 0); |
6384 |
coding->dst_object = dst_object; |
coding->dst_object = dst_object; |
6385 |
coding->dst_pos = BUF_PT (XBUFFER (dst_object)); |
coding->dst_pos = BUF_PT (XBUFFER (dst_object)); |
6386 |
coding->dst_pos_byte = BUF_PT_BYTE (XBUFFER (dst_object)); |
coding->dst_pos_byte = BUF_PT_BYTE (XBUFFER (dst_object)); |
6389 |
} |
} |
6390 |
else |
else |
6391 |
{ |
{ |
6392 |
|
code_conversion_save (buffer, 0, 0); |
6393 |
coding->dst_object = Qnil; |
coding->dst_object = Qnil; |
6394 |
coding->dst_multibyte = 1; |
coding->dst_multibyte = 1; |
6395 |
} |
} |
6439 |
} |
} |
6440 |
} |
} |
6441 |
|
|
6442 |
|
if (saved_pt >= 0) |
6443 |
|
{ |
6444 |
|
/* This is the case of: |
6445 |
|
(BUFFERP (src_object) && EQ (src_object, dst_object)) |
6446 |
|
As we have moved PT while replacing the original buffer |
6447 |
|
contents, we must recover it now. */ |
6448 |
|
set_buffer_internal (XBUFFER (src_object)); |
6449 |
|
if (saved_pt < from) |
6450 |
|
TEMP_SET_PT_BOTH (saved_pt, saved_pt_byte); |
6451 |
|
else if (saved_pt < from + chars) |
6452 |
|
TEMP_SET_PT_BOTH (from, from_byte); |
6453 |
|
else if (! NILP (current_buffer->enable_multibyte_characters)) |
6454 |
|
TEMP_SET_PT_BOTH (saved_pt + (coding->produced_char - chars), |
6455 |
|
saved_pt_byte + (coding->produced - bytes)); |
6456 |
|
else |
6457 |
|
TEMP_SET_PT_BOTH (saved_pt + (coding->produced - bytes), |
6458 |
|
saved_pt_byte + (coding->produced - bytes)); |
6459 |
|
} |
6460 |
|
|
6461 |
unbind_to (count, Qnil); |
unbind_to (count, Qnil); |
6462 |
} |
} |
6463 |
|
|
6474 |
EMACS_INT chars = to - from; |
EMACS_INT chars = to - from; |
6475 |
EMACS_INT bytes = to_byte - from_byte; |
EMACS_INT bytes = to_byte - from_byte; |
6476 |
Lisp_Object attrs; |
Lisp_Object attrs; |
6477 |
|
Lisp_Object buffer; |
6478 |
|
int saved_pt = -1, saved_pt_byte; |
6479 |
|
|
6480 |
saved_coding = coding; |
buffer = Fcurrent_buffer (); |
|
record_unwind_protect (code_conversion_restore, save_excursion_save ()); |
|
6481 |
|
|
6482 |
coding->src_object = src_object; |
coding->src_object = src_object; |
6483 |
coding->src_chars = chars; |
coding->src_chars = chars; |
6488 |
|
|
6489 |
if (! NILP (CODING_ATTR_PRE_WRITE (attrs))) |
if (! NILP (CODING_ATTR_PRE_WRITE (attrs))) |
6490 |
{ |
{ |
6491 |
coding->src_object = make_conversion_work_buffer (coding->src_multibyte); |
coding->src_object = code_conversion_save (buffer, 1, |
6492 |
|
coding->src_multibyte); |
6493 |
set_buffer_internal (XBUFFER (coding->src_object)); |
set_buffer_internal (XBUFFER (coding->src_object)); |
6494 |
if (STRINGP (src_object)) |
if (STRINGP (src_object)) |
6495 |
insert_from_string (src_object, from, from_byte, chars, bytes, 0); |
insert_from_string (src_object, from, from_byte, chars, bytes, 0); |
6501 |
if (EQ (src_object, dst_object)) |
if (EQ (src_object, dst_object)) |
6502 |
{ |
{ |
6503 |
set_buffer_internal (XBUFFER (src_object)); |
set_buffer_internal (XBUFFER (src_object)); |
6504 |
|
saved_pt = PT, saved_pt_byte = PT_BYTE; |
6505 |
del_range_both (from, from_byte, to, to_byte, 1); |
del_range_both (from, from_byte, to, to_byte, 1); |
6506 |
set_buffer_internal (XBUFFER (coding->src_object)); |
set_buffer_internal (XBUFFER (coding->src_object)); |
6507 |
} |
} |
6519 |
} |
} |
6520 |
else if (STRINGP (src_object)) |
else if (STRINGP (src_object)) |
6521 |
{ |
{ |
6522 |
|
code_conversion_save (buffer, 0, 0); |
6523 |
coding->src_pos = from; |
coding->src_pos = from; |
6524 |
coding->src_pos_byte = from_byte; |
coding->src_pos_byte = from_byte; |
6525 |
} |
} |
6526 |
else if (BUFFERP (src_object)) |
else if (BUFFERP (src_object)) |
6527 |
{ |
{ |
6528 |
|
code_conversion_save (buffer, 0, 0); |
6529 |
set_buffer_internal (XBUFFER (src_object)); |
set_buffer_internal (XBUFFER (src_object)); |
6530 |
if (EQ (src_object, dst_object)) |
if (EQ (src_object, dst_object)) |
6531 |
{ |
{ |
6532 |
|
saved_pt = PT, saved_pt_byte = PT_BYTE; |
6533 |
coding->src_object = del_range_1 (from, to, 1, 1); |
coding->src_object = del_range_1 (from, to, 1, 1); |
6534 |
coding->src_pos = 0; |
coding->src_pos = 0; |
6535 |
coding->src_pos_byte = 0; |
coding->src_pos_byte = 0; |
6542 |
coding->src_pos_byte = from_byte; |
coding->src_pos_byte = from_byte; |
6543 |
} |
} |
6544 |
} |
} |
6545 |
|
else |
6546 |
|
code_conversion_save (buffer, 0, 0); |
6547 |
|
|
6548 |
if (BUFFERP (dst_object)) |
if (BUFFERP (dst_object)) |
6549 |
{ |
{ |
6591 |
} |
} |
6592 |
} |
} |
6593 |
|
|
6594 |
|
if (saved_pt >= 0) |
6595 |
|
{ |
6596 |
|
/* This is the case of: |
6597 |
|
(BUFFERP (src_object) && EQ (src_object, dst_object)) |
6598 |
|
As we have moved PT while replacing the original buffer |
6599 |
|
contents, we must recover it now. */ |
6600 |
|
set_buffer_internal (XBUFFER (src_object)); |
6601 |
|
if (saved_pt < from) |
6602 |
|
TEMP_SET_PT_BOTH (saved_pt, saved_pt_byte); |
6603 |
|
else if (saved_pt < from + chars) |
6604 |
|
TEMP_SET_PT_BOTH (from, from_byte); |
6605 |
|
else if (! NILP (current_buffer->enable_multibyte_characters)) |
6606 |
|
TEMP_SET_PT_BOTH (saved_pt + (coding->produced_char - chars), |
6607 |
|
saved_pt_byte + (coding->produced - bytes)); |
6608 |
|
else |
6609 |
|
TEMP_SET_PT_BOTH (saved_pt + (coding->produced - bytes), |
6610 |
|
saved_pt_byte + (coding->produced - bytes)); |
6611 |
|
} |
6612 |
|
|
6613 |
unbind_to (count, Qnil); |
unbind_to (count, Qnil); |
6614 |
} |
} |
6615 |
|
|
6706 |
Lisp_Object coding_system; |
Lisp_Object coding_system; |
6707 |
{ |
{ |
6708 |
unsigned char *src_end = src + src_bytes; |
unsigned char *src_end = src + src_bytes; |
|
int mask = CATEGORY_MASK_ANY; |
|
6709 |
Lisp_Object attrs, eol_type; |
Lisp_Object attrs, eol_type; |
6710 |
Lisp_Object val; |
Lisp_Object val; |
6711 |
struct coding_system coding; |
struct coding_system coding; |
8121 |
else if (EQ (coding_type, Qiso_2022)) |
else if (EQ (coding_type, Qiso_2022)) |
8122 |
{ |
{ |
8123 |
Lisp_Object initial, reg_usage, request, flags; |
Lisp_Object initial, reg_usage, request, flags; |
8124 |
int i, id; |
int i; |
8125 |
|
|
8126 |
if (nargs < coding_arg_iso2022_max) |
if (nargs < coding_arg_iso2022_max) |
8127 |
goto short_args; |
goto short_args; |