[Dctrl-tools-devel] [SCM] Debian control file query tools branch, master, updated. 2.20.1-3-g87865ac

Antti-Juhani Kaijanaho ajk at debian.org
Sun Dec 18 19:12:22 UTC 2011


The following commit has been merged in the master branch:
commit 87865acd9c16451eb026db7a9aeec06ca0eba962
Author: Antti-Juhani Kaijanaho <ajk at debian.org>
Date:   Sun Dec 18 21:12:14 2011 +0200

    grep-dctrl: Hardcode default input file names.
    
    Until now, grep-dctrl has used a configuration file to determine which
    input file it should use by default.  Originally, this was motivated by
    a desire not to step too much into the toes of dpkg maintainers - it
    allowed the fiction that this package doesn't in fact depend on dpkg's
    internal interfaces.  Over the last decade, however, this consideration
    has became essentially moot, and the status and available files are
    effectively public interfaces.
    
    Now, theoretically, this configurability could be in use by someone.
    However, the same functionality is available by using shell functions and
    shell scripts.  I twice called for actual use cases for this feature,
    explicitly threatening to remove this feature if nobody stepped up.
    Nobody did.
    
    Signed-off-by: Antti-Juhani Kaijanaho <ajk at debian.org>

diff --git a/GNUmakefile b/GNUmakefile
index 6222866..3a25b8e 100644
--- a/GNUmakefile
+++ b/GNUmakefile
@@ -59,14 +59,11 @@ all-no-mo :	sync-available/sync-available \
 aliases = grep-status grep-available grep-aptavail grep-debtags
 
 install :
-	$(INSTALL_DIR) $(DESTDIR)$(sysconfdir)
 	$(INSTALL_DIR) $(DESTDIR)$(sbindir)
 	$(INSTALL_DIR) $(DESTDIR)$(bindir)
 	$(INSTALL_DIR) $(DESTDIR)$(docdir)
 	$(INSTALL_DIR) $(DESTDIR)$(man1dir)
 	$(INSTALL_DIR) $(DESTDIR)$(man8dir)
-	$(INSTALL_DATA) grep-dctrl/grep-dctrl.rc $(DESTDIR)$(sysconfdir)
-	$(INSTALL_DATA) grep-dctrl/grep-dctrl.rc $(DESTDIR)$(sysconfdir)
 	$(INSTALL_PROGRAM) sync-available/sync-available $(DESTDIR)$(sbindir)
 	$(INSTALL_PROGRAM) join-dctrl/join-dctrl $(DESTDIR)$(bindir)
 	$(INSTALL_PROGRAM) tbl-dctrl/tbl-dctrl $(DESTDIR)$(bindir)
@@ -124,7 +121,7 @@ po : $(foreach f,$(langs),po/$(f).po)
 
 mo : $(foreach f,$(langs),po/$(f).mo)
 
-grep-dctrl/grep-dctrl : grep-dctrl/grep-dctrl.o grep-dctrl/rc.o libdctrl.a
+grep-dctrl/grep-dctrl : grep-dctrl/grep-dctrl.o libdctrl.a
 
 sort-dctrl/sort-dctrl : sort-dctrl/sort-dctrl.o libdctrl.a
 
diff --git a/debian/changelog b/debian/changelog
index 99d69d2..15c9e70 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,8 +1,11 @@
 dctrl-tools (2.21) unstable; urgency=low
 
   * grep-dctrl: Remove the old dead annoying banner code.
+  * grep-dctrl: Hardcode default input file names.
+      - The /etc/grep-dctrl.rc conffile is removed upon package upgrade.
+      - grep-dctrl.1.cp: Updated to match.
 
- -- Antti-Juhani Kaijanaho <ajk at debian.org>  Sun, 18 Dec 2011 20:16:49 +0200
+ -- Antti-Juhani Kaijanaho <ajk at debian.org>  Sun, 18 Dec 2011 21:04:25 +0200
 
 dctrl-tools (2.20.1) unstable; urgency=low
 
diff --git a/debian/copyright b/debian/copyright
index b3b631c..014b05c 100644
--- a/debian/copyright
+++ b/debian/copyright
@@ -5,7 +5,7 @@ Wichert Akkerman, Ian Jackson and Lars Wirzenius.
 Copyright:
 
      Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
