From 49faeaaf89c820082ba816d089fab5711c9d2b06 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Thu, 28 Nov 2013 21:25:25 -0800 Subject: [PATCH] Fix minor problems found by static checking. * buffer.h (struct buffer_text, struct buffer): * frame.h (struct frame): * window.h (struct window): Avoid 'bool foo : 1;', as it's not portable to pre-C99 compilers, as described in ../lib/stdbool.in.h. Use 'unsigned foo : 1;' instead. * menu.c (syms_of_menu): Define x-popup-dialog, removing a no-longer-valid use of HAVE_MENUS. * xdisp.c (propagate_buffer_redisplay): Now static. --- src/ChangeLog | 12 ++++++++++++ src/buffer.h | 8 ++++---- src/frame.h | 44 ++++++++++++++++++++++---------------------- src/menu.c | 3 --- src/window.h | 32 ++++++++++++++++---------------- src/xdisp.c | 27 ++++++++++++++++----------- 6 files changed, 70 insertions(+), 56 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 134e082a1c9..d117bc2bfba 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,15 @@ +2013-11-29 Paul Eggert + + Fix minor problems found by static checking. + * buffer.h (struct buffer_text, struct buffer): + * frame.h (struct frame): + * window.h (struct window): + Avoid 'bool foo : 1;', as it's not portable to pre-C99 compilers, + as described in ../lib/stdbool.in.h. Use 'unsigned foo : 1;' instead. + * menu.c (syms_of_menu): Define x-popup-dialog, removing a + no-longer-valid use of HAVE_MENUS. + * xdisp.c (propagate_buffer_redisplay): Now static. + 2013-11-29 Stefan Monnier * xmenu.c (Fmenu_or_popup_active_p): diff --git a/src/buffer.h b/src/buffer.h index d26f91b5b06..586090fbe88 100644 --- a/src/buffer.h +++ b/src/buffer.h @@ -475,10 +475,10 @@ struct buffer_text /* Usually 0. Temporarily set to 1 in decode_coding_gap to prevent Fgarbage_collect from shrinking the gap and losing not-yet-decoded bytes. */ - bool inhibit_shrinking : 1; + unsigned inhibit_shrinking : 1; /* True if it needs to be redisplayed. */ - bool redisplay : 1; + unsigned redisplay : 1; }; /* Most code should use this macro to access Lisp fields in struct buffer. */ @@ -849,10 +849,10 @@ struct buffer /* Non-zero means don't use redisplay optimizations for displaying this buffer. */ - bool prevent_redisplay_optimizations_p : 1; + unsigned prevent_redisplay_optimizations_p : 1; /* Non-zero whenever the narrowing is changed in this buffer. */ - bool clip_changed : 1; + unsigned clip_changed : 1; /* List of overlays that end at or before the current center, in order of end-position. */ diff --git a/src/frame.h b/src/frame.h index cf42f787fae..657ef489590 100644 --- a/src/frame.h +++ b/src/frame.h @@ -178,44 +178,44 @@ struct frame /* 1 means that glyphs on this frame have been initialized so it can be used for output. */ - bool glyphs_initialized_p : 1; + unsigned glyphs_initialized_p : 1; /* Set to non-zero in change_frame_size when size of frame changed Clear the frame in clear_garbaged_frames if set. */ - bool resized_p : 1; + unsigned resized_p : 1; /* Set to non-zero if the default face for the frame has been realized. Reset to zero whenever the default face changes. Used to see the difference between a font change and face change. */ - bool default_face_done_p : 1; + unsigned default_face_done_p : 1; /* Set to non-zero if this frame has already been hscrolled during current redisplay. */ - bool already_hscrolled_p : 1; + unsigned already_hscrolled_p : 1; /* Set to non-zero when current redisplay has updated frame. */ - bool updated_p : 1; + unsigned updated_p : 1; #if defined (HAVE_WINDOW_SYSTEM) && ! defined (USE_GTK) && ! defined (HAVE_NS) /* Set to non-zero to minimize tool-bar height even when auto-resize-tool-bar is set to grow-only. */ - bool minimize_tool_bar_window_p : 1; + unsigned minimize_tool_bar_window_p : 1; #endif #if defined (USE_GTK) || defined (HAVE_NS) /* Nonzero means using a tool bar that comes from the toolkit. */ - bool external_tool_bar : 1; + unsigned external_tool_bar : 1; #endif /* Nonzero means that fonts have been loaded since the last glyph matrix adjustments. */ - bool fonts_changed : 1; + unsigned fonts_changed : 1; /* Nonzero means that cursor type has been changed. */ - bool cursor_type_changed : 1; + unsigned cursor_type_changed : 1; /* True if it needs to be redisplayed. */ - bool redisplay : 1; + unsigned redisplay : 1; /* Margin at the top of the frame. Used to display the tool-bar. */ int tool_bar_lines; @@ -330,7 +330,7 @@ struct frame #if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI) \ || defined (HAVE_NS) || defined (USE_GTK) /* Nonzero means using a menu bar that comes from the X toolkit. */ - bool external_menu_bar : 1; + unsigned external_menu_bar : 1; #endif /* Next two bitfields are mutually exclusive. They might both be @@ -349,43 +349,43 @@ struct frame /* Nonzero if the frame is currently iconified. Do not set this directly, use SET_FRAME_ICONIFIED instead. */ - bool iconified : 1; + unsigned iconified : 1; /* Nonzero if this frame should be redrawn. */ - bool garbaged : 1; + unsigned garbaged : 1; /* 0 means, if this frame has just one window, show no modeline for that window. */ - bool wants_modeline : 1; + unsigned wants_modeline : 1; /* Non-0 means raise this frame to the top of the heap when selected. */ - bool auto_raise : 1; + unsigned auto_raise : 1; /* Non-0 means lower this frame to the bottom of the stack when left. */ - bool auto_lower : 1; + unsigned auto_lower : 1; /* True if frame's root window can't be split. */ - bool no_split : 1; + unsigned no_split : 1; /* If this is set, then Emacs won't change the frame name to indicate the current buffer, etcetera. If the user explicitly sets the frame name, this gets set. If the user sets the name to Qnil, this is cleared. */ - bool explicit_name : 1; + unsigned explicit_name : 1; /* Nonzero if size of some window on this frame has changed. */ - bool window_sizes_changed : 1; + unsigned window_sizes_changed : 1; /* Nonzero if the mouse has moved on this display device since the last time we checked. */ - bool mouse_moved : 1; + unsigned mouse_moved : 1; /* Nonzero means that the pointer is invisible. */ - bool pointer_invisible : 1; + unsigned pointer_invisible : 1; /* Nonzero means that all windows except mini-window and selected window on this frame have frozen window starts. */ - bool frozen_window_starts : 1; + unsigned frozen_window_starts : 1; /* Nonzero if we should actually display the scroll bars on this frame. */ enum vertical_scroll_bar_type vertical_scroll_bar_type; diff --git a/src/menu.c b/src/menu.c index 9ef3b88fe86..e33c647d020 100644 --- a/src/menu.c +++ b/src/menu.c @@ -1606,9 +1606,6 @@ syms_of_menu (void) menu_items_inuse = Qnil; defsubr (&Sx_popup_menu); - -#ifdef HAVE_MENUS defsubr (&Sx_popup_dialog); -#endif defsubr (&Smenu_bar_menu_at_x_y); } diff --git a/src/window.h b/src/window.h index a81c1054070..555c386d7bd 100644 --- a/src/window.h +++ b/src/window.h @@ -282,63 +282,63 @@ struct window int window_end_vpos; /* Non-zero if this window is a minibuffer window. */ - bool mini : 1; + unsigned mini : 1; /* Meaningful only if contents is a window, non-zero if this internal window is used in horizontal combination. */ - bool horizontal : 1; + unsigned horizontal : 1; /* Non-zero means must regenerate mode line of this window. */ - bool update_mode_line : 1; + unsigned update_mode_line : 1; /* Non-nil if the buffer was "modified" when the window was last updated. */ - bool last_had_star : 1; + unsigned last_had_star : 1; /* Non-zero means current value of `start' was the beginning of a line when it was chosen. */ - bool start_at_line_beg : 1; + unsigned start_at_line_beg : 1; /* Non-zero means next redisplay must use the value of start set up for it in advance. Set by scrolling commands. */ - bool force_start : 1; + unsigned force_start : 1; /* Non-zero means we have explicitly changed the value of start, but that the next redisplay is not obliged to use the new value. This is used in Fdelete_other_windows to force a call to Vwindow_scroll_functions; also by Frecenter with argument. */ - bool optional_new_start : 1; + unsigned optional_new_start : 1; /* Non-zero means the cursor is currently displayed. This can be set to zero by functions overpainting the cursor image. */ - bool phys_cursor_on_p : 1; + unsigned phys_cursor_on_p : 1; /* 0 means cursor is logically on, 1 means it's off. Used for blinking cursor. */ - bool cursor_off_p : 1; + unsigned cursor_off_p : 1; /* Value of cursor_off_p as of the last redisplay. */ - bool last_cursor_off_p : 1; + unsigned last_cursor_off_p : 1; /* 1 means desired matrix has been build and window must be updated in update_frame. */ - bool must_be_updated_p : 1; + unsigned must_be_updated_p : 1; /* Flag indicating that this window is not a real one. Currently only used for menu bar windows of frames. */ - bool pseudo_window_p : 1; + unsigned pseudo_window_p : 1; /* Non-zero means fringes are drawn outside display margins. Otherwise draw them between margin areas and text. */ - bool fringes_outside_margins : 1; + unsigned fringes_outside_margins : 1; /* Nonzero if window_end_pos and window_end_vpos are truly valid. This is zero if nontrivial redisplay is preempted since in that case the frame image that window_end_pos did not get onto the frame. */ - bool window_end_valid : 1; + unsigned window_end_valid : 1; /* True if it needs to be redisplayed. */ - bool redisplay : 1; + unsigned redisplay : 1; /* Amount by which lines of this window are scrolled in y-direction (smooth scrolling). */ @@ -347,7 +347,7 @@ struct window /* Z_BYTE - buffer position of the last glyph in the current matrix of W. Should be nonnegative, and only valid if window_end_valid is nonzero. */ ptrdiff_t window_end_bytepos; -}; + }; /* Most code should use these functions to set Lisp fields in struct window. */ diff --git a/src/xdisp.c b/src/xdisp.c index 16e6341748d..6357f4f5f3b 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -610,25 +610,29 @@ bool help_echo_showing_p; /* Functions to mark elements as needing redisplay. */ enum { REDISPLAY_SOME = 2}; /* Arbitrary choice. */ -void redisplay_other_windows (void) +void +redisplay_other_windows (void) { if (!windows_or_buffers_changed) windows_or_buffers_changed = REDISPLAY_SOME; } -void wset_redisplay (struct window *w) +void +wset_redisplay (struct window *w) { redisplay_other_windows (); w->redisplay = true; } -void fset_redisplay (struct frame *f) +void +fset_redisplay (struct frame *f) { redisplay_other_windows (); f->redisplay = true; } -void bset_redisplay (struct buffer *b) +void +bset_redisplay (struct buffer *b) { int count = buffer_window_count (b); if (count > 0) @@ -643,7 +647,8 @@ void bset_redisplay (struct buffer *b) } } -extern void bset_update_mode_line (struct buffer *b) +void +bset_update_mode_line (struct buffer *b) { if (!update_mode_lines) update_mode_lines = REDISPLAY_SOME; @@ -11201,11 +11206,10 @@ static void prepare_menu_bars (void) { bool all_windows = windows_or_buffers_changed || update_mode_lines; - bool some_windows - = (windows_or_buffers_changed == 0 - || windows_or_buffers_changed == REDISPLAY_SOME) - && (update_mode_lines == 0 - || update_mode_lines == REDISPLAY_SOME); + bool some_windows = ((windows_or_buffers_changed == 0 + || windows_or_buffers_changed == REDISPLAY_SOME) + && (update_mode_lines == 0 + || update_mode_lines == REDISPLAY_SOME)); struct gcpro gcpro1, gcpro2; Lisp_Object tooltip_frame; @@ -12922,7 +12926,8 @@ reconsider_clip_changes (struct window *w) } } -void propagate_buffer_redisplay (void) +static void +propagate_buffer_redisplay (void) { /* Resetting b->text->redisplay is problematic! We can't just reset it in the case that some window that displays it has not been redisplayed; and such a window can stay -- 2.11.4.GIT