rpms/xorg-x11-xkb-utils/devel xkbcomp-speed.patch, NONE, 1.1 xorg-x11-xkb-utils.spec, 1.32, 1.33

Adam Jackson ajax at fedoraproject.org
Thu Jul 8 14:43:58 UTC 2010


Author: ajax

Update of /cvs/pkgs/rpms/xorg-x11-xkb-utils/devel
In directory cvs01.phx2.fedoraproject.org:/tmp/cvs-serv29451

Modified Files:
	xorg-x11-xkb-utils.spec 
Added Files:
	xkbcomp-speed.patch 
Log Message:
* Thu Jul 08 2010 Adam Jackson <ajax at redhat.com> 7.4-8
- xkbcomp-speed.patch: Backport performance changes from git master.


xkbcomp-speed.patch:
 Makefile.am  |   14 +++--
 configure.ac |   17 +++----
 keycodes.c   |   16 ++----
 parseutils.c |   10 ++--
 parseutils.h |    6 +-
 symbols.c    |    9 ++-
 xkbcomp.c    |    2 
 xkbcomp.h    |    2 
 xkbparse.y   |   53 +++++++---------------
 xkbscan.c    |  142 ++++++++++++++++++++++++++++++++++-------------------------
 10 files changed, 141 insertions(+), 130 deletions(-)

--- NEW FILE xkbcomp-speed.patch ---
diff --git a/Makefile.am b/Makefile.am
index fca1f67..3550c40 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -21,7 +21,7 @@
 
 bin_PROGRAMS = xkbcomp
 
-AM_CFLAGS = $(XKBCOMP_CFLAGS) -DDFLT_XKB_CONFIG_ROOT='"$(XKBCONFIGROOT)"'
+AM_CFLAGS = $(XKBCOMP_CFLAGS) -DDFLT_XKB_CONFIG_ROOT='"$(XKBCONFIGROOT)"' $(CWARNFLAGS)
 xkbcomp_LDADD = $(XKBCOMP_LIBS)
 
 xkbcomp_SOURCES = \
@@ -62,7 +62,8 @@ appman_PRE = \
         xkbcomp.man
 
 BUILT_SOURCES = xkbparse.c
-MAINTAINERCLEANFILES = $(BUILT_SOURCES)
+MAINTAINERCLEANFILES = ChangeLog INSTALL
+MAINTAINERCLEANFILES += $(BUILT_SOURCES)
 
 EXTRA_DIST = \
 	README.config \
@@ -99,12 +100,13 @@ SUFFIXES = .$(APP_MAN_SUFFIX) .man
 .man.$(APP_MAN_SUFFIX):
 	sed $(MAN_SUBSTS) < $< > $@
 
-EXTRA_DIST += ChangeLog
-MAINTAINERCLEANFILES += ChangeLog
 
-.PHONY: ChangeLog
+.PHONY: ChangeLog INSTALL
+
+INSTALL:
+	$(INSTALL_CMD)
 
 ChangeLog:
 	$(CHANGELOG_CMD)
 
-dist-hook: ChangeLog
+dist-hook: ChangeLog INSTALL
diff --git a/NEWS b/NEWS
deleted file mode 100644
index e69de29..0000000
diff --git a/configure.ac b/configure.ac
index 007e7ca..3ad342c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -22,26 +22,28 @@ dnl Process this file with autoconf to create configure.
 
 AC_PREREQ([2.57])
 AC_INIT(xkbcomp,[1.1.1], [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg],xkbcomp)
-AM_INIT_AUTOMAKE([dist-bzip2])
+AM_INIT_AUTOMAKE([foreign dist-bzip2])
 AM_MAINTAINER_MODE
 
