[Dctrl-tools-devel] [SCM] Debian control file query tools branch, master, updated. 2.19-9-gb0b6ee7

Antti-Juhani Kaijanaho ajk at debian.org
Sun Nov 27 18:23:00 UTC 2011


The following commit has been merged in the master branch:
commit 2510027ea14a15c7579b89e4c72491da1d69bef8
Author: Antti-Juhani Kaijanaho <ajk at debian.org>
Date:   Sun Nov 13 20:35:35 2011 +0200

    Partially revert fix for #525525 and add a migration path to it
    
    The original fix for #525525 was a cold-turkey change in behavior.
    This caused problems and drew objections.  Here, the idea is to
    revert that change and add a migration path to it.
    
    An option --ensure-dctrl is added, whose states semantics is to ensure that
    the output format is in dctrl format.  It will be ignored if -n is also
    given, as that deliberately asks for non-dctrl output.  In practical terms,
    --ensure-dctrl makes the paragraph separator unconditional, as the cold
    turkey change (in the absence of -n).  The idea is that people who prefer
    the new behaviour can set up shell aliases or other similar mechanisms
    that use --ensure-dctrl by default.
    
    Another option, --compat is added to allow people who dislike the new
    behaviour to make sure that they continue to receive it.  A --compat
    option will countermand any previous --ensure-dctrl.  Thus a user can
    put it in a shell alias, which will then continue to deliver the old
    semantics even after --ensure-dctrl is made default.
    
    The idea is that eventually --ensure-dctrl will become normal behaviour
    and the switch becomes a no-op.
    
    Signed-off-by: Antti-Juhani Kaijanaho <ajk at debian.org>

diff --git a/debian/changelog b/debian/changelog
index 9ea3fdb..b26c4bf 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -2,8 +2,13 @@ dctrl-tools (2.20) UNRELEASED; urgency=low
 
   * Improve the testsuite.
   * tester.sh: Do not output .differr if it wasn't constructed.
+  * grep-dctrl: Make a more modest fix for #525525 in adding an --ensure-dctrl
+    option that makes sure that the output (in the absence of the -n switch)
+    is in dctrl format.
+    - Later on we may want to make --ensure-dctrl the default.  In anticipation,
+      a --compat option has been added that countermands any --ensure-dctrl.
 
- -- Antti-Juhani Kaijanaho <ajk at debian.org>  Sun, 13 Nov 2011 19:33:00 +0200
+ -- Antti-Juhani Kaijanaho <ajk at debian.org>  Sun, 13 Nov 2011 20:24:48 +0200
 
 dctrl-tools (2.19) unstable; urgency=low
 
diff --git a/grep-dctrl/grep-dctrl.c b/grep-dctrl/grep-dctrl.c
index 1526e0a..a7bf6f0 100644
--- a/grep-dctrl/grep-dctrl.c
+++ b/grep-dctrl/grep-dctrl.c
@@ -61,6 +61,8 @@ enum {
         OPT_GE,
         OPT_MMAP,
         OPT_IGN_ERRS,
+        OPT_ENSURE,
+        OPT_COMPAT,
         OPT_PATTERN
 };
 
@@ -142,6 +144,8 @@ static struct argp_option options[] = {
 	{ "ignore-parse-errors", OPT_IGN_ERRS, 0,   0, N_("Ignore parse errors") },
         { "pattern",        OPT_PATTERN, N_("PATTERN"), 0, N_("Specify the pattern to search for") },
 	{ "whole-pkg",	    'w', 0,                 0, N_("Match only whole package names (this implies -e)") },
+        { "ensure-dctrl",   OPT_ENSURE, 0,          0, N_("Ensure that the output is in dctrl format (overridden by -n)") },
+        { "compat",         OPT_COMPAT, 0,          0, N_("Override the effect of an earlier --ensure-dctrl") },
 	{ 0 }
 };
 
