From 91f1119528b57f94d178f0cfb12efafd0c90bbc9 Mon Sep 17 00:00:00 2001 From: "Thomas E. Dickey" Date: Wed, 8 May 2019 21:15:08 -0400 Subject: fixes cppcheck "style" warnings (mostly variable-scope) Signed-off-by: Thomas E. Dickey --- src/Callback.c | 10 +++++----- src/Composite.c | 3 ++- src/Convert.c | 15 +++++++-------- src/Converters.c | 9 ++++----- src/Core.c | 3 +-- src/Create.c | 11 +++++------ src/Destroy.c | 7 +++---- src/Display.c | 5 +++-- src/Event.c | 23 +++++++++++------------ src/GCManager.c | 4 ++-- src/Geometry.c | 6 ++++-- src/Initialize.c | 20 +++++++++++--------- src/Intrinsic.c | 20 ++++++++++---------- src/Keyboard.c | 8 +++++--- src/Manage.c | 3 +-- src/NextEvent.c | 14 +++++++------- src/Object.c | 13 ++++++------- src/PassivGrab.c | 5 +++-- src/ResConfig.c | 9 +++++---- src/Resources.c | 14 ++++++++------ src/Selection.c | 52 ++++++++++++++++++++++++++++------------------------ src/SetSens.c | 12 +++++++----- src/SetValues.c | 5 +++-- src/Shell.c | 10 ++++++---- src/TMaction.c | 14 ++++++++------ src/TMgrab.c | 7 +++---- src/TMkey.c | 15 ++++++++------- src/TMparse.c | 22 ++++++++++++++-------- src/TMprint.c | 13 ++++++++----- src/TMstate.c | 38 +++++++++++++++----------------------- src/VarCreate.c | 10 ++++++++-- src/Varargs.c | 8 ++++---- 32 files changed, 215 insertions(+), 193 deletions(-) diff --git a/src/Callback.c b/src/Callback.c index a04a8bc..ad2c534 100644 --- a/src/Callback.c +++ b/src/Callback.c @@ -163,7 +163,6 @@ void XtAddCallback( ) { InternalCallbackList *callbacks; - Widget hookobj; XtAppContext app = XtWidgetToApplicationContext(widget); LOCK_APP(app); @@ -178,7 +177,7 @@ void XtAddCallback( } _XtAddCallback(callbacks, callback, closure); if (!_XtIsHookObject(widget)) { - hookobj = XtHooksOfDisplay(XtDisplayOfObject(widget)); + Widget hookobj = XtHooksOfDisplay(XtDisplayOfObject(widget)); if (XtHasCallbacks(hookobj, XtNchangeHook) == XtCallbackHasSome) { XtChangeHookDataRec call_data; @@ -499,9 +498,9 @@ InternalCallbackList _XtCompileCallbackList( XtCallbackList _XtGetCallbackList( InternalCallbackList *callbacks) { - register int i; - register InternalCallbackList icl; - register XtCallbackList cl, ocl; + int i; + InternalCallbackList icl; + XtCallbackList cl; icl = *callbacks; if (!icl) { @@ -512,6 +511,7 @@ XtCallbackList _XtGetCallbackList( return ToList(icl); i = icl->count; if (icl->call_state) { + XtCallbackList ocl; icl->call_state |= _XtCBFreeAfterCalling; ocl = ToList(icl); icl = (InternalCallbackList) __XtMalloc((Cardinal)(sizeof(InternalCallbackRec) + diff --git a/src/Composite.c b/src/Composite.c index a9d13a5..5188514 100644 --- a/src/Composite.c +++ b/src/Composite.c @@ -139,7 +139,7 @@ static void InheritAllowsChangeManagedSet( WidgetClass widget_class) { CompositeWidgetClass cc = (CompositeWidgetClass) widget_class; - CompositeClassExtension ext, super_ext, new_ext; + CompositeClassExtension ext, super_ext; ext = (CompositeClassExtension) XtGetClassExtension(widget_class, @@ -158,6 +158,7 @@ static void InheritAllowsChangeManagedSet( if (super_ext && super_ext->version == XtCompositeExtensionVersion && super_ext->record_size == sizeof(CompositeClassExtensionRec) && super_ext->allows_change_managed_set) { + CompositeClassExtension new_ext; new_ext = (CompositeClassExtension) __XtCalloc(1, sizeof(CompositeClassExtensionRec)); diff --git a/src/Convert.c b/src/Convert.c index ebfc984..bd7ec2a 100644 --- a/src/Convert.c +++ b/src/Convert.c @@ -362,7 +362,6 @@ CacheEnter( { register CachePtr *pHashEntry; register CachePtr p; - register Cardinal i; LOCK_PROCESS; pHashEntry = &cacheHashTable[hash & CACHEHASHMASK]; @@ -407,6 +406,7 @@ CacheEnter( p->num_args = (unsigned short) num_args; if (num_args) { XrmValue *pargs = CARGS(p); + register Cardinal i; for (i = 0; i < num_args; i++) { pargs[i].size = args[i].size; pargs[i].addr = (XPointer)_XtHeapAlloc(heap, args[i].size); @@ -481,12 +481,11 @@ void _XtCacheFlushTag( XtPointer tag) { int i; - register CachePtr *prev; register CachePtr rec; LOCK_PROCESS; for (i = CACHEHASHSIZE; --i >= 0;) { - prev = &cacheHashTable[i]; + register CachePtr *prev = &cacheHashTable[i]; while ((rec = *prev)) { if (rec->tag == tag) FreeCacheRec(app, rec, prev); @@ -532,12 +531,12 @@ static Boolean ResourceQuarkToOffset( XrmName name, Cardinal *offset) { - register WidgetClass wc; - register Cardinal i; - register XrmResourceList res, *resources; + WidgetClass wc; + Cardinal i; + XrmResourceList res; for (wc = widget_class; wc; wc = wc->core_class.superclass) { - resources = (XrmResourceList*) wc->core_class.resources; + XrmResourceList *resources = (XrmResourceList*) wc->core_class.resources; for (i = 0; i < wc->core_class.num_resources; i++, resources++) { res = *resources; if (res->xrm_name == name) { @@ -725,7 +724,6 @@ CallConverter( { CachePtr p; int hash; - Cardinal i; Boolean retval; if (!cP || ((cP->cache_type == XtCacheNone) && !cP->destructor)) { @@ -750,6 +748,7 @@ CallConverter( XtMemcmp(&p->from.addr, from->addr, from->size) : memcmp((const void *)p->from.addr, (const void *)from->addr, from->size)) && (p->num_args == num_args)) { + Cardinal i; if ((i = num_args)) { XrmValue *pargs = CARGS(p); /* Are all args the same data ? */ diff --git a/src/Converters.c b/src/Converters.c index e812930..32e3641 100644 --- a/src/Converters.c +++ b/src/Converters.c @@ -467,7 +467,6 @@ Boolean XtCvtStringToPixel( XtPerDisplay pd = _XtGetPerDisplay(dpy); Colormap colormap; Status status; - String params[1]; Cardinal num_params=1; if (*num_args != 2) { @@ -497,6 +496,7 @@ Boolean XtCvtStringToPixel( if (status == 0) { _Xconst _XtString msg; _Xconst _XtString type; + String params[1]; params[0] = str; /* Server returns a specific error code but Xlib discards it. Ugh */ @@ -1629,7 +1629,6 @@ Boolean XtCvtStringToCommandArgArray( String *strarray, *ptr; char *src; char *dst, *dst_str; - char *start; int tokens, len; if (*num_args != 0) @@ -1643,6 +1642,8 @@ Boolean XtCvtStringToCommandArgArray( tokens = 0; while (*src != '\0') { + char *start; + /* skip whitespace */ while (IsWhitespace(*src) || IsNewline(*src)) src++; @@ -1704,10 +1705,8 @@ static void ArgArrayDestructor( XrmValuePtr args, Cardinal *num_args) { - _XtString *strarray; - if (closure) { - strarray = (_XtString*) closure; + _XtString *strarray = (_XtString*) closure; XtFree(*strarray); XtFree((char *) strarray); } diff --git a/src/Core.c b/src/Core.c index 748ceaa..0f89ef3 100644 --- a/src/Core.c +++ b/src/Core.c @@ -323,11 +323,10 @@ static Boolean CoreSetValues( Boolean redisplay; Mask window_mask; XSetWindowAttributes attributes; - XtTranslations save; redisplay = FALSE; if (old->core.tm.translations != new->core.tm.translations) { - save = new->core.tm.translations; + XtTranslations save = new->core.tm.translations; new->core.tm.translations = old->core.tm.translations; _XtMergeTranslations(new, save, XtTableReplace); } diff --git a/src/Create.c b/src/Create.c index f818c0b..527be3d 100644 --- a/src/Create.c +++ b/src/Create.c @@ -267,7 +267,7 @@ xtWidgetAlloc( Cardinal num_typed_args) { Widget widget; - Cardinal wsize, csize = 0; + Cardinal csize = 0; ObjectClassExtension ext; LOCK_PROCESS; @@ -290,7 +290,7 @@ xtWidgetAlloc( (*allocate)(widget_class, &csize, &extra, args, &nargs, typed_args, &ntyped, &widget, NULL); } else { - wsize = widget_class->core_class.widget_size; + Cardinal wsize = widget_class->core_class.widget_size; UNLOCK_PROCESS; if (csize) { if (sizeof(struct {char a; double b;}) != @@ -318,7 +318,6 @@ CompileCallbacks( Widget widget) { CallbackTable offsets; - InternalCallbackList* cl; int i; LOCK_PROCESS; @@ -326,7 +325,7 @@ CompileCallbacks( widget->core.widget_class->core_class.callback_private; for (i = (int)(long) *(offsets++); --i >= 0; offsets++) { - cl = (InternalCallbackList *) + InternalCallbackList* cl = (InternalCallbackList *) ((char *) widget - (*offsets)->xrm_offset - 1); if (*cl) *cl = _XtCompileCallbackList((XtCallbackList) *cl); @@ -351,13 +350,11 @@ xtCreate( { /* need to use strictest alignment rules possible in next two decls. */ double widget_cache[100]; - double constraint_cache[20]; Widget req_widget; XtPointer req_constraints = NULL; Cardinal wsize, csize; Widget widget; XtCacheRef *cache_refs; - Cardinal i; XtCreateHookDataRec call_data; widget = xtWidgetAlloc(widget_class, parent_constraint_class, parent, @@ -392,6 +389,7 @@ xtCreate( /* Convert typed arg list to arg list */ if (typed_args != NULL && num_typed_args > 0) { + Cardinal i; args = (ArgList)ALLOCATE_LOCAL(sizeof(Arg) * num_typed_args); if (args == NULL) _XtAllocError(NULL); for (i = 0; i < num_typed_args; i++) { @@ -414,6 +412,7 @@ xtCreate( (void) memmove ((char *) req_widget, (char *) widget, (size_t) wsize); CallInitialize (XtClass(widget), req_widget, widget, args, num_args); if (parent_constraint_class != NULL) { + double constraint_cache[20]; csize = parent_constraint_class->constraint_class.constraint_size; if (csize) { req_constraints = XtStackAlloc(csize, constraint_cache); diff --git a/src/Destroy.c b/src/Destroy.c index b72f4c6..37e918a 100644 --- a/src/Destroy.c +++ b/src/Destroy.c @@ -81,11 +81,10 @@ struct _DestroyRec { static void Recursive(Widget widget, XtWidgetProc proc) { register Cardinal i; - CompositePart *cwp; /* Recurse down normal children */ if (XtIsComposite(widget)) { - cwp = &(((CompositeWidget) widget)->composite); + CompositePart *cwp = &(((CompositeWidget) widget)->composite); for (i = 0; i < cwp->num_children; i++) { Recursive(cwp->children[i], proc); } @@ -329,7 +328,7 @@ void _XtDoPhase2Destroy(XtAppContext app, int dispatch_level) void XtDestroyWidget (Widget widget) { XtAppContext app; - DestroyRec *dr, *dr2; + DestroyRec *dr; app = XtWidgetToApplicationContext(widget); LOCK_APP(app); @@ -365,7 +364,7 @@ void XtDestroyWidget (Widget widget) dr = app->destroy_list + (--i); if (dr->dispatch_level < app->dispatch_level && IsDescendant(dr->widget, widget)) { - dr2 = app->destroy_list + (app->destroy_count-1); + DestroyRec *dr2 = app->destroy_list + (app->destroy_count-1); dr2->dispatch_level = dr->dispatch_level; break; } diff --git a/src/Display.c b/src/Display.c index 2fe8167..459bce7 100644 --- a/src/Display.c +++ b/src/Display.c @@ -253,7 +253,6 @@ Display *XtOpenDisplay( { Display *d; XrmDatabase db = NULL; - XtPerDisplay pd; String language = NULL; LOCK_APP(app); @@ -282,6 +281,7 @@ Display *XtOpenDisplay( } if (d) { + XtPerDisplay pd; pd = InitPerDisplay(d, app, applName, className); pd->language = language; _XtDisplayInitialize(d, pd, applName, urlist, num_urs, argc, argv); @@ -593,7 +593,6 @@ static void CloseDisplay(Display *dpy) register XtPerDisplay xtpd; register PerDisplayTablePtr pd, opd = NULL; XrmDatabase db; - int i; XtDestroyWidget(XtHooksOfDisplay(dpy)); @@ -616,6 +615,8 @@ static void CloseDisplay(Display *dpy) xtpd = &(pd->perDpy); if (xtpd != NULL) { + int i; + if (xtpd->destroy_callbacks != NULL) { XtCallCallbackList((Widget) NULL, (XtCallbackList)xtpd->destroy_callbacks, diff --git a/src/Event.c b/src/Event.c index efcf37e..a0e452c 100644 --- a/src/Event.c +++ b/src/Event.c @@ -183,7 +183,7 @@ RemoveEventHandler( Boolean raw) { XtEventRec *p, **pp; - EventMask eventMask, oldMask = XtBuildEventMask(widget); + EventMask oldMask = XtBuildEventMask(widget); if (raw) raw = 1; pp = &widget->core.event_table; @@ -196,7 +196,7 @@ RemoveEventHandler( /* un-register it */ if (!has_type_specifier) { - eventMask = *(EventMask*)select_data; + EventMask eventMask = *(EventMask*)select_data; eventMask &= ~NonMaskableMask; if (other) eventMask |= NonMaskableMask; @@ -525,7 +525,7 @@ void XtRegisterDrawable( Widget widget) { WWTable tab; - int idx, rehash; + int idx; Widget entry; Window window = (Window) drawable; WIDGET_TO_APPCON(widget); @@ -549,7 +549,7 @@ void XtRegisterDrawable( idx = (int) WWHASH(tab, window); if ((entry = tab->entries[idx]) && entry != &WWfake) { - rehash = (int) WWREHASHVAL(tab, window); + int rehash = (int) WWREHASHVAL(tab, window); do { idx = (int) WWREHASH(tab, idx, rehash); } while ((entry = tab->entries[idx]) && entry != &WWfake); @@ -568,7 +568,7 @@ void XtUnregisterDrawable( Drawable drawable) { WWTable tab; - int idx, rehash; + int idx; Widget entry; Window window = (Window) drawable; Widget widget = XtWindowToWidget (display, window); @@ -596,7 +596,7 @@ void XtUnregisterDrawable( idx = (int) WWHASH(tab, window); if ((entry = tab->entries[idx])) { if (entry != widget) { - rehash = (int) WWREHASHVAL(tab, window); + int rehash = (int) WWREHASHVAL(tab, window); do { idx = (int) WWREHASH(tab, idx, rehash); if (!(entry = tab->entries[idx])) { @@ -651,9 +651,9 @@ Widget XtWindowToWidget( register Display *display, register Window window) { - register WWTable tab; - register int idx, rehash; - register Widget entry; + WWTable tab; + int idx; + Widget entry; WWPair pair; DPY_TO_APPCON(display); @@ -664,7 +664,7 @@ Widget XtWindowToWidget( tab = WWTABLE(display); idx = (int) WWHASH(tab, window); if ((entry = tab->entries[idx]) && XtWindow(entry) != window) { - rehash = (int) WWREHASHVAL(tab, window); + int rehash = (int) WWREHASHVAL(tab, window); do { idx = (int) WWREHASH(tab, idx, rehash); } while ((entry = tab->entries[idx]) && XtWindow(entry) != window); @@ -1667,7 +1667,6 @@ void XtRegisterExtensionSelector( XtExtensionSelectProc proc, XtPointer client_data) { - ExtSelectRec *e; XtPerDisplay pd; int i; DPY_TO_APPCON(dpy); @@ -1682,7 +1681,7 @@ void XtRegisterExtensionSelector( pd = _XtGetPerDisplay(dpy); for (i = 0; i < pd->ext_select_count; i++) { - e = &pd->ext_select_list[i]; + ExtSelectRec *e = &pd->ext_select_list[i]; if (e->min == min_event_type && e->max == max_event_type) { e->proc = proc; e->client_data = client_data; diff --git a/src/GCManager.c b/src/GCManager.c index 5769d11..52e32ae 100644 --- a/src/GCManager.c +++ b/src/GCManager.c @@ -162,8 +162,7 @@ void _XtGClistFree( Display *dpy, register XtPerDisplay pd) { - register GCptr GClist, next; - register int i; + GCptr GClist, next; GClist = pd->GClist; while (GClist) { @@ -172,6 +171,7 @@ void _XtGClistFree( GClist = next; } if (pd->pixmap_tab) { + int i; for (i = ScreenCount(dpy); --i >= 0; ) { if (pd->pixmap_tab[i]) XtFree((char *)pd->pixmap_tab[i]); diff --git a/src/Geometry.c b/src/Geometry.c index cb37806..b8d3606 100644 --- a/src/Geometry.c +++ b/src/Geometry.c @@ -562,11 +562,12 @@ void XtResizeWindow( Widget w) { XtConfigureHookDataRec req; - Widget hookobj; WIDGET_TO_APPCON(w); LOCK_APP(app); if (XtIsRealized(w)) { + Widget hookobj; + req.changes.width = w->core.width; req.changes.height = w->core.height; req.changes.border_width = w->core.border_width; @@ -603,7 +604,6 @@ void XtConfigureWidget( _XtDimension borderWidth) { XtConfigureHookDataRec req; - Widget hookobj; XWindowChanges old; WIDGET_TO_APPCON(w); @@ -649,6 +649,8 @@ void XtConfigureWidget( } if (req.changeMask != 0) { + Widget hookobj; + if (XtIsRealized(w)) { if (XtIsWidget(w)) { CALLGEOTAT(_XtGeoTrace(w, diff --git a/src/Initialize.c b/src/Initialize.c index 363920e..2adf1fd 100644 --- a/src/Initialize.c +++ b/src/Initialize.c @@ -360,7 +360,6 @@ static String GetRootDirName( #ifdef X_NEEDS_PWPARAMS _Xgetpwparams pwparams; #endif - struct passwd *pw; static char *ptr; if (len <= 0 || dest == NULL) @@ -370,6 +369,7 @@ static String GetRootDirName( (void) strncpy (dest, ptr, (size_t)(len-1)); dest[len-1] = '\0'; } else { + struct passwd *pw; if ((ptr = getenv("USER"))) pw = _XGetpwnam(ptr,pwparams); else @@ -425,16 +425,16 @@ static void CombineUserDefaults( Display *dpy, XrmDatabase *pdb) { -#ifdef __MINGW32__ - const char *slashDotXdefaults = "/Xdefaults"; -#else - const char *slashDotXdefaults = "/.Xdefaults"; -#endif char *dpy_defaults = XResourceManagerString(dpy); if (dpy_defaults) { XrmCombineDatabase(XrmGetStringDatabase(dpy_defaults), pdb, False); } else { +#ifdef __MINGW32__ + const char *slashDotXdefaults = "/Xdefaults"; +#else + const char *slashDotXdefaults = "/.Xdefaults"; +#endif char filename[PATH_MAX]; (void) GetRootDirName(filename, PATH_MAX - (int)strlen (slashDotXdefaults) - 1); @@ -648,12 +648,11 @@ static void _MergeOptionTables( Cardinal *num_dst) { XrmOptionDescRec *table, *endP; - register XrmOptionDescRec *opt1, *whereP, *dstP; - register const XrmOptionDescRec *opt2; + XrmOptionDescRec *opt1, *dstP; + const XrmOptionDescRec *opt2; int i1; Cardinal i2; int dst_len, order; - Boolean found; enum {Check, NotSorted, IsSorted} sort_order = Check; *dst = table = (XrmOptionDescRec*) @@ -666,6 +665,9 @@ static void _MergeOptionTables( } endP = &table[dst_len = (int)num_src1]; for (opt2 = src2, i2= 0; i2 < num_src2; opt2++, i2++) { + XrmOptionDescRec *whereP; + Boolean found; + found = False; whereP = endP-1; /* assume new option goes at the end */ for (opt1 = table, i1 = 0; i1 < dst_len; opt1++, i1++) { diff --git a/src/Intrinsic.c b/src/Intrinsic.c index 920ff07..49bec47 100644 --- a/src/Intrinsic.c +++ b/src/Intrinsic.c @@ -250,11 +250,10 @@ static void MapChildren( { Cardinal i; WidgetList children; - register Widget child; children = cwp->children; for (i = 0; i < cwp->num_children; i++) { - child = children[i]; + Widget child = children[i]; if (XtIsWidget (child)){ if (child->core.managed && child->core.mapped_when_managed) { XtMapWidget (children[i]); @@ -269,11 +268,10 @@ static Boolean ShouldMapAllChildren( { Cardinal i; WidgetList children; - register Widget child; children = cwp->children; for (i = 0; i < cwp->num_children; i++) { - child = children[i]; + Widget child = children[i]; if (XtIsWidget(child)) { if (XtIsRealized(child) && (! (child->core.managed && child->core.mapped_when_managed))){ @@ -403,8 +401,6 @@ static void UnrealizeWidget( Widget widget) { CompositeWidget cw; - Cardinal i; - WidgetList children; if (!XtIsWidget(widget) || !XtIsRealized(widget)) return; @@ -413,6 +409,9 @@ static void UnrealizeWidget( /* Recurse on children */ if (XtIsComposite (widget)) { + Cardinal i; + WidgetList children; + cw = (CompositeWidget) widget; children = cw->composite.children; /* Unrealize all children */ @@ -592,7 +591,6 @@ static Widget NameListToWidget( XrmBindingList bindings, int in_depth, int *out_depth, int *found_depth) { - Widget w1, w2; int d1, d2; if (in_depth >= *found_depth) { @@ -615,6 +613,8 @@ static Widget NameListToWidget( in_depth, out_depth, found_depth); } else { /* XrmBindLoosely */ + Widget w1, w2; + w1 = SearchChildren(root, names, bindings, MatchExactChildren, in_depth, &d1, found_depth); w2 = SearchChildren(root, names, bindings, MatchWildChildren, @@ -1578,10 +1578,10 @@ _XtGeoTab (int direction) /* +1 or -1 */ void _XtGeoTrace (Widget widget, const char *fmt, ...) { - va_list args; - int i ; - if (IsTattled(widget)) { + va_list args; + int i ; + va_start(args, fmt); for (i=0; i 0; i--) { - if ((grab = _XtCheckServerGrabsOnWidget(event, trace[i-1], KEYBOARD))) + XtServerGrabPtr grab; + if ((grab = _XtCheckServerGrabsOnWidget(event, trace[i-1], KEYBOARD))) return (grab); } return (XtServerGrabPtr)0; @@ -395,7 +395,7 @@ Widget _XtProcessKeyboardEvent( XtPerDisplayInput pdi) { XtDevice device = &pdi->keyboard; - XtServerGrabPtr newGrab, devGrab = &device->grab; + XtServerGrabPtr devGrab = &device->grab; XtServerGrabRec prevGrabRec; XtServerGrabType prevGrabType = device->grabType; Widget dspWidget = NULL; @@ -407,6 +407,8 @@ Widget _XtProcessKeyboardEvent( { case KeyPress: { + XtServerGrabPtr newGrab; + if (event->keycode != 0 && /* Xlib XIM composed input */ !IsServerGrab(device->grabType) && (newGrab = CheckServerGrabs((XEvent*)event, diff --git a/src/Manage.c b/src/Manage.c index c877842..96bacbb 100644 --- a/src/Manage.c +++ b/src/Manage.c @@ -416,7 +416,6 @@ void XtChangeManagedSet( int i; Cardinal some_unmanaged; Boolean call_out; - CompositeClassExtension ext; XtAppContext app; Widget hookobj; XtChangeHookDataRec call_data; @@ -455,7 +454,7 @@ void XtChangeManagedSet( call_out = False; if (do_change_proc) { - ext = (CompositeClassExtension) + CompositeClassExtension ext = (CompositeClassExtension) XtGetClassExtension(parent->core.widget_class, XtOffsetOf(CompositeClassRec, composite_class.extension), diff --git a/src/NextEvent.c b/src/NextEvent.c index 07d0a57..49f6f8e 100644 --- a/src/NextEvent.c +++ b/src/NextEvent.c @@ -369,7 +369,6 @@ static void FindInputs ( int* dpy_no, int* found_input) { - XtInputMask condition; InputEvent *ep; int ii; #ifndef USE_POLL /* { check ready file descriptors block */ @@ -387,7 +386,8 @@ static void FindInputs ( #endif for (ii = 0; ii < wf->nfds && nfds > 0; ii++) { - condition = 0; + XtInputMask condition = 0; + if (FD_ISSET (ii, &wf->rmask) #ifdef XTHREADS && FD_ISSET (ii, &rmask) @@ -473,7 +473,7 @@ ENDILOOP: ; if (!ignoreInputs) { fdlp = &wf->fdlist[wf->num_dpys]; for (ii = wf->num_dpys; ii < wf->fdlistlen; ii++, fdlp++) { - condition = 0; + XtInputMask condition = 0; if (fdlp->revents) { if (fdlp->revents & (XPOLL_READ|POLLHUP|POLLERR) #ifdef XTHREADS @@ -1376,10 +1376,10 @@ void XtAppProcessEvent( if (CallWorkProc(app)) continue; d = _XtWaitForSomething (app, - (mask & XtIMXEvent ? FALSE : TRUE), - (mask & XtIMTimer ? FALSE : TRUE), - (mask & XtIMAlternateInput ? FALSE : TRUE), - (mask & XtIMSignal ? FALSE : TRUE), + ((mask & XtIMXEvent) ? FALSE : TRUE), + ((mask & XtIMTimer) ? FALSE : TRUE), + ((mask & XtIMAlternateInput) ? FALSE : TRUE), + ((mask & XtIMSignal) ? FALSE : TRUE), TRUE, #ifdef XTHREADS TRUE, diff --git a/src/Object.c b/src/Object.c index d5ed095..ee1ea6d 100644 --- a/src/Object.c +++ b/src/Object.c @@ -258,15 +258,15 @@ static Boolean ObjectSetValues( ArgList args, Cardinal * num_args) { - register CallbackTable offsets; - register int i; - register InternalCallbackList *ol, *nl; + CallbackTable offsets; + int i; LOCK_PROCESS; /* Compile any callback lists into internal form */ offsets = (CallbackTable) XtClass(widget)->core_class.callback_private; for (i= (int)(long) *(offsets++); --i >= 0; offsets++) { + InternalCallbackList *ol, *nl; ol = (InternalCallbackList *) ((char *) old - (*offsets)->xrm_offset - 1); nl = (InternalCallbackList *) @@ -286,9 +286,8 @@ static Boolean ObjectSetValues( static void ObjectDestroy ( register Widget widget) { - register CallbackTable offsets; - register int i; - register InternalCallbackList cl; + CallbackTable offsets; + int i; /* Remove all callbacks associated with widget */ LOCK_PROCESS; @@ -296,7 +295,7 @@ static void ObjectDestroy ( widget->core.widget_class->core_class.callback_private; for (i = (int)(long) *(offsets++); --i >= 0; offsets++) { - cl = *(InternalCallbackList *) + InternalCallbackList cl = *(InternalCallbackList *) ((char *) widget - (*offsets)->xrm_offset - 1); if (cl) XtFree((char *) cl); } diff --git a/src/PassivGrab.c b/src/PassivGrab.c index 313d336..bece0d9 100644 --- a/src/PassivGrab.c +++ b/src/PassivGrab.c @@ -655,8 +655,6 @@ static void MakeGrabs( XtPerDisplayInput pdi) { XtServerGrabPtr next = *passiveListPtr; - XtServerGrabPtr grab; - XtPerWidgetInput pwi; /* * make MakeGrab build a new list that has had the merge * processing done on it. Start with an empty list @@ -666,6 +664,9 @@ static void MakeGrabs( *passiveListPtr = NULL; while (next) { + XtServerGrabPtr grab; + XtPerWidgetInput pwi; + grab = next; next = grab->next; pwi = _XtGetPerWidgetInput(grab->widget, FALSE); diff --git a/src/ResConfig.c b/src/ResConfig.c index 2c4b278..03867d4 100644 --- a/src/ResConfig.c +++ b/src/ResConfig.c @@ -676,7 +676,6 @@ _search_widget_tree ( char *last_part; char *remainder = NULL; char last_token; - char *indx, *copy; char *loose, *tight; int loose_len, tight_len; @@ -729,6 +728,7 @@ _search_widget_tree ( * Prepend a '.' to the remainder string if there is no leading token. */ } else { + char *indx, *copy; if (remainder[0] != '*' && remainder[0] != '.') { XtAsprintf (©, ".%s", remainder); XtFree (remainder); @@ -894,10 +894,7 @@ _XtResourceConfigurationEH ( unsigned long nitems; unsigned long leftover; char *data = NULL; - unsigned long resource_len; char *data_ptr; - char *resource; - char *value; #ifdef DEBUG int indent = 0; #endif @@ -967,6 +964,7 @@ _XtResourceConfigurationEH ( if (data) { char *data_end = data + nitems; char *data_value; + unsigned long resource_len; resource_len = strtoul (data, &data_ptr, 10); @@ -977,6 +975,9 @@ _XtResourceConfigurationEH ( data_ptr = data_value = NULL; if (data_value > data_ptr && data_value < data_end) { + char *resource; + char *value; + *data_value++ = '\0'; resource = XtNewString (data_ptr); diff --git a/src/Resources.c b/src/Resources.c index 672f5b9..dbb2fa5 100644 --- a/src/Resources.c +++ b/src/Resources.c @@ -426,13 +426,13 @@ void _XtResourceDependencies( void _XtConstraintResDependencies( ConstraintWidgetClass wc) { - ConstraintWidgetClass sc; - if (wc == (ConstraintWidgetClass) constraintWidgetClass) { _XtDependencies(&(wc->constraint_class.resources), &(wc->constraint_class.num_resources), (XrmResourceList *)NULL, (unsigned)0, (unsigned)0); } else { + ConstraintWidgetClass sc; + sc = (ConstraintWidgetClass) wc->core_class.superclass; _XtDependencies(&(wc->constraint_class.resources), &(wc->constraint_class.num_resources), @@ -941,8 +941,7 @@ XtCacheRef *_XtGetResources( XrmQuark quark_cache[100]; XrmQuarkList quark_args; WidgetClass wc; - ConstraintWidgetClass cwc; - XtCacheRef *cache_refs, *cache_refs_core; + XtCacheRef *cache_refs; Cardinal count; wc = XtClass(w); @@ -967,6 +966,9 @@ XtCacheRef *_XtGetResources( typed_args, num_typed_args, XtIsWidget(w)); if (w->core.constraints != NULL) { + ConstraintWidgetClass cwc; + XtCacheRef *cache_refs_core; + cwc = (ConstraintWidgetClass) XtClass(w->core.parent); cache_refs_core = GetResources(w, (char*)w->core.constraints, names, classes, @@ -1071,7 +1073,7 @@ void _XtGetApplicationResources ( XrmQuark quark_cache[100]; XrmQuarkList quark_args; XrmResourceList* table; - Cardinal count, ntyped_args = num_typed_args; + Cardinal ntyped_args = num_typed_args; #ifdef XTHREADS XtAppContext app; #endif @@ -1097,7 +1099,7 @@ void _XtGetApplicationResources ( classes[1] = NULLQUARK; } else { - count = CountTreeDepth(w); + Cardinal count = CountTreeDepth(w); names = (XrmName*) XtStackAlloc(count * sizeof(XrmName), names_s); classes = (XrmClass*) XtStackAlloc(count * sizeof(XrmClass), classes_s); if (names == NULL || classes == NULL) _XtAllocError(NULL); diff --git a/src/Selection.c b/src/Selection.c index 448f208..0e1a483 100644 --- a/src/Selection.c +++ b/src/Selection.c @@ -174,18 +174,19 @@ static PropList GetPropList( Display *dpy) { PropList sarray; - Atom atoms[4]; - static char* names[] = { - "INCR", - "MULTIPLE", - "TIMESTAMP", - "_XT_SELECTION_0" }; LOCK_PROCESS; if (selectPropertyContext == 0) selectPropertyContext = XUniqueContext(); if (XFindContext(dpy, DefaultRootWindow(dpy), selectPropertyContext, (XPointer *)&sarray)) { + Atom atoms[4]; + static char* names[] = { + "INCR", + "MULTIPLE", + "TIMESTAMP", + "_XT_SELECTION_0" }; + XtPerDisplay pd = _XtGetPerDisplay(dpy); sarray = (PropList) __XtMalloc((unsigned) sizeof(PropListRec)); sarray->dpy = dpy; @@ -803,8 +804,6 @@ static void HandleSelectionEvents( Select ctx; XSelectionEvent ev; Atom target; - int count; - Boolean writeback = FALSE; ctx = (Select) closure; switch (event->type) { @@ -841,6 +840,9 @@ static void HandleSelectionEvents( int format; unsigned long bytesafter, length; unsigned char *value = NULL; + int count; + Boolean writeback = FALSE; + ev.property = event->xselectionrequest.property; StartProtectedSection(ev.display, ev.requestor); if (XGetWindowProperty(ev.display, ev.requestor, @@ -1126,8 +1128,6 @@ static void ReqTimedOut( unsigned long bytesafter; unsigned long proplength; Atom type; - XtPointer *c; - int i; if (*info->target == info->ctx->prop_list->indirect_atom) { IndirectPair *pairs = NULL; @@ -1136,6 +1136,9 @@ static void ReqTimedOut( AnyPropertyType, &type, &format, &proplength, &bytesafter, (unsigned char **) &pairs) == Success) { + XtPointer *c; + int i; + XFree(pairs); for (proplength = proplength / IndirectPairWordSize, i = 0, c = info->req_closure; @@ -1260,8 +1263,8 @@ static unsigned long IncrPropSize( int format, unsigned long length) { - unsigned long size; if (format == 32) { + unsigned long size; size = ((unsigned long*)value)[length-1]; /* %%% what order for longs? */ return size; } @@ -1383,7 +1386,6 @@ static void HandleSelectionReplies( unsigned long length; int format; Atom type; - XtPointer *c; if (event->type != SelectionNotify) return; if (!MATCH_SELECT(event, info)) return; /* not really for us */ @@ -1394,6 +1396,8 @@ static void HandleSelectionReplies( HandleSelectionReplies, (XtPointer) info ); if (event->target == ctx->prop_list->indirect_atom) { IndirectPair *pairs = NULL, *p; + XtPointer *c; + if (XGetWindowProperty(dpy, XtWindow(widget), info->property, 0L, 10000000, True, AnyPropertyType, &type, &format, &length, &bytesafter, (unsigned char **) &pairs) @@ -1546,7 +1550,6 @@ static void GetSelectionValue( Atom property) { Select ctx; - CallBackInfo info; Atom properties[1]; properties[0] = property; @@ -1566,6 +1569,7 @@ static void GetSelectionValue( ctx->req = NULL; } else { + CallBackInfo info; info = MakeInfo(ctx, &callback, &closure, 1, widget, time, &incremental, properties); info->target = (Atom *)__XtMalloc((unsigned) sizeof(Atom)); @@ -1643,9 +1647,7 @@ static void GetSelectionValues( Atom *properties) { Select ctx; - CallBackInfo info; - IndirectPair *pairs, *p; - Atom *t; + IndirectPair *pairs; if (count == 0) return; ctx = FindCtx(XtDisplay(widget), selection); @@ -1671,6 +1673,9 @@ static void GetSelectionValues( } else { XtSelectionCallbackProc *passed_callbacks; XtSelectionCallbackProc stack_cbs[32]; + CallBackInfo info; + IndirectPair *p; + Atom *t; int i = 0, j = 0; passed_callbacks = (XtSelectionCallbackProc *) @@ -1933,7 +1938,6 @@ static Boolean IsGatheringRequest( Window window = XtWindow(wid); Display *dpy = XtDisplay(wid); Boolean found = False; - int i; if (multipleContext == 0) multipleContext = XUniqueContext(); @@ -1941,7 +1945,7 @@ static Boolean IsGatheringRequest( (void) XFindContext(dpy, window, multipleContext, (XPointer*) &qi); if (qi != NULL) { - i = 0; + int i = 0; while(qi->selections[i] != None) { if (qi->selections[i] == sel) { found = True; @@ -2044,7 +2048,6 @@ void XtSendSelectionRequest( QueuedRequestInfo queueInfo; Window window = XtWindow(widget); Display *dpy = XtDisplay(widget); - int i; LOCK_PROCESS; if (multipleContext == 0) multipleContext = XUniqueContext(); @@ -2052,6 +2055,7 @@ void XtSendSelectionRequest( queueInfo = NULL; (void) XFindContext(dpy, window, multipleContext, (XPointer*) &queueInfo); if (queueInfo != NULL) { + int i; int count = 0; QueuedRequest *req = queueInfo->requests; @@ -2222,7 +2226,6 @@ static void AddParamInfo( Atom selection, Atom param_atom) { - int n; Param p; ParamInfo pinfo; @@ -2240,6 +2243,7 @@ static void AddParamInfo( (char *)pinfo); } else { + int n; for (n = (int) pinfo->count, p = pinfo->paramlist; n; n--, p++) { if (p->selection == None || p->selection == selection) break; @@ -2263,8 +2267,6 @@ static void RemoveParamInfo( Widget w, Atom selection) { - int n; - Param p; ParamInfo pinfo; Boolean retain = False; @@ -2272,6 +2274,8 @@ static void RemoveParamInfo( if (paramPropertyContext && (XFindContext(XtDisplay(w), XtWindow(w), paramPropertyContext, (XPointer *) &pinfo) == 0)) { + Param p; + int n; /* Find and invalidate the parameter data. */ for (n = (int) pinfo->count, p = pinfo->paramlist; n; n--, p++) { @@ -2296,8 +2300,6 @@ static Atom GetParamInfo( Widget w, Atom selection) { - int n; - Param p; ParamInfo pinfo; Atom atom = None; @@ -2305,6 +2307,8 @@ static Atom GetParamInfo( if (paramPropertyContext && (XFindContext(XtDisplay(w), XtWindow(w), paramPropertyContext, (XPointer *) &pinfo) == 0)) { + Param p; + int n; for (n = (int) pinfo->count, p = pinfo->paramlist; n; n--, p++) if (p->selection == selection) { diff --git a/src/SetSens.c b/src/SetSens.c index 9a2e6b6..04d3f3a 100644 --- a/src/SetSens.c +++ b/src/SetSens.c @@ -82,9 +82,7 @@ static void SetAncestorSensitive( register Widget widget, Boolean ancestor_sensitive) { - Arg args[1]; - register Cardinal i; - register WidgetList children; + Arg args[1]; if (widget->core.ancestor_sensitive == ancestor_sensitive) return; @@ -96,6 +94,9 @@ static void SetAncestorSensitive( ancestor_sensitive is already FALSE */ if (widget->core.sensitive && XtIsComposite(widget)) { + Cardinal i; + WidgetList children; + children = ((CompositeWidget) widget)->composite.children; for (i=0; i < ((CompositeWidget)widget)->composite.num_children; i++) { SetAncestorSensitive (children[i], ancestor_sensitive); @@ -109,8 +110,6 @@ void XtSetSensitive( _XtBoolean sensitive) { Arg args[1]; - register Cardinal i; - register WidgetList children; WIDGET_TO_APPCON(widget); LOCK_APP(app); @@ -127,6 +126,9 @@ void XtSetSensitive( ancestor_sensitive is already FALSE */ if (widget->core.ancestor_sensitive && XtIsComposite (widget)) { + Cardinal i; + WidgetList children; + children = ((CompositeWidget) widget)->composite.children; for (i = 0; i < ((CompositeWidget)widget)->composite.num_children; i++){ SetAncestorSensitive (children[i], (Boolean) sensitive); diff --git a/src/SetValues.c b/src/SetValues.c index 8108576..5fd0e6b 100644 --- a/src/SetValues.c +++ b/src/SetValues.c @@ -151,9 +151,10 @@ CallConstraintSetValues ( { Boolean redisplay = FALSE; XtSetValuesFunc set_values; - ConstraintWidgetClass superclass; if ((WidgetClass)class != constraintWidgetClass) { + ConstraintWidgetClass superclass; + if (class == NULL) XtAppErrorMsg(XtWidgetToApplicationContext(current), "invalidClass","constraintSetValue",XtCXtToolkitError, @@ -204,7 +205,6 @@ void XtSetValues( WidgetClass wc; ConstraintWidgetClass cwc = NULL; Boolean hasConstraints; - XtAlmostProc set_values_almost; XtAppContext app = XtWidgetToApplicationContext(w); Widget hookobj = XtHooksOfDisplay(XtDisplayOfObject(w)); @@ -350,6 +350,7 @@ void XtSetValues( CALLGEOTAT(_XtGeoTab(1)); do { XtGeometryHookDataRec call_data; + XtAlmostProc set_values_almost; if (XtHasCallbacks(hookobj, XtNgeometryHook) == XtCallbackHasSome) { call_data.type = XtHpreGeometry; diff --git a/src/Shell.c b/src/Shell.c index 62cd8ce..f78474f 100644 --- a/src/Shell.c +++ b/src/Shell.c @@ -2981,7 +2981,6 @@ static void SetSessionProperties( XtPointer *addr; unsigned long mask; SmProp *props[XT_NUM_SM_PROPS]; - char *pnames[XT_NUM_SM_PROPS]; if (w->session.connection == NULL) return; @@ -3028,6 +3027,8 @@ static void SetSessionProperties( } if (unset_mask) { + char *pnames[XT_NUM_SM_PROPS]; + mask = 1L; num_props = 0; for (n = XtNumber(propertyTable); n; n--, p++, mask <<= 1) @@ -3069,13 +3070,13 @@ static void CleanUpSave( static void CallSaveCallbacks( SessionShellWidget w) { - XtCheckpointToken token; - if (XtHasCallbacks((Widget) w, XtNsaveCallback) != XtCallbackHasSome) { /* if the application makes no attempt to save state, report failure */ SmcSaveYourselfDone(w->session.connection, False); CleanUpSave(w); } else { + XtCheckpointToken token; + w->session.checkpoint_state = XtSaveActive; token = GetToken((Widget) w, XtSessionCheckpoint); _XtCallConditionalCallbackList((Widget)w, w->session.save_callbacks, @@ -3125,7 +3126,6 @@ static void XtInteractPermission( { Widget w = (Widget) data; SessionShellWidget sw = (SessionShellWidget) data; - XtCheckpointToken token; XtCallbackProc callback; XtPointer client_data; @@ -3133,6 +3133,8 @@ static void XtInteractPermission( _XtPeekCallback(w, sw->session.interact_callbacks, &callback, &client_data); if (callback) { + XtCheckpointToken token; + sw->session.checkpoint_state = XtInteractActive; token = GetToken(w, XtSessionInteract); XtRemoveCallback(w, XtNinteractCallback, callback, client_data); diff --git a/src/TMaction.c b/src/TMaction.c index a462e2c..5dd380b 100644 --- a/src/TMaction.c +++ b/src/TMaction.c @@ -164,7 +164,6 @@ static void ReportUnboundActions( Cardinal num_params = 1; char* message; char messagebuf[1000]; - String params[1]; register Cardinal num_chars = 0; register Cardinal i, j; XtActionProc *procs; @@ -190,6 +189,8 @@ static void ReportUnboundActions( return; message = XtStackAlloc (num_chars + 1, messagebuf); if (message != NULL) { + String params[1]; + *message = '\0'; num_unbound = 0; stateTree = (TMSimpleStateTree)xlations->stateTreeTbl[0]; @@ -225,12 +226,12 @@ static CompiledAction *SearchActionTable( CompiledActionTable actionTable, Cardinal numActions) { - register int i, left, right; + int left, right; left = 0; right = (int)numActions - 1; while (left <= right) { - i = (left + right) >> 1; + int i = (left + right) >> 1; if (signature < actionTable[i].signature) right = i - 1; else if (signature > actionTable[i].signature) @@ -785,9 +786,7 @@ void XtGetActionList( XtActionList* actions_return, Cardinal* num_actions_return) { - XtActionList list; CompiledActionTable table; - int i; *actions_return = NULL; *num_actions_return = 0; @@ -803,10 +802,13 @@ void XtGetActionList( } *num_actions_return = widget_class->core_class.num_actions; if (*num_actions_return) { - list = *actions_return = (XtActionList) + XtActionList list = *actions_return = (XtActionList) __XtMalloc((Cardinal)((size_t)*num_actions_return * sizeof(XtActionsRec))); + table = GetClassActions(widget_class); + if (table != NULL) { + int i; for (i= (int)(*num_actions_return); --i >= 0; list++, table++) { list->string = XrmQuarkToString(table->signature); list->proc = table->proc; diff --git a/src/TMgrab.c b/src/TMgrab.c index 8a2027a..5ffcebf 100644 --- a/src/TMgrab.c +++ b/src/TMgrab.c @@ -189,7 +189,6 @@ static Boolean DoGrab( TMModifierMatch modMatch; Modifiers careOn = 0; Modifiers careMask = 0; - Boolean resolved; LOCK_PROCESS; typeMatch = TMGetTypeMatch(typeIndex); @@ -206,9 +205,9 @@ static Boolean DoGrab( case ButtonPress: case ButtonRelease: if (modMatch->lateModifiers) { - resolved = _XtComputeLateBindings(XtDisplay(widget), - modMatch->lateModifiers, - &careOn, &careMask); + Boolean resolved = _XtComputeLateBindings(XtDisplay(widget), + modMatch->lateModifiers, + &careOn, &careMask); if (!resolved) break; } careOn = (careOn | (Modifiers) modMatch->modifiers); diff --git a/src/TMkey.c b/src/TMkey.c index 4fd1eca..c1f8948 100644 --- a/src/TMkey.c +++ b/src/TMkey.c @@ -177,7 +177,6 @@ Boolean _XtComputeLateBindings( int i,j,ref; ModToKeysymTable* temp; XtPerDisplay perDisplay; - Boolean found; KeySym tempKeysym = NoSymbol; perDisplay = _XtGetPerDisplay(dpy); @@ -190,7 +189,7 @@ Boolean _XtComputeLateBindings( } _InitializeKeysymTables(dpy, perDisplay); for (ref=0; lateModifiers[ref].keysym; ref++) { - found = FALSE; + Boolean found = FALSE; for (i=0;i<8;i++) { temp = &(perDisplay->modsToKeysyms[i]); for (j=0;jcount;j++){ @@ -250,13 +249,11 @@ Boolean _XtMatchUsingDontCareMods( Modifiers modifiers_return; KeySym keysym_return; Modifiers useful_mods; - int i, num_modbits; Modifiers computed = 0; Modifiers computedMask = 0; Boolean resolved = TRUE; Display *dpy = eventSeq->xev->xany.display; XtPerDisplay pd; - TMKeyContext tm_context; if (modMatch->lateModifiers != NULL) resolved = _XtComputeLateBindings(dpy, modMatch->lateModifiers, @@ -267,6 +264,9 @@ Boolean _XtMatchUsingDontCareMods( if ( (computed & computedMask) == (eventSeq->event.modifiers & computedMask) ) { + TMKeyContext tm_context; + int num_modbits; + int i; pd = _XtGetPerDisplay(dpy); tm_context = pd->tm_context; @@ -374,7 +374,6 @@ Boolean _XtMatchUsingStandardMods ( KeySym keysym_return; Modifiers computed= 0; Modifiers computedMask = 0; - Boolean resolved = TRUE; Display *dpy = eventSeq->xev->xany.display; XtPerDisplay pd = _XtGetPerDisplay(dpy); TMKeyContext tm_context = pd->tm_context; @@ -402,6 +401,8 @@ Boolean _XtMatchUsingStandardMods ( if ((typeMatch->eventCode & typeMatch->eventCodeMask) == (keysym_return & typeMatch->eventCodeMask)) { + Boolean resolved = TRUE; + if (modMatch->lateModifiers != NULL) resolved = _XtComputeLateBindings(dpy, modMatch->lateModifiers, &computed, &computedMask); @@ -671,7 +672,7 @@ void XtKeysymToKeycodeList( { XtPerDisplay pd; unsigned keycode; - int per, match; + int per; register KeySym *syms; register int i, j; KeySym lsym, usym; @@ -688,7 +689,7 @@ void XtKeysymToKeycodeList( for (syms = pd->keysyms, keycode = (unsigned) pd->min_keycode; (int)keycode <= pd->max_keycode; syms += per, keycode++) { - match = 0; + int match = 0; for (j = 0; j < per; j++) { if (syms[j] == keysym) { match = 1; diff --git a/src/TMparse.c b/src/TMparse.c index be37814..1782315 100644 --- a/src/TMparse.c +++ b/src/TMparse.c @@ -537,9 +537,12 @@ static void StoreLateBindings( LateBindingsPtr* lateBindings) { LateBindingsPtr temp; - Boolean pair = FALSE; - unsigned long count,number; + if (lateBindings != NULL){ + Boolean pair = FALSE; + unsigned long count; + unsigned long number; + temp = *lateBindings; if (temp != NULL) { for (count = 0; temp[count].keysym; count++){/*EMPTY*/} @@ -593,7 +596,7 @@ static Boolean _XtLookupModifier( Value *valueP, Bool constMask) { - register int i, left, right; + int left, right; static int previous = 0; LOCK_PROCESS; @@ -609,7 +612,7 @@ static Boolean _XtLookupModifier( left = 0; right = XtNumber(modifiers) - 1; while (left <= right) { - i = (left + right) >> 1; + int i = (left + right) >> 1; if (signature < modifiers[i].signature) right = i - 1; else if (signature > modifiers[i].signature) @@ -1694,8 +1697,7 @@ static String ParseParamSeq( } ParamRec; ParamPtr params = NULL; - register Cardinal num_params = 0; - register Cardinal i; + Cardinal num_params = 0; ScanWhitespace(str); while (*str != ')' && *str != '\0' && !IsNewline(*str)) { @@ -1721,6 +1723,8 @@ static String ParseParamSeq( if (num_params != 0) { String *paramP = (String *) __XtMalloc( (Cardinal)((num_params+1) * sizeof(String)) ); + Cardinal i; + *paramSeqP = paramP; *paramNumP = num_params; paramP += num_params; /* list is LIFO right now */ @@ -1863,14 +1867,16 @@ static String CheckForPoundSign( _XtTranslateOp defaultOp, _XtTranslateOp *actualOpRtn) { - String start; - char operation[20]; _XtTranslateOp opType; opType = defaultOp; ScanWhitespace(str); + if (*str == '#') { + String start; + char operation[20]; int len; + str++; start = str; str = ScanIdent(str); diff --git a/src/TMprint.c b/src/TMprint.c index 0c6508c..397189c 100644 --- a/src/TMprint.c +++ b/src/TMprint.c @@ -147,6 +147,7 @@ static void PrintModifiers( CHECK_STR_OVERFLOW(sb); PRINTMOD(Button4Mask, "Button4"); PRINTMOD(Button5Mask, "Button5"); + (void) notfirst; #undef PRINTMOD } @@ -208,7 +209,7 @@ static void PrintCode( if (mask != 0) { if (mask != ~0UL) (void) sprintf(sb->current, "0x%lx:0x%lx", mask, code); - else (void) sprintf(sb->current, /*"0x%lx"*/ "%d", (unsigned)code); + else (void) sprintf(sb->current, /*"0x%lx"*/ "%u", (unsigned)code); sb->current += strlen(sb->current); } } @@ -495,12 +496,13 @@ static int FindNextMatch( TMShortCard startIndex) { TMShortCard i; - TMComplexStateTree stateTree; StatePtr currState, candState; Boolean noMatch = True; - TMBranchHead prBranchHead; for (i = startIndex; noMatch && i < numPrints; i++) { + TMBranchHead prBranchHead; + TMComplexStateTree stateTree; + stateTree = (TMComplexStateTree) xlations->stateTreeTbl[printData[i].tIndex]; prBranchHead = @@ -864,8 +866,6 @@ String _XtPrintEventSeq( Display *dpy) { TMStringBufRec sbRec, *sb = &sbRec; - TMTypeMatch typeMatch; - TMModifierMatch modMatch; #define MAXSEQS 100 EventSeqPtr eventSeqs[MAXSEQS]; TMShortCard i, j; @@ -884,6 +884,9 @@ String _XtPrintEventSeq( } LOCK_PROCESS; for (j = 0; j < i; j++) { + TMTypeMatch typeMatch; + TMModifierMatch modMatch; + typeMatch = TMGetTypeMatch(_XtGetTypeIndex(&eventSeqs[j]->event)); modMatch = diff --git a/src/TMstate.c b/src/TMstate.c index 530a6cd..70ee5dd 100644 --- a/src/TMstate.c +++ b/src/TMstate.c @@ -113,14 +113,14 @@ static TMShortCard GetBranchHead( #define TM_BRANCH_HEAD_TBL_REALLOC 8 TMBranchHead branchHead = parseTree->branchHeadTbl; - TMShortCard newSize, i; - /* * dummy is used as a place holder for later matching in old-style * matching behavior. If there's already an entry we don't need * another dummy. */ if (isDummy) { + TMShortCard i; + for (i = 0; i < parseTree->numBranchHeads; i++, branchHead++) { if ((branchHead->typeIndex == typeIndex) && (branchHead->modIndex == modIndex)) @@ -129,6 +129,8 @@ static TMShortCard GetBranchHead( } if (parseTree->numBranchHeads == parseTree->branchHeadTblSize) { + TMShortCard newSize; + if (parseTree->branchHeadTblSize == 0) parseTree->branchHeadTblSize = (TMShortCard) (parseTree->branchHeadTblSize + TM_BRANCH_HEAD_TBL_ALLOC); else @@ -170,7 +172,7 @@ TMShortCard _XtGetQuarkIndex( { #define TM_QUARK_TBL_ALLOC 16 #define TM_QUARK_TBL_REALLOC 16 - TMShortCard i = parseTree->numQuarks; + TMShortCard i; for (i=0; i < parseTree->numQuarks; i++) if (parseTree->quarkTbl[i] == quark) @@ -778,25 +780,22 @@ static void HandleSimpleState( TMEventRec *curEventPtr) { XtTranslations xlations = tmRecPtr->translations; - TMSimpleStateTree stateTree; TMContext *contextPtr = GetContextPtr(tmRecPtr); TMShortCard i; ActionRec *actions = NULL; Boolean matchExact = False; Boolean match = False; StatePtr complexMatchState = NULL; - int currIndex; TMShortCard typeIndex = 0, modIndex = 0; int matchTreeIndex = TM_NO_MATCH; LOCK_PROCESS; - stateTree = (TMSimpleStateTree)xlations->stateTreeTbl[0]; - for (i = 0; ((!match || !complexMatchState) && (i < xlations->numStateTrees)); i++){ - stateTree = (TMSimpleStateTree)xlations->stateTreeTbl[i]; - currIndex = -1; + int currIndex = -1; + TMSimpleStateTree stateTree = (TMSimpleStateTree)xlations->stateTreeTbl[i]; + /* * don't process this tree if we're only looking for a * complexMatchState and there are no complex states @@ -1255,7 +1254,6 @@ void _XtInstallTranslations( { XtTranslations xlations; Cardinal i; - TMStateTree stateTree; Boolean mappingNotifyInterest = False; xlations = widget->core.tm.translations; @@ -1281,7 +1279,7 @@ void _XtInstallTranslations( i < xlations->numStateTrees; i++) { - stateTree = xlations->stateTreeTbl[i]; + TMStateTree stateTree = xlations->stateTreeTbl[i]; _XtTraverseStateTree(stateTree, AggregateEventMask, (XtPointer)&xlations->eventMask); @@ -1327,7 +1325,6 @@ void _XtRemoveTranslations( Widget widget) { Cardinal i; - TMSimpleStateTree stateTree; Boolean mappingNotifyInterest = False; XtTranslations xlations = widget->core.tm.translations; @@ -1338,7 +1335,7 @@ void _XtRemoveTranslations( i < xlations->numStateTrees; i++) { - stateTree = (TMSimpleStateTree)xlations->stateTreeTbl[i]; + TMSimpleStateTree stateTree = (TMSimpleStateTree)xlations->stateTreeTbl[i]; mappingNotifyInterest = (Boolean) (mappingNotifyInterest | stateTree->mappingNotifyInterest); } if (mappingNotifyInterest) @@ -1367,11 +1364,9 @@ void _XtDestroyTMData( if ((cBindData = (TMComplexBindData)widget->core.tm.proc_table)) { if (cBindData->isComplex) { - ATranslations aXlations, nXlations; - - nXlations = (ATranslations) cBindData->accel_context; + ATranslations nXlations = (ATranslations) cBindData->accel_context; while (nXlations){ - aXlations = nXlations; + ATranslations aXlations = nXlations; nXlations = nXlations->next; XtFree((char *)aXlations); } @@ -1828,7 +1823,7 @@ static XtTranslations MergeTranslations( TMComplexBindProcs bindings; TMShortCard i, j; TMStateTree *treePtr; - TMShortCard numNew = *numNewRtn; + TMShortCard numNew; MergeBindRec bindPair[2]; /* If the new translation has an accelerator context then pull it @@ -2209,7 +2204,6 @@ void XtInstallAccelerators( { XtTranslations aXlations; _XtTranslateOp op; - _XtString buf; WIDGET_TO_APPCON(destination); /* @@ -2232,8 +2226,7 @@ void XtInstallAccelerators( if (ComposeTranslations(destination, op, source, aXlations) && (XtClass(source)->core_class.display_accelerator != NULL)) { - - buf = _XtPrintXlations(destination, aXlations, source, False); + _XtString buf = _XtPrintXlations(destination, aXlations, source, False); (*(XtClass(source)->core_class.display_accelerator))(source,buf); XtFree(buf); } @@ -2246,14 +2239,13 @@ void XtInstallAllAccelerators( Widget source) { Cardinal i; - CompositeWidget cw; WIDGET_TO_APPCON(destination); /* Recurse down normal children */ LOCK_APP(app); LOCK_PROCESS; if (XtIsComposite(source)) { - cw = (CompositeWidget) source; + CompositeWidget cw = (CompositeWidget) source; for (i = 0; i < cw->composite.num_children; i++) { XtInstallAllAccelerators(destination,cw->composite.children[i]); } diff --git a/src/VarCreate.c b/src/VarCreate.c index eb2c35a..896935d 100644 --- a/src/VarCreate.c +++ b/src/VarCreate.c @@ -357,12 +357,15 @@ XtVaOpenApplication( WidgetClass widget_class, ...) { + Widget code; va_list var; va_start(var, widget_class); - return _XtVaOpenApplication(app_context_return, (String)application_class, + code = _XtVaOpenApplication(app_context_return, (String)application_class, options, num_options, argc_in_out, argv_in_out, fallback_resources, widget_class, var); + va_end(var); + return code; } Widget @@ -376,13 +379,16 @@ XtVaAppInitialize( String *fallback_resources, ...) { + Widget code; va_list var; va_start(var, fallback_resources); - return _XtVaOpenApplication(app_context_return, (String)application_class, + code = _XtVaOpenApplication(app_context_return, (String)application_class, options, num_options, argc_in_out, argv_in_out, fallback_resources, applicationShellWidgetClass, var); + va_end(var); + return code; } #endif /* !((SUNSHLIB || AIXSHLIB) && SHAREDCODE) */ diff --git a/src/Varargs.c b/src/Varargs.c index 619de5b..0368209 100644 --- a/src/Varargs.c +++ b/src/Varargs.c @@ -312,16 +312,16 @@ NestedArgtoArg( void _XtFreeArgList( ArgList args, /* as returned by _XtVaToArgList */ - int total_count, /* argument count returned by _XtCountVaList */ + int total_count, /* argument count returned by _XtCountVaList */ int typed_count) /* typed arg count returned by _XtCountVaList */ { - ArgList p; - if (args) { - if (typed_count) + if (typed_count) { + ArgList p; for (p = args + total_count; total_count--; ++p) { XtFree((char *)p->value); } + } XtFree((char *)args); } } -- cgit v1.2.3