Not the most elegant fix, but will do for now.
Signed-off-by: Daniel Stone <daniel@fooishbar.org>
return NULL;
}
-ShapeDef *
-ShapeDeclCreate(xkb_atom_t name, OutlineDef * outlines)
-{
- ShapeDef *shape;
- OutlineDef *ol;
-
- shape = uTypedAlloc(ShapeDef);
- if (shape != NULL)
- {
- memset(shape, 0, sizeof(ShapeDef));
- shape->common.stmtType = StmtShapeDef;
- shape->common.next = NULL;
- shape->merge = MergeDefault;
- shape->name = name;
- shape->nOutlines = 0;
- shape->outlines = outlines;
- for (ol = outlines; ol != NULL; ol = (OutlineDef *) ol->common.next)
- {
- if (ol->nPoints > 0)
- shape->nOutlines++;
- }
- }
- return shape;
-}
-
-OutlineDef *
-OutlineCreate(xkb_atom_t field, ExprDef * points)
-{
- OutlineDef *outline;
- ExprDef *pt;
-
- outline = uTypedAlloc(OutlineDef);
- if (outline != NULL)
- {
- memset(outline, 0, sizeof(OutlineDef));
- outline->common.stmtType = StmtOutlineDef;
- outline->common.next = NULL;
- outline->field = field;
- outline->nPoints = 0;
- if (points->op == ExprCoord)
- {
- for (pt = points; pt != NULL; pt = (ExprDef *) pt->common.next)
- {
- outline->nPoints++;
- }
- }
- outline->points = points;
- }
- return outline;
-}
-
-KeyDef *
-KeyDeclCreate(char *name, ExprDef * expr)
-{
- KeyDef *key;
-
- key = uTypedAlloc(KeyDef);
- if (key != NULL)
- {
- memset(key, 0, sizeof(KeyDef));
- key->common.stmtType = StmtKeyDef;
- key->common.next = NULL;
- if (name)
- key->name = name;
- else
- key->expr = expr;
- }
- return key;
-}
-
-RowDef *
-RowDeclCreate(KeyDef * keys)
-{
- RowDef *row;
- KeyDef *key;
-
- row = uTypedAlloc(RowDef);
- if (row != NULL)
- {
- memset(row, 0, sizeof(RowDef));
- row->common.stmtType = StmtRowDef;
- row->common.next = NULL;
- row->nKeys = 0;
- row->keys = keys;
- for (key = keys; key != NULL; key = (KeyDef *) key->common.next)
- {
- if (key->common.stmtType == StmtKeyDef)
- row->nKeys++;
- }
- }
- return row;
-}
-
-SectionDef *
-SectionDeclCreate(xkb_atom_t name, RowDef * rows)
-{
- SectionDef *section;
- RowDef *row;
-
- section = uTypedAlloc(SectionDef);
- if (section != NULL)
- {
- memset(section, 0, sizeof(SectionDef));
- section->common.stmtType = StmtSectionDef;
- section->common.next = NULL;
- section->name = name;
- section->nRows = 0;
- section->rows = rows;
- for (row = rows; row != NULL; row = (RowDef *) row->common.next)
- {
- if (row->common.stmtType == StmtRowDef)
- section->nRows++;
- }
- }
- return section;
-}
-
-OverlayKeyDef *
-OverlayKeyCreate(char *under, char *over)
-{
- OverlayKeyDef *key;
-
- key = uTypedAlloc(OverlayKeyDef);
- if (key != NULL)
- {
- memset(key, 0, sizeof(OverlayKeyDef));
- key->common.stmtType = StmtOverlayKeyDef;
- strncpy(key->over, over, XkbKeyNameLength);
- strncpy(key->under, under, XkbKeyNameLength);
- free(over);
- free(under);
- }
- return key;
-}
-
-OverlayDef *
-OverlayDeclCreate(xkb_atom_t name, OverlayKeyDef * keys)
-{
- OverlayDef *ol;
- OverlayKeyDef *key;
-
- ol = uTypedAlloc(OverlayDef);
- if (ol != NULL)
- {
- memset(ol, 0, sizeof(OverlayDef));
- ol->common.stmtType = StmtOverlayDef;
- ol->name = name;
- ol->keys = keys;
- for (key = keys; key != NULL;
- key = (OverlayKeyDef *) key->common.next)
- {
- ol->nKeys++;
- }
- }
- return ol;
-}
-
-DoodadDef *
-DoodadCreate(unsigned type, xkb_atom_t name, VarDef * body)
-{
- DoodadDef *doodad;
-
- doodad = uTypedAlloc(DoodadDef);
- if (doodad != NULL)
- {
- memset(doodad, 0, sizeof(DoodadDef));
- doodad->common.stmtType = StmtDoodadDef;
- doodad->common.next = NULL;
- doodad->type = type;
- doodad->name = name;
- doodad->body = body;
- }
- return doodad;
-}
-
ExprDef *
AppendKeysymList(ExprDef * list, char *sym)
{
case StmtIndicatorNameDef:
FreeStmt(&u.ledName->name->common);
break;
- case StmtOutlineDef:
- FreeStmt(&u.outline->points->common);
- break;
- case StmtShapeDef:
- FreeStmt(&u.shape->outlines->common);
- break;
- case StmtKeyDef:
- free(u.key->name);
- FreeStmt(&u.key->expr->common);
- break;
- case StmtRowDef:
- FreeStmt(&u.row->keys->common);
- break;
- case StmtSectionDef:
- FreeStmt(&u.section->rows->common);
- break;
- case StmtOverlayKeyDef:
- break;
- case StmtOverlayDef:
- FreeStmt(&u.overlay->keys->common);
- break;
- case StmtDoodadDef:
- FreeStmt(&u.doodad->body->common);
- break;
default:
break;
}
extern ExprDef *CreateKeysymList(char * /* sym */
);
-extern ShapeDef *ShapeDeclCreate(xkb_atom_t /* name */ ,
- OutlineDef * /* outlines */
- );
-
-extern OutlineDef *OutlineCreate(xkb_atom_t /* field */ ,
- ExprDef * /* points */
- );
-
-extern KeyDef *KeyDeclCreate(char * /* name */ ,
- ExprDef * /* expr */
- );
-
-extern RowDef *RowDeclCreate(KeyDef * /* keys */
- );
-
-extern SectionDef *SectionDeclCreate(xkb_atom_t /* name */ ,
- RowDef * /* rows */
- );
-
-extern OverlayKeyDef *OverlayKeyCreate(char * /* under */ ,
- char * /* over */
- );
-
-extern OverlayDef *OverlayDeclCreate(xkb_atom_t /* name */ ,
- OverlayKeyDef * /* rows */
- );
-
-extern DoodadDef *DoodadCreate(unsigned /* type */ ,
- xkb_atom_t /* name */ ,
- VarDef * /* body */
- );
-
extern ExprDef *AppendKeysymList(ExprDef * /* list */ ,
char * /* sym */
);
#define StmtGroupCompatDef 11
#define StmtIndicatorMapDef 12
#define StmtIndicatorNameDef 13
-#define StmtOutlineDef 14
-#define StmtShapeDef 15
-#define StmtKeyDef 16
-#define StmtRowDef 17
-#define StmtSectionDef 18
-#define StmtOverlayKeyDef 19
-#define StmtOverlayDef 20
-#define StmtDoodadDef 21
#define FileSymInterp 100
Bool virtual;
} IndicatorNameDef;
-typedef struct _OutlineDef
-{
- ParseCommon common;
- xkb_atom_t field;
- int nPoints;
- ExprDef *points;
-} OutlineDef;
-
-typedef struct _ShapeDef
-{
- ParseCommon common;
- unsigned merge;
- xkb_atom_t name;
- int nOutlines;
- OutlineDef *outlines;
-} ShapeDef;
-
-typedef struct _KeyDef
-{
- ParseCommon common;
- unsigned defined;
- char *name;
- ExprDef *expr;
-} KeyDef;
-
-typedef struct _RowDef
-{
- ParseCommon common;
- int nKeys;
- KeyDef *keys;
-} RowDef;
-
-typedef struct _SectionDef
-{
- ParseCommon common;
- unsigned merge;
- xkb_atom_t name;
- int nRows;
- RowDef *rows;
-} SectionDef;
-
-typedef struct _OverlayKeyDef
-{
- ParseCommon common;
- char over[5];
- char under[5];
-} OverlayKeyDef;
-
-typedef struct _OverlayDef
-{
- ParseCommon common;
- unsigned merge;
- xkb_atom_t name;
- int nKeys;
- OverlayKeyDef *keys;
-} OverlayDef;
-
-typedef struct _DoodadDef
+typedef struct _IndicatorMapDef
{
ParseCommon common;
unsigned merge;
unsigned type;
xkb_atom_t name;
VarDef *body;
-} DoodadDef;
-
-/* IndicatorMapDef doesn't use the type field, but the rest of the fields
- need to be at the same offsets as in DoodadDef. Use #define to avoid
- any strict aliasing problems. */
-#define IndicatorMapDef DoodadDef
+} IndicatorMapDef;
typedef struct _XkbFile
{
IndicatorNameDef *ledName;
KeycodeDef *keyName;
KeyAliasDef *keyAlias;
- ShapeDef *shape;
- SectionDef *section;
- RowDef *row;
- KeyDef *key;
- OverlayDef *overlay;
- OverlayKeyDef *olKey;
- OutlineDef *outline;
- DoodadDef *doodad;
+ void *geom;
XkbFile *file;
}
%type <ival> Number Integer Float SignedNumber
%type <ledName> IndicatorNameDecl
%type <keyName> KeyNameDecl
%type <keyAlias> KeyAliasDecl
-%type <shape> ShapeDecl
-%type <section> SectionDecl
-%type <row> SectionBody SectionBodyItem
-%type <key> RowBody RowBodyItem Keys Key
-%type <overlay> OverlayDecl
-%type <olKey> OverlayKeyList OverlayKey
-%type <outline> OutlineList OutlineInList
-%type <doodad> DoodadDecl
+%type <geom> ShapeDecl SectionDecl SectionBody SectionBodyItem RowBody RowBodyItem
+%type <geom> Keys Key OverlayDecl OverlayKeyList OverlayKey OutlineList OutlineInList
+%type <geom> DoodadDecl
%type <file> XkbFile XkbMapConfigList XkbMapConfig XkbConfig
%type <file> XkbCompositeMap XkbCompMapList
%%
;
XkbMapConfigList : XkbMapConfigList XkbMapConfig
- { $$= (XkbFile *)AppendStmt(&$1->common,&$2->common); }
+ {
+ if (!$2)
+ $$= $1;
+ else
+ $$= (XkbFile *)AppendStmt(&$1->common,&$2->common);
+ }
| XkbMapConfig
{ $$= $1; }
;
XkbMapConfig : OptFlags FileType OptMapName OBRACE
DeclList
CBRACE SEMI
- { $$= CreateXKBFile($2,$3,$5,$1); }
+ {
+ if ($2 == XkmGeometryIndex)
+ $$= NULL;
+ else
+ $$= CreateXKBFile($2,$3,$5,$1);
+ }
;
XkbConfig : OptFlags FileType OptMapName DeclList
- { $$= CreateXKBFile($2,$3,$4,$1); }
+ {
+ if ($2 == XkmGeometryIndex)
+ $$= NULL;
+ else
+ $$= CreateXKBFile($2,$3,$4,$1);
+ }
;
}
| OptMergeMode ShapeDecl
{
- $2->merge= StmtSetMerge(&$2->common,$1);
- $$= &$2->common;
}
| OptMergeMode SectionDecl
{
- $2->merge= StmtSetMerge(&$2->common,$1);
- $$= &$2->common;
}
| OptMergeMode DoodadDecl
{
- $2->merge= StmtSetMerge(&$2->common,$1);
- $$= &$2->common;
}
| MergeMode STRING
{
;
ShapeDecl : SHAPE String OBRACE OutlineList CBRACE SEMI
- { $$= ShapeDeclCreate($2,(OutlineDef *)&$4->common); }
+ { $$= NULL; }
| SHAPE String OBRACE CoordList CBRACE SEMI
- {
- OutlineDef *outlines;
- outlines= OutlineCreate(None,$4);
- $$= ShapeDeclCreate($2,outlines);
- }
+ { $$= NULL; }
;
SectionDecl : SECTION String OBRACE SectionBody CBRACE SEMI
- { $$= SectionDeclCreate($2,$4); }
+ { $$= NULL; }
;
SectionBody : SectionBody SectionBodyItem
- { $$=(RowDef *)AppendStmt(&$1->common,&$2->common);}
+ { $$= NULL;}
| SectionBodyItem
- { $$= $1; }
+ { $$= NULL; }
;
SectionBodyItem : ROW OBRACE RowBody CBRACE SEMI
- { $$= RowDeclCreate($3); }
+ { $$= NULL; }
| VarDecl
- { $$= (RowDef *)$1; }
+ { $$= NULL; }
| DoodadDecl
- { $$= (RowDef *)$1; }
+ { $$= NULL; }
| IndicatorMapDecl
- { $$= (RowDef *)$1; }
+ { $$= NULL; }
| OverlayDecl
- { $$= (RowDef *)$1; }
+ { $$= NULL; }
;
RowBody : RowBody RowBodyItem
- { $$=(KeyDef *)AppendStmt(&$1->common,&$2->common);}
+ { $$= NULL;}
| RowBodyItem
- { $$= $1; }
+ { $$= NULL; }
;
RowBodyItem : KEYS OBRACE Keys CBRACE SEMI
- { $$= $3; }
+ { $$= NULL; }
| VarDecl
- { $$= (KeyDef *)$1; }
+ { $$= NULL; }
;
Keys : Keys COMMA Key
- { $$=(KeyDef *)AppendStmt(&$1->common,&$3->common);}
+ { $$= NULL; }
| Key
- { $$= $1; }
+ { $$= NULL; }
;
Key : KeyName
- { $$= KeyDeclCreate($1,NULL); }
+ { $$= NULL; }
| OBRACE ExprList CBRACE
- { $$= KeyDeclCreate(NULL,$2); }
+ { $$= NULL; }
;
OverlayDecl : OVERLAY String OBRACE OverlayKeyList CBRACE SEMI
- { $$= OverlayDeclCreate($2,$4); }
+ { $$= NULL; }
;
OverlayKeyList : OverlayKeyList COMMA OverlayKey
{
- $$= (OverlayKeyDef *)
- AppendStmt(&$1->common,&$3->common);
+ $$= NULL;
}
| OverlayKey
- { $$= $1; }
+ { $$= NULL; }
;
OverlayKey : KeyName EQUALS KeyName
- { $$= OverlayKeyCreate($1,$3); }
+ { $$= NULL; }
;
OutlineList : OutlineList COMMA OutlineInList
- { $$=(OutlineDef *)AppendStmt(&$1->common,&$3->common);}
+ { $$= NULL;}
| OutlineInList
- { $$= $1; }
+ { $$= NULL; }
;
OutlineInList : OBRACE CoordList CBRACE
- { $$= OutlineCreate(None,$2); }
+ { $$= NULL; }
| Ident EQUALS OBRACE CoordList CBRACE
- { $$= OutlineCreate($1,$4); }
+ { $$= NULL; }
| Ident EQUALS Expr
- { $$= OutlineCreate($1,$3); }
+ { $$= NULL; }
;
CoordList : CoordList COMMA Coord
- { $$= (ExprDef *)AppendStmt(&$1->common,&$3->common); }
+ { $$= NULL; }
| Coord
- { $$= $1; }
+ { $$= NULL; }
;
Coord : OBRACKET SignedNumber COMMA SignedNumber CBRACKET
- {
- ExprDef *expr;
- expr= ExprCreate(ExprCoord,TypeUnknown);
- expr->value.coord.x= $2;
- expr->value.coord.y= $4;
- $$= expr;
- }
+ { $$= NULL; }
;
DoodadDecl : DoodadType String OBRACE VarDeclList CBRACE SEMI
- { $$= DoodadCreate($1,$2,$4); }
+ { $$= NULL; }
;
DoodadType : TEXT { $$= 0; }
| SHAPE
{ $$= xkb_intern_atom("shape"); }
| ROW
- { $$= xkb_intern_atom("row"); }
+ { $$= None; }
| SECTION
- { $$= xkb_intern_atom("section"); }
+ { $$= None; }
| TEXT
- { $$= xkb_intern_atom("text"); }
+ { $$= None; }
;
OptMergeMode : MergeMode { $$= $1; }
| INTEGER { $$= scanInt*XkbGeomPtsPerMM; }
;
-Float : FLOAT { $$= scanInt; }
+Float : FLOAT { $$= 0; }
;
Integer : INTEGER { $$= scanInt; }