aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPaul Eggert2011-07-19 14:39:36 -0700
committerPaul Eggert2011-07-19 14:39:36 -0700
commitebfa62c01481332072f519581aaf4d8d7da49e68 (patch)
treec62f6a866f44165112999f66f5ca7e5f30dc2af3 /src
parent63cf7836ae7616ce91d7eeaeac997d71609e191b (diff)
downloademacs-ebfa62c01481332072f519581aaf4d8d7da49e68.tar.gz
emacs-ebfa62c01481332072f519581aaf4d8d7da49e68.zip
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.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog11
-rw-r--r--src/character.c2
-rw-r--r--src/composite.c22
-rw-r--r--src/composite.h8
-rw-r--r--src/dispextern.h4
-rw-r--r--src/window.c2
-rw-r--r--src/xdisp.c2
7 files changed, 33 insertions, 18 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 30af92a57e9..b3125b2c183 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,5 +1,16 @@
12011-07-19 Paul Eggert <eggert@cs.ucla.edu> 12011-07-19 Paul Eggert <eggert@cs.ucla.edu>
2 2
3 Use ptrdiff_t for composition IDs.
4 * character.c (lisp_string_width):
5 * composite.c (composition_table_size, n_compositions)
6 (get_composition_id, composition_gstring_from_id):
7 * dispextern.h (struct glyph_string.cmp_id, struct composition_it.id):
8 * xdisp.c (BUILD_COMPOSITE_GLYPH_STRING):
9 * window.c (Frecenter):
10 Use ptrdiff_t, not int, for composition IDs.
11 * composite.c (get_composition_id): Check for integer overflow.
12 * composite.h: Adjust prototypes to match the above changes.
13
3 Use ptrdiff_t for hash table indexes. 14 Use ptrdiff_t for hash table indexes.
4 * category.c (hash_get_category_set): 15 * category.c (hash_get_category_set):
5 * ccl.c (ccl_driver): 16 * ccl.c (ccl_driver):
diff --git a/src/character.c b/src/character.c
index c2f23e0d8ec..5e2eccf54db 100644
--- a/src/character.c
+++ b/src/character.c
@@ -423,7 +423,7 @@ lisp_string_width (Lisp_Object string, EMACS_INT precision,
423 { 423 {
424 EMACS_INT chars, bytes, thiswidth; 424 EMACS_INT chars, bytes, thiswidth;
425 Lisp_Object val; 425 Lisp_Object val;
426 int cmp_id; 426 ptrdiff_t cmp_id;
427 EMACS_INT ignore, end; 427 EMACS_INT ignore, end;
428 428
429 if (find_composition (i, -1, &ignore, &end, &val, string) 429 if (find_composition (i, -1, &ignore, &end, &val, string)
diff --git a/src/composite.c b/src/composite.c
index 43041f7b381..b25699b9ff4 100644
--- a/src/composite.c
+++ b/src/composite.c
@@ -142,10 +142,10 @@ Lisp_Object Qcomposition;
142struct composition **composition_table; 142struct composition **composition_table;
143 143
144/* The current size of `composition_table'. */ 144/* The current size of `composition_table'. */
145static int composition_table_size; 145static ptrdiff_t composition_table_size;
146 146
147/* Number of compositions currently made. */ 147/* Number of compositions currently made. */
148int n_compositions; 148ptrdiff_t n_compositions;
149 149
150/* Hash table for compositions. The key is COMPONENTS-VEC of 150/* Hash table for compositions. The key is COMPONENTS-VEC of
151 `composition' property. The value is the corresponding 151 `composition' property. The value is the corresponding
@@ -172,7 +172,7 @@ Lisp_Object composition_temp;
172 172
173 If the composition is invalid, return -1. */ 173 If the composition is invalid, return -1. */
174 174
175int 175ptrdiff_t
176get_composition_id (EMACS_INT charpos, EMACS_INT bytepos, EMACS_INT nchars, 176get_composition_id (EMACS_INT charpos, EMACS_INT bytepos, EMACS_INT nchars,
177 Lisp_Object prop, Lisp_Object string) 177 Lisp_Object prop, Lisp_Object string)
178{ 178{
@@ -260,18 +260,22 @@ get_composition_id (EMACS_INT charpos, EMACS_INT bytepos, EMACS_INT nchars,
260 /* Check if we have sufficient memory to store this information. */ 260 /* Check if we have sufficient memory to store this information. */
261 if (composition_table_size == 0) 261 if (composition_table_size == 0)
262 { 262 {
263 composition_table_size = 256;
264 composition_table 263 composition_table
265 = (struct composition **) xmalloc (sizeof (composition_table[0]) 264 = (struct composition **) xmalloc (sizeof (composition_table[0]) * 256);
266 * composition_table_size); 265 composition_table_size = 256;
267 } 266 }
268 else if (composition_table_size <= n_compositions) 267 else if (composition_table_size <= n_compositions)
269 { 268 {
270 composition_table_size += 256; 269 if ((min (MOST_POSITIVE_FIXNUM,
270 min (PTRDIFF_MAX, SIZE_MAX) / sizeof composition_table[0])
271 - 256)
272 < composition_table_size)
273 memory_full (SIZE_MAX);
271 composition_table 274 composition_table
272 = (struct composition **) xrealloc (composition_table, 275 = (struct composition **) xrealloc (composition_table,
273 sizeof (composition_table[0]) 276 sizeof (composition_table[0])
274 * composition_table_size); 277 * (composition_table_size + 256));
278 composition_table_size += 256;
275 } 279 }
276 280
277 key_contents = XVECTOR (key)->contents; 281 key_contents = XVECTOR (key)->contents;
@@ -691,7 +695,7 @@ composition_gstring_put_cache (Lisp_Object gstring, EMACS_INT len)
691} 695}
692 696
693Lisp_Object 697Lisp_Object
694composition_gstring_from_id (int id) 698composition_gstring_from_id (ptrdiff_t id)
695{ 699{
696 struct Lisp_Hash_Table *h = XHASH_TABLE (gstring_hash_table); 700 struct Lisp_Hash_Table *h = XHASH_TABLE (gstring_hash_table);
697 701
diff --git a/src/composite.h b/src/composite.h
index 8cedfdbe352..a43e41901ee 100644
--- a/src/composite.h
+++ b/src/composite.h
@@ -204,7 +204,7 @@ struct composition {
204 COMPOSITION-ID. */ 204 COMPOSITION-ID. */
205extern struct composition **composition_table; 205extern struct composition **composition_table;
206/* Number of the currently registered compositions. */ 206/* Number of the currently registered compositions. */
207extern int n_compositions; 207extern ptrdiff_t n_compositions;
208 208
209/* Mask bits for CHECK_MASK arg to update_compositions. 209/* Mask bits for CHECK_MASK arg to update_compositions.
210 For a change in the region FROM and TO, check compositions ... */ 210 For a change in the region FROM and TO, check compositions ... */
@@ -216,8 +216,8 @@ extern int n_compositions;
216 216
217extern Lisp_Object Qcomposition; 217extern Lisp_Object Qcomposition;
218extern Lisp_Object composition_hash_table; 218extern Lisp_Object composition_hash_table;
219extern int get_composition_id (EMACS_INT, EMACS_INT, EMACS_INT, 219extern ptrdiff_t get_composition_id (EMACS_INT, EMACS_INT, EMACS_INT,
220 Lisp_Object, Lisp_Object); 220 Lisp_Object, Lisp_Object);
221extern int find_composition (EMACS_INT, EMACS_INT, EMACS_INT *, EMACS_INT *, 221extern int find_composition (EMACS_INT, EMACS_INT, EMACS_INT *, EMACS_INT *,
222 Lisp_Object *, Lisp_Object); 222 Lisp_Object *, Lisp_Object);
223extern void update_compositions (EMACS_INT, EMACS_INT, int); 223extern void update_compositions (EMACS_INT, EMACS_INT, int);
@@ -299,7 +299,7 @@ struct face;
299struct font_metrics; 299struct font_metrics;
300 300
301extern Lisp_Object composition_gstring_put_cache (Lisp_Object, EMACS_INT); 301extern Lisp_Object composition_gstring_put_cache (Lisp_Object, EMACS_INT);
302extern Lisp_Object composition_gstring_from_id (int); 302extern Lisp_Object composition_gstring_from_id (ptrdiff_t);
303extern int composition_gstring_p (Lisp_Object); 303extern int composition_gstring_p (Lisp_Object);
304extern int composition_gstring_width (Lisp_Object, EMACS_INT, EMACS_INT, 304extern int composition_gstring_width (Lisp_Object, EMACS_INT, EMACS_INT,
305 struct font_metrics *); 305 struct font_metrics *);
diff --git a/src/dispextern.h b/src/dispextern.h
index bb4da7d52a8..1d7bf5d53ec 100644
--- a/src/dispextern.h
+++ b/src/dispextern.h
@@ -1240,7 +1240,7 @@ struct glyph_string
1240 struct composition *cmp; 1240 struct composition *cmp;
1241 1241
1242 /* If not negative, this string describes a compos. */ 1242 /* If not negative, this string describes a compos. */
1243 int cmp_id; 1243 ptrdiff_t cmp_id;
1244 1244
1245 /* Start and end glyph indices in a glyph-string. */ 1245 /* Start and end glyph indices in a glyph-string. */
1246 int cmp_from, cmp_to; 1246 int cmp_from, cmp_to;
@@ -2056,7 +2056,7 @@ struct composition_it
2056 EMACS_INT stop_pos; 2056 EMACS_INT stop_pos;
2057 /* ID number of the composition or glyph-string. If negative, we 2057 /* ID number of the composition or glyph-string. If negative, we
2058 are not iterating over a composition now. */ 2058 are not iterating over a composition now. */
2059 int id; 2059 ptrdiff_t id;
2060 /* If non-negative, character that triggers the automatic 2060 /* If non-negative, character that triggers the automatic
2061 composition at `stop_pos', and this is an automatic composition. 2061 composition at `stop_pos', and this is an automatic composition.
2062 If negative, this is a static composition. This is set to -2 2062 If negative, this is a static composition. This is set to -2
diff --git a/src/window.c b/src/window.c
index 3f5a743f5c6..04fea6b9bf6 100644
--- a/src/window.c
+++ b/src/window.c
@@ -5069,7 +5069,7 @@ and redisplay normally--don't erase and redraw the frame. */)
5069 && (!EQ (Vrecenter_redisplay, Qtty) 5069 && (!EQ (Vrecenter_redisplay, Qtty)
5070 || !NILP (Ftty_type (selected_frame)))) 5070 || !NILP (Ftty_type (selected_frame))))
5071 { 5071 {
5072 int i; 5072 ptrdiff_t i;
5073 5073
5074 /* Invalidate pixel data calculated for all compositions. */ 5074 /* Invalidate pixel data calculated for all compositions. */
5075 for (i = 0; i < n_compositions; i++) 5075 for (i = 0; i < n_compositions; i++)
diff --git a/src/xdisp.c b/src/xdisp.c
index 43f60abb812..55296db0b8f 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -22002,7 +22002,7 @@ compute_overhangs_and_x (struct glyph_string *s, int x, int backward_p)
22002 do { \ 22002 do { \
22003 int face_id = (row)->glyphs[area][START].face_id; \ 22003 int face_id = (row)->glyphs[area][START].face_id; \
22004 struct face *base_face = FACE_FROM_ID (f, face_id); \ 22004 struct face *base_face = FACE_FROM_ID (f, face_id); \
22005 int cmp_id = (row)->glyphs[area][START].u.cmp.id; \ 22005 ptrdiff_t cmp_id = (row)->glyphs[area][START].u.cmp.id; \
22006 struct composition *cmp = composition_table[cmp_id]; \ 22006 struct composition *cmp = composition_table[cmp_id]; \
22007 XChar2b *char2b; \ 22007 XChar2b *char2b; \
22008 struct glyph_string *first_s IF_LINT (= NULL); \ 22008 struct glyph_string *first_s IF_LINT (= NULL); \