aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDmitry Antipov2013-01-15 13:22:25 +0400
committerDmitry Antipov2013-01-15 13:22:25 +0400
commit2b30549c493d7b67fa92c2b4bcd2bd2e55210ae1 (patch)
treeac4cc77344b3285eb47d5145eb0b28dd6034f54d
parent1b971ac155006504b6b1c2688199747f976723af (diff)
downloademacs-2b30549c493d7b67fa92c2b4bcd2bd2e55210ae1.tar.gz
emacs-2b30549c493d7b67fa92c2b4bcd2bd2e55210ae1.zip
* src/lisp.h (XSAVE_POINTER, XSAVE_INTEGER): Change to allow extraction
from any Lisp_Save_Value slot. Add type checking. * src/alloc.c, src/dired.c, src/editfns.c, src/fileio.c, src/ftfont.c: * src/gtkutil.c, src/keymap.c, src/lread.c, src/nsterm.h, src/nsmenu.c: * src/xfns.c, src/xmenu.c, src/xselect.c: All users changed. * admin/coccinelle/xsave.cocci: Semantic patch to adjust users of XSAVE_POINTER and XSAVE_INTEGER macros.
-rw-r--r--admin/ChangeLog5
-rw-r--r--admin/coccinelle/xsave.cocci11
-rw-r--r--src/ChangeLog8
-rw-r--r--src/alloc.c2
-rw-r--r--src/dired.c2
-rw-r--r--src/editfns.c2
-rw-r--r--src/fileio.c2
-rw-r--r--src/font.c2
-rw-r--r--src/ftfont.c18
-rw-r--r--src/gtkutil.c2
-rw-r--r--src/keymap.c4
-rw-r--r--src/lisp.h14
-rw-r--r--src/lread.c2
-rw-r--r--src/nsmenu.m2
-rw-r--r--src/nsterm.h4
-rw-r--r--src/xfns.c2
-rw-r--r--src/xmenu.c8
-rw-r--r--src/xselect.c2
18 files changed, 61 insertions, 31 deletions
diff --git a/admin/ChangeLog b/admin/ChangeLog
index 7d77becb522..5da0bf0c67d 100644
--- a/admin/ChangeLog
+++ b/admin/ChangeLog
@@ -1,3 +1,8 @@
12013-01-15 Dmitry Antipov <dmantipov@yandex.ru>
2
3 * coccinelle/xsave.cocci: Semantic patch to adjust users of
4 XSAVE_POINTER and XSAVE_INTEGER macros.
5
12013-01-03 Glenn Morris <rgm@gnu.org> 62013-01-03 Glenn Morris <rgm@gnu.org>
2 7
3 * check-doc-strings: Update for CVS->bzr, moved lispref/ directory. 8 * check-doc-strings: Update for CVS->bzr, moved lispref/ directory.
diff --git a/admin/coccinelle/xsave.cocci b/admin/coccinelle/xsave.cocci
new file mode 100644
index 00000000000..5172bb55b33
--- /dev/null
+++ b/admin/coccinelle/xsave.cocci
@@ -0,0 +1,11 @@
1// Adjust users of XSAVE_POINTER and XSAVE_INTEGER.
2@@
3expression E;
4@@
5(
6- XSAVE_POINTER (E)
7+ XSAVE_POINTER (E, 0)
8|
9- XSAVE_INTEGER (E)
10+ XSAVE_INTEGER (E, 1)
11)
diff --git a/src/ChangeLog b/src/ChangeLog
index 34c137a35c6..289aed36088 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,5 +1,13 @@
12013-01-15 Dmitry Antipov <dmantipov@yandex.ru> 12013-01-15 Dmitry Antipov <dmantipov@yandex.ru>
2 2
3 * lisp.h (XSAVE_POINTER, XSAVE_INTEGER): Change to allow
4 extraction from any Lisp_Save_Value slot. Add type checking.
5 * alloc.c, dired.c, editfns.c, fileio.c, ftfont.c, gtkutil.c:
6 * keymap.c, lread.c, nsterm.h, nsmenu.c, xfns.c, xmenu.c:
7 * xselect.c: All users changed.
8
92013-01-15 Dmitry Antipov <dmantipov@yandex.ru>
10
3 Some convenient bits to deal with Lisp_Save_Values. 11 Some convenient bits to deal with Lisp_Save_Values.
4 * lisp.h (XSAVE_OBJECT): New macro to extract saved objects. 12 * lisp.h (XSAVE_OBJECT): New macro to extract saved objects.
5 (allocate_misc): Remove prototype. 13 (allocate_misc): Remove prototype.
diff --git a/src/alloc.c b/src/alloc.c
index e1cb97163ce..b83b621bc7d 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -3420,7 +3420,7 @@ make_save_value (void *pointer, ptrdiff_t integer)
3420void 3420void
3421free_save_value (Lisp_Object save) 3421free_save_value (Lisp_Object save)
3422{ 3422{
3423 xfree (XSAVE_POINTER (save)); 3423 xfree (XSAVE_POINTER (save, 0));
3424 free_misc (save); 3424 free_misc (save);
3425} 3425}
3426 3426
diff --git a/src/dired.c b/src/dired.c
index 8483721401a..3dca9d24f67 100644
--- a/src/dired.c
+++ b/src/dired.c
@@ -78,7 +78,7 @@ directory_files_internal_w32_unwind (Lisp_Object arg)
78static Lisp_Object 78static Lisp_Object
79directory_files_internal_unwind (Lisp_Object dh) 79directory_files_internal_unwind (Lisp_Object dh)
80{ 80{
81 DIR *d = XSAVE_POINTER (dh); 81 DIR *d = XSAVE_POINTER (dh, 0);
82 block_input (); 82 block_input ();
83 closedir (d); 83 closedir (d);
84 unblock_input (); 84 unblock_input ();
diff --git a/src/editfns.c b/src/editfns.c
index 3fe085caac8..8910b66e4d3 100644
--- a/src/editfns.c
+++ b/src/editfns.c
@@ -4254,7 +4254,7 @@ usage: (format STRING &rest OBJECTS) */)
4254 memcpy (buf, initial_buffer, used); 4254 memcpy (buf, initial_buffer, used);
4255 } 4255 }
4256 else 4256 else
4257 XSAVE_POINTER (buf_save_value) = buf = xrealloc (buf, bufsize); 4257 XSAVE_POINTER (buf_save_value, 0) = buf = xrealloc (buf, bufsize);
4258 4258
4259 p = buf + used; 4259 p = buf + used;
4260 } 4260 }
diff --git a/src/fileio.c b/src/fileio.c
index d468576d639..8c194a56fc8 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -5507,7 +5507,7 @@ static Lisp_Object
5507do_auto_save_unwind (Lisp_Object arg) /* used as unwind-protect function */ 5507do_auto_save_unwind (Lisp_Object arg) /* used as unwind-protect function */
5508 5508
5509{ 5509{
5510 FILE *stream = XSAVE_POINTER (arg); 5510 FILE *stream = XSAVE_POINTER (arg, 0);
5511 auto_saving = 0; 5511 auto_saving = 0;
5512 if (stream != NULL) 5512 if (stream != NULL)
5513 { 5513 {
diff --git a/src/font.c b/src/font.c
index c4153428147..89931f6ec76 100644
--- a/src/font.c
+++ b/src/font.c
@@ -1857,7 +1857,7 @@ otf_open (Lisp_Object file)
1857 OTF *otf; 1857 OTF *otf;
1858 1858
1859 if (! NILP (val)) 1859 if (! NILP (val))
1860 otf = XSAVE_POINTER (XCDR (val)); 1860 otf = XSAVE_POINTER (XCDR (val), 0);
1861 else 1861 else
1862 { 1862 {
1863 otf = STRINGP (file) ? OTF_open (SSDATA (file)) : NULL; 1863 otf = STRINGP (file) ? OTF_open (SSDATA (file)) : NULL;
diff --git a/src/ftfont.c b/src/ftfont.c
index 1d7678bfe09..5bf91832c7c 100644
--- a/src/ftfont.c
+++ b/src/ftfont.c
@@ -400,7 +400,7 @@ ftfont_lookup_cache (Lisp_Object key, enum ftfont_cache_for cache_for)
400 else 400 else
401 { 401 {
402 val = XCDR (cache); 402 val = XCDR (cache);
403 cache_data = XSAVE_POINTER (val); 403 cache_data = XSAVE_POINTER (val, 0);
404 } 404 }
405 405
406 if (cache_for == FTFONT_CACHE_FOR_ENTITY) 406 if (cache_for == FTFONT_CACHE_FOR_ENTITY)
@@ -466,7 +466,7 @@ ftfont_get_fc_charset (Lisp_Object entity)
466 466
467 cache = ftfont_lookup_cache (entity, FTFONT_CACHE_FOR_CHARSET); 467 cache = ftfont_lookup_cache (entity, FTFONT_CACHE_FOR_CHARSET);
468 val = XCDR (cache); 468 val = XCDR (cache);
469 cache_data = XSAVE_POINTER (val); 469 cache_data = XSAVE_POINTER (val, 0);
470 return cache_data->fc_charset; 470 return cache_data->fc_charset;
471} 471}
472 472
@@ -1198,9 +1198,9 @@ ftfont_open (FRAME_PTR f, Lisp_Object entity, int pixel_size)
1198 filename = XCAR (val); 1198 filename = XCAR (val);
1199 idx = XCDR (val); 1199 idx = XCDR (val);
1200 val = XCDR (cache); 1200 val = XCDR (cache);
1201 cache_data = XSAVE_POINTER (XCDR (cache)); 1201 cache_data = XSAVE_POINTER (XCDR (cache), 0);
1202 ft_face = cache_data->ft_face; 1202 ft_face = cache_data->ft_face;
1203 if (XSAVE_INTEGER (val) > 0) 1203 if (XSAVE_INTEGER (val, 1) > 0)
1204 { 1204 {
1205 /* FT_Face in this cache is already used by the different size. */ 1205 /* FT_Face in this cache is already used by the different size. */
1206 if (FT_New_Size (ft_face, &ft_size) != 0) 1206 if (FT_New_Size (ft_face, &ft_size) != 0)
@@ -1211,13 +1211,13 @@ ftfont_open (FRAME_PTR f, Lisp_Object entity, int pixel_size)
1211 return Qnil; 1211 return Qnil;
1212 } 1212 }
1213 } 1213 }
1214 XSAVE_INTEGER (val)++; 1214 XSAVE_INTEGER (val, 1)++;
1215 size = XINT (AREF (entity, FONT_SIZE_INDEX)); 1215 size = XINT (AREF (entity, FONT_SIZE_INDEX));
1216 if (size == 0) 1216 if (size == 0)
1217 size = pixel_size; 1217 size = pixel_size;
1218 if (FT_Set_Pixel_Sizes (ft_face, size, size) != 0) 1218 if (FT_Set_Pixel_Sizes (ft_face, size, size) != 0)
1219 { 1219 {
1220 if (XSAVE_INTEGER (val) == 0) 1220 if (XSAVE_INTEGER (val, 1) == 0)
1221 FT_Done_Face (ft_face); 1221 FT_Done_Face (ft_face);
1222 return Qnil; 1222 return Qnil;
1223 } 1223 }
@@ -1326,10 +1326,10 @@ ftfont_close (FRAME_PTR f, struct font *font)
1326 cache = ftfont_lookup_cache (val, FTFONT_CACHE_FOR_FACE); 1326 cache = ftfont_lookup_cache (val, FTFONT_CACHE_FOR_FACE);
1327 eassert (CONSP (cache)); 1327 eassert (CONSP (cache));
1328 val = XCDR (cache); 1328 val = XCDR (cache);
1329 (XSAVE_INTEGER (val))--; 1329 XSAVE_INTEGER (val, 1)--;
1330 if (XSAVE_INTEGER (val) == 0) 1330 if (XSAVE_INTEGER (val, 1) == 0)
1331 { 1331 {
1332 struct ftfont_cache_data *cache_data = XSAVE_POINTER (val); 1332 struct ftfont_cache_data *cache_data = XSAVE_POINTER (val, 0);
1333 1333
1334 FT_Done_Face (cache_data->ft_face); 1334 FT_Done_Face (cache_data->ft_face);
1335#ifdef HAVE_LIBOTF 1335#ifdef HAVE_LIBOTF
diff --git a/src/gtkutil.c b/src/gtkutil.c
index 259e0e971fd..f045deacd33 100644
--- a/src/gtkutil.c
+++ b/src/gtkutil.c
@@ -1650,7 +1650,7 @@ xg_dialog_response_cb (GtkDialog *w,
1650static Lisp_Object 1650static Lisp_Object
1651pop_down_dialog (Lisp_Object arg) 1651pop_down_dialog (Lisp_Object arg)
1652{ 1652{
1653 struct xg_dialog_data *dd = XSAVE_POINTER (arg); 1653 struct xg_dialog_data *dd = XSAVE_POINTER (arg, 0);
1654 1654
1655 block_input (); 1655 block_input ();
1656 if (dd->w) gtk_widget_destroy (dd->w); 1656 if (dd->w) gtk_widget_destroy (dd->w);
diff --git a/src/keymap.c b/src/keymap.c
index 82c9e980221..f64c8d5a848 100644
--- a/src/keymap.c
+++ b/src/keymap.c
@@ -565,14 +565,14 @@ map_keymap_char_table_item (Lisp_Object args, Lisp_Object key, Lisp_Object val)
565{ 565{
566 if (!NILP (val)) 566 if (!NILP (val))
567 { 567 {
568 map_keymap_function_t fun = XSAVE_POINTER (XCAR (args)); 568 map_keymap_function_t fun = XSAVE_POINTER (XCAR (args), 0);
569 args = XCDR (args); 569 args = XCDR (args);
570 /* If the key is a range, make a copy since map_char_table modifies 570 /* If the key is a range, make a copy since map_char_table modifies
571 it in place. */ 571 it in place. */
572 if (CONSP (key)) 572 if (CONSP (key))
573 key = Fcons (XCAR (key), XCDR (key)); 573 key = Fcons (XCAR (key), XCDR (key));
574 map_keymap_item (fun, XCDR (args), key, val, 574 map_keymap_item (fun, XCDR (args), key, val,
575 XSAVE_POINTER (XCAR (args))); 575 XSAVE_POINTER (XCAR (args), 0));
576 } 576 }
577} 577}
578 578
diff --git a/src/lisp.h b/src/lisp.h
index ac7346c5386..1ff8f83270b 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -1413,15 +1413,21 @@ struct Lisp_Save_Value
1413 } data[4]; 1413 } data[4];
1414 }; 1414 };
1415 1415
1416/* Compatibility macro to set and extract saved pointer. */ 1416/* Macro to set and extract Nth saved pointer. Type
1417 checking is ugly because it's used as an lvalue. */
1417 1418
1418#define XSAVE_POINTER(obj) XSAVE_VALUE (obj)->data[0].pointer 1419#define XSAVE_POINTER(obj, n) \
1420 XSAVE_VALUE (obj)->data[(eassert (XSAVE_VALUE (obj)->type \
1421 ## n == SAVE_POINTER), n)].pointer
1419 1422
1420/* Likewise for the saved integer. */ 1423/* Likewise for the saved integer. */
1421 1424
1422#define XSAVE_INTEGER(obj) XSAVE_VALUE (obj)->data[1].integer 1425#define XSAVE_INTEGER(obj, n) \
1426 XSAVE_VALUE (obj)->data[(eassert (XSAVE_VALUE (obj)->type \
1427 ## n == SAVE_INTEGER), n)].integer
1423 1428
1424/* Macro to extract Nth saved object. */ 1429/* Macro to extract Nth saved object. This is never used as
1430 an lvalue, so we can do more convenient type checking. */
1425 1431
1426#define XSAVE_OBJECT(obj, n) \ 1432#define XSAVE_OBJECT(obj, n) \
1427 (eassert (XSAVE_VALUE (obj)->type ## n == SAVE_OBJECT), \ 1433 (eassert (XSAVE_VALUE (obj)->type ## n == SAVE_OBJECT), \
diff --git a/src/lread.c b/src/lread.c
index ced690a77b0..a01cf099b49 100644
--- a/src/lread.c
+++ b/src/lread.c
@@ -1357,7 +1357,7 @@ Return t if the file exists and loads successfully. */)
1357static Lisp_Object 1357static Lisp_Object
1358load_unwind (Lisp_Object arg) /* Used as unwind-protect function in load. */ 1358load_unwind (Lisp_Object arg) /* Used as unwind-protect function in load. */
1359{ 1359{
1360 FILE *stream = XSAVE_POINTER (arg); 1360 FILE *stream = XSAVE_POINTER (arg, 0);
1361 if (stream != NULL) 1361 if (stream != NULL)
1362 { 1362 {
1363 block_input (); 1363 block_input ();
diff --git a/src/nsmenu.m b/src/nsmenu.m
index 3e6fa54b047..b0369e76a27 100644
--- a/src/nsmenu.m
+++ b/src/nsmenu.m
@@ -1347,7 +1347,7 @@ struct Popdown_data
1347static Lisp_Object 1347static Lisp_Object
1348pop_down_menu (Lisp_Object arg) 1348pop_down_menu (Lisp_Object arg)
1349{ 1349{
1350 struct Popdown_data *unwind_data = XSAVE_POINTER (arg); 1350 struct Popdown_data *unwind_data = XSAVE_POINTER (arg, 0);
1351 1351
1352 block_input (); 1352 block_input ();
1353 if (popup_activated_flag) 1353 if (popup_activated_flag)
diff --git a/src/nsterm.h b/src/nsterm.h
index 7732e6d27cc..0cf4aa60d08 100644
--- a/src/nsterm.h
+++ b/src/nsterm.h
@@ -675,9 +675,9 @@ struct x_output
675#define FRAME_FONT(f) ((f)->output_data.ns->font) 675#define FRAME_FONT(f) ((f)->output_data.ns->font)
676 676
677#ifdef __OBJC__ 677#ifdef __OBJC__
678#define XNS_SCROLL_BAR(vec) ((id) XSAVE_POINTER (vec)) 678#define XNS_SCROLL_BAR(vec) ((id) XSAVE_POINTER (vec, 0))
679#else 679#else
680#define XNS_SCROLL_BAR(vec) XSAVE_POINTER (vec) 680#define XNS_SCROLL_BAR(vec) XSAVE_POINTER (vec, 0)
681#endif 681#endif
682 682
683/* Compute pixel size for vertical scroll bars */ 683/* Compute pixel size for vertical scroll bars */
diff --git a/src/xfns.c b/src/xfns.c
index fe99d36f9f4..65148d1c9e1 100644
--- a/src/xfns.c
+++ b/src/xfns.c
@@ -5292,7 +5292,7 @@ file_dialog_unmap_cb (Widget widget, XtPointer client_data, XtPointer call_data)
5292static Lisp_Object 5292static Lisp_Object
5293clean_up_file_dialog (Lisp_Object arg) 5293clean_up_file_dialog (Lisp_Object arg)
5294{ 5294{
5295 Widget dialog = XSAVE_POINTER (arg); 5295 Widget dialog = XSAVE_POINTER (arg, 0);
5296 5296
5297 /* Clean up. */ 5297 /* Clean up. */
5298 block_input (); 5298 block_input ();
diff --git a/src/xmenu.c b/src/xmenu.c
index 6d880993d19..56a3783127e 100644
--- a/src/xmenu.c
+++ b/src/xmenu.c
@@ -1413,7 +1413,7 @@ pop_down_menu (Lisp_Object arg)
1413{ 1413{
1414 popup_activated_flag = 0; 1414 popup_activated_flag = 0;
1415 block_input (); 1415 block_input ();
1416 gtk_widget_destroy (GTK_WIDGET (XSAVE_POINTER (arg))); 1416 gtk_widget_destroy (GTK_WIDGET (XSAVE_POINTER (arg, 0)));
1417 unblock_input (); 1417 unblock_input ();
1418 return Qnil; 1418 return Qnil;
1419} 1419}
@@ -1610,7 +1610,7 @@ create_and_show_popup_menu (FRAME_PTR f, widget_value *first_wv,
1610static Lisp_Object 1610static Lisp_Object
1611cleanup_widget_value_tree (Lisp_Object arg) 1611cleanup_widget_value_tree (Lisp_Object arg)
1612{ 1612{
1613 free_menubar_widget_value_tree (XSAVE_POINTER (arg)); 1613 free_menubar_widget_value_tree (XSAVE_POINTER (arg, 0));
1614 return Qnil; 1614 return Qnil;
1615} 1615}
1616 1616
@@ -2236,8 +2236,8 @@ menu_help_callback (char const *help_string, int pane, int item)
2236static Lisp_Object 2236static Lisp_Object
2237pop_down_menu (Lisp_Object arg) 2237pop_down_menu (Lisp_Object arg)
2238{ 2238{
2239 FRAME_PTR f = XSAVE_POINTER (Fcar (arg)); 2239 FRAME_PTR f = XSAVE_POINTER (Fcar (arg), 0);
2240 XMenu *menu = XSAVE_POINTER (Fcdr (arg)); 2240 XMenu *menu = XSAVE_POINTER (Fcdr (arg), 0);
2241 2241
2242 block_input (); 2242 block_input ();
2243#ifndef MSDOS 2243#ifndef MSDOS
diff --git a/src/xselect.c b/src/xselect.c
index 9abfb2931f8..b7cdf70ff77 100644
--- a/src/xselect.c
+++ b/src/xselect.c
@@ -1120,7 +1120,7 @@ unexpect_property_change (struct prop_location *location)
1120static Lisp_Object 1120static Lisp_Object
1121wait_for_property_change_unwind (Lisp_Object loc) 1121wait_for_property_change_unwind (Lisp_Object loc)
1122{ 1122{
1123 struct prop_location *location = XSAVE_POINTER (loc); 1123 struct prop_location *location = XSAVE_POINTER (loc, 0);
1124 1124
1125 unexpect_property_change (location); 1125 unexpect_property_change (location);
1126 if (location == property_change_reply_object) 1126 if (location == property_change_reply_object)