2006-11-25 13:07:29 -07:00
|
|
|
/************************************************************
|
|
|
|
Copyright (c) 1994 by Silicon Graphics Computer Systems, Inc.
|
|
|
|
|
|
|
|
Permission to use, copy, modify, and distribute this
|
|
|
|
software and its documentation for any purpose and without
|
|
|
|
fee is hereby granted, provided that the above copyright
|
|
|
|
notice appear in all copies and that both that copyright
|
|
|
|
notice and this permission notice appear in supporting
|
|
|
|
documentation, and that the name of Silicon Graphics not be
|
|
|
|
used in advertising or publicity pertaining to distribution
|
|
|
|
of the software without specific prior written permission.
|
|
|
|
Silicon Graphics makes no representation about the suitability
|
|
|
|
of this software for any purpose. It is provided "as is"
|
|
|
|
without any express or implied warranty.
|
|
|
|
|
|
|
|
SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
|
|
|
|
SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
|
|
AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
|
|
|
|
GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
|
|
|
|
DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
|
|
|
|
DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
|
|
|
|
OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
|
|
|
|
THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
|
|
|
|
|
|
********************************************************/
|
|
|
|
|
|
|
|
#define DEBUG_VAR parseDebug
|
|
|
|
#include "parseutils.h"
|
|
|
|
#include "xkbpath.h"
|
|
|
|
#include <X11/keysym.h>
|
|
|
|
#include <X11/extensions/XKBgeom.h>
|
|
|
|
#include <X11/Xalloca.h>
|
2011-01-11 13:56:40 -07:00
|
|
|
#include <limits.h>
|
|
|
|
#include <stdlib.h>
|
2006-11-25 13:07:29 -07:00
|
|
|
|
2011-01-11 13:56:40 -07:00
|
|
|
XkbFile *rtrnValue;
|
2006-11-25 13:07:29 -07:00
|
|
|
|
|
|
|
ParseCommon *
|
2011-01-11 13:56:40 -07:00
|
|
|
AppendStmt(ParseCommon * to, ParseCommon * append)
|
2006-11-25 13:07:29 -07:00
|
|
|
{
|
2011-01-11 13:56:40 -07:00
|
|
|
ParseCommon *start = to;
|
2006-11-25 13:07:29 -07:00
|
|
|
|
2011-01-11 13:56:40 -07:00
|
|
|
if (append == NULL)
|
|
|
|
return to;
|
|
|
|
while ((to != NULL) && (to->next != NULL))
|
|
|
|
{
|
|
|
|
to = to->next;
|
2006-11-25 13:07:29 -07:00
|
|
|
}
|
2011-01-11 13:56:40 -07:00
|
|
|
if (to)
|
|
|
|
{
|
|
|
|
to->next = append;
|
|
|
|
return start;
|
2006-11-25 13:07:29 -07:00
|
|
|
}
|
|
|
|
return append;
|
|
|
|
}
|
|
|
|
|
|
|
|
ExprDef *
|
2011-01-11 13:56:40 -07:00
|
|
|
ExprCreate(unsigned op, unsigned type)
|
|
|
|
{
|
|
|
|
ExprDef *expr;
|
|
|
|
expr = uTypedAlloc(ExprDef);
|
|
|
|
if (expr)
|
|
|
|
{
|
|
|
|
expr->common.stmtType = StmtExpr;
|
|
|
|
expr->common.next = NULL;
|
|
|
|
expr->op = op;
|
|
|
|
expr->type = type;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
FATAL("Couldn't allocate expression in parser\n");
|
|
|
|
/* NOTREACHED */
|
2006-11-25 13:07:29 -07:00
|
|
|
}
|
|
|
|
return expr;
|
|
|
|
}
|
|
|
|
|
|
|
|
ExprDef *
|
2011-01-11 13:56:40 -07:00
|
|
|
ExprCreateUnary(unsigned op, unsigned type, ExprDef * child)
|
|
|
|
{
|
|
|
|
ExprDef *expr;
|
|
|
|
expr = uTypedAlloc(ExprDef);
|
|
|
|
if (expr)
|
|
|
|
{
|
|
|
|
expr->common.stmtType = StmtExpr;
|
|
|
|
expr->common.next = NULL;
|
|
|
|
expr->op = op;
|
|
|
|
expr->type = type;
|
|
|
|
expr->value.child = child;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
FATAL("Couldn't allocate expression in parser\n");
|
|
|
|
/* NOTREACHED */
|
2006-11-25 13:07:29 -07:00
|
|
|
}
|
|
|
|
return expr;
|
|
|
|
}
|
|
|
|
|
|
|
|
ExprDef *
|
2011-01-11 13:56:40 -07:00
|
|
|
ExprCreateBinary(unsigned op, ExprDef * left, ExprDef * right)
|
|
|
|
{
|
|
|
|
ExprDef *expr;
|
|
|
|
expr = uTypedAlloc(ExprDef);
|
|
|
|
if (expr)
|
|
|
|
{
|
|
|
|
expr->common.stmtType = StmtExpr;
|
|
|
|
expr->common.next = NULL;
|
|
|
|
expr->op = op;
|
|
|
|
if ((op == OpAssign) || (left->type == TypeUnknown))
|
|
|
|
expr->type = right->type;
|
|
|
|
else if ((left->type == right->type) || (right->type == TypeUnknown))
|
|
|
|
expr->type = left->type;
|
|
|
|
else
|
|
|
|
expr->type = TypeUnknown;
|
|
|
|
expr->value.binary.left = left;
|
|
|
|
expr->value.binary.right = right;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
FATAL("Couldn't allocate expression in parser\n");
|
|
|
|
/* NOTREACHED */
|
2006-11-25 13:07:29 -07:00
|
|
|
}
|
|
|
|
return expr;
|
|
|
|
}
|
|
|
|
|
|
|
|
KeycodeDef *
|
2011-01-11 13:56:40 -07:00
|
|
|
KeycodeCreate(char *name, ExprDef * value)
|
2006-11-25 13:07:29 -07:00
|
|
|
{
|
2011-01-11 13:56:40 -07:00
|
|
|
KeycodeDef *def;
|
2006-11-25 13:07:29 -07:00
|
|
|
|
2011-01-11 13:56:40 -07:00
|
|
|
def = uTypedAlloc(KeycodeDef);
|
|
|
|
if (def)
|
|
|
|
{
|
|
|
|
def->common.stmtType = StmtKeycodeDef;
|
|
|
|
def->common.next = NULL;
|
|
|
|
strncpy(def->name, name, XkbKeyNameLength);
|
|
|
|
def->name[XkbKeyNameLength] = '\0';
|
|
|
|
def->value = value;
|
2006-11-25 13:07:29 -07:00
|
|
|
}
|
2011-01-11 13:56:40 -07:00
|
|
|
else
|
|
|
|
{
|
|
|
|
FATAL("Couldn't allocate key name definition in parser\n");
|
|
|
|
/* NOTREACHED */
|
2006-11-25 13:07:29 -07:00
|
|
|
}
|
|
|
|
return def;
|
|
|
|
}
|
|
|
|
|
|
|
|
KeyAliasDef *
|
2011-01-11 13:56:40 -07:00
|
|
|
KeyAliasCreate(char *alias, char *real)
|
2006-11-25 13:07:29 -07:00
|
|
|
{
|
2011-01-11 13:56:40 -07:00
|
|
|
KeyAliasDef *def;
|
2006-11-25 13:07:29 -07:00
|
|
|
|
2011-01-11 13:56:40 -07:00
|
|
|
def = uTypedAlloc(KeyAliasDef);
|
|
|
|
if (def)
|
|
|
|
{
|
|
|
|
def->common.stmtType = StmtKeyAliasDef;
|
|
|
|
def->common.next = NULL;
|
|
|
|
strncpy(def->alias, alias, XkbKeyNameLength);
|
|
|
|
def->alias[XkbKeyNameLength] = '\0';
|
|
|
|
strncpy(def->real, real, XkbKeyNameLength);
|
|
|
|
def->real[XkbKeyNameLength] = '\0';
|
2006-11-25 13:07:29 -07:00
|
|
|
}
|
2011-01-11 13:56:40 -07:00
|
|
|
else
|
|
|
|
{
|
|
|
|
FATAL("Couldn't allocate key alias definition in parser\n");
|
|
|
|
/* NOTREACHED */
|
2006-11-25 13:07:29 -07:00
|
|
|
}
|
|
|
|
return def;
|
|
|
|
}
|
|
|
|
|
|
|
|
VModDef *
|
2011-01-11 13:56:40 -07:00
|
|
|
VModCreate(Atom name, ExprDef * value)
|
|
|
|
{
|
|
|
|
VModDef *def;
|
|
|
|
def = uTypedAlloc(VModDef);
|
|
|
|
if (def)
|
|
|
|
{
|
|
|
|
def->common.stmtType = StmtVModDef;
|
|
|
|
def->common.next = NULL;
|
|
|
|
def->name = name;
|
|
|
|
def->value = value;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
FATAL("Couldn't allocate variable definition in parser\n");
|
|
|
|
/* NOTREACHED */
|
2006-11-25 13:07:29 -07:00
|
|
|
}
|
|
|
|
return def;
|
|
|
|
}
|
|
|
|
|
|
|
|
VarDef *
|
2011-01-11 13:56:40 -07:00
|
|
|
VarCreate(ExprDef * name, ExprDef * value)
|
|
|
|
{
|
|
|
|
VarDef *def;
|
|
|
|
def = uTypedAlloc(VarDef);
|
|
|
|
if (def)
|
|
|
|
{
|
|
|
|
def->common.stmtType = StmtVarDef;
|
|
|
|
def->common.next = NULL;
|
|
|
|
def->name = name;
|
|
|
|
def->value = value;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
FATAL("Couldn't allocate variable definition in parser\n");
|
|
|
|
/* NOTREACHED */
|
2006-11-25 13:07:29 -07:00
|
|
|
}
|
|
|
|
return def;
|
|
|
|
}
|
|
|
|
|
|
|
|
VarDef *
|
2011-01-11 13:56:40 -07:00
|
|
|
BoolVarCreate(Atom nameToken, unsigned set)
|
2006-11-25 13:07:29 -07:00
|
|
|
{
|
2011-01-11 13:56:40 -07:00
|
|
|
ExprDef *name, *value;
|
2006-11-25 13:07:29 -07:00
|
|
|
|
2011-01-11 13:56:40 -07:00
|
|
|
name = ExprCreate(ExprIdent, TypeUnknown);
|
|
|
|
name->value.str = nameToken;
|
|
|
|
value = ExprCreate(ExprValue, TypeBoolean);
|
|
|
|
value->value.uval = set;
|
|
|
|
return VarCreate(name, value);
|
2006-11-25 13:07:29 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
InterpDef *
|
2011-08-28 05:21:51 -06:00
|
|
|
InterpCreate(const char *sym_str, ExprDef * match)
|
2006-11-25 13:07:29 -07:00
|
|
|
{
|
2011-01-11 13:56:40 -07:00
|
|
|
InterpDef *def;
|
2006-11-25 13:07:29 -07:00
|
|
|
|
2011-01-11 13:56:40 -07:00
|
|
|
def = uTypedAlloc(InterpDef);
|
|
|
|
if (def)
|
|
|
|
{
|
|
|
|
def->common.stmtType = StmtInterpDef;
|
|
|
|
def->common.next = NULL;
|
2011-08-28 05:21:51 -06:00
|
|
|
if (LookupKeysym(sym_str, &def->sym) == 0)
|
|
|
|
def->ignore = True;
|
|
|
|
else
|
|
|
|
def->ignore = False;
|
2011-01-11 13:56:40 -07:00
|
|
|
def->match = match;
|
2006-11-25 13:07:29 -07:00
|
|
|
}
|
2011-01-11 13:56:40 -07:00
|
|
|
else
|
|
|
|
{
|
|
|
|
FATAL("Couldn't allocate interp definition in parser\n");
|
|
|
|
/* NOTREACHED */
|
2006-11-25 13:07:29 -07:00
|
|
|
}
|
|
|
|
return def;
|
|
|
|
}
|
|
|
|
|
|
|
|
KeyTypeDef *
|
2011-01-11 13:56:40 -07:00
|
|
|
KeyTypeCreate(Atom name, VarDef * body)
|
2006-11-25 13:07:29 -07:00
|
|
|
{
|
2011-01-11 13:56:40 -07:00
|
|
|
KeyTypeDef *def;
|
2006-11-25 13:07:29 -07:00
|
|
|
|
2011-01-11 13:56:40 -07:00
|
|
|
def = uTypedAlloc(KeyTypeDef);
|
|
|
|
if (def)
|
|
|
|
{
|
|
|
|
def->common.stmtType = StmtKeyTypeDef;
|
|
|
|
def->common.next = NULL;
|
|
|
|
def->merge = MergeDefault;
|
|
|
|
def->name = name;
|
|
|
|
def->body = body;
|
2006-11-25 13:07:29 -07:00
|
|
|
}
|
2011-01-11 13:56:40 -07:00
|
|
|
else
|
|
|
|
{
|
|
|
|
FATAL("Couldn't allocate key type definition in parser\n");
|
|
|
|
/* NOTREACHED */
|
2006-11-25 13:07:29 -07:00
|
|
|
}
|
|
|
|
return def;
|
|
|
|
}
|
|
|
|
|
|
|
|
SymbolsDef *
|
2011-01-11 13:56:40 -07:00
|
|
|
SymbolsCreate(char *keyName, ExprDef * symbols)
|
2006-11-25 13:07:29 -07:00
|
|
|
{
|
2011-01-11 13:56:40 -07:00
|
|
|
SymbolsDef *def;
|
2006-11-25 13:07:29 -07:00
|
|
|
|
2011-01-11 13:56:40 -07:00
|
|
|
def = uTypedAlloc(SymbolsDef);
|
|
|
|
if (def)
|
|
|
|
{
|
|
|
|
def->common.stmtType = StmtSymbolsDef;
|
|
|
|
def->common.next = NULL;
|
|
|
|
def->merge = MergeDefault;
|
|
|
|
bzero(def->keyName, 5);
|
|
|
|
strncpy(def->keyName, keyName, 4);
|
|
|
|
def->symbols = symbols;
|
2006-11-25 13:07:29 -07:00
|
|
|
}
|
2011-01-11 13:56:40 -07:00
|
|
|
else
|
|
|
|
{
|
|
|
|
FATAL("Couldn't allocate symbols definition in parser\n");
|
|
|
|
/* NOTREACHED */
|
2006-11-25 13:07:29 -07:00
|
|
|
}
|
|
|
|
return def;
|
|
|
|
}
|
|
|
|
|
|
|
|
GroupCompatDef *
|
2011-01-11 13:56:40 -07:00
|
|
|
GroupCompatCreate(int group, ExprDef * val)
|
2006-11-25 13:07:29 -07:00
|
|
|
{
|
2011-01-11 13:56:40 -07:00
|
|
|
GroupCompatDef *def;
|
2006-11-25 13:07:29 -07:00
|
|
|
|
2011-01-11 13:56:40 -07:00
|
|
|
def = uTypedAlloc(GroupCompatDef);
|
|
|
|
if (def)
|
|
|
|
{
|
|
|
|
def->common.stmtType = StmtGroupCompatDef;
|
|
|
|
def->common.next = NULL;
|
|
|
|
def->merge = MergeDefault;
|
|
|
|
def->group = group;
|
|
|
|
def->def = val;
|
2006-11-25 13:07:29 -07:00
|
|
|
}
|
2011-01-11 13:56:40 -07:00
|
|
|
else
|
|
|
|
{
|
|
|
|
FATAL("Couldn't allocate group compat definition in parser\n");
|
|
|
|
/* NOTREACHED */
|
2006-11-25 13:07:29 -07:00
|
|
|
}
|
|
|
|
return def;
|
|
|
|
}
|
|
|
|
|
|
|
|
ModMapDef *
|
2011-01-11 13:56:40 -07:00
|
|
|
ModMapCreate(Atom modifier, ExprDef * keys)
|
2006-11-25 13:07:29 -07:00
|
|
|
{
|
2011-01-11 13:56:40 -07:00
|
|
|
ModMapDef *def;
|
2006-11-25 13:07:29 -07:00
|
|
|
|
2011-01-11 13:56:40 -07:00
|
|
|
def = uTypedAlloc(ModMapDef);
|
|
|
|
if (def)
|
|
|
|
{
|
|
|
|
def->common.stmtType = StmtModMapDef;
|
|
|
|
def->common.next = NULL;
|
|
|
|
def->merge = MergeDefault;
|
|
|
|
def->modifier = modifier;
|
|
|
|
def->keys = keys;
|
2006-11-25 13:07:29 -07:00
|
|
|
}
|
2011-01-11 13:56:40 -07:00
|
|
|
else
|
|
|
|
{
|
|
|
|
FATAL("Couldn't allocate mod mask definition in parser\n");
|
|
|
|
/* NOTREACHED */
|
2006-11-25 13:07:29 -07:00
|
|
|
}
|
|
|
|
return def;
|
|
|
|
}
|
|
|
|
|
|
|
|
IndicatorMapDef *
|
2011-01-11 13:56:40 -07:00
|
|
|
IndicatorMapCreate(Atom name, VarDef * body)
|
2006-11-25 13:07:29 -07:00
|
|
|
{
|
2011-01-11 13:56:40 -07:00
|
|
|
IndicatorMapDef *def;
|
2006-11-25 13:07:29 -07:00
|
|
|
|
2011-01-11 13:56:40 -07:00
|
|
|
def = uTypedAlloc(IndicatorMapDef);
|
|
|
|
if (def)
|
|
|
|
{
|
|
|
|
def->common.stmtType = StmtIndicatorMapDef;
|
|
|
|
def->common.next = NULL;
|
|
|
|
def->merge = MergeDefault;
|
|
|
|
def->name = name;
|
|
|
|
def->body = body;
|
2006-11-25 13:07:29 -07:00
|
|
|
}
|
2011-01-11 13:56:40 -07:00
|
|
|
else
|
|
|
|
{
|
|
|
|
FATAL("Couldn't allocate indicator map definition in parser\n");
|
|
|
|
/* NOTREACHED */
|
2006-11-25 13:07:29 -07:00
|
|
|
}
|
|
|
|
return def;
|
|
|
|
}
|
|
|
|
|
|
|
|
IndicatorNameDef *
|
2011-01-11 13:56:40 -07:00
|
|
|
IndicatorNameCreate(int ndx, ExprDef * name, Bool virtual)
|
2006-11-25 13:07:29 -07:00
|
|
|
{
|
2011-01-11 13:56:40 -07:00
|
|
|
IndicatorNameDef *def;
|
2006-11-25 13:07:29 -07:00
|
|
|
|
2011-01-11 13:56:40 -07:00
|
|
|
def = uTypedAlloc(IndicatorNameDef);
|
|
|
|
if (def)
|
|
|
|
{
|
|
|
|
def->common.stmtType = StmtIndicatorNameDef;
|
|
|
|
def->common.next = NULL;
|
|
|
|
def->merge = MergeDefault;
|
|
|
|
def->ndx = ndx;
|
|
|
|
def->name = name;
|
|
|
|
def->virtual = virtual;
|
2006-11-25 13:07:29 -07:00
|
|
|
}
|
2011-01-11 13:56:40 -07:00
|
|
|
else
|
|
|
|
{
|
|
|
|
FATAL("Couldn't allocate indicator index definition in parser\n");
|
|
|
|
/* NOTREACHED */
|
2006-11-25 13:07:29 -07:00
|
|
|
}
|
|
|
|
return def;
|
|
|
|
}
|
|
|
|
|
|
|
|
ExprDef *
|
2011-01-11 13:56:40 -07:00
|
|
|
ActionCreate(Atom name, ExprDef * args)
|
2006-11-25 13:07:29 -07:00
|
|
|
{
|
2011-01-11 13:56:40 -07:00
|
|
|
ExprDef *act;
|
2006-11-25 13:07:29 -07:00
|
|
|
|
2011-01-11 13:56:40 -07:00
|
|
|
act = uTypedAlloc(ExprDef);
|
|
|
|
if (act)
|
|
|
|
{
|
|
|
|
act->common.stmtType = StmtExpr;
|
|
|
|
act->common.next = NULL;
|
|
|
|
act->op = ExprActionDecl;
|
|
|
|
act->value.action.name = name;
|
|
|
|
act->value.action.args = args;
|
|
|
|
return act;
|
2006-11-25 13:07:29 -07:00
|
|
|
}
|
|
|
|
FATAL("Couldn't allocate ActionDef in parser\n");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
ExprDef *
|
2011-01-11 13:56:40 -07:00
|
|
|
CreateKeysymList(char *sym)
|
|
|
|
{
|
|
|
|
ExprDef *def;
|
|
|
|
|
|
|
|
def = ExprCreate(ExprKeysymList, TypeSymbols);
|
|
|
|
if (def)
|
|
|
|
{
|
|
|
|
def->value.list.nSyms = 1;
|
|
|
|
def->value.list.szSyms = 4;
|
|
|
|
def->value.list.syms = uTypedCalloc(4, char *);
|
|
|
|
if (def->value.list.syms != NULL)
|
|
|
|
{
|
|
|
|
def->value.list.syms[0] = sym;
|
|
|
|
return def;
|
|
|
|
}
|
2006-11-25 13:07:29 -07:00
|
|
|
}
|
|
|
|
FATAL("Couldn't allocate expression for keysym list in parser\n");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
ShapeDef *
|
2011-01-11 13:56:40 -07:00
|
|
|
ShapeDeclCreate(Atom name, OutlineDef * outlines)
|
|
|
|
{
|
|
|
|
ShapeDef *shape;
|
|
|
|
OutlineDef *ol;
|
|
|
|
|
|
|
|
shape = uTypedAlloc(ShapeDef);
|
|
|
|
if (shape != NULL)
|
|
|
|
{
|
|
|
|
bzero(shape, 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++;
|
|
|
|
}
|
2006-11-25 13:07:29 -07:00
|
|
|
}
|
|
|
|
return shape;
|
|
|
|
}
|
|
|
|
|
|
|
|
OutlineDef *
|
2011-01-11 13:56:40 -07:00
|
|
|
OutlineCreate(Atom field, ExprDef * points)
|
|
|
|
{
|
|
|
|
OutlineDef *outline;
|
|
|
|
ExprDef *pt;
|
|
|
|
|
|
|
|
outline = uTypedAlloc(OutlineDef);
|
|
|
|
if (outline != NULL)
|
|
|
|
{
|
|
|
|
bzero(outline, 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;
|
2006-11-25 13:07:29 -07:00
|
|
|
}
|
|
|
|
return outline;
|
|
|
|
}
|
|
|
|
|
|
|
|
KeyDef *
|
2011-01-11 13:56:40 -07:00
|
|
|
KeyDeclCreate(char *name, ExprDef * expr)
|
2006-11-25 13:07:29 -07:00
|
|
|
{
|
2011-01-11 13:56:40 -07:00
|
|
|
KeyDef *key;
|
2006-11-25 13:07:29 -07:00
|
|
|
|
2011-01-11 13:56:40 -07:00
|
|
|
key = uTypedAlloc(KeyDef);
|
|
|
|
if (key != NULL)
|
|
|
|
{
|
|
|
|
bzero(key, sizeof(KeyDef));
|
|
|
|
key->common.stmtType = StmtKeyDef;
|
|
|
|
key->common.next = NULL;
|
|
|
|
if (name)
|
|
|
|
key->name = name;
|
|
|
|
else
|
|
|
|
key->expr = expr;
|
2006-11-25 13:07:29 -07:00
|
|
|
}
|
|
|
|
return key;
|
|
|
|
}
|
|
|
|
|
|
|
|
KeyDef *
|
2011-01-11 13:56:40 -07:00
|
|
|
KeyDeclMerge(KeyDef * into, KeyDef * from)
|
2006-11-25 13:07:29 -07:00
|
|
|
{
|
2011-01-11 13:56:40 -07:00
|
|
|
into->expr =
|
|
|
|
(ExprDef *) AppendStmt(&into->expr->common, &from->expr->common);
|
|
|
|
from->expr = NULL;
|
2006-11-25 13:07:29 -07:00
|
|
|
uFree(from);
|
|
|
|
return into;
|
|
|
|
}
|
|
|
|
|
|
|
|
RowDef *
|
2011-01-11 13:56:40 -07:00
|
|
|
RowDeclCreate(KeyDef * keys)
|
|
|
|
{
|
|
|
|
RowDef *row;
|
|
|
|
KeyDef *key;
|
|
|
|
|
|
|
|
row = uTypedAlloc(RowDef);
|
|
|
|
if (row != NULL)
|
|
|
|
{
|
|
|
|
bzero(row, 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++;
|
|
|
|
}
|
2006-11-25 13:07:29 -07:00
|
|
|
}
|
|
|
|
return row;
|
|
|
|
}
|
|
|
|
|
|
|
|
SectionDef *
|
2011-01-11 13:56:40 -07:00
|
|
|
SectionDeclCreate(Atom name, RowDef * rows)
|
|
|
|
{
|
|
|
|
SectionDef *section;
|
|
|
|
RowDef *row;
|
|
|
|
|
|
|
|
section = uTypedAlloc(SectionDef);
|
|
|
|
if (section != NULL)
|
|
|
|
{
|
|
|
|
bzero(section, 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++;
|
|
|
|
}
|
2006-11-25 13:07:29 -07:00
|
|
|
}
|
|
|
|
return section;
|
|
|
|
}
|
|
|
|
|
|
|
|
OverlayKeyDef *
|
2011-01-11 13:56:40 -07:00
|
|
|
OverlayKeyCreate(char *under, char *over)
|
|
|
|
{
|
|
|
|
OverlayKeyDef *key;
|
|
|
|
|
|
|
|
key = uTypedAlloc(OverlayKeyDef);
|
|
|
|
if (key != NULL)
|
|
|
|
{
|
|
|
|
bzero(key, sizeof(OverlayKeyDef));
|
|
|
|
key->common.stmtType = StmtOverlayKeyDef;
|
|
|
|
strncpy(key->over, over, XkbKeyNameLength);
|
|
|
|
strncpy(key->under, under, XkbKeyNameLength);
|
|
|
|
if (over)
|
|
|
|
uFree(over);
|
|
|
|
if (under)
|
|
|
|
uFree(under);
|
2006-11-25 13:07:29 -07:00
|
|
|
}
|
|
|
|
return key;
|
|
|
|
}
|
|
|
|
|
|
|
|
OverlayDef *
|
2011-01-11 13:56:40 -07:00
|
|
|
OverlayDeclCreate(Atom name, OverlayKeyDef * keys)
|
|
|
|
{
|
|
|
|
OverlayDef *ol;
|
|
|
|
OverlayKeyDef *key;
|
|
|
|
|
|
|
|
ol = uTypedAlloc(OverlayDef);
|
|
|
|
if (ol != NULL)
|
|
|
|
{
|
|
|
|
bzero(ol, sizeof(OverlayDef));
|
|
|
|
ol->common.stmtType = StmtOverlayDef;
|
|
|
|
ol->name = name;
|
|
|
|
ol->keys = keys;
|
|
|
|
for (key = keys; key != NULL;
|
|
|
|
key = (OverlayKeyDef *) key->common.next)
|
|
|
|
{
|
|
|
|
ol->nKeys++;
|
|
|
|
}
|
2006-11-25 13:07:29 -07:00
|
|
|
}
|
|
|
|
return ol;
|
|
|
|
}
|
|
|
|
|
|
|
|
DoodadDef *
|
2011-01-11 13:56:40 -07:00
|
|
|
DoodadCreate(unsigned type, Atom name, VarDef * body)
|
2006-11-25 13:07:29 -07:00
|
|
|
{
|
2011-01-11 13:56:40 -07:00
|
|
|
DoodadDef *doodad;
|
2006-11-25 13:07:29 -07:00
|
|
|
|
2011-01-11 13:56:40 -07:00
|
|
|
doodad = uTypedAlloc(DoodadDef);
|
|
|
|
if (doodad != NULL)
|
|
|
|
{
|
|
|
|
bzero(doodad, sizeof(DoodadDef));
|
|
|
|
doodad->common.stmtType = StmtDoodadDef;
|
|
|
|
doodad->common.next = NULL;
|
|
|
|
doodad->type = type;
|
|
|
|
doodad->name = name;
|
|
|
|
doodad->body = body;
|
2006-11-25 13:07:29 -07:00
|
|
|
}
|
|
|
|
return doodad;
|
|
|
|
}
|
|
|
|
|
|
|
|
ExprDef *
|
2011-01-11 13:56:40 -07:00
|
|
|
AppendKeysymList(ExprDef * list, char *sym)
|
|
|
|
{
|
|
|
|
if (list->value.list.nSyms >= list->value.list.szSyms)
|
|
|
|
{
|
|
|
|
list->value.list.szSyms *= 2;
|
|
|
|
list->value.list.syms = uTypedRecalloc(list->value.list.syms,
|
|
|
|
list->value.list.nSyms,
|
|
|
|
list->value.list.szSyms,
|
|
|
|
char *);
|
|
|
|
if (list->value.list.syms == NULL)
|
|
|
|
{
|
|
|
|
FATAL("Couldn't resize list of symbols for append\n");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
list->value.list.syms[list->value.list.nSyms++] = sym;
|
2006-11-25 13:07:29 -07:00
|
|
|
return list;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2011-08-28 05:21:51 -06:00
|
|
|
LookupKeysym(const char *str, KeySym * sym_rtrn)
|
2011-01-11 13:56:40 -07:00
|
|
|
{
|
|
|
|
KeySym sym;
|
|
|
|
char *tmp;
|
|
|
|
|
|
|
|
if ((!str) || (uStrCaseCmp(str, "any") == 0)
|
|
|
|
|| (uStrCaseCmp(str, "nosymbol") == 0))
|
|
|
|
{
|
|
|
|
*sym_rtrn = NoSymbol;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
else if ((uStrCaseCmp(str, "none") == 0)
|
|
|
|
|| (uStrCaseCmp(str, "voidsymbol") == 0))
|
|
|
|
{
|
|
|
|
*sym_rtrn = XK_VoidSymbol;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
sym = XStringToKeysym(str);
|
|
|
|
if (sym != NoSymbol)
|
|
|
|
{
|
|
|
|
*sym_rtrn = sym;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
if (strlen(str) > 2 && str[0] == '0' && str[1] == 'x') {
|
|
|
|
sym = strtoul(str, &tmp, 16);
|
|
|
|
if (sym != ULONG_MAX && (!tmp || *tmp == '\0')) {
|
|
|
|
*sym_rtrn = sym;
|
|
|
|
return 1;
|
|
|
|
}
|
2006-11-25 13:07:29 -07:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
IncludeStmt *
|
2011-01-11 13:56:40 -07:00
|
|
|
IncludeCreate(char *str, unsigned merge)
|
|
|
|
{
|
|
|
|
IncludeStmt *incl, *first;
|
|
|
|
char *file, *map, *stmt, *tmp, *extra_data;
|
|
|
|
char nextop;
|
|
|
|
Bool haveSelf;
|
|
|
|
|
|
|
|
haveSelf = False;
|
|
|
|
incl = first = NULL;
|
|
|
|
file = map = NULL;
|
|
|
|
tmp = str;
|
|
|
|
stmt = uStringDup(str);
|
|
|
|
while ((tmp) && (*tmp))
|
|
|
|
{
|
|
|
|
if (XkbParseIncludeMap(&tmp, &file, &map, &nextop, &extra_data))
|
|
|
|
{
|
|
|
|
if ((file == NULL) && (map == NULL))
|
|
|
|
{
|
|
|
|
if (haveSelf)
|
|
|
|
goto BAIL;
|
|
|
|
haveSelf = True;
|
|
|
|
}
|
|
|
|
if (first == NULL)
|
|
|
|
first = incl = uTypedAlloc(IncludeStmt);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
incl->next = uTypedAlloc(IncludeStmt);
|
|
|
|
incl = incl->next;
|
|
|
|
}
|
|
|
|
if (incl)
|
|
|
|
{
|
|
|
|
incl->common.stmtType = StmtInclude;
|
|
|
|
incl->common.next = NULL;
|
|
|
|
incl->merge = merge;
|
|
|
|
incl->stmt = NULL;
|
|
|
|
incl->file = file;
|
|
|
|
incl->map = map;
|
|
|
|
incl->modifier = extra_data;
|
|
|
|
incl->path = NULL;
|
|
|
|
incl->next = NULL;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
WSGO("Allocation failure in IncludeCreate\n");
|
|
|
|
ACTION("Using only part of the include\n");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (nextop == '|')
|
|
|
|
merge = MergeAugment;
|
|
|
|
else
|
|
|
|
merge = MergeOverride;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
goto BAIL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (first)
|
|
|
|
first->stmt = stmt;
|
|
|
|
else if (stmt)
|
|
|
|
uFree(stmt);
|
2006-11-25 13:07:29 -07:00
|
|
|
return first;
|
2011-01-11 13:56:40 -07:00
|
|
|
BAIL:
|
|
|
|
ERROR1("Illegal include statement \"%s\"\n", stmt);
|
2006-11-25 13:07:29 -07:00
|
|
|
ACTION("Ignored\n");
|
2011-01-11 13:56:40 -07:00
|
|
|
while (first)
|
|
|
|
{
|
|
|
|
incl = first->next;
|
|
|
|
if (first->file)
|
|
|
|
uFree(first->file);
|
|
|
|
if (first->map)
|
|
|
|
uFree(first->map);
|
|
|
|
if (first->modifier)
|
|
|
|
uFree(first->modifier);
|
|
|
|
if (first->path)
|
|
|
|
uFree(first->path);
|
|
|
|
first->file = first->map = first->path = NULL;
|
|
|
|
uFree(first);
|
|
|
|
first = incl;
|
2006-11-25 13:07:29 -07:00
|
|
|
}
|
|
|
|
if (stmt)
|
2011-01-11 13:56:40 -07:00
|
|
|
uFree(stmt);
|
2006-11-25 13:07:29 -07:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
void
|
2011-01-11 13:56:40 -07:00
|
|
|
PrintStmtAddrs(ParseCommon * stmt)
|
2006-11-25 13:07:29 -07:00
|
|
|
{
|
2011-01-11 13:56:40 -07:00
|
|
|
fprintf(stderr, "0x%x", stmt);
|
|
|
|
if (stmt)
|
|
|
|
{
|
|
|
|
do
|
|
|
|
{
|
|
|
|
fprintf(stderr, "->0x%x", stmt->next);
|
|
|
|
stmt = stmt->next;
|
|
|
|
}
|
|
|
|
while (stmt);
|
2006-11-25 13:07:29 -07:00
|
|
|
}
|
2011-01-11 13:56:40 -07:00
|
|
|
fprintf(stderr, "\n");
|
2006-11-25 13:07:29 -07:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static void
|
2011-01-11 13:56:40 -07:00
|
|
|
CheckDefaultMap(XkbFile * maps)
|
|
|
|
{
|
|
|
|
XkbFile *dflt, *tmp;
|
|
|
|
|
|
|
|
dflt = NULL;
|
|
|
|
for (tmp = maps, dflt = NULL; tmp != NULL;
|
|
|
|
tmp = (XkbFile *) tmp->common.next)
|
|
|
|
{
|
|
|
|
if (tmp->flags & XkbLC_Default)
|
|
|
|
{
|
|
|
|
if (dflt == NULL)
|
|
|
|
dflt = tmp;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (warningLevel > 2)
|
|
|
|
{
|
|
|
|
WARN1("Multiple default components in %s\n",
|
|
|
|
(scanFile ? scanFile : "(unknown)"));
|
|
|
|
ACTION2("Using %s, ignoring %s\n",
|
|
|
|
(dflt->name ? dflt->name : "(first)"),
|
|
|
|
(tmp->name ? tmp->name : "(subsequent)"));
|
|
|
|
}
|
|
|
|
tmp->flags &= (~XkbLC_Default);
|
|
|
|
}
|
|
|
|
}
|
2006-11-25 13:07:29 -07:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2011-01-11 13:56:40 -07:00
|
|
|
XKBParseFile(FILE * file, XkbFile ** pRtrn)
|
|
|
|
{
|
|
|
|
if (file)
|
|
|
|
{
|
|
|
|
yyin = file;
|
|
|
|
rtrnValue = NULL;
|
|
|
|
if (yyparse() == 0)
|
|
|
|
{
|
|
|
|
*pRtrn = rtrnValue;
|
|
|
|
CheckDefaultMap(rtrnValue);
|
|
|
|
rtrnValue = NULL;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
*pRtrn = NULL;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
*pRtrn = NULL;
|
2006-11-25 13:07:29 -07:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
XkbFile *
|
2011-01-11 13:56:40 -07:00
|
|
|
CreateXKBFile(int type, char *name, ParseCommon * defs, unsigned flags)
|
|
|
|
{
|
|
|
|
XkbFile *file;
|
|
|
|
static int fileID;
|
|
|
|
|
|
|
|
file = uTypedAlloc(XkbFile);
|
|
|
|
if (file)
|
|
|
|
{
|
|
|
|
XkbEnsureSafeMapName(name);
|
|
|
|
bzero(file, sizeof(XkbFile));
|
|
|
|
file->type = type;
|
|
|
|
file->topName = uStringDup(name);
|
|
|
|
file->name = name;
|
|
|
|
file->defs = defs;
|
|
|
|
file->id = fileID++;
|
|
|
|
file->compiled = False;
|
|
|
|
file->flags = flags;
|
2006-11-25 13:07:29 -07:00
|
|
|
}
|
|
|
|
return file;
|
|
|
|
}
|
|
|
|
|
2011-01-11 13:56:40 -07:00
|
|
|
unsigned
|
|
|
|
StmtSetMerge(ParseCommon * stmt, unsigned merge)
|
2006-11-25 13:07:29 -07:00
|
|
|
{
|
2011-01-11 13:56:40 -07:00
|
|
|
if ((merge == MergeAltForm) && (stmt->stmtType != StmtKeycodeDef))
|
|
|
|
{
|
|
|
|
yyerror("illegal use of 'alternate' merge mode");
|
|
|
|
merge = MergeDefault;
|
2006-11-25 13:07:29 -07:00
|
|
|
}
|
|
|
|
return merge;
|
|
|
|
}
|