diff options
| author | Eli Zaretskii | 2011-11-12 13:56:57 +0200 |
|---|---|---|
| committer | Eli Zaretskii | 2011-11-12 13:56:57 +0200 |
| commit | 7a7270ddb6e2a0b5f8c7404277a46272d80a8100 (patch) | |
| tree | b9e8782cc3e3df961e821a5e8648f2e68834e601 /src | |
| parent | 1e5b2111b6ebfa6f8e244add939de453e9feafe6 (diff) | |
| download | emacs-7a7270ddb6e2a0b5f8c7404277a46272d80a8100.tar.gz emacs-7a7270ddb6e2a0b5f8c7404277a46272d80a8100.zip | |
Verify glyph row's hash values.
src/dispnew.c (verify_row_hash) [XASSERTS]: New function.
(adjust_glyph_matrix, row_equal_p): Use it in xassert to verify
that the hash value of glyph rows is correct.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 3 | ||||
| -rw-r--r-- | src/dispnew.c | 23 |
2 files changed, 26 insertions, 0 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 71c2ff3131e..286896be6e3 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -2,6 +2,9 @@ | |||
| 2 | 2 | ||
| 3 | * dispnew.c (scrolling_window): Fix incorrect indices in accessing | 3 | * dispnew.c (scrolling_window): Fix incorrect indices in accessing |
| 4 | current_matrix and desired_matrix. (Bug#9990) | 4 | current_matrix and desired_matrix. (Bug#9990) |
| 5 | (verify_row_hash) [XASSERTS]: New function. | ||
| 6 | (adjust_glyph_matrix, row_equal_p): Use it in xassert to verify | ||
| 7 | that the hash value of glyph rows is correct. | ||
| 5 | 8 | ||
| 6 | 2011-11-12 Martin Rudalics <rudalics@gmx.at> | 9 | 2011-11-12 Martin Rudalics <rudalics@gmx.at> |
| 7 | 10 | ||
diff --git a/src/dispnew.c b/src/dispnew.c index dafb8127eb3..7b594c5b4e8 100644 --- a/src/dispnew.c +++ b/src/dispnew.c | |||
| @@ -429,6 +429,25 @@ margin_glyphs_to_reserve (struct window *w, int total_glyphs, Lisp_Object margin | |||
| 429 | return n; | 429 | return n; |
| 430 | } | 430 | } |
| 431 | 431 | ||
| 432 | #if XASSERTS | ||
| 433 | /* Return non-zero if ROW's hash value is correct, zero if not. */ | ||
| 434 | int | ||
| 435 | verify_row_hash (struct glyph_row *row) | ||
| 436 | { | ||
| 437 | int area, k; | ||
| 438 | unsigned row_hash = 0; | ||
| 439 | |||
| 440 | for (area = LEFT_MARGIN_AREA; area < LAST_AREA; ++area) | ||
| 441 | for (k = 0; k < row->used[area]; ++k) | ||
| 442 | row_hash = ((((row_hash << 4) + (row_hash >> 24)) & 0x0fffffff) | ||
| 443 | + row->glyphs[area][k].u.val | ||
| 444 | + row->glyphs[area][k].face_id | ||
| 445 | + row->glyphs[area][k].padding_p | ||
| 446 | + (row->glyphs[area][k].type << 2)); | ||
| 447 | |||
| 448 | return row_hash == row->hash; | ||
| 449 | } | ||
| 450 | #endif | ||
| 432 | 451 | ||
| 433 | /* Adjust glyph matrix MATRIX on window W or on a frame to changed | 452 | /* Adjust glyph matrix MATRIX on window W or on a frame to changed |
| 434 | window sizes. | 453 | window sizes. |
| @@ -600,6 +619,7 @@ adjust_glyph_matrix (struct window *w, struct glyph_matrix *matrix, int x, int y | |||
| 600 | row->glyphs[LAST_AREA] | 619 | row->glyphs[LAST_AREA] |
| 601 | = row->glyphs[LEFT_MARGIN_AREA] + dim.width; | 620 | = row->glyphs[LEFT_MARGIN_AREA] + dim.width; |
| 602 | } | 621 | } |
| 622 | xassert (!row->enabled_p || verify_row_hash (row)); | ||
| 603 | ++row; | 623 | ++row; |
| 604 | } | 624 | } |
| 605 | } | 625 | } |
| @@ -1271,6 +1291,9 @@ line_draw_cost (struct glyph_matrix *matrix, int vpos) | |||
| 1271 | static inline int | 1291 | static inline int |
| 1272 | row_equal_p (struct glyph_row *a, struct glyph_row *b, int mouse_face_p) | 1292 | row_equal_p (struct glyph_row *a, struct glyph_row *b, int mouse_face_p) |
| 1273 | { | 1293 | { |
| 1294 | xassert (verify_row_hash (a)); | ||
| 1295 | xassert (verify_row_hash (b)); | ||
| 1296 | |||
| 1274 | if (a == b) | 1297 | if (a == b) |
| 1275 | return 1; | 1298 | return 1; |
| 1276 | else if (a->hash != b->hash) | 1299 | else if (a->hash != b->hash) |