summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Stone <daniel@fooishbar.org>2008-07-18 16:27:57 +0300
committerDaniel Stone <daniel@fooishbar.org>2009-01-22 15:08:56 +1100
commit133e0bd6f1cc147a2ddbbe1519d10300e7dbe669 (patch)
treeb58d395b127071188a4fcc983a9ef1274d5e778f
parentcc5c6d628aa0dc87c2cc9d063972e09ad747a596 (diff)
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 <daniel@fooishbar.org> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
-rw-r--r--include/xkbrules.h18
-rw-r--r--xkb/ddxLoad.c2
-rw-r--r--xkb/maprules.c96
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;(i<rules->num_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;i<rules->num_rules;i++,rule++) {
if (rule->model) _XkbFree(rule->model);