summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 735c674)
raw | patch | inline | side by side (parent: 735c674)
author | Alex Vandiver <alex@chmrr.net> | |
Fri, 24 Jul 2009 21:21:43 +0000 (17:21 -0400) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Sat, 25 Jul 2009 06:42:34 +0000 (23:42 -0700) |
Signed-off-by: Alex Vandiver <alex@chmrr.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
config.c | patch | blob | history |
diff --git a/config.c b/config.c
index 1682273c12ab042d73fa32caf30d18fb13ef85e3..8d0e549976d6d2081e62c5de3a3da4085bb0c99e 100644 (file)
--- a/config.c
+++ b/config.c
static int section_name_match (const char *buf, const char *name)
{
int i = 0, j = 0, dot = 0;
- for (; buf[i] && buf[i] != ']'; i++) {
+ if (buf[i] != '[')
+ return 0;
+ for (i = 1; buf[i] && buf[i] != ']'; i++) {
if (!dot && isspace(buf[i])) {
dot = 1;
if (name[j++] != '.')
if (buf[i] != name[j++])
break;
}
- return (buf[i] == ']' && name[j] == 0);
+ if (buf[i] == ']' && name[j] == 0) {
+ /*
+ * We match, now just find the right length offset by
+ * gobbling up any whitespace after it, as well
+ */
+ i++;
+ for (; buf[i] && isspace(buf[i]); i++)
+ ; /* do nothing */
+ return i;
+ }
+ return 0;
}
/* if new_name == NULL, the section is removed instead */
; /* do nothing */
if (buf[i] == '[') {
/* it's a section */
- if (section_name_match (&buf[i+1], old_name)) {
+ int offset = section_name_match(&buf[i], old_name);
+ if (offset > 0) {
ret++;
if (new_name == NULL) {
remove = 1;