Print this page
Add catman, makewhatis functionality.  Print an error if the whatis database
is missing.

*** 157,166 **** --- 157,167 ---- static int makewhatis = 0; static int printmp = 0; static int sargs = 0; static int psoutput = 0; static int whatis = 0; + static int makewhatishere = 0; static char *mansec; static char *pager; static char *addlocale(char *);
*** 189,198 **** --- 190,201 ---- static int searchdir(char *, char *, char *); static void sortdir(DIR *, char ***); static char **split(char *, char); static void usage_man(void); static void usage_whatapro(void); + static void usage_catman(void); + static void usage_makewhatis(void); static void whatapro(struct man_node *, char *); static char language[MAXPATHLEN]; /* LC_MESSAGES */ static char localedir[MAXPATHLEN]; /* locale specific path component */
*** 211,220 **** --- 214,224 ---- static struct man_node *mandirs = NULL; int bmp_flags = 0; int ret = 0; char *opts; char *mwstr; + int catman = 0; (void) setlocale(LC_ALL, ""); (void) strcpy(language, setlocale(LC_MESSAGES, (char *)NULL)); if (strcmp("C", language) != 0) (void) strlcpy(localedir, language, MAXPATHLEN);
*** 229,238 **** --- 233,251 ---- opts = "M:ds:"; } else if (strcmp(__progname, "whatis") == 0) { apropos++; whatis++; opts = "M:ds:"; + } else if (strcmp(__progname, "catman") == 0) { + catman++; + makewhatis++; + opts = "M:w"; + } else if (strcmp(__progname, "makewhatis") == 0) { + makewhatis++; + makewhatishere++; + manpath = "."; + opts = ""; } else { opts = "M:adfklps:tw"; } opterr = 0;
*** 271,280 **** --- 284,297 ---- break; case '?': default: if (apropos) usage_whatapro(); + else if (catman) + usage_catman(); + else if (makewhatishere) + usage_makewhatis(); else usage_man(); } } argc -= optind;
*** 688,699 **** regex_t preg; char **ss = NULL; char s[MAXNAMELEN]; int i; ! if ((fp = fopen(whatpath, "r")) == NULL) return; DPRINTF("-- Found %s: %s\n", WHATIS, whatpath); /* Build keyword regex */ if (asprintf(&pkwd, "%s%s%s", (whatis) ? "\\<" : "", --- 705,718 ---- regex_t preg; char **ss = NULL; char s[MAXNAMELEN]; int i; ! if ((fp = fopen(whatpath, "r")) == NULL) { ! perror(whatpath); return; + } DPRINTF("-- Found %s: %s\n", WHATIS, whatpath); /* Build keyword regex */ if (asprintf(&pkwd, "%s%s%s", (whatis) ? "\\<" : "",
*** 1562,1567 **** --- 1581,1603 ---- (void) fprintf(stderr, gettext( "usage: %s [-M path] [-s section] keyword ...\n"), whatis ? "whatis" : "apropos"); exit(1); + } + + static void + usage_catman(void) + { + (void) fprintf(stderr, gettext( + "usage: catman [-M path] [-w]\n")); + + exit(1); + } + + static void + usage_makewhatis(void) + { + (void) fprintf(stderr, gettext("usage: makewhatis\n")); + + exit(1); }