diff options
Diffstat (limited to 'src/TMprint.c')
-rw-r--r-- | src/TMprint.c | 277 |
1 files changed, 137 insertions, 140 deletions
diff --git a/src/TMprint.c b/src/TMprint.c index 082d80e..ef1b763 100644 --- a/src/TMprint.c +++ b/src/TMprint.c @@ -6,13 +6,13 @@ Copyright 1993 by Sun Microsystems, Inc. Mountain View, CA. All Rights Reserved -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies and that -both that copyright notice and this permission notice appear in +both that copyright notice and this permission notice appear in supporting documentation, and that the names of Digital or Sun not be used in advertising or publicity pertaining to distribution of the -software without specific, written prior permission. +software without specific, written prior permission. DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL @@ -81,7 +81,7 @@ if (sb->current - sb->start > (int)sb->max - STR_THRESHOLD) \ } #define ExpandForChars(sb, nchars ) \ - if (sb->current - sb->start > sb->max - STR_THRESHOLD - nchars) { \ + if ((unsigned)(sb->current - sb->start) > sb->max - STR_THRESHOLD - nchars) { \ String old = sb->start; \ sb->start = XtRealloc(old, \ (Cardinal)(sb->max += STR_INCAMOUNT + nchars)); \ @@ -90,18 +90,18 @@ if (sb->current - sb->start > (int)sb->max - STR_THRESHOLD) \ #define ExpandToFit(sb, more) \ { \ - int l = strlen(more); \ + size_t l = strlen(more); \ ExpandForChars(sb, l); \ } -static void PrintModifiers(sb, mask, mod) - TMStringBuf sb; - unsigned long mask, mod; +static void PrintModifiers( + TMStringBuf sb, + unsigned long mask, unsigned long mod) { Boolean notfirst = False; CHECK_STR_OVERFLOW(sb); - if (mask == ~0L && mod == 0) { + if (mask == ~0UL && mod == 0) { *sb->current++ = '!'; *sb->current = '\0'; return; @@ -140,9 +140,9 @@ static void PrintModifiers(sb, mask, mod) #undef PRINTMOD } -static void PrintEventType(sb, event) - TMStringBuf sb; - unsigned long event; +static void PrintEventType( + TMStringBuf sb, + unsigned long event) { CHECK_STR_OVERFLOW(sb); switch (event) { @@ -189,22 +189,22 @@ static void PrintEventType(sb, event) sb->current += strlen(sb->current); } -static void PrintCode(sb, mask, code) - TMStringBuf sb; - unsigned long mask, code; +static void PrintCode( + TMStringBuf sb, + unsigned long mask, unsigned long code) { CHECK_STR_OVERFLOW(sb); if (mask != 0) { - if (mask != (unsigned long)~0L) + if (mask != ~0UL) (void) sprintf(sb->current, "0x%lx:0x%lx", mask, code); else (void) sprintf(sb->current, /*"0x%lx"*/ "%d", (unsigned)code); sb->current += strlen(sb->current); } } -static void PrintKeysym(sb, keysym) - TMStringBuf sb; - KeySym keysym; +static void PrintKeysym( + TMStringBuf sb, + KeySym keysym) { String keysymName; @@ -213,7 +213,7 @@ static void PrintKeysym(sb, keysym) CHECK_STR_OVERFLOW(sb); keysymName = XKeysymToString(keysym); if (keysymName == NULL) - PrintCode(sb,(unsigned long)~0L,(unsigned long)keysym); + PrintCode(sb,~0UL,(unsigned long)keysym); else { ExpandToFit(sb, keysymName); strcpy(sb->current, keysymName); @@ -221,10 +221,10 @@ static void PrintKeysym(sb, keysym) } } -static void PrintAtom(sb, dpy, atom) - TMStringBuf sb; - Display *dpy; - Atom atom; +static void PrintAtom( + TMStringBuf sb, + Display *dpy, + Atom atom) { String atomName; @@ -233,7 +233,7 @@ static void PrintAtom(sb, dpy, atom) atomName = (dpy ? XGetAtomName(dpy, atom) : NULL); if (! atomName) - PrintCode(sb,(unsigned long)~0L,(unsigned long)atom); + PrintCode(sb,~0UL,(unsigned long)atom); else { ExpandToFit( sb, atomName ); strcpy(sb->current, atomName); @@ -242,9 +242,9 @@ static void PrintAtom(sb, dpy, atom) } } -static void PrintLateModifiers(sb, lateModifiers) - TMStringBuf sb; - LateBindingsPtr lateModifiers; +static void PrintLateModifiers( + TMStringBuf sb, + LateBindingsPtr lateModifiers) { for (; lateModifiers->keysym; lateModifiers++) { CHECK_STR_OVERFLOW(sb); @@ -262,11 +262,11 @@ static void PrintLateModifiers(sb, lateModifiers) } } -static void PrintEvent(sb, typeMatch, modMatch, dpy) - TMStringBuf sb; - register TMTypeMatch typeMatch; - register TMModifierMatch modMatch; - Display *dpy; +static void PrintEvent( + TMStringBuf sb, + register TMTypeMatch typeMatch, + register TMModifierMatch modMatch, + Display *dpy) { if (modMatch->standard) *sb->current++ = ':'; @@ -293,10 +293,10 @@ static void PrintEvent(sb, typeMatch, modMatch, dpy) } } -static void PrintParams(sb, params, num_params) - TMStringBuf sb; - String *params; - Cardinal num_params; +static void PrintParams( + TMStringBuf sb, + String *params, + Cardinal num_params) { register Cardinal i; for (i = 0; i<num_params; i++) { @@ -313,11 +313,11 @@ static void PrintParams(sb, params, num_params) *sb->current = '\0'; } -static void PrintActions(sb, actions, quarkTbl, accelWidget) - TMStringBuf sb; - register ActionPtr actions; - XrmQuark *quarkTbl; - Widget accelWidget; +static void PrintActions( + TMStringBuf sb, + register ActionPtr actions, + XrmQuark *quarkTbl, + Widget accelWidget) { while (actions != NULL) { String proc; @@ -345,12 +345,11 @@ static void PrintActions(sb, actions, quarkTbl, accelWidget) *sb->current = '\0'; } -static Boolean LookAheadForCycleOrMulticlick(state, state_return, countP, - nextLevelP) - register StatePtr state; - StatePtr *state_return; /* state to print, usually startState */ - int *countP; - StatePtr *nextLevelP; +static Boolean LookAheadForCycleOrMulticlick( + register StatePtr state, + StatePtr *state_return, /* state to print, usually startState */ + int *countP, + StatePtr *nextLevelP) { int repeatCount = 0; StatePtr startState = state; @@ -408,13 +407,13 @@ static Boolean LookAheadForCycleOrMulticlick(state, state_return, countP, return isCycle; } -static void PrintComplexState(sb, includeRHS, state, stateTree, accelWidget, dpy) - TMStringBuf sb; - Boolean includeRHS; - StatePtr state; - TMStateTree stateTree; - Widget accelWidget; - Display *dpy; +static void PrintComplexState( + TMStringBuf sb, + Boolean includeRHS, + StatePtr state, + TMStateTree stateTree, + Widget accelWidget, + Display *dpy) { int clickCount = 0; Boolean cycle; @@ -441,18 +440,18 @@ static void PrintComplexState(sb, includeRHS, state, stateTree, accelWidget, dpy while (! state->actions && ! state->isCycleEnd) state = state->nextLevel; /* should be trigger state */ } - + if (state->actions) { if (includeRHS) { CHECK_STR_OVERFLOW(sb); *sb->current++ = ':'; - PrintActions(sb, + PrintActions(sb, state->actions, ((TMSimpleStateTree)stateTree)->quarkTbl, accelWidget); *sb->current++ = '\n'; } - } + } else { if (state->nextLevel && !cycle && !clickCount) *sb->current++ = ','; @@ -463,7 +462,7 @@ static void PrintComplexState(sb, includeRHS, state, stateTree, accelWidget, dpy } } *sb->current = '\0'; - + /* print succeeding states */ if (state->nextLevel && !cycle && !clickCount) PrintComplexState(sb, includeRHS, state->nextLevel, @@ -476,14 +475,13 @@ typedef struct{ TMShortCard bIndex; }PrintRec, *Print; -static int FindNextMatch(printData, numPrints, xlations, - branchHead, nextLevel, startIndex) - PrintRec *printData; - TMShortCard numPrints; - XtTranslations xlations; - TMBranchHead branchHead; - StatePtr nextLevel; - TMShortCard startIndex; +static int FindNextMatch( + PrintRec *printData, + TMShortCard numPrints, + XtTranslations xlations, + TMBranchHead branchHead, + StatePtr nextLevel, + TMShortCard startIndex) { TMShortCard i; TMComplexStateTree stateTree; @@ -494,7 +492,7 @@ static int FindNextMatch(printData, numPrints, xlations, for (i = startIndex; noMatch && i < numPrints; i++) { stateTree = (TMComplexStateTree) xlations->stateTreeTbl[printData[i].tIndex]; - prBranchHead = + prBranchHead = &(stateTree->branchHeadTbl[printData[i].bIndex]); if ((prBranchHead->typeIndex == branchHead->typeIndex) && @@ -524,20 +522,20 @@ static int FindNextMatch(printData, numPrints, xlations, } return TM_NO_MATCH; } - -static void ProcessLaterMatches(printData,xlations,tIndex,bIndex,numPrintsRtn) - PrintRec *printData; - XtTranslations xlations; - TMShortCard tIndex; - int bIndex; - TMShortCard *numPrintsRtn; + +static void ProcessLaterMatches( + PrintRec *printData, + XtTranslations xlations, + TMShortCard tIndex, + int bIndex, + TMShortCard *numPrintsRtn) { - TMComplexStateTree stateTree; + TMComplexStateTree stateTree; int i, j; TMBranchHead branchHead, matchBranch = NULL; for (i = tIndex; i < (int)xlations->numStateTrees; i++) { - stateTree = (TMComplexStateTree)xlations->stateTreeTbl[i]; + stateTree = (TMComplexStateTree)xlations->stateTreeTbl[i]; if (i == tIndex) { matchBranch = &stateTree->branchHeadTbl[bIndex]; j = bIndex+1; @@ -554,7 +552,7 @@ static void ProcessLaterMatches(printData,xlations,tIndex,bIndex,numPrintsRtn) else state = NULL; if ((!branchHead->isSimple || branchHead->hasActions) && - (FindNextMatch(printData, + (FindNextMatch(printData, *numPrintsRtn, xlations, branchHead, @@ -569,18 +567,18 @@ static void ProcessLaterMatches(printData,xlations,tIndex,bIndex,numPrintsRtn) } } -static void ProcessStateTree(printData, xlations, tIndex, numPrintsRtn) - PrintRec *printData; - XtTranslations xlations; - TMShortCard tIndex; - TMShortCard *numPrintsRtn; +static void ProcessStateTree( + PrintRec *printData, + XtTranslations xlations, + TMShortCard tIndex, + TMShortCard *numPrintsRtn) { - TMComplexStateTree stateTree; + TMComplexStateTree stateTree; int i; TMBranchHead branchHead; - stateTree = (TMComplexStateTree)xlations->stateTreeTbl[tIndex]; - + stateTree = (TMComplexStateTree)xlations->stateTreeTbl[tIndex]; + for (i = 0, branchHead = stateTree->branchHeadTbl; i < (int)stateTree->numBranchHeads; i++, branchHead++) { @@ -590,7 +588,7 @@ static void ProcessStateTree(printData, xlations, tIndex, numPrintsRtn) else state = NULL; if (FindNextMatch(printData, *numPrintsRtn, xlations, branchHead, - (state ? state->nextLevel : NULL), 0) + (state ? state->nextLevel : NULL), 0) == TM_NO_MATCH) { if (!branchHead->isSimple || branchHead->hasActions) { printData[*numPrintsRtn].tIndex = tIndex; @@ -599,9 +597,9 @@ static void ProcessStateTree(printData, xlations, tIndex, numPrintsRtn) } LOCK_PROCESS; if (_XtGlobalTM.newMatchSemantics == False) - ProcessLaterMatches(printData, - xlations, - tIndex, + ProcessLaterMatches(printData, + xlations, + tIndex, i, numPrintsRtn); UNLOCK_PROCESS; @@ -609,13 +607,13 @@ static void ProcessStateTree(printData, xlations, tIndex, numPrintsRtn) } } -static void PrintState(sb, tree, branchHead, includeRHS, accelWidget, dpy) - TMStringBuf sb; - TMStateTree tree; - TMBranchHead branchHead; - Boolean includeRHS; - Widget accelWidget; - Display *dpy; +static void PrintState( + TMStringBuf sb, + TMStateTree tree, + TMBranchHead branchHead, + Boolean includeRHS, + Widget accelWidget, + Display *dpy) { TMComplexStateTree stateTree = (TMComplexStateTree)tree; LOCK_PROCESS; @@ -626,14 +624,14 @@ static void PrintState(sb, tree, branchHead, includeRHS, accelWidget, dpy) dpy); if (includeRHS) { ActionRec actRec; - + CHECK_STR_OVERFLOW(sb); *sb->current++ = ':'; actRec.idx = TMBranchMore(branchHead); actRec.num_params = 0; actRec.params = NULL; actRec.next = NULL; - PrintActions(sb, + PrintActions(sb, &actRec, stateTree->quarkTbl, accelWidget); @@ -681,7 +679,7 @@ String _XtPrintXlations( sb->max = 1000; maxPrints = 0; for (i = 0; i < xlations->numStateTrees; i++) - maxPrints += + maxPrints += ((TMSimpleStateTree)(xlations->stateTreeTbl[i]))->numBranchHeads; prints = (PrintRec *) XtStackAlloc(maxPrints * sizeof(PrintRec), stackPrints); @@ -693,9 +691,9 @@ String _XtPrintXlations( for (i = 0; i < numPrints; i++) { TMSimpleStateTree stateTree = (TMSimpleStateTree) xlations->stateTreeTbl[prints[i].tIndex]; - TMBranchHead branchHead = + TMBranchHead branchHead = &stateTree->branchHeadTbl[prints[i].bIndex]; -#ifdef TRACE_TM +#ifdef TRACE_TM TMComplexBindProcs complexBindProcs; if (hasAccel == False) { @@ -716,11 +714,11 @@ String _XtPrintXlations( #ifndef NO_MIT_HACKS /*ARGSUSED*/ -void _XtDisplayTranslations(widget, event, params, num_params) - Widget widget; - XEvent *event; - String *params; - Cardinal *num_params; +void _XtDisplayTranslations( + Widget widget, + XEvent *event, + String *params, + Cardinal *num_params) { String xString; @@ -733,16 +731,16 @@ void _XtDisplayTranslations(widget, event, params, num_params) } /*ARGSUSED*/ -void _XtDisplayAccelerators(widget, event, params, num_params) - Widget widget; - XEvent *event; - String *params; - Cardinal *num_params; +void _XtDisplayAccelerators( + Widget widget, + XEvent *event, + String *params, + Cardinal *num_params) { String xString; - - xString = _XtPrintXlations(widget, + + xString = _XtPrintXlations(widget, widget->core.accelerators, NULL, True); @@ -751,11 +749,11 @@ void _XtDisplayAccelerators(widget, event, params, num_params) } /*ARGSUSED*/ -void _XtDisplayInstalledAccelerators(widget, event, params, num_params) - Widget widget; - XEvent *event; - String *params; - Cardinal *num_params; +void _XtDisplayInstalledAccelerators( + Widget widget, + XEvent *event, + String *params, + Cardinal *num_params) { Widget eventWidget = XtWindowToWidget(event->xany.display, event->xany.window); @@ -779,7 +777,7 @@ void _XtDisplayInstalledAccelerators(widget, event, params, num_params) sb->max = 1000; maxPrints = 0; for (i = 0; i < xlations->numStateTrees; i++) - maxPrints += + maxPrints += ((TMSimpleStateTree)xlations->stateTreeTbl[i])->numBranchHeads; prints = (PrintRec *) XtStackAlloc(maxPrints * sizeof(PrintRec), stackPrints); @@ -798,13 +796,13 @@ void _XtDisplayInstalledAccelerators(widget, event, params, num_params) for (i = 0; i < numPrints; i++) { TMSimpleStateTree stateTree = (TMSimpleStateTree) xlations->stateTreeTbl[prints[i].tIndex]; - TMBranchHead branchHead = + TMBranchHead branchHead = &stateTree->branchHeadTbl[prints[i].bIndex]; complexBindProcs = TMGetComplexBindEntry(bindData, 0); - - PrintState(sb, (TMStateTree)stateTree, branchHead, True, - complexBindProcs[prints[i].tIndex].widget, + + PrintState(sb, (TMStateTree)stateTree, branchHead, True, + complexBindProcs[prints[i].tIndex].widget, XtDisplay(widget)); } XtStackFree((XtPointer)prints, (XtPointer)stackPrints); @@ -813,24 +811,24 @@ void _XtDisplayInstalledAccelerators(widget, event, params, num_params) } #endif /*NO_MIT_HACKS*/ -String _XtPrintActions(actions, quarkTbl) - register ActionRec *actions; - XrmQuark *quarkTbl; +String _XtPrintActions( + register ActionRec *actions, + XrmQuark *quarkTbl) { TMStringBufRec sbRec, *sb = &sbRec; - + sb->max = 1000; sb->current = sb->start = __XtMalloc((Cardinal)1000); - PrintActions(sb, + PrintActions(sb, actions, quarkTbl, (Widget)NULL); return sb->start; } -String _XtPrintState(stateTree, branchHead) - TMStateTree stateTree; - TMBranchHead branchHead; +String _XtPrintState( + TMStateTree stateTree, + TMBranchHead branchHead) { TMStringBufRec sbRec, *sb = &sbRec; @@ -842,9 +840,9 @@ String _XtPrintState(stateTree, branchHead) } -String _XtPrintEventSeq(eventSeq, dpy) - register EventSeqPtr eventSeq; - Display *dpy; +String _XtPrintEventSeq( + register EventSeqPtr eventSeq, + Display *dpy) { TMStringBufRec sbRec, *sb = &sbRec; TMTypeMatch typeMatch; @@ -858,7 +856,7 @@ String _XtPrintEventSeq(eventSeq, dpy) sb->max = 1000; for (i = 0; i < MAXSEQS && eventSeq != NULL && !cycle; - eventSeq = eventSeq->next, i++) + eventSeq = eventSeq->next, i++) { eventSeqs[i] = eventSeq; for (j = 0; j < i && !cycle; j++) @@ -867,9 +865,9 @@ String _XtPrintEventSeq(eventSeq, dpy) } LOCK_PROCESS; for (j = 0; j < i; j++) { - typeMatch = + typeMatch = TMGetTypeMatch(_XtGetTypeIndex(&eventSeqs[j]->event)); - modMatch = + modMatch = TMGetModifierMatch(_XtGetModifierIndex(&eventSeqs[j]->event)); PrintEvent(sb, typeMatch, modMatch, dpy); if (j < i) @@ -878,4 +876,3 @@ String _XtPrintEventSeq(eventSeq, dpy) UNLOCK_PROCESS; return sb->start; } - |