-# Require xorg-macros: XORG_CWARNFLAGS, XORG_CHANGELOG
-m4_ifndef([XORG_MACROS_VERSION], [AC_FATAL([must install xorg-macros 1.2 or later before running autoconf/autogen])])
-XORG_MACROS_VERSION(1.2)
+# Require xorg-macros: XORG_DEFAULT_OPTIONS
+m4_ifndef([XORG_MACROS_VERSION],
+          [m4_fatal([must install xorg-macros 1.3 or later before running autoconf/autogen])])
+XORG_MACROS_VERSION(1.3)
+XORG_DEFAULT_OPTIONS
 
 AM_CONFIG_HEADER(config.h)
 
 AC_PROG_CC
 AC_PROG_YACC
+AC_PATH_PROG([YACC_INST], $YACC)
+test -z "$YACC_INST" && AC_MSG_ERROR([yacc not found - unable to compile xkbparse.y])
 AC_PROG_INSTALL
 
-XORG_CWARNFLAGS
 
 AC_CHECK_FUNCS([strdup strcasecmp])
 
 # Checks for pkg-config packages
 PKG_CHECK_MODULES(XKBCOMP, x11 xkbfile)
-XKBCOMP_CFLAGS="$CWARNFLAGS $XKBCOMP_CFLAGS"
 AC_SUBST(XKBCOMP_CFLAGS)
 AC_SUBST(XKBCOMP_LIBS)
 
@@ -52,8 +54,5 @@ AC_ARG_WITH([xkb_config_root],
     [XKBCONFIGROOT='${datadir}/X11/xkb'])
 AC_SUBST([XKBCONFIGROOT])
 
-XORG_MANPAGE_SECTIONS
-XORG_RELEASE_VERSION
-XORG_CHANGELOG
 
 AC_OUTPUT([Makefile])
