Bool ResolveVirtualModifier(ExprDef *def,ExprResult *val_rtrn,VModInfo *info) { XkbNamesPtr names; names= info->xkb->names; if (def->op==ExprIdent) { register int i,bit; for (i=0,bit=1;i<XkbNumVirtualMods;i++,bit<<=1) { char *str1,*str2; str1= XkbAtomGetString(info->xkb->dpy,names->vmods[i]); str2= XkbAtomGetString(NULL,def->value.str); if ((info->available&bit)&& (uStrCaseCmp(str1,str2)==Equal)) { val_rtrn->uval= i; return True; } } } if (ExprResolveInteger(def,val_rtrn,NULL,NULL)) { if (val_rtrn->uval<XkbNumVirtualMods) return True; ERROR2("Illegal virtual modifier %d (must be 0..%d inclusive)\n", val_rtrn->uval,XkbNumVirtualMods-1); } return False; }
int LookupVModIndex( XPointer priv, Atom elem, Atom field, unsigned type, ExprResult * val_rtrn) { register int i; register char * fieldStr; register char * modStr; XkbDescPtr xkb; xkb= (XkbDescPtr)priv; if ((xkb==NULL)||(xkb->names==NULL)||(elem!=None)||(type!=TypeInt)) { return False; } fieldStr= XkbAtomGetString(xkb->dpy,field); if (fieldStr==NULL) return False; for (i=0;i<XkbNumVirtualMods;i++) { modStr= XkbAtomGetString(xkb->dpy,xkb->names->vmods[i]); if ((modStr!=NULL)&&(uStrCaseCmp(fieldStr,modStr)==0)) { val_rtrn->uval= i; return True; } } return False; }
/** * Returns the index of the given modifier in the xkb->names->vmods array. * * @param priv Pointer to the xkb data structure. * @param elem Must be None, otherwise return False. * @param field The Atom of the modifier's name (e.g. Atom for LAlt) * @param type Must be TypeInt, otherwise return False. * @param val_rtrn Set to the index of the modifier that matches. * * @return True on success, False otherwise. If False is returned, val_rtrn is * undefined. */ int LookupVModIndex(XPointer priv, Atom elem, Atom field, unsigned type, ExprResult * val_rtrn) { register int i; register char *fieldStr; register char *modStr; XkbDescPtr xkb; xkb = (XkbDescPtr) priv; if ((xkb == NULL) || (xkb->names == NULL) || (elem != None) || (type != TypeInt)) { return False; } /* get the actual name */ fieldStr = XkbAtomGetString(xkb->dpy, field); if (fieldStr == NULL) return False; /* For each named modifier, get the name and compare it to the one passed * in. If we get a match, return the index of the modifier. * The order of modifiers is the same as in the virtual_modifiers line in * the xkb_types section. */ for (i = 0; i < XkbNumVirtualMods; i++) { modStr = XkbAtomGetString(xkb->dpy, xkb->names->vmods[i]); if ((modStr != NULL) && (uStrCaseCmp(fieldStr, modStr) == 0)) { val_rtrn->uval = i; return True; } } return False; }
static int yyGetIdent(int first) { int ch,i,found; int rtrn = IDENT; buf[0] = first; nInBuf = 1; while ( ((ch=getc(yyin))!=EOF) && (isalnum(ch)||(ch=='_')) ) { if ( nInBuf < BUFSIZE - 1 ) buf[nInBuf++] = ch; } buf[nInBuf++] = '\0'; found= 0; for (i=0;(!found)&&(i<numKeywords);i++) { if (uStrCaseCmp(buf,keywords[i].keyword)==0) { rtrn= keywords[i].token; found= 1; } } if (!found) { if ( scanStr ) uFree( scanStr ); scanStr = (char *)uStringDup(buf); scanStrLine = lineNum; rtrn = IDENT; } if ( (ch!=EOF) && (!isspace(ch)) ) ungetc( ch, yyin ); else if ( ch=='\n' ) lineNum++; return rtrn; }
static int yyGetIdent(int first) { int ch, i, j, found; int rtrn = IDENT; scanBuf[0] = first; j = 1; while (((ch = scanchar()) != EOF) && (isalnum(ch) || (ch == '_'))) { if (j < sizeof(scanBuf) - 1) scanBuf[j++] = ch; } scanBuf[j++] = '\0'; found = 0; for (i = 0; (!found) && (i < numKeywords); i++) { if (uStrCaseCmp(scanBuf, keywords[i].keyword) == 0) { rtrn = keywords[i].token; found = 1; } } if (!found) { scanStrLine = lineNum; rtrn = IDENT; } if ((ch != EOF) && (!isspace(ch))) unscanchar(ch); else if (ch == '\n') lineNum++; return rtrn; }