+2011-06-22 Paul Eggert <eggert@cs.ucla.edu>
+
+ GLYPH_DEBUG fixes
+ The following patches are for when GLYPH_DEBUG && !XASSERT.
+ * dispextern.h (trace_redisplay_p, dump_glyph_string):
+ * dispnew.c (flush_stdout):
+ * xdisp.c (dump_glyph_row, dump_glyph_matrix, dump_glyph):
+ Mark as externally visible.
+ * dispnew.c (check_window_matrix_pointers): Now static.
+ * dispnew.c (window_to_frame_vpos):
+ * xfns.c (unwind_create_frame):
+ * xterm.c (x_check_font): Remove unused local.
+ * scroll.c (CHECK_BOUNDS):
+ * xfaces.c (cache_fache): Rename local to avoid shadowing.
+ * xfns.c, w32fns.c (image_cache_refcount, dpyinfo_refcount): Now static.
+ * xdisp.c (check_window_end): Now a no-op if !XASSERTS.
+ (debug_first_unchanged_at_end_vpos, debug_last_unchanged_at_beg_vpos)
+ (debug_dvpos, debug_dy, debug_delta, debug_delta_bytes, debug_end_vpos):
+ Now static.
+ (debug_method_add): Use va_list and vsprintf rather than relying
+ on undefined behavior with wrong number of arguments.
+ (dump_glyph, dump_glyph_row, Fdump_glyph_matrix):
+ Don't assume ptrdiff_t and EMACS_INT are the same width as int.
+ In this code, it's OK to assume C99 behavior for ptrdiff_t formats
+ since we're not interested in debugging glyphs with old libraries.
+ * xfaces.c (cache_face): Move debugging code earlier; this pacifies
+ GCC 4.6.0's static checking.
+
2011-06-22 Paul Eggert <eggert@cs.ucla.edu>
Integer overflow and signedness fixes (Bug#8873).
#endif /* not 0 */
-#if GLYPH_DEBUG
+#if GLYPH_DEBUG && XASSERTS
/* Check that the window end of window W is what we expect it
to be---the last row in the current matrix displaying text. */
#define CHECK_WINDOW_END(W) check_window_end ((W))
-#else /* not GLYPH_DEBUG */
+#else
#define CHECK_WINDOW_END(W) (void) 0
-#endif /* not GLYPH_DEBUG */
+#endif
\f
/* First and last unchanged row for try_window_id. */
-int debug_first_unchanged_at_end_vpos;
-int debug_last_unchanged_at_beg_vpos;
+static int debug_first_unchanged_at_end_vpos;
+static int debug_last_unchanged_at_beg_vpos;
/* Delta vpos and y. */
-int debug_dvpos, debug_dy;
+static int debug_dvpos, debug_dy;
/* Delta in characters and bytes for try_window_id. */
-EMACS_INT debug_delta, debug_delta_bytes;
+static EMACS_INT debug_delta, debug_delta_bytes;
/* Values of window_end_pos and window_end_vpos at the end of
try_window_id. */
-EMACS_INT debug_end_vpos;
+static EMACS_INT debug_end_vpos;
/* Append a string to W->desired_matrix->method. FMT is a printf
- format string. A1...A9 are a supplement for a variable-length
- argument list. If trace_redisplay_p is non-zero also printf the
+ format string. If trace_redisplay_p is non-zero also printf the
resulting string to stderr. */
+static void debug_method_add (struct window *, char const *, ...)
+ ATTRIBUTE_FORMAT_PRINTF (2, 3);
+
static void
-debug_method_add (w, fmt, a1, a2, a3, a4, a5, a6, a7, a8, a9)
- struct window *w;
- char *fmt;
- int a1, a2, a3, a4, a5, a6, a7, a8, a9;
+debug_method_add (struct window *w, char const *fmt, ...)
{
char buffer[512];
char *method = w->desired_matrix->method;
int len = strlen (method);
int size = sizeof w->desired_matrix->method;
int remaining = size - len - 1;
+ va_list ap;
- sprintf (buffer, fmt, a1, a2, a3, a4, a5, a6, a7, a8, a9);
+ va_start (ap, fmt);
+ vsprintf (buffer, fmt, ap);
+ va_end (ap);
if (len && remaining)
{
method[len] = '|';
#if GLYPH_DEBUG
-void dump_glyph_row (struct glyph_row *, int, int);
-void dump_glyph_matrix (struct glyph_matrix *, int);
-void dump_glyph (struct glyph_row *, struct glyph *, int);
+void dump_glyph_row (struct glyph_row *, int, int) EXTERNALLY_VISIBLE;
+void dump_glyph_matrix (struct glyph_matrix *, int) EXTERNALLY_VISIBLE;
+void dump_glyph (struct glyph_row *, struct glyph *, int) EXTERNALLY_VISIBLE;
/* Dump the contents of glyph matrix MATRIX on stderr.
if (glyph->type == CHAR_GLYPH)
{
fprintf (stderr,
- " %5d %4c %6d %c %3d 0x%05x %c %4d %1.1d%1.1d\n",
+ " %5td %4c %6"pI"d %c %3d 0x%05x %c %4d %1.1d%1.1d\n",
glyph - row->glyphs[TEXT_AREA],
'C',
glyph->charpos,
else if (glyph->type == STRETCH_GLYPH)
{
fprintf (stderr,
- " %5d %4c %6d %c %3d 0x%05x %c %4d %1.1d%1.1d\n",
+ " %5td %4c %6"pI"d %c %3d 0x%05x %c %4d %1.1d%1.1d\n",
glyph - row->glyphs[TEXT_AREA],
'S',
glyph->charpos,
else if (glyph->type == IMAGE_GLYPH)
{
fprintf (stderr,
- " %5d %4c %6d %c %3d 0x%05x %c %4d %1.1d%1.1d\n",
+ " %5td %4c %6"pI"d %c %3d 0x%05x %c %4d %1.1d%1.1d\n",
glyph - row->glyphs[TEXT_AREA],
'I',
glyph->charpos,
else if (glyph->type == COMPOSITE_GLYPH)
{
fprintf (stderr,
- " %5d %4c %6d %c %3d 0x%05x",
+ " %5td %4c %6"pI"d %c %3d 0x%05x",
glyph - row->glyphs[TEXT_AREA],
'+',
glyph->charpos,
fprintf (stderr, "Row Start End Used oE><\\CTZFesm X Y W H V A P\n");
fprintf (stderr, "======================================================================\n");
- fprintf (stderr, "%3d %5d %5d %4d %1.1d%1.1d%1.1d%1.1d\
+ fprintf (stderr, "%3d %5"pI"d %5"pI"d %4d %1.1d%1.1d%1.1d%1.1d\
%1.1d%1.1d%1.1d%1.1d%1.1d%1.1d%1.1d%1.1d %4d %4d %4d %4d %4d %4d %4d\n",
vpos,
MATRIX_ROW_START_CHARPOS (row),
fprintf (stderr, "%9d %5d\t%5d\n", row->start.overlay_string_index,
row->end.overlay_string_index,
row->continuation_lines_width);
- fprintf (stderr, "%9d %5d\n",
+ fprintf (stderr, "%9"pI"d %5"pI"d\n",
CHARPOS (row->start.string_pos),
CHARPOS (row->end.string_pos));
fprintf (stderr, "%9d %5d\n", row->start.dpvec_index,
struct window *w = XWINDOW (selected_window);
struct buffer *buffer = XBUFFER (w->buffer);
- fprintf (stderr, "PT = %d, BEGV = %d. ZV = %d\n",
+ fprintf (stderr, "PT = %"pI"d, BEGV = %"pI"d. ZV = %"pI"d\n",
BUF_PT (buffer), BUF_BEGV (buffer), BUF_ZV (buffer));
fprintf (stderr, "Cursor x = %d, y = %d, hpos = %d, vpos = %d\n",
w->cursor.x, w->cursor.y, w->cursor.hpos, w->cursor.vpos);