emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] /srv/bzr/emacs/trunk r109260: Generalize marker debugging


From: Dmitry Antipov
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r109260: Generalize marker debugging code under MARKER_DEBUG and use eassert.
Date: Sun, 29 Jul 2012 15:20:43 +0400
User-agent: Bazaar (2.5.0)

------------------------------------------------------------
revno: 109260
committer: Dmitry Antipov <address@hidden>
branch nick: trunk
timestamp: Sun 2012-07-29 15:20:43 +0400
message:
  Generalize marker debugging code under MARKER_DEBUG and use eassert.
  * insdel.c (CHECK_MARKERS, check_markers_debug_flag): Remove.
  (gap_left, gap_right, adjust_markers_for_delete, insert_1_both)
  (insert_from_string_1, insert_from_gap, insert_from_buffer_1)
  (replace_range, replace_range_2, del_range_2): Change to eassert.
  * marker.c (byte_char_debug_check): Adjust style.
modified:
  src/ChangeLog
  src/insdel.c
  src/marker.c
=== modified file 'src/ChangeLog'
--- a/src/ChangeLog     2012-07-29 08:18:29 +0000
+++ b/src/ChangeLog     2012-07-29 11:20:43 +0000
@@ -1,3 +1,12 @@
+2012-07-29  Dmitry Antipov  <address@hidden>
+
+       Generalize marker debugging code under MARKER_DEBUG and use eassert.
+       * insdel.c (CHECK_MARKERS, check_markers_debug_flag): Remove.
+       (gap_left, gap_right, adjust_markers_for_delete, insert_1_both)
+       (insert_from_string_1, insert_from_gap, insert_from_buffer_1)
+       (replace_range, replace_range_2, del_range_2): Change to eassert.
+       * marker.c (byte_char_debug_check): Adjust style.
+
 2012-07-29  Paul Eggert  <address@hidden>
 
        Don't use the abbreviation "win" to refer to Windows (Bug#10421).

=== modified file 'src/insdel.c'
--- a/src/insdel.c      2012-07-03 18:24:42 +0000
+++ b/src/insdel.c      2012-07-29 11:20:43 +0000
@@ -59,14 +59,10 @@
 Lisp_Object Qinhibit_modification_hooks;
 
 static void signal_before_change (ptrdiff_t, ptrdiff_t, ptrdiff_t *);
-
-#define CHECK_MARKERS()                                \
-  do                                           \
-    {                                          \
-      if (check_markers_debug_flag)            \
-       check_markers ();                       \
-    }                                          \
-  while (0)
+
+/* Also used in marker.c to enable expensive marker checks.  */
+
+#ifdef MARKER_DEBUG
 
 static void
 check_markers (void)
@@ -86,7 +82,13 @@
        abort ();
     }
 }
-
+
+#else /* not MARKER_DEBUG */
+
+#define check_markers() do { } while (0)
+
+#endif /* MARKER_DEBUG */
+
 /* Move gap to position CHARPOS.
    Note that this can quit!  */
 
@@ -158,8 +160,7 @@
      was specified or may be where a quit was detected.  */
   GPT_BYTE = bytepos;
   GPT = charpos;
-  if (bytepos < charpos)
-    abort ();
+  eassert (charpos <= bytepos);
   if (GAP_SIZE > 0) *(GPT_ADDR) = 0; /* Put an anchor.  */
   QUIT;
 }
@@ -209,8 +210,7 @@
 
   GPT = charpos;
   GPT_BYTE = bytepos;
-  if (bytepos < charpos)
-    abort ();
+  eassert (charpos <= bytepos);
   if (GAP_SIZE > 0) *(GPT_ADDR) = 0; /* Put an anchor.  */
   QUIT;
 }
@@ -233,9 +233,7 @@
   for (m = BUF_MARKERS (current_buffer); m; m = m->next)
     {
       charpos = m->charpos;
-
-      if (charpos > Z)
-       abort ();
+      eassert (charpos <= Z);
 
       /* If the marker is after the deletion,
         relocate by number of chars / bytes deleted.  */
@@ -375,7 +373,7 @@
        }
     }
 
