[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Man-db-devel] [PATCH 2/2] man(1): add NAME..[.[.]] names
From: |
Mihail Konev |
Subject: |
[Man-db-devel] [PATCH 2/2] man(1): add NAME..[.[.]] names |
Date: |
Mon, 3 Oct 2016 20:50:11 +0000 |
`man chmod..` is now the same as `man -f chmod`
`man chmod...` is now the same as `man -k chmod`
`man chmod....` is now the same as `man -K chmod`
TODO: update manpages
TODO: check for incompatible command-line args
---
src/man.c | 37 +++++++++++++++++++++++++++++++++++++
1 file changed, 37 insertions(+)
diff --git a/src/man.c b/src/man.c
index e7b76d66063a..d556b99fa281 100644
--- a/src/man.c
+++ b/src/man.c
@@ -3973,6 +3973,41 @@ static const char **get_section_list (void)
}
}
+void dots_scan(int argc, char *argv[]) {
+ int i;
+ int maxdots;
+
+ maxdots = 0;
+ for (i = 0; i < argc; i++) {
+ char *arg;
+ int l;
+ int dots;
+
+ arg = argv[i];
+ l = strlen(arg);
+ dots = 0;
+ while (l > 0) {
+ if (arg[l-1] != '.')
+ break;
+ dots++;
+ l--;
+ }
+ if (dots >= 2)
+ arg[l] = 0;
+ if (dots > maxdots)
+ maxdots = dots;
+ }
+
+ if (maxdots >= 4) {
+ global_apropos = 1;
+ print_where = 1;
+ } else if (maxdots >= 3) {
+ external = APROPOS;
+ } else if (maxdots >= 2) {
+ external = WHATIS;
+ }
+}
+
int main (int argc, char *argv[])
{
int argc_env, exit_status = OK;
@@ -4035,6 +4070,8 @@ int main (int argc, char *argv[])
read_config_file (local_man_file || user_config_file);
+ dots_scan(argc, argv);
+
/* if the user wants whatis or apropos, give it to them... */
if (external)
do_extern (argc, argv);
--
2.9.2