summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Nicholson <dbn.lists@gmail.com>2010-02-10 15:36:45 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2010-02-11 19:25:14 +1000
commit8b1a685f00ae76be864cc188943a0874f48b8d64 (patch)
tree8aeb867f2c90de45f982e45cc41533db5710942f
parent67bc278a511ca6ec42e1f8d2d5897c0109e94e2c (diff)
xfree86: Handle config files ending without newline
The config parser expects to find a newline at the end of each line, so files ending without one would confuse it. A newline is inserted at the end of the buffer in these situations. Additionally, switching to the next config file is moved to the higher level to allow parsing of the last line of the previous file to complete before shifting the index and resetting the line number. Signed-off-by: Dan Nicholson <dbn.lists@gmail.com> Tested-by: Stephan Raue<stephan.raue@gmx.net> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
-rw-r--r--hw/xfree86/parser/scan.c26
1 files changed, 19 insertions, 7 deletions
diff --git a/hw/xfree86/parser/scan.c b/hw/xfree86/parser/scan.c
index b80fbfb8f..03cbc8a44 100644
--- a/hw/xfree86/parser/scan.c
+++ b/hw/xfree86/parser/scan.c
@@ -227,13 +227,15 @@ xf86getNextLine(void)
configFiles[curFileIndex].file);
if (!ret) {
- /* stop if there are no more files */
- if (++curFileIndex >= numFiles) {
- curFileIndex = 0;
+ /*
+ * if the file doesn't end in a newline, add one
+ * and trigger another read
+ */
+ if (pos != 0) {
+ strcpy(&configBuf[pos], "\n");
+ ret = configBuf;
+ } else
break;
- }
- configLineNo = 0;
- continue;
}
/* search for EOL in the new block of chars */
@@ -338,7 +340,17 @@ again:
}
if (ret == NULL)
{
- return (pushToken = EOF_TOKEN);
+ /*
+ * if necessary, move to the next file and
+ * read the first line
+ */
+ if (curFileIndex + 1 < numFiles) {
+ curFileIndex++;
+ configLineNo = 0;
+ goto again;
+ }
+ else
+ return (pushToken = EOF_TOKEN);
}
configLineNo++;
configPos = 0;