-  CHECK_MARKERS ();
+  check_markers ();
 }
 
 
@@ -835,8 +833,7 @@
   Z_BYTE += nbytes;
   if (GAP_SIZE > 0) *(GPT_ADDR) = 0; /* Put an anchor.  */
 
-  if (GPT_BYTE < GPT)
-    abort ();
+  eassert (GPT <= GPT_BYTE);
 
   /* The insert may have been in the unchanged region, so check again. */
   if (Z - GPT < END_UNCHANGED)
@@ -856,7 +853,7 @@
 
   adjust_point (nchars, nbytes);
 
-  CHECK_MARKERS ();
+  check_markers ();
 }
 
 /* Insert the part of the text of STRING, a Lisp object assumed to be
@@ -966,8 +963,7 @@
   Z_BYTE += outgoing_nbytes;
   if (GAP_SIZE > 0) *(GPT_ADDR) = 0; /* Put an anchor.  */
 
-  if (GPT_BYTE < GPT)
-    abort ();
+  eassert (GPT <= GPT_BYTE);
 
   /* The insert may have been in the unchanged region, so check again. */
   if (Z - GPT < END_UNCHANGED)
@@ -991,7 +987,7 @@
 
   adjust_point (nchars, outgoing_nbytes);
 
-  CHECK_MARKERS ();
+  check_markers ();
 }
 
 /* Insert a sequence of NCHARS chars which occupy NBYTES bytes
@@ -1015,8 +1011,7 @@
   Z_BYTE += nbytes;
   if (GAP_SIZE > 0) *(GPT_ADDR) = 0; /* Put an anchor.  */
 
-  if (GPT_BYTE < GPT)
-    abort ();
+  eassert (GPT <= GPT_BYTE);
 
   adjust_overlays_for_insert (GPT - nchars, nchars);
   adjust_markers_for_insert (GPT - nchars, GPT_BYTE - nbytes,
@@ -1032,7 +1027,7 @@
   if (GPT - nchars < PT)
     adjust_point (nchars, nbytes);
 
-  CHECK_MARKERS ();
+  check_markers ();
 }
 
 /* Insert text from BUF, NCHARS characters starting at CHARPOS, into the
@@ -1151,8 +1146,7 @@
   Z_BYTE += outgoing_nbytes;
   if (GAP_SIZE > 0) *(GPT_ADDR) = 0; /* Put an anchor.  */
 
-  if (GPT_BYTE < GPT)
-    abort ();
+  eassert (GPT <= GPT_BYTE);
 
   /* The insert may have been in the unchanged region, so check again. */
   if (Z - GPT < END_UNCHANGED)
@@ -1243,7 +1237,7 @@
   if (Z - GPT < END_UNCHANGED)
     END_UNCHANGED = Z - GPT;
 
-  CHECK_MARKERS ();
+  check_markers ();
 
   if (len == 0)
     evaporate_overlays (from);
@@ -1296,7 +1290,7 @@
   ptrdiff_t outgoing_insbytes = insbytes;
   Lisp_Object deletion;
 
-  CHECK_MARKERS ();
+  check_markers ();
 
   GCPRO1 (new);
   deletion = Qnil;
@@ -1357,8 +1351,7 @@
   GPT_BYTE = from_byte;
   if (GAP_SIZE > 0) *(GPT_ADDR) = 0; /* Put an anchor.  */
 
-  if (GPT_BYTE < GPT)
-    abort ();
+  eassert (GPT <= GPT_BYTE);
 
   if (GPT - BEG < BEG_UNCHANGED)
     BEG_UNCHANGED = GPT - BEG;
@@ -1404,8 +1397,7 @@
   Z_BYTE += outgoing_insbytes;
   if (GAP_SIZE > 0) *(GPT_ADDR) = 0; /* Put an anchor.  */
 
