[Dctrl-tools-devel] Bug#476861: dctrl-tools: option to match against package-name boundaries

Stefano Zacchiroli zack at debian.org
Thu Jan 29 10:48:42 UTC 2009

tags 476861 + patch

[ Cc-ing a somehow related bug log ]

On Sat, Apr 19, 2008 at 06:16:35PM +0200, Adeodato Simó wrote:
> Frequently, I find my self wanting to do an exact match for a package
> name contained in a multi-word field, e.g. Depends.

Same here.

> To ensure I'm not matching sub-words, I'm doing something like:
>   % grep-dctrl -F Depends -e '(^| )package([, ]|$)'
> Which is a tad inconvenient. I would like something like:
>   % grep-dctrl --package-word -F Depends package

The attached patch does exactly that. The name of the flag I've chose
is "--whole-pkg", YMMV. Note that in my implementation the flag
implies "-e", because the implementation is actually (extended) regex

More in detail, I just "dress" the given atom(s) with regex boundaries
as yours. It might be seen as hackish, but I find it way better than
adding specific parsing of inter-package relationship
fields. Considering that the use case we are discussing is really
common, I believe it is worth to implement this this way.

I've changed a bit the regular expression boundaries wrt yours, mines

	#define RE_PKG_BEGIN	"(^| )"
	#define RE_PKG_END	"([, \\(]|$)"

with the rationale that whitespaces, according to policy, do not
necessarily appear between package names and optional version
requirements; hence also '(' can denote the end of package name.

A final note about whitespaces, the policy is not entirely clear about
which kind of whitespaces are accepted (or else I've missed it). While
the current implementation rely on real spaces only, it might be worth
to use the '[:space:]' character class instead.

Please consider applying the attached patch.


PS the attached patches (one for the code, one for the manpage) have
   been generated from the Git repo available at:

Stefano Zacchiroli -o- PhD in Computer Science \ PostDoc @ Univ. Paris 7
zack@{upsilon.cc,pps.jussieu.fr,debian.org} -<>- http://upsilon.cc/zack/
Dietro un grande uomo c'è ..|  .  |. Et ne m'en veux pas si je te tutoie
sempre uno zaino ...........| ..: |.... Je dis tu à tous ceux que j'aime
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-add-whole-pkg-to-match-eregex-on-whole-package.patch
Type: text/x-diff
Size: 0 bytes
Desc: not available
Url : http://lists.alioth.debian.org/pipermail/dctrl-tools-devel/attachments/20090129/61ee032c/attachment-0001.patch 

More information about the Dctrl-tools-devel mailing list