diff options
-rw-r--r-- | ChangeLog | 9 | ||||
-rw-r--r-- | configure.ac | 3 | ||||
-rw-r--r-- | src/XKBfileInt.h | 8 | ||||
-rw-r--r-- | src/maprules.c | 8 | ||||
-rw-r--r-- | src/xkbconfig.c | 80 | ||||
-rw-r--r-- | src/xkbmisc.c | 16 |
6 files changed, 79 insertions, 45 deletions
@@ -1,3 +1,12 @@ +2006-03-27 Daniel Stone <daniel@freedesktop.org> + + * configure.ac: + * src/XKBfileInt.h: + * src/xkbmisc.c: + * src/xkbconfig.c: + * src/maprules.c: + Fix horrendous botching of previous commit. + 2006-03-25 Daniel Stone <daniel@freedesktop.org> * src/XKBfileInt.h: diff --git a/configure.ac b/configure.ac index 9a35abe..dd6fde7 100644 --- a/configure.ac +++ b/configure.ac @@ -33,6 +33,9 @@ AM_CONFIG_HEADER(config.h) AC_PROG_CC AC_PROG_LIBTOOL +AC_CHECK_FUNC(strcasecmp, [], AC_DEFINE([NEED_STRCASECMP], 1, + [Do not have have `strcasecmp'.])) + # Check for dependencies PKG_CHECK_MODULES(XKBFILE, x11 kbproto) diff --git a/src/XKBfileInt.h b/src/XKBfileInt.h index a20094e..7eb81a0 100644 --- a/src/XKBfileInt.h +++ b/src/XKBfileInt.h @@ -68,7 +68,13 @@ extern char * _XkbDupString( char * /* old_str */ ); -#define _XkbStrCaseEqual(s1,s2) (strcmp(tolower(s1),tolower(s2))==0) +#define _XkbStrCaseEqual(s1,s2) (_XkbStrCaseCmp(s1,s2)==0) + +#ifdef NEED_STRCASECMP +extern int _XkbStrCaseCmp(char *s1, char *s2); +#else +#define _XkbStrCaseCmp strcasecmp +#endif _XFUNCPROTOEND diff --git a/src/maprules.c b/src/maprules.c index 2638071..7986896 100644 --- a/src/maprules.c +++ b/src/maprules.c @@ -1108,18 +1108,18 @@ int len,headingtype,extra_ndx = 0; tok = strtok(&(line.line[1]), " \t"); if (strcmp(tok,"model") == 0) headingtype = HEAD_MODEL; - else if (strcmp(tolower(tok),"layout") == 0) + else if (_XkbStrCaseCmp(tok,"layout") == 0) headingtype = HEAD_LAYOUT; - else if (strcmp(tolower(tok),"variant") == 0) + else if (_XkbStrCaseCmp(tok,"variant") == 0) headingtype = HEAD_VARIANT; - else if (strcmp(tolower(tok),"option") == 0) + else if (_XkbStrCaseCmp(tok,"option") == 0) headingtype = HEAD_OPTION; else { int i; headingtype = HEAD_EXTRA; extra_ndx= -1; for (i=0;(i<rules->num_extra)&&(extra_ndx<0);i++) { - if (_XkbStrCaseCmp(tolower(tok),rules->extra_names[i])) + if (_XkbStrCaseCmp(tok,rules->extra_names[i])) extra_ndx= i; } if (extra_ndx<0) { diff --git a/src/xkbconfig.c b/src/xkbconfig.c index bf2395d..7930979 100644 --- a/src/xkbconfig.c +++ b/src/xkbconfig.c @@ -256,32 +256,32 @@ int ch; static Bool AddCtrlByName(XkbConfigRtrnPtr rtrn,char *name,unsigned long *ctrls_rtrn) { - if ((strcmp(tolower(name),"repeat")==0)|| - (strcmp(tolower(name),"repeatkeys")==0)) + if ((_XkbStrCaseCmp(name,"repeat")==0)|| + (_XkbStrCaseCmp(name,"repeatkeys")==0)) *ctrls_rtrn= XkbRepeatKeysMask; - else if (strcmp(tolower(name),"slowkeys")==0) + else if (_XkbStrCaseCmp(name,"slowkeys")==0) *ctrls_rtrn= XkbSlowKeysMask; - else if (strcmp(tolower(name),"bouncekeys")==0) + else if (_XkbStrCaseCmp(name,"bouncekeys")==0) *ctrls_rtrn= XkbBounceKeysMask; - else if (strcmp(tolower(name),"stickykeys")==0) + else if (_XkbStrCaseCmp(name,"stickykeys")==0) *ctrls_rtrn= XkbStickyKeysMask; - else if (strcmp(tolower(name),"mousekeys")==0) + else if (_XkbStrCaseCmp(name,"mousekeys")==0) *ctrls_rtrn= XkbMouseKeysMask; - else if (strcmp(tolower(name),"mousekeysaccel")==0) + else if (_XkbStrCaseCmp(name,"mousekeysaccel")==0) *ctrls_rtrn= XkbMouseKeysAccelMask; - else if (strcmp(tolower(name),"accessxkeys")==0) + else if (_XkbStrCaseCmp(name,"accessxkeys")==0) *ctrls_rtrn= XkbAccessXKeysMask; - else if (strcmp(tolower(name),"accessxtimeout")==0) + else if (_XkbStrCaseCmp(name,"accessxtimeout")==0) *ctrls_rtrn= XkbAccessXTimeoutMask; - else if (strcmp(tolower(name),"accessxfeedback")==0) + else if (_XkbStrCaseCmp(name,"accessxfeedback")==0) *ctrls_rtrn= XkbAccessXFeedbackMask; - else if (strcmp(tolower(name),"audiblebell")==0) + else if (_XkbStrCaseCmp(name,"audiblebell")==0) *ctrls_rtrn= XkbAudibleBellMask; - else if (strcmp(tolower(name),"overlay1")==0) + else if (_XkbStrCaseCmp(name,"overlay1")==0) *ctrls_rtrn= XkbOverlay1Mask; - else if (strcmp(tolower(name),"overlay2")==0) + else if (_XkbStrCaseCmp(name,"overlay2")==0) *ctrls_rtrn= XkbOverlay2Mask; - else if (strcmp(tolower(name),"ignoregrouplock")==0) + else if (_XkbStrCaseCmp(name,"ignoregrouplock")==0) *ctrls_rtrn= XkbIgnoreGroupLockMask; else { rtrn->error= XkbCF_ExpectedControl; @@ -295,29 +295,29 @@ AddAXTimeoutOptByName( XkbConfigRtrnPtr rtrn, char * name, unsigned short * opts_rtrn) { - if (strcmp(tolower(name),"slowkeyspress")==0) + if (_XkbStrCaseCmp(name,"slowkeyspress")==0) *opts_rtrn= XkbAX_SKPressFBMask; - else if (strcmp(tolower(name),"slowkeysaccept")==0) + else if (_XkbStrCaseCmp(name,"slowkeysaccept")==0) *opts_rtrn= XkbAX_SKAcceptFBMask; - else if (strcmp(tolower(name),"feature")==0) + else if (_XkbStrCaseCmp(name,"feature")==0) *opts_rtrn= XkbAX_FeatureFBMask; - else if (strcmp(tolower(name),"slowwarn")==0) + else if (_XkbStrCaseCmp(name,"slowwarn")==0) *opts_rtrn= XkbAX_SlowWarnFBMask; - else if (strcmp(tolower(name),"indicator")==0) + else if (_XkbStrCaseCmp(name,"indicator")==0) *opts_rtrn= XkbAX_IndicatorFBMask; - else if (strcmp(tolower(name),"stickykeys")==0) + else if (_XkbStrCaseCmp(name,"stickykeys")==0) *opts_rtrn= XkbAX_StickyKeysFBMask; - else if (strcmp(tolower(name),"twokeys")==0) + else if (_XkbStrCaseCmp(name,"twokeys")==0) *opts_rtrn= XkbAX_TwoKeysMask; - else if (strcmp(tolower(name),"latchtolock")==0) + else if (_XkbStrCaseCmp(name,"latchtolock")==0) *opts_rtrn= XkbAX_LatchToLockMask; - else if (strcmp(tolower(name),"slowkeysrelease")==0) + else if (_XkbStrCaseCmp(name,"slowkeysrelease")==0) *opts_rtrn= XkbAX_SKReleaseFBMask; - else if (strcmp(tolower(name),"slowkeysreject")==0) + else if (_XkbStrCaseCmp(name,"slowkeysreject")==0) *opts_rtrn= XkbAX_SKRejectFBMask; - else if (strcmp(tolower(name),"bouncekeysreject")==0) + else if (_XkbStrCaseCmp(name,"bouncekeysreject")==0) *opts_rtrn= XkbAX_BKRejectFBMask; - else if (strcmp(tolower(name),"dumbbell")==0) + else if (_XkbStrCaseCmp(name,"dumbbell")==0) *opts_rtrn= XkbAX_DumbBellFBMask; else { rtrn->error= XkbCF_ExpectedControl; @@ -351,22 +351,22 @@ XkbCFAddModByName( XkbConfigRtrnPtr rtrn, last->merge= merge; last->name= NULL; } - if (strcmp(tolower(name),"shift")==0) + if (_XkbStrCaseCmp(name,"shift")==0) last->mods|= ShiftMask; - else if (strcmp(tolower(name),"lock")==0) + else if (_XkbStrCaseCmp(name,"lock")==0) last->mods|= LockMask; - else if ((strcmp(tolower(name),"control")==0)|| - (strcmp(tolower(name),"ctrl")==0)) + else if ((_XkbStrCaseCmp(name,"control")==0)|| + (_XkbStrCaseCmp(name,"ctrl")==0)) last->mods|= ControlMask; - else if (strcmp(tolower(name),"mod1")==0) + else if (_XkbStrCaseCmp(name,"mod1")==0) last->mods|= Mod1Mask; - else if (strcmp(tolower(name),"mod2")==0) + else if (_XkbStrCaseCmp(name,"mod2")==0) last->mods|= Mod2Mask; - else if (strcmp(tolower(name),"mod3")==0) + else if (_XkbStrCaseCmp(name,"mod3")==0) last->mods|= Mod3Mask; - else if (strcmp(tolower(name),"mod4")==0) + else if (_XkbStrCaseCmp(name,"mod4")==0) last->mods|= Mod4Mask; - else if (strcmp(tolower(name),"mod5")==0) + else if (_XkbStrCaseCmp(name,"mod5")==0) last->mods|= Mod5Mask; else { if (last->name!=NULL) { @@ -796,11 +796,11 @@ unsigned what; if (tok!=XkbCF_Integer) { Bool ok= False; if ((onoff)&&(tok==XkbCF_Ident)&&(val.str!=NULL)) { - if (strcmp(tolower(val.str),"on")) { + if (_XkbStrCaseCmp(val.str,"on")) { val.ival= onoff; ok= True; } - else if (strcmp(tolower(val.str),"off")) { + else if (_XkbStrCaseCmp(val.str,"off")) { val.ival= 0; ok= True; } @@ -826,10 +826,10 @@ unsigned what; } tok= XkbCFScan(file,&val,rtrn); if (tok==XkbCF_Ident) { - if (strcmp(tolower(val.str),"wrap")==0) { + if (_XkbStrCaseCmp(val.str,"wrap")==0) { rtrn->groups_wrap= XkbSetGroupInfo(0,XkbWrapIntoRange,0); } - else if (strcmp(tolower(val.str),"clamp")==0) { + else if (_XkbStrCaseCmp(val.str,"clamp")==0) { rtrn->groups_wrap= XkbSetGroupInfo(0,XkbClampIntoRange,0); } else { @@ -1280,7 +1280,7 @@ XkbConfigFieldsPtr tmp; XkbConfigFieldPtr f; for (i=0,f=tmp->fields;(i<tmp->num_fields)&&(!done);i++,f++) { - if (strcmp(tolower(val.str),f->field)!=0) + if (_XkbStrCaseCmp(val.str,f->field)!=0) continue; if ((*tmp->parser)(file,tmp,f,xkb,rtrn)) done= True; diff --git a/src/xkbmisc.c b/src/xkbmisc.c index 01f6174..0116b5f 100644 --- a/src/xkbmisc.c +++ b/src/xkbmisc.c @@ -659,3 +659,19 @@ XkbNameMatchesPattern(char *name,char *ptrn) /* if we get here, the pattern is exhausted (-:just like me:-) */ return (name[0]=='\0'); } + +#ifdef NEED_STRCASECMP +_X_HIDDEN int +_XkbStrCaseCmp(char *str1,char *str2) +{ + const u_char *us1 = (const u_char *)str1, *us2 = (const u_char *)str2; + + while (tolower(*us1) == tolower(*us2)) { + if (*us1++ == '\0') + return (0); + us2++; + } + + return (tolower(*us1) - tolower(*us2)); +} +#endif |