-  if (GPT_BYTE < GPT)
-    abort ();
+  eassert (GPT <= GPT_BYTE);
 
   /* Adjust the overlay center as needed.  This must be done after
      adjusting the markers that bound the overlays.  */
@@ -1435,7 +1427,7 @@
   if (outgoing_insbytes == 0)
     evaporate_overlays (from);
 
-  CHECK_MARKERS ();
+  check_markers ();
 
   MODIFF++;
   CHARS_MODIFF = MODIFF;
@@ -1465,7 +1457,7 @@
 {
   ptrdiff_t nbytes_del, nchars_del;
 
-  CHECK_MARKERS ();
+  check_markers ();
 
   nchars_del = to - from;
   nbytes_del = to_byte - from_byte;
@@ -1488,8 +1480,7 @@
   GPT_BYTE = from_byte;
   if (GAP_SIZE > 0) *(GPT_ADDR) = 0; /* Put an anchor.  */
 
-  if (GPT_BYTE < GPT)
-    abort ();
+  eassert (GPT <= GPT_BYTE);
 
   if (GPT - BEG < BEG_UNCHANGED)
     BEG_UNCHANGED = GPT - BEG;
@@ -1522,8 +1513,7 @@
   Z_BYTE += insbytes;
   if (GAP_SIZE > 0) *(GPT_ADDR) = 0; /* Put an anchor.  */
 
-  if (GPT_BYTE < GPT)
-    abort ();
+  eassert (GPT <= GPT_BYTE);
 
   /* Adjust the overlay center as needed.  This must be done after
      adjusting the markers that bound the overlays.  */
@@ -1554,7 +1544,7 @@
   if (insbytes == 0)
     evaporate_overlays (from);
 
-  CHECK_MARKERS ();
+  check_markers ();
 
   MODIFF++;
   CHARS_MODIFF = MODIFF;
@@ -1705,7 +1695,7 @@
   register ptrdiff_t nbytes_del, nchars_del;
   Lisp_Object deletion;
 
-  CHECK_MARKERS ();
+  check_markers ();
 
   nchars_del = to - from;
   nbytes_del = to_byte - from_byte;
@@ -1761,15 +1751,14 @@
        needs to access the previous gap contents.  */
     *(GPT_ADDR) = 0;
 
-  if (GPT_BYTE < GPT)
-    abort ();
+  eassert (GPT <= GPT_BYTE);
 
   if (GPT - BEG < BEG_UNCHANGED)
     BEG_UNCHANGED = GPT - BEG;
   if (Z - GPT < END_UNCHANGED)
     END_UNCHANGED = Z - GPT;
 
-  CHECK_MARKERS ();
+  check_markers ();
 
   evaporate_overlays (from);
 
@@ -2201,9 +2190,6 @@
   combine_after_change_list = Qnil;
   combine_after_change_buffer = Qnil;
 
-  DEFVAR_BOOL ("check-markers-debug-flag", check_markers_debug_flag,
-              doc: /* Non-nil means enable debugging checks for invalid marker 
positions.  */);
-  check_markers_debug_flag = 0;
   DEFVAR_LISP ("combine-after-change-calls", Vcombine_after_change_calls,
               doc: /* Used internally by the `combine-after-change-calls' 
macro.  */);
   Vcombine_after_change_calls = Qnil;

=== modified file 'src/marker.c'
--- a/src/marker.c      2012-07-27 07:51:52 +0000
+++ b/src/marker.c      2012-07-29 11:20:43 +0000
@@ -64,7 +64,7 @@
 
 #else /* not MARKER_DEBUG */
 
-#define byte_char_debug_check(b,charpos,bytepos) do { } while (0)
+#define byte_char_debug_check(b, charpos, bytepos) do { } while (0)
 
 #endif /* MARKER_DEBUG */
  


reply via email to

[Prev in Thread] Current Thread [Next in Thread]