summaryrefslogtreecommitdiff
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
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>
-rw-r--r--debian/changelog3
-rw-r--r--lib/paragraph.c17
-rw-r--r--tests/0010.err2
-rw-r--r--tests/0010.fails0
-rw-r--r--tests/0010.in6
-rw-r--r--tests/0010.sh8
-rw-r--r--tests/0011.err2
-rw-r--r--tests/0011.fails0
-rw-r--r--tests/0011.in7
-rw-r--r--tests/0011.sh8
10 files changed, 46 insertions, 7 deletions
diff --git a/debian/changelog b/debian/changelog
index 88f0bae..1bb150b 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -7,11 +7,12 @@ dctrl-tools (2.15) UNRELEASED; urgency=low
* Update FSF address in license blurbs all over the source tree.
* debian/copyright: Update copyright years
* Merge 2.14.1
+ * lib/paragraph.c (para_parse_next): Fix line counting.
[ Cyril Brulebois ]
* Add Build-Depends/Build-Depends-Indep search example (closes: #339380)
- -- Antti-Juhani Kaijanaho <ajk@debian.org> Sat, 28 Aug 2010 09:38:24 +0300
+ -- Antti-Juhani Kaijanaho <ajk@debian.org> Sat, 28 Aug 2010 20:20:50 +0300
dctrl-tools (2.14.1) unstable; urgency=low
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;
}
diff --git a/tests/0010.err b/tests/0010.err
new file mode 100644
index 0000000..4b9f606
--- /dev/null
+++ b/tests/0010.err
@@ -0,0 +1,2 @@
+../grep-dctrl/grep-dctrl: -:3: expected a colon
+. \ No newline at end of file
diff --git a/tests/0010.fails b/tests/0010.fails
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/0010.fails
diff --git a/tests/0010.in b/tests/0010.in
new file mode 100644
index 0000000..8f2920d
--- /dev/null
+++ b/tests/0010.in
@@ -0,0 +1,6 @@
+Foo: bar
+
+bar
+baz
+
+xyzzy
diff --git a/tests/0010.sh b/tests/0010.sh
new file mode 100644
index 0000000..1fed9f1
--- /dev/null
+++ b/tests/0010.sh
@@ -0,0 +1,8 @@
+#!/bin/sh
+
+set -e
+
+LC_ALL=C
+export LC_ALL
+
+$GREP_DCTRL ''
diff --git a/tests/0011.err b/tests/0011.err
new file mode 100644
index 0000000..5200d77
--- /dev/null
+++ b/tests/0011.err
@@ -0,0 +1,2 @@
+../grep-dctrl/grep-dctrl: -:5: expected a colon
+. \ No newline at end of file
diff --git a/tests/0011.fails b/tests/0011.fails
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/0011.fails
diff --git a/tests/0011.in b/tests/0011.in
new file mode 100644
index 0000000..fe4ab13
--- /dev/null
+++ b/tests/0011.in
@@ -0,0 +1,7 @@
+Foo: bar
+
+Foo: bar
+
+error
+
+Whatever: here
diff --git a/tests/0011.sh b/tests/0011.sh
new file mode 100644
index 0000000..1fed9f1
--- /dev/null
+++ b/tests/0011.sh
@@ -0,0 +1,8 @@
+#!/bin/sh
+
+set -e
+
+LC_ALL=C
+export LC_ALL
+
+$GREP_DCTRL ''