diff --git a/keycodes.c b/keycodes.c
index 1bff7fa..13579ec 100644
--- a/keycodes.c
+++ b/keycodes.c
@@ -158,7 +158,6 @@ AddIndicatorName(KeyNamesInfo * info, IndicatorNameInfo * new)
 {
     IndicatorNameInfo *old;
     Bool replace;
-    const char *action;
 
     replace = (new->defs.merge == MergeReplace) ||
         (new->defs.merge == MergeOverride);
@@ -176,23 +175,22 @@ AddIndicatorName(KeyNamesInfo * info, IndicatorNameInfo * new)
                 {
                     if (replace)
                         old->virtual = new->virtual;
-                    action = "Using %s instead of %s\n";
+                    ACTION2("Using %s instead of %s\n",
+                            (old->virtual ? "virtual" : "real"),
+                            (old->virtual ? "real" : "virtual"));
                 }
                 else
                 {
-                    action = "Identical definitions ignored\n";
+                    ACTION("Identical definitions ignored\n");
                 }
-                ACTION2(action, (old->virtual ? "virtual" : "real"),
-                        (old->virtual ? "real" : "virtual"));
                 return True;
             }
             else
             {
                 if (replace)
-                    action = "Ignoring %d, using %d\n";
+                    ACTION2("Ignoring %d, using %d\n", old->ndx, new->ndx);
                 else
-                    action = "Using %d, ignoring %d\n";
-                ACTION2(action, old->ndx, new->ndx);
+                    ACTION2("Using %d, ignoring %d\n", old->ndx, new->ndx);
             }
             if (replace)
             {
@@ -224,7 +222,7 @@ AddIndicatorName(KeyNamesInfo * info, IndicatorNameInfo * new)
         {
             WARN1("Multiple names for indicator %d\n", new->ndx);
             if ((old->name == new->name) && (old->virtual == new->virtual))
-                action = "Identical definitions ignored\n";
+                ACTION("Identical definitions ignored\n");
             else
             {
                 const char *oldType, *newType;
diff --git a/parseutils.c b/parseutils.c
index ad1b0d1..d59e3fb 100644
--- a/parseutils.c
+++ b/parseutils.c
@@ -392,7 +392,7 @@ ActionCreate(Atom name, ExprDef * args)
 }
 
 ExprDef *
-CreateKeysymList(KeySym sym)
+CreateKeysymList(char *sym)
 {
     ExprDef *def;
 
@@ -400,8 +400,8 @@ CreateKeysymList(KeySym sym)
     if (def)
     {
         def->value.list.nSyms = 1;
-        def->value.list.szSyms = 2;
-        def->value.list.syms = uTypedCalloc(2, KeySym);
+        def->value.list.szSyms = 4;
+        def->value.list.syms = uTypedCalloc(4, char *);
         if (def->value.list.syms != NULL)
         {
             def->value.list.syms[0] = sym;
@@ -600,7 +600,7 @@ DoodadCreate(unsigned type, Atom name, VarDef * body)
 }
 
 ExprDef *
-AppendKeysymList(ExprDef * list, KeySym sym)
+AppendKeysymList(ExprDef * list, char *sym)
 {
     if (list->value.list.nSyms >= list->value.list.szSyms)
     {
@@ -608,7 +608,7 @@ AppendKeysymList(ExprDef * list, KeySym sym)
         list->value.list.syms = uTypedRecalloc(list->value.list.syms,
                                                list->value.list.nSyms,
                                                list->value.list.szSyms,
-                                               KeySym);
+                                               char *);
         if (list->value.list.syms == NULL)
         {
             FATAL("Couldn't resize list of symbols for append\n");
diff --git a/parseutils.h b/parseutils.h
index 73a0ec8..0d06ce9 100644
--- a/parseutils.h
+++ b/parseutils.h
@@ -33,7 +33,7 @@
 
 #include "xkbcomp.h"
 
-extern char *scanStr;
+extern char scanBuf[1024];
 extern int scanInt;
 extern int lineNum;
 
@@ -121,7 +121,7 @@ extern ExprDef *ActionCreate(Atom /* name */ ,
                              ExprDef *  /* args */
     );
 
-extern ExprDef *CreateKeysymList(KeySym /* sym */
+extern ExprDef *CreateKeysymList(char * /* sym */
     );
 
 extern ShapeDef *ShapeDeclCreate(Atom /* name */ ,
@@ -161,7 +161,7 @@ extern DoodadDef *DoodadCreate(unsigned /* type */ ,
     );
 
 extern ExprDef *AppendKeysymList(ExprDef * /* list */ ,
-                                 KeySym /* sym */
+                                 char * /* sym */
     );
 
 extern int LookupKeysym(char * /* str */ ,
diff --git a/symbols.c b/symbols.c
index 47ad67b..cac69e3 100644
--- a/symbols.c
+++ b/symbols.c
@@ -27,6 +27,7 @@
 #include "xkbcomp.h"
 #include "tokens.h"
 #include "expr.h"
+#include "parseutils.h"
 
 #include <X11/keysym.h>
 #include <X11/Xutil.h>
@@ -968,8 +969,12 @@ AddSymbolsToKey(KeyInfo * key,
         return False;
     }
     key->symsDefined |= (1 << ndx);
-    memcpy((char *) key->syms[ndx], (char *) value->value.list.syms,
-           nSyms * sizeof(KeySym));
+    for (i = 0; i < nSyms; i++) {
+        if (!LookupKeysym(value->value.list.syms[i], &key->syms[ndx][i])) {
+            WSGO1("Could not resolve keysym %s\n", value->value.list.syms[i]);
+            key->syms[ndx][i] = NoSymbol;
+        }
+    }
     for (i = key->numLevels[ndx] - 1;
          (i >= 0) && (key->syms[ndx][i] == NoSymbol); i--)
     {
diff --git a/xkbcomp.c b/xkbcomp.c
index bf3f670..b0df920 100644
--- a/xkbcomp.c
+++ b/xkbcomp.c
@@ -864,7 +864,9 @@ GetDisplay(char *program, char *dpyName)
 
 /***====================================================================***/
 
+#ifdef DEBUG
 extern int yydebug;
+#endif
 
 int
 main(int argc, char *argv[])
diff --git a/xkbcomp.h b/xkbcomp.h
index 6e02ed5..d6a7185 100644
--- a/xkbcomp.h
+++ b/xkbcomp.h
@@ -156,7 +156,7 @@ typedef struct _Expr
         {
             int nSyms;
             int szSyms;
-            KeySym *syms;
+            char **syms;
         } list;
         struct
         {
diff --git a/xkbparse.y b/xkbparse.y
index 63f87bb..862acd8 100644
--- a/xkbparse.y
+++ b/xkbparse.y
@@ -136,9 +136,9 @@ unsigned int parseDebug;
 	XkbFile		*file;
 }
 %type <ival>	Number Integer Float SignedNumber
-%type <uval>	XkbCompositeType FileType MergeMode OptMergeMode KeySym
+%type <uval>	XkbCompositeType FileType MergeMode OptMergeMode
 %type <uval>	DoodadType Flag Flags OptFlags
-%type <str>	KeyName MapName OptMapName
+%type <str>	KeyName MapName OptMapName KeySym
 %type <sval>	FieldSpec Ident Element String 
 %type <any>	DeclList Decl 
 %type <expr>	OptExprList ExprList Expr Term Lhs Terminal ArrayInit
@@ -311,10 +311,10 @@ Decl		:	OptMergeMode VarDecl
 			{
 			    if ($1==MergeAltForm) {
 				yyerror("cannot use 'alternate' to include other maps");
-				$$= &IncludeCreate(scanStr,MergeDefault)->common;
+				$$= &IncludeCreate(scanBuf,MergeDefault)->common;
 			    }
 			    else {
-				$$= &IncludeCreate(scanStr,$1)->common;
+				$$= &IncludeCreate(scanBuf,$1)->common;
 			    }
                         }
 		;
@@ -374,9 +374,9 @@ InterpretDecl	:	INTERPRET InterpretMatch OBRACE
 		;
 
 InterpretMatch	:	KeySym PLUS Expr	
-			{ $$= InterpCreate((KeySym)$1,$3); }
+			{ $$= InterpCreate(XStringToKeysym($1), $3); }
 		|	KeySym			
-			{ $$= InterpCreate((KeySym)$1,NULL); }
+			{ $$= InterpCreate(XStringToKeysym($1), NULL); }
 		;
 
 VarDeclList	:	VarDeclList VarDecl
@@ -716,34 +716,17 @@ OptKeySymList	:	KeySymList			{ $$= $1; }
 		;
 
 KeySymList	:	KeySymList COMMA KeySym
-			{ $$= AppendKeysymList($1,(KeySym)$3); }
+			{ $$= AppendKeysymList($1,$3); }
 		|	KeySym
-			{ $$= CreateKeysymList((KeySym)$1); }
+			{ $$= CreateKeysymList($1); }
 		;
 
-KeySym		:	IDENT
-			{ 
-			    KeySym sym;
-			    if (LookupKeysym(scanStr,&sym))
-				$$= sym;
-			    else {
-				char buf[120];
-				snprintf(buf, sizeof(buf),
-					 "expected keysym, got %s",
-					 uStringText(scanStr));
-				yyerror(buf);
-				yynerrs++;
-				$$= NoSymbol;
-			    }
-			}
-		|	SECTION
-			{
-			    $$= XK_section;
-			}
+KeySym		:	IDENT           { $$= strdup(scanBuf); }
+		|	SECTION         { $$= strdup("section"); }
 		|	Integer		
 			{
-			    if ($1<10)	$$= $1+'0';	/* XK_0 .. XK_9 */
-			    else	$$= $1;
+			    if ($1<10)	{ $$= malloc(2); $$[0]= '0' + $1; $$[1]= '\0'; }
+			    else	{ $$= malloc(17); snprintf($$, 17, "%x", $1); }
 			}
 		;
 
@@ -761,21 +744,21 @@ Float		:	FLOAT		{ $$= scanInt; }
 Integer		:	INTEGER		{ $$= scanInt; }
 		;
 
-KeyName		:	KEYNAME		{ $$= scanStr; scanStr= NULL; }
+KeyName		:	KEYNAME		{ $$= strdup(scanBuf); }
 		;
 
-Ident		:	IDENT	{ $$= XkbInternAtom(NULL,scanStr,False); }
+Ident		:	IDENT	{ $$= XkbInternAtom(NULL,scanBuf,False); }
 		|	DEFAULT { $$= XkbInternAtom(NULL,"default",False); }
 		;
 
-String		:	STRING	{ $$= XkbInternAtom(NULL,scanStr,False); }
+String		:	STRING	{ $$= XkbInternAtom(NULL,scanBuf,False); }
 		;
 
 OptMapName	:	MapName	{ $$= $1; }
 		|		{ $$= NULL; }
 		;
 
-MapName		:	STRING 	{ $$= scanStr; scanStr= NULL; }
+MapName		:	STRING 	{ $$= strdup(scanBuf); }
 		;
 %%
 void
@@ -784,8 +767,8 @@ yyerror(const char *s)
     if (warningLevel>0) {
 	(void)fprintf(stderr,"%s: line %d of %s\n",s,lineNum,
 					(scanFile?scanFile:"(unknown)"));
-	if ((scanStr)&&(warningLevel>3))
-	    (void)fprintf(stderr,"last scanned symbol is: %s\n",scanStr);
+	if ((warningLevel>3))
+	    (void)fprintf(stderr,"last scanned symbol is: %s\n",scanBuf);
     }
     return;
 }
diff --git a/xkbscan.c b/xkbscan.c
index 31cafd4..1e7902d 100644
--- a/xkbscan.c
+++ b/xkbscan.c
@@ -45,14 +45,17 @@ int lineNum = 0;
 
 int scanInt;
 
-char *scanStr = NULL;
+char scanBuf[1024];
 static int scanStrLine = 0;
 
-#define	BUFSIZE	512
-static int nInBuf = 0;
-static char buf[BUFSIZE];
+#define	BUFSIZE	4096
+static char readBuf[BUFSIZE];
+static int readBufPos = 0;
+static int readBufLen = 0;
 
 #ifdef DEBUG
+extern int debugFlags;
+
 static char *
 tokText(int tok)
 {
@@ -216,7 +219,7 @@ tokText(int tok)
         break;
 
     case STRING:
-        snprintf(buf, sizeof(buf), "STRING (%s)", scanStr);
+        snprintf(buf, sizeof(buf), "STRING (%s)", scanBuf);
         break;
     case INTEGER:
         snprintf(buf, sizeof(buf), "INTEGER (0x%x)", scanInt);
@@ -226,10 +229,10 @@ tokText(int tok)
                 scanInt / XkbGeomPtsPerMM, scanInt % XkbGeomPtsPerMM);
         break;
     case IDENT:
-        snprintf(buf, sizeof(buf), "IDENT (%s)", scanStr);
+        snprintf(buf, sizeof(buf), "IDENT (%s)", scanBuf);
         break;
     case KEYNAME:
-        snprintf(buf, sizeof(buf), "KEYNAME (%s)", scanStr);
+        snprintf(buf, sizeof(buf), "KEYNAME (%s)", scanBuf);
         break;
 
     case PARTIAL:
@@ -266,6 +269,32 @@ tokText(int tok)
 }
 #endif
 
+static char
+scanchar(void)
+{
+    if (readBufPos >= readBufLen) {
+        readBufLen = fread(readBuf, 1, BUFSIZE, yyin);
+        readBufPos = 0;
+        if (!readBufLen)
+            return EOF;
+        if (feof(yyin))
+            readBuf[readBufLen] = EOF;
+    }
+
+    return readBuf[readBufPos++];
+}
+
+static void
+unscanchar(char c)
+{
+    if (readBuf[--readBufPos] != c) {
+        fprintf(stderr, "UNGETCHAR FAILED! Put back %c, was expecting %c at "
+                        "position %d, buf is '%s'\n", c, readBuf[readBufPos],
+                        readBufPos, readBuf);
+        _exit(94);
+    }
+}
+
 int
 setScanState(char *file, int line)
 {
@@ -279,14 +308,14 @@ setScanState(char *file, int line)
 static int
 yyGetString(void)
 {
-    int ch;
+    int ch, i;
 
-    nInBuf = 0;
-    while (((ch = getc(yyin)) != EOF) && (ch != '"'))
+    i = 0;
+    while (((ch = scanchar()) != EOF) && (ch != '"'))
     {
         if (ch == '\\')
         {
-            if ((ch = getc(yyin)) != EOF)
+            if ((ch = scanchar()) != EOF)
             {
                 if (ch == 'n')
                     ch = '\n';
@@ -306,7 +335,7 @@ yyGetString(void)
                 {
                     int tmp, stop;
                     ch = stop = 0;
-                    if (((tmp = getc(yyin)) != EOF) && (isdigit(tmp))
+                    if (((tmp = scanchar()) != EOF) && (isdigit(tmp))
                         && (tmp != '8') && (tmp != '9'))
                     {
                         ch = (ch * 8) + (tmp - '0');
@@ -314,11 +343,11 @@ yyGetString(void)
                     else
                     {
                         stop = 1;
-                        ungetc(tmp, yyin);
+                        unscanchar(tmp);
                     }
                     if (!stop)
                     {
-                        if (((tmp = getc(yyin)) != EOF)
+                        if (((tmp = scanchar()) != EOF)
                             && (isdigit(tmp)) && (tmp != '8') && (tmp != '9'))
                         {
                             ch = (ch * 8) + (tmp - '0');
@@ -326,12 +355,12 @@ yyGetString(void)
                         else
                         {
                             stop = 1;
-                            ungetc(tmp, yyin);
+                            unscanchar(tmp);
                         }
                     }
                     if (!stop)
                     {
-                        if (((tmp = getc(yyin)) != EOF)
+                        if (((tmp = scanchar()) != EOF)
                             && (isdigit(tmp)) && (tmp != '8') && (tmp != '9'))
                         {
                             ch = (ch * 8) + (tmp - '0');
@@ -339,7 +368,7 @@ yyGetString(void)
                         else
                         {
                             stop = 1;
-                            ungetc(tmp, yyin);
+                            unscanchar(tmp);
                         }
                     }
                 }
@@ -347,15 +376,12 @@ yyGetString(void)
             else
                 return ERROR_TOK;
         }
-        if (nInBuf < BUFSIZE - 1)
-            buf[nInBuf++] = ch;
+        if (i < sizeof(scanBuf) - 1)
+            scanBuf[i++] = ch;
     }
     if (ch == '"')
     {
-        buf[nInBuf++] = '\0';
-        if (scanStr)
-            uFree(scanStr);
-        scanStr = (char *) uStringDup(buf);
+        scanBuf[i++] = '\0';
         scanStrLine = lineNum;
         return STRING;
     }
@@ -365,14 +391,14 @@ yyGetString(void)
 static int
 yyGetKeyName(void)
 {
-    int ch;
+    int ch, i;
 
-    nInBuf = 0;
-    while (((ch = getc(yyin)) != EOF) && (ch != '>'))
+    i = 0;
+    while (((ch = scanchar()) != EOF) && (ch != '>'))
     {
         if (ch == '\\')
         {
-            if ((ch = getc(yyin)) != EOF)
+            if ((ch = scanchar()) != EOF)
             {
                 if (ch == 'n')
                     ch = '\n';
@@ -392,7 +418,7 @@ yyGetKeyName(void)
                 {
                     int tmp, stop;
                     ch = stop = 0;
-                    if (((tmp = getc(yyin)) != EOF) && (isdigit(tmp))
+                    if (((tmp = scanchar()) != EOF) && (isdigit(tmp))
                         && (tmp != '8') && (tmp != '9'))
                     {
                         ch = (ch * 8) + (tmp - '0');
@@ -400,9 +426,9 @@ yyGetKeyName(void)
                     else
                     {
                         stop = 1;
-                        ungetc(tmp, yyin);
+                        unscanchar(tmp);
                     }
-                    if ((!stop) && ((tmp = getc(yyin)) != EOF)
+                    if ((!stop) && ((tmp = scanchar()) != EOF)
                         && (isdigit(tmp)) && (tmp != '8') && (tmp != '9'))
                     {
                         ch = (ch * 8) + (tmp - '0');
@@ -410,9 +436,9 @@ yyGetKeyName(void)
                     else
                     {
                         stop = 1;
-                        ungetc(tmp, yyin);
+                        unscanchar(tmp);
                     }
-                    if ((!stop) && ((tmp = getc(yyin)) != EOF)
+                    if ((!stop) && ((tmp = scanchar()) != EOF)
                         && (isdigit(tmp)) && (tmp != '8') && (tmp != '9'))
                     {
                         ch = (ch * 8) + (tmp - '0');
@@ -420,7 +446,7 @@ yyGetKeyName(void)
                     else
                     {
                         stop = 1;
-                        ungetc(tmp, yyin);
+                        unscanchar(tmp);
                     }
                 }
             }
@@ -428,15 +454,12 @@ yyGetKeyName(void)
                 return ERROR_TOK;
         }
 
-        if (nInBuf < BUFSIZE - 1)
-            buf[nInBuf++] = ch;
+        if (i < sizeof(scanBuf) - 1)
+            scanBuf[i++] = ch;
     }
-    if ((ch == '>') && (nInBuf < 5))
+    if ((ch == '>') && (i < 5))
     {
-        buf[nInBuf++] = '\0';
-        if (scanStr)
-            uFree(scanStr);
-        scanStr = (char *) uStringDup(buf);
+        scanBuf[i++] = '\0';
         scanStrLine = lineNum;
         return KEYNAME;
     }
@@ -545,22 +568,22 @@ static int numKeywords = sizeof(keywords) / sizeof(struct _Keyword);
 static int
 yyGetIdent(int first)
 {
-    int ch, i, found;
+    int ch, i, j, found;
     int rtrn = IDENT;
 
-    buf[0] = first;
-    nInBuf = 1;
-    while (((ch = getc(yyin)) != EOF) && (isalnum(ch) || (ch == '_')))
+    scanBuf[0] = first;
+    j = 1;
+    while (((ch = scanchar()) != EOF) && (isalnum(ch) || (ch == '_')))
     {
-        if (nInBuf < BUFSIZE - 1)
-            buf[nInBuf++] = ch;
+        if (j < sizeof(scanBuf) - 1)
+            scanBuf[j++] = ch;
     }
-    buf[nInBuf++] = '\0';
+    scanBuf[j++] = '\0';
     found = 0;
 
     for (i = 0; (!found) && (i < numKeywords); i++)
     {
-        if (uStrCaseCmp(buf, keywords[i].keyword) == 0)
+        if (uStrCaseCmp(scanBuf, keywords[i].keyword) == 0)
         {
             rtrn = keywords[i].token;
             found = 1;
@@ -568,15 +591,12 @@ yyGetIdent(int first)
     }
     if (!found)
     {
-        if (scanStr)
-            uFree(scanStr);
-        scanStr = (char *) uStringDup(buf);
         scanStrLine = lineNum;
         rtrn = IDENT;
     }
 
     if ((ch != EOF) && (!isspace(ch)))
-        ungetc(ch, yyin);
+        unscanchar(ch);
     else if (ch == '\n')
         lineNum++;
 
@@ -587,10 +607,12 @@ static int
 yyGetNumber(int ch)
 {
     int isFloat = 0;
+    char buf[1024];
+    int nInBuf = 0;
 
     buf[0] = ch;
     nInBuf = 1;
-    while (((ch = getc(yyin)) != EOF)
+    while (((ch = scanchar()) != EOF)
            && (isxdigit(ch) || ((nInBuf == 1) && (ch == 'x'))))
     {
         buf[nInBuf++] = ch;
@@ -599,14 +621,14 @@ yyGetNumber(int ch)
     {
         isFloat = 1;
         buf[nInBuf++] = ch;
-        while (((ch = getc(yyin)) != EOF) && (isxdigit(ch)))
+        while (((ch = scanchar()) != EOF) && (isxdigit(ch)))
         {
             buf[nInBuf++] = ch;
         }
     }
     buf[nInBuf++] = '\0';
     if ((ch != EOF) && (!isspace(ch)))
-        ungetc(ch, yyin);
+        unscanchar(ch);
 
     if (isFloat)
     {
@@ -631,7 +653,7 @@ yylex(void)
 
     do
     {
-        ch = getc(yyin);
+        ch = scanchar();
         if (ch == '\n')
         {
             lineNum++;
@@ -640,26 +662,26 @@ yylex(void)
         {                       /* handle shell style '#' comments */
             do
             {
-                ch = getc(yyin);
+                ch = scanchar();
             }
             while ((ch != '\n') && (ch != EOF));
             lineNum++;
         }
         else if (ch == '/')
         {                       /* handle C++ style double-/ comments */
-            int newch = getc(yyin);
+            int newch = scanchar();
             if (newch == '/')
             {
                 do
                 {
-                    ch = getc(yyin);
+                    ch = scanchar();
                 }
                 while ((ch != '\n') && (ch != EOF));
                 lineNum++;
             }
             else if (newch != EOF)
             {
-                ungetc(newch, yyin);
+                unscanchar(newch);
             }
         }
     }


Index: xorg-x11-xkb-utils.spec
===================================================================
RCS file: /cvs/pkgs/rpms/xorg-x11-xkb-utils/devel/xorg-x11-xkb-utils.spec,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -p -r1.32 -r1.33
--- xorg-x11-xkb-utils.spec	19 Oct 2009 23:04:09 -0000	1.32
+++ xorg-x11-xkb-utils.spec	8 Jul 2010 14:43:58 -0000	1.33
@@ -1,7 +1,7 @@
 Summary: X.Org X11 xkb utilities
 Name: xorg-x11-xkb-utils
 Version: 7.4
-Release: 7%{?dist}
+Release: 8%{?dist}
 License: MIT
 Group: User Interface/X
 URL: http://www.x.org
@@ -15,6 +15,8 @@ Source2: ftp://ftp.x.org/pub/individual/
 Source3: ftp://ftp.x.org/pub/individual/app/xkbprint-1.0.1.tar.bz2
 Source4: ftp://ftp.x.org/pub/individual/app/setxkbmap-1.1.0.tar.bz2
 
+Patch0: xkbcomp-speed.patch
+
 BuildRequires: pkgconfig
 BuildRequires: libxkbfile-devel
 BuildRequires: libX11-devel
@@ -48,13 +50,17 @@ X.Org X11 xkb gadgets
 
 %prep
 %setup -q -c %{name}-%{version} -a1 -a2 -a3 -a4
+pushd xkbcomp-*
+%patch0 -p1 -b .speeeeeed
+popd
 
 %build
 export CFLAGS="$RPM_OPT_FLAGS -DHAVE_STRCASECMP -Os"
 for pkg in xkbutils setxkbmap xkbcomp xkbevd xkbprint ; do
     pushd $pkg-*
+    [ $pkg == xkbcomp ] && rm xkbparse.c # force regen
     %configure
-    make
+    make V=1
     popd
 done
 
@@ -92,6 +98,9 @@ rm -rf $RPM_BUILD_ROOT
 %{_mandir}/man1/xkbwatch.*
 
 %changelog
+* Thu Jul 08 2010 Adam Jackson <ajax at redhat.com> 7.4-8
+- xkbcomp-speed.patch: Backport performance changes from git master.
+
 * Mon Oct 19 2009 Adam Jackson <ajax at redhat.com> 7.4-7
 - xkbevd 1.1.0
 - xkbutils 1.0.2



More information about the scm-commits mailing list