-                   2009, 2010
+                   2009, 2010, 2011
                    Antti-Juhani Kaijanaho
   
      This program is free software; you can redistribute it and/or modify
@@ -26,8 +26,7 @@ Copyright:
 In Debian systems, the GNU GPL version 2 is available at
 /usr/share/common-licenses/GPL .
 
-The files getaline.c and fnutil.c are covered by the following
-copyright:
+The file fnutil.c are covered by the following copyright:
 
    Copyright (c) 1994 Lars Wirzenius.  All rights reserved.
    Copyright (C) 2004 Antti-Juhani Kaijanaho.  All rights reserved.
diff --git a/debian/dctrl-tools.postinst b/debian/dctrl-tools.postinst
new file mode 100644
index 0000000..cc2ef25
--- /dev/null
+++ b/debian/dctrl-tools.postinst
@@ -0,0 +1,8 @@
+#!/bin/sh
+
+set -e
+
+dpkg-maintscript-helper rm_conffile \
+    /etc/grep-dctrl.rc 2.20.1 dctrl-tools -- "$@"
+
+#DEBHELPER#
\ No newline at end of file
diff --git a/debian/dctrl-tools.postrm b/debian/dctrl-tools.postrm
new file mode 100644
index 0000000..ce09c5e
--- /dev/null
+++ b/debian/dctrl-tools.postrm
@@ -0,0 +1,8 @@
+#!/bin/sh
+
+set -e
+
+dpkg-maintscript-helper rm_conffile \
+    /etc/grep-dctrl.rc 2.20.1 dctrl-tools -- "$@"
+
+#DEBHELPER#
diff --git a/debian/dctrl-tools.preinst b/debian/dctrl-tools.preinst
new file mode 100644
index 0000000..ce09c5e
--- /dev/null
+++ b/debian/dctrl-tools.preinst
@@ -0,0 +1,8 @@
+#!/bin/sh
+
+set -e
+
+dpkg-maintscript-helper rm_conffile \
+    /etc/grep-dctrl.rc 2.20.1 dctrl-tools -- "$@"
+
+#DEBHELPER#
diff --git a/grep-dctrl/grep-dctrl.c b/grep-dctrl/grep-dctrl.c
index 9667847..66a0828 100644
--- a/grep-dctrl/grep-dctrl.c
+++ b/grep-dctrl/grep-dctrl.c
@@ -33,11 +33,11 @@
 #include "fnutil.h"
 #include "fsaf.h"
 #include "i18n.h"
+#include "ifile.h"
 #include "misc.h"
 #include "msg.h"
 #include "paragraph.h"
 #include "predicate.h"
-#include "rc.h"
 #include "util.h"
 
 const char * argp_program_version = "grep-dctrl (dctrl-tools) " VERSION;
