[Dctrl-tools-devel] [SCM] Debian control file query tools branch, master, updated. 2.11-49-g2bc3218

Antti-Juhani Kaijanaho ajk at debian.org
Sat Dec 5 10:42:54 UTC 2009


The following commit has been merged in the master branch:
commit 2bc3218cf4f70db497b97687b0d4bc3a847ec217
Author: Antti-Juhani Kaijanaho <ajk at debian.org>
Date:   Sat Dec 5 12:42:49 2009 +0200

    Add support for #-comments
    
    Debian Policy allows, in debian/control, lines that start with the
    '#'-character.  Those lines are treated as comments by Policy, and ignored.
    
    This patch adds parser support for these comments in dctrl-tools.
    Unfortunately, it is not possible (without major changes) to ignore
    those comments semantically, since dctrl-tools represents paragraphs
    and fields as substrings of the input file.
    
    Accordingly, what this patch does is allow the parser to not choke on
    comments.  Comments found inside a paragraph are left semantically
    significant (ie. part of the field body in which they are found),
    while comments otside of paragraphs are elided.
    
    Signed-off-by: Antti-Juhani Kaijanaho <ajk at debian.org>

diff --git a/debian/changelog b/debian/changelog
index b8bee61..d5c5a29 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -29,13 +29,16 @@ dctrl-tools (2.14) UNRELEASED; urgency=low
     key...)
     Closes: #559543 (doesn't take into account secondary sorting criteria)
     Reported by: Ryan Niebur <ryan at debian.org>
+  * lib/paragraph.c (para_parse_next): parse comment lines that start with
+    unindented '#'-characters (they are not removed semantically, though)
+    Closes: #521006 (support #-comments)
   
   [ Stefano Zacchiroli ]
   * grep-dctrl: add new matching mode --whole-pkg/-w: it is an improved -e
     matching exact package names, i.e., no sub-string matching on package
     names. Closes: #383921
 
- -- Antti-Juhani Kaijanaho <ajk at debian.org>  Sat, 05 Dec 2009 12:32:47 +0200
+ -- Antti-Juhani Kaijanaho <ajk at debian.org>  Sat, 05 Dec 2009 12:41:52 +0200
 
 dctrl-tools (2.13.0) unstable; urgency=low
 
diff --git a/lib/paragraph.c b/lib/paragraph.c
index f67af94..448cf07 100644
--- a/lib/paragraph.c
+++ b/lib/paragraph.c
@@ -107,12 +107,29 @@ START:
         case '\n':
                 para->start++;
                 goto START;
+        case '#':
+                para->start++;
+                goto START_SKIPCOMMENT;
         default:
                 field_start = --pos;
                 goto FIELD_NAME;
         }
         assert(0);
 
+START_SKIPCOMMENT:
+        GETC;
+        switch (c) {
+        case -1:
+                pp->eof = true;
+                goto END;
+        case '\n':
+                para->start++;
+                goto START;
+        default:
+                para->start++;
+                goto START_SKIPCOMMENT;
+        }
+
 FIELD_NAME:
         GETC;
         switch (c) {
@@ -188,6 +205,8 @@ BODY_NEWLINE:
                 goto END;
         case ' ': case '\t':
                 goto BODY_SKIPBLANKS;
+        case '#':
+                goto BODY_SKIPCOMMENT;
         default:
                 field_start = --pos;
 		goto FIELD_NAME;
@@ -209,6 +228,17 @@ BODY_SKIPBLANKS:
         }
         assert(0);
 
+BODY_SKIPCOMMENT:
+        GETC;
+        switch (c) {
+        case -1:
+                /* pass through */
+        case '\n':
+                goto BODY_NEWLINE;
+        default:
+                goto BODY_SKIPCOMMENT;
+        }
+
 #undef GETC
 
 FAIL:
diff --git a/tests/0009.in b/tests/0009.in
new file mode 100644
index 0000000..f6d485e
--- /dev/null
+++ b/tests/0009.in
@@ -0,0 +1,9 @@
+# abc
+Foo: bar
+# baz
+Xyzzy: foo
+#ytty
+
+# ccd
+Sdd: gh
+goo: gaa
diff --git a/tests/0009.out b/tests/0009.out
new file mode 100644
index 0000000..7c6c2de
--- /dev/null
+++ b/tests/0009.out
@@ -0,0 +1,8 @@
+Foo: bar
+# baz
+Xyzzy: foo
+#ytty
+
+Sdd: gh
+goo: gaa
+
diff --git a/tests/0009.sh b/tests/0009.sh
new file mode 100644
index 0000000..5e2204f
--- /dev/null
+++ b/tests/0009.sh
@@ -0,0 +1,5 @@
+#!/bin/sh
+
+set -e
+
+$GREP_DCTRL ''

-- 
Debian control file query tools



More information about the Dctrl-tools-devel mailing list