summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAntti-Juhani Kaijanaho <ajk@debian.org>2010-08-28 20:23:04 +0300
committerAntti-Juhani Kaijanaho <ajk@debian.org>2010-08-28 20:23:04 +0300
commit808de4efa746be07aed56cb0f2bcab6a2c12f19f (patch)
tree838de8b7c37c01d92bd010ff961171b76c316f35 /lib
parent710b0a4e092611343e008653d7f9dc2a35592e00 (diff)
downloaddctrl-tools-808de4efa746be07aed56cb0f2bcab6a2c12f19f.tar.gz
lib/paragraph.c (para_parse_next): Fix line counting.
Signed-off-by: Antti-Juhani Kaijanaho <ajk@debian.org>
Diffstat (limited to 'lib')
-rw-r--r--lib/paragraph.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/lib/paragraph.c b/lib/paragraph.c
index c0903a2..b30a3bc 100644
--- a/lib/paragraph.c
+++ b/lib/paragraph.c
@@ -1,5 +1,5 @@
/* dctrl-tools - Debian control file inspection tools
- Copyright © 2003, 2004, 2008 Antti-Juhani Kaijanaho
+ Copyright © 2003, 2004, 2008, 2010 Antti-Juhani Kaijanaho
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -97,6 +97,7 @@ redo:
struct field_data * field_data = 0;
#define GETC (c = fsaf_getc(fp, pos++), c == '\n' ? line++ : line)
+#define UNGETC (fsaf_getc(fp, --pos) == '\n' ? --line : line)
int c;
START:
GETC;
@@ -111,7 +112,8 @@ START:
para->start++;
goto START_SKIPCOMMENT;
default:
- field_start = --pos;
+ UNGETC;
+ field_start = pos;
goto FIELD_NAME;
}
assert(0);
@@ -135,7 +137,7 @@ FIELD_NAME:
switch (c) {
case '\n': case -1:
if (pp->ignore_broken_paras) {
- line_message(L_IMPORTANT, fp->fname,
+ line_message(L_IMPORTANT, fp->fname,
c == '\n' ?line-1:line,
_("warning: expected a colon"));
goto FAIL;
@@ -208,7 +210,8 @@ BODY_NEWLINE:
case '#':
goto BODY_SKIPCOMMENT;
default:
- field_start = --pos;
+ UNGETC;
+ field_start = pos;
goto FIELD_NAME;
}
assert(0);
@@ -249,7 +252,9 @@ FAIL:
goto redo;
END:
- para->end = pos-2;
+ UNGETC;
+ UNGETC;
+ para->end = pos;
pp->loc = para->end;
- pp->line = fsaf_getc(fp, pp->loc) == '\n' ? line-1 : line;
+ pp->line = line;
}