aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDmitry Antipov2013-03-15 11:23:49 +0400
committerDmitry Antipov2013-03-15 11:23:49 +0400
commitf258b4be0054dd0af7e52bbbbdbb776096ab3f8b (patch)
treea425ae33dfb8ab4498c3caf7a4ea3da16cabbdaa /src
parentf35ffe5e3714cecdc5d7ea4027339178393cb578 (diff)
downloademacs-f258b4be0054dd0af7e52bbbbdbb776096ab3f8b.tar.gz
emacs-f258b4be0054dd0af7e52bbbbdbb776096ab3f8b.zip
* region-cache.c (find_cache_boundary, move_cache_gap)
(insert_cache_boundary, delete_cache_boundaries, set_cache_region): Simplify debugging check and convert to eassert. Adjust comment. (pp_cache): Put under ENABLE_CHECKING.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog7
-rw-r--r--src/region-cache.c58
2 files changed, 27 insertions, 38 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 84a0cdcf6ec..228210a59cd 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,10 @@
12013-03-15 Dmitry Antipov <dmantipov@yandex.ru>
2
3 * region-cache.c (find_cache_boundary, move_cache_gap)
4 (insert_cache_boundary, delete_cache_boundaries, set_cache_region):
5 Simplify debugging check and convert to eassert. Adjust comment.
6 (pp_cache): Put under ENABLE_CHECKING.
7
12013-03-14 Eli Zaretskii <eliz@gnu.org> 82013-03-14 Eli Zaretskii <eliz@gnu.org>
2 9
3 * w32term.c (w32_read_socket) <WM_WINDOWPOSCHANGED>: Remove old 10 * w32term.c (w32_read_socket) <WM_WINDOWPOSCHANGED>: Remove old
diff --git a/src/region-cache.c b/src/region-cache.c
index 452a5b3a065..be7d50a50e4 100644
--- a/src/region-cache.c
+++ b/src/region-cache.c
@@ -190,10 +190,9 @@ find_cache_boundary (struct region_cache *c, ptrdiff_t pos)
190 } 190 }
191 191
192 /* Some testing. */ 192 /* Some testing. */
193 if (BOUNDARY_POS (c, low) > pos 193 eassert (!(BOUNDARY_POS (c, low) > pos
194 || (low + 1 < c->cache_len 194 || (low + 1 < c->cache_len
195 && BOUNDARY_POS (c, low + 1) <= pos)) 195 && BOUNDARY_POS (c, low + 1) <= pos)));
196 emacs_abort ();
197 196
198 return low; 197 return low;
199} 198}
@@ -214,14 +213,9 @@ move_cache_gap (struct region_cache *c, ptrdiff_t pos, ptrdiff_t min_size)
214 ptrdiff_t buffer_beg = c->buffer_beg; 213 ptrdiff_t buffer_beg = c->buffer_beg;
215 ptrdiff_t buffer_end = c->buffer_end; 214 ptrdiff_t buffer_end = c->buffer_end;
216 215
217 if (pos < 0
218 || pos > c->cache_len)
219 emacs_abort ();
220
221 /* We mustn't ever try to put the gap before the dummy start 216 /* We mustn't ever try to put the gap before the dummy start
222 boundary. That must always be start-relative. */ 217 boundary. That must always be start-relative. */
223 if (pos == 0) 218 eassert (0 < pos && pos <= c->cache_len);
224 emacs_abort ();
225 219
226 /* Need we move the gap right? */ 220 /* Need we move the gap right? */
227 while (gap_start < pos) 221 while (gap_start < pos)
@@ -288,26 +282,19 @@ static void
288insert_cache_boundary (struct region_cache *c, ptrdiff_t i, ptrdiff_t pos, 282insert_cache_boundary (struct region_cache *c, ptrdiff_t i, ptrdiff_t pos,
289 int value) 283 int value)
290{ 284{
291 /* i must be a valid cache index. */ 285 /* I must be a valid cache index, and we must never want
292 if (i < 0 || i > c->cache_len) 286 to insert something before the dummy first boundary. */
293 emacs_abort (); 287 eassert (0 < i && i <= c->cache_len);
294
295 /* We must never want to insert something before the dummy first
296 boundary. */
297 if (i == 0)
298 emacs_abort ();
299 288
300 /* We must only be inserting things in order. */ 289 /* We must only be inserting things in order. */
301 if (! (BOUNDARY_POS (c, i - 1) < pos 290 eassert ((BOUNDARY_POS (c, i - 1) < pos
302 && (i == c->cache_len 291 && (i == c->cache_len
303 || pos < BOUNDARY_POS (c, i)))) 292 || pos < BOUNDARY_POS (c, i))));
304 emacs_abort ();
305 293
306 /* The value must be different from the ones around it. However, we 294 /* The value must be different from the ones around it. However, we
307 temporarily create boundaries that establish the same value as 295 temporarily create boundaries that establish the same value as
308 the subsequent boundary, so we're not going to flag that case. */ 296 the subsequent boundary, so we're not going to flag that case. */
309 if (BOUNDARY_VALUE (c, i - 1) == value) 297 eassert (BOUNDARY_VALUE (c, i - 1) != value);
310 emacs_abort ();
311 298
312 move_cache_gap (c, i, 1); 299 move_cache_gap (c, i, 1);
313 300
@@ -328,18 +315,13 @@ delete_cache_boundaries (struct region_cache *c,
328 ptrdiff_t len = end - start; 315 ptrdiff_t len = end - start;
329 316
330 /* Gotta be in range. */ 317 /* Gotta be in range. */
331 if (start < 0 318 eassert (0 <= start && end <= c->cache_len);
332 || end > c->cache_len)
333 emacs_abort ();
334 319
335 /* Gotta be in order. */ 320 /* Gotta be in order. */
336 if (start > end) 321 eassert (start <= end);
337 emacs_abort ();
338 322
339 /* Can't delete the dummy entry. */ 323 /* Can't delete the dummy entry. */
340 if (start == 0 324 eassert (!(start == 0 && end >= 1));
341 && end >= 1)
342 emacs_abort ();
343 325
344 /* Minimize gap motion. If we're deleting nothing, do nothing. */ 326 /* Minimize gap motion. If we're deleting nothing, do nothing. */
345 if (len == 0) 327 if (len == 0)
@@ -378,11 +360,8 @@ static void
378set_cache_region (struct region_cache *c, 360set_cache_region (struct region_cache *c,
379 ptrdiff_t start, ptrdiff_t end, int value) 361 ptrdiff_t start, ptrdiff_t end, int value)
380{ 362{
381 if (start > end) 363 eassert (start <= end);
382 emacs_abort (); 364 eassert (c->buffer_beg <= start && end <= c->buffer_end);
383 if (start < c->buffer_beg
384 || end > c->buffer_end)
385 emacs_abort ();
386 365
387 /* Eliminate this case; then we can assume that start and end-1 are 366 /* Eliminate this case; then we can assume that start and end-1 are
388 both the locations of real characters in the buffer. */ 367 both the locations of real characters in the buffer. */
@@ -772,7 +751,8 @@ int region_cache_backward (struct buffer *buf, struct region_cache *c,
772 } 751 }
773} 752}
774 753
775 754#ifdef ENABLE_CHECKING
755
776/* Debugging: pretty-print a cache to the standard error output. */ 756/* Debugging: pretty-print a cache to the standard error output. */
777 757
778void pp_cache (struct region_cache *) EXTERNALLY_VISIBLE; 758void pp_cache (struct region_cache *) EXTERNALLY_VISIBLE;
@@ -803,3 +783,5 @@ pp_cache (struct region_cache *c)
803 fprintf (stderr, "%"pD"d : %d\n", pos, BOUNDARY_VALUE (c, i)); 783 fprintf (stderr, "%"pD"d : %d\n", pos, BOUNDARY_VALUE (c, i));
804 } 784 }
805} 785}
786
787#endif /* ENABLE_CHECKING */