diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2011-04-16 16:11:35 -0700 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2011-04-16 16:11:35 -0700 |
commit | fd35b6f96777be3305879a9ca60ab5befb254042 (patch) | |
tree | db72c649acdc7f53d9672fba88b6a08b3601cdda | |
parent | c4354cb4f4a3982331180439120ca72734d49cc5 (diff) | |
parent | 399c71d323b8beef139437311c78440d0033c652 (diff) | |
download | emacs-fd35b6f96777be3305879a9ca60ab5befb254042.tar.gz |
Static checks with GCC 4.6.0 and non-default toolkits.
72 files changed, 639 insertions, 471 deletions
diff --git a/lib-src/ChangeLog b/lib-src/ChangeLog index e3d7edf94bd..c45da107a8c 100644 --- a/lib-src/ChangeLog +++ b/lib-src/ChangeLog @@ -1,3 +1,18 @@ +2011-04-16 Paul Eggert <eggert@cs.ucla.edu> + + Static checks with GCC 4.6.0 and non-default toolkits. + + * movemail.c (mail_spool_name): Protoize. + (main): Remove unused var. Mark var as initialized. + Move locals to avoid shadowing, and use time_t for times. + + * fakemail.c (xmalloc, xreallc): Use standard C prototypes + with void *. This avoids warnings about pointer casts. + + * emacsclient.c (main): Don't use uninitialized var. + (IS_ANY_SEP): Remove; unused. + (get_current_dir_name): Add an extern decl. + 2011-04-06 Paul Eggert <eggert@cs.ucla.edu> Fix more problems found by GCC 4.6.0's static checks. diff --git a/lib-src/emacsclient.c b/lib-src/emacsclient.c index c5231fb9989..2aabc52e828 100644 --- a/lib-src/emacsclient.c +++ b/lib-src/emacsclient.c @@ -218,10 +218,8 @@ xmalloc (unsigned int size) #define IS_DEVICE_SEP(_c_) ((_c_) == DEVICE_SEP) #endif #endif -#ifndef IS_ANY_SEP -#define IS_ANY_SEP(_c_) (IS_DIRECTORY_SEP (_c_)) -#endif +char *get_current_dir_name (void); /* Return the current working directory. Returns NULL on errors. Any other returned value must be freed with free. This is used @@ -1524,7 +1522,7 @@ start_daemon_and_retry_set_socket (void) int main (int argc, char **argv) { - int rl, needlf = 0; + int rl = 0, needlf = 0; char *cwd, *str; char string[BUFSIZ+1]; int null_socket_name IF_LINT ( = 0); diff --git a/lib-src/fakemail.c b/lib-src/fakemail.c index 940d6219425..435512125ff 100644 --- a/lib-src/fakemail.c +++ b/lib-src/fakemail.c @@ -178,20 +178,20 @@ fatal (const char *s1) /* Like malloc but get fatal error if memory is exhausted. */ -static long * -xmalloc (int size) +static void * +xmalloc (size_t size) { - long *result = (long *) malloc (((unsigned) size)); - if (result == ((long *) NULL)) + void *result = malloc (size); + if (! result) fatal ("virtual memory exhausted"); return result; } -static long * -xrealloc (long int *ptr, int size) +static void * +xrealloc (void *ptr, size_t size) { - long *result = (long *) realloc (ptr, ((unsigned) size)); - if (result == ((long *) NULL)) + void *result = realloc (ptr, size); + if (! result) fatal ("virtual memory exhausted"); return result; } @@ -221,7 +221,7 @@ readline (struct linebuffer *linebuffer, FILE *stream) if (p == end) { linebuffer->size *= 2; - buffer = ((char *) xrealloc ((long *)buffer, linebuffer->size)); + buffer = (char *) xrealloc (buffer, linebuffer->size); p = buffer + (p - linebuffer->buffer); end = buffer + linebuffer->size; linebuffer->buffer = buffer; diff --git a/lib-src/movemail.c b/lib-src/movemail.c index 4a894c1cba1..4cf97cbac18 100644 --- a/lib-src/movemail.c +++ b/lib-src/movemail.c @@ -131,7 +131,7 @@ extern int lk_open (), lk_close (); files appear in. */ #ifdef MAILDIR #define MAIL_USE_MAILLOCK -static char *mail_spool_name (); +static char *mail_spool_name (char *); #endif #endif @@ -167,7 +167,6 @@ main (int argc, char **argv) #ifndef MAIL_USE_SYSTEM_LOCK struct stat st; - long now; int tem; char *lockname, *p; char *tempname; @@ -259,7 +258,13 @@ main (int argc, char **argv) #ifndef MAIL_USE_SYSTEM_LOCK #ifdef MAIL_USE_MAILLOCK spool_name = mail_spool_name (inname); - if (! spool_name) + if (spool_name) + { +#ifdef lint + lockname = 0; +#endif + } + else #endif { #ifndef DIRECTORY_SEP @@ -336,7 +341,7 @@ main (int argc, char **argv) by time differences between machines. */ if (stat (lockname, &st) >= 0) { - now = time (0); + time_t now = time (0); if (st.st_ctime < now - 300) unlink (lockname); } @@ -352,7 +357,10 @@ main (int argc, char **argv) int lockcount = 0; int status = 0; #if defined (MAIL_USE_MAILLOCK) && defined (HAVE_TOUCHLOCK) - time_t touched_lock, now; + time_t touched_lock; +# ifdef lint + touched_lock = 0; +# endif #endif if (setuid (getuid ()) < 0 || setregid (-1, real_gid) < 0) @@ -462,7 +470,7 @@ main (int argc, char **argv) #if defined (MAIL_USE_MAILLOCK) && defined (HAVE_TOUCHLOCK) if (spool_name) { - now = time (0); + time_t now = time (0); if (now - touched_lock > 60) { touchlock (); diff --git a/lwlib/ChangeLog b/lwlib/ChangeLog index 64ae2fe085d..e98526f2546 100644 --- a/lwlib/ChangeLog +++ b/lwlib/ChangeLog @@ -1,3 +1,19 @@ +2011-04-16 Paul Eggert <eggert@cs.ucla.edu> + + Static checks with GCC 4.6.0 and non-default toolkits. + + * lwlib-Xm.c (make_dialog): Rename local to avoid shadowing. + (make_menu_in_widget): Add cast to avoid warning. + * lwlib-utils.c (XtCompositeChildren): Likewise. + + * lwlib.c (EXPLAIN, destroy_one_instance): Avoid "else;". + (first_child) [USE_MOTIF]: Protoize. + + * lwlib-utils.h, lwlib-utils.c (XtSafelyDestroyWidget): Remove; unused. + + * xlwmenu.c (XlwMenuSetValues): Rename/ move locals to avoid shadowing. + (MINL): Define only if not emacs. + 2011-03-07 Chong Yidong <cyd@stupidchicken.com> * Version 23.3 released. diff --git a/lwlib/lwlib-Xm.c b/lwlib/lwlib-Xm.c index 55b27b9dab0..2b7677a02f5 100644 --- a/lwlib/lwlib-Xm.c +++ b/lwlib/lwlib-Xm.c @@ -511,7 +511,7 @@ make_menu_in_widget (widget_instance* instance, /* Allocate the children array */ for (num_children = 0, cur = val; cur; num_children++, cur = cur->next) ; - children = (Widget*)XtMalloc (num_children * sizeof (Widget)); + children = (Widget*)(void*)XtMalloc (num_children * sizeof (Widget)); /* WIDGET should be a RowColumn. */ if (!XmIsRowColumn (widget)) @@ -1020,10 +1020,10 @@ dialog_key_cb (Widget widget, { KeySym sym = 0; Modifiers modif_ret; - + XtTranslateKeycode (event->xkey.display, event->xkey.keycode, 0, &modif_ret, &sym); - + if (sym == osfXK_Cancel) { Widget w = *((Widget *) closure); @@ -1055,7 +1055,7 @@ make_dialog (char* name, Widget row; Widget icon; Widget icon_separator; - Widget message; + Widget message_label; Widget value = 0; Widget separator; Widget button = 0; @@ -1269,7 +1269,7 @@ make_dialog (char* name, XtSetArg(al[ac], XmNleftWidget, icon); ac++; XtSetArg(al[ac], XmNrightAttachment, XmATTACH_FORM); ac++; XtSetArg(al[ac], XmNrightOffset, 13); ac++; - message = XmCreateLabel (form, "message", al, ac); + message_label = XmCreateLabel (form, "message", al, ac); if (list) XtManageChild (value); @@ -1281,7 +1281,7 @@ make_dialog (char* name, { children [i] = value; i++; } - children [i] = message; i++; + children [i] = message_label; i++; children [i] = icon; i++; children [i] = icon_separator; i++; XtManageChildren (children, i); diff --git a/lwlib/lwlib-utils.c b/lwlib/lwlib-utils.c index a3e1cb3b432..7a0dd1b264a 100644 --- a/lwlib/lwlib-utils.c +++ b/lwlib/lwlib-utils.c @@ -129,7 +129,7 @@ XtCompositeChildren (Widget widget, unsigned int *number) return NULL; } n = cw->composite.num_children; - result = (Widget*)XtMalloc (n * sizeof (Widget)); + result = (Widget*)(void*)XtMalloc (n * sizeof (Widget)); *number = n; for (i = 0; i < n; i++) result [i] = cw->composite.children [i]; @@ -141,29 +141,3 @@ XtWidgetBeingDestroyedP (Widget widget) { return widget->core.being_destroyed; } - -void -XtSafelyDestroyWidget (Widget widget) -{ -#if 0 - - /* this requires IntrinsicI.h (actually, InitialI.h) */ - - XtAppContext app = XtWidgetToApplicationContext(widget); - - if (app->dispatch_level == 0) - { - app->dispatch_level = 1; - XtDestroyWidget (widget); - /* generates an event so that the event loop will be called */ - XChangeProperty (XtDisplay (widget), XtWindow (widget), - XA_STRING, XA_STRING, 32, PropModeAppend, NULL, 0); - app->dispatch_level = 0; - } - else - XtDestroyWidget (widget); - -#else - abort (); -#endif -} diff --git a/lwlib/lwlib-utils.h b/lwlib/lwlib-utils.h index b988374288a..ec3daab94ef 100644 --- a/lwlib/lwlib-utils.h +++ b/lwlib/lwlib-utils.h @@ -15,7 +15,4 @@ Widget *XtCompositeChildren (Widget, unsigned int *); Boolean XtWidgetBeingDestroyedP (Widget widget); -void XtSafelyDestroyWidget (Widget); - #endif /* _LWLIB_UTILS_H_ */ - diff --git a/lwlib/lwlib.c b/lwlib/lwlib.c index 290ce091301..9d8ec3330d3 100644 --- a/lwlib/lwlib.c +++ b/lwlib/lwlib.c @@ -422,7 +422,7 @@ safe_strcmp (const char *s1, const char *s2) (nc == STRUCTURAL_CHANGE ? "structural" : "???")))), \ nc, desc, a1, a2) #else -# define EXPLAIN(name, oc, nc, desc, a1, a2) +# define EXPLAIN(name, oc, nc, desc, a1, a2) ((void) 0) #endif @@ -912,8 +912,9 @@ destroy_one_instance (widget_instance *instance) xaw_destroy_instance (instance); else #endif - /* do not remove the empty statement */ - ; + { + /* Empty compound statement to terminate if-then-else chain. */ + } } free_widget_instance (instance); @@ -978,7 +979,7 @@ lw_destroy_all_pop_ups (void) } #ifdef USE_MOTIF -extern Widget first_child (/* Widget */); /* garbage */ +extern Widget first_child (Widget); /* garbage */ #endif Widget diff --git a/lwlib/xlwmenu.c b/lwlib/xlwmenu.c index 5b97f2bf999..e9ec604ae7f 100644 --- a/lwlib/xlwmenu.c +++ b/lwlib/xlwmenu.c @@ -1220,9 +1220,9 @@ display_menu (XlwMenuWidget mw, { if (val->enabled) *hit_return = val; - else + else no_return = 1; - if (mw->menu.inside_entry != val) + if (mw->menu.inside_entry != val) { if (mw->menu.inside_entry) XtCallCallbackList ((Widget)mw, mw->menu.leave, @@ -1426,7 +1426,7 @@ fit_to_screen (XlwMenuWidget mw, static void create_pixmap_for_menu (window_state* ws, XlwMenuWidget mw) { - if (ws->pixmap != None) + if (ws->pixmap != None) { XFreePixmap (XtDisplay (ws->w), ws->pixmap); ws->pixmap = None; @@ -1592,9 +1592,9 @@ map_event_to_widget_value (XlwMenuWidget mw, } } - if (!inside) + if (!inside) { - if (mw->menu.inside_entry != NULL) + if (mw->menu.inside_entry != NULL) XtCallCallbackList ((Widget)mw, mw->menu.leave, (XtPointer) mw->menu.inside_entry); mw->menu.inside_entry = NULL; @@ -1693,8 +1693,10 @@ release_drawing_gcs (XlwMenuWidget mw) mw->menu.background_gc = (GC) -1; } +#ifndef emacs #define MINL(x,y) ((((unsigned long) (x)) < ((unsigned long) (y))) \ ? ((unsigned long) (x)) : ((unsigned long) (y))) +#endif static void make_shadow_gcs (XlwMenuWidget mw) @@ -1881,7 +1883,7 @@ openXftFont (XlwMenuWidget mw) if (!mw->menu.font) { mw->menu.xft_font = XftFontOpenName (XtDisplay (mw), screen, fname); - if (!mw->menu.xft_font) + if (!mw->menu.xft_font) { fprintf (stderr, "Can't find font '%s'\n", fname); mw->menu.xft_font = getDefaultXftFont (mw); @@ -1930,19 +1932,19 @@ XlwMenuInitialize (Widget request, Widget w, ArgList args, Cardinal *num_args) if (!mw->menu.font) { mw->menu.font = XLoadQueryFont (display, "fixed"); - if (!mw->menu.font) + if (!mw->menu.font) { fprintf (stderr, "Menu font fixed not found, can't continue.\n"); abort (); } } } - + #ifdef HAVE_X_I18N if (mw->menu.fontSet) mw->menu.font_extents = XExtentsOfFontSet (mw->menu.fontSet); #endif - + make_drawing_gcs (mw); make_shadow_gcs (mw); @@ -2118,12 +2120,12 @@ XlwMenuDestroy (Widget w) XftFontClose (XtDisplay (mw), mw->menu.xft_font); #endif - if (mw->menu.windows [0].pixmap != None) + if (mw->menu.windows [0].pixmap != None) XFreePixmap (XtDisplay (mw), mw->menu.windows [0].pixmap); /* start from 1 because the one in slot 0 is w->core.window */ for (i = 1; i < mw->menu.windows_length; i++) { - if (mw->menu.windows [i].pixmap != None) + if (mw->menu.windows [i].pixmap != None) XFreePixmap (XtDisplay (mw), mw->menu.windows [i].pixmap); #ifdef HAVE_XFT if (mw->menu.windows [i].xft_draw) @@ -2153,18 +2155,17 @@ XlwMenuSetValues (Widget current, Widget request, Widget new, { XlwMenuWidget oldmw = (XlwMenuWidget)current; XlwMenuWidget newmw = (XlwMenuWidget)new; - Boolean redisplay = False; - int i; + Boolean do_redisplay = False; if (newmw->menu.contents && newmw->menu.contents->contents && newmw->menu.contents->contents->change >= VISIBLE_CHANGE) - redisplay = True; + do_redisplay = True; /* Do redisplay if the contents are entirely eliminated. */ if (newmw->menu.contents && newmw->menu.contents->contents == 0 && newmw->menu.contents->change >= VISIBLE_CHANGE) - redisplay = True; + do_redisplay = True; if (newmw->core.background_pixel != oldmw->core.background_pixel || newmw->menu.foreground != oldmw->menu.foreground @@ -2179,6 +2180,7 @@ XlwMenuSetValues (Widget current, Widget request, Widget new, #endif ) { + int i; release_drawing_gcs (newmw); make_drawing_gcs (newmw); @@ -2188,7 +2190,7 @@ XlwMenuSetValues (Widget current, Widget request, Widget new, newmw->menu.bottom_shadow_color = -1; make_shadow_gcs (newmw); - redisplay = True; + do_redisplay = True; if (XtIsRealized (current)) /* If the menu is currently displayed, change the display. */ @@ -2229,12 +2231,12 @@ XlwMenuSetValues (Widget current, Widget request, Widget new, #ifdef HAVE_X_I18N if (newmw->menu.fontSet != oldmw->menu.fontSet && newmw->menu.fontSet != NULL) { - redisplay = True; + do_redisplay = True; newmw->menu.font_extents = XExtentsOfFontSet (newmw->menu.fontSet); } #endif - return redisplay; + return do_redisplay; } static void diff --git a/oldXMenu/Activate.c b/oldXMenu/Activate.c index 42eb33d208a..fef8a3b6b25 100644 --- a/oldXMenu/Activate.c +++ b/oldXMenu/Activate.c @@ -122,7 +122,7 @@ XMenuActivate( int y_pos, /* Y coordinate of menu position. */ unsigned int event_mask, /* Mouse button event mask. */ char **data, /* Pointer to return data value. */ - void (* help_callback) (char *, int, int)) /* Help callback. */ + void (*help_callback) (char const *, int, int)) /* Help callback. */ { int status; /* X routine call status. */ int orig_x; /* Upper left menu origin X coord. */ diff --git a/oldXMenu/AddPane.c b/oldXMenu/AddPane.c index 67900a6bc76..36b57fe8da6 100644 --- a/oldXMenu/AddPane.c +++ b/oldXMenu/AddPane.c @@ -16,14 +16,14 @@ #include "XMenuInt.h" int -XMenuAddPane(Display *display, register XMenu *menu, register char *label, int active) - +XMenuAddPane(Display *display, register XMenu *menu, register char const *label, int active) + /* Menu object to be modified. */ /* Selection label. */ /* Make selection active? */ { register XMPane *pane; /* Newly created pane. */ - register XMSelect *select; /* Initial selection for the new pane. */ + register XMSelect *sel; /* Initial selection for the new pane. */ int label_length; /* Label length in characters. */ int label_width; /* Label width in pixels. */ @@ -44,8 +44,8 @@ XMenuAddPane(Display *display, register XMenu *menu, register char *label, int a _XMErrorCode = XME_CALLOC; return(XM_FAILURE); } - select = (XMSelect *)calloc(1, sizeof(XMSelect)); - if (select == NULL) { + sel = (XMSelect *)calloc(1, sizeof(XMSelect)); + if (sel == NULL) { _XMErrorCode = XME_CALLOC; return(XM_FAILURE); } @@ -62,11 +62,11 @@ XMenuAddPane(Display *display, register XMenu *menu, register char *label, int a * Set up the initial selection. * Values not explicitly set are zeroed by calloc. */ - select->next = select; - select->prev = select; - select->type = SL_HEADER; - select->serial = -1; - select->parent_p = pane; + sel->next = sel; + sel->prev = sel; + sel->type = SL_HEADER; + sel->serial = -1; + sel->parent_p = pane; /* * Fill the XMPane structure. @@ -78,7 +78,7 @@ XMenuAddPane(Display *display, register XMenu *menu, register char *label, int a pane->label = label; pane->label_width = label_width; pane->label_length = label_length; - pane->s_list = select; + pane->s_list = sel; /* * Insert the pane at the end of the pane list. @@ -101,4 +101,3 @@ XMenuAddPane(Display *display, register XMenu *menu, register char *label, int a _XMErrorCode = XME_NO_ERROR; return((menu->p_count - 1)); } - diff --git a/oldXMenu/AddSel.c b/oldXMenu/AddSel.c index 9183aba7e8e..9bbcf71cd3c 100644 --- a/oldXMenu/AddSel.c +++ b/oldXMenu/AddSel.c @@ -17,8 +17,8 @@ #include "XMenuInt.h" int -XMenuAddSelection(Display *display, register XMenu *menu, register int p_num, char *data, char *label, int active, char *help) - +XMenuAddSelection(Display *display, register XMenu *menu, register int p_num, char *data, char *label, int active, char const *help) + /* Menu object to be modified. */ /* Pane number to be modified. */ /* Data value. */ @@ -27,7 +27,7 @@ XMenuAddSelection(Display *display, register XMenu *menu, register int p_num, ch /* Help string */ { register XMPane *pane; /* Pane containing the new selection. */ - register XMSelect *select; /* Newly created selection. */ + register XMSelect *sel; /* Newly created selection. */ int label_length; /* Label lenght in characters. */ @@ -49,8 +49,8 @@ XMenuAddSelection(Display *display, register XMenu *menu, register int p_num, ch /* * Calloc the XMSelect structure. */ - select = (XMSelect *)calloc(1, sizeof(XMSelect)); - if (select == NULL) { + sel = (XMSelect *)calloc(1, sizeof(XMSelect)); + if (sel == NULL) { _XMErrorCode = XME_CALLOC; return(XM_FAILURE); } @@ -65,27 +65,27 @@ XMenuAddSelection(Display *display, register XMenu *menu, register int p_num, ch */ if (!strcmp (label, "--") || !strcmp (label, "---")) { - select->type = SEPARATOR; - select->active = 0; + sel->type = SEPARATOR; + sel->active = 0; } else { - select->type = SELECTION; - select->active = active; + sel->type = SELECTION; + sel->active = active; } - select->serial = -1; - select->label = label; - select->label_width = label_width; - select->label_length = label_length; - select->data = data; - select->parent_p = pane; - select->help_string = help; + sel->serial = -1; + sel->label = label; + sel->label_width = label_width; + sel->label_length = label_length; + sel->data = data; + sel->parent_p = pane; + sel->help_string = help; /* * Insert the selection at the end of the selection list. */ - emacs_insque(select, pane->s_list->prev); + emacs_insque(sel, pane->s_list->prev); /* * Update the selection count. @@ -103,4 +103,3 @@ XMenuAddSelection(Display *display, register XMenu *menu, register int p_num, ch _XMErrorCode = XME_NO_ERROR; return((pane->s_count - 1)); } - diff --git a/oldXMenu/ChangeLog b/oldXMenu/ChangeLog index f0e650ab4b3..b40b5ca7084 100644 --- a/oldXMenu/ChangeLog +++ b/oldXMenu/ChangeLog @@ -1,3 +1,43 @@ +2011-04-16 Paul Eggert <eggert@cs.ucla.edu> + + Static checks with GCC 4.6.0 and non-default toolkits. + + Modernize to C89, for better static checking. + * Activate.c (XMenuActivate): Callback's first arg is readonly. + * AddPane.c (XMenuAddPane): Label is readonly. Rename local + to avoid shadowing. + * AddSel.c (XMenuAddSelection): Help arg is readonly. Rename local. + * Create.c (atoi, atof): Remove decls; include <stdlib.h>. + (MAX_INACT_PNUM, TILE_BUF_SIZE): Remove; unused. + (x_get_resource_string): Args are readonly. + (XAllocDisplayColor): colorName is readonly. + (XMenuCreate): def_env is readonly. Remove unused locals. Avoid + "else;". + * Destroy.c (XMenuDestroy): Return void. + * Error.c (XMenuError): Remove const pointer. + * EvHand.c (XMenuEventHandler): Return void. + * FindPane.c, FindSel.c: Include <string.h>. + * InsPane.c (XMenuInsertPane): Rename local to avoid shadowing. + * InsSel.c (XMenuInsertSelection): Likewise. + * Internal.c (toggle_color, BUFFER_SIZE): Remove; unused. + (_XMErrorList): Now const. + (_XMWinQueInit, _XMRecomputeGlobals, _XMTransToOrigin, _XMRefreshPane): + (_XMRefreshSelection): Return void. + (_XMWinQueFlush, _XMRefreshSelection): Rename locals to avoid + shadowing. + (_XMWinQueFlush): Use stack, not heap. Don't use uninitialized var. + * SetAEQ.c (XMenuSetAEQ): Now returns void. + * SetFrz.c (XMenuSetFreeze): Likewise. + * X10.h (XAssoc): Use void * for generic pointer. + * XDelAssoc.c: Include XMenuInt.h rather than duplicating part of it. + * XDestAssoc.c, XMakeAssoc.c: Likewise. + * XDestAssoc.c (XDestroyAssocTable): Return void. + * XMakeAssoc.c (XMakeAssoc): Use void * for generic pointer. + * XMenu.h, XMenuInt.h: Adjust to signature changes. Use const + for pointers to readonly storage. + * insque.c: Include XMenuInt.h, to check our own signature. + (emacs_insque, emacs_remque): Use void * for generic pointers. + 2011-03-07 Chong Yidong <cyd@stupidchicken.com> * Version 23.3 released. diff --git a/oldXMenu/Create.c b/oldXMenu/Create.c index 8354208773f..25f1f1c3381 100644 --- a/oldXMenu/Create.c +++ b/oldXMenu/Create.c @@ -31,7 +31,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include <config.h> #include "XMenuInt.h" - +#include <stdlib.h> #ifdef EMACS_BITMAP_FILES #include "../src/bitmaps/dimple1.xbm" @@ -71,7 +71,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */ #define DEF_MENU_STYLE LEFT #define DEF_MENU_MODE BOX #define DEF_INACT_PNUM 3 -#define MAX_INACT_PNUM 4 #define DEF_P_STYLE CENTER @@ -88,16 +87,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */ #define XASSOC_TABLE_SIZE 64 -#define TILE_BUF_SIZE 5 - -int atoi(const char *); -double atof(const char *); -char *x_get_resource_string (char *attribute, char *class); +char *x_get_resource_string (char const *, char const *); static Status -XAllocDisplayColor(Display *display, Colormap map, char *colorName, XColor *color, XColor *junk) +XAllocDisplayColor(Display *display, Colormap map, char const *colorName, + XColor *color, XColor *junk) { return (colorName!=0 && XParseColor(display, map, colorName, color) && @@ -106,13 +102,11 @@ XAllocDisplayColor(Display *display, Colormap map, char *colorName, XColor *colo XMenu * -XMenuCreate(Display *display, Window parent, register char *def_env) +XMenuCreate(Display *display, Window parent, register char const *def_env) /* ID of previously opened display */ /* Window ID of the menu's parent window. */ /* X Defaults program environment name. */ { - register int i; /* Loop counter. */ - register int j; /* Loop counter. */ register char *def_val; /* X Default value temp variable. */ register XMenu *menu; /* Pointer to the new menu. */ @@ -125,7 +119,7 @@ XMenuCreate(Display *display, Window parent, register char *def_env) int reverse; /* Reverse video mode. */ XMStyle p_style; /* Pane display style. */ - char *p_fnt_name; /* Flag font name. */ + char const *p_fnt_name; /* Flag font name. */ XFontStruct *p_fnt_info; /* Flag font structure */ int p_fnt_pad; /* Flag font padding in pixels. */ double p_spread; /* Pane spread in flag height fractions. */ @@ -138,7 +132,7 @@ XMenuCreate(Display *display, Window parent, register char *def_env) GC pane_GC; /* Pane graphics context. */ XMStyle s_style; /* Selection display style. */ - char *s_fnt_name; /* Selection font name. */ + char const *s_fnt_name; /* Selection font name. */ XFontStruct *s_fnt_info; /* Selection font structure. */ int s_fnt_pad; /* Selection font padding in pixels. */ int s_fnt_height; /* Selection font character height */ @@ -151,10 +145,8 @@ XMenuCreate(Display *display, Window parent, register char *def_env) GC inverse_select_GC; /* GC used for inverse video selection. */ GC inact_GC; /* GC for inactive pane header and */ /* selections. */ - GC inact_GC_noexpose; XColor color_def; /* Temp color definition holder. */ - XColor screen_def; /* Temp screen color definition holder */ XColor p_bdr_color; /* Color of border. */ XColor s_bdr_color; /* Color of highlight. */ XColor p_frg_color; /* Color of pane foreground color. */ @@ -166,17 +158,6 @@ XMenuCreate(Display *display, Window parent, register char *def_env) int inact_pnum; /* Inactive background pattern number. */ - Pixel p_bdr_pixel; /* Pane border pixel. */ - Pixel s_bdr_pixel; /* Selection border pixel. */ - Pixel p_frg_pixel; /* Pane foreground pixel. */ - Pixel s_frg_pixel; /* Selection foreground pixel. */ - Pixel bkgnd_pixel; /* Menu background pixel. */ - - int *width, *height; - Pixmap *bitmap; - int *x_hot, *y_hot; - int status; /* Return code from XReadBitmapFile. */ - Pixmap cursor; /* Cursor pixmap holder. */ Pixmap cursor_mask; /* Cursor mask pixmap holder. */ Pixmap stipple_pixmap; /* Stipple mask for half-tone text. */ @@ -282,7 +263,7 @@ XMenuCreate(Display *display, Window parent, register char *def_env) &mouse_color, &color_def) ); - else ; + else {} def_val = x_get_resource_string ("menuBackground", "MenuBackground"); if ( @@ -304,7 +285,7 @@ XMenuCreate(Display *display, Window parent, register char *def_env) "white", &bkgnd_color, &color_def) ); - else; + else {} def_val = x_get_resource_string ("menuInactivePattern", "MenuInactivePattern"); if (def_val != NULL) { @@ -401,7 +382,7 @@ XMenuCreate(Display *display, Window parent, register char *def_env) "black", &s_frg_color, &color_def) ) ; - else ; + else {} def_val = x_get_resource_string ("selectionBorder", "SelectionBorder"); @@ -424,7 +405,7 @@ XMenuCreate(Display *display, Window parent, register char *def_env) "black", &s_bdr_color, &color_def) ) ; - else ; + else {} def_val = x_get_resource_string ("selectionBorderWidth", "SelectionBorderWidth"); if (def_val != NULL) s_bdr_width = atoi(def_val); @@ -681,9 +662,6 @@ XMenuCreate(Display *display, Window parent, register char *def_env) valuemask |= (GCGraphicsExposures); values->graphics_exposures = False; - inact_GC_noexpose = XCreateGC (display, - root, - valuemask, values); /* @@ -752,4 +730,3 @@ XMenuCreate(Display *display, Window parent, register char *def_env) _XMErrorCode = XME_NO_ERROR; return(menu); } - diff --git a/oldXMenu/Destroy.c b/oldXMenu/Destroy.c index 6a379609ad0..7f0f6146316 100644 --- a/oldXMenu/Destroy.c +++ b/oldXMenu/Destroy.c @@ -15,8 +15,9 @@ #include "XMenuInt.h" +void XMenuDestroy(Display *display, register XMenu *menu) - + /* Menu object to destroy. */ { register XMPane *p_ptr; /* Pointer to the current pane. */ @@ -114,4 +115,3 @@ XMenuDestroy(Display *display, register XMenu *menu) */ free(menu); } - diff --git a/oldXMenu/Error.c b/oldXMenu/Error.c index 99f5eb6500d..01738458b6a 100644 --- a/oldXMenu/Error.c +++ b/oldXMenu/Error.c @@ -16,7 +16,7 @@ #include "XMenuInt.h" -char * +char const * XMenuError(void) { static char message[128]; /* Error message buffer. */ @@ -27,4 +27,3 @@ XMenuError(void) sprintf(message, "Unknown _XMErrorCode: %d", _XMErrorCode); return(message); } - diff --git a/oldXMenu/EvHand.c b/oldXMenu/EvHand.c index 5ee6877374b..bd15359d919 100644 --- a/oldXMenu/EvHand.c +++ b/oldXMenu/EvHand.c @@ -15,6 +15,7 @@ #include "XMenuInt.h" +void XMenuEventHandler(int (*handler) (XEvent*)) { /* @@ -22,4 +23,3 @@ XMenuEventHandler(int (*handler) (XEvent*)) */ _XMEventHandler = handler; } - diff --git a/oldXMenu/FindPane.c b/oldXMenu/FindPane.c index 022e7619034..8101d009a2f 100644 --- a/oldXMenu/FindPane.c +++ b/oldXMenu/FindPane.c @@ -15,6 +15,7 @@ */ #include "XMenuInt.h" +#include <string.h> int XMenuFindPane(register XMenu *menu, register char *label) @@ -60,4 +61,3 @@ XMenuFindPane(register XMenu *menu, register char *label) _XMErrorCode = XME_P_NOT_FOUND; return (XM_FAILURE); } - diff --git a/oldXMenu/FindSel.c b/oldXMenu/FindSel.c index 72ee142dc80..fbf235c463d 100644 --- a/oldXMenu/FindSel.c +++ b/oldXMenu/FindSel.c @@ -31,6 +31,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "XMenuInt.h" +#include <string.h> int XMenuFindSelection(register XMenu *menu, int p_num, register char *label) @@ -83,4 +84,3 @@ XMenuFindSelection(register XMenu *menu, int p_num, register char *label) _XMErrorCode = XME_S_NOT_FOUND; return (XM_FAILURE); } - diff --git a/oldXMenu/InsPane.c b/oldXMenu/InsPane.c index c1993f5bfda..bdbadbf1226 100644 --- a/oldXMenu/InsPane.c +++ b/oldXMenu/InsPane.c @@ -26,7 +26,7 @@ XMenuInsertPane(register XMenu *menu, register int p_num, char *label, int activ { register XMPane *p_ptr; /* XMPane pointer. */ register XMPane *pane; /* Newly created pane. */ - register XMSelect *select; /* Initial selection for the new pane. */ + register XMSelect *sel; /* Initial selection for the new pane. */ int label_length; /* Label length in characters. */ int label_width; /* Label width in pixels. */ @@ -54,8 +54,8 @@ XMenuInsertPane(register XMenu *menu, register int p_num, char *label, int activ _XMErrorCode = XME_CALLOC; return(XM_FAILURE); } - select = (XMSelect *)calloc(1, sizeof(XMSelect)); - if (select == NULL) { + sel = (XMSelect *)calloc(1, sizeof(XMSelect)); + if (sel == NULL) { _XMErrorCode = XME_CALLOC; return(XM_FAILURE); } @@ -70,11 +70,11 @@ XMenuInsertPane(register XMenu *menu, register int p_num, char *label, int activ * Set up the initial selection. * Values not explicitly set are zeroed by calloc. */ - select->next = select; - select->prev = select; - select->type = SL_HEADER; - select->serial = -1; - select->parent_p = pane; + sel->next = sel; + sel->prev = sel; + sel->type = SL_HEADER; + sel->serial = -1; + sel->parent_p = pane; /* * Fill the XMPane structure. @@ -85,7 +85,7 @@ XMenuInsertPane(register XMenu *menu, register int p_num, char *label, int activ pane->label = label; pane->label_width = label_width; pane->label_length = label_length; - pane->s_list = select; + pane->s_list = sel; /* * Insert the pane after the pane with the pane @@ -110,4 +110,3 @@ XMenuInsertPane(register XMenu *menu, register int p_num, char *label, int activ _XMErrorCode = XME_NO_ERROR; return(p_num); } - diff --git a/oldXMenu/InsSel.c b/oldXMenu/InsSel.c index be0e43e0cb9..5db285f6408 100644 --- a/oldXMenu/InsSel.c +++ b/oldXMenu/InsSel.c @@ -28,7 +28,7 @@ XMenuInsertSelection(register XMenu *menu, register int p_num, register int s_nu register XMPane *p_ptr; /* XMPane pointer. */ register XMSelect *s_ptr; /* XMSelect pointer. */ - XMSelect *select; /* Newly created selection. */ + XMSelect *sel; /* Newly created selection. */ int label_length; /* Label length in characters. */ int label_width; /* Label width in pixels. */ @@ -57,8 +57,8 @@ XMenuInsertSelection(register XMenu *menu, register int p_num, register int s_nu /* * Calloc the XMSelect structure. */ - select = (XMSelect *)calloc(1, sizeof(XMSelect)); - if (select == NULL) { + sel = (XMSelect *)calloc(1, sizeof(XMSelect)); + if (sel == NULL) { _XMErrorCode = XME_CALLOC; return(XM_FAILURE); } @@ -75,28 +75,28 @@ XMenuInsertSelection(register XMenu *menu, register int p_num, register int s_nu */ if (!strcmp (label, "--") || !strcmp (label, "---")) { - select->type = SEPARATOR; - select->active = 0; + sel->type = SEPARATOR; + sel->active = 0; } else { - select->type = SELECTION; - select->active = active; + sel->type = SELECTION; + sel->active = active; } - select->active = active; - select->serial = -1; - select->label = label; - select->label_width = label_width; - select->label_length = label_length; - select->data = data; - select->parent_p = p_ptr; + sel->active = active; + sel->serial = -1; + sel->label = label; + sel->label_width = label_width; + sel->label_length = label_length; + sel->data = data; + sel->parent_p = p_ptr; /* * Insert the selection after the selection with the selection * number one less than the desired number for the new selection. */ - emacs_insque(select, s_ptr); + emacs_insque(sel, s_ptr); /* * Update the selection count. @@ -114,4 +114,3 @@ XMenuInsertSelection(register XMenu *menu, register int p_num, register int s_nu _XMErrorCode = XME_NO_ERROR; return(s_num); } - diff --git a/oldXMenu/Internal.c b/oldXMenu/Internal.c index 23b54493e23..102de9d7a56 100644 --- a/oldXMenu/Internal.c +++ b/oldXMenu/Internal.c @@ -33,17 +33,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "XMenuInt.h" /* - * Toggle color macro. - */ -#define toggle_color(x) \ - ((x) == menu->bkgnd_color ? menu->s_frg_color : menu->bkgnd_color) - -/* * Internal Window creation queue sizes. */ #define S_QUE_SIZE 300 #define P_QUE_SIZE 20 -#define BUFFER_SIZE (S_QUE_SIZE >= P_QUE_SIZE ? S_QUE_SIZE : P_QUE_SIZE) /* @@ -71,7 +64,7 @@ int _XMErrorCode = XME_NO_ERROR; /* * _XMErrorList - Global XMenu error code description strings. */ -char * +char const *const _XMErrorList[XME_CODE_COUNT] = { "No error", /* XME_NO_ERROR */ "Menu not initialized", /* XME_NOT_INIT */ @@ -103,6 +96,7 @@ int (*_XMEventHandler)(XEvent*) = NULL; * _XMWinQueInit - Internal routine to initialize the window * queue. */ +void _XMWinQueInit(void) { /* @@ -138,7 +132,7 @@ _XMWinQueInit(void) */ int _XMWinQueAddPane(register Display *display, register XMenu *menu, register XMPane *p_ptr) - + /* Menu being manipulated. */ /* XMPane being queued. */ { @@ -172,7 +166,7 @@ _XMWinQueAddPane(register Display *display, register XMenu *menu, register XMPan */ int _XMWinQueAddSelection(register Display *display, register XMenu *menu, register XMSelect *s_ptr) - + /* Menu being manipulated. */ /* XMSelection being queued. */ { @@ -205,8 +199,8 @@ _XMWinQueAddSelection(register Display *display, register XMenu *menu, register * selection window queues. */ int -_XMWinQueFlush(register Display *display, register XMenu *menu, register XMPane *pane, XMSelect *select) - +_XMWinQueFlush(register Display *display, register XMenu *menu, register XMPane *pane, XMSelect *sel) + /* Menu being manipulated. */ /* Current pane. */ { @@ -215,7 +209,8 @@ _XMWinQueFlush(register Display *display, register XMenu *menu, register XMPane register XMPane *p_ptr; /* XMPane pointer. */ register XMSelect *s_ptr; /* XMSelect pointer. */ unsigned long valuemask; /* Which attributes to set. */ - XSetWindowAttributes *attributes; /* Attributes to be set. */ + XSetWindowAttributes attributes_buf; /* Attributes to be set. */ + XSetWindowAttributes *attributes = &attributes_buf; /* * If the pane window queue is not empty... @@ -226,7 +221,6 @@ _XMWinQueFlush(register Display *display, register XMenu *menu, register XMPane * set up attributes for pane window to be created. */ valuemask = (CWBackPixmap | CWBorderPixel | CWOverrideRedirect); - attributes = (XSetWindowAttributes *)malloc(sizeof(XSetWindowAttributes)); attributes->border_pixel = menu->p_bdr_color; attributes->background_pixmap = menu->inact_pixmap; attributes->override_redirect = True; @@ -415,6 +409,7 @@ _XMGetSelectionPtr(register XMPane *p_ptr, register int s_num) * _XMRecomputeGlobals - Internal subroutine to recompute menu wide * global values. */ +void _XMRecomputeGlobals(register Display *display, register XMenu *menu) /*X11 display variable. */ /* Menu object to compute from. */ @@ -681,7 +676,7 @@ _XMRecomputePane(register Display *display, register XMenu *menu, register XMPan */ int _XMRecomputeSelection(register Display *display, register XMenu *menu, register XMSelect *s_ptr, register int s_num) - + /* Menu object being recomputed. */ /* Selection pointer. */ /* Selection sequence number. */ @@ -810,6 +805,7 @@ _XMRecomputeSelection(register Display *display, register XMenu *menu, register * recomputed before calling this routine or * unpredictable results will follow. */ +void _XMTransToOrigin(Display *display, register XMenu *menu, register XMPane *p_ptr, register XMSelect *s_ptr, int x_pos, int y_pos, int *orig_x, int *orig_y) /* Not used. Included for consistency. */ /* Menu being computed against. */ @@ -870,6 +866,7 @@ _XMTransToOrigin(Display *display, register XMenu *menu, register XMPane *p_ptr, * _XMRefreshPane - Internal subroutine to completely refresh * the contents of a pane. */ +void _XMRefreshPane(register Display *display, register XMenu *menu, register XMPane *pane) { register XMSelect *s_list = pane->s_list; @@ -937,34 +934,35 @@ _XMRefreshPane(register Display *display, register XMenu *menu, register XMPane * _XMRefreshSelection - Internal subroutine that refreshes * a single selection window. */ -_XMRefreshSelection(register Display *display, register XMenu *menu, register XMSelect *select) +void +_XMRefreshSelection(register Display *display, register XMenu *menu, register XMSelect *sel) { - register int width = select->window_w; - register int height = select->window_h; + register int width = sel->window_w; + register int height = sel->window_h; register int bdr_width = menu->s_bdr_width; - if (select->type == SEPARATOR) { + if (sel->type == SEPARATOR) { XDrawLine(display, - select->parent_p->window, + sel->parent_p->window, menu->normal_select_GC, - select->window_x, - select->window_y + height / 2, - select->window_x + width, - select->window_y + height / 2); + sel->window_x, + sel->window_y + height / 2, + sel->window_x + width, + sel->window_y + height / 2); } - else if (select->activated) { + else if (sel->activated) { if (menu->menu_mode == INVERT) { XFillRectangle(display, - select->parent_p->window, + sel->parent_p->window, menu->normal_select_GC, - select->window_x, select->window_y, + sel->window_x, sel->window_y, width, height); XDrawString(display, - select->parent_p->window, + sel->parent_p->window, menu->inverse_select_GC, - select->label_x, - select->label_y, - select->label, select->label_length); + sel->label_x, + sel->label_y, + sel->label, sel->label_length); } else { /* @@ -975,42 +973,41 @@ _XMRefreshSelection(register Display *display, register XMenu *menu, register XM */ XDrawRectangle(display, - select->parent_p->window, + sel->parent_p->window, menu->normal_select_GC, - select->window_x + (bdr_width >> 1), - select->window_y + (bdr_width >> 1 ), + sel->window_x + (bdr_width >> 1), + sel->window_y + (bdr_width >> 1 ), width - bdr_width, height - bdr_width); XDrawString(display, - select->parent_p->window, + sel->parent_p->window, menu->normal_select_GC, - select->label_x, - select->label_y, - select->label, select->label_length); + sel->label_x, + sel->label_y, + sel->label, sel->label_length); } } else { XClearArea(display, - select->parent_p->window, - select->window_x, select->window_y, + sel->parent_p->window, + sel->window_x, sel->window_y, width, height, False); - if (select->active) { + if (sel->active) { XDrawString(display, - select->parent_p->window, + sel->parent_p->window, menu->normal_select_GC, - select->label_x, - select->label_y, - select->label, select->label_length); + sel->label_x, + sel->label_y, + sel->label, sel->label_length); } else { XDrawString(display, - select->parent_p->window, + sel->parent_p->window, menu->inact_GC, - select->label_x, - select->label_y, - select->label, select->label_length); + sel->label_x, + sel->label_y, + sel->label, sel->label_length); } } } - diff --git a/oldXMenu/SetAEQ.c b/oldXMenu/SetAEQ.c index f4d51d24bec..ee2d64b8806 100644 --- a/oldXMenu/SetAEQ.c +++ b/oldXMenu/SetAEQ.c @@ -18,6 +18,7 @@ #include "XMenuInt.h" +void XMenuSetAEQ(register XMenu *menu, register int aeq) /* Menu object to be modified. */ /* AEQ mode? */ @@ -27,4 +28,3 @@ XMenuSetAEQ(register XMenu *menu, register int aeq) */ menu->aeq = aeq; } - diff --git a/oldXMenu/SetFrz.c b/oldXMenu/SetFrz.c index b16c659ed57..c8998eeb66b 100644 --- a/oldXMenu/SetFrz.c +++ b/oldXMenu/SetFrz.c @@ -17,6 +17,7 @@ #include "XMenuInt.h" +void XMenuSetFreeze(register XMenu *menu, register int freeze) /* Menu object to be modified. */ /* Freeze mode? */ @@ -26,4 +27,3 @@ XMenuSetFreeze(register XMenu *menu, register int freeze) */ menu->freeze = freeze; } - diff --git a/oldXMenu/X10.h b/oldXMenu/X10.h index 6b0626f212c..c30632b9d68 100644 --- a/oldXMenu/X10.h +++ b/oldXMenu/X10.h @@ -54,7 +54,7 @@ typedef struct _XAssoc { struct _XAssoc *prev; /* Previous obejct in this bucket. */ Display *display; /* Display which owns the id. */ XID x_id; /* X Window System id. */ - char *data; /* Pointer to untyped memory. */ + void *data; /* Pointer to untyped memory. */ } XAssoc; /* @@ -75,4 +75,3 @@ XAssocTable *XCreateAssocTable(int size); char *XLookUpAssoc(Display *dpy, XAssocTable *table, XID x_id); #endif /* _X10_H_ */ - diff --git a/oldXMenu/XDelAssoc.c b/oldXMenu/XDelAssoc.c index 018c71c3a3e..ec1d09d46ec 100644 --- a/oldXMenu/XDelAssoc.c +++ b/oldXMenu/XDelAssoc.c @@ -2,15 +2,7 @@ #include "copyright.h" - -#include <X11/Xlib.h> -#include "X10.h" -struct qelem { - struct qelem *q_forw; - struct qelem *q_back; - char q_data[1]; -}; -void emacs_remque(struct qelem*); +#include "XMenuInt.h" /* * XDeleteAssoc - Delete an association in an XAssocTable keyed on @@ -56,4 +48,3 @@ XDeleteAssoc(register Display *dpy, register XAssocTable *table, register XID x_ /* It is apparently not in the table. */ return; } - diff --git a/oldXMenu/XDestAssoc.c b/oldXMenu/XDestAssoc.c index 135b0c2cdaf..94c0454756a 100644 --- a/oldXMenu/XDestAssoc.c +++ b/oldXMenu/XDestAssoc.c @@ -2,14 +2,13 @@ #include "copyright.h" - -#include <X11/Xlib.h> -#include "X10.h" +#include "XMenuInt.h" /* * XDestroyAssocTable - Destroy (free the memory associated with) * an XAssocTable. */ +void XDestroyAssocTable(register XAssocTable *table) { register int i; @@ -35,4 +34,3 @@ XDestroyAssocTable(register XAssocTable *table) /* Free the table. */ free((char *)table); } - diff --git a/oldXMenu/XMakeAssoc.c b/oldXMenu/XMakeAssoc.c index 3626eb01f52..143b2641112 100644 --- a/oldXMenu/XMakeAssoc.c +++ b/oldXMenu/XMakeAssoc.c @@ -4,22 +4,14 @@ #include <config.h> -#include <X11/Xlib.h> +#include "XMenuInt.h" #include <X11/Xresource.h> -#include "X10.h" #include <errno.h> #ifndef NULL #define NULL 0 #endif -struct qelem { - struct qelem *q_forw; - struct qelem *q_back; - char q_data[1]; -}; -void emacs_insque (struct qelem *elem, struct qelem *prev); - /* * XMakeAssoc - Insert data into an XAssocTable keyed on an XId. * Data is inserted into the table only once. Redundant inserts are @@ -27,7 +19,7 @@ void emacs_insque (struct qelem *elem, struct qelem *prev); * bucket is sorted (lowest XId to highest XId). */ void -XMakeAssoc(register Display *dpy, register XAssocTable *table, register XID x_id, register caddr_t data) +XMakeAssoc(register Display *dpy, register XAssocTable *table, register XID x_id, register void *data) { int hash; register XAssoc *bucket; @@ -85,4 +77,3 @@ XMakeAssoc(register Display *dpy, register XAssocTable *table, register XID x_id /* Insert the new entry. */ emacs_insque((struct qelem *)new_entry, (struct qelem *)Entry->prev); } - diff --git a/oldXMenu/XMenu.h b/oldXMenu/XMenu.h index b94c6c3cede..bf1e77b5ff7 100644 --- a/oldXMenu/XMenu.h +++ b/oldXMenu/XMenu.h @@ -54,7 +54,7 @@ * XMenu error code and error list definitions. */ extern int _XMErrorCode; -extern char *_XMErrorList[]; +extern char const *const _XMErrorList[]; /* * Define the XMWindow datatypes. @@ -106,7 +106,7 @@ typedef struct _xmpane { int active; /* Window active? */ int activated; /* Window activated? */ int serial; /* -- Pane serial number. */ - char *label; /* -- Pane label. */ + char const *label; /* -- Pane label. */ int label_width; /* -- Pane label width in pixels. */ int label_length; /* -- Pane label length in chars. */ int label_x; /* -- Pane label X offset. */ @@ -141,7 +141,7 @@ typedef struct _xmselect { struct _xmwindow *pad_l9; /* ---- */ char *data; /* -- Selection data pointer. */ struct _xmpane *parent_p; /* -- Selection parent pane structure. */ - char *help_string; /* Help string or null. */ + char const *help_string; /* Help string or null. */ } XMSelect; @@ -240,29 +240,29 @@ typedef void (*Wait_func)(void*); /* * XMenu library routine declarations. */ -XMenu *XMenuCreate(Display *display, Window parent, register char *def_env); -int XMenuAddPane(Display *display, register XMenu *menu, register char *label, int active); -int XMenuAddSelection(Display *display, register XMenu *menu, register int p_num, char *data, char *label, int active, char *help); -int XMenuInsertPane(register XMenu *menu, register int p_num, char *label, int active); -int XMenuInsertSelection(register XMenu *menu, register int p_num, register int s_num, char *data, char *label, int active); -int XMenuFindPane(register XMenu *menu, register char *label); -int XMenuFindSelection(register XMenu *menu, int p_num, register char *label); -int XMenuChangePane(register XMenu *menu, register int p_num, char *label); -int XMenuChangeSelection(Display *display, register XMenu *menu, register int p_num, register int s_num, char *data, int data_sw, char *label, int label_sw); -int XMenuSetPane(register XMenu *menu, register int p_num, register int active); -int XMenuSetSelection(register XMenu *menu, register int p_num, register int s_num, int active); -int XMenuRecompute(Display *display, register XMenu *menu); -int XMenuEventHandler(int (*handler) (XEvent *)); /* No value actually returned. */ -int XMenuLocate(register Display *display, register XMenu *menu, int p_num, int s_num, int x_pos, int y_pos, int *ul_x, int *ul_y, int *width, int *height); -int XMenuSetFreeze(register XMenu *menu, register int freeze); /* No value actually returned. */ +XMenu *XMenuCreate(Display *display, Window parent, char const *def_env); +int XMenuAddPane(Display *display, XMenu *menu, char const *label, int active); +int XMenuAddSelection(Display *display, XMenu *menu, int p_num, char *data, char *label, int active, char const *help); +int XMenuInsertPane(XMenu *menu, int p_num, char *label, int active); +int XMenuInsertSelection(XMenu *menu, int p_num, int s_num, char *data, char *label, int active); +int XMenuFindPane(XMenu *menu, char *label); +int XMenuFindSelection(XMenu *menu, int p_num, char *label); +int XMenuChangePane(XMenu *menu, int p_num, char *label); +int XMenuChangeSelection(Display *display, XMenu *menu, int p_num, int s_num, char *data, int data_sw, char *label, int label_sw); +int XMenuSetPane(XMenu *menu, int p_num, int active); +int XMenuSetSelection(XMenu *menu, int p_num, int s_num, int active); +int XMenuRecompute(Display *display, XMenu *menu); +void XMenuEventHandler(int (*handler) (XEvent *)); +int XMenuLocate(Display *display, XMenu *menu, int p_num, int s_num, int x_pos, int y_pos, int *ul_x, int *ul_y, int *width, int *height); +void XMenuSetFreeze(XMenu *menu, int freeze); void XMenuActivateSetWaitFunction(Wait_func func, void *data); -int XMenuActivate(Display *display, XMenu *menu, int *p_num, int *s_num, int x_pos, int y_pos, unsigned int event_mask, char **data, void (*help_callback) (char *, int, int)); -char *XMenuPost(register Display *display, register XMenu *menu, register int *p_num, register int *s_num, register int x_pos, register int y_pos, int event_mask); -int XMenuDeletePane(register Display *display, register XMenu *menu, register int p_num); -int XMenuDeleteSelection(register Display *display, register XMenu *menu, register int p_num, register int s_num); -int XMenuDestroy(Display *display, register XMenu *menu); /* No value actually returned. */ -char *XMenuError(void); +int XMenuActivate(Display *display, XMenu *menu, int *p_num, int *s_num, int x_pos, int y_pos, unsigned int event_mask, char **data, void (*help_callback) (char const *, int, int)); +char *XMenuPost(Display *display, XMenu *menu, int *p_num, int *s_num, int x_pos, int y_pos, int event_mask); +int XMenuDeletePane(Display *display, XMenu *menu, int p_num); +int XMenuDeleteSelection(Display *display, XMenu *menu, int p_num, int s_num); +void XMenuDestroy(Display *display, XMenu *menu); +char const *XMenuError(void); +void XMenuSetAEQ(XMenu *menu, int aeq); #endif /* Don't add after this point. */ - diff --git a/oldXMenu/XMenuInt.h b/oldXMenu/XMenuInt.h index c9373460216..721652c9539 100644 --- a/oldXMenu/XMenuInt.h +++ b/oldXMenu/XMenuInt.h @@ -46,18 +46,24 @@ extern int (*_XMEventHandler)(XEvent*); /* * Internal routine declarations. */ -int _XMWinQueInit(void); /* No value actually returned. */ -int _XMWinQueAddPane(register Display *display, register XMenu *menu, register XMPane *p_ptr); -int _XMWinQueAddSelection(register Display *display, register XMenu *menu, register XMSelect *s_ptr); -int _XMWinQueFlush(register Display *display, register XMenu *menu, register XMPane *pane, XMSelect *select); -XMPane *_XMGetPanePtr(register XMenu *menu, register int p_num); -XMSelect *_XMGetSelectionPtr(register XMPane *p_ptr, register int s_num); -int _XMRecomputeGlobals(register Display *display, register XMenu *menu); /* No value actually returned. */ -int _XMRecomputePane(register Display *display, register XMenu *menu, register XMPane *p_ptr, register int p_num); -int _XMRecomputeSelection(register Display *display, register XMenu *menu, register XMSelect *s_ptr, register int s_num); -int _XMTransToOrigin(Display *display, register XMenu *menu, register XMPane *p_ptr, register XMSelect *s_ptr, int x_pos, int y_pos, int *orig_x, int *orig_y); /* No value actually returned. */ -int _XMRefreshPane(register Display *display, register XMenu *menu, register XMPane *pane); /* No value actually returned. */ +void _XMWinQueInit(void); +int _XMWinQueAddPane(Display *display, XMenu *menu, XMPane *p_ptr); +int _XMWinQueAddSelection(Display *display, XMenu *menu, XMSelect *s_ptr); +int _XMWinQueFlush(Display *display, XMenu *menu, XMPane *pane, XMSelect *select); +XMPane *_XMGetPanePtr(XMenu *menu, int p_num); +XMSelect *_XMGetSelectionPtr(XMPane *p_ptr, int s_num); +void _XMRecomputeGlobals(Display *display, XMenu *menu); +int _XMRecomputePane(Display *display, XMenu *menu, XMPane *p_ptr, int p_num); +int _XMRecomputeSelection(Display *display, XMenu *menu, XMSelect *s_ptr, int s_num); +void _XMTransToOrigin(Display *display, XMenu *menu, XMPane *p_ptr, XMSelect *s_ptr, int x_pos, int y_pos, int *orig_x, int *orig_y); +void _XMRefreshPane(Display *display, XMenu *menu, XMPane *pane); +void _XMRefreshSelection(Display *display, XMenu *menu, XMSelect *select); +void emacs_insque (void *elem, void *prev); +void emacs_remque (void *elem); +void XDeleteAssoc(Display *dpy, XAssocTable *table, XID x_id); +void XDestroyAssocTable(XAssocTable *table); +void XMakeAssoc(Display *dpy, XAssocTable *table, XID x_id, void *data); +void XDeleteAssoc(Display *dpy, XAssocTable *table, XID x_id); #endif /* Don't add stuff after this #endif */ - diff --git a/oldXMenu/insque.c b/oldXMenu/insque.c index b324ade1d55..90a8eec4e71 100644 --- a/oldXMenu/insque.c +++ b/oldXMenu/insque.c @@ -19,6 +19,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */ their callers have been renamed to emacs_mumble to allow us to include this file in the menu library on all systems. */ +#include "XMenuInt.h" struct qelem { struct qelem *q_forw; @@ -29,8 +30,10 @@ struct qelem { /* Insert ELEM into a doubly-linked list, after PREV. */ void -emacs_insque (struct qelem *elem, struct qelem *prev) +emacs_insque (void *velem, void *vprev) { + struct qelem *elem = velem; + struct qelem *prev = vprev; struct qelem *next = prev->q_forw; prev->q_forw = elem; if (next) @@ -41,8 +44,10 @@ emacs_insque (struct qelem *elem, struct qelem *prev) /* Unlink ELEM from the doubly-linked list that it is in. */ -emacs_remque (struct qelem *elem) +void +emacs_remque (void *velem) { + struct qelem *elem = velem; struct qelem *next = elem->q_forw; struct qelem *prev = elem->q_back; if (next) @@ -50,4 +55,3 @@ emacs_remque (struct qelem *elem) if (prev) prev->q_forw = next; } - diff --git a/src/ChangeLog b/src/ChangeLog index d9f764cde85..908f885cafd 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,107 @@ +2011-04-16 Paul Eggert <eggert@cs.ucla.edu> + + Static checks with GCC 4.6.0 and non-default toolkits. + + * s/sol2-6.h, s/unixware.h (PTY_TTY_NAME_SPRINTF): Protoize decl. + + * process.c (keyboard_bit_set): Define only if SIGIO. + (send_process_trap): Mark it with NO_RETURN if it doesn't return. + (send_process): Repair possible setjmp clobbering. + + * s/usg5-4-common.h (SETUP_SLAVE_PTY): Don't pass extra arg to 'fatal'. + + * eval.c: Include <stdio.h>, for vsnprintf on non-GNU/Linux hosts. + + * data.c (arith_error): Mark with NO_RETURN if it doesn't return. + + * alloc.c (bytes_used_when_full, SPARE_MEMORY, BYTES_USED): + Define only if needed. + + * sysdep.c (_FILE_OFFSET_BITS): Make this hack even uglier + by pacifying GCC about it. Maybe it's time to retire it? + * xfaces.c (USG, __TIMEVAL__): Likewise. + + * dispextern.h (struct redisplay_interface): Rename param + to avoid shadowing. + * termhooks.h (struct terminal): Likewise. + * xterm.c (xembed_send_message): Likewise. + + * insdel.c (make_gap_smaller): Define only if + USE_MMAP_FOR_BUFFERS || REL_ALLOC || DOUG_LEA_MALLOC. + + * keyboard.c (read_char): Make a var volatile so longjmp won't clobber + it. + + * emacs.c (MAX_HEAP_BSS_DIFF, my_edata): Move to where they're used, + so that we aren't warned about unused symbols. + + * xfns.c (Fx_file_dialog): Rename local to avoid shadowing. + + * xdisp.c (x_produce_glyphs): Mark var as initialized (Bug#8512). + + * xfns.c (x_real_positions): Mark locals as initialized. + + * xmenu.c (xmenu_show): Don't use uninitialized vars. + + * xterm.c: Fix problems found by static analysis with other toolkits. + (toolkit_scroll_bar_interaction): Define and use only if USE_X_TOOLKIT. + (x_dispatch_event): Declare static if USE_GTK, and + define if USE_GTK || USE_X_TOOLKIT. + (SET_SAVED_BUTTON_EVENT): Define only if USE_X_TOOLKIT || USE_GTK. + * xterm.h (x_dispatch_event): Extern only if USE_X_TOOLKIT. + * xterm.c, xterm.h (x_mouse_leave): Bring this function back, but only if + defined HAVE_MENUS && !defined USE_X_TOOLKIT && !defined USE_GTK. + + * xmenu.c (menu_help_callback): Pointer type fixes. + Use const pointers when pointing at readonly data. Avoid pointer + signedness clashes. + (FALSE): Remove unused macro. + (update_frame_menubar): Remove unused decl. + + * xfns.c (Fx_hide_tip): Move locals to avoid shadowing. + + * menu.c (push_submenu_start, push_submenu_end): Do not define unless + USE_X_TOOLKIT || USE_GTK || HAVE_NS || defined HAVE_NTGUI. + (single_menu_item): Rename local to avoid shadowing. + + * keyboard.c (make_lispy_event): Remove unused local var. + + * frame.c, frame.h (x_get_resource_string): Bring this back, but + only if HAVE_X_WINDOWS && !USE_X_TOOLKIT. + + * bitmaps: Change bitmaps from unsigned char back to the X11 + compatible char. Avoid the old compiler warnings about + out-of-range initializers by using, for example, '\xab' rather + than 0xab. + + * xgselect.c (xgselect_initialize): Check vs interface + even if ! (defined (USE_GTK) || defined (HAVE_GCONF)). + + * xmenu.c (xmenu_show): Rename parm to avoid shadowing. + + * xterm.c (x_create_toolkit_scroll_bar): Use const * for pointers + to read-only memory. + + * fns.c (vector): Remove; this old hack is no longer needed. + + * xsmfns.c (create_client_leader_window): Rename shadowing arg. + Remove unused var. + (gdk_x11_set_sm_client_id) [!USE_GTK]: Don't define. + + * xrdb.c (x_load_resources): Omit unused local. + + * xfns.c (free_frame_menubar, atof): Remove duplicate decls. + (x_window): Rename locals to avoid shadowing. + (USG): Use the kludged USG macro, to pacify gcc. + + * xterm.c (x_alloc_nearest_color_for_widget): Remove; unused. + (x_term_init): Remove local to avoid shadowing. + + * xfns.c, xterm.c (_XEditResCheckMessages): Protoize decl. + + * xdisp.c, dispextern.h (set_vertical_scroll_bar): Now extern if + USE_TOOLKIT_SCROLL_BARS && !USE_GTK, as xterm.c needs it then. + 2011-04-16 Eli Zaretskii <eliz@gnu.org> * gnutls.c (Fgnutls_boot): Don't pass Lisp_Object to `error'. diff --git a/src/alloc.c b/src/alloc.c index 16cd183aaa1..412527b41a0 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -139,10 +139,6 @@ static pthread_mutex_t alloc_mutex; #endif /* ! defined HAVE_GTK_AND_PTHREAD */ #endif /* ! defined SYSTEM_MALLOC && ! defined SYNC_INPUT */ -/* Value of _bytes_used, when spare_memory was freed. */ - -static __malloc_size_t bytes_used_when_full; - /* Mark, unmark, query mark bit of a Lisp string. S must be a pointer to a struct Lisp_String. */ @@ -198,9 +194,11 @@ static int total_free_floats, total_floats; static char *spare_memory[7]; +#ifndef SYSTEM_MALLOC /* Amount of spare memory to keep in large reserve block. */ #define SPARE_MEMORY (1 << 14) +#endif /* Number of extra blocks malloc should get when it needs more core. */ @@ -469,13 +467,6 @@ display_malloc_warning (void) intern ("emergency")); pending_malloc_warning = 0; } - - -#ifdef DOUG_LEA_MALLOC -# define BYTES_USED (mallinfo ().uordblks) -#else -# define BYTES_USED _bytes_used -#endif /* Called if we can't allocate relocatable space for a buffer. */ @@ -1096,8 +1087,18 @@ static void * (*old_malloc_hook) (size_t, const void *); static void * (*old_realloc_hook) (void *, size_t, const void*); static void (*old_free_hook) (void*, const void*); +#ifdef DOUG_LEA_MALLOC +# define BYTES_USED (mallinfo ().uordblks) +#else +# define BYTES_USED _bytes_used +#endif + static __malloc_size_t bytes_used_when_reconsidered; +/* Value of _bytes_used, when spare_memory was freed. */ + +static __malloc_size_t bytes_used_when_full; + /* This function is used as the hook for free to call. */ static void @@ -3296,7 +3297,7 @@ memory_full (void) /* Record the space now used. When it decreases substantially, we can refill the memory reserve. */ -#ifndef SYSTEM_MALLOC +#if !defined SYSTEM_MALLOC && !defined SYNC_INPUT bytes_used_when_full = BYTES_USED; #endif diff --git a/src/bitmaps/cntrpmsk.xbm b/src/bitmaps/cntrpmsk.xbm index 1eeebc4e896..828830fcde1 100644 --- a/src/bitmaps/cntrpmsk.xbm +++ b/src/bitmaps/cntrpmsk.xbm @@ -1,6 +1,6 @@ #define cntr_ptrmsk_width 16 #define cntr_ptrmsk_height 16 -static unsigned char cntr_ptrmsk_bits[] = { - 0xc0, 0x03, 0xc0, 0x03, 0xe0, 0x07, 0xe0, 0x07, 0xf0, 0x0f, 0xf0, 0x0f, - 0xf8, 0x1f, 0xf8, 0x1f, 0xfc, 0x3f, 0xfc, 0x3f, 0xfc, 0x3f, 0xdc, 0x3b, - 0xc0, 0x03, 0xc0, 0x03, 0xc0, 0x03, 0xc0, 0x03}; +static char cntr_ptrmsk_bits[] = { + '\xc0','\x03','\xc0','\x03','\xe0','\x07','\xe0','\x07','\xf0','\x0f','\xf0','\x0f', + '\xf8','\x1f','\xf8','\x1f','\xfc','\x3f','\xfc','\x3f','\xfc','\x3f','\xdc','\x3b', + '\xc0','\x03','\xc0','\x03','\xc0','\x03','\xc0','\x03'}; diff --git a/src/bitmaps/cntrptr.xbm b/src/bitmaps/cntrptr.xbm index 545442cc4f4..ee3b606b3a5 100644 --- a/src/bitmaps/cntrptr.xbm +++ b/src/bitmaps/cntrptr.xbm @@ -2,7 +2,7 @@ #define cntr_ptr_height 16 #define cntr_ptr_x_hot 7 #define cntr_ptr_y_hot 1 -static unsigned char cntr_ptr_bits[] = { - 0x00, 0x00, 0x80, 0x01, 0x80, 0x01, 0xc0, 0x03, 0xc0, 0x03, 0xe0, 0x07, - 0xe0, 0x07, 0xf0, 0x0f, 0xf0, 0x0f, 0x98, 0x19, 0x88, 0x11, 0x80, 0x01, - 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x00, 0x00}; +static char cntr_ptr_bits[] = { + '\x00','\x00','\x80','\x01','\x80','\x01','\xc0','\x03','\xc0','\x03','\xe0','\x07', + '\xe0','\x07','\xf0','\x0f','\xf0','\x0f','\x98','\x19','\x88','\x11','\x80','\x01', + '\x80','\x01','\x80','\x01','\x80','\x01','\x00','\x00'}; diff --git a/src/bitmaps/crosswv.xbm b/src/bitmaps/crosswv.xbm index 45ffbb48bda..ccf2d110887 100644 --- a/src/bitmaps/crosswv.xbm +++ b/src/bitmaps/crosswv.xbm @@ -1,6 +1,6 @@ #define cross_weave_width 16 #define cross_weave_height 16 -static unsigned char cross_weave_bits[] = { - 0x55, 0x55, 0x88, 0x88, 0x55, 0x55, 0x22, 0x22, 0x55, 0x55, 0x88, 0x88, - 0x55, 0x55, 0x22, 0x22, 0x55, 0x55, 0x88, 0x88, 0x55, 0x55, 0x22, 0x22, - 0x55, 0x55, 0x88, 0x88, 0x55, 0x55, 0x22, 0x22}; +static char cross_weave_bits[] = { + '\x55','\x55','\x88','\x88','\x55','\x55','\x22','\x22','\x55','\x55','\x88','\x88', + '\x55','\x55','\x22','\x22','\x55','\x55','\x88','\x88','\x55','\x55','\x22','\x22', + '\x55','\x55','\x88','\x88','\x55','\x55','\x22','\x22'}; diff --git a/src/bitmaps/dimple1.xbm b/src/bitmaps/dimple1.xbm index c1a36e5c91b..6db190e431f 100644 --- a/src/bitmaps/dimple1.xbm +++ b/src/bitmaps/dimple1.xbm @@ -1,6 +1,6 @@ #define dimple1_width 16 #define dimple1_height 16 -static unsigned char dimple1_bits[] = { - 0x55, 0x55, 0x00, 0x00, 0x55, 0x55, 0x00, 0x00, 0x55, 0x55, 0x00, 0x00, - 0x55, 0x55, 0x00, 0x00, 0x55, 0x55, 0x00, 0x00, 0x55, 0x55, 0x00, 0x00, - 0x55, 0x55, 0x00, 0x00, 0x55, 0x55, 0x00, 0x00}; +static char dimple1_bits[] = { + '\x55','\x55','\x00','\x00','\x55','\x55','\x00','\x00','\x55','\x55','\x00','\x00', + '\x55','\x55','\x00','\x00','\x55','\x55','\x00','\x00','\x55','\x55','\x00','\x00', + '\x55','\x55','\x00','\x00','\x55','\x55','\x00','\x00'}; diff --git a/src/bitmaps/dimple3.xbm b/src/bitmaps/dimple3.xbm index 25eb294beac..521ac8e5be2 100644 --- a/src/bitmaps/dimple3.xbm +++ b/src/bitmaps/dimple3.xbm @@ -1,6 +1,6 @@ #define dimple3_width 16 #define dimple3_height 16 -static unsigned char dimple3_bits[] = { - 0x11, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x11, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x11, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x11, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; +static char dimple3_bits[] = { + '\x11','\x11','\x00','\x00','\x00','\x00','\x00','\x00','\x11','\x11','\x00','\x00', + '\x00','\x00','\x00','\x00','\x11','\x11','\x00','\x00','\x00','\x00','\x00','\x00', + '\x11','\x11','\x00','\x00','\x00','\x00','\x00','\x00'}; diff --git a/src/bitmaps/gray.xbm b/src/bitmaps/gray.xbm index dc7327e5c1a..ec471219011 100644 --- a/src/bitmaps/gray.xbm +++ b/src/bitmaps/gray.xbm @@ -1,4 +1,4 @@ #define gray_width 2 #define gray_height 2 static char gray_bits[] = { - 0x01, 0x02}; + '\x01','\x02'}; diff --git a/src/bitmaps/gray1.xbm b/src/bitmaps/gray1.xbm index 186ea2233c6..19ee0e7b44a 100644 --- a/src/bitmaps/gray1.xbm +++ b/src/bitmaps/gray1.xbm @@ -1,4 +1,4 @@ #define gray1_width 2 #define gray1_height 2 -static unsigned char gray1_bits[] = { - 0x01, 0x02}; +static char gray1_bits[] = { + '\x01','\x02'}; diff --git a/src/bitmaps/gray3.xbm b/src/bitmaps/gray3.xbm index 0356c8dab5c..3af2a9c58a0 100644 --- a/src/bitmaps/gray3.xbm +++ b/src/bitmaps/gray3.xbm @@ -1,4 +1,4 @@ #define gray3_width 4 #define gray3_height 4 -static unsigned char gray3_bits[] = { - 0x01, 0x00, 0x04, 0x00}; +static char gray3_bits[] = { + '\x01','\x00','\x04','\x00'}; diff --git a/src/bitmaps/leftpmsk.xbm b/src/bitmaps/leftpmsk.xbm index 722abe63f15..f34c1edf7fd 100644 --- a/src/bitmaps/leftpmsk.xbm +++ b/src/bitmaps/leftpmsk.xbm @@ -1,6 +1,6 @@ #define left_ptrmsk_width 16 #define left_ptrmsk_height 16 -static unsigned char left_ptrmsk_bits[] = { - 0x0c, 0x00, 0x1c, 0x00, 0x3c, 0x00, 0x7c, 0x00, 0xfc, 0x00, 0xfc, 0x01, - 0xfc, 0x03, 0xfc, 0x07, 0xfc, 0x0f, 0xfc, 0x0f, 0xfc, 0x01, 0xdc, 0x03, - 0xcc, 0x03, 0x80, 0x07, 0x80, 0x07, 0x00, 0x03}; +static char left_ptrmsk_bits[] = { + '\x0c','\x00','\x1c','\x00','\x3c','\x00','\x7c','\x00','\xfc','\x00','\xfc','\x01', + '\xfc','\x03','\xfc','\x07','\xfc','\x0f','\xfc','\x0f','\xfc','\x01','\xdc','\x03', + '\xcc','\x03','\x80','\x07','\x80','\x07','\x00','\x03'}; diff --git a/src/bitmaps/leftptr.xbm b/src/bitmaps/leftptr.xbm index 8a3e0d5aa4f..572f3acf578 100644 --- a/src/bitmaps/leftptr.xbm +++ b/src/bitmaps/leftptr.xbm @@ -2,7 +2,7 @@ #define left_ptr_height 16 #define left_ptr_x_hot 3 #define left_ptr_y_hot 1 -static unsigned char left_ptr_bits[] = { - 0x00, 0x00, 0x08, 0x00, 0x18, 0x00, 0x38, 0x00, 0x78, 0x00, 0xf8, 0x00, - 0xf8, 0x01, 0xf8, 0x03, 0xf8, 0x07, 0xf8, 0x00, 0xd8, 0x00, 0x88, 0x01, - 0x80, 0x01, 0x00, 0x03, 0x00, 0x03, 0x00, 0x00}; +static char left_ptr_bits[] = { + '\x00','\x00','\x08','\x00','\x18','\x00','\x38','\x00','\x78','\x00','\xf8','\x00', + '\xf8','\x01','\xf8','\x03','\xf8','\x07','\xf8','\x00','\xd8','\x00','\x88','\x01', + '\x80','\x01','\x00','\x03','\x00','\x03','\x00','\x00'}; diff --git a/src/bitmaps/rtpmsk.xbm b/src/bitmaps/rtpmsk.xbm index 28e83f21430..ba4b399fda9 100644 --- a/src/bitmaps/rtpmsk.xbm +++ b/src/bitmaps/rtpmsk.xbm @@ -1,6 +1,6 @@ #define right_ptrmsk_width 16 #define right_ptrmsk_height 16 -static unsigned char right_ptrmsk_bits[] = { - 0x00, 0x30, 0x00, 0x38, 0x00, 0x3c, 0x00, 0x3e, 0x00, 0x3f, 0x80, 0x3f, - 0xc0, 0x3f, 0xe0, 0x3f, 0xf0, 0x3f, 0xf0, 0x3f, 0x80, 0x3f, 0xc0, 0x3b, - 0xc0, 0x33, 0xe0, 0x01, 0xe0, 0x01, 0xc0, 0x00}; +static char right_ptrmsk_bits[] = { + '\x00','\x30','\x00','\x38','\x00','\x3c','\x00','\x3e','\x00','\x3f','\x80','\x3f', + '\xc0','\x3f','\xe0','\x3f','\xf0','\x3f','\xf0','\x3f','\x80','\x3f','\xc0','\x3b', + '\xc0','\x33','\xe0','\x01','\xe0','\x01','\xc0','\x00'}; diff --git a/src/bitmaps/rtptr.xbm b/src/bitmaps/rtptr.xbm index a8a63806d46..4e71cdf9993 100644 --- a/src/bitmaps/rtptr.xbm +++ b/src/bitmaps/rtptr.xbm @@ -2,7 +2,7 @@ #define right_ptr_height 16 #define right_ptr_x_hot 12 #define right_ptr_y_hot 1 -static unsigned char right_ptr_bits[] = { - 0x00, 0x00, 0x00, 0x10, 0x00, 0x18, 0x00, 0x1c, 0x00, 0x1e, 0x00, 0x1f, - 0x80, 0x1f, 0xc0, 0x1f, 0xe0, 0x1f, 0x00, 0x1f, 0x00, 0x1b, 0x80, 0x11, - 0x80, 0x01, 0xc0, 0x00, 0xc0, 0x00, 0x00, 0x00}; +static char right_ptr_bits[] = { + '\x00','\x00','\x00','\x10','\x00','\x18','\x00','\x1c','\x00','\x1e','\x00','\x1f', + '\x80','\x1f','\xc0','\x1f','\xe0','\x1f','\x00','\x1f','\x00','\x1b','\x80','\x11', + '\x80','\x01','\xc0','\x00','\xc0','\x00','\x00','\x00'}; diff --git a/src/bitmaps/stipple.xbm b/src/bitmaps/stipple.xbm index 2e5b9411701..5a25ba29a67 100644 --- a/src/bitmaps/stipple.xbm +++ b/src/bitmaps/stipple.xbm @@ -1,4 +1,4 @@ #define stipple_width 16 #define stipple_height 4 -static unsigned char stipple_bits[] = { - 0x55, 0x55, 0xee, 0xee, 0x55, 0x55, 0xba, 0xbb}; +static char stipple_bits[] = { + '\x55','\x55','\xee','\xee','\x55','\x55','\xba','\xbb'}; diff --git a/src/data.c b/src/data.c index 956ff3700f2..c9250a67bf0 100644 --- a/src/data.c +++ b/src/data.c @@ -3305,6 +3305,10 @@ syms_of_data (void) XSYMBOL (intern_c_string ("most-negative-fixnum"))->constant = 1; } +#ifndef FORWARD_SIGNAL_TO_MAIN_THREAD +static void arith_error (int) NO_RETURN; +#endif + static void arith_error (int signo) { diff --git a/src/dispextern.h b/src/dispextern.h index 840a27ebc62..d00eeae2b19 100644 --- a/src/dispextern.h +++ b/src/dispextern.h @@ -2650,9 +2650,9 @@ struct redisplay_interface int cursor_type, int cursor_width, int on_p, int active_p); -/* Draw vertical border for window W from (X,Y0) to (X,Y1). */ +/* Draw vertical border for window W from (X,Y_0) to (X,Y_1). */ void (*draw_vertical_window_border) (struct window *w, - int x, int y0, int y1); + int x, int y_0, int y_1); /* Shift display of frame F to make room for inserted glyphs. The area at pixel (X,Y) of width WIDTH and height HEIGHT is @@ -2953,6 +2953,9 @@ int line_bottom_y (struct it *); int display_prop_intangible_p (Lisp_Object); void resize_echo_area_exactly (void); int resize_mini_window (struct window *, int); +#if defined USE_TOOLKIT_SCROLL_BARS && !defined USE_GTK +void set_vertical_scroll_bar (struct window *); +#endif int try_window (Lisp_Object, struct text_pos, int); void window_box (struct window *, int, int *, int *, int *, int *); int window_box_height (struct window *); diff --git a/src/emacs.c b/src/emacs.c index cccd07417e1..0a132e156a0 100644 --- a/src/emacs.c +++ b/src/emacs.c @@ -164,10 +164,6 @@ static void *my_heap_start; /* The gap between BSS end and heap start as far as we can tell. */ static unsigned long heap_bss_diff; -/* If the gap between BSS end and heap start is larger than this - output a warning in dump-emacs. */ -#define MAX_HEAP_BSS_DIFF (1024*1024) - /* Nonzero means running Emacs without interactive terminal. */ int noninteractive; @@ -2100,7 +2096,6 @@ This is used in the file `loadup.el' when building Emacs. You must run Emacs in batch mode in order to dump it. */) (Lisp_Object filename, Lisp_Object symfile) { - extern char my_edata[]; Lisp_Object tem; Lisp_Object symbol; int count = SPECPDL_INDEX (); @@ -2111,6 +2106,10 @@ You must run Emacs in batch mode in order to dump it. */) error ("Dumping Emacs works only in batch mode"); #ifdef GNU_LINUX + + /* Warn if the gap between BSS end and heap start is larger than this. */ +# define MAX_HEAP_BSS_DIFF (1024*1024) + if (heap_bss_diff > MAX_HEAP_BSS_DIFF) { fprintf (stderr, "**************************************************\n"); @@ -2157,7 +2156,10 @@ You must run Emacs in batch mode in order to dump it. */) #ifndef WINDOWSNT /* On Windows, this was done before dumping, and that once suffices. Meanwhile, my_edata is not valid on Windows. */ - memory_warnings (my_edata, malloc_warning); + { + extern char my_edata[]; + memory_warnings (my_edata, malloc_warning); + } #endif /* not WINDOWSNT */ #if defined (HAVE_GTK_AND_PTHREAD) && !defined SYNC_INPUT /* Pthread may call malloc before main, and then we will get an endless diff --git a/src/eval.c b/src/eval.c index c068f5f3fbf..b843ca5b2ec 100644 --- a/src/eval.c +++ b/src/eval.c @@ -20,6 +20,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include <config.h> #include <limits.h> #include <setjmp.h> +#include <stdio.h> #include "lisp.h" #include "blockinput.h" #include "commands.h" diff --git a/src/fns.c b/src/fns.c index d3009775b81..c057f64469c 100644 --- a/src/fns.c +++ b/src/fns.c @@ -23,11 +23,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include <time.h> #include <setjmp.h> -/* Note on some machines this defines `vector' as a typedef, - so make sure we don't use that name in this file. */ -#undef vector -#define vector ***** - #include "lisp.h" #include "commands.h" #include "character.h" diff --git a/src/frame.c b/src/frame.c index cafcd149503..9024a2fb5e2 100644 --- a/src/frame.c +++ b/src/frame.c @@ -3845,6 +3845,31 @@ display_x_get_resource (Display_Info *dpyinfo, Lisp_Object attribute, Lisp_Objec attribute, class, component, subclass); } +#if defined HAVE_X_WINDOWS && !defined USE_X_TOOLKIT +/* Used when C code wants a resource value. */ +/* Called from oldXMenu/Create.c. */ +char * +x_get_resource_string (const char *attribute, const char *class) +{ + char *name_key; + char *class_key; + struct frame *sf = SELECTED_FRAME (); + + /* Allocate space for the components, the dots which separate them, + and the final '\0'. */ + name_key = (char *) alloca (SBYTES (Vinvocation_name) + + strlen (attribute) + 2); + class_key = (char *) alloca ((sizeof (EMACS_CLASS) - 1) + + strlen (class) + 2); + + sprintf (name_key, "%s.%s", SSDATA (Vinvocation_name), attribute); + sprintf (class_key, "%s.%s", EMACS_CLASS, class); + + return x_get_string_resource (FRAME_X_DISPLAY_INFO (sf)->xrdb, + name_key, class_key); +} +#endif + /* Return the value of parameter PARAM. First search ALIST, then Vdefault_frame_alist, then the X defaults diff --git a/src/frame.h b/src/frame.h index 1f176f6f900..944a3270ae5 100644 --- a/src/frame.h +++ b/src/frame.h @@ -1133,6 +1133,10 @@ extern Lisp_Object display_x_get_resource (Display_Info *, Lisp_Object component, Lisp_Object subclass); +#if defined HAVE_X_WINDOWS && !defined USE_X_TOOLKIT +extern char *x_get_resource_string (const char *, const char *); +#endif + /* In xmenu.c */ extern void set_frame_menubar (FRAME_PTR, int, int); diff --git a/src/insdel.c b/src/insdel.c index 82dce13af98..5ecb01c9538 100644 --- a/src/insdel.c +++ b/src/insdel.c @@ -442,6 +442,7 @@ make_gap_larger (EMACS_INT nbytes_added) Vinhibit_quit = tem; } +#if defined USE_MMAP_FOR_BUFFERS || defined REL_ALLOC || defined DOUG_LEA_MALLOC /* Make the gap NBYTES_REMOVED bytes shorter. */ @@ -501,6 +502,8 @@ make_gap_smaller (EMACS_INT nbytes_removed) Vinhibit_quit = tem; } +#endif /* USE_MMAP_FOR_BUFFERS || REL_ALLOC || DOUG_LEA_MALLOC */ + void make_gap (EMACS_INT nbytes_added) { diff --git a/src/keyboard.c b/src/keyboard.c index c0c53c82714..c601649ebca 100644 --- a/src/keyboard.c +++ b/src/keyboard.c @@ -2259,7 +2259,7 @@ read_char (int commandflag, int nmaps, Lisp_Object *maps, Lisp_Object prev_event volatile Lisp_Object also_record; volatile int reread; struct gcpro gcpro1, gcpro2; - int polling_stopped_here = 0; + int volatile polling_stopped_here = 0; struct kboard *orig_kboard = current_kboard; also_record = Qnil; @@ -5455,7 +5455,6 @@ make_lispy_event (struct input_event *event) && (event->modifiers & down_modifier)) { Lisp_Object items, item; - int i; /* Find the menu bar item under `column'. */ item = Qnil; diff --git a/src/menu.c b/src/menu.c index 3bfb74863ae..f637b92679a 100644 --- a/src/menu.c +++ b/src/menu.c @@ -180,6 +180,9 @@ grow_menu_items (void) menu_items = larger_vector (menu_items, menu_items_allocated, Qnil); } +#if (defined USE_X_TOOLKIT || defined USE_GTK || defined HAVE_NS \ + || defined HAVE_NTGUI) + /* Begin a submenu. */ static void @@ -204,6 +207,8 @@ push_submenu_end (void) menu_items_submenu_depth--; } +#endif /* USE_X_TOOLKIT || USE_GTK || HAVE_NS || defined HAVE_NTGUI */ + /* Indicate boundary between left and right. */ static void @@ -368,34 +373,34 @@ single_menu_item (Lisp_Object key, Lisp_Object item, Lisp_Object dummy, void *sk if (skp->notbuttons) /* The first button. Line up previous items in this menu. */ { - int index = skp->notbuttons; /* Index for first item this menu. */ + int idx = skp->notbuttons; /* Index for first item this menu. */ int submenu = 0; Lisp_Object tem; - while (index < menu_items_used) + while (idx < menu_items_used) { tem - = XVECTOR (menu_items)->contents[index + MENU_ITEMS_ITEM_NAME]; + = XVECTOR (menu_items)->contents[idx + MENU_ITEMS_ITEM_NAME]; if (NILP (tem)) { - index++; + idx++; submenu++; /* Skip sub menu. */ } else if (EQ (tem, Qlambda)) { - index++; + idx++; submenu--; /* End sub menu. */ } else if (EQ (tem, Qt)) - index += 3; /* Skip new pane marker. */ + idx += 3; /* Skip new pane marker. */ else if (EQ (tem, Qquote)) - index++; /* Skip a left, right divider. */ + idx++; /* Skip a left, right divider. */ else { if (!submenu && SREF (tem, 0) != '\0' && SREF (tem, 0) != '-') - XVECTOR (menu_items)->contents[index + MENU_ITEMS_ITEM_NAME] + XVECTOR (menu_items)->contents[idx + MENU_ITEMS_ITEM_NAME] = concat2 (build_string (" "), tem); - index += MENU_ITEMS_ITEM_LENGTH; + idx += MENU_ITEMS_ITEM_LENGTH; } } skp->notbuttons = 0; diff --git a/src/process.c b/src/process.c index c9c6ab6d4b3..d8851c56cf0 100644 --- a/src/process.c +++ b/src/process.c @@ -237,7 +237,9 @@ static int process_output_skip; static Lisp_Object Fget_process (Lisp_Object); static void create_process (Lisp_Object, char **, Lisp_Object); +#ifdef SIGIO static int keyboard_bit_set (SELECT_TYPE *); +#endif static void deactivate_process (Lisp_Object); static void status_notify (struct Lisp_Process *); static int read_process_output (Lisp_Object, int); @@ -5220,6 +5222,10 @@ read_process_output (Lisp_Object proc, register int channel) static jmp_buf send_process_frame; static Lisp_Object process_sent_to; +#ifndef FORWARD_SIGNAL_TO_MAIN_THREAD +static void send_process_trap (int) NO_RETURN; +#endif + static void send_process_trap (int ignore) { @@ -5360,6 +5366,8 @@ send_process (volatile Lisp_Object proc, const char *volatile buf, when returning with longjmp despite being declared volatile. */ if (!setjmp (send_process_frame)) { + p = XPROCESS (proc); /* Repair any setjmp clobbering. */ + process_sent_to = proc; while (len > 0) { @@ -6583,6 +6591,8 @@ delete_gpm_wait_descriptor (int desc) delete_keyboard_wait_descriptor (desc); } +# ifdef SIGIO + /* Return nonzero if *MASK has a bit set that corresponds to one of the keyboard input descriptors. */ @@ -6598,6 +6608,7 @@ keyboard_bit_set (fd_set *mask) return 0; } +# endif #else /* not subprocesses */ diff --git a/src/s/sol2-6.h b/src/s/sol2-6.h index 4c6fd3e2f9b..3d9bd6ddafc 100644 --- a/src/s/sol2-6.h +++ b/src/s/sol2-6.h @@ -44,7 +44,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #define PTY_TTY_NAME_SPRINTF \ { \ - char *ptsname (), *ptyname; \ + char *ptsname (int), *ptyname; \ \ sigblock (sigmask (SIGCLD)); \ if (grantpt (fd) == -1) \ @@ -60,4 +60,3 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #define GC_SETJMP_WORKS 1 #define GC_MARK_STACK GC_MAKE_GCPROS_NOOPS - diff --git a/src/s/unixware.h b/src/s/unixware.h index 407282ff78c..8fe28625dd4 100644 --- a/src/s/unixware.h +++ b/src/s/unixware.h @@ -35,7 +35,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ within, it should be caught after sigrelse(2). */ #define PTY_TTY_NAME_SPRINTF \ { \ - char *ptsname(), *ptyname; \ + char *ptsname (int), *ptyname; \ \ sigblock(sigmask(SIGCLD)); \ if (grantpt(fd) == -1) \ diff --git a/src/s/usg5-4-common.h b/src/s/usg5-4-common.h index 236f71e3007..e6d992d8f9c 100644 --- a/src/s/usg5-4-common.h +++ b/src/s/usg5-4-common.h @@ -88,11 +88,11 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ /* Push various streams modules onto a PTY channel. */ #define SETUP_SLAVE_PTY \ if (ioctl (xforkin, I_PUSH, "ptem") == -1) \ - fatal ("ioctl I_PUSH ptem", errno); \ + fatal ("ioctl I_PUSH ptem"); \ if (ioctl (xforkin, I_PUSH, "ldterm") == -1) \ - fatal ("ioctl I_PUSH ldterm", errno); \ + fatal ("ioctl I_PUSH ldterm"); \ if (ioctl (xforkin, I_PUSH, "ttcompat") == -1) \ - fatal ("ioctl I_PUSH ttcompat", errno); + fatal ("ioctl I_PUSH ttcompat"); /* This definition was suggested for next release. So give it a try. */ #define HAVE_SOCKETS diff --git a/src/sysdep.c b/src/sysdep.c index e01bc4b1fbc..45e80ac0155 100644 --- a/src/sysdep.c +++ b/src/sysdep.c @@ -2966,6 +2966,8 @@ system_process_attributes (Lisp_Object pid) #if PROCFS_FILE_OFFSET_BITS_HACK == 1 #define _FILE_OFFSET_BITS 64 +#ifdef _FILE_OFFSET_BITS /* Avoid unused-macro warnings. */ +#endif #endif /* PROCFS_FILE_OFFSET_BITS_HACK == 1 */ Lisp_Object diff --git a/src/termhooks.h b/src/termhooks.h index 2f509009bd9..468381b69aa 100644 --- a/src/termhooks.h +++ b/src/termhooks.h @@ -465,7 +465,7 @@ struct terminal enum scroll_bar_part *part, Lisp_Object *x, Lisp_Object *y, - unsigned long *time); + unsigned long *); /* The window system handling code should set this if the mouse has moved since the last call to the mouse_position_hook. Calling that @@ -484,10 +484,10 @@ struct terminal support overlapping frames, so there's no need to raise or lower anything. - If RAISE is non-zero, F is brought to the front, before all other - windows. If RAISE is zero, F is sent to the back, behind all other + If RAISE_FLAG is non-zero, F is brought to the front, before all other + windows. If RAISE_FLAG is zero, F is sent to the back, behind all other windows. */ - void (*frame_raise_lower_hook) (struct frame *f, int raise); + void (*frame_raise_lower_hook) (struct frame *f, int raise_flag); /* If the value of the frame parameter changed, whis hook is called. For example, if going from fullscreen to not fullscreen this hook diff --git a/src/xdisp.c b/src/xdisp.c index 4f1830f4c6c..3c75a63f4e0 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -13630,7 +13630,10 @@ try_cursor_movement (Lisp_Object window, struct text_pos startp, int *scroll_ste return rc; } -static void +#if !defined USE_TOOLKIT_SCROLL_BARS || defined USE_GTK +static +#endif +void set_vertical_scroll_bar (struct window *w) { EMACS_INT start, end, whole; @@ -22709,7 +22712,7 @@ x_produce_glyphs (struct it *it) int lbearing, rbearing; int i, width, ascent, descent; int left_padded = 0, right_padded = 0; - int c; + int c IF_LINT (= 0); /* cmp->glyph_len can't be zero; see Bug#8512 */ XChar2b char2b; struct font_metrics *pcm; int font_not_found_p; diff --git a/src/xfaces.c b/src/xfaces.c index 5cfe99d1285..fbed183522a 100644 --- a/src/xfaces.c +++ b/src/xfaces.c @@ -273,6 +273,8 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include <X11/Xos.h> #define USG #define __TIMEVAL__ +#if defined USG || defined __TIMEVAL__ /* Don't warn about unused macros. */ +#endif #else /* not XOS_NEEDS_TIME_H */ #include <X11/Xos.h> #endif /* not XOS_NEEDS_TIME_H */ diff --git a/src/xfns.c b/src/xfns.c index 290b6161215..51aca3e9670 100644 --- a/src/xfns.c +++ b/src/xfns.c @@ -83,6 +83,8 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #undef USG /* ####KLUDGE for Solaris 2.2 and up */ #include <X11/Xos.h> #define USG +#ifdef USG /* Pacify gcc -Wunused-macros. */ +#endif #else #include <X11/Xos.h> #endif @@ -105,16 +107,13 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #if !defined(NO_EDITRES) #define HACK_EDITRES -extern void _XEditResCheckMessages (); +extern void _XEditResCheckMessages (Widget, XtPointer, XEvent *, Boolean *); #endif /* not defined NO_EDITRES */ /* Unique id counter for widgets created by the Lucid Widget Library. */ extern LWLIB_ID widget_id_tick; -extern void free_frame_menubar (); -extern double atof (); - #ifdef USE_MOTIF #endif /* USE_MOTIF */ @@ -428,7 +427,7 @@ x_top_window_to_frame (struct x_display_info *dpyinfo, int wdesc) void x_real_positions (FRAME_PTR f, int *xptr, int *yptr) { - int win_x, win_y, outer_x, outer_y; + int win_x, win_y, outer_x IF_LINT (= 0), outer_y IF_LINT (= 0); int real_x = 0, real_y = 0; int had_errors = 0; Window win = f->output_data.x->parent_desc; @@ -2430,8 +2429,8 @@ x_window (struct frame *f, long window_prompting, int minibuffer_only) { int len; char *tem, shell_position[32]; - Arg al[10]; - int ac = 0; + Arg gal[10]; + int gac = 0; int extra_borders = 0; int menubar_size = (f->output_data.x->menubar_widget @@ -2492,8 +2491,8 @@ x_window (struct frame *f, long window_prompting, int minibuffer_only) If Emacs had just one program position, we could set it in fallback resources, but since each make-frame call can specify different program positions, this is easier. */ - XtSetArg (al[ac], XtNx, left); ac++; - XtSetArg (al[ac], XtNy, top); ac++; + XtSetArg (gal[gac], XtNx, left); gac++; + XtSetArg (gal[gac], XtNy, top); gac++; } } @@ -2504,8 +2503,8 @@ x_window (struct frame *f, long window_prompting, int minibuffer_only) when the frame is deleted. */ tem = (char *) xmalloc (len); strncpy (tem, shell_position, len); - XtSetArg (al[ac], XtNgeometry, tem); ac++; - XtSetValues (shell_widget, al, ac); + XtSetArg (gal[gac], XtNgeometry, tem); gac++; + XtSetValues (shell_widget, gal, gac); } XtManageChild (pane_widget); @@ -5206,7 +5205,6 @@ Value is t if tooltip was open, nil otherwise. */) int count; Lisp_Object deleted, frame, timer; struct gcpro gcpro1, gcpro2; - struct frame *f; /* Return quickly if nothing to do. */ if (NILP (tip_timer) && NILP (tip_frame)) @@ -5225,11 +5223,13 @@ Value is t if tooltip was open, nil otherwise. */) call1 (Qcancel_timer, timer); #ifdef USE_GTK - /* When using system tooltip, tip_frame is the Emacs frame on which - the tip is shown. */ - f = XFRAME (frame); - if (FRAME_LIVE_P (f) && xg_hide_tooltip (f)) - frame = Qnil; + { + /* When using system tooltip, tip_frame is the Emacs frame on which + the tip is shown. */ + struct frame *f = XFRAME (frame); + if (FRAME_LIVE_P (f) && xg_hide_tooltip (f)) + frame = Qnil; + } #endif if (FRAMEP (frame)) @@ -5243,7 +5243,7 @@ Value is t if tooltip was open, nil otherwise. */) items is unmapped. Redisplay the menu manually... */ { Widget w; - f = SELECTED_FRAME (); + struct frame *f = SELECTED_FRAME (); w = f->output_data.x->menubar_widget; if (!DoesSaveUnders (FRAME_X_DISPLAY_INFO (f)->screen) @@ -5462,12 +5462,12 @@ Otherwise, if ONLY-DIR-P is non-nil, the user can only select directories. */) /* Get the result. */ if (result == XmCR_OK) { - XmString text; + XmString text_string; String data; - XtVaGetValues (dialog, XmNtextString, &text, NULL); - XmStringGetLtoR (text, XmFONTLIST_DEFAULT_TAG, &data); - XmStringFree (text); + XtVaGetValues (dialog, XmNtextString, &text_string, NULL); + XmStringGetLtoR (text_string, XmFONTLIST_DEFAULT_TAG, &data); + XmStringFree (text_string); file = build_string (data); XtFree (data); } diff --git a/src/xgselect.c b/src/xgselect.c index 96d763ff088..0d154f6496a 100644 --- a/src/xgselect.c +++ b/src/xgselect.c @@ -19,11 +19,14 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include <config.h> +#include <setjmp.h> +#include "xgselect.h" + #if defined (USE_GTK) || defined (HAVE_GCONF) + #include <glib.h> #include <errno.h> #include <setjmp.h> -#include "xgselect.h" static GPollFD *gfds; static int gfds_size; diff --git a/src/xmenu.c b/src/xmenu.c index 6e84b845a46..938e5696b21 100644 --- a/src/xmenu.c +++ b/src/xmenu.c @@ -108,7 +108,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #ifndef TRUE #define TRUE 1 -#define FALSE 0 #endif /* no TRUE */ static Lisp_Object Qdebug_on_next_call; @@ -117,8 +116,6 @@ static Lisp_Object Qdebug_on_next_call; static Lisp_Object xdialog_show (FRAME_PTR, int, Lisp_Object, Lisp_Object, const char **); #endif - -static int update_frame_menubar (struct frame *); /* Flag which when set indicates a dialog or menu has been posted by Xt on behalf of one of the widget sets. */ @@ -2185,7 +2182,7 @@ static struct frame *menu_help_frame; keyboard events. */ static void -menu_help_callback (char *help_string, int pane, int item) +menu_help_callback (char const *help_string, int pane, int item) { Lisp_Object *first_item; Lisp_Object pane_name; @@ -2245,7 +2242,7 @@ pop_down_menu (Lisp_Object arg) Lisp_Object xmenu_show (FRAME_PTR f, int x, int y, int for_click, int keymaps, - Lisp_Object title, const char **error, EMACS_UINT timestamp) + Lisp_Object title, const char **error_name, EMACS_UINT timestamp) { Window root; XMenu *menu; @@ -2263,13 +2260,13 @@ xmenu_show (FRAME_PTR f, int x, int y, int for_click, int keymaps, if (! FRAME_X_P (f) && ! FRAME_MSDOS_P (f)) abort (); - *error = 0; + *error_name = 0; if (menu_items_n_panes == 0) return Qnil; if (menu_items_used <= MENU_ITEMS_PANE_LENGTH) { - *error = "Empty menu"; + *error_name = "Empty menu"; return Qnil; } @@ -2282,7 +2279,7 @@ xmenu_show (FRAME_PTR f, int x, int y, int for_click, int keymaps, menu = XMenuCreate (FRAME_X_DISPLAY (f), root, "emacs"); if (menu == NULL) { - *error = "Can't create menu"; + *error_name = "Can't create menu"; return Qnil; } @@ -2302,7 +2299,8 @@ xmenu_show (FRAME_PTR f, int x, int y, int for_click, int keymaps, y += f->top_pos; /* Create all the necessary panes and their items. */ - maxlines = lines = i = 0; + maxwidth = maxlines = lines = i = 0; + lpane = XM_FAILURE; while (i < menu_items_used) { if (EQ (XVECTOR (menu_items)->contents[i], Qt)) @@ -2324,13 +2322,12 @@ xmenu_show (FRAME_PTR f, int x, int y, int for_click, int keymaps, if (lpane == XM_FAILURE) { XMenuDestroy (FRAME_X_DISPLAY (f), menu); - *error = "Can't create pane"; + *error_name = "Can't create pane"; return Qnil; } i += MENU_ITEMS_PANE_LENGTH; /* Find the width of the widest item in this pane. */ - maxwidth = 0; j = i; while (j < menu_items_used) { @@ -2358,40 +2355,38 @@ xmenu_show (FRAME_PTR f, int x, int y, int for_click, int keymaps, { /* Create a new item within current pane. */ Lisp_Object item_name, enable, descrip, help; - unsigned char *item_data; - char *help_string; + char *item_data; + char const *help_string; item_name = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_NAME]; enable = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_ENABLE]; descrip = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_EQUIV_KEY]; help = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_HELP]; - help_string = STRINGP (help) ? SDATA (help) : NULL; + help_string = STRINGP (help) ? SSDATA (help) : NULL; if (!NILP (descrip)) { - int gap = maxwidth - SBYTES (item_name); /* if alloca is fast, use that to make the space, to reduce gc needs. */ - item_data - = (unsigned char *) alloca (maxwidth - + SBYTES (descrip) + 1); - memcpy (item_data, SDATA (item_name), SBYTES (item_name)); + item_data = (char *) alloca (maxwidth + SBYTES (descrip) + 1); + memcpy (item_data, SSDATA (item_name), SBYTES (item_name)); for (j = SCHARS (item_name); j < maxwidth; j++) item_data[j] = ' '; - memcpy (item_data + j, SDATA (descrip), SBYTES (descrip)); + memcpy (item_data + j, SSDATA (descrip), SBYTES (descrip)); item_data[j + SBYTES (descrip)] = 0; } else - item_data = SDATA (item_name); + item_data = SSDATA (item_name); - if (XMenuAddSelection (FRAME_X_DISPLAY (f), - menu, lpane, 0, item_data, - !NILP (enable), help_string) - == XM_FAILURE) + if (lpane == XM_FAILURE + || (XMenuAddSelection (FRAME_X_DISPLAY (f), + menu, lpane, 0, item_data, + !NILP (enable), help_string) + == XM_FAILURE)) { XMenuDestroy (FRAME_X_DISPLAY (f), menu); - *error = "Can't add selection to menu"; + *error_name = "Can't add selection to menu"; return Qnil; } i += MENU_ITEMS_ITEM_LENGTH; @@ -2468,6 +2463,7 @@ xmenu_show (FRAME_PTR f, int x, int y, int for_click, int keymaps, status = XMenuActivate (FRAME_X_DISPLAY (f), menu, &pane, &selidx, x, y, ButtonReleaseMask, &datap, menu_help_callback); + entry = pane_prefix = Qnil; switch (status) { @@ -2512,16 +2508,14 @@ xmenu_show (FRAME_PTR f, int x, int y, int for_click, int keymaps, break; case XM_FAILURE: - *error = "Can't activate menu"; + *error_name = "Can't activate menu"; case XM_IA_SELECT: - entry = Qnil; break; case XM_NO_SELECT: /* Make "Cancel" equivalent to C-g unless FOR_CLICK (which means the menu was invoked with a mouse event as POSITION). */ if (! for_click) Fsignal (Qquit, Qnil); - entry = Qnil; break; } diff --git a/src/xrdb.c b/src/xrdb.c index d350f38a8c4..b01e344edf2 100644 --- a/src/xrdb.c +++ b/src/xrdb.c @@ -479,7 +479,9 @@ x_load_resources (Display *display, const char *xrm_string, XrmDatabase db; char line[256]; +#if defined USE_MOTIF || !defined HAVE_XFT || !defined USE_LUCID const char *helv = "-*-helvetica-medium-r-*--*-120-*-*-*-*-iso8859-1"; +#endif #ifdef USE_MOTIF const char *courier = "-*-courier-medium-r-*-*-*-120-*-*-*-*-iso8859-1"; diff --git a/src/xsmfns.c b/src/xsmfns.c index f3879dbcec0..c199036587f 100644 --- a/src/xsmfns.c +++ b/src/xsmfns.c @@ -41,8 +41,8 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include "process.h" #include "keyboard.h" -#ifndef HAVE_GTK3 -#define gdk_x11_set_sm_client_id(w) gdk_set_sm_client_id (w) +#if defined USE_GTK && !defined HAVE_GTK3 +#define gdk_x11_set_sm_client_id(w) gdk_set_sm_client_id (w) #endif /* This is the event used when SAVE_SESSION_EVENT occurs. */ @@ -250,7 +250,7 @@ smc_save_yourself_CB (SmcConn smcConn, props[props_idx]->vals[vp_idx++].value = chdir_opt; } - for (i = 1; i < initial_argc; ++i) + for (i = 1; i < initial_argc; ++i) { props[props_idx]->vals[vp_idx].length = strlen (initial_argv[i]); props[props_idx]->vals[vp_idx++].value = initial_argv[i]; @@ -365,11 +365,10 @@ ice_conn_watch_CB (IceConn iceConn, IcePointer clientData, #ifndef USE_GTK static void -create_client_leader_window (struct x_display_info *dpyinfo, char *client_id) +create_client_leader_window (struct x_display_info *dpyinfo, char *client_ID) { Window w; XClassHint class_hints; - Atom sm_id; w = XCreateSimpleWindow (dpyinfo->display, dpyinfo->root_window, @@ -383,7 +382,7 @@ create_client_leader_window (struct x_display_info *dpyinfo, char *client_id) XChangeProperty (dpyinfo->display, w, dpyinfo->Xatom_SM_CLIENT_ID, XA_STRING, 8, PropModeReplace, - (unsigned char *)client_id, strlen (client_id)); + (unsigned char *) client_ID, strlen (client_ID)); dpyinfo->client_leader_window = w; } diff --git a/src/xterm.c b/src/xterm.c index bc847388756..a44313d0a56 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -102,7 +102,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #ifdef USE_X_TOOLKIT #if !defined(NO_EDITRES) #define HACK_EDITRES -extern void _XEditResCheckMessages (); +extern void _XEditResCheckMessages (Widget, XtPointer, XEvent *, Boolean *); #endif /* not NO_EDITRES */ /* Include toolkit specific headers for the scroll bar widget. */ @@ -187,11 +187,11 @@ static struct { /* The application context for Xt use. */ XtAppContext Xt_app_con; static String Xt_default_resources[] = {0}; -#endif /* USE_X_TOOLKIT */ /* Non-zero means user is interacting with a toolkit scroll bar. */ static int toolkit_scroll_bar_interaction; +#endif /* USE_X_TOOLKIT */ /* Non-zero timeout value means ignore next mouse click if it arrives before that timeout elapses (i.e. as part of the same sequence of @@ -349,7 +349,7 @@ static void x_check_expected_move (struct frame *, int, int); static void x_sync_with_move (struct frame *, int, int, int); static int handle_one_xevent (struct x_display_info *, XEvent *, int *, struct input_event *); -#if ! (defined USE_MOTIF || defined USE_X_TOOLKIT) +#ifdef USE_GTK static int x_dispatch_event (XEvent *, Display *); #endif /* Don't declare this NO_RETURN because we want no @@ -1451,19 +1451,6 @@ x_frame_of_widget (Widget widget) } -/* Allocate the color COLOR->pixel on the screen and display of - widget WIDGET in colormap CMAP. If an exact match cannot be - allocated, try the nearest color available. Value is non-zero - if successful. This is called from lwlib. */ - -int -x_alloc_nearest_color_for_widget (Widget widget, Colormap cmap, XColor *color) -{ - struct frame *f = x_frame_of_widget (widget); - return x_alloc_nearest_color (f, cmap, color); -} - - /* Allocate a color which is lighter or darker than *PIXEL by FACTOR or DELTA. Try a color with RGB values multiplied by FACTOR first. If this produces the same color as PIXEL, try a color where all RGB @@ -3459,6 +3446,16 @@ x_detect_focus_change (struct x_display_info *dpyinfo, XEvent *event, struct inp } +#if defined HAVE_MENUS && !defined USE_X_TOOLKIT && !defined USE_GTK +/* Handle an event saying the mouse has moved out of an Emacs frame. */ + +void +x_mouse_leave (struct x_display_info *dpyinfo) +{ + x_new_focus_frame (dpyinfo, dpyinfo->x_focus_event_frame); +} +#endif + /* The focus has changed, or we have redirected a frame's focus to another frame (this happens when a frame uses a surrogate mini-buffer frame). Shift the highlight as appropriate. @@ -4221,8 +4218,8 @@ x_send_scroll_bar_event (Lisp_Object window, int part, int portion, int whole) ev->data.l[4] = (long) whole; /* Make Xt timeouts work while the scroll bar is active. */ - toolkit_scroll_bar_interaction = 1; #ifdef USE_X_TOOLKIT + toolkit_scroll_bar_interaction = 1; x_activate_timeout_atimer (); #endif @@ -4535,7 +4532,7 @@ x_create_toolkit_scroll_bar (struct frame *f, struct scroll_bar *bar) Widget widget; Arg av[20]; int ac = 0; - char *scroll_bar_name = SCROLL_BAR_NAME; + char const *scroll_bar_name = SCROLL_BAR_NAME; unsigned long pixel; BLOCK_INPUT; @@ -4687,8 +4684,8 @@ x_create_toolkit_scroll_bar (struct frame *f, struct scroll_bar *bar) f->output_data.x->edit_widget, av, ac); { - char *initial = ""; - char *val = initial; + char const *initial = ""; + char const *val = initial; XtVaGetValues (widget, XtNscrollVCursor, (XtPointer) &val, #ifdef XtNarrowScrollbars XtNarrowScrollbars, (XtPointer) &xaw3d_arrow_scroll, @@ -5668,6 +5665,7 @@ static struct x_display_info *XTread_socket_fake_io_error; static struct x_display_info *next_noop_dpyinfo; +#if defined USE_X_TOOLKIT || defined USE_GTK #define SET_SAVED_BUTTON_EVENT \ do \ { \ @@ -5679,6 +5677,7 @@ static struct x_display_info *next_noop_dpyinfo; XSETFRAME (inev.ie.frame_or_window, f); \ } \ while (0) +#endif enum { @@ -5764,8 +5763,8 @@ event_handler_gdk (GdkXEvent *gxev, GdkEvent *ev, gpointer data) #endif /* USE_GTK */ -static void xembed_send_message (struct frame *f, Time time, - enum xembed_message message, +static void xembed_send_message (struct frame *f, Time, + enum xembed_message, long detail, long data1, long data2); /* Handles the XEvent EVENT on display DPYINFO. @@ -6978,15 +6977,13 @@ handle_one_xevent (struct x_display_info *dpyinfo, XEvent *eventptr, return count; } +#if defined USE_GTK || defined USE_X_TOOLKIT /* Handles the XEvent EVENT on display DISPLAY. This is used for event loops outside the normal event handling, i.e. looping while a popup menu or a dialog is posted. Returns the value handle_one_xevent sets in the finish argument. */ -#if ! (defined USE_MOTIF || defined USE_X_TOOLKIT) -static -#endif int x_dispatch_event (XEvent *event, Display *display) { @@ -7000,6 +6997,7 @@ x_dispatch_event (XEvent *event, Display *display) return finish; } +#endif /* Read events coming from the X server. @@ -10273,10 +10271,10 @@ x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name) #ifdef USE_LUCID { - Display *dpy = dpyinfo->display; XrmValue d, fr, to; Font font; + dpy = dpyinfo->display; d.addr = (XPointer)&dpy; d.size = sizeof (Display *); fr.addr = XtDefaultFont; diff --git a/src/xterm.h b/src/xterm.h index bd5cf2dbd31..fbd638fe73b 100644 --- a/src/xterm.h +++ b/src/xterm.h @@ -982,11 +982,11 @@ extern int x_alloc_nearest_color (struct frame *, Colormap, XColor *); extern void x_query_colors (struct frame *f, XColor *, int); extern void x_query_color (struct frame *f, XColor *); extern void x_clear_area (Display *, Window, int, int, int, int, int); -#ifdef WINDOWSNT +#if defined HAVE_MENUS && !defined USE_X_TOOLKIT && !defined USE_GTK extern void x_mouse_leave (struct x_display_info *); #endif -#if defined USE_MOTIF || defined USE_X_TOOLKIT +#ifdef USE_X_TOOLKIT extern int x_dispatch_event (XEvent *, Display *); #endif extern unsigned int x_x_to_emacs_modifiers (struct x_display_info *, |