summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/X11/extensions/XKBconfig.h7
-rw-r--r--include/X11/extensions/XKBrules.h71
-rw-r--r--include/X11/extensions/XKMformat.h4
-rw-r--r--src/cout.c18
-rw-r--r--src/maprules.c664
-rw-r--r--src/srvmisc.c5
-rw-r--r--src/xkbatom.c3
-rw-r--r--src/xkbconfig.c151
-rw-r--r--src/xkbdraw.c3
-rw-r--r--src/xkberrs.c6
-rw-r--r--src/xkbmisc.c78
-rw-r--r--src/xkbout.c18
-rw-r--r--src/xkbtext.c15
-rw-r--r--src/xkmout.c7
-rw-r--r--src/xkmread.c13
15 files changed, 745 insertions, 318 deletions
diff --git a/include/X11/extensions/XKBconfig.h b/include/X11/extensions/XKBconfig.h
index 5c38b6f..f139125 100644
--- a/include/X11/extensions/XKBconfig.h
+++ b/include/X11/extensions/XKBconfig.h
@@ -27,6 +27,7 @@
THE USE OR PERFORMANCE OF THIS SOFTWARE.
********************************************************/
+/* $XFree86: xc/lib/xkbfile/XKBconfig.h,v 3.5 2001/01/17 19:43:39 dawes Exp $ */
typedef struct _XkbConfigRtrn *XkbConfigRtrnPtr;
@@ -93,6 +94,7 @@ typedef struct _XkbConfigUnboundMod {
#define XkbCF_AccessXTimeoutOptsOn (1L<<7)
#define XkbCF_AccessXTimeoutOptsOff (1L<<8)
#define XkbCF_GroupsWrap (1L<<9)
+#define XkbCF_InitialOpts (1L<<10)
typedef struct _XkbConfigRtrn {
unsigned defined;
@@ -119,10 +121,15 @@ typedef struct _XkbConfigRtrn {
char * symbols;
char * types;
char * compat;
+
Bool replace_initial_ctrls;
unsigned long initial_ctrls;
unsigned long initial_ctrls_clear;
+ Bool replace_initial_opts;
+ unsigned short initial_opts;
+ unsigned short initial_opts_clear;
+
XkbConfigModInfoRec initial_mods;
XkbConfigModInfoRec internal_mods;
XkbConfigModInfoRec ignore_lock_mods;
diff --git a/include/X11/extensions/XKBrules.h b/include/X11/extensions/XKBrules.h
index ffc5138..61f1551 100644
--- a/include/X11/extensions/XKBrules.h
+++ b/include/X11/extensions/XKBrules.h
@@ -27,6 +27,7 @@
THE USE OR PERFORMANCE OF THIS SOFTWARE.
********************************************************/
+/* $XFree86: xc/lib/xkbfile/XKBrules.h,v 3.5 2002/11/26 01:43:25 dawes Exp $ */
/***====================================================================***/
@@ -53,6 +54,9 @@ typedef struct _XkbRF_DescribeVars {
} XkbRF_DescribeVarsRec,*XkbRF_DescribeVarsPtr;
typedef struct _XkbRF_Rule {
+ int number;
+ int layout_num;
+ int variant_num;
char * model;
char * layout;
char * variant;
@@ -67,10 +71,17 @@ typedef struct _XkbRF_Rule {
unsigned flags;
} XkbRF_RuleRec,*XkbRF_RulePtr;
+typedef struct _XkbRF_Group {
+ int number;
+ char * name;
+ char * words;
+} XkbRF_GroupRec, *XkbRF_GroupPtr;
+
#define XkbRF_PendingMatch (1L<<1)
-#define XkbRF_Delayed (1L<<2)
+#define XkbRF_Option (1L<<2)
#define XkbRF_Append (1L<<3)
-#define XkbRF_Invalid (1L<<4)
+#define XkbRF_Normal (1L<<4)
+#define XkbRF_Invalid (1L<<5)
typedef struct _XkbRF_Rules {
XkbRF_DescribeVarsRec models;
@@ -85,63 +96,15 @@ typedef struct _XkbRF_Rules {
unsigned short sz_rules;
unsigned short num_rules;
XkbRF_RulePtr rules;
+ unsigned short sz_groups;
+ unsigned short num_groups;
+ XkbRF_GroupPtr groups;
} XkbRF_RulesRec, *XkbRF_RulesPtr;
/***====================================================================***/
_XFUNCPROTOBEGIN
-extern Bool XkbRF_ApplyRule(
-#if NeedFunctionPrototypes
- XkbRF_RulePtr /* rule */,
- XkbComponentNamesPtr /* names */
-#endif
-);
-
-extern Bool XkbRF_CheckApplyRule(
-#if NeedFunctionPrototypes
- XkbRF_RulePtr /* rule */,
- XkbRF_VarDefsPtr /* defs */,
- XkbComponentNamesPtr /* names */
-#endif
-);
-
-extern void XkbRF_ClearPartialMatches(
-#if NeedFunctionPrototypes
- XkbRF_RulesPtr /* rules */
-#endif
-);
-
-extern Bool XkbRF_ApplyPartialMatches(
-#if NeedFunctionPrototypes
- XkbRF_RulesPtr /* rules */,
- XkbComponentNamesPtr /* names */
-#endif
-);
-
-extern void XkbRF_CheckApplyDelayedRules(
-#if NeedFunctionPrototypes
- XkbRF_RulesPtr /* rules */,
- XkbRF_VarDefsPtr /* defs */,
- XkbComponentNamesPtr /* names */
-#endif
-);
-
-extern Bool XkbRF_CheckApplyRules(
-#if NeedFunctionPrototypes
- XkbRF_RulesPtr /* rules */,
- XkbRF_VarDefsPtr /* defs */,
- XkbComponentNamesPtr /* names */
-#endif
-);
-
-extern char * XkbRF_SubstituteVars(
-#if NeedFunctionPrototypes
- char * /* p_name */,
- XkbRF_VarDefsPtr /* defs */
-#endif
-);
-
extern Bool XkbRF_GetComponents(
#if NeedFunctionPrototypes
XkbRF_RulesPtr /* rules */,
@@ -156,6 +119,8 @@ extern XkbRF_RulePtr XkbRF_AddRule(
#endif
);
+extern XkbRF_GroupPtr XkbRF_AddGroup(XkbRF_RulesPtr rules);
+
extern Bool XkbRF_LoadRules(
#if NeedFunctionPrototypes
FILE * /* file */,
diff --git a/include/X11/extensions/XKMformat.h b/include/X11/extensions/XKMformat.h
index 9e70845..8834630 100644
--- a/include/X11/extensions/XKMformat.h
+++ b/include/X11/extensions/XKMformat.h
@@ -24,12 +24,14 @@
THE USE OR PERFORMANCE OF THIS SOFTWARE.
********************************************************/
+/* $XFree86: xc/lib/xkbfile/XKMformat.h,v 1.2 2001/08/01 00:44:44 tsi Exp $ */
+
#ifndef _XKMFORMAT_H_
#define _XKMFORMAT_H_ 1
#include <X11/extensions/XKB.h>
#include <X11/extensions/XKBproto.h>
-#include "XKM.h"
+#include <X11/extensions/XKM.h>
typedef struct _xkmFileInfo {
CARD8 type;
diff --git a/src/cout.c b/src/cout.c
index 4d7c147..f8deed2 100644
--- a/src/cout.c
+++ b/src/cout.c
@@ -24,12 +24,11 @@
THE USE OR PERFORMANCE OF THIS SOFTWARE.
********************************************************/
+ /* $XFree86: xc/lib/xkbfile/cout.c,v 3.8 2003/02/03 20:12:00 paulo Exp $ */
#include <stdio.h>
#include <ctype.h>
-#ifndef X_NOT_STDC_ENV
#include <stdlib.h>
-#endif
#include <X11/Xos.h>
#include <X11/Xlib.h>
#include <X11/XKBlib.h>
@@ -364,8 +363,8 @@ register unsigned i;
if (i==0) fprintf(file," ");
else if ((i&3)==0) fprintf(file,",\n ");
else fprintf(file,", ");
- fprintf(file,"{ %2d, 0x%x, %3d }",map->kt_index,map->group_info,
- map->offset);
+ fprintf(file, "{ %2d, 0x%x, %3d }",
+ map->kt_index[0], map->group_info, map->offset);
}
fprintf(file,"\n};\n");
}
@@ -496,17 +495,18 @@ XkbIndicatorMapPtr imap;
if (xkb->indicators==NULL)
return True;
- fprintf(file,"static XkbIndicatorRec indicators= {\n");
- fprintf(file," 0x%x,\n {\n",xkb->indicators->phys_indicators);
+ fprintf(file, "static XkbIndicatorRec indicators= {\n");
+ fprintf(file, " 0x%lx,\n {\n",
+ (long)xkb->indicators->phys_indicators);
for (imap=xkb->indicators->maps,i=nNames=0;i<XkbNumIndicators;i++,imap++) {
- fprintf(file,"%s { 0x%02x, %s, 0x%02x, %s, %s, ",
+ fprintf(file,"%s { 0x%02x, %s, 0x%02x, %s, { %s, ",
(i!=0?",\n":""),
imap->flags,
XkbIMWhichStateMaskText(imap->which_groups,XkbCFile),
imap->groups,
XkbIMWhichStateMaskText(imap->which_mods,XkbCFile),
XkbModMaskText(imap->mods.mask,XkbCFile));
- fprintf(file," %s, %s, %s }",
+ fprintf(file," %s, %s }, %s }",
XkbModMaskText(imap->mods.real_mods,XkbCFile),
XkbVModMaskText(dpy,xkb,0,imap->mods.vmods,XkbCFile),
XkbControlsMaskText(imap->ctrls,XkbCFile));
@@ -1208,7 +1208,7 @@ Bool (*func)(
if (tmp==NULL)
tmp= name;
else tmp++;
- hdrdef= (char *)_XkbCalloc(strlen(tmp+1),sizeof(char));
+ hdrdef= (char *)_XkbCalloc(strlen(tmp)+1,sizeof(char));
if (hdrdef) {
strcpy(hdrdef,tmp);
tmp= hdrdef;
diff --git a/src/maprules.c b/src/maprules.c
index 559dc9c..8c5ce1a 100644
--- a/src/maprules.c
+++ b/src/maprules.c
@@ -24,13 +24,11 @@
THE USE OR PERFORMANCE OF THIS SOFTWARE.
********************************************************/
+/* $XFree86: xc/lib/xkbfile/maprules.c,v 3.17 2002/11/26 01:43:25 dawes Exp $ */
#include <stdio.h>
#include <ctype.h>
-#ifndef X_NOT_STDC_ENV
#include <stdlib.h>
-#endif
-
#define X_INCLUDE_STRING_H
#define XOS_USE_NO_LOCKING
@@ -69,11 +67,13 @@
#endif
#ifdef DEBUG
-#define PR_DEBUG(s) fprintf(stderr,s)
-#define PR_DEBUG1(s,a) fprintf(stderr,s,a)
+#define PR_DEBUG(s) fprintf(stderr,s)
+#define PR_DEBUG1(s,a) fprintf(stderr,s,a)
+#define PR_DEBUG2(s,a,b) fprintf(stderr,s,a,b)
#else
#define PR_DEBUG(s)
#define PR_DEBUG1(s,a)
+#define PR_DEBUG2(s,a,b)
#endif
/***====================================================================***/
@@ -254,8 +254,12 @@ static char * cname[MAX_WORDS] = {
};
typedef struct _RemapSpec {
+ int number;
int num_remap;
- int remap[MAX_WORDS];
+ struct {
+ int word;
+ int index;
+ } remap[MAX_WORDS];
} RemapSpec;
typedef struct _FileSpec {
@@ -263,8 +267,49 @@ typedef struct _FileSpec {
struct _FileSpec * pending;
} FileSpec;
+typedef struct {
+ char * model;
+ char * layout[XkbNumKbdGroups+1];
+ char * variant[XkbNumKbdGroups+1];
+ char * options;
+} XkbRF_MultiDefsRec, *XkbRF_MultiDefsPtr;
+
+#define NDX_BUFF_SIZE 4
+
/***====================================================================***/
+static char*
+#if NeedFunctionPrototypes
+get_index(char *str, int *ndx)
+#else
+get_index(str, ndx)
+ char *str;
+ int *ndx;
+#endif
+{
+ char ndx_buf[NDX_BUFF_SIZE];
+ char *end;
+
+ if (*str != '[') {
+ *ndx = 0;
+ return str;
+ }
+ str++;
+ end = strchr(str, ']');
+ if (end == NULL) {
+ *ndx = -1;
+ return str - 1;
+ }
+ if ( (end - str) >= NDX_BUFF_SIZE) {
+ *ndx = -1;
+ return end + 1;
+ }
+ strncpy(ndx_buf, str, end - str);
+ ndx_buf[end - str] = '\0';
+ *ndx = atoi(ndx_buf);
+ return end + 1;
+}
+
static void
#if NeedFunctionPrototypes
SetUpRemap(InputLine *line,RemapSpec *remap)
@@ -275,16 +320,20 @@ SetUpRemap(line,remap)
#endif
{
char * tok,*str;
-unsigned present;
+unsigned present, l_ndx_present, v_ndx_present;
register int i;
+int len, ndx;
+_Xstrtokparams strtok_buf;
#ifdef DEBUG
Bool found;
#endif
-_Xstrtokparams strtok_buf;
- present= 0;
+
+ l_ndx_present = v_ndx_present = present= 0;
str= &line->line[1];
+ len = remap->number;
bzero((char *)remap,sizeof(RemapSpec));
+ remap->number = len;
while ((tok=_XStrtok(str," ",strtok_buf))!=NULL) {
#ifdef DEBUG
found= False;
@@ -293,17 +342,40 @@ _Xstrtokparams strtok_buf;
if (strcmp(tok,"=")==0)
continue;
for (i=0;i<MAX_WORDS;i++) {
- if (strcmp(cname[i],tok)==0) {
+ len = strlen(cname[i]);
+ if (strncmp(cname[i],tok,len)==0) {
+ if(strlen(tok) > len) {
+ char *end = get_index(tok+len, &ndx);
+ if ((i != LAYOUT && i != VARIANT) ||
+ *end != '\0' || ndx == -1)
+ break;
+ if (ndx < 1 || ndx > XkbNumKbdGroups) {
+ PR_DEBUG2("Illegal %s index: %d\n", cname[i], ndx);
+ PR_DEBUG1("Index must be in range 1..%d\n",
+ XkbNumKbdGroups);
+ break;
+ }
+ } else {
+ ndx = 0;
+ }
#ifdef DEBUG
found= True;
#endif
if (present&(1<<i)) {
- PR_DEBUG1("Component \"%s\" listed twice\n",tok);
- PR_DEBUG("Second definition ignored\n");
- break;
+ if ((i == LAYOUT && l_ndx_present&(1<<ndx)) ||
+ (i == VARIANT && v_ndx_present&(1<<ndx)) ) {
+ PR_DEBUG1("Component \"%s\" listed twice\n",tok);
+ PR_DEBUG("Second definition ignored\n");
+ break;
+ }
}
- present|= (1<<i);
- remap->remap[remap->num_remap++]= i;
+ present |= (1<<i);
+ if (i == LAYOUT)
+ l_ndx_present |= 1 << ndx;
+ if (i == VARIANT)
+ v_ndx_present |= 1 << ndx;
+ remap->remap[remap->num_remap].word= i;
+ remap->remap[remap->num_remap++].index= ndx;
break;
}
}
@@ -316,8 +388,8 @@ _Xstrtokparams strtok_buf;
if ((present&PART_MASK)==0) {
#ifdef DEBUG
unsigned mask= PART_MASK;
- fprintf(stderr,"Mapping needs at one of ");
- for (i=0;(i<MAX_WORDS)&mask;i++) {
+ fprintf(stderr,"Mapping needs at least one of ");
+ for (i=0; (i<MAX_WORDS); i++) {
if ((1L<<i)&mask) {
mask&= ~(1L<<i);
if (mask) fprintf(stderr,"\"%s,\" ",cname[i]);
@@ -349,6 +421,7 @@ _Xstrtokparams strtok_buf;
remap->num_remap= 0;
return;
}
+ remap->number++;
return;
}
@@ -386,23 +459,52 @@ static Bool
#if NeedFunctionPrototypes
CheckLine( InputLine * line,
RemapSpec * remap,
- XkbRF_RulePtr rule)
+ XkbRF_RulePtr rule,
+ XkbRF_GroupPtr group)
#else
-CheckLine(line,remap,rule)
+CheckLine(line,remap,rule,group)
InputLine * line;
RemapSpec * remap;
XkbRF_RulePtr rule;
+ XkbRF_GroupsPtr group;
#endif
{
char * str,*tok;
-register int nread;
+register int nread, i;
FileSpec tmp;
_Xstrtokparams strtok_buf;
+Bool append = False;
if (line->line[0]=='!') {
- SetUpRemap(line,remap);
- return False;
+ if (line->line[1] == '$' ||
+ (line->line[1] == ' ' && line->line[2] == '$')) {
+ char *gname = strchr(line->line, '$');
+ char *words = strchr(gname, ' ');
+ if(!words)
+ return False;
+ *words++ = '\0';
+ for (; *words; words++) {
+ if (*words != '=' && *words != ' ')
+ break;
+ }
+ if (*words == '\0')
+ return False;
+ group->name = _XkbDupString(gname);
+ group->words = _XkbDupString(words);
+ for (i = 1, words = group->words; *words; words++) {
+ if ( *words == ' ') {
+ *words++ = '\0';
+ i++;
+ }
+ }
+ group->number = i;
+ return True;
+ } else {
+ SetUpRemap(line,remap);
+ return False;
+ }
}
+
if (remap->num_remap==0) {
PR_DEBUG("Must have a mapping before first line of data\n");
PR_DEBUG("Illegal line of data ignored\n");
@@ -421,23 +523,24 @@ _Xstrtokparams strtok_buf;
PR_DEBUG1("Extra word \"%s\" ignored\n",tok);
continue;
}
- tmp.name[remap->remap[nread]]= tok;
+ tmp.name[remap->remap[nread].word]= tok;
+ if (*tok == '+' || *tok == '|')
+ append = True;
}
if (nread<remap->num_remap) {
- PR_DEBUG("Too few words on a line\n");
+ PR_DEBUG1("Too few words on a line: %s\n", line->line);
PR_DEBUG("line ignored\n");
return False;
}
- if ((tmp.name[MODEL]!=NULL)&&(strcmp(tmp.name[MODEL],"*")==0))
- tmp.name[MODEL]= NULL;
- if ((tmp.name[LAYOUT]!=NULL)&&(strcmp(tmp.name[LAYOUT],"*")==0))
- tmp.name[LAYOUT]= NULL;
- if ((tmp.name[VARIANT]!=NULL)&&(strcmp(tmp.name[VARIANT],"*")==0))
- tmp.name[VARIANT]= NULL;
rule->flags= 0;
+ rule->number = remap->number;
if (tmp.name[OPTION])
- rule->flags|= XkbRF_Delayed|XkbRF_Append;
+ rule->flags|= XkbRF_Option;
+ else if (append)
+ rule->flags|= XkbRF_Append;
+ else
+ rule->flags|= XkbRF_Normal;
rule->model= _XkbDupString(tmp.name[MODEL]);
rule->layout= _XkbDupString(tmp.name[LAYOUT]);
rule->variant= _XkbDupString(tmp.name[VARIANT]);
@@ -449,6 +552,16 @@ _Xstrtokparams strtok_buf;
rule->compat= _XkbDupString(tmp.name[COMPAT]);
rule->geometry= _XkbDupString(tmp.name[GEOMETRY]);
rule->keymap= _XkbDupString(tmp.name[KEYMAP]);
+
+ rule->layout_num = rule->variant_num = 0;
+ for (i = 0; i < nread; i++) {
+ if (remap->remap[i].index) {
+ if (remap->remap[i].word == LAYOUT)
+ rule->layout_num = remap->remap[i].index;
+ if (remap->remap[i].word == VARIANT)
+ rule->variant_num = remap->remap[i].index;
+ }
+ }
return True;
}
@@ -465,14 +578,127 @@ int len;
if ((!str1)||(!str2))
return str1;
- len= strlen(str1)+strlen(str2)+1;
+ len= strlen(str1)+strlen(str2)+1;
str1= _XkbTypedRealloc(str1,len,char);
if (str1)
strcat(str1,str2);
return str1;
}
-Bool
+static void
+#if NeedFunctionPrototypes
+squeeze_spaces(char *p1)
+#else
+squeeze_spaces(p1)
+ char *p1;
+#endif
+{
+ char *p2;
+ for (p2 = p1; *p2; p2++) {
+ *p1 = *p2;
+ if (*p1 != ' ') p1++;
+ }
+ *p1 = '\0';
+}
+
+static Bool
+#if NeedFunctionPrototypes
+MakeMultiDefs(XkbRF_MultiDefsPtr mdefs, XkbRF_VarDefsPtr defs)
+#else
+MakeMultiDefs(mdefs, defs)
+ XkbRF_MultiDefsPtr mdefs
+ XkbRF_VarDefsPtr defs;
+#endif
+{
+
+ bzero((char *)mdefs,sizeof(XkbRF_MultiDefsRec));
+ mdefs->model = defs->model;
+ mdefs->options = _XkbDupString(defs->options);
+ if (mdefs->options) squeeze_spaces(mdefs->options);
+
+ if (defs->layout) {
+ if (!strchr(defs->layout, ',')) {
+ mdefs->layout[0] = defs->layout;
+ } else {
+ char *p;
+ int i;
+ mdefs->layout[1] = _XkbDupString(defs->layout);
+ if (mdefs->layout[1] == NULL)
+ return False;
+ squeeze_spaces(mdefs->layout[1]);
+ p = mdefs->layout[1];
+ for (i = 2; i <= XkbNumKbdGroups; i++) {
+ if ((p = strchr(p, ','))) {
+ *p++ = '\0';
+ mdefs->layout[i] = p;
+ } else {
+ break;
+ }
+ }
+ if (p && (p = strchr(p, ',')))
+ *p = '\0';
+ }
+ }
+
+ if (defs->variant) {
+ if (!strchr(defs->variant, ',')) {
+ mdefs->variant[0] = defs->variant;
+ } else {
+ char *p;
+ int i;
+ mdefs->variant[1] = _XkbDupString(defs->variant);
+ if (mdefs->variant[1] == NULL)
+ return False;
+ squeeze_spaces(mdefs->variant[1]);
+ p = mdefs->variant[1];
+ for (i = 2; i <= XkbNumKbdGroups; i++) {
+ if ((p = strchr(p, ','))) {
+ *p++ = '\0';
+ mdefs->variant[i] = p;
+ } else {
+ break;
+ }
+ }
+ if (p && (p = strchr(p, ',')))
+ *p = '\0';
+ }
+ }
+ return True;
+}
+
+static void
+#if NeedFunctionPrototypes
+FreeMultiDefs(XkbRF_MultiDefsPtr defs)
+#else
+FreeMultiDefs(defs)
+ XkbRF_MultiDefsPtr defs;
+#endif
+{
+ if (defs->options) _XkbFree(defs->options);
+ if (defs->layout[1]) _XkbFree(defs->layout[1]);
+ if (defs->variant[1]) _XkbFree(defs->variant[1]);
+}
+
+static void
+#if NeedFunctionPrototypes
+Apply(char *src, char **dst)
+#else
+Apply(src, dst)
+ char *src;
+ char *dst;
+#endif
+{
+ if (src) {
+ if (*src == '+' || *src == '!') {
+ *dst= _Concat(*dst, src);
+ } else {
+ if (*dst == NULL)
+ *dst= _XkbDupString(src);
+ }
+ }
+}
+
+static void
#if NeedFunctionPrototypes
XkbRF_ApplyRule( XkbRF_RulePtr rule,
XkbComponentNamesPtr names)
@@ -483,86 +709,129 @@ XkbRF_ApplyRule(rule,names)
#endif
{
rule->flags&= ~XkbRF_PendingMatch; /* clear the flag because it's applied */
- if ((rule->flags&XkbRF_Append)==0) {
- if ((names->keycodes==NULL)&&(rule->keycodes!=NULL))
- names->keycodes= _XkbDupString(rule->keycodes);
-
- if ((names->symbols==NULL)&&(rule->symbols!=NULL))
- names->symbols= _XkbDupString(rule->symbols);
-
- if ((names->types==NULL)&&(rule->types!=NULL))
- names->types= _XkbDupString(rule->types);
- if ((names->compat==NULL)&&(rule->compat!=NULL))
- names->compat= _XkbDupString(rule->compat);
-
- if ((names->geometry==NULL)&&(rule->geometry!=NULL))
- names->geometry= _XkbDupString(rule->geometry);
-
- if ((names->keymap==NULL)&&(rule->keymap!=NULL))
- names->keymap= _XkbDupString(rule->keymap);
- }
- else {
- if (rule->keycodes)
- names->keycodes= _Concat(names->keycodes,rule->keycodes);
- if (rule->symbols)
- names->symbols= _Concat(names->symbols,rule->symbols);
- if (rule->types)
- names->types= _Concat(names->types,rule->types);
- if (rule->compat)
- names->compat= _Concat(names->compat,rule->compat);
- if (rule->geometry)
- names->geometry= _Concat(names->geometry,rule->geometry);
- if (rule->keymap)
- names->keymap= _Concat(names->keymap,rule->keymap);
- }
- return (names->keycodes && names->symbols && names->types &&
- names->compat && names->geometry ) || names->keymap;
+ Apply(rule->keycodes, &names->keycodes);
+ Apply(rule->symbols, &names->symbols);
+ Apply(rule->types, &names->types);
+ Apply(rule->compat, &names->compat);
+ Apply(rule->geometry, &names->geometry);
+ Apply(rule->keymap, &names->keymap);
}
-#define CHECK_MATCH(r,d) ((((r)[0]=='?')&&((r)[1]=='\0'))||(strcmp(r,d)==0))
+static Bool
+#if NeedFunctionPrototypes
+CheckGroup( XkbRF_RulesPtr rules,
+ char * group_name,
+ char * name)
+#else
+XkbRF_CheckApplyRule(rules,group,name)
+ XkbRF_RulesPtr rules;
+ char * group_name;
+ char * name;
+#endif
+{
+ int i;
+ char *p;
+ XkbRF_GroupPtr group;
+
+ for (i = 0, group = rules->groups; i < rules->num_groups; i++, group++) {
+ if (! strcmp(group->name, group_name)) {
+ break;
+ }
+ }
+ if (i == rules->num_groups)
+ return False;
+ for (i = 0, p = group->words; i < group->number; i++, p += strlen(p)+1) {
+ if (! strcmp(p, name)) {
+ return True;
+ }
+ }
+ return False;
+}
-Bool
+static int
#if NeedFunctionPrototypes
XkbRF_CheckApplyRule( XkbRF_RulePtr rule,
- XkbRF_VarDefsPtr defs,
- XkbComponentNamesPtr names)
+ XkbRF_MultiDefsPtr mdefs,
+ XkbComponentNamesPtr names,
+ XkbRF_RulesPtr rules)
#else
-XkbRF_CheckApplyRule(rule,defs,names)
+XkbRF_CheckApplyRule(rule,mdefs,names)
XkbRF_RulePtr rule;
- XkbRF_VarDefsPtr defs;
+ XkbRF_MultiDefsPtr mdefs;
XkbComponentNamesPtr names;
+ XkbRF_RulesPtr rules;
#endif
{
- if (rule->model!=NULL) {
- if ((!defs->model)||(!CHECK_MATCH(rule->model,defs->model)))
- return False;
+ Bool pending = False;
+
+ if (rule->model != NULL) {
+ if(mdefs->model == NULL)
+ return 0;
+ if (strcmp(rule->model, "*") == 0) {
+ pending = True;
+ } else {
+ if (rule->model[0] == '$') {
+ if (!CheckGroup(rules, rule->model, mdefs->model))
+ return 0;
+ } else {
+ if (strcmp(rule->model, mdefs->model) != 0)
+ return 0;
+ }
+ }
}
- if (rule->layout!=NULL) {
- if ((!defs->layout)||(!CHECK_MATCH(rule->layout,defs->layout)))
- return False;
+ if (rule->option != NULL) {
+ if (mdefs->options == NULL)
+ return 0;
+ if ((!MatchOneOf(rule->option,mdefs->options)))
+ return 0;
}
- if (rule->variant!=NULL) {
- if ((!defs->variant)||(!CHECK_MATCH(rule->variant,defs->variant)))
- return False;
+
+ if (rule->layout != NULL) {
+ if(mdefs->layout[rule->layout_num] == NULL ||
+ *mdefs->layout[rule->layout_num] == '\0')
+ return 0;
+ if (strcmp(rule->layout, "*") == 0) {
+ pending = True;
+ } else {
+ if (rule->layout[0] == '$') {
+ if (!CheckGroup(rules, rule->layout,
+ mdefs->layout[rule->layout_num]))
+ return 0;
+ } else {
+ if (strcmp(rule->layout, mdefs->layout[rule->layout_num]) != 0)
+ return 0;
+ }
+ }
}
- if (rule->option!=NULL) {
- if ((!defs->options)||(!MatchOneOf(rule->option,defs->options)))
- return False;
+ if (rule->variant != NULL) {
+ if (mdefs->variant[rule->variant_num] == NULL ||
+ *mdefs->variant[rule->variant_num] == '\0')
+ return 0;
+ if (strcmp(rule->variant, "*") == 0) {
+ pending = True;
+ } else {
+ if (rule->variant[0] == '$') {
+ if (!CheckGroup(rules, rule->variant,
+ mdefs->variant[rule->variant_num]))
+ return 0;
+ } else {
+ if (strcmp(rule->variant,
+ mdefs->variant[rule->variant_num]) != 0)
+ return 0;
+ }
+ }
}
-
- if ((!rule->option)&&
- ((!rule->model)||(!rule->layout)||(!rule->variant))) {
- /* partial map -- partial maps are applied in the order they */
- /* appear, but all partial maps come before any options. */
- rule->flags|= XkbRF_PendingMatch;
- return False;
+ if (pending) {
+ rule->flags|= XkbRF_PendingMatch;
+ return rule->number;
}
/* exact match, apply it now */
- return XkbRF_ApplyRule(rule,names);
+ XkbRF_ApplyRule(rule,names);
+ return rule->number;
}
-void
+static void
#if NeedFunctionPrototypes
XkbRF_ClearPartialMatches(XkbRF_RulesPtr rules)
#else
@@ -578,7 +847,7 @@ XkbRF_RulePtr rule;
}
}
-Bool
+static void
#if NeedFunctionPrototypes
XkbRF_ApplyPartialMatches(XkbRF_RulesPtr rules,XkbComponentNamesPtr names)
#else
@@ -589,78 +858,57 @@ XkbRF_ApplyPartialMatches(rules,names)
{
int i;
XkbRF_RulePtr rule;
-Bool complete;
- complete= False;
- for (rule=rules->rules,i=0;(i<rules->num_rules)&&(!complete);i++,rule++) {
+ for (rule = rules->rules, i = 0; i < rules->num_rules; i++, rule++) {
if ((rule->flags&XkbRF_PendingMatch)==0)
continue;
- complete= XkbRF_ApplyRule(rule,names);
- }
- return complete;
-}
-
-void
-#if NeedFunctionPrototypes
-XkbRF_CheckApplyDelayedRules( XkbRF_RulesPtr rules,
- XkbRF_VarDefsPtr defs,
- XkbComponentNamesPtr names)
-#else
-XkbRF_CheckApplyDelayedRules(rules,defs,names)
- XkbRF_RulesPtr rules;
- XkbRF_VarDefsPtr defs;
- XkbComponentNamesPtr names;
-#endif
-{
-int i;
-XkbRF_RulePtr rule;
-
- for (rule=rules->rules,i=0;(i<rules->num_rules);i++,rule++) {
- if ((rule->flags&XkbRF_Delayed)==0)
- continue;
- XkbRF_CheckApplyRule(rule,defs,names);
+ XkbRF_ApplyRule(rule,names);
}
- return;
}
-Bool
+static void
#if NeedFunctionPrototypes
XkbRF_CheckApplyRules( XkbRF_RulesPtr rules,
- XkbRF_VarDefsPtr defs,
- XkbComponentNamesPtr names)
+ XkbRF_MultiDefsPtr mdefs,
+ XkbComponentNamesPtr names,
+ int flags)
#else
-XkbRF_CheckApplyRules(rules,defs,names)
+XkbRF_CheckApplyRules(rules, mdefs, names, flags)
XkbRF_RulesPtr rules;
- XkbRF_VarDefsPtr defs;
+ XkbRF_MultiDefsPtr mdefs;
XkbComponentNamesPtr names;
+ int flags;
#endif
{
int i;
XkbRF_RulePtr rule;
-Bool complete;
+int skip;
- complete= False;
- for (rule=rules->rules,i=0;(i<rules->num_rules)&&(!complete);i++,rule++) {
- if ((rule->flags&XkbRF_Delayed)!=0)
+ for (rule = rules->rules, i=0; i < rules->num_rules; rule++, i++) {
+ if ((rule->flags & flags) != flags)
continue;
- complete= XkbRF_CheckApplyRule(rule,defs,names);
+ skip = XkbRF_CheckApplyRule(rule, mdefs, names, rules);
+ if (skip && !(flags & XkbRF_Option)) {
+ for ( ;(i < rules->num_rules) && (rule->number == skip);
+ rule++, i++);
+ rule--; i--;
+ }
}
- return complete;
}
/***====================================================================***/
-char *
+static char *
#if NeedFunctionPrototypes
-XkbRF_SubstituteVars(char *name,XkbRF_VarDefsPtr defs)
+XkbRF_SubstituteVars(char *name, XkbRF_MultiDefsPtr mdefs)
#else
-XkbRF_SubstituteVars(name,defs)
+XkbRF_SubstituteVars(name, mdefs)
char * name;
- XkbRF_VarDefsPtr defs;
+ XkbRF_MultiDefsPtr mdefs;
#endif
{
-char *str,*outstr,*orig;
-int len;
+char *str, *outstr, *orig, *var;
+int len, ndx;
orig= name;
str= index(name,'%');
@@ -678,17 +926,22 @@ int len;
extra_len= 2;
str++;
}
-
- if ((str[1]=='l')&&defs->layout)
- len+= strlen(defs->layout)+extra_len;
- else if ((str[1]=='m')&&defs->model)
- len+= strlen(defs->model)+extra_len;
- else if ((str[1]=='v')&&defs->variant)
- len+= strlen(defs->variant)+extra_len;
- if ((pfx=='(')&&(str[2]==')')) {
+ var = str + 1;
+ str = get_index(var + 1, &ndx);
+ if (ndx == -1) {
+ str = index(str,'%');
+ continue;
+ }
+ if ((*var=='l') && mdefs->layout[ndx] && *mdefs->layout[ndx])
+ len+= strlen(mdefs->layout[ndx])+extra_len;
+ else if ((*var=='m')&&mdefs->model)
+ len+= strlen(mdefs->model)+extra_len;
+ else if ((*var=='v') && mdefs->variant[ndx] && *mdefs->variant[ndx])
+ len+= strlen(mdefs->variant[ndx])+extra_len;
+ if ((pfx=='(')&&(*str==')')) {
str++;
}
- str= index(&str[1],'%');
+ str= index(&str[0],'%');
}
name= (char *)_XkbAlloc(len+1);
str= orig;
@@ -708,26 +961,30 @@ int len;
}
else pfx= '\0';
- if ((str[0]=='l')&&(defs->layout)) {
+ var = str;
+ str = get_index(var + 1, &ndx);
+ if (ndx == -1) {
+ continue;
+ }
+ if ((*var=='l') && mdefs->layout[ndx] && *mdefs->layout[ndx]) {
if (pfx) *outstr++= pfx;
- strcpy(outstr,defs->layout);
- outstr+= strlen(defs->layout);
+ strcpy(outstr,mdefs->layout[ndx]);
+ outstr+= strlen(mdefs->layout[ndx]);
if (sfx) *outstr++= sfx;
}
- else if ((str[0]=='m')&&(defs->model)) {
+ else if ((*var=='m')&&(mdefs->model)) {
if (pfx) *outstr++= pfx;
- strcpy(outstr,defs->model);
- outstr+= strlen(defs->model);
+ strcpy(outstr,mdefs->model);
+ outstr+= strlen(mdefs->model);
if (sfx) *outstr++= sfx;
}
- else if ((str[0]=='v')&&(defs->variant)) {
+ else if ((*var=='v') && mdefs->variant[ndx] && *mdefs->variant[ndx]) {
if (pfx) *outstr++= pfx;
- strcpy(outstr,defs->variant);
- outstr+= strlen(defs->variant);
+ strcpy(outstr,mdefs->variant[ndx]);
+ outstr+= strlen(mdefs->variant[ndx]);
if (sfx) *outstr++= sfx;
}
- str++;
- if ((pfx=='(')&&(str[0]==')'))
+ if ((pfx=='(')&&(*str==')'))
str++;
}
else {
@@ -754,26 +1011,32 @@ XkbRF_GetComponents(rules,defs,names)
XkbComponentNamesPtr names;
#endif
{
-Bool complete;
+ XkbRF_MultiDefsRec mdefs;
+
+ MakeMultiDefs(&mdefs, defs);
bzero((char *)names,sizeof(XkbComponentNamesRec));
XkbRF_ClearPartialMatches(rules);
- complete= XkbRF_CheckApplyRules(rules,defs,names);
- if (!complete)
- complete= XkbRF_ApplyPartialMatches(rules,names);
- XkbRF_CheckApplyDelayedRules(rules,defs,names);
+ XkbRF_CheckApplyRules(rules, &mdefs, names, XkbRF_Normal);
+ XkbRF_ApplyPartialMatches(rules, names);
+ XkbRF_CheckApplyRules(rules, &mdefs, names, XkbRF_Append);
+ XkbRF_ApplyPartialMatches(rules, names);
+ XkbRF_CheckApplyRules(rules, &mdefs, names, XkbRF_Option);
+
if (names->keycodes)
- names->keycodes= XkbRF_SubstituteVars(names->keycodes,defs);
+ names->keycodes= XkbRF_SubstituteVars(names->keycodes, &mdefs);
if (names->symbols)
- names->symbols= XkbRF_SubstituteVars(names->symbols,defs);
+ names->symbols= XkbRF_SubstituteVars(names->symbols, &mdefs);
if (names->types)
- names->types= XkbRF_SubstituteVars(names->types,defs);
+ names->types= XkbRF_SubstituteVars(names->types, &mdefs);
if (names->compat)
- names->compat= XkbRF_SubstituteVars(names->compat,defs);
+ names->compat= XkbRF_SubstituteVars(names->compat, &mdefs);
if (names->geometry)
- names->geometry= XkbRF_SubstituteVars(names->geometry,defs);
+ names->geometry= XkbRF_SubstituteVars(names->geometry, &mdefs);
if (names->keymap)
- names->keymap= XkbRF_SubstituteVars(names->keymap,defs);
+ names->keymap= XkbRF_SubstituteVars(names->keymap, &mdefs);
+
+ FreeMultiDefs(&mdefs);
return (names->keycodes && names->symbols && names->types &&
names->compat && names->geometry ) || names->keymap;
}
@@ -807,6 +1070,33 @@ XkbRF_AddRule(rules)
return &rules->rules[rules->num_rules++];
}
+XkbRF_GroupPtr
+#if NeedFunctionPrototypes
+XkbRF_AddGroup(XkbRF_RulesPtr rules)
+#else
+XkbRF_AddGroup(rules)
+ XkbRF_RulesPtr rules;
+#endif
+{
+ if (rules->sz_groups<1) {
+ rules->sz_groups= 16;
+ rules->num_groups= 0;
+ rules->groups= _XkbTypedCalloc(rules->sz_groups,XkbRF_GroupRec);
+ }
+ else if (rules->num_groups >= rules->sz_groups) {
+ rules->sz_groups *= 2;
+ rules->groups= _XkbTypedRealloc(rules->groups,rules->sz_groups,
+ XkbRF_GroupRec);
+ }
+ if (!rules->groups) {
+ rules->sz_groups= rules->num_groups= 0;
+ return NULL;
+ }
+
+ bzero((char *)&rules->groups[rules->num_groups],sizeof(XkbRF_GroupRec));
+ return &rules->groups[rules->num_groups++];
+}
+
Bool
#if NeedFunctionPrototypes
XkbRF_LoadRules(FILE *file, XkbRF_RulesPtr rules)
@@ -819,16 +1109,25 @@ XkbRF_LoadRules(file,rules)
InputLine line;
RemapSpec remap;
XkbRF_RuleRec trule,*rule;
+XkbRF_GroupRec tgroup,*group;
if (!(rules && file))
return False;
bzero((char *)&remap,sizeof(RemapSpec));
+ bzero((char *)&tgroup,sizeof(XkbRF_GroupRec));
InitInputLine(&line);
while (GetInputLine(file,&line,True)) {
- if (CheckLine(&line,&remap,&trule)) {
- if ((rule= XkbRF_AddRule(rules))!=NULL) {
- *rule= trule;
- bzero((char *)&trule,sizeof(XkbRF_RuleRec));
+ if (CheckLine(&line,&remap,&trule,&tgroup)) {
+ if (tgroup.number) {
+ if ((group= XkbRF_AddGroup(rules))!=NULL) {
+ *group= tgroup;
+ bzero((char *)&tgroup,sizeof(XkbRF_GroupRec));
+ }
+ } else {
+ if ((rule= XkbRF_AddRule(rules))!=NULL) {
+ *rule= trule;
+ bzero((char *)&trule,sizeof(XkbRF_RuleRec));
+ }
}
}
line.num_line= 0;
@@ -976,7 +1275,7 @@ XkbRF_LoadDescriptions(file,rules)
InputLine line;
XkbRF_VarDescRec tmp;
char *tok;
-int len,headingtype,extra_ndx;
+int len,headingtype,extra_ndx = 0;
bzero((char *)&tmp, sizeof(XkbRF_VarDescRec));
headingtype = HEAD_NONE;
@@ -1200,6 +1499,7 @@ XkbRF_Free(rules,freeRules)
{
int i;
XkbRF_RulePtr rule;
+XkbRF_GroupPtr group;
if (!rules)
return;
@@ -1233,6 +1533,16 @@ XkbRF_RulePtr rule;
rules->num_rules= rules->sz_rules= 0;
rules->rules= NULL;
}
+
+ if (rules->groups) {
+ for (i=0, group=rules->groups;i<rules->num_groups;i++,group++) {
+ if (group->name) _XkbFree(group->name);
+ if (group->words) _XkbFree(group->words);
+ }
+ _XkbFree(rules->groups);
+ rules->num_groups= 0;
+ rules->groups= NULL;
+ }
if (freeRules)
_XkbFree(rules);
return;
@@ -1246,7 +1556,7 @@ XkbRF_GetNamesProp(Display *dpy,char **rf_rtrn,XkbRF_VarDefsPtr vd_rtrn)
#else
XkbRF_GetNamesProp(dpy,rf_rtrn,vd_rtrn)
Display * dpy;
- char ** rf_rtrn;
+ char ** rf_rtrn;
XkbRF_VarDefsPtr vd_rtrn;
#endif
{
diff --git a/src/srvmisc.c b/src/srvmisc.c
index 8dfde74..9a47333 100644
--- a/src/srvmisc.c
+++ b/src/srvmisc.c
@@ -24,12 +24,11 @@
THE USE OR PERFORMANCE OF THIS SOFTWARE.
********************************************************/
+/* $XFree86: xc/lib/xkbfile/srvmisc.c,v 3.4 2001/10/28 03:32:47 tsi Exp $ */
#include <stdio.h>
#include <ctype.h>
-#ifndef X_NOT_STDC_ENV
#include <stdlib.h>
-#endif
#include <X11/Xlib.h>
#include <X11/XKBlib.h>
#include <X11/extensions/XKBgeom.h>
@@ -100,7 +99,7 @@ XkbReadFromServer(dpy,need,want,result)
#endif
{
unsigned which= need|want;
-unsigned tmp;
+unsigned tmp = 0;
if ((result==NULL)||(dpy==NULL))
return which;
diff --git a/src/xkbatom.c b/src/xkbatom.c
index 30675d1..2883cac 100644
--- a/src/xkbatom.c
+++ b/src/xkbatom.c
@@ -71,12 +71,11 @@ SOFTWARE.
THE USE OR PERFORMANCE OF THIS SOFTWARE.
********************************************************/
+/* $XFree86: xc/lib/xkbfile/xkbatom.c,v 3.8 2001/12/14 19:57:03 dawes Exp $ */
#include <stdio.h>
#include <ctype.h>
-#ifndef X_NOT_STDC_ENV
#include <stdlib.h>
-#endif
#include <X11/Xos.h>
#include <X11/Xlib.h>
#include <X11/XKBlib.h>
diff --git a/src/xkbconfig.c b/src/xkbconfig.c
index d2e6794..c94b06f 100644
--- a/src/xkbconfig.c
+++ b/src/xkbconfig.c
@@ -24,12 +24,11 @@
THE USE OR PERFORMANCE OF THIS SOFTWARE.
********************************************************/
+/* $XFree86: xc/lib/xkbfile/xkbconfig.c,v 3.7 2001/11/30 12:11:51 eich Exp $ */
#include <stdio.h>
#include <ctype.h>
-#ifndef X_NOT_STDC_ENV
#include <stdlib.h>
-#endif
#include <X11/Xfuncs.h>
@@ -274,6 +273,7 @@ int ch;
#define _XkbCF_InternalMods 35
#define _XkbCF_GroupsWrap 36
+#define _XkbCF_InitialFeedback 37
static Bool
#if NeedFunctionPrototypes
@@ -343,6 +343,10 @@ AddAXTimeoutOptByName(rtrn,name,opts_rtrn)
*opts_rtrn= XkbAX_IndicatorFBMask;
else if (_XkbStrCaseCmp(name,"stickykeys")==0)
*opts_rtrn= XkbAX_StickyKeysFBMask;
+ else if (_XkbStrCaseCmp(name,"twokeys")==0)
+ *opts_rtrn= XkbAX_TwoKeysMask;
+ else if (_XkbStrCaseCmp(name,"latchtolock")==0)
+ *opts_rtrn= XkbAX_LatchToLockMask;
else if (_XkbStrCaseCmp(name,"slowkeysrelease")==0)
*opts_rtrn= XkbAX_SKReleaseFBMask;
else if (_XkbStrCaseCmp(name,"slowkeysreject")==0)
@@ -524,9 +528,9 @@ int tok;
XkbCFScanResultRec val;
char ** str;
int merge;
-unsigned long * ctrls;
-unsigned short * opts;
-int * pival;
+unsigned long * ctrls, ctrls_mask;
+unsigned short * opts, opts_mask;
+int * pival, sign;
int onoff;
XkbConfigUnboundModPtr last;
unsigned what;
@@ -611,7 +615,6 @@ unsigned what;
break;
case _XkbCF_InitialCtrls:
rtrn->defined|= XkbCF_InitialCtrls;
- opts= NULL;
ctrls= NULL;
if (tok==XkbCF_PlusEquals)
ctrls= &rtrn->initial_ctrls;
@@ -636,9 +639,10 @@ unsigned what;
rtrn->error= XkbCF_ExpectedControl;
return False;
}
- if (!AddCtrlByName(rtrn,val.str,ctrls)) {
+ if (!AddCtrlByName(rtrn,val.str,&ctrls_mask)) {
return False;
}
+ *ctrls |= ctrls_mask;
tok= XkbCFScan(file,&val,rtrn);
if ((tok!=XkbCF_EOL)&&(tok!=XkbCF_EOF)&&(tok!=XkbCF_Semi)) {
if (tok!=XkbCF_Plus) {
@@ -651,18 +655,6 @@ unsigned what;
break;
case _XkbCF_AccessXTimeoutCtrlsOn:
case _XkbCF_AccessXTimeoutCtrlsOff:
- case _XkbCF_AccessXTimeoutOptsOff:
- case _XkbCF_AccessXTimeoutOptsOn:
- if (field->field_id==_XkbCF_AccessXTimeoutOptsOff)
- field->field_id= _XkbCF_AccessXTimeoutCtrlsOff;
- else if (field->field_id==_XkbCF_AccessXTimeoutCtrlsOn)
- field->field_id= _XkbCF_AccessXTimeoutCtrlsOn;
-
- if (field->field_id==_XkbCF_AccessXTimeoutCtrlsOff)
- rtrn->defined|= XkbCF_AccessXTimeoutCtrlsOff;
- else if (field->field_id==_XkbCF_AccessXTimeoutCtrlsOn)
- rtrn->defined|= XkbCF_AccessXTimeoutCtrlsOn;
-
opts= NULL;
if (tok==XkbCF_MinusEquals) {
ctrls= &rtrn->axt_ctrls_ignore;
@@ -697,9 +689,10 @@ unsigned what;
rtrn->error= XkbCF_ExpectedControl;
return False;
}
- if (!AddCtrlByName(rtrn,val.str,ctrls)) {
- if (!AddAXTimeoutOptByName(rtrn,val.str,opts))
+ if (!AddCtrlByName(rtrn,val.str,&ctrls_mask)) {
+ if (!AddAXTimeoutOptByName(rtrn,val.str,&opts_mask))
return False;
+ *opts |= opts_mask;
if (field->field_id==_XkbCF_AccessXTimeoutCtrlsOff) {
rtrn->defined|= XkbCF_AccessXTimeoutOptsOff;
if (rtrn->replace_axt_ctrls_off)
@@ -711,6 +704,94 @@ unsigned what;
rtrn->replace_axt_opts_on= True;
}
}
+ else
+ *ctrls |= ctrls_mask;
+ tok= XkbCFScan(file,&val,rtrn);
+ if ((tok!=XkbCF_EOL)&&(tok!=XkbCF_EOF)&&(tok!=XkbCF_Semi)) {
+ if (tok!=XkbCF_Plus) {
+ rtrn->error= XkbCF_ExpectedOperator;
+ return False;
+ }
+ tok= XkbCFScan(file,&val,rtrn);
+ }
+ }
+ break;
+ case _XkbCF_InitialFeedback:
+ rtrn->defined|= XkbCF_InitialOpts;
+ opts= NULL;
+ if (tok==XkbCF_PlusEquals)
+ opts= &rtrn->initial_opts;
+ else if (tok==XkbCF_MinusEquals)
+ opts= &rtrn->initial_opts_clear;
+ else if (tok==XkbCF_Equals) {
+ opts= &rtrn->initial_opts;
+ rtrn->replace_initial_opts= True;
+ *opts= 0;
+ }
+ else {
+ rtrn->error= XkbCF_MissingEquals;
+ goto BAILOUT;
+ }
+ tok= XkbCFScan(file,&val,rtrn);
+ if ((tok==XkbCF_EOL)||(tok==XkbCF_Semi)||(tok==XkbCF_EOF)) {
+ rtrn->error= XkbCF_ExpectedAXOption;
+ return False;
+ }
+ while ((tok!=XkbCF_EOL)&&(tok!=XkbCF_Semi)&&(tok!=XkbCF_EOF)) {
+ if ((tok!=XkbCF_Ident)&&(tok!=XkbCF_String)) {
+ rtrn->error= XkbCF_ExpectedAXOption;
+ return False;
+ }
+ if (!AddAXTimeoutOptByName(rtrn,val.str,&opts_mask)) {
+ return False;
+ }
+ *opts |= opts_mask;
+ tok= XkbCFScan(file,&val,rtrn);
+ if ((tok!=XkbCF_EOL)&&(tok!=XkbCF_EOF)&&(tok!=XkbCF_Semi)) {
+ if (tok!=XkbCF_Plus) {
+ rtrn->error= XkbCF_ExpectedOperator;
+ return False;
+ }
+ tok= XkbCFScan(file,&val,rtrn);
+ }
+ }
+ break;
+ case _XkbCF_AccessXTimeoutOptsOff:
+ case _XkbCF_AccessXTimeoutOptsOn:
+ opts= NULL;
+ if (tok==XkbCF_MinusEquals)
+ opts= &rtrn->axt_opts_ignore;
+ else if ((tok==XkbCF_PlusEquals)||(tok==XkbCF_Equals)) {
+ if (field->field_id==_XkbCF_AccessXTimeoutOptsOff) {
+ opts= &rtrn->axt_opts_off;
+ if (tok==XkbCF_Equals)
+ rtrn->replace_axt_opts_off= True;
+ }
+ else {
+ opts= &rtrn->axt_opts_on;
+ if (tok==XkbCF_Equals)
+ rtrn->replace_axt_opts_on= True;
+ }
+ *opts = 0;
+ }
+ else {
+ rtrn->error= XkbCF_MissingEquals;
+ goto BAILOUT;
+ }
+ tok= XkbCFScan(file,&val,rtrn);
+ if ((tok==XkbCF_EOL)||(tok==XkbCF_Semi)||(tok==XkbCF_EOF)) {
+ rtrn->error= XkbCF_ExpectedControl;
+ return False;
+ }
+ while ((tok!=XkbCF_EOL)&&(tok!=XkbCF_Semi)&&(tok!=XkbCF_EOF)) {
+ if ((tok!=XkbCF_Ident)&&(tok!=XkbCF_String)) {
+ rtrn->error= XkbCF_ExpectedControl;
+ return False;
+ }
+ if (!AddAXTimeoutOptByName(rtrn,val.str,&opts_mask))
+ return False;
+ *opts |= opts_mask;
+
tok= XkbCFScan(file,&val,rtrn);
if ((tok!=XkbCF_EOL)&&(tok!=XkbCF_EOF)&&(tok!=XkbCF_Semi)) {
if (tok!=XkbCF_Plus) {
@@ -772,6 +853,13 @@ unsigned what;
goto BAILOUT;
}
tok= XkbCFScan(file,&val,rtrn);
+ if (tok == XkbCF_Minus && field->field_id == _XkbCF_MouseKeysCurve) {
+ /* This can be a negative value */
+ tok = XkbCFScan(file,&val,rtrn);
+ sign = -1;
+ }
+ else
+ sign = 1;
if (tok!=XkbCF_Integer) {
Bool ok= False;
if ((onoff)&&(tok==XkbCF_Ident)&&(val.str!=NULL)) {
@@ -789,8 +877,9 @@ unsigned what;
goto BAILOUT;
}
}
- *pival= val.ival;
- rtrn->defined|= XkbCF_AccessXTimeout;
+ *pival= val.ival * sign;
+ if (field->field_id == _XkbCF_AccessXTimeout)
+ rtrn->defined|=XkbCF_AccessXTimeout;
tok= XkbCFScan(file,&val,rtrn);
if ((tok!=XkbCF_EOL)&&(tok!=XkbCF_Semi)&&(tok!=XkbCF_EOF)) {
rtrn->error= XkbCF_ExpectedEOS;
@@ -986,7 +1075,7 @@ unsigned int mask;
ctrls->mk_max_speed= rtrn->mk_max_speed;
if (rtrn->mk_curve>0)
ctrls->mk_curve= rtrn->mk_curve;
- if (rtrn->defined&XkbCF_AccessXTimeout)
+ if (rtrn->defined&XkbCF_AccessXTimeout && rtrn->ax_timeout > 0)
ctrls->ax_timeout= rtrn->ax_timeout;
/* any value set to both off and on is reset to ignore */
@@ -1120,13 +1209,18 @@ static XkbConfigFieldRec _XkbCFDfltFields[] = {
{ "axtctrlson", _XkbCF_AccessXTimeoutCtrlsOn },
{ "accessxtimeoutctrlsoff",_XkbCF_AccessXTimeoutCtrlsOff },
{ "axtctrlsoff",_XkbCF_AccessXTimeoutCtrlsOff },
+ { "accessxtimeoutfeedbackon", _XkbCF_AccessXTimeoutOptsOn },
+ { "axtfeedbackon", _XkbCF_AccessXTimeoutOptsOn },
+ { "accessxtimeoutfeedbackoff", _XkbCF_AccessXTimeoutOptsOff },
+ { "axtfeedbackoff", _XkbCF_AccessXTimeoutOptsOff },
{ "ignorelockmods",_XkbCF_IgnoreLockMods },
{ "ignorelockmodifiers",_XkbCF_IgnoreLockMods },
{ "ignoregrouplock",_XkbCF_IgnoreGroupLock },
{ "internalmods",_XkbCF_InternalMods },
{ "internalmodifiers",_XkbCF_InternalMods },
{ "outofrangegroups",_XkbCF_GroupsWrap },
- { "groups", _XkbCF_GroupsWrap }
+ { "groups", _XkbCF_GroupsWrap },
+ { "feedback", _XkbCF_InitialFeedback },
};
#define _XkbCFNumDfltFields (sizeof(_XkbCFDfltFields)/sizeof(XkbConfigFieldRec))
@@ -1344,6 +1438,7 @@ BAILOUT:
return False;
}
+/*ARGSUSED*/
void
#if NeedFunctionPrototypes
XkbCFReportError(FILE *file,char *name,int error,int line)
@@ -1387,8 +1482,14 @@ char * msg;
default:
msg= "unknown error on line %d"; break;
}
+#ifndef XKB_IN_SERVER
fprintf(file,msg,line);
if (name) fprintf(file," of %s\n",name);
else fprintf(file,"\n");
+#else
+ ErrorF(msg,line);
+ if (name) ErrorF(" of %s\n",name);
+ else ErrorF("\n");
+#endif
return;
}
diff --git a/src/xkbdraw.c b/src/xkbdraw.c
index fffc832..bbd2519 100644
--- a/src/xkbdraw.c
+++ b/src/xkbdraw.c
@@ -24,12 +24,11 @@
THE USE OR PERFORMANCE OF THIS SOFTWARE.
********************************************************/
+/* $XFree86: xc/lib/xkbfile/xkbdraw.c,v 1.3 2001/07/29 05:01:13 tsi Exp $ */
#include <stdio.h>
#include <ctype.h>
-#ifndef X_NOT_STDC_ENV
#include <stdlib.h>
-#endif
#include <X11/Xos.h>
#include <X11/Xfuncs.h>
diff --git a/src/xkberrs.c b/src/xkberrs.c
index 41df420..d12467f 100644
--- a/src/xkberrs.c
+++ b/src/xkberrs.c
@@ -24,15 +24,11 @@
THE USE OR PERFORMANCE OF THIS SOFTWARE.
********************************************************/
+/* $XFree86: xc/lib/xkbfile/xkberrs.c,v 3.5 2002/11/08 13:35:43 alanh Exp $ */
#include <stdio.h>
#include <ctype.h>
-#ifndef X_NOT_STDC_ENV
#include <stdlib.h>
-#endif
-#include <X11/Xlib.h>
-#include <X11/XKBlib.h>
-#include <X11/extensions/XKBfile.h>
char * _XkbErrMessages[] = {
"success", /* _XkbSuccess */
diff --git a/src/xkbmisc.c b/src/xkbmisc.c
index d07a704..8246390 100644
--- a/src/xkbmisc.c
+++ b/src/xkbmisc.c
@@ -24,14 +24,11 @@
THE USE OR PERFORMANCE OF THIS SOFTWARE.
********************************************************/
+/* $XFree86: xc/lib/xkbfile/xkbmisc.c,v 1.4 2002/12/20 20:18:35 paulo Exp $ */
#include <stdio.h>
#include <ctype.h>
-#ifndef X_NOT_STDC_ENV
#include <stdlib.h>
-#endif
-
-#define XK_CYRILLIC
#include <X11/Xos.h>
#include <X11/Xfuncs.h>
@@ -70,19 +67,78 @@ _XkbKSCheckCase(ks)
#endif
{
unsigned set,rtrn;
-unsigned char ch;
- set= (ks & (~0xff));
- ch= (char)(ks&0xff);
+ set= (ks & (~0xff)) >> 8;
rtrn= 0;
switch (set) {
case 0: /* latin 1 */
- if (((ch>=XK_A)&&(ch<=XK_Z))||
- ((ch>=XK_Agrave)&&(ch<=XK_THORN)&&(ch!=XK_multiply))) {
+ if (((ks>=XK_A)&&(ks<=XK_Z))||
+ ((ks>=XK_Agrave)&&(ks<=XK_THORN)&&(ks!=XK_multiply))) {
+ rtrn|= _XkbKSUpper;
+ }
+ if (((ks>=XK_a)&&(ks<=XK_z))||
+ ((ks>=XK_agrave)&&(ks<=XK_ydiaeresis))) {
+ rtrn|= _XkbKSLower;
+ }
+ break;
+ case 1: /* latin 2 */
+ if (((ks>=XK_Aogonek)&&(ks<=XK_Zabovedot)&&(ks!=XK_breve))||
+ ((ks>=XK_Racute)&&(ks<=XK_Tcedilla))) {
+ rtrn|= _XkbKSUpper;
+ }
+ if (((ks>=XK_aogonek)&&(ks<=XK_zabovedot)&&(ks!=XK_caron))||
+ ((ks>=XK_racute)&&(ks<=XK_tcedilla))) {
+ rtrn|= _XkbKSLower;
+ }
+ break;
+ case 2: /* latin 3 */
+ if (((ks>=XK_Hstroke)&&(ks<=XK_Jcircumflex))||
+ ((ks>=XK_Cabovedot)&&(ks<=XK_Scircumflex))) {
+ rtrn|= _XkbKSUpper;
+ }
+ if (((ks>=XK_hstroke)&&(ks<=XK_jcircumflex))||
+ ((ks>=XK_cabovedot)&&(ks<=XK_scircumflex))) {
+ rtrn|= _XkbKSLower;
+ }
+ break;
+ case 3: /* latin 4 */
+ if (((ks>=XK_Rcedilla)&&(ks<=XK_Tslash))||
+ (ks==XK_ENG)||
+ ((ks>=XK_Amacron)&&(ks<=XK_Umacron))) {
+ rtrn|= _XkbKSUpper;
+ }
+ if (((ks>=XK_rcedilla)&&(ks<=XK_tslash))||
+ (ks==XK_eng)||
+ ((ks>=XK_amacron)&&(ks<=XK_umacron))) {
+ rtrn|= _XkbKSLower;
+ }
+ break;
+ case 18: /* latin 8 */
+ if ((ks==XK_Babovedot)||
+ ((ks>=XK_Dabovedot)&&(ks<=XK_Wacute))||
+ ((ks>=XK_Ygrave)&&(ks<=XK_Fabovedot))||
+ (ks==XK_Mabovedot)||
+ (ks==XK_Pabovedot)||
+ (ks==XK_Sabovedot)||
+ (ks==XK_Wdiaeresis)||
+ ((ks>=XK_Wcircumflex)&&(ks<=XK_Ycircumflex))) {
+ rtrn|= _XkbKSUpper;
+ }
+ if ((ks==XK_babovedot)||
+ (ks==XK_dabovedot)||
+ (ks==XK_fabovedot)||
+ (ks==XK_mabovedot)||
+ ((ks>=XK_wgrave)&&(ks<=XK_wacute))||
+ (ks==XK_ygrave)||
+ ((ks>=XK_wdiaeresis)&&(ks<=XK_ycircumflex))) {
+ rtrn|= _XkbKSLower;
+ }
+ break;
+ case 19: /* latin 9 */
+ if ((ks==XK_OE)||(ks==XK_Ydiaeresis)) {
rtrn|= _XkbKSUpper;
}
- if (((ch>=XK_a)&&(ch<=XK_z))||
- ((ch>=XK_agrave)&&(ch<=XK_ydiaeresis))) {
+ if (ks==XK_oe) {
rtrn|= _XkbKSLower;
}
break;
diff --git a/src/xkbout.c b/src/xkbout.c
index 8453253..fd7603b 100644
--- a/src/xkbout.c
+++ b/src/xkbout.c
@@ -24,12 +24,11 @@
THE USE OR PERFORMANCE OF THIS SOFTWARE.
********************************************************/
+/* $XFree86: xc/lib/xkbfile/xkbout.c,v 3.9 2001/10/28 03:32:47 tsi Exp $ */
#include <stdio.h>
#include <ctype.h>
-#ifndef X_NOT_STDC_ENV
#include <stdlib.h>
-#endif
#include <X11/Xfuncs.h>
#ifndef XKB_IN_SERVER
@@ -849,7 +848,7 @@ WriteXKBSection(file,dpy,s,geom)
{
register int i;
XkbRowPtr row;
-int dfltKeyColor;
+int dfltKeyColor = 0;
fprintf(file," section \"%s\" {\n",
XkbAtomText(dpy,s->name,XkbXKBFile));
@@ -1100,6 +1099,7 @@ XkbDescPtr xkb;
xkb= result->xkb;
fprintf(file,"xkb_layout {\n");
ok= XkbWriteXKBKeycodes(file,result,False,showImplicit,addOn,priv);
+ ok= ok&&XkbWriteXKBKeyTypes(file,result,False,showImplicit,addOn,priv);
ok= ok&&XkbWriteXKBSymbols(file,result,False,showImplicit,addOn,priv);
if (xkb->geom)
ok= ok&&XkbWriteXKBGeometry(file,result,False,showImplicit,addOn,priv);
@@ -1157,7 +1157,7 @@ XkbWriteXKBFile(out,result,showImplicit,addOn,priv)
void * priv;
#endif
{
-Bool ok;
+Bool ok = False;
Bool (*func)(
#if NeedFunctionPrototypes
FILE * /* file */,
@@ -1167,7 +1167,7 @@ Bool (*func)(
XkbFileAddOnFunc /* addOn */,
void * /* priv */
#endif
-);
+) = NULL;
switch (result->type) {
case XkmSemanticsFile:
@@ -1205,12 +1205,8 @@ Bool (*func)(
_XkbLibError(_XkbErrFileCannotOpen,"XkbWriteXkbFile",0);
ok= False;
}
- else {
+ else if (func) {
ok= (*func)(out,result,True,showImplicit,addOn,priv);
}
- if (!ok) {
- return False;
- }
- return True;
+ return ok;
}
-
diff --git a/src/xkbtext.c b/src/xkbtext.c
index 18c07a1..d233af0 100644
--- a/src/xkbtext.c
+++ b/src/xkbtext.c
@@ -24,12 +24,11 @@
THE USE OR PERFORMANCE OF THIS SOFTWARE.
********************************************************/
+/* $XFree86: xc/lib/xkbfile/xkbtext.c,v 3.11 2002/12/21 18:49:02 paulo Exp $ */
#include <stdio.h>
#include <ctype.h>
-#ifndef X_NOT_STDC_ENV
#include <stdlib.h>
-#endif
#include <X11/Xos.h>
@@ -403,7 +402,7 @@ static char buf[32],*rtrn;
if (sym==NoSymbol)
strcpy(rtrn=buf,"NoSymbol");
else if ((rtrn=XKeysymToString(sym))==NULL)
- sprintf(rtrn=buf,"0x%x",sym);
+ sprintf(rtrn=buf, "0x%lx", (long)sym);
else if (format==XkbCFile) {
sprintf(buf,"XK_%s",rtrn);
rtrn= buf;
@@ -412,7 +411,7 @@ static char buf[32],*rtrn;
#else /* def XKB_IN_SERVER */
if (sym==NoSymbol)
strcpy(rtrn=buf,"NoSymbol");
- else sprintf(rtrn=buf,"0x%x",sym);
+ else sprintf(rtrn=buf, "0x%lx", (long)sym);
return rtrn;
#endif /* XKB_IN_SERVER */
}
@@ -589,7 +588,7 @@ int len,plen,slen;
if ((detail&XkbAllNewKeyboardEventsMask)==0) {
- char * tmp;
+ char *tmp = "";
if (format==XkbCFile) tmp= "0";
else if (format==XkbMessage) tmp= "none";
buf= tbGetBuffer(strlen(tmp)+1);
@@ -874,7 +873,7 @@ char *rtrn;
}
return rtrn;
}
- sprintf(buf,"0x%x",type);
+ sprintf(buf,"Private");
return buf;
}
@@ -1500,7 +1499,7 @@ int sz;
if (format==XkbCFile) {
sprintf(buf,
- "{ %20s, 0x%02x, 0x%02x, 0x%02x, 0x%02x, 0x%02x, 0x%02x, 0x%02x }",
+ "{ %20s, { 0x%02x, 0x%02x, 0x%02x, 0x%02x, 0x%02x, 0x%02x, 0x%02x } }",
XkbActionTypeText(action->type,XkbCFile),
action->any.data[0],action->any.data[1],action->any.data[2],
action->any.data[3],action->any.data[4],action->any.data[5],
@@ -1543,7 +1542,7 @@ char buf[256],*tmp;
permanent=((behavior->type&XkbKB_Permanent)!=0);
if (type==XkbKB_Lock) {
- sprintf(buf,"lock= %s,",(permanent?"Permanent":"True"));
+ sprintf(buf,"lock= %s",(permanent?"Permanent":"True"));
}
else if (type==XkbKB_RadioGroup) {
int g;
diff --git a/src/xkmout.c b/src/xkmout.c
index c4aaadf..18418f1 100644
--- a/src/xkmout.c
+++ b/src/xkmout.c
@@ -24,12 +24,11 @@
THE USE OR PERFORMANCE OF THIS SOFTWARE.
********************************************************/
+/* $XFree86: xc/lib/xkbfile/xkmout.c,v 1.5 2001/07/25 15:04:58 dawes Exp $ */
#include <stdio.h>
#include <ctype.h>
-#ifndef X_NOT_STDC_ENV
#include <stdlib.h>
-#endif
#include <X11/Xfuncs.h>
#include <X11/Xlib.h>
#include <X11/XKBlib.h>
@@ -666,7 +665,7 @@ unsigned tmp,size= 0;
for (i=xkb->min_key_code;i<=(int)xkb->max_key_code;i++) {
char *typeName[XkbNumKbdGroups];
wireMap.width= XkbKeyGroupsWidth(xkb,i);
- wireMap.num_groups= XkbKeyNumGroups(xkb,i);
+ wireMap.num_groups= XkbKeyGroupInfo(xkb,i);
if (xkb->map && xkb->map->modmap)
wireMap.modifier_map= xkb->map->modmap[i];
else wireMap.modifier_map= 0;
@@ -705,7 +704,7 @@ unsigned tmp,size= 0;
size+= xkmPutCountedString(file,typeName[g]);
}
}
- if (wireMap.num_groups>0) {
+ if (XkbNumGroups(wireMap.num_groups)>0) {
KeySym *sym;
sym= XkbKeySymsPtr(xkb,i);
for (n=XkbKeyNumSyms(xkb,i);n>0;n--,sym++) {
diff --git a/src/xkmread.c b/src/xkmread.c
index 7a4a2b4..af6cc3e 100644
--- a/src/xkmread.c
+++ b/src/xkmread.c
@@ -24,6 +24,7 @@
THE USE OR PERFORMANCE OF THIS SOFTWARE.
********************************************************/
+/* $XFree86: xc/lib/xkbfile/xkmread.c,v 1.6 2002/02/13 22:09:42 herrb Exp $ */
#include <stdio.h>
@@ -32,9 +33,7 @@
#ifndef XKB_IN_SERVER
-#ifndef X_NOT_STDC_ENV
#include <stdlib.h>
-#endif
#include <X11/Xlib.h>
#include <X11/keysym.h>
@@ -172,7 +171,7 @@ XkmGetCARD32(file,pNRead)
int * pNRead;
#endif
{
-unsigned long val;
+CARD32 val;
if ((fread(&val,4,1,file)==1)&&(pNRead))
(*pNRead)+= 4;
@@ -797,13 +796,13 @@ XkbDescPtr xkb;
xkb->server->explicit[i]|= XkbExplicitAutoRepeatMask;
}
xkb->map->modmap[i]= wireMap.modifier_map;
- if (wireMap.num_groups>0) {
+ if (XkbNumGroups(wireMap.num_groups)>0) {
KeySym *sym;
int nSyms;
- if (wireMap.num_groups>xkb->ctrls->num_groups)
+ if (XkbNumGroups(wireMap.num_groups)>xkb->ctrls->num_groups)
xkb->ctrls->num_groups= wireMap.num_groups;
- nSyms= wireMap.num_groups*wireMap.width;
+ nSyms= XkbNumGroups(wireMap.num_groups)*wireMap.width;
sym= XkbResizeKeySyms(xkb,i,nSyms);
if (!sym)
return -1;
@@ -820,7 +819,7 @@ XkbDescPtr xkb;
xkb->server->explicit[i]|= XkbExplicitInterpretMask;
}
}
- for (g=0;g<wireMap.num_groups;g++) {
+ for (g=0;g<XkbNumGroups(wireMap.num_groups);g++) {
if (((xkb->server->explicit[i]&(1<<g))==0)||(type[g]==NULL)) {
KeySym *tmpSyms;
tmpSyms= XkbKeySymsPtr(xkb,i)+(wireMap.width*g);