Blame SOURCES/0001-Reset-scan-state-when-opening-a-new-file.patch

aea5f6
From a68c5b7b29eb1433b1be73b50c4248e10eab8e64 Mon Sep 17 00:00:00 2001
aea5f6
From: Daniel Stone <daniel@fooishbar.org>
aea5f6
Date: Thu, 1 Nov 2012 16:37:03 +1100
aea5f6
Subject: [PATCH] Reset scan state when opening a new file
aea5f6
aea5f6
When we opened a new file after encountering a parse error, we weren't
aea5f6
resetting our scan state, and continued to read out of the old buffer
aea5f6
rather than that of the new file.
aea5f6
aea5f6
Fixes a regression introduced in 9887842e ('Use fread() instead of
aea5f6
getc()').
aea5f6
aea5f6
Test case:
aea5f6
    xkbcomp -lfhlpR "path/to/xkeyboard-config.git/symbols/*"
aea5f6
The Makefiles in that tree would cause parse errors, the resulting directory
aea5f6
file is incomplete (down from ~12000 to ~230 lines).
aea5f6
aea5f6
Reported-by: Peter Hutterer <peter.hutterer@who-t.net>
aea5f6
Signed-off-by: Daniel Stone <daniel@fooishbar.org>
aea5f6
---
aea5f6
 parseutils.c |  2 +-
aea5f6
 parseutils.h |  3 +--
aea5f6
 xkbcomp.c    |  2 +-
aea5f6
 xkbscan.c    | 10 +++++++++-
aea5f6
 4 files changed, 12 insertions(+), 5 deletions(-)
aea5f6
aea5f6
diff --git a/xkbcomp-1.2.4/parseutils.c b/parseutils.c
aea5f6
index 253cd9d..a1b6e9e 100644
aea5f6
--- a/xkbcomp-1.2.4/parseutils.c
aea5f6
+++ b/xkbcomp-1.2.4/parseutils.c
aea5f6
@@ -797,7 +797,7 @@ XKBParseFile(FILE * file, XkbFile ** pRtrn)
aea5f6
 {
aea5f6
     if (file)
aea5f6
     {
aea5f6
-        yyin = file;
aea5f6
+        scan_set_file(file);
aea5f6
         rtrnValue = NULL;
aea5f6
         if (yyparse() == 0)
aea5f6
         {
aea5f6
diff --git a/xkbcomp-1.2.4/parseutils.h b/xkbcomp-1.2.4/parseutils.h
aea5f6
index 8b8a6c1..8c381d4 100644
aea5f6
--- a/xkbcomp-1.2.4/parseutils.h
aea5f6
+++ b/xkbcomp-1.2.4/parseutils.h
aea5f6
@@ -198,11 +198,10 @@ extern int yywrap(void);
aea5f6
 
aea5f6
 extern int yylex(void);
aea5f6
 extern int yyparse(void);
aea5f6
+extern void scan_set_file(FILE *file);
aea5f6
 
aea5f6
 extern int setScanState(char * /* file */ ,
aea5f6
                         int     /* line */
aea5f6
     );
aea5f6
 
aea5f6
-extern FILE *yyin;
aea5f6
-
aea5f6
 #endif /* XKBPARSE_H */
aea5f6
diff --git a/xkbcomp-1.2.4/xkbcomp.c b/xkbcomp-1.2.4/xkbcomp.c
aea5f6
index 063ae87..116bcfa 100644
aea5f6
--- a/xkbcomp-1.2.4/xkbcomp.c
aea5f6
+++ b/xkbcomp-1.2.4/xkbcomp.c
aea5f6
@@ -883,7 +883,7 @@ main(int argc, char *argv[])
aea5f6
     XkbFileInfo result;
aea5f6
     Status status;
aea5f6
 
aea5f6
-    yyin = stdin;
aea5f6
+    scan_set_file(stdin);
aea5f6
     uSetEntryFile(NullString);
aea5f6
     uSetDebugFile(NullString);
aea5f6
     uSetErrorFile(NullString);
aea5f6
diff --git a/xkbcomp-1.2.4/xkbscan.c b/xkbcomp-1.2.4/xkbscan.c
aea5f6
index 22a034f..a05d569 100644
aea5f6
--- a/xkbcomp-1.2.4/xkbscan.c
aea5f6
+++ b/xkbcomp-1.2.4/xkbscan.c
aea5f6
@@ -37,7 +37,7 @@
aea5f6
 
aea5f6
 unsigned int scanDebug;
aea5f6
 
aea5f6
-FILE *yyin = NULL;
aea5f6
+static FILE *yyin;
aea5f6
 
aea5f6
 static char scanFileBuf[1024] = {0};
aea5f6
 char *scanFile = scanFileBuf;
aea5f6
@@ -269,6 +269,14 @@ tokText(int tok)
aea5f6
 }
aea5f6
 #endif
aea5f6
 
aea5f6
+void
aea5f6
+scan_set_file(FILE *file)
aea5f6
+{
aea5f6
+    readBufLen = 0;
aea5f6
+    readBufPos = 0;
aea5f6
+    yyin = file;
aea5f6
+}
aea5f6
+
aea5f6
 static int
aea5f6
 scanchar(void)
aea5f6
 {
aea5f6
-- 
aea5f6
1.7.11.7
aea5f6