[Dctrl-tools-devel] [PATCH] grep-dctrl/grep-dctrl.c: don't display a field with an empty value

Jon Bernard jbernard at debian.org
Mon Dec 10 02:19:00 UTC 2007


Reported by Dan Jacobson <jidanni at jidanni.org>

Signed-off-by: Jon Bernard <jbernard at debian.org>
---
 debian/changelog        |    9 +++++++++
 grep-dctrl/grep-dctrl.c |   13 ++++++++++---
 tests/0006.out          |    1 -
 3 files changed, 19 insertions(+), 4 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index 079480f..4d43343 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,12 @@
+dctrl-tools (2.14) UNRELEASED; urgency=low
+
+  * grep-dctrl/grep-dctrl.c: don't display a field with an empty value,
+    closes: #264907
+  * tests/0006.out: remove "Version: ", no output is expected with the above
+    change.
+
+ -- Jon Bernard <jbernard at debian.org>  Fri, 07 Dec 2007 10:55:13 -0500
+
 dctrl-tools (2.13) UNRELEASED; urgency=low
 
   * debian/control: suggest debtags, note grep-debtags in description
diff --git a/grep-dctrl/grep-dctrl.c b/grep-dctrl/grep-dctrl.c
index 98ecc87..3f6a81f 100644
--- a/grep-dctrl/grep-dctrl.c
+++ b/grep-dctrl/grep-dctrl.c
@@ -751,9 +751,6 @@ static void show_field(struct arguments *args,
                        struct paragraph *para,
                        struct field_attr *fa)
 {
-        if (args->show_field_name) {
-                printf("%s: ", fa->name);
-        }
         struct fsaf_read_rv r 
                 = get_field(para, 
                             fa->inx,
@@ -764,6 +761,16 @@ static void show_field(struct arguments *args,
                 char * nl = memchr(r.b, '\n', r.len);
                 if (nl != 0) r.len = nl - r.b;
         }
+
+        if (r.len == 0) {
+                /* don't display a field with an empty value */
+                return;
+        }
+
+        if (args->show_field_name) {
+                printf("%s: ", fa->name);
+        }
+
         fwrite(r.b, 1, r.len, stdout);
         puts("");
 }
diff --git a/tests/0006.out b/tests/0006.out
index 988cac6..e69de29 100644
--- a/tests/0006.out
+++ b/tests/0006.out
@@ -1 +0,0 @@
-Version: 
-- 
1.5.3.7




More information about the Dctrl-tools-devel mailing list