On Fri, Jan 01, 2010 at 07:48:30PM +0100, Stephan Raue wrote:
> Am 01.01.2010 19:13, schrieb Dan Nicholson:
>> On Fri, Jan 1, 2010 at 7:38 AM, Stephan Raue<[email protected]>  
>> wrote:
>>> another little issue i have found in the implementation of xorg.conf.d:
>>>
>>> if i have configfiles without an empty last line there are errors
>>> because the first line of the second configfile will be parsed with the
>>> last line of the first config file.
>>>      
>> Wow, good to know. I guess my editor always ends the files with
>> newlines. I'll have to take a look at it.
>>
>>    
> thank you :-) and thank you for our good work :-)

Can you try the patch below? I haven't built or tested it (upgrading my
system right now), but I think it should do the right thing.

--
Dan

>From 16902d9960518c2ac54199440746e77ff6cb93f5 Mon Sep 17 00:00:00 2001
From: Dan Nicholson <[email protected]>
Date: Fri, 1 Jan 2010 11:58:03 -0800
Subject: [PATCH] xfree86: Return non-NULL when reaching EOF with more files to 
parse

The config parser is line based, so it has to return when reaching EOF
just like when reaching EOL. In order to signal that there are still
files to parse, non-NULL must be returned. Previously, the parser was
just moving to the first line of the next file and continuing without
returning to the caller. This only works when each file ends in an empty
line.

Signed-off-by: Dan Nicholson <[email protected]>
---
 hw/xfree86/parser/scan.c |   15 +++++++++------
 1 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/hw/xfree86/parser/scan.c b/hw/xfree86/parser/scan.c
index b80fbfb..b26b6f6 100644
--- a/hw/xfree86/parser/scan.c
+++ b/hw/xfree86/parser/scan.c
@@ -226,14 +226,17 @@ xf86getNextLine(void)
                ret = fgets(configBuf + pos, configBufLen - pos - 1,
                            configFiles[curFileIndex].file);
 
+               /*
+                * If we've reached EOF, prepare for the next file and don't
+                * return NULL. Otherwise, just reset the index for parsing.
+                */
                if (!ret) {
-                       /* stop if there are no more files */
-                       if (++curFileIndex >= numFiles) {
+                       if (++curFileIndex < numFiles) {
+                               ret = configBuf;
+                               configLineNo = 0;
+                       } else
                                curFileIndex = 0;
-                               break;
-                       }
-                       configLineNo = 0;
-                       continue;
+                       break;
                }
 
                /* search for EOL in the new block of chars */
-- 
1.6.2.5
_______________________________________________
xorg-devel mailing list
[email protected]
http://lists.x.org/mailman/listinfo/xorg-devel

Reply via email to