From 133e0bd6f1cc147a2ddbbe1519d10300e7dbe669 Mon Sep 17 00:00:00 2001 From: Daniel Stone Date: Fri, 18 Jul 2008 16:27:57 +0300 Subject: XKB: Remove 'extra' functionality from rules parsing When we find something weird in the rules, don't stash it as an extra freeform component, just state that the rules file is likely broken and move on with our lives. Signed-off-by: Daniel Stone Signed-off-by: Peter Hutterer --- include/xkbrules.h | 18 +--------- xkb/ddxLoad.c | 2 +- xkb/maprules.c | 96 +++++++----------------------------------------------- 3 files changed, 14 insertions(+), 102 deletions(-) diff --git a/include/xkbrules.h b/include/xkbrules.h index e8917f076..0001481cd 100644 --- a/include/xkbrules.h +++ b/include/xkbrules.h @@ -42,10 +42,6 @@ typedef struct _XkbRF_VarDefs { char * layout; char * variant; char * options; - unsigned short sz_extra; - unsigned short num_extra; - char * extra_names; - char ** extra_values; } XkbRF_VarDefsRec,*XkbRF_VarDefsPtr; typedef struct _XkbRF_VarDesc { @@ -94,10 +90,6 @@ typedef struct _XkbRF_Rules { XkbRF_DescribeVarsRec layouts; XkbRF_DescribeVarsRec variants; XkbRF_DescribeVarsRec options; - unsigned short sz_extra; - unsigned short num_extra; - char ** extra_names; - XkbRF_DescribeVarsPtr extra; unsigned short sz_rules; unsigned short num_rules; @@ -148,11 +140,6 @@ extern _X_EXPORT XkbRF_VarDescPtr XkbRF_AddVarDescCopy( XkbRF_VarDescPtr /* copy_from */ ); -extern _X_EXPORT XkbRF_DescribeVarsPtr XkbRF_AddVarToDescribe( - XkbRF_RulesPtr /* rules */, - char * /* name */ -); - extern _X_EXPORT Bool XkbRF_LoadDescriptions( FILE * /* file */, XkbRF_RulesPtr /* rules */ @@ -171,10 +158,7 @@ extern _X_EXPORT XkbRF_RulesPtr XkbRF_Load( Bool /* wantRules */ ); -extern _X_EXPORT XkbRF_RulesPtr XkbRF_Create( - int /* sz_rules */, - int /* sz_extra */ -); +extern _X_EXPORT XkbRF_RulesPtr XkbRF_Create(void); /***====================================================================***/ diff --git a/xkb/ddxLoad.c b/xkb/ddxLoad.c index c24b2cc2f..8d7f8377b 100644 --- a/xkb/ddxLoad.c +++ b/xkb/ddxLoad.c @@ -404,7 +404,7 @@ XkbRF_RulesPtr rules; return False; } - rules = XkbRF_Create(0, 0); + rules = XkbRF_Create(); if (!rules) { LogMessage(X_ERROR, "XKB: Couldn't create rules struct\n"); fclose(file); diff --git a/xkb/maprules.c b/xkb/maprules.c index b56055f5d..6dfcc9975 100644 --- a/xkb/maprules.c +++ b/xkb/maprules.c @@ -1019,41 +1019,13 @@ XkbRF_VarDescPtr nd; return nd; } -XkbRF_DescribeVarsPtr -XkbRF_AddVarToDescribe(XkbRF_RulesPtr rules,char *name) -{ - if (rules->sz_extra<1) { - rules->num_extra= 0; - rules->sz_extra= 1; - rules->extra_names= _XkbTypedCalloc(rules->sz_extra,char *); - rules->extra= _XkbTypedCalloc(rules->sz_extra, XkbRF_DescribeVarsRec); - } - else if (rules->num_extra>=rules->sz_extra) { - rules->sz_extra*= 2; - rules->extra_names= _XkbTypedRealloc(rules->extra_names,rules->sz_extra, - char *); - rules->extra=_XkbTypedRealloc(rules->extra, rules->sz_extra, - XkbRF_DescribeVarsRec); - } - if ((!rules->extra_names)||(!rules->extra)) { - DebugF("allocation error in extra parts\n"); - rules->sz_extra= rules->num_extra= 0; - rules->extra_names= NULL; - rules->extra= NULL; - return NULL; - } - rules->extra_names[rules->num_extra]= _XkbDupString(name); - bzero(&rules->extra[rules->num_extra],sizeof(XkbRF_DescribeVarsRec)); - return &rules->extra[rules->num_extra++]; -} - Bool XkbRF_LoadDescriptions(FILE *file,XkbRF_RulesPtr rules) { InputLine line; XkbRF_VarDescRec tmp; char *tok; -int len,headingtype,extra_ndx = 0; +int len,headingtype; bzero((char *)&tmp, sizeof(XkbRF_VarDescRec)); headingtype = HEAD_NONE; @@ -1069,23 +1041,13 @@ int len,headingtype,extra_ndx = 0; headingtype = HEAD_VARIANT; else if (strcasecmp(tok,"option") == 0) headingtype = HEAD_OPTION; - else { - int i; - headingtype = HEAD_EXTRA; - extra_ndx= -1; - for (i=0;(inum_extra)&&(extra_ndx<0);i++) { - if (!strcasecmp(tok,rules->extra_names[i])) - extra_ndx= i; - } - if (extra_ndx<0) { - XkbRF_DescribeVarsPtr var; - DebugF("Extra heading \"%s\" encountered\n",tok); - var= XkbRF_AddVarToDescribe(rules,tok); - if (var) - extra_ndx= var-rules->extra; - else headingtype= HEAD_NONE; - } - } + else { + ErrorF("Broken rules file: unknown type for line %s\n", + line.line); + ErrorF("Not parsing rules file further\n"); + FreeInputLine(&line); + return False; + } continue; } @@ -1129,17 +1091,13 @@ int len,headingtype,extra_ndx = 0; case HEAD_OPTION: XkbRF_AddVarDescCopy(&rules->options,&tmp); break; - case HEAD_EXTRA: - XkbRF_AddVarDescCopy(&rules->extra[extra_ndx],&tmp); - break; } } FreeInputLine(&line); if ((rules->models.num_desc==0) && (rules->layouts.num_desc==0) && - (rules->variants.num_desc==0) && (rules->options.num_desc==0) && - (rules->num_extra==0)) { + (rules->variants.num_desc==0) && (rules->options.num_desc==0)) return False; - } + return True; } @@ -1199,31 +1157,9 @@ XkbRF_RulesPtr rules; } XkbRF_RulesPtr -XkbRF_Create(int szRules,int szExtra) +XkbRF_Create(void) { -XkbRF_RulesPtr rules; - - if ((rules=_XkbTypedCalloc(1,XkbRF_RulesRec))==NULL) - return NULL; - if (szRules>0) { - rules->sz_rules= szRules; - rules->rules= _XkbTypedCalloc(rules->sz_rules,XkbRF_RuleRec); - if (!rules->rules) { - _XkbFree(rules); - return NULL; - } - } - if (szExtra>0) { - rules->sz_extra= szExtra; - rules->extra= _XkbTypedCalloc(rules->sz_extra,XkbRF_DescribeVarsRec); - if (!rules->extra) { - if (rules->rules) - _XkbFree(rules->rules); - _XkbFree(rules); - return NULL; - } - } - return rules; + return _XkbTypedCalloc(1, XkbRF_RulesRec); } /***====================================================================***/ @@ -1259,14 +1195,6 @@ XkbRF_GroupPtr group; XkbRF_ClearVarDescriptions(&rules->layouts); XkbRF_ClearVarDescriptions(&rules->variants); XkbRF_ClearVarDescriptions(&rules->options); - if (rules->extra) { - for (i = 0; i < rules->num_extra; i++) { - XkbRF_ClearVarDescriptions(&rules->extra[i]); - } - _XkbFree(rules->extra); - rules->num_extra= rules->sz_extra= 0; - rules->extra= NULL; - } if (rules->rules) { for (i=0,rule=rules->rules;inum_rules;i++,rule++) { if (rule->model) _XkbFree(rule->model); -- cgit v1.2.3