aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEli Zaretskii2024-03-04 17:09:29 +0200
committerEli Zaretskii2024-03-04 17:09:29 +0200
commit6e801077ae88e72dbad32015a083602062c4efe3 (patch)
tree8dc888b38452e42fa8a3eb8eb96d006a93f615a8 /src
parentae80192d97b8d0e54a9429091cd84190bdbeb49e (diff)
downloademacs-6e801077ae88e72dbad32015a083602062c4efe3.tar.gz
emacs-6e801077ae88e72dbad32015a083602062c4efe3.zip
; * src/composite.c (composition_compute_stop_pos): Add comment.
Diffstat (limited to 'src')
-rw-r--r--src/composite.c26
1 files changed, 21 insertions, 5 deletions
diff --git a/src/composite.c b/src/composite.c
index a9b037f4a4a..84cea8bcad6 100644
--- a/src/composite.c
+++ b/src/composite.c
@@ -1153,12 +1153,12 @@ composition_compute_stop_pos (struct composition_it *cmp_it, ptrdiff_t charpos,
1153 } 1153 }
1154 else if (charpos > endpos) 1154 else if (charpos > endpos)
1155 { 1155 {
1156 /* Search backward for a pattern that may be composed and the 1156 /* Search backward for a pattern that may be composed such that
1157 position of (possibly) the last character of the match is 1157 the position of (possibly) the last character of the match is
1158 closest to (but not after) START. The reason for the last 1158 closest to (but not after) START. The reason for the last
1159 character is that set_iterator_to_next works in reverse order, 1159 character is that set_iterator_to_next works in reverse
1160 and thus we must stop at the last character for composition 1160 order, and thus we must stop at the last character for
1161 check. */ 1161 composition check. */
1162 unsigned char *p; 1162 unsigned char *p;
1163 int len; 1163 int len;
1164 /* Limit byte position used in fast_looking_at. This is the 1164 /* Limit byte position used in fast_looking_at. This is the
@@ -1171,6 +1171,22 @@ composition_compute_stop_pos (struct composition_it *cmp_it, ptrdiff_t charpos,
1171 p = SDATA (string) + bytepos; 1171 p = SDATA (string) + bytepos;
1172 c = string_char_and_length (p, &len); 1172 c = string_char_and_length (p, &len);
1173 limit = bytepos + len; 1173 limit = bytepos + len;
1174 /* The algorithmic idea behind the loop below is somewhat tricky
1175 and subtle. Keep in mind that any arbitrarily long sequence
1176 of composable characters can potentially be composed to end
1177 at or before START. So the fact that we find a character C
1178 before START that can be composed with several following
1179 characters does not mean we can exit the loop, because some
1180 character before C could also be composed, yielding a longer
1181 composed sequence which ends closer to START. And since a
1182 composition can be arbitrarily long, it is very important to
1183 know where to stop the search back, because the default --
1184 BEGV -- could be VERY far away. Since searching back is only
1185 needed when delivering bidirectional text reordered for
1186 display, and since no character composition can ever cross
1187 into another embedding level, the search could end when it
1188 gets to the end of the current embedding level, but this
1189 limit should be imposed by the caller. */
1174 while (char_composable_p (c)) 1190 while (char_composable_p (c))
1175 { 1191 {
1176 val = CHAR_TABLE_REF (Vcomposition_function_table, c); 1192 val = CHAR_TABLE_REF (Vcomposition_function_table, c);