Tweak X toolkit code to pacify modern GCC

* lwlib/lwlib-Xaw.c, lwlib/lwlib-Xm.c, lwlib/lwlib.c:
Don’t include <stdlib.h>, since this code now calls emacs_abort
rather than abort.
* lwlib/lwlib-Xaw.c (make_dialog, xaw_generic_callback)
(wm_delete_window):
* lwlib/lwlib-Xm.c (make_menu_in_widget, do_call):
* lwlib/lwlib.c (instantiate_widget_instance, lw_make_widget):
* lwlib/xlwmenu.c (abort_gracefully, draw_separator)
(separator_height, XlwMenuInitialize):
Use emacs_abort, not abort.  Without this change, some calls
to ‘abort’ were invalid, as stdlib.h was not always included.
* src/widget.c (resources, emacsFrameClassRec):
* src/xfns.c (x_window) [USE_X_TOOLKIT]:
* src/xmenu.c (create_and_show_popup_menu) [USE_X_TOOLKIT]:
* src/xterm.c (emacs_options) [USE_X_TOOLKIT}:
(x_term_init) [USE_X_TOOLKIT]:
Cast string constants to char * to pacify --enable-gcc-warnings.
This commit is contained in:
Paul Eggert 2017-03-10 09:30:30 -08:00
parent 817c4d1a30
commit ec168376d1
8 changed files with 60 additions and 59 deletions

View file

@ -21,7 +21,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#include <config.h>
#include <stdio.h>
#include <stdlib.h>
#include <setjmp.h>
#include <lisp.h>
@ -516,10 +515,10 @@ make_dialog (char* name,
XtTranslations button_override;
#endif
if (! pop_up_p) abort (); /* not implemented */
if (text_input_slot) abort (); /* not implemented */
if (radio_box) abort (); /* not implemented */
if (list) abort (); /* not implemented */
if (! pop_up_p) emacs_abort (); /* not implemented */
if (text_input_slot) emacs_abort (); /* not implemented */
if (radio_box) emacs_abort (); /* not implemented */
if (list) emacs_abort (); /* not implemented */
if (! actions_initted)
{
@ -764,7 +763,7 @@ xaw_generic_callback (Widget widget, XtPointer closure, XtPointer call_data)
break;
val = val->next;
}
if (! val) abort ();
if (! val) emacs_abort ();
user_data = val->call_data;
}
@ -790,11 +789,11 @@ wm_delete_window (Widget w,
shell = w;
if (! XtIsSubclass (shell, shellWidgetClass))
abort ();
emacs_abort ();
XtVaGetValues (shell, XtNnumChildren, &nkids, NULL);
XtVaGetValues (shell, XtNchildren, &kids, NULL);
if (!kids || !*kids)
abort ();
emacs_abort ();
for (i = 0; i < nkids; i++)
{
widget = kids[i];
@ -804,11 +803,11 @@ wm_delete_window (Widget w,
if (! widget) return;
id = lw_get_widget_id (widget);
if (! id) abort ();
if (! id) emacs_abort ();
{
widget_info *info = lw_get_widget_info (id);
if (! info) abort ();
if (! info) emacs_abort ();
if (info->selection_cb)
info->selection_cb (widget, id, (XtPointer) -1);
}

View file

@ -22,7 +22,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <setjmp.h>
#include <X11/StringDefs.h>
@ -504,14 +503,14 @@ make_menu_in_widget (widget_instance* instance,
/* WIDGET should be a RowColumn. */
if (!XmIsRowColumn (widget))
abort ();
emacs_abort ();
/* Determine whether WIDGET is a menu bar. */
type = -1;
XtSetArg (al[0], XmNrowColumnType, &type);
XtGetValues (widget, al, 1);
if (type != XmMENU_BAR && type != XmMENU_PULLDOWN && type != XmMENU_POPUP)
abort ();
emacs_abort ();
menubar_p = type == XmMENU_BAR;
/* Add a callback to popups and pulldowns that is called when
@ -528,7 +527,7 @@ make_menu_in_widget (widget_instance* instance,
/* Check that those are all we have
(the caller should have deleted the rest). */
if (old_num_children != keep_first_children)
abort ();
emacs_abort ();
/* Create the rest. */
for (child_index = keep_first_children; cur; child_index++, cur = cur->next)
@ -677,7 +676,7 @@ update_one_menu_entry (widget_instance* instance,
if (strcmp (XtName (widget_list[i]), XtName (widget)) == 0)
break;
if (i == old_num_children)
abort ();
emacs_abort ();
if (XmIsCascadeButton (widget_list[i]))
{
menu = XmCreatePulldownMenu (parent, XtName(widget), NULL, 0);
@ -1829,7 +1828,7 @@ do_call (Widget widget,
break;
default:
abort ();
emacs_abort ();
}
}

View file

@ -26,7 +26,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#include <sys/types.h>
#include <stdio.h>
#include <stdlib.h>
#include "lwlib-int.h"
#include "lwlib-utils.h"
#include <X11/StringDefs.h>
@ -721,13 +720,13 @@ instantiate_widget_instance (widget_instance *instance)
{
printf ("No creation function for widget type %s\n",
instance->info->type);
abort ();
emacs_abort ();
}
instance->widget = (*function) (instance);
if (!instance->widget)
abort ();
emacs_abort ();
/* XtRealizeWidget (instance->widget);*/
}
@ -772,7 +771,7 @@ lw_make_widget (LWLIB_ID id, Widget parent, Boolean pop_up_p)
initialize_widget_instance (instance);
}
if (!instance->widget)
abort ();
emacs_abort ();
return instance->widget;
}

View file

@ -267,7 +267,7 @@ abort_gracefully (Widget w)
if (XtIsShell (XtParent (w)))
XtRemoveGrab (w);
ungrab_all (w, CurrentTime);
abort ();
emacs_abort ();
}
static void
@ -897,7 +897,7 @@ draw_separator (XlwMenuWidget mw,
break;
default:
abort ();
emacs_abort ();
}
}
@ -933,7 +933,7 @@ separator_height (enum menu_separator separator)
return 5;
default:
abort ();
emacs_abort ();
}
}
@ -1900,7 +1900,7 @@ XlwMenuInitialize (Widget request, Widget w, ArgList args, Cardinal *num_args)
if (!mw->menu.font)
{
fprintf (stderr, "Menu font fixed not found, can't continue.\n");
abort ();
emacs_abort ();
}
}
}

