Mercurial > emacs
comparison src/intervals.c @ 20677:3cb3da7382f5
(set_intervals_multibyte): New function.
(set_intervals_multibyte_1): New function.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Mon, 19 Jan 1998 19:30:38 +0000 |
parents | b1edf278ca98 |
children | d43ba5d91281 |
comparison
equal
deleted
inserted
replaced
20676:96075a98e445 | 20677:3cb3da7382f5 |
---|---|
2102 if (len2 == distance) | 2102 if (len2 == distance) |
2103 i2 = next_interval (i2); | 2103 i2 = next_interval (i2); |
2104 } | 2104 } |
2105 return 1; | 2105 return 1; |
2106 } | 2106 } |
2107 | |
2108 static void set_intervals_multibyte_1 (INTERVAL, int, int, int, int, int); | |
2109 | |
2110 /* Update the intervals of the current buffer | |
2111 to fit the contents as multibyte (if MULTI_FLAG is 1) | |
2112 or to fit them as non-multibyte (if MULTI_FLAG is 0). */ | |
2113 | |
2114 void | |
2115 set_intervals_multibyte (multi_flag) | |
2116 int multi_flag; | |
2117 { | |
2118 if (BUF_INTERVALS (current_buffer)) | |
2119 set_intervals_multibyte_1 (BUF_INTERVALS (current_buffer), multi_flag, | |
2120 BEG, BEG_BYTE, Z, Z_BYTE); | |
2121 } | |
2122 | |
2123 /* Recursively adjust interval I in the current buffer | |
2124 for setting enable_multibyte_characters to MULTI_FLAG. | |
2125 The range of interval I is START ... END in characters, | |
2126 START_BYTE ... END_BYTE in bytes. */ | |
2127 | |
2128 static void | |
2129 set_intervals_multibyte_1 (i, multi_flag, start, start_byte, end, end_byte) | |
2130 INTERVAL i; | |
2131 int multi_flag; | |
2132 int start, start_byte, end, end_byte; | |
2133 { | |
2134 INTERVAL left, right; | |
2135 | |
2136 /* Fix the length of this interval. */ | |
2137 if (multi_flag) | |
2138 i->total_length = end - start; | |
2139 else | |
2140 i->total_length = end_byte - start_byte; | |
2141 | |
2142 /* Recursively fix the length of the subintervals. */ | |
2143 if (i->left) | |
2144 { | |
2145 int left_end, left_end_byte; | |
2146 | |
2147 if (multi_flag) | |
2148 { | |
2149 left_end_byte = start_byte + LEFT_TOTAL_LENGTH (i); | |
2150 left_end = BYTE_TO_CHAR (left_end_byte); | |
2151 } | |
2152 else | |
2153 { | |
2154 left_end = start + LEFT_TOTAL_LENGTH (i); | |
2155 left_end_byte = CHAR_TO_BYTE (left_end); | |
2156 } | |
2157 | |
2158 set_intervals_multibyte_1 (i->left, multi_flag, start, start_byte, | |
2159 left_end, left_end_byte); | |
2160 } | |
2161 if (i->right) | |
2162 { | |
2163 int right_start_byte, right_start; | |
2164 | |
2165 if (multi_flag) | |
2166 { | |
2167 right_start_byte = end_byte - RIGHT_TOTAL_LENGTH (i); | |
2168 right_start = BYTE_TO_CHAR (right_start_byte); | |
2169 } | |
2170 else | |
2171 { | |
2172 right_start = end - RIGHT_TOTAL_LENGTH (i); | |
2173 right_start_byte = CHAR_TO_BYTE (right_start); | |
2174 } | |
2175 | |
2176 set_intervals_multibyte_1 (i->right, multi_flag, | |
2177 right_start, right_start_byte, | |
2178 end, end_byte); | |
2179 } | |
2180 } | |
2107 | 2181 |
2108 #endif /* USE_TEXT_PROPERTIES */ | 2182 #endif /* USE_TEXT_PROPERTIES */ |