threads / patch / 4080

patchAnother config file parsing fix.

Subject: [PATCH] Another config file parsing fix.

## tl;dr

One message between May 6, 2006 and May 6, 2006. Diffs are folded; open one to read it.

replies: 0people: 1as markdown or json

sean· May 6, 2006, 18:14 UTC · lore

If the variable we need to store should go into a section that currently only has a single variable (not matching the one we're trying to insert), we will already be into the next section before we notice we've bypassed the correct location to insert the variable.

To handle this case we store the current location as soon as we find a variable matching the section of our new variable.

Signed-off-by: Sean Estabrooks <seanlkml@sympatico.ca>
---
 config.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
1ba487db7393d773a2a4b7c404ba1b807272eb7d
Show changes to config.c +3 −1
diff --git a/config.c b/config.c
index 87fb220..41066e4 100644
--- a/config.c
+++ b/config.c
@@ -336,8 +336,10 @@ static int store_aux(const char* key, co
 			store.state = KEY_SEEN;
 			store.seen++;
 		} else if (strrchr(key, '.') - key == store.baselen &&
-			      !strncmp(key, store.key, store.baselen))
+			      !strncmp(key, store.key, store.baselen)) {
 					store.state = SECTION_SEEN;
+					store.offset[store.seen] = ftell(config_file);
+		}
 	}
 	return 0;
 }
-- 
1.3.2.g6e99a-dirty

← back to recent threads