aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKenichi Handa1998-01-30 11:05:41 +0000
committerKenichi Handa1998-01-30 11:05:41 +0000
commit4031e2bf0af27749dbbcace7ce0edad0bd34bcf7 (patch)
tree841b4beb0aebc5a014fad91802d844db87368020
parent2d0aa229c2c211e77a4e814d24b3672a0df971d0 (diff)
downloademacs-4031e2bf0af27749dbbcace7ce0edad0bd34bcf7.tar.gz
emacs-4031e2bf0af27749dbbcace7ce0edad0bd34bcf7.zip
(ENCODE_ISO_CHARACTER): Pay attention to
CODING_FLAG_ISO_USE_ROMAN and CODING_FLAG_ISO_USE_OLDJIS. (code_convert_region1): New function. (Fdecode_coding_region): Call code_convert_region1. (Fencode_coding_region): Likewise. (code_convert_string1): New function. (Fdecode_coding_string): Call code_convert_string1. (Fencode_coding_string): Likewise. /
-rw-r--r--src/coding.c94
1 files changed, 46 insertions, 48 deletions
diff --git a/src/coding.c b/src/coding.c
index 2417c2558b8..3b9661dfa63 100644
--- a/src/coding.c
+++ b/src/coding.c
@@ -1551,12 +1551,22 @@ decode_coding_iso2022 (coding, source, destination, src_bytes, dst_bytes)
1551 else \ 1551 else \
1552 charset_alt = charset; \ 1552 charset_alt = charset; \
1553 if (CHARSET_DIMENSION (charset_alt) == 1) \ 1553 if (CHARSET_DIMENSION (charset_alt) == 1) \
1554 ENCODE_ISO_CHARACTER_DIMENSION1 (charset_alt, c1); \ 1554 { \
1555 if (charset == CHARSET_ASCII \
1556 && coding->flags & CODING_FLAG_ISO_USE_ROMAN) \
1557 charset_alt = charset_latin_jisx0201; \
1558 ENCODE_ISO_CHARACTER_DIMENSION1 (charset_alt, c1); \
1559 } \
1555 else \ 1560 else \
1556 ENCODE_ISO_CHARACTER_DIMENSION2 (charset_alt, c1, c2); \ 1561 { \
1562 if (charset == charset_jisx0208 \
1563 && coding->flags & CODING_FLAG_ISO_USE_OLDJIS) \
1564 charset_alt = charset_jisx0208_1978; \
1565 ENCODE_ISO_CHARACTER_DIMENSION2 (charset_alt, c1, c2); \
1566 } \
1557 if (! COMPOSING_P (coding->composing)) \ 1567 if (! COMPOSING_P (coding->composing)) \
1558 coding->consumed_char++; \ 1568 coding->consumed_char++; \
1559 } while (0) 1569 } while (0)
1560 1570
1561/* Produce designation and invocation codes at a place pointed by DST 1571/* Produce designation and invocation codes at a place pointed by DST
1562 to use CHARSET. The element `spec.iso2022' of *CODING is updated. 1572 to use CHARSET. The element `spec.iso2022' of *CODING is updated.
@@ -4344,17 +4354,13 @@ highest priority.")
4344 !NILP (highest)); 4354 !NILP (highest));
4345} 4355}
4346 4356
4347DEFUN ("decode-coding-region", Fdecode_coding_region, Sdecode_coding_region, 4357Lisp_Object
4348 3, 3, "r\nzCoding system: ", 4358code_convert_region1 (start, end, coding_system, encodep)
4349 "Decode the current region by specified coding system.\n\
4350When called from a program, takes three arguments:\n\
4351START, END, and CODING-SYSTEM. START and END are buffer positions.\n\
4352Return length of decoded text.")
4353 (start, end, coding_system)
4354 Lisp_Object start, end, coding_system; 4359 Lisp_Object start, end, coding_system;
4360 int encodep;
4355{ 4361{
4356 struct coding_system coding; 4362 struct coding_system coding;
4357 int from, to; 4363 int from, to, len;
4358 4364
4359 CHECK_NUMBER_COERCE_MARKER (start, 0); 4365 CHECK_NUMBER_COERCE_MARKER (start, 0);
4360 CHECK_NUMBER_COERCE_MARKER (end, 1); 4366 CHECK_NUMBER_COERCE_MARKER (end, 1);
@@ -4371,7 +4377,20 @@ Return length of decoded text.")
4371 error ("Invalid coding system: %s", XSYMBOL (coding_system)->name->data); 4377 error ("Invalid coding system: %s", XSYMBOL (coding_system)->name->data);
4372 4378
4373 coding.mode |= CODING_MODE_LAST_BLOCK; 4379 coding.mode |= CODING_MODE_LAST_BLOCK;
4374 return code_convert_region (from, to, &coding, 0, 1); 4380 len = code_convert_region (from, to, &coding, encodep, 1);
4381 return make_number (len);
4382}
4383
4384DEFUN ("decode-coding-region", Fdecode_coding_region, Sdecode_coding_region,
4385 3, 3, "r\nzCoding system: ",
4386 "Decode the current region by specified coding system.\n\
4387When called from a program, takes three arguments:\n\
4388START, END, and CODING-SYSTEM. START and END are buffer positions.\n\
4389Return length of decoded text.")
4390 (start, end, coding_system)
4391 Lisp_Object start, end, coding_system;
4392{
4393 return code_convert_region1 (start, end, coding_system, 0);
4375} 4394}
4376 4395
4377DEFUN ("encode-coding-region", Fencode_coding_region, Sencode_coding_region, 4396DEFUN ("encode-coding-region", Fencode_coding_region, Sencode_coding_region,
@@ -4383,25 +4402,27 @@ Return length of encoded text.")
4383 (start, end, coding_system) 4402 (start, end, coding_system)
4384 Lisp_Object start, end, coding_system; 4403 Lisp_Object start, end, coding_system;
4385{ 4404{
4386 struct coding_system coding; 4405 return code_convert_region1 (start, end, coding_system, 1);
4387 int from, to; 4406}
4388 4407
4389 CHECK_NUMBER_COERCE_MARKER (start, 0); 4408Lisp_Object
4390 CHECK_NUMBER_COERCE_MARKER (end, 1); 4409code_convert_string1 (string, coding_system, nocopy, encodep)
4391 CHECK_SYMBOL (coding_system, 2); 4410 Lisp_Object string, coding_system, nocopy;
4411 int encodep;
4412{
4413 struct coding_system coding;
4392 4414
4393 validate_region (&start, &end); 4415 CHECK_STRING (string, 0);
4394 from = XFASTINT (start); 4416 CHECK_SYMBOL (coding_system, 1);
4395 to = XFASTINT (end);
4396 4417
4397 if (NILP (coding_system)) 4418 if (NILP (coding_system))
4398 return make_number (to - from); 4419 return (NILP (nocopy) ? Fcopy_sequence (string) : string);
4399 4420
4400 if (setup_coding_system (Fcheck_coding_system (coding_system), &coding) < 0) 4421 if (setup_coding_system (Fcheck_coding_system (coding_system), &coding) < 0)
4401 error ("Invalid coding system: %s", XSYMBOL (coding_system)->name->data); 4422 error ("Invalid coding system: %s", XSYMBOL (coding_system)->name->data);
4402 4423
4403 coding.mode |= CODING_MODE_LAST_BLOCK; 4424 coding.mode |= CODING_MODE_LAST_BLOCK;
4404 return code_convert_region (from, to, &coding, 1, 1); 4425 return code_convert_string (string, &coding, encodep, !NILP (nocopy));
4405} 4426}
4406 4427
4407DEFUN ("decode-coding-string", Fdecode_coding_string, Sdecode_coding_string, 4428DEFUN ("decode-coding-string", Fdecode_coding_string, Sdecode_coding_string,
@@ -4412,19 +4433,7 @@ if the decoding operation is trivial.")
4412 (string, coding_system, nocopy) 4433 (string, coding_system, nocopy)
4413 Lisp_Object string, coding_system, nocopy; 4434 Lisp_Object string, coding_system, nocopy;
4414{ 4435{
4415 struct coding_system coding; 4436 return code_convert_string1(string, coding_system, nocopy, 0);
4416
4417 CHECK_STRING (string, 0);
4418 CHECK_SYMBOL (coding_system, 1);
4419
4420 if (NILP (coding_system))
4421 return (NILP (nocopy) ? Fcopy_sequence (string) : string);
4422
4423 if (setup_coding_system (Fcheck_coding_system (coding_system), &coding) < 0)
4424 error ("Invalid coding system: %s", XSYMBOL (coding_system)->name->data);
4425
4426 coding.mode |= CODING_MODE_LAST_BLOCK;
4427 return code_convert_string (string, &coding, 0, !NILP (nocopy));
4428} 4437}
4429 4438
4430DEFUN ("encode-coding-string", Fencode_coding_string, Sencode_coding_string, 4439DEFUN ("encode-coding-string", Fencode_coding_string, Sencode_coding_string,
@@ -4435,20 +4444,9 @@ if the encoding operation is trivial.")
4435 (string, coding_system, nocopy) 4444 (string, coding_system, nocopy)
4436 Lisp_Object string, coding_system, nocopy; 4445 Lisp_Object string, coding_system, nocopy;
4437{ 4446{
4438 struct coding_system coding; 4447 return code_convert_string1(string, coding_system, nocopy, 1);
4439
4440 CHECK_STRING (string, 0);
4441 CHECK_SYMBOL (coding_system, 1);
4442
4443 if (NILP (coding_system))
4444 return (NILP (nocopy) ? Fcopy_sequence (string) : string);
4445
4446 if (setup_coding_system (Fcheck_coding_system (coding_system), &coding) < 0)
4447 error ("Invalid coding system: %s", XSYMBOL (coding_system)->name->data);
4448
4449 coding.mode |= CODING_MODE_LAST_BLOCK;
4450 return code_convert_string (string, &coding, 1, !NILP (nocopy));
4451} 4448}
4449
4452 4450
4453DEFUN ("decode-sjis-char", Fdecode_sjis_char, Sdecode_sjis_char, 1, 1, 0, 4451DEFUN ("decode-sjis-char", Fdecode_sjis_char, Sdecode_sjis_char, 1, 1, 0,
4454 "Decode a JISX0208 character of shift-jis encoding.\n\ 4452 "Decode a JISX0208 character of shift-jis encoding.\n\