diff options
| author | Richard M. Stallman | 1998-03-28 21:52:10 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1998-03-28 21:52:10 +0000 |
| commit | 60ea60525e1f1789903bbf10e0587af0c3928864 (patch) | |
| tree | b6e37da885b44055aa8808299ccde3f63c67a9bf /src | |
| parent | 4c315bdabd2270964b4054dce2d9f52f018bcb3a (diff) | |
| download | emacs-60ea60525e1f1789903bbf10e0587af0c3928864.tar.gz emacs-60ea60525e1f1789903bbf10e0587af0c3928864.zip | |
(check_markers_debug_flag): New variable.
(syms_of_insdel): Set up Lisp var.
(CHECK_MARKERS): New macro. Use it everywhere
instead of calling check_markers directly.
It tests check_markers_debug_flag.
Diffstat (limited to 'src')
| -rw-r--r-- | src/insdel.c | 51 |
1 files changed, 49 insertions, 2 deletions
diff --git a/src/insdel.c b/src/insdel.c index c94602c90a4..43aa2a7d196 100644 --- a/src/insdel.c +++ b/src/insdel.c | |||
| @@ -64,6 +64,35 @@ Lisp_Object combine_after_change_list; | |||
| 64 | /* Buffer which combine_after_change_list is about. */ | 64 | /* Buffer which combine_after_change_list is about. */ |
| 65 | Lisp_Object combine_after_change_buffer; | 65 | Lisp_Object combine_after_change_buffer; |
| 66 | 66 | ||
| 67 | /* Check all markers in the current buffer, looking for something invalid. */ | ||
| 68 | |||
| 69 | static int check_markers_debug_flag; | ||
| 70 | |||
| 71 | #define CHECK_MARKERS() \ | ||
| 72 | if (check_markers_debug_flag) \ | ||
| 73 | check_markers (); \ | ||
| 74 | else | ||
| 75 | |||
| 76 | void | ||
| 77 | check_markers () | ||
| 78 | { | ||
| 79 | register Lisp_Object tail, prev, next; | ||
| 80 | |||
| 81 | tail = BUF_MARKERS (current_buffer); | ||
| 82 | |||
| 83 | while (XSYMBOL (tail) != XSYMBOL (Qnil)) | ||
| 84 | { | ||
| 85 | if (XMARKER (tail)->buffer->text != current_buffer->text) | ||
| 86 | abort (); | ||
| 87 | if (XMARKER (tail)->charpos > Z) | ||
| 88 | abort (); | ||
| 89 | if (XMARKER (tail)->bytepos > Z_BYTE) | ||
| 90 | abort (); | ||
| 91 | |||
| 92 | tail = XMARKER (tail)->chain; | ||
| 93 | } | ||
| 94 | } | ||
| 95 | |||
| 67 | /* Move gap to position CHARPOS. | 96 | /* Move gap to position CHARPOS. |
| 68 | Note that this can quit! */ | 97 | Note that this can quit! */ |
| 69 | 98 | ||
| @@ -911,6 +940,8 @@ combine_bytes (pos, pos_byte, nbytes) | |||
| 911 | if (BUF_INTERVALS (current_buffer) != 0) | 940 | if (BUF_INTERVALS (current_buffer) != 0) |
| 912 | /* Only defined if Emacs is compiled with USE_TEXT_PROPERTIES. */ | 941 | /* Only defined if Emacs is compiled with USE_TEXT_PROPERTIES. */ |
| 913 | offset_intervals (current_buffer, pos, - nbytes); | 942 | offset_intervals (current_buffer, pos, - nbytes); |
| 943 | |||
| 944 | CHECK_MARKERS (); | ||
| 914 | } | 945 | } |
| 915 | 946 | ||
| 916 | /* Insert a sequence of NCHARS chars which occupy NBYTES bytes | 947 | /* Insert a sequence of NCHARS chars which occupy NBYTES bytes |
| @@ -1390,6 +1421,8 @@ adjust_before_replace (from, from_byte, to, to_byte) | |||
| 1390 | Lisp_Object deletion; | 1421 | Lisp_Object deletion; |
| 1391 | deletion = make_buffer_string_both (from, from_byte, to, to_byte, 1); | 1422 | deletion = make_buffer_string_both (from, from_byte, to, to_byte, 1); |
| 1392 | 1423 | ||
| 1424 | CHECK_MARKERS (); | ||
| 1425 | |||
| 1393 | adjust_markers_for_delete (from, from_byte, to, to_byte); | 1426 | adjust_markers_for_delete (from, from_byte, to, to_byte); |
| 1394 | record_delete (from, deletion); | 1427 | record_delete (from, deletion); |
| 1395 | adjust_overlays_for_delete (from, to - from); | 1428 | adjust_overlays_for_delete (from, to - from); |
| @@ -1397,7 +1430,8 @@ adjust_before_replace (from, from_byte, to, to_byte) | |||
| 1397 | 1430 | ||
| 1398 | /* This function should be called after altering the text between FROM | 1431 | /* This function should be called after altering the text between FROM |
| 1399 | and TO to a new text of LEN chars (LEN_BYTE bytes), but before | 1432 | and TO to a new text of LEN chars (LEN_BYTE bytes), but before |
| 1400 | making the text a buffer contents. It exists just after GPT_ADDR. */ | 1433 | making the text into buffer contents. |
| 1434 | The new text exists just after GPT_ADDR. */ | ||
| 1401 | 1435 | ||
| 1402 | void | 1436 | void |
| 1403 | adjust_after_replace (from, from_byte, to, to_byte, len, len_byte, replace) | 1437 | adjust_after_replace (from, from_byte, to, to_byte, len, len_byte, replace) |
| @@ -1472,6 +1506,8 @@ adjust_after_replace (from, from_byte, to, to_byte, len, len_byte, replace) | |||
| 1472 | combine_bytes (from, from_byte, combined_before_bytes); | 1506 | combine_bytes (from, from_byte, combined_before_bytes); |
| 1473 | } | 1507 | } |
| 1474 | 1508 | ||
| 1509 | CHECK_MARKERS (); | ||
| 1510 | |||
| 1475 | if (len == 0) | 1511 | if (len == 0) |
| 1476 | evaporate_overlays (from); | 1512 | evaporate_overlays (from); |
| 1477 | MODIFF++; | 1513 | MODIFF++; |
| @@ -1504,6 +1540,8 @@ replace_range (from, to, new, prepare, inherit, nomarkers) | |||
| 1504 | int outgoing_insbytes = insbytes; | 1540 | int outgoing_insbytes = insbytes; |
| 1505 | Lisp_Object deletion; | 1541 | Lisp_Object deletion; |
| 1506 | 1542 | ||
| 1543 | CHECK_MARKERS (); | ||
| 1544 | |||
| 1507 | GCPRO1 (new); | 1545 | GCPRO1 (new); |
| 1508 | 1546 | ||
| 1509 | if (prepare) | 1547 | if (prepare) |
| @@ -1685,6 +1723,8 @@ replace_range (from, to, new, prepare, inherit, nomarkers) | |||
| 1685 | if (outgoing_insbytes == 0) | 1723 | if (outgoing_insbytes == 0) |
| 1686 | evaporate_overlays (from); | 1724 | evaporate_overlays (from); |
| 1687 | 1725 | ||
| 1726 | CHECK_MARKERS (); | ||
| 1727 | |||
| 1688 | MODIFF++; | 1728 | MODIFF++; |
| 1689 | UNGCPRO; | 1729 | UNGCPRO; |
| 1690 | 1730 | ||
| @@ -1818,6 +1858,8 @@ del_range_2 (from, from_byte, to, to_byte) | |||
| 1818 | Lisp_Object deletion; | 1858 | Lisp_Object deletion; |
| 1819 | int from_byte_1; | 1859 | int from_byte_1; |
| 1820 | 1860 | ||
| 1861 | CHECK_MARKERS (); | ||
| 1862 | |||
| 1821 | nchars_del = to - from; | 1863 | nchars_del = to - from; |
| 1822 | nbytes_del = to_byte - from_byte; | 1864 | nbytes_del = to_byte - from_byte; |
| 1823 | 1865 | ||
| @@ -1913,6 +1955,8 @@ del_range_2 (from, from_byte, to, to_byte) | |||
| 1913 | record_insert (GPT - 1, 1); | 1955 | record_insert (GPT - 1, 1); |
| 1914 | } | 1956 | } |
| 1915 | 1957 | ||
| 1958 | CHECK_MARKERS (); | ||
| 1959 | |||
| 1916 | evaporate_overlays (from); | 1960 | evaporate_overlays (from); |
| 1917 | signal_after_change (from, nchars_del, 0); | 1961 | signal_after_change (from, nchars_del, 0); |
| 1918 | } | 1962 | } |
| @@ -2312,8 +2356,11 @@ syms_of_insdel () | |||
| 2312 | staticpro (&combine_after_change_list); | 2356 | staticpro (&combine_after_change_list); |
| 2313 | combine_after_change_list = Qnil; | 2357 | combine_after_change_list = Qnil; |
| 2314 | 2358 | ||
| 2359 | DEFVAR_BOOL ("check-markers-debug-flag", &check_markers_debug_flag, | ||
| 2360 | "Non-nil means enable debugging checks for invalid marker positions."); | ||
| 2361 | check_markers_debug_flag = 0; | ||
| 2315 | DEFVAR_LISP ("combine-after-change-calls", &Vcombine_after_change_calls, | 2362 | DEFVAR_LISP ("combine-after-change-calls", &Vcombine_after_change_calls, |
| 2316 | "Used internally by the `combine-after-change-calls' macro."); | 2363 | "Used internally by the `combine-after-change-calls' macro."); |
| 2317 | Vcombine_after_change_calls = Qnil; | 2364 | Vcombine_after_change_calls = Qnil; |
| 2318 | 2365 | ||
| 2319 | defsubr (&Scombine_after_change_execute); | 2366 | defsubr (&Scombine_after_change_execute); |