diff options
| author | Kenichi Handa | 2004-12-06 11:34:00 +0000 |
|---|---|---|
| committer | Kenichi Handa | 2004-12-06 11:34:00 +0000 |
| commit | eb3d9ec7821d76f1e71409cc1ed5f5ba2e212045 (patch) | |
| tree | f46981e4ef6494312aa18d395d50a42d7d0ee6da /src | |
| parent | 08588bfa5465b1707ef6f70d312952a4437edcf8 (diff) | |
| download | emacs-eb3d9ec7821d76f1e71409cc1ed5f5ba2e212045.tar.gz emacs-eb3d9ec7821d76f1e71409cc1ed5f5ba2e212045.zip | |
(Ftranslate_region_internal): Don't convert unibyte
string to multibyte (sync to HEAD).
Diffstat (limited to 'src')
| -rw-r--r-- | src/editfns.c | 70 |
1 files changed, 40 insertions, 30 deletions
diff --git a/src/editfns.c b/src/editfns.c index 0917fadb500..2adc43e3a04 100644 --- a/src/editfns.c +++ b/src/editfns.c | |||
| @@ -2884,16 +2884,15 @@ It returns the number of characters changed. */) | |||
| 2884 | { | 2884 | { |
| 2885 | if (! EQ (XCHAR_TABLE (table)->purpose, Qtranslation_table)) | 2885 | if (! EQ (XCHAR_TABLE (table)->purpose, Qtranslation_table)) |
| 2886 | error ("Not a translation table"); | 2886 | error ("Not a translation table"); |
| 2887 | size = MAX_CHAR; | ||
| 2887 | tt = NULL; | 2888 | tt = NULL; |
| 2888 | } | 2889 | } |
| 2889 | else | 2890 | else |
| 2890 | { | 2891 | { |
| 2891 | CHECK_STRING (table); | 2892 | CHECK_STRING (table); |
| 2892 | 2893 | ||
| 2893 | if (multibyte != (SCHARS (table) < SBYTES (table))) | 2894 | if (! multibyte && (SCHARS (table) < SBYTES (table))) |
| 2894 | table = (multibyte | 2895 | table = string_make_unibyte (table); |
| 2895 | ? string_make_multibyte (table) | ||
| 2896 | : string_make_unibyte (table)); | ||
| 2897 | string_multibyte = SCHARS (table) < SBYTES (table); | 2896 | string_multibyte = SCHARS (table) < SBYTES (table); |
| 2898 | size = SBYTES (table); | 2897 | size = SBYTES (table); |
| 2899 | tt = SDATA (table); | 2898 | tt = SDATA (table); |
| @@ -2914,45 +2913,56 @@ It returns the number of characters changed. */) | |||
| 2914 | Lisp_Object val; | 2913 | Lisp_Object val; |
| 2915 | 2914 | ||
| 2916 | if (multibyte) | 2915 | if (multibyte) |
| 2917 | nc = oc = STRING_CHAR_AND_LENGTH (p, 0, len); | 2916 | oc = STRING_CHAR_AND_LENGTH (p, MAX_MULTIBYTE_LENGTH, len); |
| 2918 | else | 2917 | else |
| 2919 | nc = oc = *p, len = 1; | 2918 | oc = *p, len = 1; |
| 2920 | if (tt) | 2919 | if (oc < size) |
| 2921 | { | 2920 | { |
| 2922 | if (oc < size) | 2921 | if (tt) |
| 2923 | { | 2922 | { |
| 2924 | if (string_multibyte) | 2923 | if (string_multibyte) |
| 2925 | { | 2924 | { |
| 2926 | str = tt + string_char_to_byte (table, oc); | 2925 | str = tt + string_char_to_byte (table, oc); |
| 2927 | nc = STRING_CHAR_AND_LENGTH (str, 0, str_len); | 2926 | nc = STRING_CHAR_AND_LENGTH (str, MAX_MULTIBYTE_LENGTH, |
| 2927 | str_len); | ||
| 2928 | } | 2928 | } |
| 2929 | else | 2929 | else |
| 2930 | { | 2930 | { |
| 2931 | str = tt + oc; | 2931 | nc = tt[oc]; |
| 2932 | nc = tt[oc], str_len = 1; | 2932 | if (! ASCII_BYTE_P (nc) && multibyte) |
| 2933 | { | ||
| 2934 | str_len = BYTE8_STRING (nc, buf); | ||
| 2935 | str = buf; | ||
| 2936 | } | ||
| 2937 | else | ||
| 2938 | { | ||
| 2939 | str_len = 1; | ||
| 2940 | str = tt + oc; | ||
| 2941 | } | ||
| 2933 | } | 2942 | } |
| 2934 | } | 2943 | } |
| 2935 | } | 2944 | else |
| 2936 | else | ||
| 2937 | { | ||
| 2938 | val = CHAR_TABLE_REF (table, oc); | ||
| 2939 | if (CHARACTERP (val)) | ||
| 2940 | { | ||
| 2941 | nc = XFASTINT (val); | ||
| 2942 | str_len = CHAR_STRING (nc, buf); | ||
| 2943 | str = buf; | ||
| 2944 | } | ||
| 2945 | else if (VECTORP (val) || (CONSP (val))) | ||
| 2946 | { | 2945 | { |
| 2947 | /* VAL is [TO_CHAR ...] or (([FROM-CHAR ...] . TO) ...) | 2946 | int c; |
| 2948 | where TO is TO-CHAR or [TO-CHAR ...]. */ | 2947 | |
| 2949 | nc = -1; | 2948 | nc = oc; |
| 2949 | val = CHAR_TABLE_REF (table, oc); | ||
| 2950 | if (CHARACTERP (val) | ||
| 2951 | && (c = XINT (val), CHAR_VALID_P (c, 0))) | ||
| 2952 | { | ||
| 2953 | nc = c; | ||
| 2954 | str_len = CHAR_STRING (nc, buf); | ||
| 2955 | str = buf; | ||
| 2956 | } | ||
| 2957 | else if (VECTORP (val) || (CONSP (val))) | ||
| 2958 | { | ||
| 2959 | /* VAL is [TO_CHAR ...] or (([FROM-CHAR ...] . TO) ...) | ||
| 2960 | where TO is TO-CHAR or [TO-CHAR ...]. */ | ||
| 2961 | nc = -1; | ||
| 2962 | } | ||
| 2950 | } | 2963 | } |
| 2951 | } | ||
| 2952 | 2964 | ||
| 2953 | if (nc != oc) | 2965 | if (nc != oc && nc >= 0) |
| 2954 | { | ||
| 2955 | if (nc >= 0) | ||
| 2956 | { | 2966 | { |
| 2957 | /* Simple one char to one char translation. */ | 2967 | /* Simple one char to one char translation. */ |
| 2958 | if (len != str_len) | 2968 | if (len != str_len) |
| @@ -2975,7 +2985,7 @@ It returns the number of characters changed. */) | |||
| 2975 | } | 2985 | } |
| 2976 | ++cnt; | 2986 | ++cnt; |
| 2977 | } | 2987 | } |
| 2978 | else | 2988 | else if (nc < 0) |
| 2979 | { | 2989 | { |
| 2980 | Lisp_Object string; | 2990 | Lisp_Object string; |
| 2981 | 2991 | ||