Commit ebfa62c0 authored by Paul Eggert's avatar Paul Eggert

Use ptrdiff_t for composition IDs.

* character.c (lisp_string_width):
* composite.c (composition_table_size, n_compositions)
(get_composition_id, composition_gstring_from_id):
* dispextern.h (struct glyph_string.cmp_id, struct composition_it.id):
* xdisp.c (BUILD_COMPOSITE_GLYPH_STRING):
* window.c (Frecenter):
Use ptrdiff_t, not int, for composition IDs.
* composite.c (get_composition_id): Check for integer overflow.
* composite.h: Adjust prototypes to match the above changes.
parent 63cf7836
2011-07-19 Paul Eggert <eggert@cs.ucla.edu>
Use ptrdiff_t for composition IDs.
* character.c (lisp_string_width):
* composite.c (composition_table_size, n_compositions)
(get_composition_id, composition_gstring_from_id):
* dispextern.h (struct glyph_string.cmp_id, struct composition_it.id):
* xdisp.c (BUILD_COMPOSITE_GLYPH_STRING):
* window.c (Frecenter):
Use ptrdiff_t, not int, for composition IDs.
* composite.c (get_composition_id): Check for integer overflow.
* composite.h: Adjust prototypes to match the above changes.
Use ptrdiff_t for hash table indexes.
* category.c (hash_get_category_set):
* ccl.c (ccl_driver):
......
......@@ -423,7 +423,7 @@ lisp_string_width (Lisp_Object string, EMACS_INT precision,
{
EMACS_INT chars, bytes, thiswidth;
Lisp_Object val;
int cmp_id;
ptrdiff_t cmp_id;
EMACS_INT ignore, end;
if (find_composition (i, -1, &ignore, &end, &val, string)
......
......@@ -142,10 +142,10 @@ Lisp_Object Qcomposition;
struct composition **composition_table;
/* The current size of `composition_table'. */
static int composition_table_size;
static ptrdiff_t composition_table_size;
/* Number of compositions currently made. */
int n_compositions;
ptrdiff_t n_compositions;
/* Hash table for compositions. The key is COMPONENTS-VEC of
`composition' property. The value is the corresponding
......@@ -172,7 +172,7 @@ Lisp_Object composition_temp;
If the composition is invalid, return -1. */
int
ptrdiff_t
get_composition_id (EMACS_INT charpos, EMACS_INT bytepos, EMACS_INT nchars,
Lisp_Object prop, Lisp_Object string)
{
......@@ -260,18 +260,22 @@ get_composition_id (EMACS_INT charpos, EMACS_INT bytepos, EMACS_INT nchars,
/* Check if we have sufficient memory to store this information. */
if (composition_table_size == 0)
{
composition_table_size = 256;
composition_table
= (struct composition **) xmalloc (sizeof (composition_table[0])
* composition_table_size);
= (struct composition **) xmalloc (sizeof (composition_table[0]) * 256);
composition_table_size = 256;
}
else if (composition_table_size <= n_compositions)
{
composition_table_size += 256;
if ((min (MOST_POSITIVE_FIXNUM,
min (PTRDIFF_MAX, SIZE_MAX) / sizeof composition_table[0])
- 256)
< composition_table_size)
memory_full (SIZE_MAX);
composition_table
= (struct composition **) xrealloc (composition_table,
sizeof (composition_table[0])
* composition_table_size);
* (composition_table_size + 256));
composition_table_size += 256;
}
key_contents = XVECTOR (key)->contents;
......@@ -691,7 +695,7 @@ composition_gstring_put_cache (Lisp_Object gstring, EMACS_INT len)
}
Lisp_Object
composition_gstring_from_id (int id)
composition_gstring_from_id (ptrdiff_t id)
{
struct Lisp_Hash_Table *h = XHASH_TABLE (gstring_hash_table);
......
......@@ -204,7 +204,7 @@ struct composition {
COMPOSITION-ID. */
extern struct composition **composition_table;
/* Number of the currently registered compositions. */
extern int n_compositions;
extern ptrdiff_t n_compositions;
/* Mask bits for CHECK_MASK arg to update_compositions.
For a change in the region FROM and TO, check compositions ... */
......@@ -216,8 +216,8 @@ extern int n_compositions;
extern Lisp_Object Qcomposition;
extern Lisp_Object composition_hash_table;
extern int get_composition_id (EMACS_INT, EMACS_INT, EMACS_INT,
Lisp_Object, Lisp_Object);
extern ptrdiff_t get_composition_id (EMACS_INT, EMACS_INT, EMACS_INT,
Lisp_Object, Lisp_Object);
extern int find_composition (EMACS_INT, EMACS_INT, EMACS_INT *, EMACS_INT *,
Lisp_Object *, Lisp_Object);
extern void update_compositions (EMACS_INT, EMACS_INT, int);
......@@ -299,7 +299,7 @@ struct face;
struct font_metrics;
extern Lisp_Object composition_gstring_put_cache (Lisp_Object, EMACS_INT);
extern Lisp_Object composition_gstring_from_id (int);
extern Lisp_Object composition_gstring_from_id (ptrdiff_t);
extern int composition_gstring_p (Lisp_Object);
extern int composition_gstring_width (Lisp_Object, EMACS_INT, EMACS_INT,
struct font_metrics *);
......
......@@ -1240,7 +1240,7 @@ struct glyph_string
struct composition *cmp;
/* If not negative, this string describes a compos. */
int cmp_id;
ptrdiff_t cmp_id;
/* Start and end glyph indices in a glyph-string. */
int cmp_from, cmp_to;
......@@ -2056,7 +2056,7 @@ struct composition_it
EMACS_INT stop_pos;
/* ID number of the composition or glyph-string. If negative, we
are not iterating over a composition now. */
int id;
ptrdiff_t id;
/* If non-negative, character that triggers the automatic
composition at `stop_pos', and this is an automatic composition.
If negative, this is a static composition. This is set to -2
......
......@@ -5069,7 +5069,7 @@ and redisplay normally--don't erase and redraw the frame. */)
&& (!EQ (Vrecenter_redisplay, Qtty)
|| !NILP (Ftty_type (selected_frame))))
{
int i;
ptrdiff_t i;
/* Invalidate pixel data calculated for all compositions. */
for (i = 0; i < n_compositions; i++)
......
......@@ -22002,7 +22002,7 @@ compute_overhangs_and_x (struct glyph_string *s, int x, int backward_p)
do { \
int face_id = (row)->glyphs[area][START].face_id; \
struct face *base_face = FACE_FROM_ID (f, face_id); \
int cmp_id = (row)->glyphs[area][START].u.cmp.id; \
ptrdiff_t cmp_id = (row)->glyphs[area][START].u.cmp.id; \
struct composition *cmp = composition_table[cmp_id]; \
XChar2b *char2b; \
struct glyph_string *first_s IF_LINT (= NULL); \
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment