diff options
| author | Kenichi Handa | 1999-09-03 01:28:42 +0000 |
|---|---|---|
| committer | Kenichi Handa | 1999-09-03 01:28:42 +0000 |
| commit | e50d9192e8e44fcb053934347636d05a08d67a24 (patch) | |
| tree | 7b4a6f11a17cb51f0ea82a1f23ea15574bb79c2b /src | |
| parent | 197516c20d6a23ba998c657139026b2545c968d9 (diff) | |
| download | emacs-e50d9192e8e44fcb053934347636d05a08d67a24.tar.gz emacs-e50d9192e8e44fcb053934347636d05a08d67a24.zip | |
(count_combining): Use the macro PARSE_MULTIBYTE_SEQ.
(string_char_to_byte): Likewise.
(string_byte_to_char): Likewise.
Diffstat (limited to 'src')
| -rw-r--r-- | src/fns.c | 43 |
1 files changed, 27 insertions, 16 deletions
| @@ -526,16 +526,15 @@ count_combining (str, len, i) | |||
| 526 | unsigned char *str; | 526 | unsigned char *str; |
| 527 | int len, i; | 527 | int len, i; |
| 528 | { | 528 | { |
| 529 | int j = i - 1; | 529 | int j = i - 1, bytes; |
| 530 | 530 | ||
| 531 | if (i == 0 || i == len || CHAR_HEAD_P (str[i])) | 531 | if (i == 0 || i == len || CHAR_HEAD_P (str[i])) |
| 532 | return 0; | 532 | return 0; |
| 533 | while (j >= 0 && !CHAR_HEAD_P (str[j])) j--; | 533 | while (j >= 0 && !CHAR_HEAD_P (str[j])) j--; |
| 534 | if (j < 0 || ! BASE_LEADING_CODE_P (str[j])) | 534 | if (j < 0 || ! BASE_LEADING_CODE_P (str[j])) |
| 535 | return 0; | 535 | return 0; |
| 536 | j = i + 1; | 536 | PARSE_MULTIBYTE_SEQ (str + j, len - j, bytes); |
| 537 | while (j < len && ! CHAR_HEAD_P (str[j])) j++; | 537 | return (bytes <= i - j ? 0 : bytes - (i - j)); |
| 538 | return j - i; | ||
| 539 | } | 538 | } |
| 540 | 539 | ||
| 541 | /* This structure holds information of an argument of `concat' that is | 540 | /* This structure holds information of an argument of `concat' that is |
| @@ -898,13 +897,19 @@ string_char_to_byte (string, char_index) | |||
| 898 | { | 897 | { |
| 899 | while (best_above > char_index) | 898 | while (best_above > char_index) |
| 900 | { | 899 | { |
| 901 | int best_above_byte_saved = --best_above_byte; | 900 | unsigned char *pend = XSTRING (string)->data + best_above_byte; |
| 902 | 901 | unsigned char *pbeg = pend - best_above_byte; | |
| 903 | while (best_above_byte > 0 | 902 | unsigned char *p = pend - 1; |
| 904 | && !CHAR_HEAD_P (XSTRING (string)->data[best_above_byte])) | 903 | int bytes; |
| 904 | |||
| 905 | while (p > pbeg && !CHAR_HEAD_P (*p)) p--; | ||
| 906 | PARSE_MULTIBYTE_SEQ (p, pend - p, bytes); | ||
| 907 | if (bytes == pend - p) | ||
| 908 | best_above_byte -= bytes; | ||
| 909 | else if (bytes > pend - p) | ||
| 910 | best_above_byte -= (pend - p); | ||
| 911 | else | ||
| 905 | best_above_byte--; | 912 | best_above_byte--; |
| 906 | if (!BASE_LEADING_CODE_P (XSTRING (string)->data[best_above_byte])) | ||
| 907 | best_above_byte = best_above_byte_saved; | ||
| 908 | best_above--; | 913 | best_above--; |
| 909 | } | 914 | } |
| 910 | i = best_above; | 915 | i = best_above; |
| @@ -964,13 +969,19 @@ string_byte_to_char (string, byte_index) | |||
| 964 | { | 969 | { |
| 965 | while (best_above_byte > byte_index) | 970 | while (best_above_byte > byte_index) |
| 966 | { | 971 | { |
| 967 | int best_above_byte_saved = --best_above_byte; | 972 | unsigned char *pend = XSTRING (string)->data + best_above_byte; |
| 968 | 973 | unsigned char *pbeg = pend - best_above_byte; | |
| 969 | while (best_above_byte > 0 | 974 | unsigned char *p = pend - 1; |
| 970 | && !CHAR_HEAD_P (XSTRING (string)->data[best_above_byte])) | 975 | int bytes; |
| 976 | |||
| 977 | while (p > pbeg && !CHAR_HEAD_P (*p)) p--; | ||
| 978 | PARSE_MULTIBYTE_SEQ (p, pend - p, bytes); | ||
| 979 | if (bytes == pend - p) | ||
| 980 | best_above_byte -= bytes; | ||
| 981 | else if (bytes > pend - p) | ||
| 982 | best_above_byte -= (pend - p); | ||
| 983 | else | ||
| 971 | best_above_byte--; | 984 | best_above_byte--; |
| 972 | if (!BASE_LEADING_CODE_P (XSTRING (string)->data[best_above_byte])) | ||
| 973 | best_above_byte = best_above_byte_saved; | ||
| 974 | best_above--; | 985 | best_above--; |
| 975 | } | 986 | } |
| 976 | i = best_above; | 987 | i = best_above; |