aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog7
-rw-r--r--src/font.c48
-rw-r--r--src/font.h6
-rw-r--r--src/fontset.c6
-rw-r--r--src/w32font.c9
-rw-r--r--src/xfont.c2
-rw-r--r--src/xftfont.c3
7 files changed, 36 insertions, 45 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index e45b4de48d9..eb19fad9abe 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,5 +1,12 @@
12012-08-15 Dmitry Antipov <dmantipov@yandex.ru> 12012-08-15 Dmitry Antipov <dmantipov@yandex.ru>
2 2
3 Generalize and cleanup font subsystem checks.
4 * font.h (FONT_DEBUG, font_assert): Remove.
5 * font.c, fontset.c, w32font.c, xfont.c, xftfont.c: Change
6 font_assert to eassert. Use eassert where appropriate.
7
82012-08-15 Dmitry Antipov <dmantipov@yandex.ru>
9
3 * gtkutil.c (xg_get_font): Use pango_units_to_double. 10 * gtkutil.c (xg_get_font): Use pango_units_to_double.
4 11
52012-08-15 Chong Yidong <cyd@gnu.org> 122012-08-15 Chong Yidong <cyd@gnu.org>
diff --git a/src/font.c b/src/font.c
index 4520d9bc9a2..c3040b8aa3f 100644
--- a/src/font.c
+++ b/src/font.c
@@ -290,7 +290,7 @@ font_pixel_size (FRAME_PTR f, Lisp_Object spec)
290 return XINT (size); 290 return XINT (size);
291 if (NILP (size)) 291 if (NILP (size))
292 return 0; 292 return 0;
293 font_assert (FLOATP (size)); 293 eassert (FLOATP (size));
294 point_size = XFLOAT_DATA (size); 294 point_size = XFLOAT_DATA (size);
295 val = AREF (spec, FONT_DPI_INDEX); 295 val = AREF (spec, FONT_DPI_INDEX);
296 if (INTEGERP (val)) 296 if (INTEGERP (val))
@@ -354,8 +354,7 @@ font_style_to_value (enum font_property_index prop, Lisp_Object val, int noerror
354 } 354 }
355 if (! noerror) 355 if (! noerror)
356 return -1; 356 return -1;
357 if (len == 255) 357 eassert (len < 255);
358 abort ();
359 elt = Fmake_vector (make_number (2), make_number (100)); 358 elt = Fmake_vector (make_number (2), make_number (100));
360 ASET (elt, 1, val); 359 ASET (elt, 1, val);
361 args[0] = table; 360 args[0] = table;
@@ -404,10 +403,10 @@ font_style_symbolic (Lisp_Object font, enum font_property_index prop, int for_fa
404 table = AREF (font_style_table, prop - FONT_WEIGHT_INDEX); 403 table = AREF (font_style_table, prop - FONT_WEIGHT_INDEX);
405 CHECK_VECTOR (table); 404 CHECK_VECTOR (table);
406 i = XINT (val) & 0xFF; 405 i = XINT (val) & 0xFF;
407 font_assert (((i >> 4) & 0xF) < ASIZE (table)); 406 eassert (((i >> 4) & 0xF) < ASIZE (table));
408 elt = AREF (table, ((i >> 4) & 0xF)); 407 elt = AREF (table, ((i >> 4) & 0xF));
409 CHECK_VECTOR (elt); 408 CHECK_VECTOR (elt);
410 font_assert ((i & 0xF) + 1 < ASIZE (elt)); 409 eassert ((i & 0xF) + 1 < ASIZE (elt));
411 elt = (for_face ? AREF (elt, 1) : AREF (elt, (i & 0xF) + 1)); 410 elt = (for_face ? AREF (elt, 1) : AREF (elt, (i & 0xF) + 1));
412 CHECK_SYMBOL (elt); 411 CHECK_SYMBOL (elt);
413 return elt; 412 return elt;
@@ -1076,7 +1075,7 @@ font_parse_xlfd (char *name, ptrdiff_t len, Lisp_Object font)
1076 { 1075 {
1077 double point_size = -1; 1076 double point_size = -1;
1078 1077
1079 font_assert (FONT_SPEC_P (font)); 1078 eassert (FONT_SPEC_P (font));
1080 p = f[XLFD_POINT_INDEX]; 1079 p = f[XLFD_POINT_INDEX];
1081 if (*p == '[') 1080 if (*p == '[')
1082 point_size = parse_matrix (p); 1081 point_size = parse_matrix (p);
@@ -1197,7 +1196,7 @@ font_unparse_xlfd (Lisp_Object font, int pixel_size, char *name, int nbytes)
1197 Lisp_Object val; 1196 Lisp_Object val;
1198 int i, j, len; 1197 int i, j, len;
1199 1198
1200 font_assert (FONTP (font)); 1199 eassert (FONTP (font));
1201 1200
1202 for (i = FONT_FOUNDRY_INDEX, j = XLFD_FOUNDRY_INDEX; i <= FONT_REGISTRY_INDEX; 1201 for (i = FONT_FOUNDRY_INDEX, j = XLFD_FOUNDRY_INDEX; i <= FONT_REGISTRY_INDEX;
1203 i++, j++) 1202 i++, j++)
@@ -1248,7 +1247,7 @@ font_unparse_xlfd (Lisp_Object font, int pixel_size, char *name, int nbytes)
1248 } 1247 }
1249 1248
1250 val = AREF (font, FONT_SIZE_INDEX); 1249 val = AREF (font, FONT_SIZE_INDEX);
1251 font_assert (NUMBERP (val) || NILP (val)); 1250 eassert (NUMBERP (val) || NILP (val));
1252 if (INTEGERP (val)) 1251 if (INTEGERP (val))
1253 { 1252 {
1254 EMACS_INT v = XINT (val); 1253 EMACS_INT v = XINT (val);
@@ -1585,8 +1584,7 @@ font_unparse_fcname (Lisp_Object font, int pixel_size, char *name, int nbytes)
1585 } 1584 }
1586 else 1585 else
1587 { 1586 {
1588 if (! FLOATP (val)) 1587 eassert (FLOATP (val));
1589 abort ();
1590 pixel_size = -1; 1588 pixel_size = -1;
1591 point_size = (int) XFLOAT_DATA (val); 1589 point_size = (int) XFLOAT_DATA (val);
1592 } 1590 }
@@ -2540,7 +2538,7 @@ font_finish_cache (FRAME_PTR f, struct font_driver *driver)
2540 val = XCDR (cache); 2538 val = XCDR (cache);
2541 while (CONSP (val) && ! EQ (XCAR (XCAR (val)), driver->type)) 2539 while (CONSP (val) && ! EQ (XCAR (XCAR (val)), driver->type))
2542 cache = val, val = XCDR (val); 2540 cache = val, val = XCDR (val);
2543 font_assert (! NILP (val)); 2541 eassert (! NILP (val));
2544 tmp = XCDR (XCAR (val)); 2542 tmp = XCDR (XCAR (val));
2545 XSETCAR (tmp, make_number (XINT (XCAR (tmp)) - 1)); 2543 XSETCAR (tmp, make_number (XINT (XCAR (tmp)) - 1));
2546 if (XINT (XCAR (tmp)) == 0) 2544 if (XINT (XCAR (tmp)) == 0)
@@ -2557,9 +2555,9 @@ font_get_cache (FRAME_PTR f, struct font_driver *driver)
2557 Lisp_Object val = driver->get_cache (f); 2555 Lisp_Object val = driver->get_cache (f);
2558 Lisp_Object type = driver->type; 2556 Lisp_Object type = driver->type;
2559 2557
2560 font_assert (CONSP (val)); 2558 eassert (CONSP (val));
2561 for (val = XCDR (val); ! EQ (XCAR (XCAR (val)), type); val = XCDR (val)); 2559 for (val = XCDR (val); ! EQ (XCAR (XCAR (val)), type); val = XCDR (val));
2562 font_assert (CONSP (val)); 2560 eassert (CONSP (val));
2563 /* VAL = ((DRIVER-TYPE NUM-FRAMES FONT-CACHE-DATA ...) ...) */ 2561 /* VAL = ((DRIVER-TYPE NUM-FRAMES FONT-CACHE-DATA ...) ...) */
2564 val = XCDR (XCAR (val)); 2562 val = XCDR (XCAR (val));
2565 return val; 2563 return val;
@@ -2596,7 +2594,7 @@ font_clear_cache (FRAME_PTR f, Lisp_Object cache, struct font_driver *driver)
2596 2594
2597 if (! NILP (AREF (val, FONT_TYPE_INDEX))) 2595 if (! NILP (AREF (val, FONT_TYPE_INDEX)))
2598 { 2596 {
2599 font_assert (font && driver == font->driver); 2597 eassert (font && driver == font->driver);
2600 driver->close (f, font); 2598 driver->close (f, font);
2601 num_fonts--; 2599 num_fonts--;
2602 } 2600 }
@@ -2706,7 +2704,7 @@ font_list_entities (Lisp_Object frame, Lisp_Object spec)
2706 int need_filtering = 0; 2704 int need_filtering = 0;
2707 int i; 2705 int i;
2708 2706
2709 font_assert (FONT_SPEC_P (spec)); 2707 eassert (FONT_SPEC_P (spec));
2710 2708
2711 if (INTEGERP (AREF (spec, FONT_SIZE_INDEX))) 2709 if (INTEGERP (AREF (spec, FONT_SIZE_INDEX)))
2712 size = XINT (AREF (spec, FONT_SIZE_INDEX)); 2710 size = XINT (AREF (spec, FONT_SIZE_INDEX));
@@ -2826,7 +2824,7 @@ font_open_entity (FRAME_PTR f, Lisp_Object entity, int pixel_size)
2826 int min_width, height; 2824 int min_width, height;
2827 int scaled_pixel_size = pixel_size; 2825 int scaled_pixel_size = pixel_size;
2828 2826
2829 font_assert (FONT_ENTITY_P (entity)); 2827 eassert (FONT_ENTITY_P (entity));
2830 size = AREF (entity, FONT_SIZE_INDEX); 2828 size = AREF (entity, FONT_SIZE_INDEX);
2831 if (XINT (size) != 0) 2829 if (XINT (size) != 0)
2832 scaled_pixel_size = pixel_size = XINT (size); 2830 scaled_pixel_size = pixel_size = XINT (size);
@@ -2903,7 +2901,7 @@ font_close_object (FRAME_PTR f, Lisp_Object font_object)
2903 FONT_ADD_LOG ("close", font_object, Qnil); 2901 FONT_ADD_LOG ("close", font_object, Qnil);
2904 font->driver->close (f, font); 2902 font->driver->close (f, font);
2905#ifdef HAVE_WINDOW_SYSTEM 2903#ifdef HAVE_WINDOW_SYSTEM
2906 font_assert (FRAME_X_DISPLAY_INFO (f)->n_fonts); 2904 eassert (FRAME_X_DISPLAY_INFO (f)->n_fonts);
2907 FRAME_X_DISPLAY_INFO (f)->n_fonts--; 2905 FRAME_X_DISPLAY_INFO (f)->n_fonts--;
2908#endif 2906#endif
2909 num_fonts--; 2907 num_fonts--;
@@ -2933,7 +2931,7 @@ font_has_char (FRAME_PTR f, Lisp_Object font, int c)
2933 return driver_list->driver->has_char (font, c); 2931 return driver_list->driver->has_char (font, c);
2934 } 2932 }
2935 2933
2936 font_assert (FONT_OBJECT_P (font)); 2934 eassert (FONT_OBJECT_P (font));
2937 fontp = XFONT_OBJECT (font); 2935 fontp = XFONT_OBJECT (font);
2938 if (fontp->driver->has_char) 2936 if (fontp->driver->has_char)
2939 { 2937 {
@@ -2953,7 +2951,7 @@ font_encode_char (Lisp_Object font_object, int c)
2953{ 2951{
2954 struct font *font; 2952 struct font *font;
2955 2953
2956 font_assert (FONT_OBJECT_P (font_object)); 2954 eassert (FONT_OBJECT_P (font_object));
2957 font = XFONT_OBJECT (font_object); 2955 font = XFONT_OBJECT (font_object);
2958 return font->driver->encode_char (font, c); 2956 return font->driver->encode_char (font, c);
2959} 2957}
@@ -2964,7 +2962,7 @@ font_encode_char (Lisp_Object font_object, int c)
2964Lisp_Object 2962Lisp_Object
2965font_get_name (Lisp_Object font_object) 2963font_get_name (Lisp_Object font_object)
2966{ 2964{
2967 font_assert (FONT_OBJECT_P (font_object)); 2965 eassert (FONT_OBJECT_P (font_object));
2968 return AREF (font_object, FONT_NAME_INDEX); 2966 return AREF (font_object, FONT_NAME_INDEX);
2969} 2967}
2970 2968
@@ -3250,10 +3248,8 @@ font_open_for_lface (FRAME_PTR f, Lisp_Object entity, Lisp_Object *attrs, Lisp_O
3250 { 3248 {
3251 struct face *def = FACE_FROM_ID (f, DEFAULT_FACE_ID); 3249 struct face *def = FACE_FROM_ID (f, DEFAULT_FACE_ID);
3252 Lisp_Object height = def->lface[LFACE_HEIGHT_INDEX]; 3250 Lisp_Object height = def->lface[LFACE_HEIGHT_INDEX];
3253 if (INTEGERP (height)) 3251 eassert (INTEGERP (height));
3254 pt = XINT (height); 3252 pt = XINT (height);
3255 else
3256 abort (); /* We should never end up here. */
3257 } 3253 }
3258 3254
3259 pt /= 10; 3255 pt /= 10;
@@ -3728,7 +3724,7 @@ font_range (ptrdiff_t pos, ptrdiff_t *limit, struct window *w, struct face *face
3728 } 3724 }
3729 else 3725 else
3730 { 3726 {
3731 font_assert (face); 3727 eassert (face);
3732 pos_byte = string_char_to_byte (string, pos); 3728 pos_byte = string_char_to_byte (string, pos);
3733 } 3729 }
3734 3730
@@ -4268,7 +4264,7 @@ DEFUN ("clear-font-cache", Fclear_font_cache, Sclear_font_cache, 0, 0, 0,
4268 while (! NILP (val) 4264 while (! NILP (val)
4269 && ! EQ (XCAR (XCAR (val)), driver_list->driver->type)) 4265 && ! EQ (XCAR (XCAR (val)), driver_list->driver->type))
4270 val = XCDR (val); 4266 val = XCDR (val);
4271 font_assert (! NILP (val)); 4267 eassert (! NILP (val));
4272 tmp = XCDR (XCAR (val)); 4268 tmp = XCDR (XCAR (val));
4273 if (XINT (XCAR (tmp)) == 0) 4269 if (XINT (XCAR (tmp)) == 0)
4274 { 4270 {
diff --git a/src/font.h b/src/font.h
index 2e374571c67..3e9af6df235 100644
--- a/src/font.h
+++ b/src/font.h
@@ -858,10 +858,4 @@ extern void font_deferred_log (const char *, Lisp_Object, Lisp_Object);
858 font_deferred_log ((ACTION), (ARG), (RESULT)); \ 858 font_deferred_log ((ACTION), (ARG), (RESULT)); \
859 } while (0) 859 } while (0)
860 860
861#ifdef FONT_DEBUG
862#define font_assert(X) do {if (!(X)) abort ();} while (0)
863#else /* not FONT_DEBUG */
864#define font_assert(X) (void) 0
865#endif /* not FONT_DEBUG */
866
867#endif /* not EMACS_FONT_H */ 861#endif /* not EMACS_FONT_H */
diff --git a/src/fontset.c b/src/fontset.c
index d4ce8b08ea3..3c7e931d121 100644
--- a/src/fontset.c
+++ b/src/fontset.c
@@ -1027,8 +1027,7 @@ make_fontset_for_ascii_face (FRAME_PTR f, int base_fontset_id, struct face *face
1027 base_fontset = FONTSET_FROM_ID (base_fontset_id); 1027 base_fontset = FONTSET_FROM_ID (base_fontset_id);
1028 if (!BASE_FONTSET_P (base_fontset)) 1028 if (!BASE_FONTSET_P (base_fontset))
1029 base_fontset = FONTSET_BASE (base_fontset); 1029 base_fontset = FONTSET_BASE (base_fontset);
1030 if (! BASE_FONTSET_P (base_fontset)) 1030 eassert (BASE_FONTSET_P (base_fontset));
1031 abort ();
1032 } 1031 }
1033 else 1032 else
1034 base_fontset = Vdefault_fontset; 1033 base_fontset = Vdefault_fontset;
@@ -1725,8 +1724,7 @@ fontset_from_font (Lisp_Object font_object)
1725 fontset_spec = copy_font_spec (font_spec); 1724 fontset_spec = copy_font_spec (font_spec);
1726 ASET (fontset_spec, FONT_REGISTRY_INDEX, alias); 1725 ASET (fontset_spec, FONT_REGISTRY_INDEX, alias);
1727 name = Ffont_xlfd_name (fontset_spec, Qnil); 1726 name = Ffont_xlfd_name (fontset_spec, Qnil);
1728 if (NILP (name)) 1727 eassert (!NILP (name));
1729 abort ();
1730 fontset = make_fontset (Qnil, name, Qnil); 1728 fontset = make_fontset (Qnil, name, Qnil);
1731 Vfontset_alias_alist = Fcons (Fcons (name, SYMBOL_NAME (alias)), 1729 Vfontset_alias_alist = Fcons (Fcons (name, SYMBOL_NAME (alias)),
1732 Vfontset_alias_alist); 1730 Vfontset_alias_alist);
diff --git a/src/w32font.c b/src/w32font.c
index 59dab789ab7..cfd453282dd 100644
--- a/src/w32font.c
+++ b/src/w32font.c
@@ -234,8 +234,7 @@ get_outline_metrics_w(HDC hdc, UINT cbData, LPOUTLINETEXTMETRICW lpotmw)
234 s_pfn_Get_Outline_Text_MetricsW = (GetOutlineTextMetricsW_Proc) 234 s_pfn_Get_Outline_Text_MetricsW = (GetOutlineTextMetricsW_Proc)
235 GetProcAddress (hm_unicows, "GetOutlineTextMetricsW"); 235 GetProcAddress (hm_unicows, "GetOutlineTextMetricsW");
236 } 236 }
237 if (s_pfn_Get_Outline_Text_MetricsW == NULL) 237 eassert (s_pfn_Get_Outline_Text_MetricsW != NULL);
238 abort (); /* cannot happen */
239 return s_pfn_Get_Outline_Text_MetricsW (hdc, cbData, lpotmw); 238 return s_pfn_Get_Outline_Text_MetricsW (hdc, cbData, lpotmw);
240} 239}
241 240
@@ -252,8 +251,7 @@ get_text_metrics_w(HDC hdc, LPTEXTMETRICW lptmw)
252 s_pfn_Get_Text_MetricsW = (GetTextMetricsW_Proc) 251 s_pfn_Get_Text_MetricsW = (GetTextMetricsW_Proc)
253 GetProcAddress (hm_unicows, "GetTextMetricsW"); 252 GetProcAddress (hm_unicows, "GetTextMetricsW");
254 } 253 }
255 if (s_pfn_Get_Text_MetricsW == NULL) 254 eassert (s_pfn_Get_Text_MetricsW != NULL);
256 abort (); /* cannot happen */
257 return s_pfn_Get_Text_MetricsW (hdc, lptmw); 255 return s_pfn_Get_Text_MetricsW (hdc, lptmw);
258} 256}
259 257
@@ -271,8 +269,7 @@ get_glyph_outline_w (HDC hdc, UINT uChar, UINT uFormat, LPGLYPHMETRICS lpgm,
271 s_pfn_Get_Glyph_OutlineW = (GetGlyphOutlineW_Proc) 269 s_pfn_Get_Glyph_OutlineW = (GetGlyphOutlineW_Proc)
272 GetProcAddress (hm_unicows, "GetGlyphOutlineW"); 270 GetProcAddress (hm_unicows, "GetGlyphOutlineW");
273 } 271 }
274 if (s_pfn_Get_Glyph_OutlineW == NULL) 272 eassert (s_pfn_Get_Glyph_OutlineW != NULL);
275 abort (); /* cannot happen */
276 return s_pfn_Get_Glyph_OutlineW (hdc, uChar, uFormat, lpgm, cbBuffer, 273 return s_pfn_Get_Glyph_OutlineW (hdc, uChar, uFormat, lpgm, cbBuffer,
277 lpvBuffer, lpmat2); 274 lpvBuffer, lpmat2);
278} 275}
diff --git a/src/xfont.c b/src/xfont.c
index e3e2eb18c29..9e929eed678 100644
--- a/src/xfont.c
+++ b/src/xfont.c
@@ -59,7 +59,7 @@ xfont_get_pcm (XFontStruct *xfont, XChar2b *char2b)
59 /* The result metric information. */ 59 /* The result metric information. */
60 XCharStruct *pcm = NULL; 60 XCharStruct *pcm = NULL;
61 61
62 font_assert (xfont && char2b); 62 eassert (xfont && char2b);
63 63
64 if (xfont->per_char != NULL) 64 if (xfont->per_char != NULL)
65 { 65 {
diff --git a/src/xftfont.c b/src/xftfont.c
index f999ac662ce..2f8125393bc 100644
--- a/src/xftfont.c
+++ b/src/xftfont.c
@@ -622,8 +622,7 @@ xftfont_get_xft_draw (FRAME_PTR f)
622 FRAME_X_VISUAL (f), 622 FRAME_X_VISUAL (f),
623 FRAME_X_COLORMAP (f)); 623 FRAME_X_COLORMAP (f));
624 UNBLOCK_INPUT; 624 UNBLOCK_INPUT;
625 if (! xft_draw) 625 eassert (xft_draw != NULL);
626 abort ();
627 font_put_frame_data (f, &xftfont_driver, xft_draw); 626 font_put_frame_data (f, &xftfont_driver, xft_draw);
628 } 627 }
629 return xft_draw; 628 return xft_draw;