summaryrefslogtreecommitdiff
path: root/config.c
diff options
context:
space:
mode:
authorMartin Stenberg <martin@gnutiken.se>2012-03-09 21:57:54 (GMT)
committerJunio C Hamano <gitster@pobox.com>2012-03-12 16:39:06 (GMT)
commit4b340593551217904d794cc0a8db55db89b5b066 (patch)
treecc73f2727a638a51a40e688008f4d0709b0331c4 /config.c
parentd909e0761c234b28aac77566368c1ee5451a856a (diff)
downloadgit-4b340593551217904d794cc0a8db55db89b5b066.zip
git-4b340593551217904d794cc0a8db55db89b5b066.tar.gz
git-4b340593551217904d794cc0a8db55db89b5b066.tar.bz2
config: report errors at the EOL with correct line number
A section in a config file with a missing "]" reports the next line as bad, same goes to a value with a missing end quote. This happens because the error is not detected until the end of the line, when line number is already increased. Fix this by decreasing line number by one for these cases. Signed-off-by: Martin Stenberg <martin@gnutiken.se> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'config.c')
-rw-r--r--config.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/config.c b/config.c
index d3bcaa0..fc27913 100644
--- a/config.c
+++ b/config.c
@@ -135,8 +135,10 @@ static char *parse_value(void)
for (;;) {
int c = get_next_char();
if (c == '\n') {
- if (quote)
+ if (quote) {
+ cf->linenr--;
return NULL;
+ }
return cf->value.buf;
}
if (comment)
@@ -226,7 +228,7 @@ static int get_extended_base_var(char *name, int baselen, int c)
{
do {
if (c == '\n')
- return -1;
+ goto error_incomplete_line;
c = get_next_char();
} while (isspace(c));
@@ -238,13 +240,13 @@ static int get_extended_base_var(char *name, int baselen, int c)
for (;;) {
int c = get_next_char();
if (c == '\n')
- return -1;
+ goto error_incomplete_line;
if (c == '"')
break;
if (c == '\\') {
c = get_next_char();
if (c == '\n')
- return -1;
+ goto error_incomplete_line;
}
name[baselen++] = c;
if (baselen > MAXNAME / 2)
@@ -255,6 +257,9 @@ static int get_extended_base_var(char *name, int baselen, int c)
if (get_next_char() != ']')
return -1;
return baselen;
+error_incomplete_line:
+ cf->linenr--;
+ return -1;
}
static int get_base_var(char *name)