comparison src/intervals.c @ 110505:e67da919e2b5

Fix uses of int instead of EMACS_INT in intervals.c. intervals.c (traverse_intervals, rotate_right, rotate_left) (balance_an_interval, split_interval_right, split_interval_left) (find_interval, next_interval, update_interval) (adjust_intervals_for_insertion, delete_node, delete_interval) (interval_deletion_adjustment, adjust_intervals_for_deletion) (offset_intervals, merge_interval_right, merge_interval_left) (graft_intervals_into_buffer, adjust_for_invis_intang) (move_if_not_intangible, get_local_map, copy_intervals) (copy_intervals_to_string, compare_string_intervals) (set_intervals_multibyte_1): Use EMACS_INT for buffer positions and EMACS_UINT for interval tree size. intervals.h (traverse_intervals, split_interval_right) (split_interval_left, find_interval, offset_intervals) (graft_intervals_into_buffer, copy_intervals) (copy_intervals_to_string, move_if_not_intangible, get_local_map) (update_interval): Adjust prototypes.
author Eli Zaretskii <eliz@gnu.org>
date Thu, 23 Sep 2010 11:46:54 -0400
parents 0fdd992ff057
children db816f28c44b
comparison
equal deleted inserted replaced
110504:0fdd992ff057 110505:e67da919e2b5
220 220
221 /* Traverse an interval tree TREE, performing FUNCTION on each node. 221 /* Traverse an interval tree TREE, performing FUNCTION on each node.
222 Pass FUNCTION two args: an interval, and ARG. */ 222 Pass FUNCTION two args: an interval, and ARG. */
223 223
224 void 224 void
225 traverse_intervals (INTERVAL tree, int position, void (*function) (INTERVAL, Lisp_Object), Lisp_Object arg) 225 traverse_intervals (INTERVAL tree, EMACS_UINT position,
226 void (*function) (INTERVAL, Lisp_Object), Lisp_Object arg)
226 { 227 {
227 while (!NULL_INTERVAL_P (tree)) 228 while (!NULL_INTERVAL_P (tree))
228 { 229 {
229 traverse_intervals (tree->left, position, function, arg); 230 traverse_intervals (tree->left, position, function, arg);
230 position += LEFT_TOTAL_LENGTH (tree); 231 position += LEFT_TOTAL_LENGTH (tree);
314 static INLINE INTERVAL 315 static INLINE INTERVAL
315 rotate_right (INTERVAL interval) 316 rotate_right (INTERVAL interval)
316 { 317 {
317 INTERVAL i; 318 INTERVAL i;
318 INTERVAL B = interval->left; 319 INTERVAL B = interval->left;
319 int old_total = interval->total_length; 320 EMACS_UINT old_total = interval->total_length;
320 321
321 /* Deal with any Parent of A; make it point to B. */ 322 /* Deal with any Parent of A; make it point to B. */
322 if (! ROOT_INTERVAL_P (interval)) 323 if (! ROOT_INTERVAL_P (interval))
323 { 324 {
324 if (AM_LEFT_CHILD (interval)) 325 if (AM_LEFT_CHILD (interval))
361 static INLINE INTERVAL 362 static INLINE INTERVAL
362 rotate_left (INTERVAL interval) 363 rotate_left (INTERVAL interval)
363 { 364 {
364 INTERVAL i; 365 INTERVAL i;
365 INTERVAL B = interval->right; 366 INTERVAL B = interval->right;
366 int old_total = interval->total_length; 367 EMACS_UINT old_total = interval->total_length;
367 368
368 /* Deal with any parent of A; make it point to B. */ 369 /* Deal with any parent of A; make it point to B. */
369 if (! ROOT_INTERVAL_P (interval)) 370 if (! ROOT_INTERVAL_P (interval))
370 { 371 {
371 if (AM_LEFT_CHILD (interval)) 372 if (AM_LEFT_CHILD (interval))
400 themselves are already balanced. */ 401 themselves are already balanced. */
401 402
402 static INTERVAL 403 static INTERVAL
403 balance_an_interval (INTERVAL i) 404 balance_an_interval (INTERVAL i)
404 { 405 {
405 register int old_diff, new_diff; 406 register EMACS_INT old_diff, new_diff;
406 407
407 while (1) 408 while (1)
408 { 409 {
409 old_diff = LEFT_TOTAL_LENGTH (i) - RIGHT_TOTAL_LENGTH (i); 410 old_diff = LEFT_TOTAL_LENGTH (i) - RIGHT_TOTAL_LENGTH (i);
410 if (old_diff > 0) 411 if (old_diff > 0)
500 501
501 Note that this does not change the position of INTERVAL; if it is a root, 502 Note that this does not change the position of INTERVAL; if it is a root,
502 it is still a root after this operation. */ 503 it is still a root after this operation. */
503 504
504 INTERVAL 505 INTERVAL
505 split_interval_right (INTERVAL interval, int offset) 506 split_interval_right (INTERVAL interval, EMACS_INT offset)
506 { 507 {
507 INTERVAL new = make_interval (); 508 INTERVAL new = make_interval ();
508 int position = interval->position; 509 EMACS_UINT position = interval->position;
509 int new_length = LENGTH (interval) - offset; 510 EMACS_UINT new_length = LENGTH (interval) - offset;
510 511
511 new->position = position + offset; 512 new->position = position + offset;
512 SET_INTERVAL_PARENT (new, interval); 513 SET_INTERVAL_PARENT (new, interval);
513 514
514 if (NULL_RIGHT_CHILD (interval)) 515 if (NULL_RIGHT_CHILD (interval))
545 546
546 Note that this does not change the position of INTERVAL; if it is a root, 547 Note that this does not change the position of INTERVAL; if it is a root,
547 it is still a root after this operation. */ 548 it is still a root after this operation. */
548 549
549 INTERVAL 550 INTERVAL
550 split_interval_left (INTERVAL interval, int offset) 551 split_interval_left (INTERVAL interval, EMACS_INT offset)
551 { 552 {
552 INTERVAL new = make_interval (); 553 INTERVAL new = make_interval ();
553 int new_length = offset; 554 EMACS_INT new_length = offset;
554 555
555 new->position = interval->position; 556 new->position = interval->position;
556 interval->position = interval->position + offset; 557 interval->position = interval->position + offset;
557 SET_INTERVAL_PARENT (new, interval); 558 SET_INTERVAL_PARENT (new, interval);
558 559
611 The `position' field, which is a cache of an interval's position, 612 The `position' field, which is a cache of an interval's position,
612 is updated in the interval found. Other functions (e.g., next_interval) 613 is updated in the interval found. Other functions (e.g., next_interval)
613 will update this cache based on the result of find_interval. */ 614 will update this cache based on the result of find_interval. */
614 615
615 INTERVAL 616 INTERVAL
616 find_interval (register INTERVAL tree, register int position) 617 find_interval (register INTERVAL tree, register EMACS_INT position)
617 { 618 {
618 /* The distance from the left edge of the subtree at TREE 619 /* The distance from the left edge of the subtree at TREE
619 to POSITION. */ 620 to POSITION. */
620 register int relative_position; 621 register EMACS_UINT relative_position;
621 622
622 if (NULL_INTERVAL_P (tree)) 623 if (NULL_INTERVAL_P (tree))
623 return NULL_INTERVAL; 624 return NULL_INTERVAL;
624 625
625 relative_position = position; 626 relative_position = position;
668 669
669 INTERVAL 670 INTERVAL
670 next_interval (register INTERVAL interval) 671 next_interval (register INTERVAL interval)
671 { 672 {
672 register INTERVAL i = interval; 673 register INTERVAL i = interval;
673 register int next_position; 674 register EMACS_UINT next_position;
674 675
675 if (NULL_INTERVAL_P (i)) 676 if (NULL_INTERVAL_P (i))
676 return NULL_INTERVAL; 677 return NULL_INTERVAL;
677 next_position = interval->position + LENGTH (interval); 678 next_position = interval->position + LENGTH (interval);
678 679
743 in the same tree. Note that we need to update interval->position 744 in the same tree. Note that we need to update interval->position
744 if we go down the tree. 745 if we go down the tree.
745 To speed up the process, we assume that the ->position of 746 To speed up the process, we assume that the ->position of
746 I and all its parents is already uptodate. */ 747 I and all its parents is already uptodate. */
747 INTERVAL 748 INTERVAL
748 update_interval (register INTERVAL i, int pos) 749 update_interval (register INTERVAL i, EMACS_INT pos)
749 { 750 {
750 if (NULL_INTERVAL_P (i)) 751 if (NULL_INTERVAL_P (i))
751 return NULL_INTERVAL; 752 return NULL_INTERVAL;
752 753
753 while (1) 754 while (1)
862 If both intervals are "sticky", then make them belong to the left-most 863 If both intervals are "sticky", then make them belong to the left-most
863 interval. Another possibility would be to create a new interval for 864 interval. Another possibility would be to create a new interval for
864 this text, and make it have the merged properties of both ends. */ 865 this text, and make it have the merged properties of both ends. */
865 866
866 static INTERVAL 867 static INTERVAL
867 adjust_intervals_for_insertion (INTERVAL tree, int position, int length) 868 adjust_intervals_for_insertion (INTERVAL tree,
869 EMACS_INT position, EMACS_INT length)
868 { 870 {
869 register INTERVAL i; 871 register INTERVAL i;
870 register INTERVAL temp; 872 register INTERVAL temp;
871 int eobp = 0; 873 int eobp = 0;
872 Lisp_Object parent; 874 Lisp_Object parent;
873 int offset; 875 EMACS_INT offset;
874 876
875 if (TOTAL_LENGTH (tree) == 0) /* Paranoia */ 877 if (TOTAL_LENGTH (tree) == 0) /* Paranoia */
876 abort (); 878 abort ();
877 879
878 GET_INTERVAL_OBJECT (parent, tree); 880 GET_INTERVAL_OBJECT (parent, tree);
1226 1228
1227 static INTERVAL 1229 static INTERVAL
1228 delete_node (register INTERVAL i) 1230 delete_node (register INTERVAL i)
1229 { 1231 {
1230 register INTERVAL migrate, this; 1232 register INTERVAL migrate, this;
1231 register int migrate_amt; 1233 register EMACS_UINT migrate_amt;
1232 1234
1233 if (NULL_INTERVAL_P (i->left)) 1235 if (NULL_INTERVAL_P (i->left))
1234 return i->right; 1236 return i->right;
1235 if (NULL_INTERVAL_P (i->right)) 1237 if (NULL_INTERVAL_P (i->right))
1236 return i->left; 1238 return i->left;
1259 1261
1260 void 1262 void
1261 delete_interval (register INTERVAL i) 1263 delete_interval (register INTERVAL i)
1262 { 1264 {
1263 register INTERVAL parent; 1265 register INTERVAL parent;
1264 int amt = LENGTH (i); 1266 EMACS_UINT amt = LENGTH (i);
1265 1267
1266 if (amt > 0) /* Only used on zero-length intervals now. */ 1268 if (amt > 0) /* Only used on zero-length intervals now. */
1267 abort (); 1269 abort ();
1268 1270
1269 if (ROOT_INTERVAL_P (i)) 1271 if (ROOT_INTERVAL_P (i))
1309 recursively on subtrees. 1311 recursively on subtrees.
1310 1312
1311 Do this by recursing down TREE to the interval in question, and 1313 Do this by recursing down TREE to the interval in question, and
1312 deleting the appropriate amount of text. */ 1314 deleting the appropriate amount of text. */
1313 1315
1314 static int 1316 static EMACS_UINT
1315 interval_deletion_adjustment (register INTERVAL tree, register int from, register int amount) 1317 interval_deletion_adjustment (register INTERVAL tree, register EMACS_UINT from,
1316 { 1318 register EMACS_UINT amount)
1317 register int relative_position = from; 1319 {
1320 register EMACS_UINT relative_position = from;
1318 1321
1319 if (NULL_INTERVAL_P (tree)) 1322 if (NULL_INTERVAL_P (tree))
1320 return 0; 1323 return 0;
1321 1324
1322 /* Left branch */ 1325 /* Left branch */
1323 if (relative_position < LEFT_TOTAL_LENGTH (tree)) 1326 if (relative_position < LEFT_TOTAL_LENGTH (tree))
1324 { 1327 {
1325 int subtract = interval_deletion_adjustment (tree->left, 1328 EMACS_UINT subtract = interval_deletion_adjustment (tree->left,
1326 relative_position, 1329 relative_position,
1327 amount); 1330 amount);
1328 tree->total_length -= subtract; 1331 tree->total_length -= subtract;
1329 CHECK_TOTAL_LENGTH (tree); 1332 CHECK_TOTAL_LENGTH (tree);
1330 return subtract; 1333 return subtract;
1331 } 1334 }
1332 /* Right branch */ 1335 /* Right branch */
1333 else if (relative_position >= (TOTAL_LENGTH (tree) 1336 else if (relative_position >= (TOTAL_LENGTH (tree)
1334 - RIGHT_TOTAL_LENGTH (tree))) 1337 - RIGHT_TOTAL_LENGTH (tree)))
1335 { 1338 {
1336 int subtract; 1339 EMACS_UINT subtract;
1337 1340
1338 relative_position -= (tree->total_length 1341 relative_position -= (tree->total_length
1339 - RIGHT_TOTAL_LENGTH (tree)); 1342 - RIGHT_TOTAL_LENGTH (tree));
1340 subtract = interval_deletion_adjustment (tree->right, 1343 subtract = interval_deletion_adjustment (tree->right,
1341 relative_position, 1344 relative_position,
1346 } 1349 }
1347 /* Here -- this node. */ 1350 /* Here -- this node. */
1348 else 1351 else
1349 { 1352 {
1350 /* How much can we delete from this interval? */ 1353 /* How much can we delete from this interval? */
1351 int my_amount = ((tree->total_length 1354 EMACS_UINT my_amount = ((tree->total_length
1352 - RIGHT_TOTAL_LENGTH (tree)) 1355 - RIGHT_TOTAL_LENGTH (tree))
1353 - relative_position); 1356 - relative_position);
1354 1357
1355 if (amount > my_amount) 1358 if (amount > my_amount)
1356 amount = my_amount; 1359 amount = my_amount;
1357 1360
1358 tree->total_length -= amount; 1361 tree->total_length -= amount;
1370 correspond to the deletion of LENGTH characters from that buffer 1373 correspond to the deletion of LENGTH characters from that buffer
1371 text. The deletion is effected at position START (which is a 1374 text. The deletion is effected at position START (which is a
1372 buffer position, i.e. origin 1). */ 1375 buffer position, i.e. origin 1). */
1373 1376
1374 static void 1377 static void
1375 adjust_intervals_for_deletion (struct buffer *buffer, int start, int length) 1378 adjust_intervals_for_deletion (struct buffer *buffer,
1376 { 1379 EMACS_INT start, EMACS_INT length)
1377 register int left_to_delete = length; 1380 {
1381 register EMACS_INT left_to_delete = length;
1378 register INTERVAL tree = BUF_INTERVALS (buffer); 1382 register INTERVAL tree = BUF_INTERVALS (buffer);
1379 Lisp_Object parent; 1383 Lisp_Object parent;
1380 int offset; 1384 EMACS_UINT offset;
1381 1385
1382 GET_INTERVAL_OBJECT (parent, tree); 1386 GET_INTERVAL_OBJECT (parent, tree);
1383 offset = (BUFFERP (parent) ? BUF_BEG (XBUFFER (parent)) : 0); 1387 offset = (BUFFERP (parent) ? BUF_BEG (XBUFFER (parent)) : 0);
1384 1388
1385 if (NULL_INTERVAL_P (tree)) 1389 if (NULL_INTERVAL_P (tree))
1421 represent an addition or deletion of LENGTH characters starting 1425 represent an addition or deletion of LENGTH characters starting
1422 at position START. Addition or deletion is indicated by the sign 1426 at position START. Addition or deletion is indicated by the sign
1423 of LENGTH. */ 1427 of LENGTH. */
1424 1428
1425 INLINE void 1429 INLINE void
1426 offset_intervals (struct buffer *buffer, int start, int length) 1430 offset_intervals (struct buffer *buffer, EMACS_INT start, EMACS_INT length)
1427 { 1431 {
1428 if (NULL_INTERVAL_P (BUF_INTERVALS (buffer)) || length == 0) 1432 if (NULL_INTERVAL_P (BUF_INTERVALS (buffer)) || length == 0)
1429 return; 1433 return;
1430 1434
1431 if (length > 0) 1435 if (length > 0)
1444 interval. */ 1448 interval. */
1445 1449
1446 INTERVAL 1450 INTERVAL
1447 merge_interval_right (register INTERVAL i) 1451 merge_interval_right (register INTERVAL i)
1448 { 1452 {
1449 register int absorb = LENGTH (i); 1453 register EMACS_UINT absorb = LENGTH (i);
1450 register INTERVAL successor; 1454 register INTERVAL successor;
1451 1455
1452 /* Zero out this interval. */ 1456 /* Zero out this interval. */
1453 i->total_length -= absorb; 1457 i->total_length -= absorb;
1454 CHECK_TOTAL_LENGTH (i); 1458 CHECK_TOTAL_LENGTH (i);
1500 The caller must verify that this is not the first (leftmost) interval. */ 1504 The caller must verify that this is not the first (leftmost) interval. */
1501 1505
1502 INTERVAL 1506 INTERVAL
1503 merge_interval_left (register INTERVAL i) 1507 merge_interval_left (register INTERVAL i)
1504 { 1508 {
1505 register int absorb = LENGTH (i); 1509 register EMACS_UINT absorb = LENGTH (i);
1506 register INTERVAL predecessor; 1510 register INTERVAL predecessor;
1507 1511
1508 /* Zero out this interval. */ 1512 /* Zero out this interval. */
1509 i->total_length -= absorb; 1513 i->total_length -= absorb;
1510 CHECK_TOTAL_LENGTH (i); 1514 CHECK_TOTAL_LENGTH (i);
1596 interval. */ 1600 interval. */
1597 1601
1598 static INTERVAL 1602 static INTERVAL
1599 make_new_interval (intervals, start, length) 1603 make_new_interval (intervals, start, length)
1600 INTERVAL intervals; 1604 INTERVAL intervals;
1601 int start, length; 1605 EMACS_INT start, length;
1602 { 1606 {
1603 INTERVAL slot; 1607 INTERVAL slot;
1604 1608
1605 slot = find_interval (intervals, start); 1609 slot = find_interval (intervals, start);
1606 if (start + length > slot->position + LENGTH (slot)) 1610 if (start + length > slot->position + LENGTH (slot))
1668 only its properties, as if neither sticky property were set. Perhaps 1672 only its properties, as if neither sticky property were set. Perhaps
1669 we should consider merging all three sets of properties onto the new 1673 we should consider merging all three sets of properties onto the new
1670 text... */ 1674 text... */
1671 1675
1672 void 1676 void
1673 graft_intervals_into_buffer (INTERVAL source, int position, int length, struct buffer *buffer, int inherit) 1677 graft_intervals_into_buffer (INTERVAL source, EMACS_INT position,
1678 EMACS_INT length, struct buffer *buffer,
1679 int inherit)
1674 { 1680 {
1675 register INTERVAL under, over, this, prev; 1681 register INTERVAL under, over, this, prev;
1676 register INTERVAL tree; 1682 register INTERVAL tree;
1677 int over_used; 1683 EMACS_UINT over_used;
1678 1684
1679 tree = BUF_INTERVALS (buffer); 1685 tree = BUF_INTERVALS (buffer);
1680 1686
1681 /* If the new text has no properties, then with inheritance it 1687 /* If the new text has no properties, then with inheritance it
1682 becomes part of whatever interval it was inserted into. 1688 becomes part of whatever interval it was inserted into.
1919 1925
1920 Note that `stickiness' is determined by overlay marker insertion types, 1926 Note that `stickiness' is determined by overlay marker insertion types,
1921 if the invisible property comes from an overlay. */ 1927 if the invisible property comes from an overlay. */
1922 1928
1923 static int 1929 static int
1924 adjust_for_invis_intang (int pos, int test_offs, int adj, int test_intang) 1930 adjust_for_invis_intang (EMACS_INT pos, EMACS_INT test_offs, EMACS_INT adj,
1931 int test_intang)
1925 { 1932 {
1926 Lisp_Object invis_propval, invis_overlay; 1933 Lisp_Object invis_propval, invis_overlay;
1927 Lisp_Object test_pos; 1934 Lisp_Object test_pos;
1928 1935
1929 if ((adj < 0 && pos + adj < BEGV) || (adj > 0 && pos + adj > ZV)) 1936 if ((adj < 0 && pos + adj < BEGV) || (adj > 0 && pos + adj > ZV))
2181 2188
2182 /* Move point to POSITION, unless POSITION is inside an intangible 2189 /* Move point to POSITION, unless POSITION is inside an intangible
2183 segment that reaches all the way to point. */ 2190 segment that reaches all the way to point. */
2184 2191
2185 void 2192 void
2186 move_if_not_intangible (int position) 2193 move_if_not_intangible (EMACS_INT position)
2187 { 2194 {
2188 Lisp_Object pos; 2195 Lisp_Object pos;
2189 Lisp_Object intangible_propval; 2196 Lisp_Object intangible_propval;
2190 2197
2191 XSETINT (pos, position); 2198 XSETINT (pos, position);
2288 `local-map' use BUFFER's local map. 2295 `local-map' use BUFFER's local map.
2289 2296
2290 POSITION must be in the accessible part of BUFFER. */ 2297 POSITION must be in the accessible part of BUFFER. */
2291 2298
2292 Lisp_Object 2299 Lisp_Object
2293 get_local_map (register int position, register struct buffer *buffer, Lisp_Object type) 2300 get_local_map (register EMACS_INT position, register struct buffer *buffer,
2301 Lisp_Object type)
2294 { 2302 {
2295 Lisp_Object prop, lispy_position, lispy_buffer; 2303 Lisp_Object prop, lispy_position, lispy_buffer;
2296 int old_begv, old_zv, old_begv_byte, old_zv_byte; 2304 EMACS_INT old_begv, old_zv, old_begv_byte, old_zv_byte;
2297 2305
2298 /* Perhaps we should just change `position' to the limit. */ 2306 /* Perhaps we should just change `position' to the limit. */
2299 if (position > BUF_ZV (buffer) || position < BUF_BEGV (buffer)) 2307 if (position > BUF_ZV (buffer) || position < BUF_BEGV (buffer))
2300 abort (); 2308 abort ();
2301 2309
2341 /* Produce an interval tree reflecting the intervals in 2349 /* Produce an interval tree reflecting the intervals in
2342 TREE from START to START + LENGTH. 2350 TREE from START to START + LENGTH.
2343 The new interval tree has no parent and has a starting-position of 0. */ 2351 The new interval tree has no parent and has a starting-position of 0. */
2344 2352
2345 INTERVAL 2353 INTERVAL
2346 copy_intervals (INTERVAL tree, int start, int length) 2354 copy_intervals (INTERVAL tree, EMACS_INT start, EMACS_INT length)
2347 { 2355 {
2348 register INTERVAL i, new, t; 2356 register INTERVAL i, new, t;
2349 register int got, prevlen; 2357 register EMACS_UINT got, prevlen;
2350 2358
2351 if (NULL_INTERVAL_P (tree) || length <= 0) 2359 if (NULL_INTERVAL_P (tree) || length <= 0)
2352 return NULL_INTERVAL; 2360 return NULL_INTERVAL;
2353 2361
2354 i = find_interval (tree, start); 2362 i = find_interval (tree, start);
2382 } 2390 }
2383 2391
2384 /* Give STRING the properties of BUFFER from POSITION to LENGTH. */ 2392 /* Give STRING the properties of BUFFER from POSITION to LENGTH. */
2385 2393
2386 INLINE void 2394 INLINE void
2387 copy_intervals_to_string (Lisp_Object string, struct buffer *buffer, int position, int length) 2395 copy_intervals_to_string (Lisp_Object string, struct buffer *buffer,
2396 EMACS_INT position, EMACS_INT length)
2388 { 2397 {
2389 INTERVAL interval_copy = copy_intervals (BUF_INTERVALS (buffer), 2398 INTERVAL interval_copy = copy_intervals (BUF_INTERVALS (buffer),
2390 position, length); 2399 position, length);
2391 if (NULL_INTERVAL_P (interval_copy)) 2400 if (NULL_INTERVAL_P (interval_copy))
2392 return; 2401 return;
2400 2409
2401 int 2410 int
2402 compare_string_intervals (Lisp_Object s1, Lisp_Object s2) 2411 compare_string_intervals (Lisp_Object s1, Lisp_Object s2)
2403 { 2412 {
2404 INTERVAL i1, i2; 2413 INTERVAL i1, i2;
2405 int pos = 0; 2414 EMACS_INT pos = 0;
2406 int end = SCHARS (s1); 2415 EMACS_INT end = SCHARS (s1);
2407 2416
2408 i1 = find_interval (STRING_INTERVALS (s1), 0); 2417 i1 = find_interval (STRING_INTERVALS (s1), 0);
2409 i2 = find_interval (STRING_INTERVALS (s2), 0); 2418 i2 = find_interval (STRING_INTERVALS (s2), 0);
2410 2419
2411 while (pos < end) 2420 while (pos < end)
2412 { 2421 {
2413 /* Determine how far we can go before we reach the end of I1 or I2. */ 2422 /* Determine how far we can go before we reach the end of I1 or I2. */
2414 int len1 = (i1 != 0 ? INTERVAL_LAST_POS (i1) : end) - pos; 2423 EMACS_INT len1 = (i1 != 0 ? INTERVAL_LAST_POS (i1) : end) - pos;
2415 int len2 = (i2 != 0 ? INTERVAL_LAST_POS (i2) : end) - pos; 2424 EMACS_INT len2 = (i2 != 0 ? INTERVAL_LAST_POS (i2) : end) - pos;
2416 int distance = min (len1, len2); 2425 EMACS_INT distance = min (len1, len2);
2417 2426
2418 /* If we ever find a mismatch between the strings, 2427 /* If we ever find a mismatch between the strings,
2419 they differ. */ 2428 they differ. */
2420 if (! intervals_equal (i1, i2)) 2429 if (! intervals_equal (i1, i2))
2421 return 0; 2430 return 0;
2435 for setting enable_multibyte_characters to MULTI_FLAG. 2444 for setting enable_multibyte_characters to MULTI_FLAG.
2436 The range of interval I is START ... END in characters, 2445 The range of interval I is START ... END in characters,
2437 START_BYTE ... END_BYTE in bytes. */ 2446 START_BYTE ... END_BYTE in bytes. */
2438 2447
2439 static void 2448 static void
2440 set_intervals_multibyte_1 (INTERVAL i, int multi_flag, int start, int start_byte, int end, int end_byte) 2449 set_intervals_multibyte_1 (INTERVAL i, int multi_flag,
2450 EMACS_INT start, EMACS_INT start_byte,
2451 EMACS_INT end, EMACS_INT end_byte)
2441 { 2452 {
2442 /* Fix the length of this interval. */ 2453 /* Fix the length of this interval. */
2443 if (multi_flag) 2454 if (multi_flag)
2444 i->total_length = end - start; 2455 i->total_length = end - start;
2445 else 2456 else
2453 } 2464 }
2454 2465
2455 /* Recursively fix the length of the subintervals. */ 2466 /* Recursively fix the length of the subintervals. */
2456 if (i->left) 2467 if (i->left)
2457 { 2468 {
2458 int left_end, left_end_byte; 2469 EMACS_INT left_end, left_end_byte;
2459 2470
2460 if (multi_flag) 2471 if (multi_flag)
2461 { 2472 {
2462 int temp; 2473 EMACS_INT temp;
2463 left_end_byte = start_byte + LEFT_TOTAL_LENGTH (i); 2474 left_end_byte = start_byte + LEFT_TOTAL_LENGTH (i);
2464 left_end = BYTE_TO_CHAR (left_end_byte); 2475 left_end = BYTE_TO_CHAR (left_end_byte);
2465 2476
2466 temp = CHAR_TO_BYTE (left_end); 2477 temp = CHAR_TO_BYTE (left_end);
2467 2478
2486 set_intervals_multibyte_1 (i->left, multi_flag, start, start_byte, 2497 set_intervals_multibyte_1 (i->left, multi_flag, start, start_byte,
2487 left_end, left_end_byte); 2498 left_end, left_end_byte);
2488 } 2499 }
2489 if (i->right) 2500 if (i->right)
2490 { 2501 {
2491 int right_start_byte, right_start; 2502 EMACS_INT right_start_byte, right_start;
2492 2503
2493 if (multi_flag) 2504 if (multi_flag)
2494 { 2505 {
2495 int temp; 2506 EMACS_INT temp;
2496 2507
2497 right_start_byte = end_byte - RIGHT_TOTAL_LENGTH (i); 2508 right_start_byte = end_byte - RIGHT_TOTAL_LENGTH (i);
2498 right_start = BYTE_TO_CHAR (right_start_byte); 2509 right_start = BYTE_TO_CHAR (right_start_byte);
2499 2510
2500 /* If RIGHT_START_BYTE is in the middle of a character, 2511 /* If RIGHT_START_BYTE is in the middle of a character,