diff options
| author | Richard M. Stallman | 1998-01-19 19:45:53 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1998-01-19 19:45:53 +0000 |
| commit | 3a73fa5d33fde1799cf990527d2a103c859df182 (patch) | |
| tree | 64b7a335924c9695c71a7118a16c259f5e1d62fe /src | |
| parent | 3ac81adbcc0cdea2ef8a731176fce6ece1762ba9 (diff) | |
| download | emacs-3a73fa5d33fde1799cf990527d2a103c859df182.tar.gz emacs-3a73fa5d33fde1799cf990527d2a103c859df182.zip | |
(code_convert_region): Always count chars inserted
in accord with value of enable-multilibyte-characters.
(Fcoding_system_p): Doc fix.
(Fcheck_coding_system): Doc fix.
(Fterminal_coding_system): Doc fix.
(Fkeyboard_coding_system): Doc fix.
Diffstat (limited to 'src')
| -rw-r--r-- | src/coding.c | 123 |
1 files changed, 62 insertions, 61 deletions
diff --git a/src/coding.c b/src/coding.c index ff4f248bb02..fd585a1987c 100644 --- a/src/coding.c +++ b/src/coding.c | |||
| @@ -3125,7 +3125,8 @@ get_conversion_buffer (size) | |||
| 3125 | 3125 | ||
| 3126 | DEFUN ("coding-system-p", Fcoding_system_p, Scoding_system_p, 1, 1, 0, | 3126 | DEFUN ("coding-system-p", Fcoding_system_p, Scoding_system_p, 1, 1, 0, |
| 3127 | "Return t if OBJECT is nil or a coding-system.\n\ | 3127 | "Return t if OBJECT is nil or a coding-system.\n\ |
| 3128 | See document of make-coding-system for coding-system object.") | 3128 | See the documentation of `make-coding-system' for information\n\ |
| 3129 | about coding-system objects.") | ||
| 3129 | (obj) | 3130 | (obj) |
| 3130 | Lisp_Object obj; | 3131 | Lisp_Object obj; |
| 3131 | { | 3132 | { |
| @@ -3173,8 +3174,8 @@ If the user enters null input, return second argument DEFAULT-CODING-SYSTEM.") | |||
| 3173 | DEFUN ("check-coding-system", Fcheck_coding_system, Scheck_coding_system, | 3174 | DEFUN ("check-coding-system", Fcheck_coding_system, Scheck_coding_system, |
| 3174 | 1, 1, 0, | 3175 | 1, 1, 0, |
| 3175 | "Check validity of CODING-SYSTEM.\n\ | 3176 | "Check validity of CODING-SYSTEM.\n\ |
| 3176 | If valid, return CODING-SYSTEM, else `coding-system-error' is signaled.\n\ | 3177 | If valid, return CODING-SYSTEM, else signal a `coding-system-error' error.\n\ |
| 3177 | CODING-SYSTEM is valid if it is a symbol and has \"coding-system\" property.\n\ | 3178 | It is valid if it is a symbol with a non-nil `coding-system' property.\n\ |
| 3178 | The value of property should be a vector of length 5.") | 3179 | The value of property should be a vector of length 5.") |
| 3179 | (coding_system) | 3180 | (coding_system) |
| 3180 | Lisp_Object coding_system; | 3181 | Lisp_Object coding_system; |
| @@ -3185,7 +3186,7 @@ The value of property should be a vector of length 5.") | |||
| 3185 | while (1) | 3186 | while (1) |
| 3186 | Fsignal (Qcoding_system_error, Fcons (coding_system, Qnil)); | 3187 | Fsignal (Qcoding_system_error, Fcons (coding_system, Qnil)); |
| 3187 | } | 3188 | } |
| 3188 | 3189 | ||
| 3189 | DEFUN ("detect-coding-region", Fdetect_coding_region, Sdetect_coding_region, | 3190 | DEFUN ("detect-coding-region", Fdetect_coding_region, Sdetect_coding_region, |
| 3190 | 2, 2, 0, | 3191 | 2, 2, 0, |
| 3191 | "Detect coding system of the text in the region between START and END.\n\ | 3192 | "Detect coding system of the text in the region between START and END.\n\ |
| @@ -3276,7 +3277,7 @@ If only ASCII characters are found, it returns `undecided'\n\ | |||
| 3276 | 3277 | ||
| 3277 | return val; | 3278 | return val; |
| 3278 | } | 3279 | } |
| 3279 | 3280 | ||
| 3280 | /* Scan text in the region between *BEGP and *ENDP, skip characters | 3281 | /* Scan text in the region between *BEGP and *ENDP, skip characters |
| 3281 | which we never have to encode to (iff ENCODEP is 1) or decode from | 3282 | which we never have to encode to (iff ENCODEP is 1) or decode from |
| 3282 | coding system CODING at the head and tail, then set BEGP and ENDP | 3283 | coding system CODING at the head and tail, then set BEGP and ENDP |
| @@ -3383,7 +3384,7 @@ shrink_conversion_area (begp, endp, coding, encodep) | |||
| 3383 | *endp = end_addr; | 3384 | *endp = end_addr; |
| 3384 | return; | 3385 | return; |
| 3385 | } | 3386 | } |
| 3386 | 3387 | ||
| 3387 | /* Encode into or decode from (according to ENCODEP) coding system CODING | 3388 | /* Encode into or decode from (according to ENCODEP) coding system CODING |
| 3388 | the text between char positions B and E. */ | 3389 | the text between char positions B and E. */ |
| 3389 | 3390 | ||
| @@ -3467,11 +3468,11 @@ code_convert_region (b, e, coding, encodep) | |||
| 3467 | 3468 | ||
| 3468 | TEMP_SET_PT_BOTH (shrunk_beg, shrunk_beg_byte); | 3469 | TEMP_SET_PT_BOTH (shrunk_beg, shrunk_beg_byte); |
| 3469 | 3470 | ||
| 3470 | if (encodep) | 3471 | /* We let the number of characters in the result |
| 3471 | /* If we just encoded, treat the result as single-byte. */ | 3472 | be computed in accord with enable-multilibyte-characters |
| 3472 | insert_1_both (buf, produced, produced, 0, 1, 0); | 3473 | even when encoding. Otherwise the buffer contents |
| 3473 | else | 3474 | will be inconsistent. */ |
| 3474 | insert (buf, produced); | 3475 | insert (buf, produced); |
| 3475 | 3476 | ||
| 3476 | del_range_byte (PT_BYTE, PT_BYTE + shrunk_len_byte, 1); | 3477 | del_range_byte (PT_BYTE, PT_BYTE + shrunk_len_byte, 1); |
| 3477 | 3478 | ||
| @@ -3520,6 +3521,52 @@ code_convert_region (b, e, coding, encodep) | |||
| 3520 | return make_number (len); | 3521 | return make_number (len); |
| 3521 | } | 3522 | } |
| 3522 | 3523 | ||
| 3524 | DEFUN ("decode-coding-region", Fdecode_coding_region, Sdecode_coding_region, | ||
| 3525 | 3, 3, "r\nzCoding system: ", | ||
| 3526 | "Decode current region by specified coding system.\n\ | ||
| 3527 | When called from a program, takes three arguments:\n\ | ||
| 3528 | START, END, and CODING-SYSTEM. START END are buffer positions.\n\ | ||
| 3529 | Return length of decoded text.") | ||
| 3530 | (b, e, coding_system) | ||
| 3531 | Lisp_Object b, e, coding_system; | ||
| 3532 | { | ||
| 3533 | struct coding_system coding; | ||
| 3534 | |||
| 3535 | CHECK_NUMBER_COERCE_MARKER (b, 0); | ||
| 3536 | CHECK_NUMBER_COERCE_MARKER (e, 1); | ||
| 3537 | CHECK_SYMBOL (coding_system, 2); | ||
| 3538 | |||
| 3539 | if (NILP (coding_system)) | ||
| 3540 | return make_number (XFASTINT (e) - XFASTINT (b)); | ||
| 3541 | if (setup_coding_system (Fcheck_coding_system (coding_system), &coding) < 0) | ||
| 3542 | error ("Invalid coding-system: %s", XSYMBOL (coding_system)->name->data); | ||
| 3543 | |||
| 3544 | return code_convert_region (b, e, &coding, 0); | ||
| 3545 | } | ||
| 3546 | |||
| 3547 | DEFUN ("encode-coding-region", Fencode_coding_region, Sencode_coding_region, | ||
| 3548 | 3, 3, "r\nzCoding system: ", | ||
| 3549 | "Encode current region by specified coding system.\n\ | ||
| 3550 | When called from a program, takes three arguments:\n\ | ||
| 3551 | START, END, and CODING-SYSTEM. START END are buffer positions.\n\ | ||
| 3552 | Return length of encoded text.") | ||
| 3553 | (b, e, coding_system) | ||
| 3554 | Lisp_Object b, e, coding_system; | ||
| 3555 | { | ||
| 3556 | struct coding_system coding; | ||
| 3557 | |||
| 3558 | CHECK_NUMBER_COERCE_MARKER (b, 0); | ||
| 3559 | CHECK_NUMBER_COERCE_MARKER (e, 1); | ||
| 3560 | CHECK_SYMBOL (coding_system, 2); | ||
| 3561 | |||
| 3562 | if (NILP (coding_system)) | ||
| 3563 | return make_number (XFASTINT (e) - XFASTINT (b)); | ||
| 3564 | if (setup_coding_system (Fcheck_coding_system (coding_system), &coding) < 0) | ||
| 3565 | error ("Invalid coding-system: %s", XSYMBOL (coding_system)->name->data); | ||
| 3566 | |||
| 3567 | return code_convert_region (b, e, &coding, 1); | ||
| 3568 | } | ||
| 3569 | |||
| 3523 | /* Encode or decode (according to ENCODEP) the text of string STR | 3570 | /* Encode or decode (according to ENCODEP) the text of string STR |
| 3524 | using coding CODING. If NOCOPY is nil, we never return STR | 3571 | using coding CODING. If NOCOPY is nil, we never return STR |
| 3525 | itself, but always a copy. If NOCOPY is non-nil, we return STR | 3572 | itself, but always a copy. If NOCOPY is non-nil, we return STR |
| @@ -3601,52 +3648,6 @@ code_convert_string (str, coding, encodep, nocopy) | |||
| 3601 | return make_string (buf, head_skip + produced + tail_skip); | 3648 | return make_string (buf, head_skip + produced + tail_skip); |
| 3602 | } | 3649 | } |
| 3603 | 3650 | ||
| 3604 | DEFUN ("decode-coding-region", Fdecode_coding_region, Sdecode_coding_region, | ||
| 3605 | 3, 3, "r\nzCoding system: ", | ||
| 3606 | "Decode current region by specified coding system.\n\ | ||
| 3607 | When called from a program, takes three arguments:\n\ | ||
| 3608 | START, END, and CODING-SYSTEM. START END are buffer positions.\n\ | ||
| 3609 | Return length of decoded text.") | ||
| 3610 | (b, e, coding_system) | ||
| 3611 | Lisp_Object b, e, coding_system; | ||
| 3612 | { | ||
| 3613 | struct coding_system coding; | ||
| 3614 | |||
| 3615 | CHECK_NUMBER_COERCE_MARKER (b, 0); | ||
| 3616 | CHECK_NUMBER_COERCE_MARKER (e, 1); | ||
| 3617 | CHECK_SYMBOL (coding_system, 2); | ||
| 3618 | |||
| 3619 | if (NILP (coding_system)) | ||
| 3620 | return make_number (XFASTINT (e) - XFASTINT (b)); | ||
| 3621 | if (setup_coding_system (Fcheck_coding_system (coding_system), &coding) < 0) | ||
| 3622 | error ("Invalid coding-system: %s", XSYMBOL (coding_system)->name->data); | ||
| 3623 | |||
| 3624 | return code_convert_region (b, e, &coding, 0); | ||
| 3625 | } | ||
| 3626 | |||
| 3627 | DEFUN ("encode-coding-region", Fencode_coding_region, Sencode_coding_region, | ||
| 3628 | 3, 3, "r\nzCoding system: ", | ||
| 3629 | "Encode current region by specified coding system.\n\ | ||
| 3630 | When called from a program, takes three arguments:\n\ | ||
| 3631 | START, END, and CODING-SYSTEM. START END are buffer positions.\n\ | ||
| 3632 | Return length of encoded text.") | ||
| 3633 | (b, e, coding_system) | ||
| 3634 | Lisp_Object b, e, coding_system; | ||
| 3635 | { | ||
| 3636 | struct coding_system coding; | ||
| 3637 | |||
| 3638 | CHECK_NUMBER_COERCE_MARKER (b, 0); | ||
| 3639 | CHECK_NUMBER_COERCE_MARKER (e, 1); | ||
| 3640 | CHECK_SYMBOL (coding_system, 2); | ||
| 3641 | |||
| 3642 | if (NILP (coding_system)) | ||
| 3643 | return make_number (XFASTINT (e) - XFASTINT (b)); | ||
| 3644 | if (setup_coding_system (Fcheck_coding_system (coding_system), &coding) < 0) | ||
| 3645 | error ("Invalid coding-system: %s", XSYMBOL (coding_system)->name->data); | ||
| 3646 | |||
| 3647 | return code_convert_region (b, e, &coding, 1); | ||
| 3648 | } | ||
| 3649 | |||
| 3650 | DEFUN ("decode-coding-string", Fdecode_coding_string, Sdecode_coding_string, | 3651 | DEFUN ("decode-coding-string", Fdecode_coding_string, Sdecode_coding_string, |
| 3651 | 2, 3, 0, | 3652 | 2, 3, 0, |
| 3652 | "Decode STRING which is encoded in CODING-SYSTEM, and return the result.\n\ | 3653 | "Decode STRING which is encoded in CODING-SYSTEM, and return the result.\n\ |
| @@ -3688,7 +3689,7 @@ if the encoding operation is trivial.") | |||
| 3688 | 3689 | ||
| 3689 | return code_convert_string (string, &coding, 1, nocopy); | 3690 | return code_convert_string (string, &coding, 1, nocopy); |
| 3690 | } | 3691 | } |
| 3691 | 3692 | ||
| 3692 | DEFUN ("decode-sjis-char", Fdecode_sjis_char, Sdecode_sjis_char, 1, 1, 0, | 3693 | DEFUN ("decode-sjis-char", Fdecode_sjis_char, Sdecode_sjis_char, 1, 1, 0, |
| 3693 | "Decode a JISX0208 character of shift-jis encoding.\n\ | 3694 | "Decode a JISX0208 character of shift-jis encoding.\n\ |
| 3694 | CODE is the character code in SJIS.\n\ | 3695 | CODE is the character code in SJIS.\n\ |
| @@ -3765,7 +3766,7 @@ Return the corresponding character code in Big5.") | |||
| 3765 | XSETFASTINT (val, 0); | 3766 | XSETFASTINT (val, 0); |
| 3766 | return val; | 3767 | return val; |
| 3767 | } | 3768 | } |
| 3768 | 3769 | ||
| 3769 | DEFUN ("set-terminal-coding-system-internal", | 3770 | DEFUN ("set-terminal-coding-system-internal", |
| 3770 | Fset_terminal_coding_system_internal, | 3771 | Fset_terminal_coding_system_internal, |
| 3771 | Sset_terminal_coding_system_internal, 1, 1, 0, "") | 3772 | Sset_terminal_coding_system_internal, 1, 1, 0, "") |
| @@ -3794,7 +3795,7 @@ DEFUN ("set-safe-terminal-coding-system-internal", | |||
| 3794 | 3795 | ||
| 3795 | DEFUN ("terminal-coding-system", | 3796 | DEFUN ("terminal-coding-system", |
| 3796 | Fterminal_coding_system, Sterminal_coding_system, 0, 0, 0, | 3797 | Fterminal_coding_system, Sterminal_coding_system, 0, 0, 0, |
| 3797 | "Return coding-system of your terminal.") | 3798 | "Return coding system specified for terminal output.") |
| 3798 | () | 3799 | () |
| 3799 | { | 3800 | { |
| 3800 | return terminal_coding.symbol; | 3801 | return terminal_coding.symbol; |
| @@ -3813,7 +3814,7 @@ DEFUN ("set-keyboard-coding-system-internal", | |||
| 3813 | 3814 | ||
| 3814 | DEFUN ("keyboard-coding-system", | 3815 | DEFUN ("keyboard-coding-system", |
| 3815 | Fkeyboard_coding_system, Skeyboard_coding_system, 0, 0, 0, | 3816 | Fkeyboard_coding_system, Skeyboard_coding_system, 0, 0, 0, |
| 3816 | "Return coding-system of what is sent from terminal keyboard.") | 3817 | "Return coding system specified for decoding keyboard input.") |
| 3817 | () | 3818 | () |
| 3818 | { | 3819 | { |
| 3819 | return keyboard_coding.symbol; | 3820 | return keyboard_coding.symbol; |