diff options
author | Walter Harms <wharms@bfs.de> | 2019-05-18 19:31:28 +0200 |
---|---|---|
committer | Walter Harms <wharms@bfs.de> | 2019-05-18 19:31:28 +0200 |
commit | d4208c7734fb12adbfb5ef1b65dfcfe7126380d6 (patch) | |
tree | 82b9d498978f936350857e06b289983685420202 /src | |
parent | b3b86a2f6b974f5e040d64aa3778075c987bf0fa (diff) | |
parent | 4264ac5f8bc959844ae8ac623d4db491fc691fa5 (diff) |
Merge branch 'master' of ssh://gitlab.freedesktop.org/xorg/lib/libxt
Diffstat (limited to 'src')
-rw-r--r-- | src/Callback.c | 10 | ||||
-rw-r--r-- | src/Composite.c | 41 | ||||
-rw-r--r-- | src/Convert.c | 19 | ||||
-rw-r--r-- | src/Converters.c | 23 | ||||
-rw-r--r-- | src/Core.c | 3 | ||||
-rw-r--r-- | src/Create.c | 15 | ||||
-rw-r--r-- | src/Destroy.c | 7 | ||||
-rw-r--r-- | src/Display.c | 34 | ||||
-rw-r--r-- | src/Error.c | 12 | ||||
-rw-r--r-- | src/Event.c | 38 | ||||
-rw-r--r-- | src/GCManager.c | 4 | ||||
-rw-r--r-- | src/Geometry.c | 53 | ||||
-rw-r--r-- | src/Initialize.c | 20 | ||||
-rw-r--r-- | src/Intrinsic.c | 20 | ||||
-rw-r--r-- | src/Keyboard.c | 11 | ||||
-rw-r--r-- | src/Manage.c | 5 | ||||
-rw-r--r-- | src/NextEvent.c | 22 | ||||
-rw-r--r-- | src/Object.c | 13 | ||||
-rw-r--r-- | src/PassivGrab.c | 13 | ||||
-rw-r--r-- | src/Popup.c | 2 | ||||
-rw-r--r-- | src/ResConfig.c | 75 | ||||
-rw-r--r-- | src/Resources.c | 142 | ||||
-rw-r--r-- | src/Selection.c | 52 | ||||
-rw-r--r-- | src/SetSens.c | 14 | ||||
-rw-r--r-- | src/SetValues.c | 23 | ||||
-rw-r--r-- | src/Shell.c | 11 | ||||
-rw-r--r-- | src/TMaction.c | 21 | ||||
-rw-r--r-- | src/TMgrab.c | 9 | ||||
-rw-r--r-- | src/TMkey.c | 17 | ||||
-rw-r--r-- | src/TMparse.c | 92 | ||||
-rw-r--r-- | src/TMprint.c | 15 | ||||
-rw-r--r-- | src/TMstate.c | 41 | ||||
-rw-r--r-- | src/Threads.c | 3 | ||||
-rw-r--r-- | src/VarCreate.c | 10 | ||||
-rw-r--r-- | src/VarGet.c | 58 | ||||
-rw-r--r-- | src/Varargs.c | 84 |
36 files changed, 541 insertions, 491 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..108645d 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)); @@ -183,34 +184,32 @@ static void CompositeClassPartInitialize( wcPtr = (CompositePartPtr) &(((CompositeWidgetClass)myWidgetClass)->composite_class); - if (myWidgetClass != compositeWidgetClass) + if (myWidgetClass != compositeWidgetClass) { /* don't compute possible bogus pointer */ superPtr = (CompositePartPtr)&(((CompositeWidgetClass)myWidgetClass ->core_class.superclass)->composite_class); - /* We don't need to check for null super since we'll get to composite - eventually, and it had better define them! */ - - LOCK_PROCESS; - if (wcPtr->geometry_manager == XtInheritGeometryManager) { - wcPtr->geometry_manager = - superPtr->geometry_manager; - } + LOCK_PROCESS; + if (wcPtr->geometry_manager == XtInheritGeometryManager) { + wcPtr->geometry_manager = + superPtr->geometry_manager; + } - if (wcPtr->change_managed == XtInheritChangeManaged) { - wcPtr->change_managed = - superPtr->change_managed; - InheritAllowsChangeManagedSet(myWidgetClass); - } + if (wcPtr->change_managed == XtInheritChangeManaged) { + wcPtr->change_managed = + superPtr->change_managed; + InheritAllowsChangeManagedSet(myWidgetClass); + } - if (wcPtr->insert_child == XtInheritInsertChild) { - wcPtr->insert_child = superPtr->insert_child; - } + if (wcPtr->insert_child == XtInheritInsertChild) { + wcPtr->insert_child = superPtr->insert_child; + } - if (wcPtr->delete_child == XtInheritDeleteChild) { - wcPtr->delete_child = superPtr->delete_child; + if (wcPtr->delete_child == XtInheritDeleteChild) { + wcPtr->delete_child = superPtr->delete_child; + } + UNLOCK_PROCESS; } - UNLOCK_PROCESS; } static void CompositeDestroy( diff --git a/src/Convert.c b/src/Convert.c index ebfc984..f9f241e 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]; @@ -405,8 +404,9 @@ CacheEnter( (void) memmove((char *)p->from.addr, (char *)from->addr, from->size); } p->num_args = (unsigned short) num_args; - if (num_args) { + if (num_args && 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); @@ -453,7 +453,7 @@ static void FreeCacheRec( *(CEXT(p)->prev) = p->next; if (p->next && p->next->has_ext) CEXT(p->next)->prev = CEXT(p)->prev; - } else { + } else if (prev) { *prev = p->next; if (p->next && p->next->has_ext) CEXT(p->next)->prev = prev; @@ -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..fbfa076 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 */ @@ -561,15 +561,16 @@ static void FetchDisplayArg( Cardinal *size, XrmValue* value) { - if (widget == NULL) + if (widget == NULL) { XtErrorMsg("missingWidget", "fetchDisplayArg", XtCXtToolkitError, "FetchDisplayArg called without a widget to reference", NULL, NULL); /* can't return any useful Display and caller will de-ref NULL, so aborting is the only useful option */ - - value->size = sizeof(Display*); - value->addr = (XPointer)&DisplayOfScreen(XtScreenOfObject(widget)); + } else { + value->size = sizeof(Display*); + value->addr = (XPointer)&DisplayOfScreen(XtScreenOfObject(widget)); + } } static XtConvertArgRec const displayConvertArg[] = { @@ -809,11 +810,8 @@ Boolean XtCvtStringToFloat( int ret; float f, nan; -#ifndef ISC /* On ISC this generates a core dump :-( at least with gs */ - /* depending on the system this may or may not do anything useful */ - (void) sscanf ("NaNS", "%g", + (void) sscanf ("NaN", "%g", toVal->addr != NULL ? (float*) toVal->addr : &nan); -#endif if (*num_args != 0) XtAppWarningMsg(XtDisplayToApplicationContext(dpy), @@ -1629,7 +1627,6 @@ Boolean XtCvtStringToCommandArgArray( String *strarray, *ptr; char *src; char *dst, *dst_str; - char *start; int tokens, len; if (*num_args != 0) @@ -1643,6 +1640,8 @@ Boolean XtCvtStringToCommandArgArray( tokens = 0; while (*src != '\0') { + char *start; + /* skip whitespace */ while (IsWhitespace(*src) || IsNewline(*src)) src++; @@ -1704,10 +1703,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); } @@ -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..1d18590 100644 --- a/src/Create.c +++ b/src/Create.c @@ -267,9 +267,12 @@ xtWidgetAlloc( Cardinal num_typed_args) { Widget widget; - Cardinal wsize, csize = 0; + Cardinal csize = 0; ObjectClassExtension ext; + if (widget_class == NULL) + return 0; + LOCK_PROCESS; if (! (widget_class->core_class.class_inited)) XtInitializeWidgetClass(widget_class); @@ -290,7 +293,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 +321,6 @@ CompileCallbacks( Widget widget) { CallbackTable offsets; - InternalCallbackList* cl; int i; LOCK_PROCESS; @@ -326,7 +328,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 +353,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 +392,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++) { @@ -409,11 +410,11 @@ xtCreate( } wsize = widget_class->core_class.widget_size; - csize = 0; req_widget = (Widget) XtStackAlloc(wsize, widget_cache); (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..e4cf87d 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); @@ -555,6 +555,7 @@ PerDisplayTablePtr _XtperDisplayList = NULL; XtPerDisplay _XtSortPerDisplayList(Display *dpy) { register PerDisplayTablePtr pd, opd = NULL; + XtPerDisplay result = NULL; LOCK_PROCESS; for (pd = _XtperDisplayList; @@ -567,17 +568,18 @@ XtPerDisplay _XtSortPerDisplayList(Display *dpy) XtErrorMsg(XtNnoPerDisplay, "getPerDisplay", XtCXtToolkitError, "Couldn't find per display information", NULL, NULL); - } - - if (pd != _XtperDisplayList) { /* move it to the front */ - /* opd points to the previous one... */ + } else { + if (pd != _XtperDisplayList) { /* move it to the front */ + /* opd points to the previous one... */ - opd->next = pd->next; - pd->next = _XtperDisplayList; - _XtperDisplayList = pd; + opd->next = pd->next; + pd->next = _XtperDisplayList; + _XtperDisplayList = pd; + } + result = &(pd->perDpy); } UNLOCK_PROCESS; - return &(pd->perDpy); + return result; } XtAppContext XtDisplayToApplicationContext(Display *dpy) @@ -590,10 +592,9 @@ XtAppContext XtDisplayToApplicationContext(Display *dpy) static void CloseDisplay(Display *dpy) { - register XtPerDisplay xtpd; + register XtPerDisplay xtpd = NULL; register PerDisplayTablePtr pd, opd = NULL; XrmDatabase db; - int i; XtDestroyWidget(XtHooksOfDisplay(dpy)); @@ -608,14 +609,17 @@ static void CloseDisplay(Display *dpy) XtErrorMsg(XtNnoPerDisplay, "closeDisplay", XtCXtToolkitError, "Couldn't find per display information", NULL, NULL); - } + } else { - if (pd == _XtperDisplayList) _XtperDisplayList = pd->next; - else opd->next = pd->next; + if (pd == _XtperDisplayList) _XtperDisplayList = pd->next; + else opd->next = pd->next; - xtpd = &(pd->perDpy); + xtpd = &(pd->perDpy); + } if (xtpd != NULL) { + int i; + if (xtpd->destroy_callbacks != NULL) { XtCallCallbackList((Widget) NULL, (XtCallbackList)xtpd->destroy_callbacks, diff --git a/src/Error.c b/src/Error.c index 38d4e15..a302dbd 100644 --- a/src/Error.c +++ b/src/Error.c @@ -93,7 +93,7 @@ void _XtDefaultError(String) _X_NORETURN; void _XtDefaultWarning(String); static XtErrorMsgHandler errorMsgHandler = _XtDefaultErrorMsg; static XtErrorMsgHandler warningMsgHandler = _XtDefaultWarningMsg; -static XtErrorHandler errorHandler = _XtDefaultError; +static XtErrorHandler errorHandler _X_NORETURN = _XtDefaultError; static XtErrorHandler warningHandler = _XtDefaultWarning; #endif /* GLOBALERRORS */ @@ -344,6 +344,7 @@ void XtErrorMsg( (*errorMsgHandler)((String)name,(String)type,(String)class, (String)defaultp,params,num_params); UNLOCK_PROCESS; + exit(1); #else XtAppErrorMsg(_XtDefaultAppContext(),name,type,class, defaultp,params,num_params); @@ -364,6 +365,7 @@ void XtAppErrorMsg( (*errorMsgHandler)((String)name,(String)type,(String)class, (String)defaultp,params,num_params); UNLOCK_PROCESS; + exit(1); #else LOCK_APP(app); (*app->errorMsgHandler)(name,type,class,defaultp,params,num_params); @@ -412,7 +414,7 @@ void XtAppWarningMsg( } void XtSetErrorMsgHandler( - XtErrorMsgHandler handler) + XtErrorMsgHandler handler _X_NORETURN) { #if GLOBALERRORS LOCK_PROCESS; @@ -426,7 +428,7 @@ void XtSetErrorMsgHandler( XtErrorMsgHandler XtAppSetErrorMsgHandler( XtAppContext app, - XtErrorMsgHandler handler) + XtErrorMsgHandler handler _X_NORETURN) { XtErrorMsgHandler old; #if GLOBALERRORS @@ -547,7 +549,7 @@ void XtAppWarning( #endif /* GLOBALERRORS */ } -void XtSetErrorHandler(XtErrorHandler handler) +void XtSetErrorHandler(XtErrorHandler handler _X_NORETURN) { #if GLOBALERRORS LOCK_PROCESS; @@ -561,7 +563,7 @@ void XtSetErrorHandler(XtErrorHandler handler) XtErrorHandler XtAppSetErrorHandler( XtAppContext app, - XtErrorHandler handler) + XtErrorHandler handler _X_NORETURN) { XtErrorHandler old; #if GLOBALERRORS diff --git a/src/Event.c b/src/Event.c index 313f14e..a682d24 100644 --- a/src/Event.c +++ b/src/Event.c @@ -184,7 +184,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; @@ -197,7 +197,7 @@ RemoveEventHandler( /* un-register it */ if (!has_type_specifier) { - eventMask = *(EventMask*)select_data; + EventMask eventMask = *(EventMask*)select_data; eventMask &= ~NonMaskableMask; if (other) eventMask |= NonMaskableMask; @@ -316,7 +316,6 @@ AddEventHandler( if (position == XtListHead) { p->next = widget->core.event_table; widget->core.event_table = p; - pp = &widget->core.event_table; } else { *pp = p; p->next = NULL; @@ -391,7 +390,7 @@ void XtRemoveEventHandler( WIDGET_TO_APPCON(widget); LOCK_APP(app); RemoveEventHandler(widget, (XtPointer) &eventMask, 0, FALSE, - other, proc, closure, FALSE); + (Boolean) other, proc, closure, FALSE); UNLOCK_APP(app); } @@ -404,7 +403,7 @@ void XtAddEventHandler( { WIDGET_TO_APPCON(widget); LOCK_APP(app); - AddEventHandler(widget, (XtPointer) &eventMask, 0, FALSE, other, + AddEventHandler(widget, (XtPointer) &eventMask, 0, FALSE, (Boolean) other, proc, closure, XtListTail, FALSE, FALSE); UNLOCK_APP(app); } @@ -419,7 +418,7 @@ void XtInsertEventHandler( { WIDGET_TO_APPCON(widget); LOCK_APP(app); - AddEventHandler(widget, (XtPointer) &eventMask, 0, FALSE, other, + AddEventHandler(widget, (XtPointer) &eventMask, 0, FALSE, (Boolean) other, proc, closure, position, TRUE, FALSE); UNLOCK_APP(app); } @@ -434,7 +433,7 @@ void XtRemoveRawEventHandler( WIDGET_TO_APPCON(widget); LOCK_APP(app); RemoveEventHandler(widget, (XtPointer) &eventMask, 0, FALSE, - other, proc, closure, TRUE); + (Boolean) other, proc, closure, TRUE); UNLOCK_APP(app); } @@ -448,7 +447,7 @@ void XtInsertRawEventHandler( { WIDGET_TO_APPCON(widget); LOCK_APP(app); - AddEventHandler(widget, (XtPointer) &eventMask, 0, FALSE, other, + AddEventHandler(widget, (XtPointer) &eventMask, 0, FALSE, (Boolean) other, proc, closure, position, TRUE, TRUE); UNLOCK_APP(app); } @@ -462,7 +461,7 @@ void XtAddRawEventHandler( { WIDGET_TO_APPCON(widget); LOCK_APP(app); - AddEventHandler(widget, (XtPointer) &eventMask, 0, FALSE, other, + AddEventHandler(widget, (XtPointer) &eventMask, 0, FALSE, (Boolean) other, proc, closure, XtListTail, FALSE, TRUE); UNLOCK_APP(app); } @@ -526,7 +525,7 @@ void XtRegisterDrawable( Widget widget) { WWTable tab; - int idx, rehash; + int idx; Widget entry; Window window = (Window) drawable; WIDGET_TO_APPCON(widget); @@ -550,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); @@ -569,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); @@ -597,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])) { @@ -652,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); @@ -665,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); @@ -1485,7 +1484,7 @@ void XtAddGrab( exclusive = TRUE; } - gl = NewGrabRec(widget, exclusive, spring_loaded); + gl = NewGrabRec(widget, (Boolean) exclusive, (Boolean) spring_loaded); gl->next = *grabListPtr; *grabListPtr = gl; @@ -1668,7 +1667,6 @@ void XtRegisterExtensionSelector( XtExtensionSelectProc proc, XtPointer client_data) { - ExtSelectRec *e; XtPerDisplay pd; int i; DPY_TO_APPCON(dpy); @@ -1683,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 fdd5661..992141e 100644 --- a/src/Geometry.c +++ b/src/Geometry.c @@ -116,7 +116,9 @@ _XtMakeGeometryRequest ( XtGeometryHandler manager = (XtGeometryHandler) NULL; XtGeometryResult returnCode; Widget parent = widget->core.parent; - Boolean managed, parentRealized, rgm = False; + Boolean managed; + Boolean parentRealized = False; + Boolean rgm = False; XtConfigureHookDataRec req; Widget hookobj; @@ -163,21 +165,22 @@ _XtMakeGeometryRequest ( parentRealized = TRUE; UNLOCK_PROCESS; } else /* not shell */ { - if (parent == NULL) + if (parent == NULL) { XtAppErrorMsg(XtWidgetToApplicationContext(widget), "invalidParent","xtMakeGeometryRequest", XtCXtToolkitError, "non-shell has no parent in XtMakeGeometryRequest", NULL, NULL); - - managed = XtIsManaged(widget); - parentRealized = XtIsRealized(parent); - if (XtIsComposite(parent)) - { - LOCK_PROCESS; - manager = ((CompositeWidgetClass) (parent->core.widget_class)) - ->composite_class.geometry_manager; - UNLOCK_PROCESS; + } else { + managed = XtIsManaged(widget); + parentRealized = XtIsRealized(parent); + if (XtIsComposite(parent)) + { + LOCK_PROCESS; + manager = ((CompositeWidgetClass) (parent->core.widget_class)) + ->composite_class.geometry_manager; + UNLOCK_PROCESS; + } } } @@ -522,8 +525,8 @@ XtMakeResizeRequest( LOCK_APP(app); request.request_mode = CWWidth | CWHeight; - request.width = width; - request.height = height; + request.width = (Dimension) width; + request.height = (Dimension) height; if (XtHasCallbacks(hookobj, XtNgeometryHook) == XtCallbackHasSome) { call_data.type = XtHpreGeometry; @@ -546,13 +549,13 @@ XtMakeResizeRequest( if (r == XtGeometryAlmost && reply.request_mode & CWWidth) *replyWidth = reply.width; else - *replyWidth = width; + *replyWidth = (Dimension) width; } if (replyHeight != NULL) { if (r == XtGeometryAlmost && reply.request_mode & CWHeight) *replyHeight = reply.height; else - *replyHeight = height; + *replyHeight = (Dimension) height; } UNLOCK_APP(app); return ((r == XtGeometryDone) ? XtGeometryYes : r); @@ -562,11 +565,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 +607,6 @@ void XtConfigureWidget( _XtDimension borderWidth) { XtConfigureHookDataRec req; - Widget hookobj; XWindowChanges old; WIDGET_TO_APPCON(w); @@ -617,38 +620,40 @@ void XtConfigureWidget( req.changeMask = 0; if ((old.x = w->core.x) != x) { CALLGEOTAT(_XtGeoTrace(w,"x move from %d to %d\n",w->core.x, x)); - req.changes.x = w->core.x = x; + req.changes.x = w->core.x = (Position) x; req.changeMask |= CWX; } if ((old.y = w->core.y) != y) { CALLGEOTAT(_XtGeoTrace(w,"y move from %d to %d\n",w->core.y, y)); - req.changes.y = w->core.y = y; + req.changes.y = w->core.y = (Position) y; req.changeMask |= CWY; } if ((old.width = w->core.width) != width) { CALLGEOTAT(_XtGeoTrace(w, "width move from %d to %d\n",w->core.width, width)); - req.changes.width = w->core.width = width; + req.changes.width = w->core.width = (Dimension) width; req.changeMask |= CWWidth; } if ((old.height = w->core.height) != height) { CALLGEOTAT(_XtGeoTrace(w, "height move from %d to %d\n",w->core.height, height)); - req.changes.height = w->core.height = height; + req.changes.height = w->core.height = (Dimension) height; req.changeMask |= CWHeight; } if ((old.border_width = w->core.border_width) != borderWidth) { CALLGEOTAT(_XtGeoTrace(w,"border_width move from %d to %d\n", w->core.border_width,borderWidth )); - req.changes.border_width = w->core.border_width = borderWidth; + req.changes.border_width = w->core.border_width = (Dimension) borderWidth; req.changeMask |= CWBorderWidth; } if (req.changeMask != 0) { + Widget hookobj; + if (XtIsRealized(w)) { if (XtIsWidget(w)) { CALLGEOTAT(_XtGeoTrace(w, @@ -712,8 +717,8 @@ void XtTranslateCoords( if (rootx == NULL) rootx = &garbagex; if (rooty == NULL) rooty = &garbagey; - *rootx = x; - *rooty = y; + *rootx = (Position) x; + *rooty = (Position) y; for (; w != NULL && ! XtIsShell(w); w = w->core.parent) { *rootx = (Position) (*rootx + w->core.x + w->core.border_width); 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<n_tab; i++) printf(" "); (void) vprintf(fmt, args); diff --git a/src/Keyboard.c b/src/Keyboard.c index 4c43b95..7697275 100644 --- a/src/Keyboard.c +++ b/src/Keyboard.c @@ -104,12 +104,12 @@ static XtServerGrabPtr CheckServerGrabs( Widget *trace, Cardinal traceDepth) { - XtServerGrabPtr grab; Cardinal i; for (i = traceDepth; 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; @@ -331,7 +331,6 @@ static Widget FindKeyDestination( { XtUngrabKeyboard(devGrab->widget, event->time); - devGrabType = XtNoServerGrab; } /* * if there isn't a grab with then check @@ -395,7 +394,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 +406,8 @@ Widget _XtProcessKeyboardEvent( { case KeyPress: { + XtServerGrabPtr newGrab; + if (event->keycode != 0 && /* Xlib XIM composed input */ !IsServerGrab(device->grabType) && (newGrab = CheckServerGrabs((XEvent*)event, @@ -574,9 +575,7 @@ void _XtHandleFocus( newFocalPoint = XtUnrelated; break; case NotifyInferior: - newFocalPoint = XtMyDescendant; return; - break; } break; } diff --git a/src/Manage.c b/src/Manage.c index f51ca59..96bacbb 100644 --- a/src/Manage.c +++ b/src/Manage.c @@ -373,7 +373,7 @@ void XtSetMappedWhenManaged( UNLOCK_APP(app); return; } - widget->core.mapped_when_managed = mapped_when_managed; + widget->core.mapped_when_managed = (Boolean) mapped_when_managed; hookobj = XtHooksOfDisplay(XtDisplay(widget)); if (XtHasCallbacks(hookobj, XtNchangeHook) == XtCallbackHasSome) { @@ -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 0b5ddc0..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 @@ -581,7 +581,7 @@ int _XtWaitForSomething( drop_lock = FALSE; #endif - InitTimes (block, howlong, &wt); + InitTimes ((Boolean) block, howlong, &wt); #ifdef USE_POLL wf.fdlist = NULL; @@ -593,7 +593,7 @@ WaitLoop: app->rebuild_fdlist = TRUE; while (1) { - AdjustTimes (app, block, howlong, ignoreTimers, &wt); + AdjustTimes (app, (Boolean) block, howlong, (Boolean) ignoreTimers, &wt); if (block && app->block_hook_list) { BlockHook hook; @@ -614,7 +614,7 @@ WaitLoop: } if (app->rebuild_fdlist) - InitFds (app, ignoreEvents, ignoreInputs, &wf); + InitFds (app, (Boolean) ignoreEvents, (Boolean) ignoreInputs, &wf); #ifdef XTHREADS /* { */ if (drop_lock) { @@ -721,7 +721,7 @@ WaitLoop: return -1; } else FindInputs (app, &wf, nfds, - ignoreEvents, ignoreInputs, + (Boolean) ignoreEvents, (Boolean) ignoreInputs, &dpy_no, &found_input); if (dpy_no >= 0 || found_input) { @@ -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 650210d..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); @@ -830,7 +831,7 @@ void XtGrabKey ( WIDGET_TO_APPCON(widget); LOCK_APP(app); - GrabKeyOrButton(widget, (KeyCode)keycode, modifiers, owner_events, + GrabKeyOrButton(widget, (KeyCode)keycode, modifiers, (Boolean) owner_events, pointer_mode, keyboard_mode, (Mask)0, (Window)None, (Cursor)None, KEYBOARD); UNLOCK_APP(app); @@ -850,7 +851,7 @@ void XtGrabButton( WIDGET_TO_APPCON(widget); LOCK_APP(app); - GrabKeyOrButton(widget, (KeyCode)button, modifiers, owner_events, + GrabKeyOrButton(widget, (KeyCode)button, modifiers, (Boolean) owner_events, pointer_mode, keyboard_mode, (Mask)event_mask, confine_to, cursor, POINTER); UNLOCK_APP(app); @@ -982,7 +983,7 @@ int XtGrabKeyboard ( WIDGET_TO_APPCON(widget); LOCK_APP(app); - retval = GrabDevice (widget, owner_events, + retval = GrabDevice (widget, (Boolean) owner_events, pointer_mode, keyboard_mode, (Mask)0, (Window)None, (Cursor)None, time, KEYBOARD); UNLOCK_APP(app); @@ -1025,7 +1026,7 @@ int XtGrabPointer ( WIDGET_TO_APPCON(widget); LOCK_APP(app); - retval = GrabDevice (widget, owner_events, + retval = GrabDevice (widget, (Boolean) owner_events, pointer_mode, keyboard_mode, (Mask)event_mask, confine_to, cursor, time, POINTER); diff --git a/src/Popup.c b/src/Popup.c index acf3633..56fa60d 100644 --- a/src/Popup.c +++ b/src/Popup.c @@ -70,7 +70,7 @@ void _XtPopup( XtCallCallbacks(widget, XtNpopupCallback, (XtPointer)&call_data); shell_widget->shell.popped_up = TRUE; shell_widget->shell.grab_kind = grab_kind; - shell_widget->shell.spring_loaded = spring_loaded; + shell_widget->shell.spring_loaded = (Boolean) spring_loaded; if (shell_widget->shell.create_popup_child_proc != NULL) { (*(shell_widget->shell.create_popup_child_proc))(widget); } diff --git a/src/ResConfig.c b/src/ResConfig.c index 2c4b278..169b22f 100644 --- a/src/ResConfig.c +++ b/src/ResConfig.c @@ -118,10 +118,16 @@ _set_resource_values ( Display *dpy; XrmDatabase tmp_db; - if (!XtIsWidget (w)) - dpy = XtDisplay (w->core.parent); - else - dpy = XtDisplay (w); + if (last_part == NULL) + return; + + if (!XtIsWidget (w)) { + if (w == 0 || w->core.parent == 0) + return; + dpy = XtDisplay (w->core.parent); + } else { + dpy = XtDisplay (w); + } tmp_db = XtDatabase(dpy); /* @@ -676,7 +682,6 @@ _search_widget_tree ( char *last_part; char *remainder = NULL; char last_token; - char *indx, *copy; char *loose, *tight; int loose_len, tight_len; @@ -715,32 +720,35 @@ _search_widget_tree ( * Parse last segment off of resource string, (eg. background, font, * etc.) */ - last_token = _get_last_part (remainder, &last_part); - /* - * this case covers resources of only one level (eg. *background) - */ - if (remainder[0] == 0) { - _set_resource_values (w, resource, value, last_part); - if (last_token == '*') - _apply_values_to_children (parent, remainder, resource, - value, last_token, last_part); - /* - * all other resource strings are recursively applied to the widget tree. - * Prepend a '.' to the remainder string if there is no leading token. - */ - } else { - if (remainder[0] != '*' && remainder[0] != '.') { - XtAsprintf (©, ".%s", remainder); - XtFree (remainder); - remainder = copy; - } - indx = remainder; - _set_and_search (parent, indx, remainder, resource, value, - last_token, last_part); + if (remainder) { + last_token = _get_last_part (remainder, &last_part); + /* + * this case covers resources of only one level (eg. *background) + */ + if (remainder[0] == 0) { + _set_resource_values (w, resource, value, last_part); + if (last_token == '*') + _apply_values_to_children (parent, remainder, resource, + value, last_token, last_part); + /* + * all other resource strings are recursively applied to the 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); + remainder = copy; + } + indx = remainder; + _set_and_search (parent, indx, remainder, resource, value, + last_token, last_part); + } + + XtFree (remainder); + XtFree (last_part); } - - XtFree (remainder); - XtFree (last_part); } /* @@ -894,10 +902,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 +972,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 +983,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..83ffd4c 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 = NULL; Cardinal count; wc = XtClass(w); @@ -950,35 +949,41 @@ XtCacheRef *_XtGetResources( 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); - - /* Get names, classes for widget and ancestors */ - GetNamesAndClasses(w, names, classes); + if (names == NULL || classes == NULL) { + _XtAllocError(NULL); + } else { - /* Compile arg list into quarks */ - CacheArgs(args, num_args, typed_args, *num_typed_args, quark_cache, - XtNumber(quark_cache), &quark_args); + /* Get names, classes for widget and ancestors */ + GetNamesAndClasses(w, names, classes); - /* Get normal resources */ - LOCK_PROCESS; - cache_refs = GetResources(w, (char*)w, names, classes, - (XrmResourceList *) wc->core_class.resources, - wc->core_class.num_resources, quark_args, args, num_args, - typed_args, num_typed_args, XtIsWidget(w)); - - if (w->core.constraints != NULL) { - cwc = (ConstraintWidgetClass) XtClass(w->core.parent); - cache_refs_core = - GetResources(w, (char*)w->core.constraints, names, classes, - (XrmResourceList *) cwc->constraint_class.resources, - cwc->constraint_class.num_resources, - quark_args, args, num_args, typed_args, num_typed_args, False); - XtFree((char *)cache_refs_core); + /* Compile arg list into quarks */ + CacheArgs(args, num_args, typed_args, *num_typed_args, quark_cache, + XtNumber(quark_cache), &quark_args); + + /* Get normal resources */ + LOCK_PROCESS; + cache_refs = GetResources(w, (char*)w, names, classes, + (XrmResourceList *) wc->core_class.resources, + wc->core_class.num_resources, quark_args, args, num_args, + 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, + (XrmResourceList *) cwc->constraint_class.resources, + cwc->constraint_class.num_resources, + quark_args, args, num_args, typed_args, num_typed_args, False); + XtFree((char *)cache_refs_core); + } + FreeCache(quark_cache, quark_args); + UNLOCK_PROCESS; + XtStackFree((XtPointer)names, names_s); + XtStackFree((XtPointer)classes, classes_s); } - FreeCache(quark_cache, quark_args); - UNLOCK_PROCESS; - XtStackFree((XtPointer)names, names_s); - XtStackFree((XtPointer)classes, classes_s); return cache_refs; } /* _XtGetResources */ @@ -1011,35 +1016,37 @@ void _XtGetSubresources ( count++; /* make sure there's enough room for name and class */ names = (XrmName*) XtStackAlloc(count * sizeof(XrmName), names_s); classes = (XrmClass*) XtStackAlloc(count * sizeof(XrmClass), classes_s); - if (names == NULL || classes == NULL) _XtAllocError(NULL); - - /* Get full name, class of subobject */ - GetNamesAndClasses(w, names, classes); - count -= 2; - names[count] = StringToName(name); - classes[count] = StringToClass(class); - count++; - names[count] = NULLQUARK; - classes[count] = NULLQUARK; + if (names == NULL || classes == NULL) { + _XtAllocError(NULL); + } else { + /* Get full name, class of subobject */ + GetNamesAndClasses(w, names, classes); + count -= 2; + names[count] = StringToName(name); + classes[count] = StringToClass(class); + count++; + names[count] = NULLQUARK; + classes[count] = NULLQUARK; - /* Compile arg list into quarks */ - CacheArgs(args, num_args, typed_args, num_typed_args, - quark_cache, XtNumber(quark_cache), &quark_args); + /* Compile arg list into quarks */ + CacheArgs(args, num_args, typed_args, num_typed_args, + quark_cache, XtNumber(quark_cache), &quark_args); - /* Compile resource list if needed */ - if (((int) resources->resource_offset) >= 0) { - XrmCompileResourceListEphem(resources, num_resources); + /* Compile resource list if needed */ + if (((int) resources->resource_offset) >= 0) { + XrmCompileResourceListEphem(resources, num_resources); + } + table = _XtCreateIndirectionTable(resources, num_resources); + Resrc = GetResources(w, (char*)base, names, classes, table, num_resources, + quark_args, args, num_args, + typed_args, &ntyped_args, False); + FreeCache(quark_cache, quark_args); + XtFree((char *)table); + XtFree((char *)Resrc); + XtStackFree((XtPointer)names, names_s); + XtStackFree((XtPointer)classes, classes_s); + UNLOCK_APP(app); } - table = _XtCreateIndirectionTable(resources, num_resources); - Resrc = GetResources(w, (char*)base, names, classes, table, num_resources, - quark_args, args, num_args, - typed_args, &ntyped_args, False); - FreeCache(quark_cache, quark_args); - XtFree((char *)table); - XtFree((char *)Resrc); - XtStackFree((XtPointer)names, names_s); - XtStackFree((XtPointer)classes, classes_s); - UNLOCK_APP(app); } void XtGetSubresources ( @@ -1071,7 +1078,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 @@ -1091,17 +1098,24 @@ void _XtGetApplicationResources ( XtPerDisplay pd = _XtGetPerDisplay(_XtDefaultAppContext()->list[0]); names = (XrmName*) XtStackAlloc (2 * sizeof(XrmName), names_s); classes = (XrmClass*) XtStackAlloc (2 * sizeof(XrmClass), classes_s); - names[0] = pd->name; - names[1] = NULLQUARK; - classes[0] = pd->class; - classes[1] = NULLQUARK; + if (names == NULL || classes == NULL) { + _XtAllocError(NULL); + } else { + names[0] = pd->name; + names[1] = NULLQUARK; + classes[0] = pd->class; + 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); - GetNamesAndClasses(w, names, classes); + if (names == NULL || classes == NULL) { + _XtAllocError(NULL); + } else { + GetNamesAndClasses(w, names, classes); + } } /* Compile arg list into quarks */ 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 85443a5..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,9 +126,12 @@ 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], sensitive); + SetAncestorSensitive (children[i], (Boolean) sensitive); } } UNLOCK_APP(app); diff --git a/src/SetValues.c b/src/SetValues.c index 8108576..cbfd680 100644 --- a/src/SetValues.c +++ b/src/SetValues.c @@ -151,23 +151,26 @@ CallConstraintSetValues ( { Boolean redisplay = FALSE; XtSetValuesFunc set_values; - ConstraintWidgetClass superclass; if ((WidgetClass)class != constraintWidgetClass) { - if (class == NULL) + ConstraintWidgetClass superclass; + + if (class == NULL) { XtAppErrorMsg(XtWidgetToApplicationContext(current), "invalidClass","constraintSetValue",XtCXtToolkitError, "Subclass of Constraint required in CallConstraintSetValues", NULL, NULL); - LOCK_PROCESS; - superclass = (ConstraintWidgetClass) class->core_class.superclass; - UNLOCK_PROCESS; - redisplay = - CallConstraintSetValues(superclass, - current, request, new, args, num_args); + } else { + LOCK_PROCESS; + superclass = (ConstraintWidgetClass) class->core_class.superclass; + UNLOCK_PROCESS; + redisplay = + CallConstraintSetValues(superclass, + current, request, new, args, num_args); + } } LOCK_PROCESS; - set_values = class->constraint_class.set_values; + set_values = class ? class->constraint_class.set_values : NULL; UNLOCK_PROCESS; if (set_values) redisplay |= (*set_values) (current, request, new, args, &num_args); @@ -204,7 +207,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 +352,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..9527a6e 100644 --- a/src/Shell.c +++ b/src/Shell.c @@ -2014,6 +2014,7 @@ static XtGeometryResult RootGeometryManager( w->core.height = (Dimension) (oldheight); \ w->core.border_width = (Dimension) (oldborder_width); } + memset(&values, 0, sizeof(values)); if (mask & CWX) { if (w->core.x == request->x) mask &= (unsigned int) (~CWX); else { @@ -2981,7 +2982,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 +3028,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 +3071,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 +3127,6 @@ static void XtInteractPermission( { Widget w = (Widget) data; SessionShellWidget sw = (SessionShellWidget) data; - XtCheckpointToken token; XtCallbackProc callback; XtPointer client_data; @@ -3133,6 +3134,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 c9066b9..d1ca2ca 100644 --- a/src/TMaction.c +++ b/src/TMaction.c @@ -159,12 +159,11 @@ static void ReportUnboundActions( XtTranslations xlations, TMBindData bindData) { - TMSimpleStateTree stateTree = (TMSimpleStateTree)xlations->stateTreeTbl[0]; + TMSimpleStateTree stateTree; Cardinal num_unbound = 0; Cardinal num_params = 1; char* message; char messagebuf[1000]; - String params[1]; register Cardinal num_chars = 0; register Cardinal i, j; XtActionProc *procs; @@ -190,9 +189,10 @@ 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]; for (i=0; i < xlations->numStateTrees; i++) { if (bindData->simple.isComplex) procs = TMGetComplexBindEntry(bindData, i)->procs; @@ -225,12 +225,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) @@ -422,7 +422,7 @@ XtPointer _XtInitializeActionData( TMClassCache classCache; classCache = XtNew(TMClassCacheRec); - classCache->actions = CompileActionTable(actions, count, inPlace, True); + classCache->actions = CompileActionTable(actions, count, (Boolean) inPlace, True); classCache->bindCache = NULL; return (XtPointer)classCache; } @@ -607,8 +607,6 @@ void _XtBindActions( if ((xlations == NULL) || widget->core.being_destroyed) return; - stateTree = (TMSimpleStateTree)xlations->stateTreeTbl[0]; - for (i = 0; i < xlations->numStateTrees; i++) { stateTree = (TMSimpleStateTree)xlations->stateTreeTbl[i]; @@ -785,9 +783,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 +799,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 333e1cd..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); @@ -327,7 +326,7 @@ void XtRegisterGrabAction( } #endif /*DEBUG*/ - actionP->owner_events = owner_events; + actionP->owner_events = (Boolean) owner_events; actionP->event_mask = event_mask; actionP->pointer_mode = pointer_mode; actionP->keyboard_mode = keyboard_mode; diff --git a/src/TMkey.c b/src/TMkey.c index 7970f5a..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;j<temp->count;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); @@ -590,7 +591,7 @@ void XtTranslateKey( *keysym_return = NoSymbol; UNLOCK_APP(app); #else - XkbLookupKeySym(dpy, keycode, modifiers, modifiers_return, keysym_return); + XkbLookupKeySym(dpy, (KeyCode) keycode, modifiers, modifiers_return, keysym_return); #endif } @@ -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..9582b0c 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) @@ -653,25 +656,22 @@ static String FetchModifierToken( if (*str == '$') { *token_return = QMeta; str++; - return str; - } - if (*str == '^') { + } else if (*str == '^') { *token_return = QCtrl; str++; - return str; - } - str = ScanIdent(str); - if (start != str) { - char modStrbuf[100]; - char* modStr; - - modStr = XtStackAlloc ((size_t)(str - start + 1), modStrbuf); - if (modStr == NULL) _XtAllocError (NULL); - (void) memmove(modStr, start, (size_t) (str - start)); - modStr[str-start] = '\0'; - *token_return = XrmStringToQuark(modStr); - XtStackFree (modStr, modStrbuf); - return str; + } else { + str = ScanIdent(str); + if (start != str) { + char modStrbuf[100]; + char* modStr; + + modStr = XtStackAlloc ((size_t)(str - start + 1), modStrbuf); + if (modStr == NULL) _XtAllocError (NULL); + (void) memmove(modStr, start, (size_t) (str - start)); + modStr[str-start] = '\0'; + *token_return = XrmStringToQuark(modStr); + XtStackFree (modStr, modStrbuf); + } } return str; } @@ -684,7 +684,7 @@ static String ParseModifiers( register String start; Boolean notFlag, exclusive, keysymAsMod; Value maskBit; - XrmQuark Qmod; + XrmQuark Qmod = QNone; ScanWhitespace(str); start = str; @@ -956,7 +956,7 @@ static String ParseKeySym( { String start; char keySymNamebuf[100]; - char* keySymName; + char* keySymName = NULL; ScanWhitespace(str); @@ -993,7 +993,7 @@ static String ParseKeySym( event->event.eventCode = StringToKeySym(keySymName, error); event->event.eventCodeMask = (unsigned long) (~0L); } - if (*error) { + if (*error && keySymName) { /* We never get here when keySymName hasn't been allocated */ if (keySymName[0] == '<') { /* special case for common error */ @@ -1694,8 +1694,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 +1720,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 */ @@ -1772,9 +1773,11 @@ static String ParseActionSeq( ActionPtr *actionsP, Boolean *error) { - ActionPtr *nextActionP = actionsP; + ActionPtr *nextActionP; + + if ((nextActionP = actionsP) != NULL) + *actionsP = NULL; - *actionsP = NULL; while (*str != '\0' && !IsNewline(*str)) { register ActionPtr action; XrmQuark quark; @@ -1792,8 +1795,10 @@ static String ParseActionSeq( action->idx = _XtGetQuarkIndex(parseTree, quark); ScanWhitespace(str); - *nextActionP = action; - nextActionP = &action->next; + if (nextActionP) { + *nextActionP = action; + nextActionP = &action->next; + } } if (IsNewline(*str)) str++; ScanWhitespace(str); @@ -1839,21 +1844,18 @@ static String ParseTranslationTableProduction( String production = str; actionsP = NULL; - str = ParseEventSeq(str, &eventSeq, &actionsP,error); + str = ParseEventSeq(str, &eventSeq, &actionsP, error); if (*error == TRUE) { ShowProduction(production); - FreeEventSeq(eventSeq); - return (str); - } - ScanWhitespace(str); - str = ParseActionSeq(parseTree, str, actionsP, error); - if (*error == TRUE) { - ShowProduction(production); - FreeEventSeq(eventSeq); - return (str); + } else { + ScanWhitespace(str); + str = ParseActionSeq(parseTree, str, actionsP, error); + if (*error == TRUE) { + ShowProduction(production); + } else { + _XtAddEventSeqToStateTree(eventSeq, parseTree); + } } - - _XtAddEventSeqToStateTree(eventSeq, parseTree); FreeEventSeq(eventSeq); return (str); } @@ -1863,14 +1865,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 8624250..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 = @@ -716,7 +718,7 @@ _XtString _XtPrintXlations( } #endif /* TRACE_TM */ PrintState(sb, (TMStateTree)stateTree, branchHead, - includeRHS, accelWidget, XtDisplay(w)); + (Boolean) includeRHS, accelWidget, XtDisplay(w)); } XtStackFree((XtPointer)prints, (XtPointer)stackPrints); return (sb->start); @@ -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..0856909 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); } @@ -1770,7 +1765,8 @@ static XtTranslations UnmergeTranslations( else first = NULL; - if (xlations->composers[1]) { + if (xlations->composers[0] + && xlations->composers[1]) { second = UnmergeTranslations(widget, xlations->composers[1], unmergeXlations, (TMShortCard)(currIndex + @@ -1828,7 +1824,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 +2205,6 @@ void XtInstallAccelerators( { XtTranslations aXlations; _XtTranslateOp op; - _XtString buf; WIDGET_TO_APPCON(destination); /* @@ -2232,8 +2227,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 +2240,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/Threads.c b/src/Threads.c index ee19c2e..14954d0 100644 --- a/src/Threads.c +++ b/src/Threads.c @@ -199,8 +199,9 @@ AppUnlock(XtAppContext app) xmutex_unlock(app_lock->mutex); #else xthread_t self; - (void)self; self = xthread_self(); + (void)self; + xmutex_lock(app_lock->mutex); assert(xthread_equal(app_lock->holder, self)); if (app_lock->level != 0) { 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/VarGet.c b/src/VarGet.c index 1ac24cd..2736899 100644 --- a/src/VarGet.c +++ b/src/VarGet.c @@ -234,44 +234,46 @@ XtVaGetValues(Widget widget, ...) _XtCountVaList(var, &total_count, &typed_count); if (total_count != typed_count) { - args = (ArgList)__XtMalloc((unsigned)((size_t)(total_count - typed_count) - * sizeof(Arg))); + size_t limit = (size_t)(total_count - typed_count); + args = (ArgList)__XtMalloc((unsigned)(limit * sizeof(Arg))); } else args = NULL; /* for lint; really unused */ va_end(var); - va_start(var,widget); - for(attr = va_arg(var, String), count = 0 ; attr != NULL; - attr = va_arg(var, String)) { - if (strcmp(attr, XtVaTypedArg) == 0) { - typed_arg.name = va_arg(var, String); - typed_arg.type = va_arg(var, String); - typed_arg.value = va_arg(var, XtArgVal); - typed_arg.size = va_arg(var, int); - - if (resources == NULL) { - XtGetResourceList(XtClass(widget), &resources,&num_resources); - } - - GetTypedArg(widget, &typed_arg, resources, num_resources); - } else if (strcmp(attr, XtVaNestedList) == 0) { - if (resources == NULL) { - XtGetResourceList(XtClass(widget),&resources, &num_resources); + if (args != NULL) { + va_start(var,widget); + for(attr = va_arg(var, String), count = 0 ; attr != NULL; + attr = va_arg(var, String)) { + if (strcmp(attr, XtVaTypedArg) == 0) { + typed_arg.name = va_arg(var, String); + typed_arg.type = va_arg(var, String); + typed_arg.value = va_arg(var, XtArgVal); + typed_arg.size = va_arg(var, int); + + if (resources == NULL) { + XtGetResourceList(XtClass(widget), &resources,&num_resources); + } + + GetTypedArg(widget, &typed_arg, resources, num_resources); + } else if (strcmp(attr, XtVaNestedList) == 0) { + if (resources == NULL) { + XtGetResourceList(XtClass(widget),&resources, &num_resources); + } + + count += GetNestedArg(widget, va_arg(var, XtTypedArgList), + (args+count), resources, num_resources); + } else { + args[count].name = attr; + args[count].value = va_arg(var, XtArgVal); + count ++; } - - count += GetNestedArg(widget, va_arg(var, XtTypedArgList), - (args+count), resources, num_resources); - } else { - args[count].name = attr; - args[count].value = va_arg(var, XtArgVal); - count ++; } + va_end(var); } - va_end(var); XtFree((XtPointer)resources); - if (total_count != typed_count) { + if (args != NULL) { XtGetValues(widget, args, (Cardinal) count); XtFree((XtPointer)args); } diff --git a/src/Varargs.c b/src/Varargs.c index 619de5b..76bbeb9 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); } } @@ -350,7 +350,7 @@ _XtVaToArgList( ArgList args = (ArgList)NULL; XtTypedArg typed_arg; XtResourceList resources = (XtResourceList)NULL; - Cardinal num_resources; + Cardinal num_resources = 0; Boolean fetched_resource_list = False; if (max_count == 0) { @@ -360,44 +360,48 @@ _XtVaToArgList( } args = (ArgList)__XtMalloc((Cardinal)((size_t)(max_count * 2) * sizeof(Arg))); - for (count = max_count * 2; --count >= 0; ) - args[count].value = (XtArgVal) NULL; - count = 0; - - for(attr = va_arg(var, String) ; attr != NULL; - attr = va_arg(var, String)) { - if (strcmp(attr, XtVaTypedArg) == 0) { - typed_arg.name = va_arg(var, String); - typed_arg.type = va_arg(var, String); - typed_arg.value = va_arg(var, XtArgVal); - typed_arg.size = va_arg(var, int); - - /* if widget is NULL, typed args are ignored */ - if (widget != NULL) { - if (!fetched_resource_list) { - GetResources(widget, &resources, &num_resources); - fetched_resource_list = True; + if (args) { + for (count = max_count * 2; --count >= 0; ) + args[count].value = (XtArgVal) NULL; + count = 0; + + for(attr = va_arg(var, String) ; attr != NULL; + attr = va_arg(var, String)) { + if (strcmp(attr, XtVaTypedArg) == 0) { + typed_arg.name = va_arg(var, String); + typed_arg.type = va_arg(var, String); + typed_arg.value = va_arg(var, XtArgVal); + typed_arg.size = va_arg(var, int); + + /* if widget is NULL, typed args are ignored */ + if (widget != NULL) { + if (!fetched_resource_list) { + GetResources(widget, &resources, &num_resources); + fetched_resource_list = True; + } + count += TypedArgToArg(widget, &typed_arg, &args[count], + resources, num_resources, + &args[max_count + count]); } - count += TypedArgToArg(widget, &typed_arg, &args[count], - resources, num_resources, - &args[max_count + count]); - } - } else if (strcmp(attr, XtVaNestedList) == 0) { - if (widget != NULL) { - if (!fetched_resource_list) { - GetResources(widget, &resources, &num_resources); - fetched_resource_list = True; + } else if (strcmp(attr, XtVaNestedList) == 0) { + if (widget != NULL) { + if (!fetched_resource_list) { + GetResources(widget, &resources, &num_resources); + fetched_resource_list = True; + } } - } - count += NestedArgtoArg(widget, va_arg(var, XtTypedArgList), - &args[count], resources, num_resources, - &args[max_count + count]); - } else { - args[count].name = attr; - args[count].value = va_arg(var, XtArgVal); - count ++; + count += NestedArgtoArg(widget, va_arg(var, XtTypedArgList), + &args[count], resources, num_resources, + &args[max_count + count]); + } else { + args[count].name = attr; + args[count].value = va_arg(var, XtArgVal); + count ++; + } } + } else { + count = 0; } XtFree((XtPointer)resources); @@ -407,7 +411,7 @@ _XtVaToArgList( } /* Function Name: GetResources - * Description: Retreives the normal and constraint resources + * Description: Retrieves the normal and constraint resources * for this widget. * Arguments: widget - the widget. * RETURNED res_list - the list of resource for this widget |