@@ -51,8 +51,7 @@ static char progdoc [] = N_("grep-dctrl -- grep Debian control files");
 static char argsdoc [] = N_("FILTER [FILENAME...]");
 
 enum {
-        OPT_CONFIG=256,
-        OPT_OPTPARSE,
+        OPT_OPTPARSE=256,
         OPT_SILENT,
         OPT_EQ,
         OPT_LT,
@@ -80,7 +79,6 @@ static struct argp_option options[] = {
 	{ "invert-match",   'v', 0,		    0, N_("Show only paragraphs that do not match.") },
         { "invert-show",    'I', 0,                 0, N_("Show those fields that have NOT been selected with -s") },
 	{ "count",	    'c', 0,		    0, N_("Show only the count of matching paragraphs.") },
-	{ "config-file",    OPT_CONFIG, N_("FNAME"),0, N_("Use FNAME as the config file.") },
 	{ "exact-match",    'X', 0,		    0, N_("Do an exact match.") },
 	{ "copying",	    'C', 0,		    0, N_("Print out the copyright license.") },
 	{ "and",	    'a', 0,		    0, N_("Conjunct filters.") },
@@ -139,8 +137,6 @@ struct arguments {
 	size_t num_show_fields;
 	/* A machine-readable representation of the predicate.  */
 	struct predicate * p;
-	/* Configuration file name */
-	char const * rcname;
 	/* Ignore parse errors? */
 	bool ignore_errors;
 	/* Quiet operation? */
@@ -397,10 +393,6 @@ static error_t parse_opt (int key, char * arg, struct argp_state * state)
 	case ARGP_KEY_ERROR: case ARGP_KEY_FINI: case ARGP_KEY_NO_ARGS:
 		debug_message("parse_opt: ignored", 0);
 		break;
-	case OPT_CONFIG:
-		debug_message("parse_opt: --config-file", 0);
-		args->rcname = strdup(arg);
-		break;
 	default:
 		return ARGP_ERR_UNKNOWN;
 	}
@@ -808,14 +800,31 @@ int main (int argc, char * argv[])
 		int fd;
 		struct ifile fname;
 		if (args.num_fnames == 0) {
-			// Hardcode grep-dctrl <-> "-" mapping so that
-			// Debian packages can genuinely depend on it.
 			char * argv0 = fnbase(argv[0]);
 			if (strcmp(argv0, "grep-dctrl") == 0) {
 				fname = (struct ifile){ .mode = m_read,
 							.s = "-" };
+                        } else if (strcmp(argv0, "grep-status") == 0) {
+                                fname = (struct ifile){
+                                        .mode = m_read,
+                                        .s = "/var/lib/dpkg/status" };
+                        } else if (strcmp(argv0, "grep-available") == 0) {
+                                fname = (struct ifile){
+                                        .mode = m_read,
+                                        .s = "/var/lib/dpkg/available" };
+                        } else if (strcmp(argv0, "grep-aptavail") == 0) {
+                                fname = (struct ifile){
+                                        .mode = m_exec,
+                                        .s = "apt-cache dumpavail" };
+                        } else if (strcmp(argv0, "grep-debtags") == 0) {
+                                fname = (struct ifile){
+                                        .mode = m_exec,
+                                        .s = "debtags dumpavail" };
 			} else {
-				fname = find_ifile_by_exename(argv0, args.rcname);
+                                message(L_FATAL, 0,
+                                        _("executable name '%s' is not recognised"),
+                                        argv0);
+                                fail();
 			}
 		} else {
 			fname = args.fname[i];
diff --git a/grep-dctrl/grep-dctrl.rc b/grep-dctrl/grep-dctrl.rc
deleted file mode 100644
index bc93e31..0000000
--- a/grep-dctrl/grep-dctrl.rc
+++ /dev/null
@@ -1,29 +0,0 @@
-# Configuration for grep-dctrl.  The config line format is
-# line-oriented.  Each line defines one executable name - default
-# input file pair; the elements of the pair are in order and separated
-# by whitespace.  The hash '#' begins a comment that lasts to the end
-# of line.  Empty lines are ignored.
-
-# There is some magic in the  default input file name field.
-# If it starts with
-#  @exec, the rest of the name is given to /bin/sh -c and its stdout is 
-#         used as input, if no explicit file name is given on the command
-#         line
-# A double @ at the start of the field denotes a single @ in the actual 
-# name.
-
-# Template:
-#   <executable name>   <default input file name>
-
-# The following line used to be required, but it is now hardcoded.
-# grep-dctrl      -
-
-# The following two pairs define common aliases for grep-dctrl.
-grep-status     /var/lib/dpkg/status
-grep-available  /var/lib/dpkg/available
-
-# A new feature: grepping apt's available information
-grep-aptavail	@exec apt-cache dumpavail
-
-# A new feature: grepping debtags' information
-grep-debtags    @exec debtags dumpavail
diff --git a/grep-dctrl/rc.c b/grep-dctrl/rc.c
deleted file mode 100644
index fb4b88b..0000000
--- a/grep-dctrl/rc.c
+++ /dev/null
@@ -1,197 +0,0 @@
-/*   grep-dctrl - grep Debian control files
-     Copyright © 1999, 2003, 2004, 2008  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
-     the Free Software Foundation; either version 2 of the License, or
-     (at your option) any later version.
-
-     This program is distributed in the hope that it will be useful,
-     but WITHOUT ANY WARRANTY; without even the implied warranty of
-     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-     GNU General Public License for more details.
-
-     You should have received a copy of the GNU General Public License along
-     with this program; if not, write to the Free Software Foundation, Inc.,
-     51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-
-*/
-
-#include <assert.h>
-#include <errno.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <unistd.h>
-#include "msg.h"
-#include "fnutil.h"
-#include "getaline.h"
-#include "rc.h"
-#include "strutil.h"
-#include "util.h"
-
-char const * const ifile_modes[] = { [m_error] = "m_error",
-				     [m_read]  = "m_read",
-				     [m_exec]  = "m_exec" };
-
-static struct ifile parse(char * s)
-{
-	assert(s != 0);
-	s = (char*)left_trimmed(s);
-	trim_right(s);
-	if (*s == 0) return (struct ifile) { .mode = m_read, .s = "-" };
-	static const char at_exec[] = "@exec ";
-	if (s[0] != '@') return (struct ifile){ .mode = m_read, .s = s };
-	assert(s[0] == '@');
-	if (s[1] == '@') return (struct ifile){ .mode = m_read, .s = s+1 };
-	if (strncmp(s, at_exec, sizeof at_exec - 1) == 0) {
-		return (struct ifile){ .mode = m_exec,
-				       .s = s + sizeof at_exec - 1 };
-	}
-	debug_message(s, 0);
-	message(L_IMPORTANT, _("Malformed default input file name"), 0);
-	return (struct ifile){ .mode = m_error, .s = 0 };
-}
-
-static bool perms_ok(char const * fname, int fd)
-{
-	struct stat stat;
-	int r = fstat(fd, &stat);
-	if (r == -1) {
-		errno_msg(L_IMPORTANT, fname);
-		return false;
-	}
-	if (stat.st_uid != 0 && stat.st_uid != getuid()) {
-		message(L_IMPORTANT, fname,
-			_("not owned by you or root, ignoring"));
-		return false;
-	}
-	if ((stat.st_mode & (S_IWGRP | S_IWOTH)) != 0) {
-		message(L_IMPORTANT, fname,
-			_("write permissions for "
-			  "group or others, ignoring"));
-		return false;
-	}
-	return true;
-}
-
-struct ifile find_ifile_by_exename(const char * exename, const char * rcfname)
-{
-	static const char * default_rcfiles [] = {
-		/* Order is significant: earlier files override later ones. */
-		"~/.grep-dctrlrc",
-		SYSCONF "/grep-dctrl.rc",
-		0 };
-	int i;
-	char * fname;
-	int lineno;
-	FILE * f;
-
-	assert(exename != 0);
-
-	if (rcfname == 0) {
-		struct ifile rv = { .mode = m_error, .s = 0 };
-		for (i = 0;
-		     rv.mode == m_error && default_rcfiles [i] != 0;
-		     i++) {
-			rv = find_ifile_by_exename(exename, default_rcfiles [i]);
-		}
-		return rv;
-	}
-
-	assert(rcfname != 0);
-
-	fname = fnqualify(rcfname);
-	if (fname == 0) {
-		errno_msg(L_IMPORTANT, rcfname);
-		return (struct ifile){ .mode = m_error, .s = 0 };
-	}
-
-	message(L_INFORMATIONAL, fname, _("reading config file"));
-
-	f = fopen(fname, "r");
-	if (f == 0) {
-		message(L_INFORMATIONAL, fname, "%s", strerror(errno));
-		return (struct ifile){ .mode = m_error, .s = 0 };
-	}
-
-	// check permissions
-	if (!perms_ok(fname, fileno(f))) {
-		return (struct ifile){ .mode = m_error, .s = 0 };
-	}
-
-	lineno = 0;
-	char * rv = 0;
-	while (1) {
-		static char * line = 0;
-		char * line_exe;
-		char * line_ifile;
-
-		/* If this is not the first call, line may be non-null
-		   and must be freed.  It must be freed on all
-		   non-first iterations, too. */
-		free(line);
-
-		line = getaline (f);
-		if (line == 0) {
-			message(L_FATAL, fname,
-				_("read failure or out of memory"));
-			fail();
-		}
-
-		++lineno;
-
-		if (*line == 0) {
-			rv = 0;
-			break;
-		}
-
-		chop_comment(line, '#');
-		chomp(line);
-
-		if (left_trimmed(line) [0] == 0) {
-			continue;
-		}
-
-		line_exe = strtok(line, " \t");
-		if (line_exe == 0) {
-			line_message(L_IMPORTANT, fname, lineno,
-				     _("syntax error: need an executable name")
-                                );
-			continue;
-		}
-
-		line_ifile = strtok(0, "\n\t");
-		if (line_ifile == 0) {
-			line_message(L_IMPORTANT, fname, lineno,
-				     _("syntax error: need an input file name")
-                                );
-			continue;
-		}
-
-		message(L_INFORMATIONAL, line_exe, 
-                        _("considering executable name"));
-		if (strcmp (exename, line_exe) == 0) {
-			message(L_INFORMATIONAL, line_exe,
-                                _("yes, will use executable name"));
-			rv = line_ifile;
-			message(L_INFORMATIONAL, rv, _("default input file"));
-			break;
-		}
-	}
-
-	fclose(f);
-	free(fname);
-
-	if (rv != 0) {
-		return parse(rv);
-	} else {
-		message(L_IMPORTANT, 0,
-                        _("executable name not found; "
-                          "reading from standard input"));
-		return (struct ifile) { .mode = m_read, .s = "-" };
-	}
-}
-
diff --git a/grep-dctrl/rc.h b/grep-dctrl/rc.h
deleted file mode 100644
index 4931c47..0000000
--- a/grep-dctrl/rc.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/*  dctrl-tools - Debian control file inspection tools
-    Copyright © 1999, 2003 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
-    the Free Software Foundation; either version 2 of the License, or
-    (at your option) any later version.
-
-    This program is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License along
-    with this program; if not, write to the Free Software Foundation, Inc.,
-    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#ifndef RC_H__
-#define RC_H__
-
-#include "ifile.h"
-
-extern char const * const ifile_modes[];
-
-/* Search for exename (only basename, though) in rcfname (or if it is
-   null, in default rc files) and return the found corresponding
-   default input file name.  The mode will be m_error, if not found or
-   other error occurred, m_read, if it is intended to be interpreted
-   as a file name, and m_exec, if the string is to be interpreted as a
-   shell command whose stdout should be used.  The returned pointer
-   will be invalidated by the next call to this function.  */
-struct ifile
-find_ifile_by_exename (const char * exename, const char * rcfname);
-
-#endif
diff --git a/lib/getaline.c b/lib/getaline.c
deleted file mode 100644
index 9bf4f96..0000000
--- a/lib/getaline.c
+++ /dev/null
@@ -1,113 +0,0 @@
-/* getaline.c -- read arbitrarily long line from file
-   (Originally from Lars Wirzenius' publib.)
-
-   Copyright © 1994 Lars Wirzenius.  All rights reserved.
-   Copyright © 2004 Antti-Juhani Kaijanaho.  All rights reserved.
-
-   Redistribution and use in source and binary forms, with or without
-   modification, are permitted provided that the following conditions
-   are met:
-
-   1. Redistributions of source code must retain the above copyright
-      notice, this list of conditions and the following disclaimer.
-
-   2. Redistributions in binary form must reproduce the above
-      copyright notice, this list of conditions and the following
-      disclaimer in the documentation and/or other materials provided
-      with the distribution.
-
-   THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
-   OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-   WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-   ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
-   DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-   DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
-   GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-   INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-   WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-   NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-   SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include "getaline.h"
-
-// NULL indicates error, EOF is indicated by a string of length zero
-char * getaline (FILE * f)
-{
-	char *buf;			/* buffer for line */
-	size_t size;			/* size of buffer */
-	size_t inc;			/* how much to enlarge buffer */
-	size_t len;			/* # of chars  stored into buf
-                                             before '\0' */
-	char *p;
-	const size_t thres = 128;	/* initial buffer size (most
-					   lines should fit into this
-					   size, so think of this as
-					   the "long line
-					   threshold").  */
-	const size_t mucho = 128;	/* if there is at least this
-					   much wasted space when the
-					   whole buffer has been read,
-					   try to reclaim it.  Don't
-					   make this too small, else
-					   there is too much time
-					   wasted trying to reclaim a
-					   couple of bytes.  */
-	const size_t mininc = 64;	/* minimum number of bytes by
-					   which to increase the
-					   allocated memory */
-
-	len = 0;
-	size = thres;
-	buf = malloc (size);
-	if (buf == NULL) return NULL;
-
-	buf[0] = '\0';
-
-	while (fgets (buf + len, size - len, f) != NULL) {
-		len += strlen(buf + len);
-		if (len > 0 && buf[len - 1] == '\n')
-			break;			/* the whole line has
-						   been read */
-
-		for (inc = size, p = NULL; inc > mininc; inc /= 2)
-			if ((p = realloc (buf, size + inc)) != NULL)
-				break;
-
-		if (p == NULL) {
-			free (buf);
-			return NULL;		/* couldn't get more memory */
-		}
-
-		size += inc;
-		buf = p;
-	}
-
-	if (len == 0 && ferror(f)) {
-		free (buf);
-		return NULL;		/* nothing read (eof or error) */
-	}
-
-#if 0
-	if (buf[len - 1] == '\n')	/* remove newline, if there */
-		buf[--len] = '\0';
-#else
-	buf[len] = '\0';
-#endif
-
-	if (size - len > mucho)	{ /* a plenitude of unused memory? */
-		p = realloc (buf, len + 1);
-
-		if (p != NULL) {
-			buf = p;
-			size = len + 1;
-		}
-	}
-
-	return buf;
-}
-
diff --git a/lib/getaline.h b/lib/getaline.h
deleted file mode 100644
index 4e692f9..0000000
--- a/lib/getaline.h
+++ /dev/null
@@ -1,26 +0,0 @@
-/*  dctrl-tools - Debian control file inspection tools
-    Copyright © 2004 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
-    the Free Software Foundation; either version 2 of the License, or
-    (at your option) any later version.
-
-    This program is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License along
-    with this program; if not, write to the Free Software Foundation, Inc.,
-    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#ifndef GETALINE_H
-#define GETALINE_H
-
-#include <stdio.h>
-
-char * getaline (FILE * f);
-
-#endif /* GETALINE_H */
diff --git a/lib/ifile.c b/lib/ifile.c
index 50c6222..2ce8a86 100644
--- a/lib/ifile.c
+++ b/lib/ifile.c
@@ -1,5 +1,5 @@
 /*  dctrl-tools - Debian control file inspection tools
-    Copyright © 2004 Antti-Juhani Kaijanaho
+    Copyright © 2004, 2011 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
@@ -24,6 +24,10 @@
 #include "ifile.h"
 #include "msg.h"
 
+char const * const ifile_modes[] = { [m_error] = "m_error",
+                                     [m_read]  = "m_read",
+                                     [m_exec]  = "m_exec" };
+
 static int open_pipe(char const * s)
 {
 	int ps[2];
diff --git a/lib/ifile.h b/lib/ifile.h
index 042bd8c..fa92ae8 100644
--- a/lib/ifile.h
+++ b/lib/ifile.h
@@ -1,5 +1,5 @@
 /*  dctrl-tools - Debian control file inspection tools
-    Copyright © 2004 Antti-Juhani Kaijanaho
+    Copyright © 2004, 2011 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
@@ -26,6 +26,8 @@ struct ifile {
 	char const * s;
 };
 
+extern char const * const ifile_modes[];
+
 // returns fd
 int open_ifile(struct ifile f);
 
diff --git a/man/grep-dctrl.1.cp b/man/grep-dctrl.1.cp
index 40e6291..40279f1 100644
--- a/man/grep-dctrl.1.cp
+++ b/man/grep-dctrl.1.cp
@@ -1,4 +1,4 @@
-.TH GREP-DCTRL 1 2011-11-13 "Debian Project" "Debian user's manual"
+.TH GREP-DCTRL 1 2011-12-18 "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
@@ -53,7 +53,7 @@ and
 .B grep\-debtags
 are aliases of (actually, symbolic links to)
 .BR grep\-dctrl .
-In the shipped configuration, these aliases use as their default input
+These aliases use as their default input
 the
 .BR dpkg (1)
 .I available
@@ -120,36 +120,24 @@ After the
 .I filter
 expression comes zero or more 
 .I file
-names.  If no 
-.I file
-names
-are specified, the 
-.I file
-name is searched in configuration files.  The
-input
-.I file
-in association with
-the correct program name is used.  The program names are matched with
-the base form of the name of the current program (the 0'th command
-line argument, if you will).  The 
+names.  The 
 .I file
 name
 .B \-
-is taken to mean the
-standard input stream.  The 
+is taken to mean the standard input stream.  The
 .IR file s
-are searched in order but
-separately; they are
+are searched in order but separately; they are
 .B not
 concatenated together.  In other words, the end of a 
 .I file
-always
-implies the end of the current paragraph.
+always implies the end of the current paragraph.
 .PP
-There is one exception to the above: if the program name is
-.BR grep\-dctrl ,
-the default input source is always standard input; this cannot be
-overridden by the configuration file.
+If no
+.I file
+names are specified, the program name is used to identify a default
+input file.  The program names are matched with the base form of the
+name of the current program (the 0'th command line argument, if you
+will).
 .SH OPTIONS
 .SS Specifying the search pattern
 .IP "\fB\-\-pattern=\fIpattern"
@@ -345,10 +333,6 @@ option given earlier on the command line.
 Ignore errors in parsing input.  A paragraph which cannot be parsed
 is ignored in its entirety, and the next paragraph is assumed to start
 after the first newline since the location of the error.
-.IP "\fB\-\-config\-file=\fIfilename"
-Use
-.I filename
-as the config file instead of the defaults.
 .IP "\fB\-\-debug\-optparse"
 Show how the current command line has been parsed. 
 .IP "\fB\-l \fIlevel\fR, \fB\-\-errorlevel=\fIlevel"
@@ -373,9 +357,6 @@ to redirect or pipe it somewhere (such as your favourite pager).
 .IP "\fB\-h\fR, \fB\-\-help"
 Print out a help summary.
 .SH EXAMPLES
-The following example queries assume that the default configuration is
-in effect.
-.PP
 The almost simplest use of this program is to print out the status or
 available record of a package.  In this respect,
 .B grep\-dctrl
@@ -590,14 +571,6 @@ filter.
 The argument to
 .B \-l
 was invalid.
-.IP "\fBread failure or out of memory"
-There was a problem reading the configuration file.  Maybe there was a
-transput error; maybe memory was exhausted.  This error may be
-transient, that is, if you try again, all may go well.
-.IP "\fBsyntax error: need a executable name"
-There is a problem in the configuration file.  Look, and you shall find it.
-.IP "\fBsyntax error: need an input file name"
-There is a problem in the configuration file.  Look, and you shall find it.
 .IP "\fBtoo many file names"
 The number of file names specified in the command line exceeded a
 compile-time limit.
@@ -609,59 +582,13 @@ limited to 256.
 .IP "\fBunexpected ')' in command line"
 There was no opening parenthesis that would match some closing
 parenthesis in the command line.
-.SH COMPATIBILITY
-If you use
-.B grep\-dctrl
-in a Debian package, it should depend on the
-.B dctrl\-tools
-package and heed the following compatibility notes:
-.PP
-.IP "Always call only the \fBgrep\-dctrl\fR executable"
-Although the \fBgrep\-status\fR and \fBgrep\-available\fR symlinks are installed
-by default, this may change in the future.  Those symlinks are meant
-for manual and not scripted use.
-.IP "Always specify an explicit file name"
-Don't rely on the implicit file name feature.  The system
-administrator may have changed the default file name.  You should
-always specify the 
-.B \-
-file, too.
-.IP "Not all features have been with us in every version"
-Check if any of the features you use is mentioned in the changelog.
-Use a versioned dependency on
-.BR dctrl\-tools ,
-if it is necessary.
 .SH FILES
-.IP \fISYSCONF/grep\-dctrl.rc
-See the next file.
-.IP \fI~/.grep\-dctrlrc
-These files are the default configuration files for
-.BR grep\-dctrl .
-The format is line-based, with
-.RB ` # '
-introducing a comment that lasts to
-the end of the line.  Each line defines one association between a
-program name and a default input file.  These two things are listed in
-the line in order, separated by whitespace.  Empty lines are ignored.
-.sp
-If the default input file name starts with two at
-.RB ( @ )
-signs, one of
-them is ignored.  This allows specifying a file name that starts with
-an at sign.  If it starts with the string 
-.BR @exec ,
-the rest of the
-name is interpreted as a command name that is fed to 
-.BR /bin/sh " " \-c ,
-and the standard output stream is used as the default input.
 .IP \fI/var/lib/dpkg/available
 The default input file of
-.B grep\-available
-when the shipped configuration is in effect.
+.BR grep\-available .
 .IP \fI/var/lib/dpkg/status
 The default input file of
-.B grep\-status
-when the shipped configuration is in effect.
+.BR grep\-status .
 .SH AUTHOR
 The program and this manual page were written by Antti-Juhani
 Kaijanaho 

-- 
Debian control file query tools



More information about the Dctrl-tools-devel mailing list