summaryrefslogtreecommitdiff
path: root/src/composite.h
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2011-06-06 01:29:01 -0700
committerPaul Eggert <eggert@cs.ucla.edu>2011-06-06 01:29:01 -0700
commitbe44ca6cd47bff4cb0dfcfd71aa14f10fdab5434 (patch)
tree34110ed6783c1314604f3382e8cd6d0812b939e3 /src/composite.h
parentd1f3d2afe1057a99b9dec6d1bd5b57bfee81fdff (diff)
downloademacs-be44ca6cd47bff4cb0dfcfd71aa14f10fdab5434.tar.gz
Check for overflow when converting integer to cons and back.
* charset.c (Fdefine_charset_internal, Fdecode_char): Use cons_to_unsigned to catch overflow. (Fencode_char): Use INTEGER_TO_CONS. * composite.h (LGLYPH_CODE): Use cons_to_unsigned. (LGLYPH_SET_CODE): Use INTEGER_TO_CONS. * data.c (long_to_cons, cons_to_long): Remove. (cons_to_unsigned, cons_to_signed): New functions. These signal an error for invalid or out-of-range values. * dired.c (Ffile_attributes): Use INTEGER_TO_CONS. * fileio.c (Fset_visited_file_modtime): Use CONS_TO_INTEGER. * font.c (Ffont_variation_glyphs): * fontset.c (Finternal_char_font): Use INTEGER_TO_CONS. * lisp.h: Include <intprops.h>. (INTEGER_TO_CONS, CONS_TO_INTEGER): New macros. (cons_to_signed, cons_to_unsigned): New decls. (long_to_cons, cons_to_long): Remove decls. * undo.c (record_first_change): Use INTEGER_TO_CONS. (Fprimitive_undo): Use CONS_TO_INTEGER. * xfns.c (Fx_window_property): Likewise. * xselect.c: Include <limits.h>. (x_own_selection, selection_data_to_lisp_data): Use INTEGER_TO_CONS. (x_handle_selection_request, x_handle_selection_clear) (x_get_foreign_selection, Fx_disown_selection_internal) (Fx_get_atom_name, x_send_client_event): Use CONS_TO_INTEGER. (lisp_data_to_selection_data): Use cons_to_unsigned. (x_fill_property_data): Use cons_to_signed. Report values out of range.
Diffstat (limited to 'src/composite.h')
-rw-r--r--src/composite.h16
1 files changed, 3 insertions, 13 deletions
diff --git a/src/composite.h b/src/composite.h
index cc8ca10a139..0f81911f0b0 100644
--- a/src/composite.h
+++ b/src/composite.h
@@ -265,10 +265,7 @@ enum lglyph_indices
#define LGLYPH_CODE(g) \
(NILP (AREF ((g), LGLYPH_IX_CODE)) \
? FONT_INVALID_CODE \
- : CONSP (AREF ((g), LGLYPH_IX_CODE)) \
- ? ((XFASTINT (XCAR (AREF ((g), LGLYPH_IX_CODE))) << 16) \
- | (XFASTINT (XCDR (AREF ((g), LGLYPH_IX_CODE))))) \
- : XFASTINT (AREF ((g), LGLYPH_IX_CODE)))
+ : cons_to_unsigned (AREF (g, LGLYPH_IX_CODE), TYPE_MAXIMUM (unsigned)))
#define LGLYPH_WIDTH(g) XINT (AREF ((g), LGLYPH_IX_WIDTH))
#define LGLYPH_LBEARING(g) XINT (AREF ((g), LGLYPH_IX_LBEARING))
#define LGLYPH_RBEARING(g) XINT (AREF ((g), LGLYPH_IX_RBEARING))
@@ -280,15 +277,8 @@ enum lglyph_indices
#define LGLYPH_SET_CHAR(g, val) ASET ((g), LGLYPH_IX_CHAR, make_number (val))
/* Callers must assure that VAL is not negative! */
#define LGLYPH_SET_CODE(g, val) \
- do { \
- if (val == FONT_INVALID_CODE) \
- ASET ((g), LGLYPH_IX_CODE, Qnil); \
- else if ((EMACS_INT)val > MOST_POSITIVE_FIXNUM) \
- ASET ((g), LGLYPH_IX_CODE, Fcons (make_number ((val) >> 16), \
- make_number ((val) & 0xFFFF))); \
- else \
- ASET ((g), LGLYPH_IX_CODE, make_number (val)); \
- } while (0)
+ ASET (g, LGLYPH_IX_CODE, \
+ val == FONT_INVALID_CODE ? Qnil : INTEGER_TO_CONS (val))
#define LGLYPH_SET_WIDTH(g, val) ASET ((g), LGLYPH_IX_WIDTH, make_number (val))
#define LGLYPH_SET_LBEARING(g, val) ASET ((g), LGLYPH_IX_LBEARING, make_number (val))