Print this page
-T on the wrong command!
Latest round of fixes per RM and AL.  Fix bugs found in man.c.

*** 21,30 **** --- 21,31 ---- /* * Copyright (c) 1990, 2010, Oracle and/or its affiliates. All rights reserved. * Copyright 2012, Josef 'Jeff' Sipek <jeffpc@31bits.net>. All rights reserved. * Copyright 2013 Nexenta Systems, Inc. All rights reserved. + * Copyright 2014 Garrett D'Amore <garrett@damore.org> */ /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T. */ /* All rights reserved. */
*** 80,90 **** { "3r", "3rt" }, { "3s", "3c" }, { "3t", "3thr" }, { "3x", "3curses" }, { "3xc", "3xcurses" }, ! { "3xn", "3xnet" } }; struct suffix { char *ds; char *fs; --- 81,92 ---- { "3r", "3rt" }, { "3s", "3c" }, { "3t", "3thr" }, { "3x", "3curses" }, { "3xc", "3xcurses" }, ! { "3xn", "3xnet" }, ! { NULL, NULL } }; struct suffix { char *ds; char *fs;
*** 156,170 **** static int list = 0; 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 *); static struct man_node *build_manpath(char **, int); static void do_makewhatis(struct man_node *); static char *check_config(char *); --- 158,173 ---- static int list = 0; static int makewhatis = 0; static int printmp = 0; static int sargs = 0; static int psoutput = 0; + static int lintout = 0; static int whatis = 0; static int makewhatishere = 0; static char *mansec; ! static char *pager = NULL; static char *addlocale(char *); static struct man_node *build_manpath(char **, int); static void do_makewhatis(struct man_node *); static char *check_config(char *);
*** 236,254 **** 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; while ((c = getopt(argc, argv, opts)) != -1) { switch (c) { case 'M': /* Respecify path for man pages */ --- 239,261 ---- whatis++; opts = "M:ds:"; } else if (strcmp(__progname, "catman") == 0) { catman++; makewhatis++; ! opts = "P:M:w"; } else if (strcmp(__progname, "makewhatis") == 0) { makewhatis++; makewhatishere++; manpath = "."; opts = ""; } else { ! opts = "FM:P:T:adfklprs:tw"; ! if (argc > 1 && strcmp(argv[1], "-") == 0) { ! pager = "cat"; ! optind++; } + } opterr = 0; while ((c = getopt(argc, argv, opts)) != -1) { switch (c) { case 'M': /* Respecify path for man pages */
*** 266,286 **** case 'k': apropos++; break; case 'l': list++; ! /*FALLTHROUGH*/ case 'p': printmp++; break; case 's': mansec = optarg; sargs++; break; case 't': psoutput++; break; case 'w': makewhatis++; break; case '?': default: --- 273,302 ---- case 'k': apropos++; break; case 'l': list++; ! all++; ! break; case 'p': printmp++; break; case 's': mansec = optarg; sargs++; break; + case 'r': + lintout++; + break; case 't': psoutput++; break; + case 'T': + case 'P': + case 'F': + /* legacy options, compatibility only and ignored */ + break; case 'w': makewhatis++; break; case '?': default:
*** 349,360 **** --- 365,378 ---- } if (manwidth != 0) { DPRINTF("-- Using non-standard page width: %d\n", manwidth); } + if (pager == NULL) { if ((pager = getenv("PAGER")) == NULL || *pager == '\0') pager = PAGER; + } DPRINTF("-- Using pager: %s\n", pager); for (i = 0; i < argc; i++) { char *cmd; static struct man_node *mp;
*** 1144,1168 **** */ static char * map_section(char *section, char *path) { int i; - int len; char fullpath[MAXPATHLEN]; if (list) /* -l option fall through */ return (NULL); ! for (i = 0; i <= ((sizeof (map)/sizeof (map[0]) - 1)); i++) { ! if (strlen(section) > strlen(map[i].new_name)) { ! len = strlen(section); ! } else { ! len = strlen(map[i].new_name); ! } ! if (strncmp(section, map[i].old_name, len) == 0) { (void) snprintf(fullpath, sizeof (fullpath), ! "%s/sman%s", path, map[i].new_name); if (!access(fullpath, R_OK | X_OK)) { return (map[i].new_name); } else { return (NULL); } --- 1162,1180 ---- */ static char * map_section(char *section, char *path) { int i; char fullpath[MAXPATHLEN]; if (list) /* -l option fall through */ return (NULL); ! for (i = 0; map[i].new_name != NULL; i++) { ! if (strcmp(section, map[i].old_name) == 0) { (void) snprintf(fullpath, sizeof (fullpath), ! "%s/man%s", path, map[i].new_name); if (!access(fullpath, R_OK | X_OK)) { return (map[i].new_name); } else { return (NULL); }
*** 1195,1205 **** dir + 3, pg); (void) snprintf(catpname, sizeof (catpname), "%s/cat%s/%s", path, dir + 3, pg); /* Can't do PS output if manpage doesn't exist */ ! if (stat(manpname, &sbman) != 0 && psoutput) return (-1); /* * If both manpage and catpage do not exist, manpname is * broken symlink, most likely. --- 1207,1217 ---- dir + 3, pg); (void) snprintf(catpname, sizeof (catpname), "%s/cat%s/%s", path, dir + 3, pg); /* Can't do PS output if manpage doesn't exist */ ! if (stat(manpname, &sbman) != 0 && (psoutput|lintout)) return (-1); /* * If both manpage and catpage do not exist, manpname is * broken symlink, most likely.
*** 1211,1221 **** if (fnmatch("*.gz", manpname, 0) == 0) cattool = "gzcat"; else if (fnmatch("*.bz2", manpname, 0) == 0) cattool = "bzcat"; else ! cattool = "gzcat -f"; /* Preprocess UTF-8 input with preconv (could be smarter) */ if (strstr(path, "UTF-8") != NULL) utf8 = 1; --- 1223,1233 ---- if (fnmatch("*.gz", manpname, 0) == 0) cattool = "gzcat"; else if (fnmatch("*.bz2", manpname, 0) == 0) cattool = "bzcat"; else ! cattool = "cat"; /* Preprocess UTF-8 input with preconv (could be smarter) */ if (strstr(path, "UTF-8") != NULL) utf8 = 1;
*** 1224,1233 **** --- 1236,1252 ---- "cd %s; %s %s%s | mandoc -Tps | lp -Tpostscript", path, cattool, manpname, utf8 ? " | " PRECONV " -e UTF-8" : ""); DPRINTF("-- Using manpage: %s\n", manpname); goto cmd; + } else if (lintout) { + (void) snprintf(cmdbuf, BUFSIZ, + "cd %s; %s %s%s | mandoc -Tlint", + path, cattool, manpname, + utf8 ? " | " PRECONV " -e UTF-8" : ""); + DPRINTF("-- Linting manpage: %s\n", manpname); + goto cmd; } /* * Output catpage if: * - manpage doesn't exist
*** 1566,1577 **** usage_man(void) { (void) fprintf(stderr, gettext( "usage: man [-alptw] [-M path] [-s section] name ...\n" ! " man [-M path] [-s section] -k keyword -- emulate apropos\n" ! " man [-M path] [-s section] -f keyword -- emulate whatis\n")); exit(1); } static void --- 1585,1596 ---- usage_man(void) { (void) fprintf(stderr, gettext( "usage: man [-alptw] [-M path] [-s section] name ...\n" ! " man [-M path] [-s section] -k keyword ...\n" ! " man [-M path] [-s section] -f keyword ...\n")); exit(1); } static void