View file

@ -57,31 +57,34 @@ static XtGeometryResult EmacsFrameQueryGeometry (Widget widget, XtWidgetGeometry
#define offset(field) offsetof (EmacsFrameRec, emacs_frame.field)
static XtResource resources[] = {
{XtNgeometry, XtCGeometry, XtRString, sizeof (String),
{(char *) XtNgeometry, (char *) XtCGeometry, XtRString, sizeof (String),
offset (geometry), XtRString, (XtPointer) 0},
{XtNiconic, XtCIconic, XtRBoolean, sizeof (Boolean),
offset (iconic), XtRImmediate, (XtPointer) False},
{XtNemacsFrame, XtCEmacsFrame, XtRPointer, sizeof (XtPointer),
{(char *) XtNemacsFrame, (char *) XtCEmacsFrame,
XtRPointer, sizeof (XtPointer),
offset (frame), XtRImmediate, 0},
{XtNminibuffer, XtCMinibuffer, XtRInt, sizeof (int),
{(char *) XtNminibuffer, (char *) XtCMinibuffer, XtRInt, sizeof (int),
offset (minibuffer), XtRImmediate, (XtPointer)0},
{XtNunsplittable, XtCUnsplittable, XtRBoolean, sizeof (Boolean),
{(char *) XtNunsplittable, (char *) XtCUnsplittable,
XtRBoolean, sizeof (Boolean),
offset (unsplittable), XtRImmediate, (XtPointer)0},
{XtNinternalBorderWidth, XtCInternalBorderWidth, XtRInt, sizeof (int),
{(char *) XtNinternalBorderWidth, (char *) XtCInternalBorderWidth,
XtRInt, sizeof (int),
offset (internal_border_width), XtRImmediate, (XtPointer)4},
{XtNinterline, XtCInterline, XtRInt, sizeof (int),
{(char *) XtNinterline, (char *) XtCInterline, XtRInt, sizeof (int),
offset (interline), XtRImmediate, (XtPointer)0},
{XtNforeground, XtCForeground, XtRPixel, sizeof (Pixel),
offset (foreground_pixel), XtRString, "XtDefaultForeground"},
{XtNcursorColor, XtCForeground, XtRPixel, sizeof (Pixel),
offset (cursor_color), XtRString, "XtDefaultForeground"},
{XtNbarCursor, XtCBarCursor, XtRBoolean, sizeof (Boolean),
{(char *) XtNforeground, (char *) XtCForeground, XtRPixel, sizeof (Pixel),
offset (foreground_pixel), XtRString, (char *) "XtDefaultForeground"},
{(char *) XtNcursorColor, (char *) XtCForeground, XtRPixel, sizeof (Pixel),
offset (cursor_color), XtRString, (char *) "XtDefaultForeground"},
{(char *) XtNbarCursor, (char *) XtCBarCursor, XtRBoolean, sizeof (Boolean),
offset (bar_cursor), XtRImmediate, (XtPointer)0},
{XtNvisualBell, XtCVisualBell, XtRBoolean, sizeof (Boolean),
{(char *) XtNvisualBell, (char *) XtCVisualBell, XtRBoolean, sizeof (Boolean),
offset (visual_bell), XtRImmediate, (XtPointer)0},
{XtNbellVolume, XtCBellVolume, XtRInt, sizeof (int),
{(char *) XtNbellVolume, (char *) XtCBellVolume, XtRInt, sizeof (int),
offset (bell_volume), XtRImmediate, (XtPointer)0},
};
@ -106,7 +109,7 @@ emacsFrameTranslations [] = "\
static EmacsFrameClassRec emacsFrameClassRec = {
{ /* core fields */
/* superclass */ &widgetClassRec,
/* class_name */ "EmacsFrame",
/* class_name */ (char *) "EmacsFrame",
/* widget_size */ sizeof (EmacsFrameRec),
/* class_initialize */ 0,
/* class_part_initialize */ 0,

View file

@ -2640,10 +2640,10 @@ x_window (struct frame *f, long window_prompting)
ac = 0;
XtSetArg (al[ac], XtNmappedWhenManaged, 0); ac++;
XtSetArg (al[ac], XtNshowGrip, 0); ac++;
XtSetArg (al[ac], XtNallowResize, 1); ac++;
XtSetArg (al[ac], XtNresizeToPreferred, 1); ac++;
XtSetArg (al[ac], XtNemacsFrame, f); ac++;
XtSetArg (al[ac], (char *) XtNshowGrip, 0); ac++;
XtSetArg (al[ac], (char *) XtNallowResize, 1); ac++;
XtSetArg (al[ac], (char *) XtNresizeToPreferred, 1); ac++;
XtSetArg (al[ac], (char *) XtNemacsFrame, f); ac++;
XtSetArg (al[ac], XtNvisual, FRAME_X_VISUAL (f)); ac++;
XtSetArg (al[ac], XtNdepth, FRAME_DISPLAY_INFO (f)->n_planes); ac++;
XtSetArg (al[ac], XtNcolormap, FRAME_X_COLORMAP (f)); ac++;

View file

@ -1366,7 +1366,7 @@ create_and_show_popup_menu (struct frame *f, widget_value *first_wv,
event->button = i;
/* Don't allow any geometry request from the user. */
XtSetArg (av[ac], XtNgeometry, 0); ac++;
XtSetArg (av[ac], (char *) XtNgeometry, 0); ac++;
XtSetValues (menu, av, ac);
/* Display the menu. */

View file

@ -11671,20 +11671,21 @@ x_check_font (struct frame *f, struct font *font)
#ifdef USE_X_TOOLKIT
static XrmOptionDescRec emacs_options[] = {
{"-geometry", ".geometry", XrmoptionSepArg, NULL},
{"-iconic", ".iconic", XrmoptionNoArg, (XtPointer) "yes"},
{(char *) "-geometry", (char *) ".geometry", XrmoptionSepArg, NULL},
{(char *) "-iconic", (char *) ".iconic", XrmoptionNoArg, (XtPointer) "yes"},
{"-internal-border-width", "*EmacsScreen.internalBorderWidth",
XrmoptionSepArg, NULL},
{"-ib", "*EmacsScreen.internalBorderWidth", XrmoptionSepArg, NULL},
{"-T", "*EmacsShell.title", XrmoptionSepArg, (XtPointer) NULL},
{"-wn", "*EmacsShell.title", XrmoptionSepArg, (XtPointer) NULL},
{"-title", "*EmacsShell.title", XrmoptionSepArg, (XtPointer) NULL},
{"-iconname", "*EmacsShell.iconName", XrmoptionSepArg, (XtPointer) NULL},
{"-in", "*EmacsShell.iconName", XrmoptionSepArg, (XtPointer) NULL},
{"-mc", "*pointerColor", XrmoptionSepArg, (XtPointer) NULL},
{"-cr", "*cursorColor", XrmoptionSepArg, (XtPointer) NULL}
{(char *) "-internal-border-width",
(char *) "*EmacsScreen.internalBorderWidth", XrmoptionSepArg, NULL},
{(char *) "-ib", (char *) "*EmacsScreen.internalBorderWidth",
XrmoptionSepArg, NULL},
{(char *) "-T", (char *) "*EmacsShell.title", XrmoptionSepArg, NULL},
{(char *) "-wn", (char *) "*EmacsShell.title", XrmoptionSepArg, NULL},
{(char *) "-title", (char *) "*EmacsShell.title", XrmoptionSepArg, NULL},
{(char *) "-iconname", (char *) "*EmacsShell.iconName",
XrmoptionSepArg, NULL},
{(char *) "-in", (char *) "*EmacsShell.iconName", XrmoptionSepArg, NULL},
{(char *) "-mc", (char *) "*pointerColor", XrmoptionSepArg, NULL},
{(char *) "-cr", (char *) "*cursorColor", XrmoptionSepArg, NULL}
};
/* Whether atimer for Xt timeouts is activated or not. */
@ -12002,11 +12003,11 @@ x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name)
int argc = 0;
char *argv[3];
argv[0] = "";
argv[0] = (char *) "";
argc = 1;
if (xrm_option)
{
argv[argc++] = "-xrm";
argv[argc++] = (char *) "-xrm";
argv[argc++] = xrm_option;
}
turn_on_atimers (false);
@ -12384,7 +12385,7 @@ x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name)
dpy = dpyinfo->display;
d.addr = (XPointer)&dpy;
d.size = sizeof (Display *);
fr.addr = XtDefaultFont;
fr.addr = (char *) XtDefaultFont;
fr.size = sizeof (XtDefaultFont);
to.size = sizeof (Font *);
to.addr = (XPointer)&font;