summaryrefslogtreecommitdiff
path: root/oldXMenu
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2011-04-16 01:25:42 -0700
committerPaul Eggert <eggert@cs.ucla.edu>2011-04-16 01:25:42 -0700
commit55660072db3bb05d1daba0eb67865913b82d313a (patch)
treebbeda328257b0960f227c5509224077c7cf9c158 /oldXMenu
parentaefd87e148d11777492fc068f3eddf2945cfbfc5 (diff)
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.
Diffstat (limited to 'oldXMenu')
-rw-r--r--oldXMenu/Activate.c2
-rw-r--r--oldXMenu/AddPane.c23
-rw-r--r--oldXMenu/AddSel.c35
-rw-r--r--oldXMenu/ChangeLog38
-rw-r--r--oldXMenu/Create.c45
-rw-r--r--oldXMenu/Destroy.c4
-rw-r--r--oldXMenu/Error.c3
-rw-r--r--oldXMenu/EvHand.c2
-rw-r--r--oldXMenu/FindPane.c2
-rw-r--r--oldXMenu/FindSel.c2
-rw-r--r--oldXMenu/InsPane.c19
-rw-r--r--oldXMenu/InsSel.c31
-rw-r--r--oldXMenu/Internal.c97
-rw-r--r--oldXMenu/SetAEQ.c2
-rw-r--r--oldXMenu/SetFrz.c2
-rw-r--r--oldXMenu/X10.h3
-rw-r--r--oldXMenu/XDelAssoc.c11
-rw-r--r--oldXMenu/XDestAssoc.c6
-rw-r--r--oldXMenu/XMakeAssoc.c13
-rw-r--r--oldXMenu/XMenu.h50
-rw-r--r--oldXMenu/XMenuInt.h30
-rw-r--r--oldXMenu/insque.c10
22 files changed, 213 insertions, 217 deletions
diff --git a/oldXMenu/Activate.c b/oldXMenu/Activate.c
index 42eb33d208..fef8a3b6b2 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 67900a6bc7..36b57fe8da 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 9183aba7e8..9bbcf71cd3 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 f0e650ab4b..9dd6cc954d 100644
--- a/oldXMenu/ChangeLog
+++ b/oldXMenu/ChangeLog
@@ -1,3 +1,41 @@
+2011-04-16 Paul Eggert <eggert@cs.ucla.edu>
+
+ 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 8354208773..25f1f1c338 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 6a379609ad..7f0f614631 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 99f5eb6500..01738458b6 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 5ee6877374..bd15359d91 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 022e761903..8101d009a2 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 72ee142dc8..fbf235c463 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 c1993f5bfd..bdbadbf122 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 be0e43e0cb..5db285f640 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 23b54493e2..102de9d7a5 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 f4d51d24be..ee2d64b880 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 b16c659ed5..c8998eeb66 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 6b0626f212..c30632b9d6 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 018c71c3a3..ec1d09d46e 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 135b0c2cda..94c0454756 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 3626eb01f5..143b264111 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 b94c6c3ced..bf1e77b5ff 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 c937346021..721652c953 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 b324ade1d5..90a8eec4e7 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;
}
-