Skip to content

Commit

Permalink
Another config file parsing fix.
Browse files Browse the repository at this point in the history
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.

This breakage was brought up by Linus.

Signed-off-by: Sean Estabrooks <seanlkml@sympatico.ca>
Signed-off-by: Junio C Hamano <junkio@cox.net>
  • Loading branch information
sean authored and Junio C Hamano committed May 13, 2006
1 parent 618faa1 commit bdf0ef0
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion config.c
Original file line number Diff line number Diff line change
Expand Up @@ -336,8 +336,10 @@ static int store_aux(const char* key, const char* value)
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;
}
Expand Down

0 comments on commit bdf0ef0

Please sign in to comment.