tags 461319 fixed-upstream
thanks
On Fri, Jan 18, 2008 at 06:04:25AM +0800, [email protected] wrote:
> C> how about man -a --regex <regexp>
> OK, you are the pros. Whatever you finally come up with. Thanks.
I spent quite a while trying to get this interface to feel right, and in
the end decided that I'd rather have --regex imply -a. I did have to
wrestle a bit to get something reasonably clean that offered both
whatis-like and apropos-like modes of operation, though. In the end I
decided to take a leaf out of apt-cache's book and provide a
--names-only option.
Excerpted documentation follows, along with the changelog entry.
--regex
Show all pages with any part of either their names or
their descriptions matching each page argument as a reg-
ular expression, as with apropos(1). Since there is
usually no reasonable way to pick a "best" page when
searching for a regular expression, this option implies
-a.
--wildcard
Show all pages with any part of either their names or
their descriptions matching each page argument using
shell-style wildcards, as with apropos(1) --wildcard.
The page argument must match the entire name or descrip-
tion, or match on word boundaries in the description.
Since there is usually no reasonable way to pick a
"best" page when searching for a wildcard, this option
implies -a.
--names-only
If the --regex or --wildcard option is used, match only
page names, not page descriptions, as with whatis(1).
Otherwise, no effect.
Thu Dec 25 22:09:01 GMT 2008 Colin Watson <[email protected]>
Add regular expression and shell wildcard search facilities to man
(Debian bug #461319).
* src/whatis.c (lower): Move to ...
* lib/lower.c: ... here, with optimisation from name_to_key. New
file.
* lib/lower.h: New file.
* src/whatis.c (word_fnmatch): Move to ...
* lib/wordfnmatch.c: ... here, with more generic argument names. New
file.
* lib/wordfnmatch.h: New file.
* src/whatis.c (main): Factor regcomp error handling out to ...
* lib/xregcomp.c: ... here. New file.
* lib/xregcomp.h: New file.
* lib/Makefile.am (libman_a_SOURCES): Add lower.c, lower.h,
wordfnmatch.c, wordfnmatch.h, xregcomp.c, and xregcomp.h.
* po/POTFILES.in: Add lib/xregcomp.c; remove src/globbing.c.
* libdb/db_lookup.c (name_to_key): Use lower.
(dblookup_pattern): New function.
* libdb/db_storage.h (dblookup_pattern): Add prototype.
* src/globbing.c (end_pattern): Rename to ...
(make_pattern): ... this. Create the whole pattern rather than
merely appending section or extension components. Handle regexes
if the new opts argument has the LFF_REGEX bit set.
(match_in_directory): Take an opts disjunction rather than a
boolean ignore_case argument; ignore_case is replaced by the
LFF_MATCHCASE bit being unset. Handle regexes if opts has the
LFF_REGEX bit set.
(look_for_file): Take an opts disjunction rather than a boolean
match_case argument; match_case is replaced by the LFF_MATCHCASE
bit being set. Handle regexes if opts has the LFF_REGEX bit set.
Handle shell wildcards if opts has the LFF_WILDCARD bit set (which
simply means not shell-escaping unesc_name). Call make_pattern
rather than end_pattern (with appropriate adjustments).
* src/globbing.h (enum look_for_file_opts): New enumeration.
(look_for_file): Update prototype.
* src/globbing_test.c (options, parse_opt): Accept -r/--regex and
-w/--wildcard.
(main): Update look_for_file arguments, including passing
LFF_REGEX or LFF_WILDCARD if the corresponding options are used.
* src/check_mandirs.c (purge_whatis, purge_missing), src/zsoelim.l
(zsoelim_open_file): Update look_for_file arguments.
* src/whatis.c (main): Only free preg if a regular expression was
compiled into it in the first place.
* src/man.c (options, parse_opt): Accept --regex, --wildcard, and
--names-only. Reset corresponding variables with -D. Refuse to
accept both --regex and --wildcard.
(try_section): Update look_for_file arguments, including passing
LFF_REGEX or LFF_WILDCARD if the corresponding options are used.
(try_db): Use dblookup_pattern if --regex or --wildcard is used,
with corresponding options.
* man/man1/man.man1 (SYNOPSIS, Finding manual pages): Document
--regex, --wildcard, and --names-only.
Thanks for the idea,
--
Colin Watson [[email protected]]
--
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]