aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPaul Eggert2012-07-07 12:23:41 -0700
committerPaul Eggert2012-07-07 12:23:41 -0700
commit6045c4fdb88ee6bd84afcaac4a0b7e8a96f23050 (patch)
tree86959a892e16b2947b794a6ad993f0090387fab3 /src
parent41f9404e0cb421fcea07538bbd686d54200ed92d (diff)
downloademacs-6045c4fdb88ee6bd84afcaac4a0b7e8a96f23050.tar.gz
emacs-6045c4fdb88ee6bd84afcaac4a0b7e8a96f23050.zip
Improve static checking when configured --with-ns.
See Samuel Bronson's remarks in <http://lists.gnu.org/archive/html/emacs-devel/2012-07/msg00146.html>. * configure.in (WARN_CFLAGS): Omit -Wunreachable-code, as it's a no-op with recent GCC and harmful in earlier ones. Omit -Wsync-nand, as it's irrelevant to Emacs and provokes a warning when compiling with ObjC. Always omit -Wunsafe-loop-optimizations, as we don't mind when optimization is being done correctly. Fix some minor --with-ns problems found by static checking. * src/frame.c (Ftool_bar_pixel_width) [!FRAME_TOOLBAR_WIDTH]: (x_set_font) [!HAVE_X_WINDOWS]: * src/image.c (xpm_load_image) [HAVE_NS]: (x_to_xcolors) [!HAVE_X_WINDOWS && !HAVE_NTGUI]: (x_disable_image) [!HAVE_NS && !HAVE_NTGUI]: Remove unused local. (Fx_parse_geometry) [HAVE_NS]: Don't return garbage. (xpm_load_image) [HAVE_NS && !HAVE_XPM]: Remove unused label. * src/image.c (x_create_bitmap_from_file) [HAVE_NS]: (xpm_load_image, xpm_load) [HAVE_NS && !HAVE_XPM]: * src/nsselect.m (symbol_to_nsstring, ns_string_to_pasteboard_internal): * src/xfaces.c (Fx_load_color_file) [!HAVE_X_WINDOWS]: Fix pointer signedness problem. * src/xfaces.c (FRAME_X_FONT_TABLE): * src/xterm.h (FRAME_X_FONT_TABLE): Remove unused, incompatible macros.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog19
-rw-r--r--src/frame.c19
-rw-r--r--src/image.c16
-rw-r--r--src/nsselect.m8
-rw-r--r--src/xfaces.c4
-rw-r--r--src/xterm.h3
6 files changed, 41 insertions, 28 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 87ea886720c..14d82ee3ecb 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,22 @@
12012-07-07 Paul Eggert <eggert@cs.ucla.edu>
2
3 Fix some minor --with-ns problems found by static checking.
4 * frame.c (Ftool_bar_pixel_width) [!FRAME_TOOLBAR_WIDTH]:
5 (x_set_font) [!HAVE_X_WINDOWS]:
6 * image.c (xpm_load_image) [HAVE_NS]:
7 (x_to_xcolors) [!HAVE_X_WINDOWS && !HAVE_NTGUI]:
8 (x_disable_image) [!HAVE_NS && !HAVE_NTGUI]:
9 Remove unused local.
10 (Fx_parse_geometry) [HAVE_NS]: Don't return garbage.
11 (xpm_load_image) [HAVE_NS && !HAVE_XPM]: Remove unused label.
12 * image.c (x_create_bitmap_from_file) [HAVE_NS]:
13 (xpm_load_image, xpm_load) [HAVE_NS && !HAVE_XPM]:
14 * nsselect.m (symbol_to_nsstring, ns_string_to_pasteboard_internal):
15 * xfaces.c (Fx_load_color_file) [!HAVE_X_WINDOWS]:
16 Fix pointer signedness problem.
17 * xfaces.c (FRAME_X_FONT_TABLE):
18 * xterm.h (FRAME_X_FONT_TABLE): Remove unused, incompatible macros.
19
12012-07-07 Glenn Morris <rgm@gnu.org> 202012-07-07 Glenn Morris <rgm@gnu.org>
2 21
3 * lread.c (load_path_check): New function, split from init_lread. 22 * lread.c (load_path_check): New function, split from init_lread.
diff --git a/src/frame.c b/src/frame.c
index 8db943bd0a5..c0293f6c869 100644
--- a/src/frame.c
+++ b/src/frame.c
@@ -2504,16 +2504,13 @@ or right side of FRAME. If FRAME is omitted, the selected frame is
2504used. */) 2504used. */)
2505 (Lisp_Object frame) 2505 (Lisp_Object frame)
2506{ 2506{
2507 struct frame *f;
2508
2509 if (NILP (frame)) 2507 if (NILP (frame))
2510 frame = selected_frame; 2508 frame = selected_frame;
2511 CHECK_FRAME (frame); 2509 CHECK_FRAME (frame);
2512 f = XFRAME (frame);
2513 2510
2514#ifdef FRAME_TOOLBAR_WIDTH 2511#ifdef FRAME_TOOLBAR_WIDTH
2515 if (FRAME_WINDOW_P (f)) 2512 if (FRAME_WINDOW_P (XFRAME (frame)))
2516 return make_number (FRAME_TOOLBAR_WIDTH (f)); 2513 return make_number (FRAME_TOOLBAR_WIDTH (XFRAME (frame)));
2517#endif 2514#endif
2518 return make_number (0); 2515 return make_number (0);
2519} 2516}
@@ -3158,8 +3155,11 @@ x_set_screen_gamma (struct frame *f, Lisp_Object new_value, Lisp_Object old_valu
3158void 3155void
3159x_set_font (struct frame *f, Lisp_Object arg, Lisp_Object oldval) 3156x_set_font (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
3160{ 3157{
3161 Lisp_Object font_object, font_param = Qnil; 3158 Lisp_Object font_object;
3162 int fontset = -1; 3159 int fontset = -1;
3160#ifdef HAVE_X_WINDOWS
3161 Lisp_Object font_param = arg;
3162#endif
3163 3163
3164 /* Set the frame parameter back to the old value because we may 3164 /* Set the frame parameter back to the old value because we may
3165 fail to use ARG as the new parameter value. */ 3165 fail to use ARG as the new parameter value. */
@@ -3170,7 +3170,6 @@ x_set_font (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
3170 never fail. */ 3170 never fail. */
3171 if (STRINGP (arg)) 3171 if (STRINGP (arg))
3172 { 3172 {
3173 font_param = arg;
3174 fontset = fs_query_fontset (arg, 0); 3173 fontset = fs_query_fontset (arg, 0);
3175 if (fontset < 0) 3174 if (fontset < 0)
3176 { 3175 {
@@ -3201,12 +3200,16 @@ x_set_font (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
3201 error ("Unknown fontset: %s", SDATA (XCAR (arg))); 3200 error ("Unknown fontset: %s", SDATA (XCAR (arg)));
3202 font_object = XCDR (arg); 3201 font_object = XCDR (arg);
3203 arg = AREF (font_object, FONT_NAME_INDEX); 3202 arg = AREF (font_object, FONT_NAME_INDEX);
3203#ifdef HAVE_X_WINDOWS
3204 font_param = Ffont_get (font_object, QCname); 3204 font_param = Ffont_get (font_object, QCname);
3205#endif
3205 } 3206 }
3206 else if (FONT_OBJECT_P (arg)) 3207 else if (FONT_OBJECT_P (arg))
3207 { 3208 {
3208 font_object = arg; 3209 font_object = arg;
3210#ifdef HAVE_X_WINDOWS
3209 font_param = Ffont_get (font_object, QCname); 3211 font_param = Ffont_get (font_object, QCname);
3212#endif
3210 /* This is to store the XLFD font name in the frame parameter for 3213 /* This is to store the XLFD font name in the frame parameter for
3211 backward compatibility. We should store the font-object 3214 backward compatibility. We should store the font-object
3212 itself in the future. */ 3215 itself in the future. */
@@ -3902,7 +3905,7 @@ On Nextstep, this just calls `ns-parse-geometry'. */)
3902 (Lisp_Object string) 3905 (Lisp_Object string)
3903{ 3906{
3904#ifdef HAVE_NS 3907#ifdef HAVE_NS
3905 call1 (Qns_parse_geometry, string); 3908 return call1 (Qns_parse_geometry, string);
3906#else 3909#else
3907 int geometry, x, y; 3910 int geometry, x, y;
3908 unsigned int width, height; 3911 unsigned int width, height;
diff --git a/src/image.c b/src/image.c
index 4877d262d00..0854d017163 100644
--- a/src/image.c
+++ b/src/image.c
@@ -323,7 +323,7 @@ x_create_bitmap_from_file (struct frame *f, Lisp_Object file)
323 dpyinfo->bitmaps[id - 1].depth = 1; 323 dpyinfo->bitmaps[id - 1].depth = 1;
324 dpyinfo->bitmaps[id - 1].height = ns_image_width (bitmap); 324 dpyinfo->bitmaps[id - 1].height = ns_image_width (bitmap);
325 dpyinfo->bitmaps[id - 1].width = ns_image_height (bitmap); 325 dpyinfo->bitmaps[id - 1].width = ns_image_height (bitmap);
326 strcpy (dpyinfo->bitmaps[id - 1].file, SDATA (file)); 326 strcpy (dpyinfo->bitmaps[id - 1].file, SSDATA (file));
327 return id; 327 return id;
328#endif 328#endif
329 329
@@ -3964,7 +3964,7 @@ xpm_load_image (struct frame *f,
3964 { 3964 {
3965 if (xstrcasecmp (SSDATA (XCDR (specified_color)), "None") == 0) 3965 if (xstrcasecmp (SSDATA (XCDR (specified_color)), "None") == 0)
3966 color_val = Qt; 3966 color_val = Qt;
3967 else if (x_defined_color (f, SDATA (XCDR (specified_color)), 3967 else if (x_defined_color (f, SSDATA (XCDR (specified_color)),
3968 &cdef, 0)) 3968 &cdef, 0))
3969 color_val = make_number (cdef.pixel); 3969 color_val = make_number (cdef.pixel);
3970 } 3970 }
@@ -4039,7 +4039,6 @@ xpm_load_image (struct frame *f,
4039 4039
4040 failure: 4040 failure:
4041 image_error ("Invalid XPM file (%s)", img->spec, Qnil); 4041 image_error ("Invalid XPM file (%s)", img->spec, Qnil);
4042 error:
4043 x_destroy_x_image (ximg); 4042 x_destroy_x_image (ximg);
4044 x_destroy_x_image (mask_img); 4043 x_destroy_x_image (mask_img);
4045 x_clear_image (f, img); 4044 x_clear_image (f, img);
@@ -4072,7 +4071,7 @@ xpm_load (struct frame *f,
4072 return 0; 4071 return 0;
4073 } 4072 }
4074 4073
4075 contents = slurp_file (SDATA (file), &size); 4074 contents = slurp_file (SSDATA (file), &size);
4076 if (contents == NULL) 4075 if (contents == NULL)
4077 { 4076 {
4078 image_error ("Error loading XPM image `%s'", img->spec, Qnil); 4077 image_error ("Error loading XPM image `%s'", img->spec, Qnil);
@@ -4456,9 +4455,8 @@ x_to_xcolors (struct frame *f, struct image *img, int rgb_p)
4456 p = colors; 4455 p = colors;
4457 for (y = 0; y < img->height; ++y) 4456 for (y = 0; y < img->height; ++y)
4458 { 4457 {
4459 XColor *row = p;
4460
4461#if defined (HAVE_X_WINDOWS) || defined (HAVE_NTGUI) 4458#if defined (HAVE_X_WINDOWS) || defined (HAVE_NTGUI)
4459 XColor *row = p;
4462 for (x = 0; x < img->width; ++x, ++p) 4460 for (x = 0; x < img->width; ++x, ++p)
4463 p->pixel = GET_PIXEL (ximg, x, y); 4461 p->pixel = GET_PIXEL (ximg, x, y);
4464 if (rgb_p) 4462 if (rgb_p)
@@ -4741,14 +4739,12 @@ x_disable_image (struct frame *f, struct image *img)
4741 if (n_planes < 2 || cross_disabled_images) 4739 if (n_planes < 2 || cross_disabled_images)
4742 { 4740 {
4743#ifndef HAVE_NTGUI 4741#ifndef HAVE_NTGUI
4744 Display *dpy = FRAME_X_DISPLAY (f);
4745 GC gc;
4746
4747#ifndef HAVE_NS /* TODO: NS support, however this not needed for toolbars */ 4742#ifndef HAVE_NS /* TODO: NS support, however this not needed for toolbars */
4748 4743
4749#define MaskForeground(f) WHITE_PIX_DEFAULT (f) 4744#define MaskForeground(f) WHITE_PIX_DEFAULT (f)
4750 4745
4751 gc = XCreateGC (dpy, img->pixmap, 0, NULL); 4746 Display *dpy = FRAME_X_DISPLAY (f);
4747 GC gc = XCreateGC (dpy, img->pixmap, 0, NULL);
4752 XSetForeground (dpy, gc, BLACK_PIX_DEFAULT (f)); 4748 XSetForeground (dpy, gc, BLACK_PIX_DEFAULT (f));
4753 XDrawLine (dpy, img->pixmap, gc, 0, 0, 4749 XDrawLine (dpy, img->pixmap, gc, 0, 0,
4754 img->width - 1, img->height - 1); 4750 img->width - 1, img->height - 1);
diff --git a/src/nsselect.m b/src/nsselect.m
index 6352d882b7a..a4d91dae1f2 100644
--- a/src/nsselect.m
+++ b/src/nsselect.m
@@ -62,7 +62,7 @@ symbol_to_nsstring (Lisp_Object sym)
62 if (EQ (sym, QPRIMARY)) return NXPrimaryPboard; 62 if (EQ (sym, QPRIMARY)) return NXPrimaryPboard;
63 if (EQ (sym, QSECONDARY)) return NXSecondaryPboard; 63 if (EQ (sym, QSECONDARY)) return NXSecondaryPboard;
64 if (EQ (sym, QTEXT)) return NSStringPboardType; 64 if (EQ (sym, QTEXT)) return NSStringPboardType;
65 return [NSString stringWithUTF8String: SDATA (XSYMBOL (sym)->xname)]; 65 return [NSString stringWithUTF8String: SSDATA (XSYMBOL (sym)->xname)];
66} 66}
67 67
68static NSPasteboard * 68static NSPasteboard *
@@ -157,7 +157,7 @@ ns_string_to_pasteboard_internal (id pb, Lisp_Object str, NSString *gtype)
157 157
158 CHECK_STRING (str); 158 CHECK_STRING (str);
159 159
160 utfStr = SDATA (str); 160 utfStr = SSDATA (str);
161 nsStr = [[NSString alloc] initWithBytesNoCopy: utfStr 161 nsStr = [[NSString alloc] initWithBytesNoCopy: utfStr
162 length: SBYTES (str) 162 length: SBYTES (str)
163 encoding: NSUTF8StringEncoding 163 encoding: NSUTF8StringEncoding
@@ -388,7 +388,7 @@ On Nextstep, FRAME is unused. */)
388 for (rest = Vns_sent_selection_hooks; CONSP (rest); rest = Fcdr (rest)) 388 for (rest = Vns_sent_selection_hooks; CONSP (rest); rest = Fcdr (rest))
389 call3 (Fcar (rest), selection, target_symbol, successful_p); 389 call3 (Fcar (rest), selection, target_symbol, successful_p);
390 } 390 }
391 391
392 return value; 392 return value;
393} 393}
394 394
@@ -443,7 +443,7 @@ On Nextstep, TERMINAL is unused. */)
443 if (EQ (selection, Qt)) selection = QSECONDARY; 443 if (EQ (selection, Qt)) selection = QSECONDARY;
444 pb = ns_symbol_to_pb (selection); 444 pb = ns_symbol_to_pb (selection);
445 if (pb == nil) return Qnil; 445 if (pb == nil) return Qnil;
446 446
447 types = [pb types]; 447 types = [pb types];
448 return ([types count] == 0) ? Qnil : Qt; 448 return ([types count] == 0) ? Qnil : Qt;
449} 449}
diff --git a/src/xfaces.c b/src/xfaces.c
index bc42cb4312a..a6b260a2929 100644
--- a/src/xfaces.c
+++ b/src/xfaces.c
@@ -233,7 +233,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
233#undef FRAME_X_DISPLAY_INFO 233#undef FRAME_X_DISPLAY_INFO
234#define FRAME_X_DISPLAY_INFO FRAME_W32_DISPLAY_INFO 234#define FRAME_X_DISPLAY_INFO FRAME_W32_DISPLAY_INFO
235#define x_display_info w32_display_info 235#define x_display_info w32_display_info
236#define FRAME_X_FONT_TABLE FRAME_W32_FONT_TABLE
237#define check_x check_w32 236#define check_x check_w32
238#define GCGraphicsExposures 0 237#define GCGraphicsExposures 0
239#endif /* WINDOWSNT */ 238#endif /* WINDOWSNT */
@@ -243,7 +242,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
243#undef FRAME_X_DISPLAY_INFO 242#undef FRAME_X_DISPLAY_INFO
244#define FRAME_X_DISPLAY_INFO FRAME_NS_DISPLAY_INFO 243#define FRAME_X_DISPLAY_INFO FRAME_NS_DISPLAY_INFO
245#define x_display_info ns_display_info 244#define x_display_info ns_display_info
246#define FRAME_X_FONT_TABLE FRAME_NS_FONT_TABLE
247#define check_x check_ns 245#define check_x check_ns
248#define GCGraphicsExposures 0 246#define GCGraphicsExposures 0
249#endif /* HAVE_NS */ 247#endif /* HAVE_NS */
@@ -6381,7 +6379,7 @@ where R,G,B are numbers between 0 and 255 and name is an arbitrary string. */)
6381 CHECK_STRING (filename); 6379 CHECK_STRING (filename);
6382 abspath = Fexpand_file_name (filename, Qnil); 6380 abspath = Fexpand_file_name (filename, Qnil);
6383 6381
6384 fp = fopen (SDATA (abspath), "rt"); 6382 fp = fopen (SSDATA (abspath), "rt");
6385 if (fp) 6383 if (fp)
6386 { 6384 {
6387 char buf[512]; 6385 char buf[512];
diff --git a/src/xterm.h b/src/xterm.h
index 573d8bf966c..86a76fd81a9 100644
--- a/src/xterm.h
+++ b/src/xterm.h
@@ -736,9 +736,6 @@ enum
736/* This is the Colormap which frame F uses. */ 736/* This is the Colormap which frame F uses. */
737#define FRAME_X_COLORMAP(f) FRAME_X_DISPLAY_INFO (f)->cmap 737#define FRAME_X_COLORMAP(f) FRAME_X_DISPLAY_INFO (f)->cmap
738 738
739/* This is the 'font_info *' which frame F has. */
740#define FRAME_X_FONT_TABLE(f) (FRAME_X_DISPLAY_INFO (f)->font_table)
741
742/* The difference in pixels between the top left corner of the 739/* The difference in pixels between the top left corner of the
743 Emacs window (including possible window manager decorations) 740 Emacs window (including possible window manager decorations)
744 and FRAME_X_WINDOW (f). */ 741 and FRAME_X_WINDOW (f). */