summaryrefslogtreecommitdiffstats
path: root/usr.bin
diff options
context:
space:
mode:
authorru <ru@FreeBSD.org>2004-12-22 15:24:48 +0000
committerru <ru@FreeBSD.org>2004-12-22 15:24:48 +0000
commitd365c986409e6495710508c25a3de7527bccbd68 (patch)
tree8433c8a5949f81815b449e13619c97f6d2f4935f /usr.bin
parentf00429a695f008127dd8bc976b78e19b151783f9 (diff)
downloadFreeBSD-src-d365c986409e6495710508c25a3de7527bccbd68.zip
FreeBSD-src-d365c986409e6495710508c25a3de7527bccbd68.tar.gz
- Fixed handling of manpage subdirectories:
catman /usr/share/man/man8 cd /usr/share/man; catman man8 - Don't print false warnings about invalid cat pages which are machine-specific cat page subdirectories (visible with -v). - Fixed one memory leak.
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/catman/catman.c32
1 files changed, 12 insertions, 20 deletions
diff --git a/usr.bin/catman/catman.c b/usr.bin/catman/catman.c
index 3d4bf8e..3298c41 100644
--- a/usr.bin/catman/catman.c
+++ b/usr.bin/catman/catman.c
@@ -39,6 +39,7 @@ __FBSDID("$FreeBSD$");
#include <fcntl.h>
#include <locale.h>
#include <langinfo.h>
+#include <libgen.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -272,22 +273,6 @@ get_cat_section(char *section)
}
/*
- * Converts .../man/manXXX to .../man.
- */
-static char *
-get_mandir(char *section)
-{
- char *slash;
- char *mandir;
-
- slash = strrchr(section, '/');
- mandir = (char *) malloc(slash - section + 1);
- strncpy(mandir, section, slash - section);
- mandir[slash - section] = '\0';
- return mandir;
-}
-
-/*
* Tests to see if the given directory has already been visited.
*/
static int
@@ -578,7 +563,11 @@ scan_section(char *mandir, char *section, char *cat_section)
if (cmp == 0)
continue;
/* we have an unexpected page */
+ snprintf(cat_path, sizeof cat_path, "%s/%s", cat_section,
+ page_name);
if (!is_manpage_name(page_name)) {
+ if (test_path(cat_path, NULL) & TEST_DIR)
+ continue;
junk_reason = "invalid cat page name";
} else if (!is_gzipped(page_name) && e + 1 < nexpected &&
strncmp(page_name, expected[e + 1], strlen(page_name)) == 0 &&
@@ -586,8 +575,6 @@ scan_section(char *mandir, char *section, char *cat_section)
junk_reason = "cat page unused due to existing " GZ_EXT;
} else
junk_reason = "cat page without man page";
- snprintf(cat_path, sizeof cat_path, "%s/%s", cat_section,
- page_name);
junk(mandir, cat_path, junk_reason);
}
free(entries);
@@ -612,6 +599,7 @@ process_section(char *mandir, char *section)
cat_section = get_cat_section(section);
if (make_writable_dir(mandir, cat_section))
scan_section(mandir, section, cat_section);
+ free(cat_section);
}
static int
@@ -671,6 +659,7 @@ process_argument(const char *arg)
{
char *dir;
char *mandir;
+ char *section;
char *parg;
parg = strdup(arg);
@@ -694,8 +683,11 @@ process_argument(const char *arg)
}
break;
case MAN_SECTION_DIR: {
- mandir = get_mandir(dir);
- process_mandir(mandir, dir);
+ mandir = strdup(dirname(dir));
+ section = strdup(basename(dir));
+ process_mandir(mandir, section);
+ free(mandir);
+ free(section);
break;
}
default:
OpenPOWER on IntegriCloud