From: Eli Zaretskii Date: Thu, 8 Jan 2015 13:46:23 +0000 (+0200) Subject: Fix fallout from "Qnil is zero" change in the display engine. (Bug#19535) X-Git-Tag: emacs-25.0.90~2605^2~21 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=daa18b5e85559ccea84bd9e8a5f8ac57cfa73189;p=emacs.git Fix fallout from "Qnil is zero" change in the display engine. (Bug#19535) src/xdisp.c (next_element_from_c_string): Use Lisp integer zero as the object. (set_cursor_from_row, try_cursor_movement, dump_glyph) (insert_left_trunc_glyphs, append_space_for_newline) (extend_face_to_end_of_line, highlight_trailing_whitespace) (find_row_edges, ROW_GLYPH_NEWLINE_P, Fmove_point_visually) (Fbidi_resolved_levels, produce_special_glyphs) (rows_from_pos_range, mouse_face_from_buffer_pos) (note_mouse_highlight): Use nil as the object for glyphs inserted by the display engine, and test with NILP instead of INTEGERP. src/w32fns.c (Fx_show_tip): Use NILP to test for glyphs inserted by the display engine. src/xfns.c (Fx_show_tip): Use NILP to test for glyphs inserted by the display engine. src/dispextern.h (struct glyph, struct it): Update comments for the OBJECT members. --- diff --git a/src/ChangeLog b/src/ChangeLog index d2ae0262171..21bdc81d797 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,26 @@ +2015-01-08 Eli Zaretskii + + * xdisp.c (next_element_from_c_string): Use Lisp integer zero as + the object. + (set_cursor_from_row, try_cursor_movement, dump_glyph) + (insert_left_trunc_glyphs, append_space_for_newline) + (extend_face_to_end_of_line, highlight_trailing_whitespace) + (find_row_edges, ROW_GLYPH_NEWLINE_P, Fmove_point_visually) + (Fbidi_resolved_levels, produce_special_glyphs) + (rows_from_pos_range, mouse_face_from_buffer_pos) + (note_mouse_highlight): Use nil as the object for glyphs inserted + by the display engine, and test with NILP instead of INTEGERP. + (Bug#19535) + + * w32fns.c (Fx_show_tip): Use NILP to test for glyphs inserted by + the display engine. + + * xfns.c (Fx_show_tip): Use NILP to test for glyphs inserted by + the display engine. + + * dispextern.h (struct glyph, struct it): Update comments for the + OBJECT members. + 2015-01-08 Paul Eggert Port new Lisp symbol init to x86 --with-wide-int diff --git a/src/dispextern.h b/src/dispextern.h index d717473f8c2..1a9aef103bd 100644 --- a/src/dispextern.h +++ b/src/dispextern.h @@ -389,10 +389,9 @@ struct glyph /* Lisp object source of this glyph. Currently either a buffer or a string, if the glyph was produced from characters which came from - a buffer or a string; or Lisp integer zero (a.k.a. "null object") - if the glyph was inserted by redisplay for its own purposes, such - as padding or truncation/continuation glyphs, or the - overlay-arrow glyphs on TTYs. */ + a buffer or a string; or nil if the glyph was inserted by + redisplay for its own purposes, such as padding, truncation, or + continuation glyphs, or the overlay-arrow glyphs on TTYs. */ Lisp_Object object; /* Width in pixels. */ @@ -2525,11 +2524,11 @@ struct it Object is normally the buffer which is being rendered, but it can also be a Lisp string in case the current display element comes from an overlay string or from a display string (before- or - after-string). It may also be nil when a C string is being - rendered, e.g., during mode-line or header-line update. It can - also be a cons cell of the form `(space ...)', when we produce a - stretch glyph from a `display' specification. Finally, it can be - a zero-valued Lisp integer, but only temporarily, when we are + after-string). It may also be a zero-valued Lisp integer when a + C string is being rendered, e.g., during mode-line or header-line + update. It can also be a cons cell of the form `(space ...)', + when we produce a stretch glyph from a `display' specification. + Finally, it can be nil, but only temporarily, when we are producing special glyphs for display purposes, like truncation and continuation glyphs, or blanks that extend each line to the edge of the window on a TTY. diff --git a/src/w32fns.c b/src/w32fns.c index 38571d3ec21..ced3d87dd66 100644 --- a/src/w32fns.c +++ b/src/w32fns.c @@ -6128,7 +6128,7 @@ Text larger than the specified size is clipped. */) place the cursor there. Don't include the width of this glyph. */ last = &row->glyphs[TEXT_AREA][row->used[TEXT_AREA] - 1]; - if (INTEGERP (last->object)) + if (NILP (last->object)) row_width -= last->pixel_width; } else @@ -6138,7 +6138,7 @@ Text larger than the specified size is clipped. */) Don't count that glyph. */ struct glyph *g = row->glyphs[TEXT_AREA]; - if (g->type == STRETCH_GLYPH && INTEGERP (g->object)) + if (g->type == STRETCH_GLYPH && NILP (g->object)) { row_width -= g->pixel_width; seen_reversed_p = 1; @@ -6187,7 +6187,7 @@ Text larger than the specified size is clipped. */) if (row->used[TEXT_AREA] && !row->reversed_p) { last = &row->glyphs[TEXT_AREA][row->used[TEXT_AREA] - 1]; - if (INTEGERP (last->object)) + if (NILP (last->object)) row_width -= last->pixel_width; } diff --git a/src/xdisp.c b/src/xdisp.c index 58a4f43be81..36babfa74db 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -7933,7 +7933,7 @@ next_element_from_c_string (struct it *it) eassert (!it->bidi_p || it->s == it->bidi_it.string.s); it->what = IT_CHARACTER; BYTEPOS (it->position) = CHARPOS (it->position) = 0; - it->object = Qnil; + it->object = make_number (0); /* With bidi reordering, the character to display might not be the character at IT_CHARPOS. BIDI_IT.FIRST_ELT non-zero means that @@ -14280,14 +14280,14 @@ set_cursor_from_row (struct window *w, struct glyph_row *row, if (!row->reversed_p) { while (glyph < end - && INTEGERP (glyph->object) + && NILP (glyph->object) && glyph->charpos < 0) { x += glyph->pixel_width; ++glyph; } while (end > glyph - && INTEGERP ((end - 1)->object) + && NILP ((end - 1)->object) /* CHARPOS is zero for blanks and stretch glyphs inserted by extend_face_to_end_of_line. */ && (end - 1)->charpos <= 0) @@ -14305,20 +14305,20 @@ set_cursor_from_row (struct window *w, struct glyph_row *row, glyph += row->used[TEXT_AREA] - 1; while (glyph > end + 1 - && INTEGERP (glyph->object) + && NILP (glyph->object) && glyph->charpos < 0) { --glyph; x -= glyph->pixel_width; } - if (INTEGERP (glyph->object) && glyph->charpos < 0) + if (NILP (glyph->object) && glyph->charpos < 0) --glyph; /* By default, in reversed rows we put the cursor on the rightmost (first in the reading order) glyph. */ for (g = end + 1; g < glyph; g++) x += g->pixel_width; while (end < glyph - && INTEGERP ((end + 1)->object) + && NILP ((end + 1)->object) && (end + 1)->charpos <= 0) ++end; glyph_before = glyph + 1; @@ -14349,7 +14349,7 @@ set_cursor_from_row (struct window *w, struct glyph_row *row, while (/* not marched to end of glyph row */ glyph < end /* glyph was not inserted by redisplay for internal purposes */ - && !INTEGERP (glyph->object)) + && !NILP (glyph->object)) { if (BUFFERP (glyph->object)) { @@ -14437,7 +14437,7 @@ set_cursor_from_row (struct window *w, struct glyph_row *row, ++glyph; } else if (glyph > end) /* row is reversed */ - while (!INTEGERP (glyph->object)) + while (!NILP (glyph->object)) { if (BUFFERP (glyph->object)) { @@ -14514,16 +14514,16 @@ set_cursor_from_row (struct window *w, struct glyph_row *row, && BUFFERP (glyph->object) && glyph->charpos == pt_old) && !(bpos_max <= pt_old && pt_old <= bpos_covered)) { - /* An empty line has a single glyph whose OBJECT is zero and + /* An empty line has a single glyph whose OBJECT is nil and whose CHARPOS is the position of a newline on that line. Note that on a TTY, there are more glyphs after that, which were produced by extend_face_to_end_of_line, but their CHARPOS is zero or negative. */ int empty_line_p = (row->reversed_p ? glyph > glyphs_end : glyph < glyphs_end) - && INTEGERP (glyph->object) && glyph->charpos > 0 + && NILP (glyph->object) && glyph->charpos > 0 /* On a TTY, continued and truncated rows also have a glyph at - their end whose OBJECT is zero and whose CHARPOS is + their end whose OBJECT is nil and whose CHARPOS is positive (the continuation and truncation glyphs), but such rows are obviously not "empty". */ && !(row->continued_p || row->truncated_on_right_p); @@ -14800,7 +14800,7 @@ set_cursor_from_row (struct window *w, struct glyph_row *row, && string_from_text_prop) /* this candidate is from newline and its position is not an exact match */ - || (INTEGERP (glyph->object) + || (NILP (glyph->object) && glyph->charpos != pt_old))))) return 0; /* If this candidate gives an exact match, use that. */ @@ -14809,7 +14809,7 @@ set_cursor_from_row (struct window *w, struct glyph_row *row, terminating newline of a line, and point is on that newline, it wins because it's an exact match. */ || (!row->continued_p - && INTEGERP (glyph->object) + && NILP (glyph->object) && glyph->charpos == 0 && pt_old == MATRIX_ROW_END_CHARPOS (row) - 1)) /* Otherwise, keep the candidate that comes from a row @@ -15652,7 +15652,7 @@ try_cursor_movement (Lisp_Object window, struct text_pos startp, int *scroll_ste exact_match_p = (BUFFERP (g->object) && g->charpos == PT) - || (INTEGERP (g->object) + || (NILP (g->object) && (g->charpos == PT || (g->charpos == 0 && endpos - 1 == PT))); } @@ -18506,7 +18506,7 @@ dump_glyph (struct glyph_row *row, struct glyph *glyph, int area) ? 'B' : (STRINGP (glyph->object) ? 'S' - : (INTEGERP (glyph->object) + : (NILP (glyph->object) ? '0' : '-'))), glyph->pixel_width, @@ -18529,7 +18529,7 @@ dump_glyph (struct glyph_row *row, struct glyph *glyph, int area) ? 'B' : (STRINGP (glyph->object) ? 'S' - : (INTEGERP (glyph->object) + : (NILP (glyph->object) ? '0' : '-'))), glyph->pixel_width, @@ -18550,7 +18550,7 @@ dump_glyph (struct glyph_row *row, struct glyph *glyph, int area) ? 'B' : (STRINGP (glyph->object) ? 'S' - : (INTEGERP (glyph->object) + : (NILP (glyph->object) ? '0' : '-'))), glyph->pixel_width, @@ -18571,7 +18571,7 @@ dump_glyph (struct glyph_row *row, struct glyph *glyph, int area) ? 'B' : (STRINGP (glyph->object) ? 'S' - : (INTEGERP (glyph->object) + : (NILP (glyph->object) ? '0' : '-'))), glyph->pixel_width, @@ -18671,7 +18671,7 @@ dump_glyph_row (struct glyph_row *row, int vpos, int glyphs) struct glyph *glyph = row->glyphs[area] + i; if (i == row->used[area] - 1 && area == TEXT_AREA - && INTEGERP (glyph->object) + && NILP (glyph->object) && glyph->type == CHAR_GLYPH && glyph->u.ch == ' ') { @@ -18901,7 +18901,7 @@ insert_left_trunc_glyphs (struct it *it) truncate_it.area = TEXT_AREA; truncate_it.glyph_row->used[TEXT_AREA] = 0; CHARPOS (truncate_it.position) = BYTEPOS (truncate_it.position) = -1; - truncate_it.object = make_number (0); + truncate_it.object = Qnil; produce_special_glyphs (&truncate_it, IT_TRUNCATION); /* Overwrite glyphs from IT with truncation glyphs. */ @@ -19184,7 +19184,7 @@ append_space_for_newline (struct it *it, int default_face_p) it->what = IT_CHARACTER; memset (&it->position, 0, sizeof it->position); - it->object = make_number (0); + it->object = Qnil; it->c = it->char_to_display = ' '; it->len = 1; @@ -19376,7 +19376,7 @@ extend_face_to_end_of_line (struct it *it) else it->face_id = face->id; it->start_of_box_run_p = 0; - append_stretch_glyph (it, make_number (0), stretch_width, + append_stretch_glyph (it, Qnil, stretch_width, it->ascent + it->descent, stretch_ascent); it->position = saved_pos; it->avoid_cursor_p = saved_avoid_cursor; @@ -19406,7 +19406,7 @@ extend_face_to_end_of_line (struct it *it) it->what = IT_CHARACTER; memset (&it->position, 0, sizeof it->position); - it->object = make_number (0); + it->object = Qnil; it->c = it->char_to_display = ' '; it->len = 1; @@ -19535,14 +19535,14 @@ highlight_trailing_whitespace (struct frame *f, struct glyph_row *row) { while (glyph >= start && glyph->type == CHAR_GLYPH - && INTEGERP (glyph->object)) + && NILP (glyph->object)) --glyph; } else { while (glyph <= start && glyph->type == CHAR_GLYPH - && INTEGERP (glyph->object)) + && NILP (glyph->object)) ++glyph; } @@ -19905,10 +19905,9 @@ find_row_edges (struct it *it, struct glyph_row *row, { start = r1->glyphs[TEXT_AREA]; end = start + r1->used[TEXT_AREA]; - /* Glyphs inserted by redisplay have an integer (zero) - as their object. */ + /* Glyphs inserted by redisplay have nil as their object. */ while (end > start - && INTEGERP ((end - 1)->object) + && NILP ((end - 1)->object) && (end - 1)->charpos <= 0) --end; if (end > start) @@ -19929,7 +19928,7 @@ find_row_edges (struct it *it, struct glyph_row *row, end = r1->glyphs[TEXT_AREA] - 1; start = end + r1->used[TEXT_AREA]; while (end < start - && INTEGERP ((end + 1)->object) + && NILP ((end + 1)->object) && (end + 1)->charpos <= 0) ++end; if (end < start) @@ -21082,7 +21081,7 @@ Value is the new character position of point. */) #define ROW_GLYPH_NEWLINE_P(ROW,GLYPH) \ (!(ROW)->continued_p \ - && INTEGERP ((GLYPH)->object) \ + && NILP ((GLYPH)->object) \ && (GLYPH)->type == CHAR_GLYPH \ && (GLYPH)->u.ch == ' ' \ && (GLYPH)->charpos >= 0 \ @@ -21124,7 +21123,7 @@ Value is the new character position of point. */) w->cursor.vpos = -1; return make_number (PT); } - else if (!INTEGERP (g->object) && !EQ (g->object, gpt->object)) + else if (!NILP (g->object) && !EQ (g->object, gpt->object)) { ptrdiff_t new_pos; @@ -21161,7 +21160,7 @@ Value is the new character position of point. */) return make_number (PT); } } - if (g == e || INTEGERP (g->object)) + if (g == e || NILP (g->object)) { if (row->truncated_on_left_p || row->truncated_on_right_p) goto simulate_display; @@ -21194,7 +21193,7 @@ Value is the new character position of point. */) EOB also has one glyph, but its charpos is -1. */ || (row->ends_at_zv_p && !row->reversed_p - && INTEGERP (g->object) + && NILP (g->object) && g->type == CHAR_GLYPH && g->u.ch == ' ')) { @@ -21232,7 +21231,7 @@ Value is the new character position of point. */) || g->type == STRETCH_GLYPH || (row->ends_at_zv_p && row->reversed_p - && INTEGERP (g->object) + && NILP (g->object) && g->type == CHAR_GLYPH && g->u.ch == ' ')) { @@ -21596,13 +21595,13 @@ Emacs UBA implementation, in particular with the test suite. */) /* Skip over glyphs at the start of the row that was generated by redisplay for its own needs. */ while (g < e - && INTEGERP (g->object) + && NILP (g->object) && g->charpos < 0) g++; g1 = g; /* Count the "interesting" glyphs in this row. */ - for (nglyphs = 0; g < e && !INTEGERP (g->object); g++) + for (nglyphs = 0; g < e && !NILP (g->object); g++) nglyphs++; /* Create and fill the array. */ @@ -21615,11 +21614,11 @@ Emacs UBA implementation, in particular with the test suite. */) g = row->glyphs[TEXT_AREA] + row->used[TEXT_AREA] - 1; e = row->glyphs[TEXT_AREA] - 1; while (g > e - && INTEGERP (g->object) + && NILP (g->object) && g->charpos < 0) g--; g1 = g; - for (nglyphs = 0; g > e && !INTEGERP (g->object); g--) + for (nglyphs = 0; g > e && !NILP (g->object); g--) nglyphs++; levels = make_uninit_vector (nglyphs); for (i = 0; g1 > g; i++, g1--) @@ -25944,7 +25943,7 @@ produce_special_glyphs (struct it *it, enum display_element_type what) GLYPH glyph; temp_it = *it; - temp_it.object = make_number (0); + temp_it.object = Qnil; memset (&temp_it.current, 0, sizeof temp_it.current); if (what == IT_CONTINUATION) @@ -26007,7 +26006,7 @@ produce_special_glyphs (struct it *it, enum display_element_type what) (((temp_it.ascent + temp_it.descent) * FONT_BASE (font)) / FONT_HEIGHT (font)); - append_stretch_glyph (&temp_it, make_number (0), stretch_width, + append_stretch_glyph (&temp_it, Qnil, stretch_width, temp_it.ascent + temp_it.descent, stretch_ascent); } @@ -28182,7 +28181,7 @@ rows_from_pos_range (struct window *w, while (g < e) { - if (((BUFFERP (g->object) || INTEGERP (g->object)) + if (((BUFFERP (g->object) || NILP (g->object)) && start_charpos <= g->charpos && g->charpos < end_charpos) /* A glyph that comes from DISP_STRING is by definition to be highlighted. */ @@ -28237,7 +28236,7 @@ rows_from_pos_range (struct window *w, while (g < e) { - if (((BUFFERP (g->object) || INTEGERP (g->object)) + if (((BUFFERP (g->object) || NILP (g->object)) && ((start_charpos <= g->charpos && g->charpos < end_charpos) /* If the buffer position of the first glyph in the row is equal to END_CHARPOS, it means @@ -28319,7 +28318,7 @@ mouse_face_from_buffer_pos (Lisp_Object window, { struct glyph *beg = prev->glyphs[TEXT_AREA]; glyph = beg + prev->used[TEXT_AREA]; - while (--glyph >= beg && INTEGERP (glyph->object)); + while (--glyph >= beg && NILP (glyph->object)); if (glyph < beg || !(EQ (glyph->object, before_string) || EQ (glyph->object, disp_string))) @@ -28383,7 +28382,7 @@ mouse_face_from_buffer_pos (Lisp_Object window, /* Skip truncation glyphs at the start of the glyph row. */ if (MATRIX_ROW_DISPLAYS_TEXT_P (r1)) for (; glyph < end - && INTEGERP (glyph->object) + && NILP (glyph->object) && glyph->charpos < 0; ++glyph) x += glyph->pixel_width; @@ -28392,7 +28391,7 @@ mouse_face_from_buffer_pos (Lisp_Object window, or DISP_STRING, and the first glyph from buffer whose position is between START_CHARPOS and END_CHARPOS. */ for (; glyph < end - && !INTEGERP (glyph->object) + && !NILP (glyph->object) && !EQ (glyph->object, disp_string) && !(BUFFERP (glyph->object) && (glyph->charpos >= start_charpos @@ -28434,7 +28433,7 @@ mouse_face_from_buffer_pos (Lisp_Object window, /* Skip truncation glyphs at the start of the glyph row. */ if (MATRIX_ROW_DISPLAYS_TEXT_P (r1)) for (; glyph > end - && INTEGERP (glyph->object) + && NILP (glyph->object) && glyph->charpos < 0; --glyph) ; @@ -28443,7 +28442,7 @@ mouse_face_from_buffer_pos (Lisp_Object window, or DISP_STRING, and the first glyph from buffer whose position is between START_CHARPOS and END_CHARPOS. */ for (; glyph > end - && !INTEGERP (glyph->object) + && !NILP (glyph->object) && !EQ (glyph->object, disp_string) && !(BUFFERP (glyph->object) && (glyph->charpos >= start_charpos @@ -28500,7 +28499,7 @@ mouse_face_from_buffer_pos (Lisp_Object window, row, and also blanks and stretch glyphs inserted by extend_face_to_end_of_line. */ while (end > glyph - && INTEGERP ((end - 1)->object)) + && NILP ((end - 1)->object)) --end; /* Scan the rest of the glyph row from the end, looking for the first glyph that comes from BEFORE_STRING, AFTER_STRING, or @@ -28508,7 +28507,7 @@ mouse_face_from_buffer_pos (Lisp_Object window, and END_CHARPOS */ for (--end; end > glyph - && !INTEGERP (end->object) + && !NILP (end->object) && !EQ (end->object, disp_string) && !(BUFFERP (end->object) && (end->charpos >= start_charpos @@ -28546,7 +28545,7 @@ mouse_face_from_buffer_pos (Lisp_Object window, x = r2->x; end++; while (end < glyph - && INTEGERP (end->object)) + && NILP (end->object)) { x += end->pixel_width; ++end; @@ -28557,7 +28556,7 @@ mouse_face_from_buffer_pos (Lisp_Object window, and END_CHARPOS */ for ( ; end < glyph - && !INTEGERP (end->object) + && !NILP (end->object) && !EQ (end->object, disp_string) && !(BUFFERP (end->object) && (end->charpos >= start_charpos @@ -29489,12 +29488,12 @@ note_mouse_highlight (struct frame *f, int x, int y) if (glyph == NULL || area != TEXT_AREA || !MATRIX_ROW_DISPLAYS_TEXT_P (MATRIX_ROW (w->current_matrix, vpos)) - /* Glyph's OBJECT is an integer for glyphs inserted by the + /* Glyph's OBJECT is nil for glyphs inserted by the display engine for its internal purposes, like truncation and continuation glyphs and blanks beyond the end of line's text on text terminals. If we are over such a glyph, we are not over any text. */ - || INTEGERP (glyph->object) + || NILP (glyph->object) /* R2L rows have a stretch glyph at their front, which stands for no text, whereas L2R rows have no glyphs at all beyond the end of text. Treat such stretch glyphs diff --git a/src/xfns.c b/src/xfns.c index d4f96c61b07..4a417526dcd 100644 --- a/src/xfns.c +++ b/src/xfns.c @@ -5494,7 +5494,7 @@ Text larger than the specified size is clipped. */) if (!row->reversed_p) { last = &row->glyphs[TEXT_AREA][row->used[TEXT_AREA] - 1]; - if (INTEGERP (last->object)) + if (NILP (last->object)) row_width -= last->pixel_width; } else @@ -5504,7 +5504,7 @@ Text larger than the specified size is clipped. */) Don't count that glyph. */ struct glyph *g = row->glyphs[TEXT_AREA]; - if (g->type == STRETCH_GLYPH && INTEGERP (g->object)) + if (g->type == STRETCH_GLYPH && NILP (g->object)) { row_width -= g->pixel_width; seen_reversed_p = 1; @@ -5548,7 +5548,7 @@ Text larger than the specified size is clipped. */) if (row->used[TEXT_AREA] && !row->reversed_p) { last = &row->glyphs[TEXT_AREA][row->used[TEXT_AREA] - 1]; - if (INTEGERP (last->object)) + if (NILP (last->object)) row_width -= last->pixel_width; }