@@ -189,6 +193,9 @@ struct arguments {
 	bool quiet;
 	/* Do show field names? */
 	bool show_field_name;
+        /* Ensure that the output is in dctrl format? (Ignored if
+           show_field_name is false.) */
+        bool ensure_dctrl;
 	/* Do show (only) first line of Description? */
 	bool short_descr;
 	/* Does show_fields contain Description? */
@@ -254,6 +261,12 @@ static error_t parse_opt (int key, char * arg, struct argp_state * state)
 	case 'B':
 		banner(false);
 #endif
+        case OPT_ENSURE:
+                args->ensure_dctrl = true;
+                break;
+        case OPT_COMPAT:
+                args->ensure_dctrl = false;
+                break;
 	case 'v':
 		args->invert_match = true;
 		break;
@@ -918,11 +931,10 @@ int main (int argc, char * argv[])
                                                (fa->application_data));
                                         show_field(&args, &para, fa);
                                 }
+                                if ((args.show_field_name &&
+                                     args.ensure_dctrl) ||
+                                    args.num_show_fields > 1) puts("");
                         }
-                        /* let's see how many users howl in pain after
-                           deactivating this conditional (see BTS #525525)
-
-                           if (args.num_show_fields > 1)*/ puts("");
 		}
 
 		fsaf_close(fp);
diff --git a/man/grep-dctrl.1.cp b/man/grep-dctrl.1.cp
index 15a67f8..50bad56 100644
--- a/man/grep-dctrl.1.cp
+++ b/man/grep-dctrl.1.cp
@@ -1,5 +1,5 @@
-.TH GREP-DCTRL 1 2007-10-27 "Debian Project" "Debian user's manual"
-\" Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007
+.TH GREP-DCTRL 1 2011-11-13 "Debian Project" "Debian user's manual"
+\" Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2011
 \"               Antti-Juhani Kaijanaho <gaia at iki.fi>
 \"      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
@@ -273,6 +273,9 @@ names in the argument to this option.  The
 .IR field s
 are shown in the order given here.  See also the option
 .BR \-I .
+Note that in the absence of the
+.B \-\-ensure\--dctrl
+option, if only one field is selected, no paragraph separator is output.
 .IP "\fB\-I\fR, \fB\-\-invert\-show"
 Invert the meaning of option
 .BR \-s :
@@ -326,6 +329,18 @@ match), show the count of those paragraphs.
 Output nothing to the standard output stream.  Instead, exit
 immediately after finding the first match.
 .SS Miscellaneous
+.IP "\fB\-\-ensure\-dctrl"
+Ensure that the output is in dctrl format, specifically that there always
+is an empty line separating paragraphs.  This option is not honored if 
+the 
+.B \-n
+option has been selected, as that option deliberately requests a non-dctrl
+format for the output.  In a future version, this option may be made the
+default behaviour.
+.IP "\fB\-\-compat"
+Override any
+.B \-\-ensure\-dctrl
+option given earlier on the command line.
 .IP "\fB\-\-ignore\-parse\-errors"
 Ignore errors in parsing input.  A paragraph which cannot be parsed
 is ignored in its entirety, and the next paragraph is assumed to start
diff --git a/tests/0006.out b/tests/0006.out
index 8b13789..e69de29 100644
--- a/tests/0006.out
+++ b/tests/0006.out
@@ -1 +0,0 @@
-
diff --git a/tests/bug144174.out b/tests/bug144174.out
index 79d2dde..9638eb6 100644
--- a/tests/bug144174.out
+++ b/tests/bug144174.out
@@ -29,4 +29,3 @@ Provides: grep-dctrl
 Depends: libc6 (>= 2.3.5-1)
 Suggests: apt
 Conflicts: grep-dctrl
-
diff --git a/tests/bug209134.out b/tests/bug209134.out
index 1cb20a2..db12b07 100644
--- a/tests/bug209134.out
+++ b/tests/bug209134.out
@@ -1,2 +1 @@
 FOO: bar
-
diff --git a/tests/bug511022.out b/tests/bug511022.out
index 64edf6a..a09386a 100644
--- a/tests/bug511022.out
+++ b/tests/bug511022.out
@@ -1,2 +1 @@
 gedit
-
diff --git a/tests/bug525525.sh b/tests/bug525525.sh
index a8c1380..8a5054c 100644
--- a/tests/bug525525.sh
+++ b/tests/bug525525.sh
@@ -2,4 +2,4 @@
 
 set -e
 
-$GREP_DCTRL -sDescription '' < 0001.in
+$GREP_DCTRL --ensure-dctrl -sDescription '' < 0001.in

-- 
Debian control file query tools



More information about the Dctrl-tools-devel mailing list