aboutsummaryrefslogtreecommitdiff
path: root/xkbcomp/xkbscan.c
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2009-07-25 18:58:20 +0000
committermarha <marha@users.sourceforge.net>2009-07-25 18:58:20 +0000
commite2c51f2ee7b0a3ea1a052fc49324057b4a4bbc78 (patch)
treed25ddcc9b5bb33bef4832bd6e8702061a9887a53 /xkbcomp/xkbscan.c
parente445df175688f07d599649591c990d432375c67e (diff)
parentdc3c299dd0995549e2a6973ca0f25b254afd38a5 (diff)
downloadvcxsrv-e2c51f2ee7b0a3ea1a052fc49324057b4a4bbc78.tar.gz
vcxsrv-e2c51f2ee7b0a3ea1a052fc49324057b4a4bbc78.tar.bz2
vcxsrv-e2c51f2ee7b0a3ea1a052fc49324057b4a4bbc78.zip
svn merge file:///D:/svnrepos/vcxsrv/branches/released .
Diffstat (limited to 'xkbcomp/xkbscan.c')
-rw-r--r--xkbcomp/xkbscan.c971
1 files changed, 613 insertions, 358 deletions
diff --git a/xkbcomp/xkbscan.c b/xkbcomp/xkbscan.c
index ef2227d79..31cafd4ab 100644
--- a/xkbcomp/xkbscan.c
+++ b/xkbcomp/xkbscan.c
@@ -1,4 +1,3 @@
-/* $Xorg: xkbscan.c,v 1.3 2000/08/17 19:54:34 cpqbld Exp $ */
/************************************************************
Copyright (c) 1994 by Silicon Graphics Computer Systems, Inc.
@@ -24,7 +23,6 @@
THE USE OR PERFORMANCE OF THIS SOFTWARE.
********************************************************/
-/* $XFree86: xc/programs/xkbcomp/xkbscan.c,v 3.10 2001/01/17 23:45:45 dawes Exp $ */
#include <stdio.h>
#include <ctype.h>
@@ -37,183 +35,329 @@
#include "utils.h"
#include "parseutils.h"
-FILE *yyin = NULL;
+unsigned int scanDebug;
-static char scanFileBuf[1024];
-char * scanFile= scanFileBuf;
-int lineNum= 0;
+FILE *yyin = NULL;
-int scanInt;
-char *scanIntStr;
-int scanIntClass;
+static char scanFileBuf[1024] = {0};
+char *scanFile = scanFileBuf;
+int lineNum = 0;
-char *scanStr = NULL;
-int scanStrLine= 0;
+int scanInt;
+
+char *scanStr = NULL;
+static int scanStrLine = 0;
#define BUFSIZE 512
-static int nInBuf = 0;
-static char buf[BUFSIZE];
+static int nInBuf = 0;
+static char buf[BUFSIZE];
#ifdef DEBUG
-
-extern unsigned debugFlags;
-
static char *
tokText(int tok)
{
-static char buf[32];
-
- switch (tok) {
- case END_OF_FILE: sprintf(buf, "END_OF_FILE");break;
- case ERROR_TOK: sprintf(buf, "ERROR"); break;
-
- case XKB_KEYMAP: sprintf(buf, "XKB_KEYMAP"); break;
- case XKB_KEYCODES: sprintf(buf, "XKB_KEYCODES"); break;
- case XKB_TYPES: sprintf(buf, "XKB_TYPES"); break;
- case XKB_SYMBOLS: sprintf(buf, "XKB_SYMBOLS"); break;
- case XKB_COMPATMAP: sprintf(buf, "XKB_COMPATMAP"); break;
- case XKB_GEOMETRY: sprintf(buf, "XKB_GEOMETRY"); break;
- case XKB_SEMANTICS: sprintf(buf, "XKB_SEMANTICS"); break;
- case XKB_LAYOUT: sprintf(buf, "XKB_LAYOUT"); break;
-
- case INCLUDE: sprintf(buf, "INCLUDE"); break;
- case OVERRIDE: sprintf(buf, "OVERRIDE"); break;
- case AUGMENT: sprintf(buf, "AUGMENT"); break;
- case REPLACE: sprintf(buf, "REPLACE"); break;
- case ALTERNATE: sprintf(buf, "ALTERNATE"); break;
-
- case VIRTUAL_MODS: sprintf(buf, "VIRTUAL_MODS"); break;
- case TYPE: sprintf(buf, "TYPE"); break;
- case INTERPRET: sprintf(buf, "INTERPRET"); break;
- case ACTION_TOK: sprintf(buf, "ACTION"); break;
- case KEY: sprintf(buf, "KEY"); break;
- case ALIAS: sprintf(buf, "ALIAS"); break;
- case GROUP: sprintf(buf, "GROUP"); break;
- case MODIFIER_MAP: sprintf(buf, "MODIFIER_MAP"); break;
- case INDICATOR: sprintf(buf, "INDICATOR"); break;
- case SHAPE: sprintf(buf, "SHAPE"); break;
- case KEYS: sprintf(buf, "KEYS"); break;
- case ROW: sprintf(buf, "ROW"); break;
- case SECTION: sprintf(buf, "SECTION"); break;
- case OVERLAY: sprintf(buf, "OVERLAY"); break;
- case TEXT: sprintf(buf, "TEXT"); break;
- case OUTLINE: sprintf(buf, "OUTLINE"); break;
- case SOLID: sprintf(buf, "SOLID"); break;
- case LOGO: sprintf(buf, "LOGO"); break;
- case VIRTUAL: sprintf(buf, "VIRTUAL"); break;
-
- case EQUALS: sprintf(buf, "EQUALS"); break;
- case PLUS: sprintf(buf, "PLUS"); break;
- case MINUS: sprintf(buf, "MINUS"); break;
- case DIVIDE: sprintf(buf, "DIVIDE"); break;
- case TIMES: sprintf(buf, "TIMES"); break;
- case OBRACE: sprintf(buf, "OBRACE"); break;
- case CBRACE: sprintf(buf, "CBRACE"); break;
- case OPAREN: sprintf(buf, "OPAREN"); break;
- case CPAREN: sprintf(buf, "CPAREN"); break;
- case OBRACKET: sprintf(buf, "OBRACKET");break;
- case CBRACKET: sprintf(buf, "CBRACKET");break;
- case DOT: sprintf(buf, "DOT"); break;
- case COMMA: sprintf(buf, "COMMA"); break;
- case SEMI: sprintf(buf, "SEMI"); break;
- case EXCLAM: sprintf(buf, "EXCLAM"); break;
- case INVERT: sprintf(buf, "INVERT"); break;
-
- case STRING: sprintf(buf, "STRING (%s)",scanStr); break;
- case INTEGER: sprintf(buf, "INTEGER (0x%x)",scanInt); break;
- case FLOAT: sprintf(buf, "FLOAT (%d.%d)",
- scanInt/XkbGeomPtsPerMM,
- scanInt%XkbGeomPtsPerMM);break;
- case IDENT: sprintf(buf, "IDENT (%s)",scanStr); break;
- case KEYNAME: sprintf(buf, "KEYNAME (%s)",scanStr); break;
-
- case PARTIAL: sprintf(buf, "PARTIAL"); break;
- case DEFAULT: sprintf(buf, "DEFAULT"); break;
- case HIDDEN: sprintf(buf, "HIDDEN"); break;
-
- case ALPHANUMERIC_KEYS: sprintf(buf, "ALPHANUMERIC_KEYS"); break;
- case MODIFIER_KEYS: sprintf(buf, "MODIFIER_KEYS"); break;
- case KEYPAD_KEYS: sprintf(buf, "KEYPAD_KEYS"); break;
- case FUNCTION_KEYS: sprintf(buf, "FUNCTION_KEYS"); break;
- case ALTERNATE_GROUP: sprintf(buf, "ALTERNATE_GROUP"); break;
-
- default: sprintf(buf, "UNKNOWN"); break;
+ static char buf[32];
+
+ switch (tok)
+ {
+ case END_OF_FILE:
+ snprintf(buf, sizeof(buf), "END_OF_FILE");
+ break;
+ case ERROR_TOK:
+ snprintf(buf, sizeof(buf), "ERROR");
+ break;
+
+ case XKB_KEYMAP:
+ snprintf(buf, sizeof(buf), "XKB_KEYMAP");
+ break;
+ case XKB_KEYCODES:
+ snprintf(buf, sizeof(buf), "XKB_KEYCODES");
+ break;
+ case XKB_TYPES:
+ snprintf(buf, sizeof(buf), "XKB_TYPES");
+ break;
+ case XKB_SYMBOLS:
+ snprintf(buf, sizeof(buf), "XKB_SYMBOLS");
+ break;
+ case XKB_COMPATMAP:
+ snprintf(buf, sizeof(buf), "XKB_COMPATMAP");
+ break;
+ case XKB_GEOMETRY:
+ snprintf(buf, sizeof(buf), "XKB_GEOMETRY");
+ break;
+ case XKB_SEMANTICS:
+ snprintf(buf, sizeof(buf), "XKB_SEMANTICS");
+ break;
+ case XKB_LAYOUT:
+ snprintf(buf, sizeof(buf), "XKB_LAYOUT");
+ break;
+
+ case INCLUDE:
+ snprintf(buf, sizeof(buf), "INCLUDE");
+ break;
+ case OVERRIDE:
+ snprintf(buf, sizeof(buf), "OVERRIDE");
+ break;
+ case AUGMENT:
+ snprintf(buf, sizeof(buf), "AUGMENT");
+ break;
+ case REPLACE:
+ snprintf(buf, sizeof(buf), "REPLACE");
+ break;
+ case ALTERNATE:
+ snprintf(buf, sizeof(buf), "ALTERNATE");
+ break;
+
+ case VIRTUAL_MODS:
+ snprintf(buf, sizeof(buf), "VIRTUAL_MODS");
+ break;
+ case TYPE:
+ snprintf(buf, sizeof(buf), "TYPE");
+ break;
+ case INTERPRET:
+ snprintf(buf, sizeof(buf), "INTERPRET");
+ break;
+ case ACTION_TOK:
+ snprintf(buf, sizeof(buf), "ACTION");
+ break;
+ case KEY:
+ snprintf(buf, sizeof(buf), "KEY");
+ break;
+ case ALIAS:
+ snprintf(buf, sizeof(buf), "ALIAS");
+ break;
+ case GROUP:
+ snprintf(buf, sizeof(buf), "GROUP");
+ break;
+ case MODIFIER_MAP:
+ snprintf(buf, sizeof(buf), "MODIFIER_MAP");
+ break;
+ case INDICATOR:
+ snprintf(buf, sizeof(buf), "INDICATOR");
+ break;
+ case SHAPE:
+ snprintf(buf, sizeof(buf), "SHAPE");
+ break;
+ case KEYS:
+ snprintf(buf, sizeof(buf), "KEYS");
+ break;
+ case ROW:
+ snprintf(buf, sizeof(buf), "ROW");
+ break;
+ case SECTION:
+ snprintf(buf, sizeof(buf), "SECTION");
+ break;
+ case OVERLAY:
+ snprintf(buf, sizeof(buf), "OVERLAY");
+ break;
+ case TEXT:
+ snprintf(buf, sizeof(buf), "TEXT");
+ break;
+ case OUTLINE:
+ snprintf(buf, sizeof(buf), "OUTLINE");
+ break;
+ case SOLID:
+ snprintf(buf, sizeof(buf), "SOLID");
+ break;
+ case LOGO:
+ snprintf(buf, sizeof(buf), "LOGO");
+ break;
+ case VIRTUAL:
+ snprintf(buf, sizeof(buf), "VIRTUAL");
+ break;
+
+ case EQUALS:
+ snprintf(buf, sizeof(buf), "EQUALS");
+ break;
+ case PLUS:
+ snprintf(buf, sizeof(buf), "PLUS");
+ break;
+ case MINUS:
+ snprintf(buf, sizeof(buf), "MINUS");
+ break;
+ case DIVIDE:
+ snprintf(buf, sizeof(buf), "DIVIDE");
+ break;
+ case TIMES:
+ snprintf(buf, sizeof(buf), "TIMES");
+ break;
+ case OBRACE:
+ snprintf(buf, sizeof(buf), "OBRACE");
+ break;
+ case CBRACE:
+ snprintf(buf, sizeof(buf), "CBRACE");
+ break;
+ case OPAREN:
+ snprintf(buf, sizeof(buf), "OPAREN");
+ break;
+ case CPAREN:
+ snprintf(buf, sizeof(buf), "CPAREN");
+ break;
+ case OBRACKET:
+ snprintf(buf, sizeof(buf), "OBRACKET");
+ break;
+ case CBRACKET:
+ snprintf(buf, sizeof(buf), "CBRACKET");
+ break;
+ case DOT:
+ snprintf(buf, sizeof(buf), "DOT");
+ break;
+ case COMMA:
+ snprintf(buf, sizeof(buf), "COMMA");
+ break;
+ case SEMI:
+ snprintf(buf, sizeof(buf), "SEMI");
+ break;
+ case EXCLAM:
+ snprintf(buf, sizeof(buf), "EXCLAM");
+ break;
+ case INVERT:
+ snprintf(buf, sizeof(buf), "INVERT");
+ break;
+
+ case STRING:
+ snprintf(buf, sizeof(buf), "STRING (%s)", scanStr);
+ break;
+ case INTEGER:
+ snprintf(buf, sizeof(buf), "INTEGER (0x%x)", scanInt);
+ break;
+ case FLOAT:
+ snprintf(buf, sizeof(buf), "FLOAT (%d.%d)",
+ scanInt / XkbGeomPtsPerMM, scanInt % XkbGeomPtsPerMM);
+ break;
+ case IDENT:
+ snprintf(buf, sizeof(buf), "IDENT (%s)", scanStr);
+ break;
+ case KEYNAME:
+ snprintf(buf, sizeof(buf), "KEYNAME (%s)", scanStr);
+ break;
+
+ case PARTIAL:
+ snprintf(buf, sizeof(buf), "PARTIAL");
+ break;
+ case DEFAULT:
+ snprintf(buf, sizeof(buf), "DEFAULT");
+ break;
+ case HIDDEN:
+ snprintf(buf, sizeof(buf), "HIDDEN");
+ break;
+
+ case ALPHANUMERIC_KEYS:
+ snprintf(buf, sizeof(buf), "ALPHANUMERIC_KEYS");
+ break;
+ case MODIFIER_KEYS:
+ snprintf(buf, sizeof(buf), "MODIFIER_KEYS");
+ break;
+ case KEYPAD_KEYS:
+ snprintf(buf, sizeof(buf), "KEYPAD_KEYS");
+ break;
+ case FUNCTION_KEYS:
+ snprintf(buf, sizeof(buf), "FUNCTION_KEYS");
+ break;
+ case ALTERNATE_GROUP:
+ snprintf(buf, sizeof(buf), "ALTERNATE_GROUP");
+ break;
+
+ default:
+ snprintf(buf, sizeof(buf), "UNKNOWN");
+ break;
}
return buf;
}
#endif
int
-setScanState(char *file,int line)
+setScanState(char *file, int line)
{
- if (file!=NULL)
- strncpy(scanFile,file,1024);
- if (line>=0)
- lineNum= line;
+ if (file != NULL)
+ strncpy(scanFile, file, 1024);
+ if (line >= 0)
+ lineNum = line;
return 1;
}
static int
yyGetString(void)
{
-int ch;
+ int ch;
nInBuf = 0;
- while ( ((ch=getc(yyin))!=EOF) && (ch!='"') ) {
- if ( ch == '\\' ) {
- if ((ch = getc(yyin))!=EOF) {
- if ( ch=='n' ) ch = '\n';
- else if ( ch == 't' ) ch = '\t';
- else if ( ch == 'v' ) ch = '\v';
- else if ( ch == 'b' ) ch = '\b';
- else if ( ch == 'r' ) ch = '\r';
- else if ( ch == 'f' ) ch = '\f';
- else if ( ch == 'e' ) ch = '\033';
- else if ( ch == '0' ) {
- int tmp,stop;
- ch = stop = 0;
- if (((tmp=getc(yyin))!=EOF) && (isdigit(tmp)) &&
- (tmp!='8') && (tmp!='9')) {
- ch= (ch*8)+(tmp-'0');
- }
- else {
- stop= 1;
- ungetc(tmp,yyin);
- }
- if (!stop) {
- if (((tmp=getc(yyin))!=EOF) && (isdigit(tmp)) &&
- (tmp!='8') && (tmp!='9')) {
- ch= (ch*8)+(tmp-'0');
- }
- else {
- stop= 1;
- ungetc(tmp,yyin);
- }
- }
- if (!stop) {
- if (((tmp=getc(yyin))!=EOF) && (isdigit(tmp)) &&
- (tmp!='8') && (tmp!='9')) {
- ch= (ch*8)+(tmp-'0');
- }
- else {
- stop= 1;
- ungetc(tmp,yyin);
- }
- }
- }
- }
- else return ERROR_TOK;
- }
- if ( nInBuf < BUFSIZE-1 )
- buf[nInBuf++] = ch;
+ while (((ch = getc(yyin)) != EOF) && (ch != '"'))
+ {
+ if (ch == '\\')
+ {
+ if ((ch = getc(yyin)) != EOF)
+ {
+ if (ch == 'n')
+ ch = '\n';
+ else if (ch == 't')
+ ch = '\t';
+ else if (ch == 'v')
+ ch = '\v';
+ else if (ch == 'b')
+ ch = '\b';
+ else if (ch == 'r')
+ ch = '\r';
+ else if (ch == 'f')
+ ch = '\f';
+ else if (ch == 'e')
+ ch = '\033';
+ else if (ch == '0')
+ {
+ int tmp, stop;
+ ch = stop = 0;
+ if (((tmp = getc(yyin)) != EOF) && (isdigit(tmp))
+ && (tmp != '8') && (tmp != '9'))
+ {
+ ch = (ch * 8) + (tmp - '0');
+ }
+ else
+ {
+ stop = 1;
+ ungetc(tmp, yyin);
+ }
+ if (!stop)
+ {
+ if (((tmp = getc(yyin)) != EOF)
+ && (isdigit(tmp)) && (tmp != '8') && (tmp != '9'))
+ {
+ ch = (ch * 8) + (tmp - '0');
+ }
+ else
+ {
+ stop = 1;
+ ungetc(tmp, yyin);
+ }
+ }
+ if (!stop)
+ {
+ if (((tmp = getc(yyin)) != EOF)
+ && (isdigit(tmp)) && (tmp != '8') && (tmp != '9'))
+ {
+ ch = (ch * 8) + (tmp - '0');
+ }
+ else
+ {
+ stop = 1;
+ ungetc(tmp, yyin);
+ }
+ }
+ }
+ }
+ else
+ return ERROR_TOK;
+ }
+ if (nInBuf < BUFSIZE - 1)
+ buf[nInBuf++] = ch;
}
- if ( ch == '"' ) {
- buf[nInBuf++] = '\0';
- if ( scanStr )
- uFree( scanStr );
- scanStr = (char *)uStringDup(buf);
- scanStrLine = lineNum;
- return STRING;
+ if (ch == '"')
+ {
+ buf[nInBuf++] = '\0';
+ if (scanStr)
+ uFree(scanStr);
+ scanStr = (char *) uStringDup(buf);
+ scanStrLine = lineNum;
+ return STRING;
}
return ERROR_TOK;
}
@@ -221,149 +365,220 @@ int ch;
static int
yyGetKeyName(void)
{
-int ch;
+ int ch;
nInBuf = 0;
- while ( ((ch=getc(yyin))!=EOF) && (ch!='>') ) {
- if ( ch == '\\' ) {
- if ((ch = getc(yyin))!=EOF) {
- if ( ch=='n' ) ch = '\n';
- else if ( ch == 't' ) ch = '\t';
- else if ( ch == 'v' ) ch = '\v';
- else if ( ch == 'b' ) ch = '\b';
- else if ( ch == 'r' ) ch = '\r';
- else if ( ch == 'f' ) ch = '\f';
- else if ( ch == 'e' ) ch = '\033';
- else if ( ch == '0' ) {
- int tmp,stop;
- ch = stop = 0;
- if (((tmp=getc(yyin))!=EOF) && (isdigit(tmp)) &&
- (tmp!='8') && (tmp!='9')) {
- ch= (ch*8)+(tmp-'0');
- }
- else {
- stop= 1;
- ungetc(tmp,yyin);
- }
- if ((!stop) && ((tmp=getc(yyin))!=EOF) && (isdigit(tmp)) &&
- (tmp!='8') && (tmp!='9')) {
- ch= (ch*8)+(tmp-'0');
- }
- else {
- stop= 1;
- ungetc(tmp,yyin);
- }
- if ((!stop) && ((tmp=getc(yyin))!=EOF) && (isdigit(tmp)) &&
- (tmp!='8') && (tmp!='9')) {
- ch= (ch*8)+(tmp-'0');
- }
- else {
- stop= 1;
- ungetc(tmp,yyin);
- }
- }
- }
- else return ERROR_TOK;
- }
-
- if ( nInBuf < BUFSIZE-1 )
- buf[nInBuf++] = ch;
+ while (((ch = getc(yyin)) != EOF) && (ch != '>'))
+ {
+ if (ch == '\\')
+ {
+ if ((ch = getc(yyin)) != EOF)
+ {
+ if (ch == 'n')
+ ch = '\n';
+ else if (ch == 't')
+ ch = '\t';
+ else if (ch == 'v')
+ ch = '\v';
+ else if (ch == 'b')
+ ch = '\b';
+ else if (ch == 'r')
+ ch = '\r';
+ else if (ch == 'f')
+ ch = '\f';
+ else if (ch == 'e')
+ ch = '\033';
+ else if (ch == '0')
+ {
+ int tmp, stop;
+ ch = stop = 0;
+ if (((tmp = getc(yyin)) != EOF) && (isdigit(tmp))
+ && (tmp != '8') && (tmp != '9'))
+ {
+ ch = (ch * 8) + (tmp - '0');
+ }
+ else
+ {
+ stop = 1;
+ ungetc(tmp, yyin);
+ }
+ if ((!stop) && ((tmp = getc(yyin)) != EOF)
+ && (isdigit(tmp)) && (tmp != '8') && (tmp != '9'))
+ {
+ ch = (ch * 8) + (tmp - '0');
+ }
+ else
+ {
+ stop = 1;
+ ungetc(tmp, yyin);
+ }
+ if ((!stop) && ((tmp = getc(yyin)) != EOF)
+ && (isdigit(tmp)) && (tmp != '8') && (tmp != '9'))
+ {
+ ch = (ch * 8) + (tmp - '0');
+ }
+ else
+ {
+ stop = 1;
+ ungetc(tmp, yyin);
+ }
+ }
+ }
+ else
+ return ERROR_TOK;
+ }
+
+ if (nInBuf < BUFSIZE - 1)
+ buf[nInBuf++] = ch;
}
- if (( ch == '>' )&&(nInBuf<5)) {
- buf[nInBuf++] = '\0';
- if ( scanStr )
- uFree( scanStr );
- scanStr = (char *)uStringDup(buf);
- scanStrLine = lineNum;
- return KEYNAME;
+ if ((ch == '>') && (nInBuf < 5))
+ {
+ buf[nInBuf++] = '\0';
+ if (scanStr)
+ uFree(scanStr);
+ scanStr = (char *) uStringDup(buf);
+ scanStrLine = lineNum;
+ return KEYNAME;
}
return ERROR_TOK;
}
-struct _Keyword {
- const char *keyword;
- int token;
-} keywords[] = {
- { "xkb_keymap", XKB_KEYMAP },
- { "xkb_keycodes", XKB_KEYCODES },
- { "xkb_types", XKB_TYPES },
- { "xkb_symbols", XKB_SYMBOLS },
- { "xkb_compat", XKB_COMPATMAP },
- { "xkb_compat_map", XKB_COMPATMAP },
- { "xkb_compatibility", XKB_COMPATMAP },
- { "xkb_compatibility_map", XKB_COMPATMAP },
- { "xkb_geometry", XKB_GEOMETRY },
- { "xkb_semantics", XKB_SEMANTICS },
- { "xkb_layout", XKB_LAYOUT },
- { "include", INCLUDE },
- { "override", OVERRIDE },
- { "augment", AUGMENT },
- { "replace", REPLACE },
- { "alternate", ALTERNATE },
- { "partial", PARTIAL },
- { "default", DEFAULT },
- { "hidden", HIDDEN },
- { "virtual_modifiers", VIRTUAL_MODS },
- { "type", TYPE },
- { "interpret", INTERPRET },
- { "action", ACTION_TOK },
- { "key", KEY },
- { "alias", ALIAS },
- { "group", GROUP },
- { "modmap", MODIFIER_MAP },
- { "mod_map", MODIFIER_MAP },
- { "modifier_map", MODIFIER_MAP },
- { "indicator", INDICATOR },
- { "shape", SHAPE },
- { "row", ROW },
- { "keys", KEYS },
- { "section", SECTION },
- { "overlay", OVERLAY },
- { "text", TEXT },
- { "outline", OUTLINE },
- { "solid", SOLID },
- { "logo", LOGO },
- { "virtual", VIRTUAL },
- { "alphanumeric_keys", ALPHANUMERIC_KEYS },
- { "modifier_keys", MODIFIER_KEYS },
- { "keypad_keys", KEYPAD_KEYS },
- { "function_keys", FUNCTION_KEYS },
- { "alternate_group", ALTERNATE_GROUP }
+static struct _Keyword
+{
+ const char *keyword;
+ int token;
+} keywords[] =
+{
+ {
+ "xkb_keymap", XKB_KEYMAP},
+ {
+ "xkb_keycodes", XKB_KEYCODES},
+ {
+ "xkb_types", XKB_TYPES},
+ {
+ "xkb_symbols", XKB_SYMBOLS},
+ {
+ "xkb_compat", XKB_COMPATMAP},
+ {
+ "xkb_compat_map", XKB_COMPATMAP},
+ {
+ "xkb_compatibility", XKB_COMPATMAP},
+ {
+ "xkb_compatibility_map", XKB_COMPATMAP},
+ {
+ "xkb_geometry", XKB_GEOMETRY},
+ {
+ "xkb_semantics", XKB_SEMANTICS},
+ {
+ "xkb_layout", XKB_LAYOUT},
+ {
+ "include", INCLUDE},
+ {
+ "override", OVERRIDE},
+ {
+ "augment", AUGMENT},
+ {
+ "replace", REPLACE},
+ {
+ "alternate", ALTERNATE},
+ {
+ "partial", PARTIAL},
+ {
+ "default", DEFAULT},
+ {
+ "hidden", HIDDEN},
+ {
+ "virtual_modifiers", VIRTUAL_MODS},
+ {
+ "type", TYPE},
+ {
+ "interpret", INTERPRET},
+ {
+ "action", ACTION_TOK},
+ {
+ "key", KEY},
+ {
+ "alias", ALIAS},
+ {
+ "group", GROUP},
+ {
+ "modmap", MODIFIER_MAP},
+ {
+ "mod_map", MODIFIER_MAP},
+ {
+ "modifier_map", MODIFIER_MAP},
+ {
+ "indicator", INDICATOR},
+ {
+ "shape", SHAPE},
+ {
+ "row", ROW},
+ {
+ "keys", KEYS},
+ {
+ "section", SECTION},
+ {
+ "overlay", OVERLAY},
+ {
+ "text", TEXT},
+ {
+ "outline", OUTLINE},
+ {
+ "solid", SOLID},
+ {
+ "logo", LOGO},
+ {
+ "virtual", VIRTUAL},
+ {
+ "alphanumeric_keys", ALPHANUMERIC_KEYS},
+ {
+ "modifier_keys", MODIFIER_KEYS},
+ {
+ "keypad_keys", KEYPAD_KEYS},
+ {
+ "function_keys", FUNCTION_KEYS},
+ {
+ "alternate_group", ALTERNATE_GROUP}
};
-int numKeywords = sizeof(keywords)/sizeof(struct _Keyword);
+static int numKeywords = sizeof(keywords) / sizeof(struct _Keyword);
static int
yyGetIdent(int first)
{
-int ch,i,found;
-int rtrn = IDENT;
-
- buf[0] = first; nInBuf = 1;
- while ( ((ch=getc(yyin))!=EOF) && (isalnum(ch)||(ch=='_')) ) {
- if ( nInBuf < BUFSIZE - 1 )
- buf[nInBuf++] = ch;
+ int ch, i, found;
+ int rtrn = IDENT;
+
+ buf[0] = first;
+ nInBuf = 1;
+ while (((ch = getc(yyin)) != EOF) && (isalnum(ch) || (ch == '_')))
+ {
+ if (nInBuf < BUFSIZE - 1)
+ buf[nInBuf++] = ch;
}
buf[nInBuf++] = '\0';
- found= 0;
-
- for (i=0;(!found)&&(i<numKeywords);i++) {
- if (uStrCaseCmp(buf,keywords[i].keyword)==0) {
- rtrn= keywords[i].token;
- found= 1;
- }
+ found = 0;
+
+ for (i = 0; (!found) && (i < numKeywords); i++)
+ {
+ if (uStrCaseCmp(buf, keywords[i].keyword) == 0)
+ {
+ rtrn = keywords[i].token;
+ found = 1;
+ }
}
- if (!found) {
- if ( scanStr )
- uFree( scanStr );
- scanStr = (char *)uStringDup(buf);
- scanStrLine = lineNum;
- rtrn = IDENT;
+ if (!found)
+ {
+ if (scanStr)
+ uFree(scanStr);
+ scanStr = (char *) uStringDup(buf);
+ scanStrLine = lineNum;
+ rtrn = IDENT;
}
- if ( (ch!=EOF) && (!isspace(ch)) )
- ungetc( ch, yyin );
- else if ( ch=='\n' )
- lineNum++;
+ if ((ch != EOF) && (!isspace(ch)))
+ ungetc(ch, yyin);
+ else if (ch == '\n')
+ lineNum++;
return rtrn;
}
@@ -371,98 +586,138 @@ int rtrn = IDENT;
static int
yyGetNumber(int ch)
{
-int isFloat= 0;
-
- buf[0]= ch;
- nInBuf= 1;
- while (((ch=getc(yyin))!=EOF)&&(isxdigit(ch)||((nInBuf==1)&&(ch=='x')))) {
- buf[nInBuf++]= ch;
+ int isFloat = 0;
+
+ buf[0] = ch;
+ nInBuf = 1;
+ while (((ch = getc(yyin)) != EOF)
+ && (isxdigit(ch) || ((nInBuf == 1) && (ch == 'x'))))
+ {
+ buf[nInBuf++] = ch;
}
- if (ch=='.') {
- isFloat= 1;
- buf[nInBuf++]= ch;
- while (((ch=getc(yyin))!=EOF)&&(isxdigit(ch))) {
- buf[nInBuf++]= ch;
- }
+ if (ch == '.')
+ {
+ isFloat = 1;
+ buf[nInBuf++] = ch;
+ while (((ch = getc(yyin)) != EOF) && (isxdigit(ch)))
+ {
+ buf[nInBuf++] = ch;
+ }
}
- buf[nInBuf++]= '\0';
- if ((ch!=EOF)&&(!isspace(ch)))
- ungetc( ch, yyin );
-
- if (isFloat) {
- float tmp;
- if (sscanf(buf,"%g",&tmp)==1) {
- scanInt= tmp*XkbGeomPtsPerMM;
- return FLOAT;
- }
+ buf[nInBuf++] = '\0';
+ if ((ch != EOF) && (!isspace(ch)))
+ ungetc(ch, yyin);
+
+ if (isFloat)
+ {
+ float tmp;
+ if (sscanf(buf, "%g", &tmp) == 1)
+ {
+ scanInt = tmp * XkbGeomPtsPerMM;
+ return FLOAT;
+ }
}
- else if ( sscanf(buf,"%i",&scanInt)==1 )
- return INTEGER;
- fprintf(stderr,"Malformed number %s\n",buf);
+ else if (sscanf(buf, "%i", &scanInt) == 1)
+ return INTEGER;
+ fprintf(stderr, "Malformed number %s\n", buf);
return ERROR_TOK;
}
int
yylex(void)
{
-int ch;
-int rtrn;
-
- do {
- ch = getc(yyin);
- if ( ch == '\n' ) {
- lineNum++;
- }
- else if ( ch=='#' ) { /* handle shell style '#' comments */
- do {
- ch= getc(yyin);
- } while ((ch!='\n')&&(ch!=EOF));
- lineNum++;
- }
- else if ( ch=='/' ) { /* handle C++ style double-/ comments */
- int newch= getc(yyin);
- if (newch=='/') {
- do {
- ch= getc(yyin);
- } while ((ch!='\n')&&(ch!=EOF));
- lineNum++;
- }
- else if (newch!=EOF) {
- ungetc(newch,yyin);
- }
- }
- } while ((ch!=EOF)&&(isspace(ch)));
- if ( ch == '=' ) rtrn = EQUALS;
- else if ( ch == '+' ) rtrn = PLUS;
- else if ( ch == '-' ) rtrn = MINUS;
- else if ( ch == '/' ) rtrn = DIVIDE;
- else if ( ch == '*' ) rtrn = TIMES;
- else if ( ch == '{' ) rtrn = OBRACE;
- else if ( ch == '}' ) rtrn = CBRACE;
- else if ( ch == '(' ) rtrn = OPAREN;
- else if ( ch == ')' ) rtrn = CPAREN;
- else if ( ch == '[' ) rtrn = OBRACKET;
- else if ( ch == ']' ) rtrn = CBRACKET;
- else if ( ch == '.' ) rtrn = DOT;
- else if ( ch == ',' ) rtrn = COMMA;
- else if ( ch == ';' ) rtrn = SEMI;
- else if ( ch == '!' ) rtrn = EXCLAM;
- else if ( ch == '~' ) rtrn = INVERT;
- else if ( ch == '"' ) rtrn = yyGetString();
- else if ( ch == '<' ) rtrn = yyGetKeyName();
- else if ( isalpha(ch) || (ch=='_')) rtrn = yyGetIdent(ch);
- else if ( isdigit(ch) ) rtrn = yyGetNumber(ch);
- else if ( ch == EOF ) rtrn = END_OF_FILE;
- else {
+ int ch;
+ int rtrn;
+
+ do
+ {
+ ch = getc(yyin);
+ if (ch == '\n')
+ {
+ lineNum++;
+ }
+ else if (ch == '#')
+ { /* handle shell style '#' comments */
+ do
+ {
+ ch = getc(yyin);
+ }
+ while ((ch != '\n') && (ch != EOF));
+ lineNum++;
+ }
+ else if (ch == '/')
+ { /* handle C++ style double-/ comments */
+ int newch = getc(yyin);
+ if (newch == '/')
+ {
+ do
+ {
+ ch = getc(yyin);
+ }
+ while ((ch != '\n') && (ch != EOF));
+ lineNum++;
+ }
+ else if (newch != EOF)
+ {
+ ungetc(newch, yyin);
+ }
+ }
+ }
+ while ((ch != EOF) && (isspace(ch)));
+ if (ch == '=')
+ rtrn = EQUALS;
+ else if (ch == '+')
+ rtrn = PLUS;
+ else if (ch == '-')
+ rtrn = MINUS;
+ else if (ch == '/')
+ rtrn = DIVIDE;
+ else if (ch == '*')
+ rtrn = TIMES;
+ else if (ch == '{')
+ rtrn = OBRACE;
+ else if (ch == '}')
+ rtrn = CBRACE;
+ else if (ch == '(')
+ rtrn = OPAREN;
+ else if (ch == ')')
+ rtrn = CPAREN;
+ else if (ch == '[')
+ rtrn = OBRACKET;
+ else if (ch == ']')
+ rtrn = CBRACKET;
+ else if (ch == '.')
+ rtrn = DOT;
+ else if (ch == ',')
+ rtrn = COMMA;
+ else if (ch == ';')
+ rtrn = SEMI;
+ else if (ch == '!')
+ rtrn = EXCLAM;
+ else if (ch == '~')
+ rtrn = INVERT;
+ else if (ch == '"')
+ rtrn = yyGetString();
+ else if (ch == '<')
+ rtrn = yyGetKeyName();
+ else if (isalpha(ch) || (ch == '_'))
+ rtrn = yyGetIdent(ch);
+ else if (isdigit(ch))
+ rtrn = yyGetNumber(ch);
+ else if (ch == EOF)
+ rtrn = END_OF_FILE;
+ else
+ {
#ifdef DEBUG
- if (debugFlags)
- fprintf(stderr,"Unexpected character %c (%d) in input stream\n",ch,ch);
+ if (debugFlags)
+ fprintf(stderr,
+ "Unexpected character %c (%d) in input stream\n", ch, ch);
#endif
- rtrn = ERROR_TOK;
+ rtrn = ERROR_TOK;
}
#ifdef DEBUG
- if (debugFlags&0x2)
- fprintf(stderr,"scan: %s\n",tokText(rtrn));
+ if (debugFlags & 0x2)
+ fprintf(stderr, "scan: %s\n", tokText(rtrn));
#endif
return rtrn;
}