1 |
/* Coding system handler (conversion, detection, and etc). |
/* Coding system handler (conversion, detection, and etc). |
2 |
Copyright (C) 1995, 1997, 1998, 2002 Electrotechnical Laboratory, JAPAN. |
Copyright (C) 1995, 1997, 1998, 2002 Electrotechnical Laboratory, JAPAN. |
3 |
Licensed to the Free Software Foundation. |
Licensed to the Free Software Foundation. |
4 |
Copyright (C) 2001 Free Software Foundation, Inc. |
Copyright (C) 2001,2002 Free Software Foundation, Inc. |
5 |
|
|
6 |
This file is part of GNU Emacs. |
This file is part of GNU Emacs. |
7 |
|
|
367 |
|
|
368 |
Lisp_Object Vselect_safe_coding_system_function; |
Lisp_Object Vselect_safe_coding_system_function; |
369 |
|
|
370 |
|
int coding_system_require_warning; |
371 |
|
|
372 |
/* Mnemonic string for each format of end-of-line. */ |
/* Mnemonic string for each format of end-of-line. */ |
373 |
Lisp_Object eol_mnemonic_unix, eol_mnemonic_dos, eol_mnemonic_mac; |
Lisp_Object eol_mnemonic_unix, eol_mnemonic_dos, eol_mnemonic_mac; |
374 |
/* Mnemonic string to indicate format of end-of-line is not yet |
/* Mnemonic string to indicate format of end-of-line is not yet |
381 |
|
|
382 |
#ifdef emacs |
#ifdef emacs |
383 |
|
|
384 |
|
/* Information about which coding system is safe for which chars. |
385 |
|
The value has the form (GENERIC-LIST . NON-GENERIC-ALIST). |
386 |
|
|
387 |
|
GENERIC-LIST is a list of generic coding systems which can encode |
388 |
|
any characters. |
389 |
|
|
390 |
|
NON-GENERIC-ALIST is an alist of non generic coding systems vs the |
391 |
|
corresponding char table that contains safe chars. */ |
392 |
|
Lisp_Object Vcoding_system_safe_chars; |
393 |
|
|
394 |
Lisp_Object Vcoding_system_list, Vcoding_system_alist; |
Lisp_Object Vcoding_system_list, Vcoding_system_alist; |
395 |
|
|
396 |
Lisp_Object Qcoding_system_p, Qcoding_system_error; |
Lisp_Object Qcoding_system_p, Qcoding_system_error; |
497 |
/* Default coding systems used for process I/O. */ |
/* Default coding systems used for process I/O. */ |
498 |
Lisp_Object Vdefault_process_coding_system; |
Lisp_Object Vdefault_process_coding_system; |
499 |
|
|
500 |
|
/* Char table for translating Quail and self-inserting input. */ |
501 |
|
Lisp_Object Vtranslation_table_for_input; |
502 |
|
|
503 |
/* Global flag to tell that we can't call post-read-conversion and |
/* Global flag to tell that we can't call post-read-conversion and |
504 |
pre-write-conversion functions. Usually the value is zero, but it |
pre-write-conversion functions. Usually the value is zero, but it |
505 |
is set to 1 temporarily while such functions are running. This is |
is set to 1 temporarily while such functions are running. This is |
506 |
to avoid infinite recursive call. */ |
to avoid infinite recursive call. */ |
507 |
static int inhibit_pre_post_conversion; |
static int inhibit_pre_post_conversion; |
508 |
|
|
|
/* Char-table containing safe coding systems of each character. */ |
|
|
Lisp_Object Vchar_coding_system_table; |
|
509 |
Lisp_Object Qchar_coding_system; |
Lisp_Object Qchar_coding_system; |
510 |
|
|
511 |
/* Return `safe-chars' property of coding system CODING. Don't check |
/* Return `safe-chars' property of CODING_SYSTEM (symbol). Don't check |
512 |
validity of CODING. */ |
its validity. */ |
513 |
|
|
514 |
Lisp_Object |
Lisp_Object |
515 |
coding_safe_chars (coding) |
coding_safe_chars (coding_system) |
516 |
struct coding_system *coding; |
Lisp_Object coding_system; |
517 |
{ |
{ |
518 |
Lisp_Object coding_spec, plist, safe_chars; |
Lisp_Object coding_spec, plist, safe_chars; |
519 |
|
|
520 |
coding_spec = Fget (coding->symbol, Qcoding_system); |
coding_spec = Fget (coding_system, Qcoding_system); |
521 |
plist = XVECTOR (coding_spec)->contents[3]; |
plist = XVECTOR (coding_spec)->contents[3]; |
522 |
safe_chars = Fplist_get (XVECTOR (coding_spec)->contents[3], Qsafe_chars); |
safe_chars = Fplist_get (XVECTOR (coding_spec)->contents[3], Qsafe_chars); |
523 |
return (CHAR_TABLE_P (safe_chars) ? safe_chars : Qt); |
return (CHAR_TABLE_P (safe_chars) ? safe_chars : Qt); |
686 |
|
|
687 |
/* Record one COMPONENT (alternate character or composition rule). */ |
/* Record one COMPONENT (alternate character or composition rule). */ |
688 |
|
|
689 |
#define CODING_ADD_COMPOSITION_COMPONENT(coding, component) \ |
#define CODING_ADD_COMPOSITION_COMPONENT(coding, component) \ |
690 |
(coding->cmp_data->data[coding->cmp_data->used++] = component) |
do { \ |
691 |
|
coding->cmp_data->data[coding->cmp_data->used++] = component; \ |
692 |
|
if (coding->cmp_data->used - coding->cmp_data_start \ |
693 |
|
== COMPOSITION_DATA_MAX_BUNCH_LENGTH) \ |
694 |
|
{ \ |
695 |
|
CODING_ADD_COMPOSITION_END (coding, coding->produced_char); \ |
696 |
|
coding->composing = COMPOSITION_NO; \ |
697 |
|
} \ |
698 |
|
} while (0) |
699 |
|
|
700 |
|
|
701 |
/* Get one byte from a data pointed by SRC and increment SRC. If SRC |
/* Get one byte from a data pointed by SRC and increment SRC. If SRC |
963 |
ONE_MORE_BYTE (c); |
ONE_MORE_BYTE (c); |
964 |
if (c != '\n') |
if (c != '\n') |
965 |
{ |
{ |
|
if (coding->mode & CODING_MODE_INHIBIT_INCONSISTENT_EOL) |
|
|
{ |
|
|
coding->result = CODING_FINISH_INCONSISTENT_EOL; |
|
|
goto label_end_of_loop; |
|
|
} |
|
966 |
src--; |
src--; |
967 |
c = '\r'; |
c = '\r'; |
968 |
} |
} |
984 |
coding->produced_char++; |
coding->produced_char++; |
985 |
continue; |
continue; |
986 |
} |
} |
987 |
else if (*src == 0x80) |
else if (*src == 0x80 && coding->cmp_data) |
988 |
{ |
{ |
989 |
/* Start of composition data. */ |
/* Start of composition data. */ |
990 |
int consumed = decode_composition_emacs_mule (coding, src, src_end, |
int consumed = decode_composition_emacs_mule (coding, src, src_end, |
1077 |
} while (0) |
} while (0) |
1078 |
|
|
1079 |
|
|
1080 |
static void encode_eol P_ ((struct coding_system *, unsigned char *, |
static void encode_eol P_ ((struct coding_system *, const unsigned char *, |
1081 |
unsigned char *, int, int)); |
unsigned char *, int, int)); |
1082 |
|
|
1083 |
static void |
static void |
1326 |
#define CHARSET_OK(idx, charset, c) \ |
#define CHARSET_OK(idx, charset, c) \ |
1327 |
(coding_system_table[idx] \ |
(coding_system_table[idx] \ |
1328 |
&& (charset == CHARSET_ASCII \ |
&& (charset == CHARSET_ASCII \ |
1329 |
|| (safe_chars = coding_safe_chars (coding_system_table[idx]), \ |
|| (safe_chars = coding_safe_chars (coding_system_table[idx]->symbol), \ |
1330 |
CODING_SAFE_CHAR_P (safe_chars, c))) \ |
CODING_SAFE_CHAR_P (safe_chars, c))) \ |
1331 |
&& (CODING_SPEC_ISO_REQUESTED_DESIGNATION (coding_system_table[idx], \ |
&& (CODING_SPEC_ISO_REQUESTED_DESIGNATION (coding_system_table[idx], \ |
1332 |
charset) \ |
charset) \ |
1335 |
#define SHIFT_OUT_OK(idx) \ |
#define SHIFT_OUT_OK(idx) \ |
1336 |
(CODING_SPEC_ISO_INITIAL_DESIGNATION (coding_system_table[idx], 1) >= 0) |
(CODING_SPEC_ISO_INITIAL_DESIGNATION (coding_system_table[idx], 1) >= 0) |
1337 |
|
|
1338 |
|
#define COMPOSITION_OK(idx) \ |
1339 |
|
(coding_system_table[idx]->composing != COMPOSITION_DISABLED) |
1340 |
|
|
1341 |
/* See the above "GENERAL NOTES on `detect_coding_XXX ()' functions". |
/* See the above "GENERAL NOTES on `detect_coding_XXX ()' functions". |
1342 |
Check if a text is encoded in ISO2022. If it is, return an |
Check if a text is encoded in ISO2022. If it is, return an |
1343 |
integer in which appropriate flag bits any of: |
integer in which appropriate flag bits any of: |
1368 |
while (mask && src < src_end) |
while (mask && src < src_end) |
1369 |
{ |
{ |
1370 |
ONE_MORE_BYTE_CHECK_MULTIBYTE (c, multibytep); |
ONE_MORE_BYTE_CHECK_MULTIBYTE (c, multibytep); |
1371 |
|
retry: |
1372 |
switch (c) |
switch (c) |
1373 |
{ |
{ |
1374 |
case ISO_CODE_ESC: |
case ISO_CODE_ESC: |
1415 |
else if (c >= '0' && c <= '4') |
else if (c >= '0' && c <= '4') |
1416 |
{ |
{ |
1417 |
/* ESC <Fp> for start/end composition. */ |
/* ESC <Fp> for start/end composition. */ |
1418 |
mask_found |= CODING_CATEGORY_MASK_ISO; |
if (COMPOSITION_OK (CODING_CATEGORY_IDX_ISO_7)) |
1419 |
|
mask_found |= CODING_CATEGORY_MASK_ISO_7; |
1420 |
|
else |
1421 |
|
mask &= ~CODING_CATEGORY_MASK_ISO_7; |
1422 |
|
if (COMPOSITION_OK (CODING_CATEGORY_IDX_ISO_7_TIGHT)) |
1423 |
|
mask_found |= CODING_CATEGORY_MASK_ISO_7_TIGHT; |
1424 |
|
else |
1425 |
|
mask &= ~CODING_CATEGORY_MASK_ISO_7_TIGHT; |
1426 |
|
if (COMPOSITION_OK (CODING_CATEGORY_IDX_ISO_8_1)) |
1427 |
|
mask_found |= CODING_CATEGORY_MASK_ISO_8_1; |
1428 |
|
else |
1429 |
|
mask &= ~CODING_CATEGORY_MASK_ISO_8_1; |
1430 |
|
if (COMPOSITION_OK (CODING_CATEGORY_IDX_ISO_8_2)) |
1431 |
|
mask_found |= CODING_CATEGORY_MASK_ISO_8_2; |
1432 |
|
else |
1433 |
|
mask &= ~CODING_CATEGORY_MASK_ISO_8_2; |
1434 |
|
if (COMPOSITION_OK (CODING_CATEGORY_IDX_ISO_7_ELSE)) |
1435 |
|
mask_found |= CODING_CATEGORY_MASK_ISO_7_ELSE; |
1436 |
|
else |
1437 |
|
mask &= ~CODING_CATEGORY_MASK_ISO_7_ELSE; |
1438 |
|
if (COMPOSITION_OK (CODING_CATEGORY_IDX_ISO_8_ELSE)) |
1439 |
|
mask_found |= CODING_CATEGORY_MASK_ISO_8_ELSE; |
1440 |
|
else |
1441 |
|
mask &= ~CODING_CATEGORY_MASK_ISO_8_ELSE; |
1442 |
break; |
break; |
1443 |
} |
} |
1444 |
else |
else |
1566 |
&& mask & CODING_CATEGORY_MASK_ISO_8_2) |
&& mask & CODING_CATEGORY_MASK_ISO_8_2) |
1567 |
{ |
{ |
1568 |
int i = 1; |
int i = 1; |
1569 |
|
|
1570 |
|
c = -1; |
1571 |
while (src < src_end) |
while (src < src_end) |
1572 |
{ |
{ |
1573 |
ONE_MORE_BYTE_CHECK_MULTIBYTE (c, multibytep); |
ONE_MORE_BYTE_CHECK_MULTIBYTE (c, multibytep); |
1580 |
mask &= ~CODING_CATEGORY_MASK_ISO_8_2; |
mask &= ~CODING_CATEGORY_MASK_ISO_8_2; |
1581 |
else |
else |
1582 |
mask_found |= CODING_CATEGORY_MASK_ISO_8_2; |
mask_found |= CODING_CATEGORY_MASK_ISO_8_2; |
1583 |
|
if (c >= 0) |
1584 |
|
/* This means that we have read one extra byte. */ |
1585 |
|
goto retry; |
1586 |
} |
} |
1587 |
} |
} |
1588 |
break; |
break; |
1781 |
Lisp_Object translation_table; |
Lisp_Object translation_table; |
1782 |
Lisp_Object safe_chars; |
Lisp_Object safe_chars; |
1783 |
|
|
1784 |
safe_chars = coding_safe_chars (coding); |
safe_chars = coding_safe_chars (coding->symbol); |
1785 |
|
|
1786 |
if (NILP (Venable_character_translation)) |
if (NILP (Venable_character_translation)) |
1787 |
translation_table = Qnil; |
translation_table = Qnil; |
1872 |
ONE_MORE_BYTE (c1); |
ONE_MORE_BYTE (c1); |
1873 |
if (c1 != ISO_CODE_LF) |
if (c1 != ISO_CODE_LF) |
1874 |
{ |
{ |
|
if (coding->mode & CODING_MODE_INHIBIT_INCONSISTENT_EOL) |
|
|
{ |
|
|
coding->result = CODING_FINISH_INCONSISTENT_EOL; |
|
|
goto label_end_of_loop; |
|
|
} |
|
1875 |
src--; |
src--; |
1876 |
c1 = '\r'; |
c1 = '\r'; |
1877 |
} |
} |
2534 |
Lisp_Object translation_table; |
Lisp_Object translation_table; |
2535 |
Lisp_Object safe_chars; |
Lisp_Object safe_chars; |
2536 |
|
|
2537 |
safe_chars = coding_safe_chars (coding); |
safe_chars = coding_safe_chars (coding->symbol); |
2538 |
|
|
2539 |
if (NILP (Venable_character_translation)) |
if (NILP (Venable_character_translation)) |
2540 |
translation_table = Qnil; |
translation_table = Qnil; |
2728 |
|
|
2729 |
/* Macros to decode or encode a character of Big5 in BIG5. B1 and B2 |
/* Macros to decode or encode a character of Big5 in BIG5. B1 and B2 |
2730 |
are the 1st and 2nd position-codes of Big5 in BIG5 coding system. |
are the 1st and 2nd position-codes of Big5 in BIG5 coding system. |
2731 |
C1 and C2 are the 1st and 2nd position-codes of of Emacs' internal |
C1 and C2 are the 1st and 2nd position-codes of Emacs' internal |
2732 |
format. CHARSET is `charset_big5_1' or `charset_big5_2'. */ |
format. CHARSET is `charset_big5_1' or `charset_big5_2'. */ |
2733 |
|
|
2734 |
/* Number of Big5 characters which have the same code in 1st byte. */ |
/* Number of Big5 characters which have the same code in 1st byte. */ |
2965 |
ONE_MORE_BYTE (c2); |
ONE_MORE_BYTE (c2); |
2966 |
if (c2 == '\n') |
if (c2 == '\n') |
2967 |
c1 = c2; |
c1 = c2; |
|
else if (coding->mode |
|
|
& CODING_MODE_INHIBIT_INCONSISTENT_EOL) |
|
|
{ |
|
|
coding->result = CODING_FINISH_INCONSISTENT_EOL; |
|
|
goto label_end_of_loop; |
|
|
} |
|
2968 |
else |
else |
2969 |
/* To process C2 again, SRC is subtracted by 1. */ |
/* To process C2 again, SRC is subtracted by 1. */ |
2970 |
src--; |
src--; |
3210 |
ONE_MORE_BYTE (c); |
ONE_MORE_BYTE (c); |
3211 |
if (c != '\n') |
if (c != '\n') |
3212 |
{ |
{ |
|
if (coding->mode & CODING_MODE_INHIBIT_INCONSISTENT_EOL) |
|
|
{ |
|
|
coding->result = CODING_FINISH_INCONSISTENT_EOL; |
|
|
goto label_end_of_loop; |
|
|
} |
|
3213 |
src--; |
src--; |
3214 |
c = '\r'; |
c = '\r'; |
3215 |
} |
} |
3268 |
static void |
static void |
3269 |
encode_eol (coding, source, destination, src_bytes, dst_bytes) |
encode_eol (coding, source, destination, src_bytes, dst_bytes) |
3270 |
struct coding_system *coding; |
struct coding_system *coding; |
3271 |
unsigned char *source, *destination; |
const unsigned char *source; |
3272 |
|
unsigned char *destination; |
3273 |
int src_bytes, dst_bytes; |
int src_bytes, dst_bytes; |
3274 |
{ |
{ |
3275 |
unsigned char *src = source; |
const unsigned char *src = source; |
3276 |
unsigned char *dst = destination; |
unsigned char *dst = destination; |
3277 |
unsigned char *src_end = src + src_bytes; |
const unsigned char *src_end = src + src_bytes; |
3278 |
unsigned char *dst_end = dst + dst_bytes; |
unsigned char *dst_end = dst + dst_bytes; |
3279 |
Lisp_Object translation_table; |
Lisp_Object translation_table; |
3280 |
/* SRC_BASE remembers the start position in source in each loop. |
/* SRC_BASE remembers the start position in source in each loop. |
3282 |
analyze multi-byte codes (within macro ONE_MORE_CHAR), or when |
analyze multi-byte codes (within macro ONE_MORE_CHAR), or when |
3283 |
there's not enough destination area to produce encoded codes |
there's not enough destination area to produce encoded codes |
3284 |
(within macro EMIT_BYTES). */ |
(within macro EMIT_BYTES). */ |
3285 |
unsigned char *src_base; |
const unsigned char *src_base; |
3286 |
|
unsigned char *tmp; |
3287 |
int c; |
int c; |
3288 |
int selective_display = coding->mode & CODING_MODE_SELECTIVE_DISPLAY; |
int selective_display = coding->mode & CODING_MODE_SELECTIVE_DISPLAY; |
3289 |
|
|
3333 |
} |
} |
3334 |
if (coding->eol_type == CODING_EOL_CR) |
if (coding->eol_type == CODING_EOL_CR) |
3335 |
{ |
{ |
3336 |
for (src = destination; src < dst; src++) |
for (tmp = destination; tmp < dst; tmp++) |
3337 |
if (*src == '\n') *src = '\r'; |
if (*tmp == '\n') *tmp = '\r'; |
3338 |
} |
} |
3339 |
else if (selective_display) |
else if (selective_display) |
3340 |
{ |
{ |
3341 |
for (src = destination; src < dst; src++) |
for (tmp = destination; tmp < dst; tmp++) |
3342 |
if (*src == '\r') *src = '\n'; |
if (*tmp == '\r') *tmp = '\n'; |
3343 |
} |
} |
3344 |
} |
} |
3345 |
if (coding->src_multibyte) |
if (coding->src_multibyte) |
3532 |
coding->type = coding_type_emacs_mule; |
coding->type = coding_type_emacs_mule; |
3533 |
coding->common_flags |
coding->common_flags |
3534 |
|= CODING_REQUIRE_DECODING_MASK | CODING_REQUIRE_ENCODING_MASK; |
|= CODING_REQUIRE_DECODING_MASK | CODING_REQUIRE_ENCODING_MASK; |
|
coding->composing = COMPOSITION_NO; |
|
3535 |
if (!NILP (coding->post_read_conversion)) |
if (!NILP (coding->post_read_conversion)) |
3536 |
coding->common_flags |= CODING_REQUIRE_DECODING_MASK; |
coding->common_flags |= CODING_REQUIRE_DECODING_MASK; |
3537 |
if (!NILP (coding->pre_write_conversion)) |
if (!NILP (coding->pre_write_conversion)) |
4127 |
void |
void |
4128 |
detect_coding (coding, src, src_bytes) |
detect_coding (coding, src, src_bytes) |
4129 |
struct coding_system *coding; |
struct coding_system *coding; |
4130 |
unsigned char *src; |
const unsigned char *src; |
4131 |
int src_bytes; |
int src_bytes; |
4132 |
{ |
{ |
4133 |
unsigned int idx; |
unsigned int idx; |
4300 |
void |
void |
4301 |
detect_eol (coding, src, src_bytes) |
detect_eol (coding, src, src_bytes) |
4302 |
struct coding_system *coding; |
struct coding_system *coding; |
4303 |
unsigned char *src; |
const unsigned char *src; |
4304 |
int src_bytes; |
int src_bytes; |
4305 |
{ |
{ |
4306 |
Lisp_Object val; |
Lisp_Object val; |
4350 |
{ |
{ |
4351 |
int src_multibyte = coding->src_multibyte; |
int src_multibyte = coding->src_multibyte; |
4352 |
int dst_multibyte = coding->dst_multibyte; |
int dst_multibyte = coding->dst_multibyte; |
4353 |
|
struct composition_data *cmp_data = coding->cmp_data; |
4354 |
|
|
4355 |
setup_coding_system (XVECTOR (val)->contents[eol_type], coding); |
setup_coding_system (XVECTOR (val)->contents[eol_type], coding); |
4356 |
coding->src_multibyte = src_multibyte; |
coding->src_multibyte = src_multibyte; |
4357 |
coding->dst_multibyte = dst_multibyte; |
coding->dst_multibyte = dst_multibyte; |
4358 |
coding->heading_ascii = skip; |
coding->heading_ascii = skip; |
4359 |
|
coding->cmp_data = cmp_data; |
4360 |
} |
} |
4361 |
} |
} |
4362 |
|
|
4718 |
int |
int |
4719 |
decode_coding (coding, source, destination, src_bytes, dst_bytes) |
decode_coding (coding, source, destination, src_bytes, dst_bytes) |
4720 |
struct coding_system *coding; |
struct coding_system *coding; |
4721 |
unsigned char *source, *destination; |
const unsigned char *source; |
4722 |
|
unsigned char *destination; |
4723 |
int src_bytes, dst_bytes; |
int src_bytes, dst_bytes; |
4724 |
{ |
{ |
4725 |
int extra = 0; |
int extra = 0; |
4798 |
if (coding->mode & CODING_MODE_LAST_BLOCK |
if (coding->mode & CODING_MODE_LAST_BLOCK |
4799 |
&& coding->result == CODING_FINISH_INSUFFICIENT_SRC) |
&& coding->result == CODING_FINISH_INSUFFICIENT_SRC) |
4800 |
{ |
{ |
4801 |
unsigned char *src = source + coding->consumed; |
const unsigned char *src = source + coding->consumed; |
4802 |
unsigned char *dst = destination + coding->produced; |
unsigned char *dst = destination + coding->produced; |
4803 |
|
|
4804 |
src_bytes -= coding->consumed; |
src_bytes -= coding->consumed; |
4832 |
int |
int |
4833 |
encode_coding (coding, source, destination, src_bytes, dst_bytes) |
encode_coding (coding, source, destination, src_bytes, dst_bytes) |
4834 |
struct coding_system *coding; |
struct coding_system *coding; |
4835 |
unsigned char *source, *destination; |
const unsigned char *source; |
4836 |
|
unsigned char *destination; |
4837 |
int src_bytes, dst_bytes; |
int src_bytes, dst_bytes; |
4838 |
{ |
{ |
4839 |
coding->produced = coding->produced_char = 0; |
coding->produced = coding->produced_char = 0; |
4875 |
if (coding->mode & CODING_MODE_LAST_BLOCK |
if (coding->mode & CODING_MODE_LAST_BLOCK |
4876 |
&& coding->result == CODING_FINISH_INSUFFICIENT_SRC) |
&& coding->result == CODING_FINISH_INSUFFICIENT_SRC) |
4877 |
{ |
{ |
4878 |
unsigned char *src = source + coding->consumed; |
const unsigned char *src = source + coding->consumed; |
4879 |
unsigned char *dst = destination + coding->produced; |
unsigned char *dst = destination + coding->produced; |
4880 |
|
|
4881 |
if (coding->type == coding_type_iso2022) |
if (coding->type == coding_type_iso2022) |
5259 |
else if (VECTORP (val) || STRINGP (val)) |
else if (VECTORP (val) || STRINGP (val)) |
5260 |
{ |
{ |
5261 |
int len = (VECTORP (val) |
int len = (VECTORP (val) |
5262 |
? XVECTOR (val)->size : XSTRING (val)->size); |
? XVECTOR (val)->size : SCHARS (val)); |
5263 |
int i; |
int i; |
5264 |
for (i = 0; i < len; i++) |
for (i = 0; i < len; i++) |
5265 |
{ |
{ |
5321 |
int len = data[0] - 4, j; |
int len = data[0] - 4, j; |
5322 |
Lisp_Object args[MAX_COMPOSITION_COMPONENTS * 2 - 1]; |
Lisp_Object args[MAX_COMPOSITION_COMPONENTS * 2 - 1]; |
5323 |
|
|
5324 |
|
if (method == COMPOSITION_WITH_RULE_ALTCHARS |
5325 |
|
&& len % 2 == 0) |
5326 |
|
len --; |
5327 |
for (j = 0; j < len; j++) |
for (j = 0; j < len; j++) |
5328 |
args[j] = make_number (data[4 + j]); |
args[j] = make_number (data[4 + j]); |
5329 |
components = (method == COMPOSITION_WITH_ALTCHARS |
components = (method == COMPOSITION_WITH_ALTCHARS |
5725 |
REQUIRE + LEN_BYTE = LEN_BYTE * (NEW / ORIG) |
REQUIRE + LEN_BYTE = LEN_BYTE * (NEW / ORIG) |
5726 |
REQUIRE = LEN_BYTE * (NEW - ORIG) / ORIG |
REQUIRE = LEN_BYTE * (NEW - ORIG) / ORIG |
5727 |
Here, we are sure that NEW >= ORIG. */ |
Here, we are sure that NEW >= ORIG. */ |
5728 |
float ratio = coding->produced - coding->consumed; |
float ratio; |
5729 |
ratio /= coding->consumed; |
|
5730 |
require = len_byte * ratio; |
if (coding->produced <= coding->consumed) |
5731 |
|
{ |
5732 |
|
/* This happens because of CCL-based coding system with |
5733 |
|
eol-type CRLF. */ |
5734 |
|
require = 0; |
5735 |
|
} |
5736 |
|
else |
5737 |
|
{ |
5738 |
|
ratio = (coding->produced - coding->consumed) / coding->consumed; |
5739 |
|
require = len_byte * ratio; |
5740 |
|
} |
5741 |
first = 0; |
first = 0; |
5742 |
} |
} |
5743 |
if ((src - dst) < (require + 2000)) |
if ((src - dst) < (require + 2000)) |
5852 |
struct coding_system *coding; |
struct coding_system *coding; |
5853 |
int encodep; |
int encodep; |
5854 |
{ |
{ |
5855 |
int count = specpdl_ptr - specpdl; |
int count = SPECPDL_INDEX (); |
5856 |
struct gcpro gcpro1; |
struct gcpro gcpro1, gcpro2; |
5857 |
int multibyte = STRING_MULTIBYTE (str); |
int multibyte = STRING_MULTIBYTE (str); |
5858 |
Lisp_Object buffer; |
Lisp_Object buffer; |
5859 |
struct buffer *buf; |
struct buffer *buf; |
5860 |
|
Lisp_Object old_deactivate_mark; |
5861 |
|
|
5862 |
record_unwind_protect (Fset_buffer, Fcurrent_buffer ()); |
record_unwind_protect (Fset_buffer, Fcurrent_buffer ()); |
5863 |
record_unwind_protect (code_convert_region_unwind, Qnil); |
record_unwind_protect (code_convert_region_unwind, Qnil); |
5864 |
GCPRO1 (str); |
/* It is not crucial to specbind this. */ |
5865 |
|
old_deactivate_mark = Vdeactivate_mark; |
5866 |
|
GCPRO2 (str, old_deactivate_mark); |
5867 |
|
|
5868 |
buffer = Fget_buffer_create (build_string (" *code-converting-work*")); |
buffer = Fget_buffer_create (build_string (" *code-converting-work*")); |
5869 |
buf = XBUFFER (buffer); |
buf = XBUFFER (buffer); |
5883 |
buf->enable_multibyte_characters = multibyte ? Qt : Qnil; |
buf->enable_multibyte_characters = multibyte ? Qt : Qnil; |
5884 |
|
|
5885 |
insert_from_string (str, 0, 0, |
insert_from_string (str, 0, 0, |
5886 |
XSTRING (str)->size, STRING_BYTES (XSTRING (str)), 0); |
SCHARS (str), SBYTES (str), 0); |
5887 |
UNGCPRO; |
UNGCPRO; |
5888 |
inhibit_pre_post_conversion = 1; |
inhibit_pre_post_conversion = 1; |
5889 |
if (encodep) |
if (encodep) |
5894 |
call1 (coding->post_read_conversion, make_number (Z - BEG)); |
call1 (coding->post_read_conversion, make_number (Z - BEG)); |
5895 |
} |
} |
5896 |
inhibit_pre_post_conversion = 0; |
inhibit_pre_post_conversion = 0; |
5897 |
|
Vdeactivate_mark = old_deactivate_mark; |
5898 |
str = make_buffer_string (BEG, Z, 1); |
str = make_buffer_string (BEG, Z, 1); |
5899 |
return unbind_to (count, str); |
return unbind_to (count, str); |
5900 |
} |
} |
5916 |
int consumed, consumed_char, produced, produced_char; |
int consumed, consumed_char, produced, produced_char; |
5917 |
|
|
5918 |
from = 0; |
from = 0; |
5919 |
to_byte = STRING_BYTES (XSTRING (str)); |
to_byte = SBYTES (str); |
5920 |
|
|
5921 |
saved_coding_symbol = coding->symbol; |
saved_coding_symbol = coding->symbol; |
5922 |
coding->src_multibyte = STRING_MULTIBYTE (str); |
coding->src_multibyte = STRING_MULTIBYTE (str); |
5926 |
/* See the comments in code_convert_region. */ |
/* See the comments in code_convert_region. */ |
5927 |
if (coding->type == coding_type_undecided) |
if (coding->type == coding_type_undecided) |
5928 |
{ |
{ |
5929 |
detect_coding (coding, XSTRING (str)->data, to_byte); |
detect_coding (coding, SDATA (str), to_byte); |
5930 |
if (coding->type == coding_type_undecided) |
if (coding->type == coding_type_undecided) |
5931 |
{ |
{ |
5932 |
coding->type = coding_type_emacs_mule; |
coding->type = coding_type_emacs_mule; |
5941 |
&& coding->type != coding_type_ccl) |
&& coding->type != coding_type_ccl) |
5942 |
{ |
{ |
5943 |
saved_coding_symbol = coding->symbol; |
saved_coding_symbol = coding->symbol; |
5944 |
detect_eol (coding, XSTRING (str)->data, to_byte); |
detect_eol (coding, SDATA (str), to_byte); |
5945 |
if (coding->eol_type == CODING_EOL_UNDECIDED) |
if (coding->eol_type == CODING_EOL_UNDECIDED) |
5946 |
coding->eol_type = CODING_EOL_LF; |
coding->eol_type = CODING_EOL_LF; |
5947 |
/* We had better recover the original eol format if we |
/* We had better recover the original eol format if we |
5960 |
{ |
{ |
5961 |
/* Decoding routines expect the source text to be unibyte. */ |
/* Decoding routines expect the source text to be unibyte. */ |
5962 |
str = Fstring_as_unibyte (str); |
str = Fstring_as_unibyte (str); |
5963 |
to_byte = STRING_BYTES (XSTRING (str)); |
to_byte = SBYTES (str); |
5964 |
nocopy = 1; |
nocopy = 1; |
5965 |
coding->src_multibyte = 0; |
coding->src_multibyte = 0; |
5966 |
} |
} |
5968 |
/* Try to skip the heading and tailing ASCIIs. */ |
/* Try to skip the heading and tailing ASCIIs. */ |
5969 |
if (require_decoding && coding->type != coding_type_ccl) |
if (require_decoding && coding->type != coding_type_ccl) |
5970 |
{ |
{ |
5971 |
SHRINK_CONVERSION_REGION (&from, &to_byte, coding, XSTRING (str)->data, |
SHRINK_CONVERSION_REGION (&from, &to_byte, coding, SDATA (str), |
5972 |
0); |
0); |
5973 |
if (from == to_byte) |
if (from == to_byte) |
5974 |
require_decoding = 0; |
require_decoding = 0; |
5975 |
shrinked_bytes = from + (STRING_BYTES (XSTRING (str)) - to_byte); |
shrinked_bytes = from + (SBYTES (str) - to_byte); |
5976 |
} |
} |
5977 |
|
|
5978 |
if (!require_decoding) |
if (!require_decoding) |
5979 |
{ |
{ |
5980 |
coding->consumed = STRING_BYTES (XSTRING (str)); |
coding->consumed = SBYTES (str); |
5981 |
coding->consumed_char = XSTRING (str)->size; |
coding->consumed_char = SCHARS (str); |
5982 |
if (coding->dst_multibyte) |
if (coding->dst_multibyte) |
5983 |
{ |
{ |
5984 |
str = Fstring_as_multibyte (str); |
str = Fstring_as_multibyte (str); |
5985 |
nocopy = 1; |
nocopy = 1; |
5986 |
} |
} |
5987 |
coding->produced = STRING_BYTES (XSTRING (str)); |
coding->produced = SBYTES (str); |
5988 |
coding->produced_char = XSTRING (str)->size; |
coding->produced_char = SCHARS (str); |
5989 |
return (nocopy ? str : Fcopy_sequence (str)); |
return (nocopy ? str : Fcopy_sequence (str)); |
5990 |
} |
} |
5991 |
|
|
5997 |
consumed = consumed_char = produced = produced_char = 0; |
consumed = consumed_char = produced = produced_char = 0; |
5998 |
while (1) |
while (1) |
5999 |
{ |
{ |
6000 |
result = decode_coding (coding, XSTRING (str)->data + from + consumed, |
result = decode_coding (coding, SDATA (str) + from + consumed, |
6001 |
buf.data + produced, to_byte - from - consumed, |
buf.data + produced, to_byte - from - consumed, |
6002 |
buf.size - produced); |
buf.size - produced); |
6003 |
consumed += coding->consumed; |
consumed += coding->consumed; |
6066 |
else |
else |
6067 |
newstr = make_uninit_string (produced + shrinked_bytes); |
newstr = make_uninit_string (produced + shrinked_bytes); |
6068 |
if (from > 0) |
if (from > 0) |
6069 |
bcopy (XSTRING (str)->data, XSTRING (newstr)->data, from); |
STRING_COPYIN (newstr, 0, SDATA (str), from); |
6070 |
bcopy (buf.data, XSTRING (newstr)->data + from, produced); |
STRING_COPYIN (newstr, from, buf.data, produced); |
6071 |
if (shrinked_bytes > from) |
if (shrinked_bytes > from) |
6072 |
bcopy (XSTRING (str)->data + to_byte, |
STRING_COPYIN (newstr, from + produced, |
6073 |
XSTRING (newstr)->data + from + produced, |
SDATA (str) + to_byte, |
6074 |
shrinked_bytes - from); |
shrinked_bytes - from); |
6075 |
free_conversion_buffer (&buf); |
free_conversion_buffer (&buf); |
6076 |
|
|
6077 |
if (coding->cmp_data && coding->cmp_data->used) |
if (coding->cmp_data && coding->cmp_data->used) |
6104 |
str = run_pre_post_conversion_on_str (str, coding, 1); |
str = run_pre_post_conversion_on_str (str, coding, 1); |
6105 |
|
|
6106 |
from = 0; |
from = 0; |
6107 |
to = XSTRING (str)->size; |
to = SCHARS (str); |
6108 |
to_byte = STRING_BYTES (XSTRING (str)); |
to_byte = SBYTES (str); |
6109 |
|
|
6110 |
/* Encoding routines determine the multibyteness of the source text |
/* Encoding routines determine the multibyteness of the source text |
6111 |
by coding->src_multibyte. */ |
by coding->src_multibyte. */ |
6113 |
coding->dst_multibyte = 0; |
coding->dst_multibyte = 0; |
6114 |
if (! CODING_REQUIRE_ENCODING (coding)) |
if (! CODING_REQUIRE_ENCODING (coding)) |
6115 |
{ |
{ |
6116 |
coding->consumed = STRING_BYTES (XSTRING (str)); |
coding->consumed = SBYTES (str); |
6117 |
coding->consumed_char = XSTRING (str)->size; |
coding->consumed_char = SCHARS (str); |
6118 |
if (STRING_MULTIBYTE (str)) |
if (STRING_MULTIBYTE (str)) |
6119 |
{ |
{ |
6120 |
str = Fstring_as_unibyte (str); |
str = Fstring_as_unibyte (str); |
6121 |
nocopy = 1; |
nocopy = 1; |
6122 |
} |
} |
6123 |
coding->produced = STRING_BYTES (XSTRING (str)); |
coding->produced = SBYTES (str); |
6124 |
coding->produced_char = XSTRING (str)->size; |
coding->produced_char = SCHARS (str); |
6125 |
return (nocopy ? str : Fcopy_sequence (str)); |
return (nocopy ? str : Fcopy_sequence (str)); |
6126 |
} |
} |
6127 |
|
|
6131 |
/* Try to skip the heading and tailing ASCIIs. */ |
/* Try to skip the heading and tailing ASCIIs. */ |
6132 |
if (coding->type != coding_type_ccl) |
if (coding->type != coding_type_ccl) |
6133 |
{ |
{ |
6134 |
SHRINK_CONVERSION_REGION (&from, &to_byte, coding, XSTRING (str)->data, |
SHRINK_CONVERSION_REGION (&from, &to_byte, coding, SDATA (str), |
6135 |
1); |
1); |
6136 |
if (from == to_byte) |
if (from == to_byte) |
6137 |
return (nocopy ? str : Fcopy_sequence (str)); |
return (nocopy ? str : Fcopy_sequence (str)); |
6138 |
shrinked_bytes = from + (STRING_BYTES (XSTRING (str)) - to_byte); |
shrinked_bytes = from + (SBYTES (str) - to_byte); |
6139 |
} |
} |
6140 |
|
|
6141 |
len = encoding_buffer_size (coding, to_byte - from); |
len = encoding_buffer_size (coding, to_byte - from); |
6144 |
consumed = consumed_char = produced = produced_char = 0; |
consumed = consumed_char = produced = produced_char = 0; |
6145 |
while (1) |
while (1) |
6146 |
{ |
{ |
6147 |
result = encode_coding (coding, XSTRING (str)->data + from + consumed, |
result = encode_coding (coding, SDATA (str) + from + consumed, |
6148 |
buf.data + produced, to_byte - from - consumed, |
buf.data + produced, to_byte - from - consumed, |
6149 |
buf.size - produced); |
buf.size - produced); |
6150 |
consumed += coding->consumed; |
consumed += coding->consumed; |
6166 |
|
|
6167 |
newstr = make_uninit_string (produced + shrinked_bytes); |
newstr = make_uninit_string (produced + shrinked_bytes); |
6168 |
if (from > 0) |
if (from > 0) |
6169 |
bcopy (XSTRING (str)->data, XSTRING (newstr)->data, from); |
STRING_COPYIN (newstr, 0, SDATA (str), from); |
6170 |
bcopy (buf.data, XSTRING (newstr)->data + from, produced); |
STRING_COPYIN (newstr, from, buf.data, produced); |
6171 |
if (shrinked_bytes > from) |
if (shrinked_bytes > from) |
6172 |
bcopy (XSTRING (str)->data + to_byte, |
STRING_COPYIN (newstr, from + produced, |
6173 |
XSTRING (newstr)->data + from + produced, |
SDATA (str) + to_byte, |
6174 |
shrinked_bytes - from); |
shrinked_bytes - from); |
6175 |
|
|
6176 |
free_conversion_buffer (&buf); |
free_conversion_buffer (&buf); |
6177 |
coding_free_composition_data (coding); |
coding_free_composition_data (coding); |
6212 |
val = Fcompleting_read (prompt, Vcoding_system_alist, Qnil, |
val = Fcompleting_read (prompt, Vcoding_system_alist, Qnil, |
6213 |
Qt, Qnil, Qcoding_system_history, Qnil, Qnil); |
Qt, Qnil, Qcoding_system_history, Qnil, Qnil); |
6214 |
} |
} |
6215 |
while (XSTRING (val)->size == 0); |
while (SCHARS (val) == 0); |
6216 |
return (Fintern (val, Qnil)); |
return (Fintern (val, Qnil)); |
6217 |
} |
} |
6218 |
|
|
6228 |
val = Fcompleting_read (prompt, Vcoding_system_alist, Qnil, |
val = Fcompleting_read (prompt, Vcoding_system_alist, Qnil, |
6229 |
Qt, Qnil, Qcoding_system_history, |
Qt, Qnil, Qcoding_system_history, |
6230 |
default_coding_system, Qnil); |
default_coding_system, Qnil); |
6231 |
return (XSTRING (val)->size == 0 ? Qnil : Fintern (val, Qnil)); |
return (SCHARS (val) == 0 ? Qnil : Fintern (val, Qnil)); |
6232 |
} |
} |
6233 |
|
|
6234 |
DEFUN ("check-coding-system", Fcheck_coding_system, Scheck_coding_system, |
DEFUN ("check-coding-system", Fcheck_coding_system, Scheck_coding_system, |
6249 |
|
|
6250 |
Lisp_Object |
Lisp_Object |
6251 |
detect_coding_system (src, src_bytes, highest, multibytep) |
detect_coding_system (src, src_bytes, highest, multibytep) |
6252 |
unsigned char *src; |
const unsigned char *src; |
6253 |
int src_bytes, highest; |
int src_bytes, highest; |
6254 |
int multibytep; |
int multibytep; |
6255 |
{ |
{ |
6312 |
|
|
6313 |
DEFUN ("detect-coding-region", Fdetect_coding_region, Sdetect_coding_region, |
DEFUN ("detect-coding-region", Fdetect_coding_region, Sdetect_coding_region, |
6314 |
2, 3, 0, |
2, 3, 0, |
6315 |
doc: /* Detect coding system of the text in the region between START and END. |
doc: /* Detect how the byte sequence in the region is encoded. |
6316 |
Return a list of possible coding systems ordered by priority. |
Return a list of possible coding systems used on decoding a byte |
6317 |
|
sequence containing the bytes in the region between START and END when |
6318 |
|
the coding system `undecided' is specified. The list is ordered by |
6319 |
|
priority decided in the current language environment. |
6320 |
|
|
6321 |
If only ASCII characters are found, it returns a list of single element |
If only ASCII characters are found, it returns a list of single element |
6322 |
`undecided' or its subsidiary coding system according to a detected |
`undecided' or its subsidiary coding system according to a detected |
6345 |
the detecting source. Then code detectors can handle the tailing |
the detecting source. Then code detectors can handle the tailing |
6346 |
byte sequence more accurately. |
byte sequence more accurately. |
6347 |
|
|
6348 |
Fix me: This is not an perfect solution. It is better that we |
Fix me: This is not a perfect solution. It is better that we |
6349 |
add one more argument, say LAST_BLOCK, to all detect_coding_XXX. |
add one more argument, say LAST_BLOCK, to all detect_coding_XXX. |
6350 |
*/ |
*/ |
6351 |
if (to == Z || (to == GPT && GAP_SIZE > 0)) |
if (to == Z || (to == GPT && GAP_SIZE > 0)) |
6359 |
|
|
6360 |
DEFUN ("detect-coding-string", Fdetect_coding_string, Sdetect_coding_string, |
DEFUN ("detect-coding-string", Fdetect_coding_string, Sdetect_coding_string, |
6361 |
1, 2, 0, |
1, 2, 0, |
6362 |
doc: /* Detect coding system of the text in STRING. |
doc: /* Detect how the byte sequence in STRING is encoded. |
6363 |
Return a list of possible coding systems ordered by priority. |
Return a list of possible coding systems used on decoding a byte |
6364 |
|
sequence containing the bytes in STRING when the coding system |
6365 |
|
`undecided' is specified. The list is ordered by priority decided in |
6366 |
|
the current language environment. |
6367 |
|
|
6368 |
If only ASCII characters are found, it returns a list of single element |
If only ASCII characters are found, it returns a list of single element |
6369 |
`undecided' or its subsidiary coding system according to a detected |
`undecided' or its subsidiary coding system according to a detected |
6376 |
{ |
{ |
6377 |
CHECK_STRING (string); |
CHECK_STRING (string); |
6378 |
|
|
6379 |
return detect_coding_system (XSTRING (string)->data, |
return detect_coding_system (SDATA (string), |
6380 |
/* "+ 1" is to include the anchor byte |
/* "+ 1" is to include the anchor byte |
6381 |
`\0'. With this, code detectors can |
`\0'. With this, code detectors can |
6382 |
handle the tailing bytes more |
handle the tailing bytes more |
6383 |
accurately. */ |
accurately. */ |
6384 |
STRING_BYTES (XSTRING (string)) + 1, |
SBYTES (string) + 1, |
6385 |
!NILP (highest), |
!NILP (highest), |
6386 |
STRING_MULTIBYTE (string)); |
STRING_MULTIBYTE (string)); |
6387 |
} |
} |
6388 |
|
|
|
/* Return an intersection of lists L1 and L2. */ |
|
|
|
|
|
static Lisp_Object |
|
|
intersection (l1, l2) |
|
|
Lisp_Object l1, l2; |
|
|
{ |
|
|
Lisp_Object val = Fcons (Qnil, Qnil), tail; |
|
|
|
|
|
for (tail = val; CONSP (l1); l1 = XCDR (l1)) |
|
|
{ |
|
|
if (!NILP (Fmemq (XCAR (l1), l2))) |
|
|
{ |
|
|
XSETCDR (tail, Fcons (XCAR (l1), Qnil)); |
|
|
tail = XCDR (tail); |
|
|
} |
|
|
} |
|
|
return XCDR (val); |
|
|
} |
|
|
|
|
|
|
|
6389 |
/* Subroutine for Fsafe_coding_systems_region_internal. |
/* Subroutine for Fsafe_coding_systems_region_internal. |
6390 |
|
|
6391 |
Return a list of coding systems that safely encode the multibyte |
Return a list of coding systems that safely encode the multibyte |
6405 |
Lisp_Object safe_codings, work_table; |
Lisp_Object safe_codings, work_table; |
6406 |
int *single_byte_char_found; |
int *single_byte_char_found; |
6407 |
{ |
{ |
6408 |
int c, len, idx; |
int c, len, i; |
6409 |
Lisp_Object val; |
Lisp_Object val, ch; |
6410 |
|
Lisp_Object prev, tail; |
6411 |
|
|
6412 |
while (p < pend) |
while (p < pend) |
6413 |
{ |
{ |
6419 |
if (SINGLE_BYTE_CHAR_P (c)) |
if (SINGLE_BYTE_CHAR_P (c)) |
6420 |
*single_byte_char_found = 1; |
*single_byte_char_found = 1; |
6421 |
if (NILP (safe_codings)) |
if (NILP (safe_codings)) |
6422 |
|
/* Already all coding systems are excluded. */ |
6423 |
continue; |
continue; |
6424 |
/* Check the safe coding systems for C. */ |
/* Check the safe coding systems for C. */ |
6425 |
val = char_table_ref_and_index (work_table, c, &idx); |
ch = make_number (c); |
6426 |
|
val = Faref (work_table, ch); |
6427 |
if (EQ (val, Qt)) |
if (EQ (val, Qt)) |
6428 |
/* This element was already checked. Ignore it. */ |
/* This element was already checked. Ignore it. */ |
6429 |
continue; |
continue; |
6430 |
/* Remember that we checked this element. */ |
/* Remember that we checked this element. */ |
6431 |
CHAR_TABLE_SET (work_table, make_number (idx), Qt); |
Faset (work_table, ch, Qt); |
6432 |
|
|
6433 |
/* If there are some safe coding systems for C and we have |
for (prev = tail = safe_codings; CONSP (tail); tail = XCDR (tail)) |
6434 |
already found the other set of coding systems for the |
{ |
6435 |
different characters, get the intersection of them. */ |
val = XCAR (tail); |
6436 |
if (!EQ (safe_codings, Qt) && !NILP (val)) |
if (NILP (Faref (XCDR (val), ch))) |
6437 |
val = intersection (safe_codings, val); |
{ |
6438 |
safe_codings = val; |
/* Exclued this coding system from SAFE_CODINGS. */ |
6439 |
|
if (EQ (tail, safe_codings)) |
6440 |
|
safe_codings = XCDR (safe_codings); |
6441 |
|
else |
6442 |
|
XSETCDR (prev, XCDR (tail)); |
6443 |
|
} |
6444 |
|
else |
6445 |
|
prev = tail; |
6446 |
|
} |
6447 |
} |
} |
6448 |
return safe_codings; |
return safe_codings; |
6449 |
} |
} |
6450 |
|
|
|
|
|
|
/* Return a list of coding systems that safely encode the text between |
|
|
START and END. If the text contains only ASCII or is unibyte, |
|
|
return t. */ |
|
|
|
|
6451 |
DEFUN ("find-coding-systems-region-internal", |
DEFUN ("find-coding-systems-region-internal", |
6452 |
Ffind_coding_systems_region_internal, |
Ffind_coding_systems_region_internal, |
6453 |
Sfind_coding_systems_region_internal, 2, 2, 0, |
Sfind_coding_systems_region_internal, 2, 2, 0, |
6458 |
Lisp_Object work_table, safe_codings; |
Lisp_Object work_table, safe_codings; |
6459 |
int non_ascii_p = 0; |
int non_ascii_p = 0; |
6460 |
int single_byte_char_found = 0; |
int single_byte_char_found = 0; |
6461 |
unsigned char *p1, *p1end, *p2, *p2end, *p; |
const unsigned char *p1, *p1end, *p2, *p2end, *p; |
6462 |
|
|
6463 |
if (STRINGP (start)) |
if (STRINGP (start)) |
6464 |
{ |
{ |
6465 |
if (!STRING_MULTIBYTE (start)) |
if (!STRING_MULTIBYTE (start)) |
6466 |
return Qt; |
return Qt; |
6467 |
p1 = XSTRING (start)->data, p1end = p1 + STRING_BYTES (XSTRING (start)); |
p1 = SDATA (start), p1end = p1 + SBYTES (start); |
6468 |
p2 = p2end = p1end; |
p2 = p2end = p1end; |
6469 |
if (XSTRING (start)->size != STRING_BYTES (XSTRING (start))) |
if (SCHARS (start) != SBYTES (start)) |
6470 |
non_ascii_p = 1; |
non_ascii_p = 1; |
6471 |
} |
} |
6472 |
else |
else |
6506 |
} |
} |
6507 |
|
|
6508 |
/* The text contains non-ASCII characters. */ |
/* The text contains non-ASCII characters. */ |
6509 |
work_table = Fcopy_sequence (Vchar_coding_system_table); |
|
6510 |
safe_codings = find_safe_codings (p1, p1end, Qt, work_table, |
work_table = Fmake_char_table (Qchar_coding_system, Qnil); |
6511 |
|
safe_codings = Fcopy_sequence (XCDR (Vcoding_system_safe_chars)); |
6512 |
|
|
6513 |
|
safe_codings = find_safe_codings (p1, p1end, safe_codings, work_table, |
6514 |
&single_byte_char_found); |
&single_byte_char_found); |
6515 |
if (p2 < p2end) |
if (p2 < p2end) |
6516 |
safe_codings = find_safe_codings (p2, p2end, safe_codings, work_table, |
safe_codings = find_safe_codings (p2, p2end, safe_codings, work_table, |
6517 |
&single_byte_char_found); |
&single_byte_char_found); |
6518 |
|
if (EQ (safe_codings, XCDR (Vcoding_system_safe_chars))) |
6519 |
|
safe_codings = Qt; |
6520 |
|
else |
6521 |
|
{ |
6522 |
|
/* Turn safe_codings to a list of coding systems... */ |
6523 |
|
Lisp_Object val; |
6524 |
|
|
6525 |
|
if (single_byte_char_found) |
6526 |
|
/* ... and append these for eight-bit chars. */ |
6527 |
|
val = Fcons (Qraw_text, |
6528 |
|
Fcons (Qemacs_mule, Fcons (Qno_conversion, Qnil))); |
6529 |
|
else |
6530 |
|
/* ... and append generic coding systems. */ |
6531 |
|
val = Fcopy_sequence (XCAR (Vcoding_system_safe_chars)); |
6532 |
|
|
6533 |
|
for (; CONSP (safe_codings); safe_codings = XCDR (safe_codings)) |
6534 |
|
val = Fcons (XCAR (XCAR (safe_codings)), val); |
6535 |
|
safe_codings = val; |
6536 |
|
} |
6537 |
|
|
6538 |
if (EQ (safe_codings, Qt)) |
return safe_codings; |
6539 |
; /* Nothing to be done. */ |
} |
6540 |
else if (!single_byte_char_found) |
|
6541 |
|
|
6542 |
|
/* Search from position POS for such characters that are unencodable |
6543 |
|
accoding to SAFE_CHARS, and return a list of their positions. P |
6544 |
|
points where in the memory the character at POS exists. Limit the |
6545 |
|
search at PEND or when Nth unencodable characters are found. |
6546 |
|
|
6547 |
|
If SAFE_CHARS is a char table, an element for an unencodable |
6548 |
|
character is nil. |
6549 |
|
|
6550 |
|
If SAFE_CHARS is nil, all non-ASCII characters are unencodable. |
6551 |
|
|
6552 |
|
Otherwise, SAFE_CHARS is t, and only eight-bit-contrl and |
6553 |
|
eight-bit-graphic characters are unencodable. */ |
6554 |
|
|
6555 |
|
static Lisp_Object |
6556 |
|
unencodable_char_position (safe_chars, pos, p, pend, n) |
6557 |
|
Lisp_Object safe_chars; |
6558 |
|
int pos; |
6559 |
|
unsigned char *p, *pend; |
6560 |
|
int n; |
6561 |
|
{ |
6562 |
|
Lisp_Object pos_list; |
6563 |
|
|
6564 |
|
pos_list = Qnil; |
6565 |
|
while (p < pend) |
6566 |
{ |
{ |
6567 |
/* Append generic coding systems. */ |
int len; |
6568 |
Lisp_Object args[2]; |
int c = STRING_CHAR_AND_LENGTH (p, MAX_MULTIBYTE_LENGTH, len); |
6569 |
args[0] = safe_codings; |
|
6570 |
args[1] = Fchar_table_extra_slot (Vchar_coding_system_table, |
if (c >= 128 |
6571 |
make_number (0)); |
&& (CHAR_TABLE_P (safe_chars) |
6572 |
safe_codings = Fappend (2, args); |
? NILP (CHAR_TABLE_REF (safe_chars, c)) |
6573 |
|
: (NILP (safe_chars) || c < 256))) |
6574 |
|
{ |
6575 |
|
pos_list = Fcons (make_number (pos), pos_list); |
6576 |
|
if (--n <= 0) |
6577 |
|
break; |
6578 |
|
} |
6579 |
|
pos++; |
6580 |
|
p += len; |
6581 |
|
} |
6582 |
|
return Fnreverse (pos_list); |
6583 |
|
} |
6584 |
|
|
6585 |
|
|
6586 |
|
DEFUN ("unencodable-char-position", Funencodable_char_position, |
6587 |
|
Sunencodable_char_position, 3, 5, 0, |
6588 |
|
doc: /* |
6589 |
|
Return position of first un-encodable character in a region. |
6590 |
|
START and END specfiy the region and CODING-SYSTEM specifies the |
6591 |
|
encoding to check. Return nil if CODING-SYSTEM does encode the region. |
6592 |
|
|
6593 |
|
If optional 4th argument COUNT is non-nil, it specifies at most how |
6594 |
|
many un-encodable characters to search. In this case, the value is a |
6595 |
|
list of positions. |
6596 |
|
|
6597 |
|
If optional 5th argument STRING is non-nil, it is a string to search |
6598 |
|
for un-encodable characters. In that case, START and END are indexes |
6599 |
|
to the string. */) |
6600 |
|
(start, end, coding_system, count, string) |
6601 |
|
Lisp_Object start, end, coding_system, count, string; |
6602 |
|
{ |
6603 |
|
int n; |
6604 |
|
Lisp_Object safe_chars; |
6605 |
|
struct coding_system coding; |
6606 |
|
Lisp_Object positions; |
6607 |
|
int from, to; |
6608 |
|
unsigned char *p, *pend; |
6609 |
|
|
6610 |
|
if (NILP (string)) |
6611 |
|
{ |
6612 |
|
validate_region (&start, &end); |
6613 |
|
from = XINT (start); |
6614 |
|
to = XINT (end); |
6615 |
|
if (NILP (current_buffer->enable_multibyte_characters)) |
6616 |
|
return Qnil; |
6617 |
|
p = CHAR_POS_ADDR (from); |
6618 |
|
if (to == GPT) |
6619 |
|
pend = GPT_ADDR; |
6620 |
|
else |
6621 |
|
pend = CHAR_POS_ADDR (to); |
6622 |
} |
} |
6623 |
else |
else |
6624 |
safe_codings = Fcons (Qraw_text, |
{ |
6625 |
Fcons (Qemacs_mule, |
CHECK_STRING (string); |
6626 |
Fcons (Qno_conversion, safe_codings))); |
CHECK_NATNUM (start); |
6627 |
return safe_codings; |
CHECK_NATNUM (end); |
6628 |
|
from = XINT (start); |
6629 |
|
to = XINT (end); |
6630 |
|
if (from > to |
6631 |
|
|| to > SCHARS (string)) |
6632 |
|
args_out_of_range_3 (string, start, end); |
6633 |
|
if (! STRING_MULTIBYTE (string)) |
6634 |
|
return Qnil; |
6635 |
|
p = SDATA (string) + string_char_to_byte (string, from); |
6636 |
|
pend = SDATA (string) + string_char_to_byte (string, to); |
6637 |
|
} |
6638 |
|
|
6639 |
|
setup_coding_system (Fcheck_coding_system (coding_system), &coding); |
6640 |
|
|
6641 |
|
if (NILP (count)) |
6642 |
|
n = 1; |
6643 |
|
else |
6644 |
|
{ |
6645 |
|
CHECK_NATNUM (count); |
6646 |
|
n = XINT (count); |
6647 |
|
} |
6648 |
|
|
6649 |
|
if (coding.type == coding_type_no_conversion |
6650 |
|
|| coding.type == coding_type_raw_text) |
6651 |
|
return Qnil; |
6652 |
|
|
6653 |
|
if (coding.type == coding_type_undecided) |
6654 |
|
safe_chars = Qnil; |
6655 |
|
else |
6656 |
|
safe_chars = coding_safe_chars (coding_system); |
6657 |
|
|
6658 |
|
if (STRINGP (string) |
6659 |
|
|| from >= GPT || to <= GPT) |
6660 |
|
positions = unencodable_char_position (safe_chars, from, p, pend, n); |
6661 |
|
else |
6662 |
|
{ |
6663 |
|
Lisp_Object args[2]; |
6664 |
|
|
6665 |
|
args[0] = unencodable_char_position (safe_chars, from, p, GPT_ADDR, n); |
6666 |
|
n -= XINT (Flength (args[0])); |
6667 |
|
if (n <= 0) |
6668 |
|
positions = args[0]; |
6669 |
|
else |
6670 |
|
{ |
6671 |
|
args[1] = unencodable_char_position (safe_chars, GPT, GAP_END_ADDR, |
6672 |
|
pend, n); |
6673 |
|
positions = Fappend (2, args); |
6674 |
|
} |
6675 |
|
} |
6676 |
|
|
6677 |
|
return (NILP (count) ? Fcar (positions) : positions); |
6678 |
} |
} |
6679 |
|
|
6680 |
|
|
6698 |
return make_number (to - from); |
return make_number (to - from); |
6699 |
|
|
6700 |
if (setup_coding_system (Fcheck_coding_system (coding_system), &coding) < 0) |
if (setup_coding_system (Fcheck_coding_system (coding_system), &coding) < 0) |
6701 |
error ("Invalid coding system: %s", XSTRING (SYMBOL_NAME (coding_system))->data); |
error ("Invalid coding system: %s", SDATA (SYMBOL_NAME (coding_system))); |
6702 |
|
|
6703 |
coding.mode |= CODING_MODE_LAST_BLOCK; |
coding.mode |= CODING_MODE_LAST_BLOCK; |
6704 |
coding.src_multibyte = coding.dst_multibyte |
coding.src_multibyte = coding.dst_multibyte |
6753 |
return (NILP (nocopy) ? Fcopy_sequence (string) : string); |
return (NILP (nocopy) ? Fcopy_sequence (string) : string); |
6754 |
|
|
6755 |
if (setup_coding_system (Fcheck_coding_system (coding_system), &coding) < 0) |
if (setup_coding_system (Fcheck_coding_system (coding_system), &coding) < 0) |
6756 |
error ("Invalid coding system: %s", XSTRING (SYMBOL_NAME (coding_system))->data); |
error ("Invalid coding system: %s", SDATA (SYMBOL_NAME (coding_system))); |
6757 |
|
|
6758 |
coding.mode |= CODING_MODE_LAST_BLOCK; |
coding.mode |= CODING_MODE_LAST_BLOCK; |
6759 |
string = (encodep |
string = (encodep |
6812 |
return string; |
return string; |
6813 |
|
|
6814 |
if (setup_coding_system (Fcheck_coding_system (coding_system), &coding) < 0) |
if (setup_coding_system (Fcheck_coding_system (coding_system), &coding) < 0) |
6815 |
error ("Invalid coding system: %s", XSTRING (SYMBOL_NAME (coding_system))->data); |
error ("Invalid coding system: %s", SDATA (SYMBOL_NAME (coding_system))); |
6816 |
|
|
6817 |
coding.composing = COMPOSITION_DISABLED; |
coding.composing = COMPOSITION_DISABLED; |
6818 |
coding.mode |= CODING_MODE_LAST_BLOCK; |
coding.mode |= CODING_MODE_LAST_BLOCK; |
6940 |
return val; |
return val; |
6941 |
} |
} |
6942 |
|
|
6943 |
DEFUN ("set-terminal-coding-system-internal", |
DEFUN ("set-terminal-coding-system-internal", Fset_terminal_coding_system_internal, |
|
Fset_terminal_coding_system_internal, |
|
6944 |
Sset_terminal_coding_system_internal, 1, 1, 0, |
Sset_terminal_coding_system_internal, 1, 1, 0, |
6945 |
doc: /* Internal use only. */) |
doc: /* Internal use only. */) |
6946 |
(coding_system) |
(coding_system) |
6959 |
return Qnil; |
return Qnil; |
6960 |
} |
} |
6961 |
|
|
6962 |
DEFUN ("set-safe-terminal-coding-system-internal", |
DEFUN ("set-safe-terminal-coding-system-internal", Fset_safe_terminal_coding_system_internal, |
|
Fset_safe_terminal_coding_system_internal, |
|
6963 |
Sset_safe_terminal_coding_system_internal, 1, 1, 0, |
Sset_safe_terminal_coding_system_internal, 1, 1, 0, |
6964 |
doc: /* Internal use only. */) |
doc: /* Internal use only. */) |
6965 |
(coding_system) |
(coding_system) |
6977 |
return Qnil; |
return Qnil; |
6978 |
} |
} |
6979 |
|
|
6980 |
DEFUN ("terminal-coding-system", |
DEFUN ("terminal-coding-system", Fterminal_coding_system, |
6981 |
Fterminal_coding_system, Sterminal_coding_system, 0, 0, 0, |
Sterminal_coding_system, 0, 0, 0, |
6982 |
doc: /* Return coding system specified for terminal output. */) |
doc: /* Return coding system specified for terminal output. */) |
6983 |
() |
() |
6984 |
{ |
{ |
6985 |
return terminal_coding.symbol; |
return terminal_coding.symbol; |
6986 |
} |
} |
6987 |
|
|
6988 |
DEFUN ("set-keyboard-coding-system-internal", |
DEFUN ("set-keyboard-coding-system-internal", Fset_keyboard_coding_system_internal, |
|
Fset_keyboard_coding_system_internal, |
|
6989 |
Sset_keyboard_coding_system_internal, 1, 1, 0, |
Sset_keyboard_coding_system_internal, 1, 1, 0, |
6990 |
doc: /* Internal use only. */) |
doc: /* Internal use only. */) |
6991 |
(coding_system) |
(coding_system) |
6998 |
return Qnil; |
return Qnil; |
6999 |
} |
} |
7000 |
|
|
7001 |
DEFUN ("keyboard-coding-system", |
DEFUN ("keyboard-coding-system", Fkeyboard_coding_system, |
7002 |
Fkeyboard_coding_system, Skeyboard_coding_system, 0, 0, 0, |
Skeyboard_coding_system, 0, 0, 0, |
7003 |
doc: /* Return coding system specified for decoding keyboard input. */) |
doc: /* Return coding system specified for decoding keyboard input. */) |
7004 |
() |
() |
7005 |
{ |
{ |
7054 |
error ("Invalid first argument"); |
error ("Invalid first argument"); |
7055 |
if (nargs < 1 + XINT (target_idx)) |
if (nargs < 1 + XINT (target_idx)) |
7056 |
error ("Too few arguments for operation: %s", |
error ("Too few arguments for operation: %s", |
7057 |
XSTRING (SYMBOL_NAME (operation))->data); |
SDATA (SYMBOL_NAME (operation))); |
7058 |
|
/* For write-region, if the 6th argument (i.e. VISIT, the 5th |
7059 |
|
argument to write-region) is string, it must be treated as a |
7060 |
|
target file name. */ |
7061 |
|
if (EQ (operation, Qwrite_region) |
7062 |
|
&& nargs > 5 |
7063 |
|
&& STRINGP (args[5])) |
7064 |
|
target_idx = make_number (4); |
7065 |
target = args[XINT (target_idx) + 1]; |
target = args[XINT (target_idx) + 1]; |
7066 |
if (!(STRINGP (target) |
if (!(STRINGP (target) |
7067 |
|| (EQ (operation, Qopen_network_stream) && INTEGERP (target)))) |
|| (EQ (operation, Qopen_network_stream) && INTEGERP (target)))) |
7171 |
return Qnil; |
return Qnil; |
7172 |
} |
} |
7173 |
|
|
7174 |
|
DEFUN ("define-coding-system-internal", Fdefine_coding_system_internal, |
7175 |
|
Sdefine_coding_system_internal, 1, 1, 0, |
7176 |
|
doc: /* Register CODING-SYSTEM as a base coding system. |
7177 |
|
This function is internal use only. */) |
7178 |
|
(coding_system) |
7179 |
|
Lisp_Object coding_system; |
7180 |
|
{ |
7181 |
|
Lisp_Object safe_chars, slot; |
7182 |
|
|
7183 |
|
if (NILP (Fcheck_coding_system (coding_system))) |
7184 |
|
Fsignal (Qcoding_system_error, Fcons (coding_system, Qnil)); |
7185 |
|
safe_chars = coding_safe_chars (coding_system); |
7186 |
|
if (! EQ (safe_chars, Qt) && ! CHAR_TABLE_P (safe_chars)) |
7187 |
|
error ("No valid safe-chars property for %s", |
7188 |
|
SDATA (SYMBOL_NAME (coding_system))); |
7189 |
|
if (EQ (safe_chars, Qt)) |
7190 |
|
{ |
7191 |
|
if (NILP (Fmemq (coding_system, XCAR (Vcoding_system_safe_chars)))) |
7192 |
|
XSETCAR (Vcoding_system_safe_chars, |
7193 |
|
Fcons (coding_system, XCAR (Vcoding_system_safe_chars))); |
7194 |
|
} |
7195 |
|
else |
7196 |
|
{ |
7197 |
|
slot = Fassq (coding_system, XCDR (Vcoding_system_safe_chars)); |
7198 |
|
if (NILP (slot)) |
7199 |
|
XSETCDR (Vcoding_system_safe_chars, |
7200 |
|
nconc2 (XCDR (Vcoding_system_safe_chars), |
7201 |
|
Fcons (Fcons (coding_system, safe_chars), Qnil))); |
7202 |
|
else |
7203 |
|
XSETCDR (slot, safe_chars); |
7204 |
|
} |
7205 |
|
return Qnil; |
7206 |
|
} |
7207 |
|
|
7208 |
#endif /* emacs */ |
#endif /* emacs */ |
7209 |
|
|
7210 |
|
|
7358 |
} |
} |
7359 |
} |
} |
7360 |
|
|
7361 |
|
Vcoding_system_safe_chars = Fcons (Qnil, Qnil); |
7362 |
|
staticpro (&Vcoding_system_safe_chars); |
7363 |
|
|
7364 |
Qtranslation_table = intern ("translation-table"); |
Qtranslation_table = intern ("translation-table"); |
7365 |
staticpro (&Qtranslation_table); |
staticpro (&Qtranslation_table); |
7366 |
Fput (Qtranslation_table, Qchar_table_extra_slots, make_number (1)); |
Fput (Qtranslation_table, Qchar_table_extra_slots, make_number (1)); |
7385 |
But don't staticpro it here--that is done in alloc.c. */ |
But don't staticpro it here--that is done in alloc.c. */ |
7386 |
Qchar_table_extra_slots = intern ("char-table-extra-slots"); |
Qchar_table_extra_slots = intern ("char-table-extra-slots"); |
7387 |
Fput (Qsafe_chars, Qchar_table_extra_slots, make_number (0)); |
Fput (Qsafe_chars, Qchar_table_extra_slots, make_number (0)); |
7388 |
Fput (Qchar_coding_system, Qchar_table_extra_slots, make_number (2)); |
Fput (Qchar_coding_system, Qchar_table_extra_slots, make_number (0)); |
7389 |
|
|
7390 |
Qvalid_codes = intern ("valid-codes"); |
Qvalid_codes = intern ("valid-codes"); |
7391 |
staticpro (&Qvalid_codes); |
staticpro (&Qvalid_codes); |
7403 |
defsubr (&Sdetect_coding_region); |
defsubr (&Sdetect_coding_region); |
7404 |
defsubr (&Sdetect_coding_string); |
defsubr (&Sdetect_coding_string); |
7405 |
defsubr (&Sfind_coding_systems_region_internal); |
defsubr (&Sfind_coding_systems_region_internal); |
7406 |
|
defsubr (&Sunencodable_char_position); |
7407 |
defsubr (&Sdecode_coding_region); |
defsubr (&Sdecode_coding_region); |
7408 |
defsubr (&Sencode_coding_region); |
defsubr (&Sencode_coding_region); |
7409 |
defsubr (&Sdecode_coding_string); |
defsubr (&Sdecode_coding_string); |
7420 |
defsubr (&Sfind_operation_coding_system); |
defsubr (&Sfind_operation_coding_system); |
7421 |
defsubr (&Supdate_coding_systems_internal); |
defsubr (&Supdate_coding_systems_internal); |
7422 |
defsubr (&Sset_coding_priority_internal); |
defsubr (&Sset_coding_priority_internal); |
7423 |
|
defsubr (&Sdefine_coding_system_internal); |
7424 |
|
|
7425 |
DEFVAR_LISP ("coding-system-list", &Vcoding_system_list, |
DEFVAR_LISP ("coding-system-list", &Vcoding_system_list, |
7426 |
doc: /* List of coding systems. |
doc: /* List of coding systems. |
7615 |
The default value is `select-safe-coding-system' (which see). */); |
The default value is `select-safe-coding-system' (which see). */); |
7616 |
Vselect_safe_coding_system_function = Qnil; |
Vselect_safe_coding_system_function = Qnil; |
7617 |
|
|
7618 |
DEFVAR_LISP ("char-coding-system-table", &Vchar_coding_system_table, |
DEFVAR_BOOL ("coding-system-require-warning", |
7619 |
doc: /* Char-table containing safe coding systems of each characters. |
&coding_system_require_warning, |
7620 |
Each element doesn't include such generic coding systems that can |
doc: /* Internal use only. |
7621 |
encode any characters. They are in the first extra slot. */); |
If non-nil, on writing a file, `select-safe-coding-system-function' is |
7622 |
Vchar_coding_system_table = Fmake_char_table (Qchar_coding_system, Qnil); |
called even if `coding-system-for-write' is non-nil. The command |
7623 |
|
`universal-coding-system-argument' binds this variable to t temporarily. */); |
7624 |
|
coding_system_require_warning = 0; |
7625 |
|
|
7626 |
|
|
7627 |
DEFVAR_BOOL ("inhibit-iso-escape-detection", |
DEFVAR_BOOL ("inhibit-iso-escape-detection", |
7628 |
&inhibit_iso_escape_detection, |
&inhibit_iso_escape_detection, |
7650 |
to explicitly specify some coding system that doesn't use ISO2022's |
to explicitly specify some coding system that doesn't use ISO2022's |
7651 |
escape sequence (e.g `latin-1') on reading by \\[universal-coding-system-argument]. */); |
escape sequence (e.g `latin-1') on reading by \\[universal-coding-system-argument]. */); |
7652 |
inhibit_iso_escape_detection = 0; |
inhibit_iso_escape_detection = 0; |
7653 |
|
|
7654 |
|
DEFVAR_LISP ("translation-table-for-input", &Vtranslation_table_for_input, |
7655 |
|
doc: /* Char table for translating self-inserting characters. |
7656 |
|
This is applied to the result of input methods, not their input. See also |
7657 |
|
`keyboard-translate-table'. */); |
7658 |
|
Vtranslation_table_for_input = Qnil; |
7659 |
} |
} |
7660 |
|
|
7661 |
char * |
char * |
7672 |
Lisp_Object dec = code_convert_string_norecord (build_string (str), |
Lisp_Object dec = code_convert_string_norecord (build_string (str), |
7673 |
Vlocale_coding_system, |
Vlocale_coding_system, |
7674 |
0); |
0); |
7675 |
str = (char *) XSTRING (dec)->data; |
str = (char *) SDATA (dec); |
7676 |
} |
} |
7677 |
|
|
7678 |
return str; |
return str; |