Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/libexec/makewhatis Reject unformatted manual pages with "[" ...
details: https://anonhg.NetBSD.org/src/rev/c28248f1ae2e
branches: trunk
changeset: 584403:c28248f1ae2e
user: tron <tron%NetBSD.org@localhost>
date: Thu Sep 15 14:20:01 2005 +0000
description:
Reject unformatted manual pages with "[" characters in the description
because "makewhatis" cannot handle nroff macros properly. This fixes
the result of "apropos chrtbl". Problem pointed out by wizd(8)
in private e-mail.
diffstat:
libexec/makewhatis/makewhatis.c | 210 +++++++++++++++++++++------------------
1 files changed, 113 insertions(+), 97 deletions(-)
diffs (truncated from 537 to 300 lines):
diff -r c529c111b27b -r c28248f1ae2e libexec/makewhatis/makewhatis.c
--- a/libexec/makewhatis/makewhatis.c Thu Sep 15 13:44:41 2005 +0000
+++ b/libexec/makewhatis/makewhatis.c Thu Sep 15 14:20:01 2005 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: makewhatis.c,v 1.36 2005/06/01 15:53:31 lukem Exp $ */
+/* $NetBSD: makewhatis.c,v 1.37 2005/09/15 14:20:01 tron Exp $ */
/*-
* Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -44,7 +44,7 @@
#if !defined(lint)
__COPYRIGHT("@(#) Copyright (c) 1999 The NetBSD Foundation, Inc.\n\
All rights reserved.\n");
-__RCSID("$NetBSD: makewhatis.c,v 1.36 2005/06/01 15:53:31 lukem Exp $");
+__RCSID("$NetBSD: makewhatis.c,v 1.37 2005/09/15 14:20:01 tron Exp $");
#endif /* not lint */
#include <sys/types.h>
@@ -91,55 +91,64 @@
char wi_prefix[1];
};
-int main(int, char * const *);
-char *findwhitespace(char *);
-char *strmove(char *,char *);
-char *GetS(gzFile, char *, size_t);
-int pathnamesection(const char *, const char *);
-int manpagesection(char *);
-char *createsectionstring(char *);
-void addmanpage(manpage **, ino_t, char *, size_t, size_t);
-void addwhatis(whatis **, char *, char *);
-char *makesection(int);
-char *makewhatisline(const char *, const char *, const char *);
-void catpreprocess(char *);
-char *parsecatpage(const char *, gzFile *);
-int manpreprocess(char *);
-char *nroff(const char *, gzFile *);
-char *parsemanpage(const char *, gzFile *, int);
-char *getwhatisdata(char *);
-void processmanpages(manpage **,whatis **);
-void dumpwhatis(FILE *, whatis *);
-void *emalloc(size_t);
-char *estrdup(const char *);
-static int makewhatis(char * const *manpath);
+int main(int, char * const *);
+static char *findwhitespace(char *);
+static char *strmove(char *,char *);
+static char *GetS(gzFile, char *, size_t);
+static int pathnamesection(const char *, const char *);
+static int manpagesection(char *);
+static char *createsectionstring(char *);
+static void addmanpage(manpage **, ino_t, char *, size_t, size_t);
+static void addwhatis(whatis **, char *, char *);
+static char *makesection(int);
+static char *makewhatisline(const char *, const char *, const char *);
+static void catpreprocess(char *);
+static char *parsecatpage(const char *, gzFile *);
+static int manpreprocess(char *);
+static char *nroff(const char *, gzFile *);
+static char *parsemanpage(const char *, gzFile *, int);
+static char *getwhatisdata(char *);
+static void processmanpages(manpage **,whatis **);
+static void dumpwhatis(FILE *, whatis *);
+static void *emalloc(size_t);
+static char *estrdup(const char *);
+static int makewhatis(char * const *manpath);
-char * const default_manpath[] = {
+static char * const default_manpath[] = {
"/usr/share/man",
NULL
};
-const char *sectionext = "0123456789ln";
-const char *whatisdb = _PATH_WHATIS;
-static int dowarn = 0;
+static const char *sectionext = "0123456789ln";
+static const char *whatisdb = _PATH_WHATIS;
+static int dowarn = 0;
+
+#define ISALPHA(c) isalpha((unsigned char)(c))
+#define ISDIGIT(c) isdigit((unsigned char)(c))
+#define ISSPACE(c) isspace((unsigned char)(c))
int
main(int argc, char *const *argv)
{
- char * const *manpath;
- int c, dofork=1;
- const char *conffile = NULL;
- ENTRY *ep;
- TAG *tp;
- int rv, jobs = 0, status;
- glob_t pg;
- char *paths[2], **p, *sl;
- int retval = EXIT_SUCCESS;
+ char * const *manpath;
+ int c, dofork;
+ const char *conffile;
+ ENTRY *ep;
+ TAG *tp;
+ int rv, jobs, status;
+ glob_t pg;
+ char *paths[2], **p, *sl;
+ int retval;
+
+ dofork = 1;
+ conffile = NULL;
+ jobs = 0;
+ retval = EXIT_SUCCESS;
(void)setlocale(LC_ALL, "");
- while((c = getopt(argc, argv, "C:fw")) != -1) {
- switch(c) {
+ while ((c = getopt(argc, argv, "C:fw")) != -1) {
+ switch (c) {
case 'C':
conffile = optarg;
break;
@@ -163,7 +172,7 @@
manpath = &argv[0];
mkwhatis:
- return (makewhatis(manpath));
+ return makewhatis(manpath);
}
/*
@@ -187,8 +196,10 @@
/* We always have something to work with here */
for (p = pg.gl_pathv; *p; p++) {
sl = strrchr(*p, '/');
- if (!sl)
- err(EXIT_FAILURE, "glob: _whatdb entry '%s' doesn't contain slash", ep->s);
+ if (sl == NULL) {
+ err(EXIT_FAILURE, "glob: _whatdb entry '%s' "
+ "doesn't contain slash", ep->s);
+ }
/*
* Cut the last component of path, leaving just
@@ -225,14 +236,14 @@
}
/* Wait for the childern to finish */
- while(jobs > 0) {
- wait(&status);
+ while (jobs > 0) {
+ (void)wait(&status);
if (!WIFEXITED(status) || WEXITSTATUS(status) != EXIT_SUCCESS)
retval = EXIT_FAILURE;
jobs--;
}
- return (retval);
+ return retval;
}
static int
@@ -258,14 +269,17 @@
* commonly, this is arch-specific subdirectory.
*/
if (fe->fts_level >= 3) {
- int sl = fe->fts_level - 1;
- const char *s, *lsl=NULL;
+ int sl;
+ const char *s, *lsl;
- s = &fe->fts_path[fe->fts_pathlen-1];
- for(; sl > 0; sl--) {
+ lsl = NULL;
+ s = &fe->fts_path[fe->fts_pathlen - 1];
+ for(sl = fe->fts_level - 1; sl > 0;
+ sl--) {
s--;
- while(s[0] != '/') s--;
- if (!lsl)
+ while (s[0] != '/')
+ s--;
+ if (lsl == NULL)
lsl = s;
}
@@ -315,10 +329,10 @@
return EXIT_SUCCESS;
}
-char *
+static char *
findwhitespace(char *str)
{
- while (!isspace((unsigned char)*str))
+ while (!ISSPACE(*str))
if (*str++ == '\0') {
str = NULL;
break;
@@ -327,13 +341,13 @@
return str;
}
-char
+static char
*strmove(char *dest,char *src)
{
return memmove(dest, src, strlen(src) + 1);
}
-char *
+static char *
GetS(gzFile in, char *buffer, size_t length)
{
char *ptr;
@@ -344,7 +358,7 @@
return ptr;
}
-char *
+static char *
makesection(int s)
{
char sectionbuffer[24];
@@ -355,7 +369,7 @@
return estrdup(sectionbuffer);
}
-int
+static int
pathnamesection(const char *pat, const char *name)
{
char *ptr, *ext;
@@ -372,7 +386,7 @@
}
-int
+static int
manpagesection(char *name)
{
char *ptr;
@@ -396,7 +410,7 @@
return -1;
}
-char *
+static char *
createsectionstring(char *section_id)
{
char *section;
@@ -406,7 +420,7 @@
return section;
}
-void
+static void
addmanpage(manpage **tree,ino_t inode,char *name, size_t sdoff, size_t sdlen)
{
manpage *mp;
@@ -427,20 +441,20 @@
*tree = mp;
}
-void
+static void
addwhatis(whatis **tree, char *data, char *prefix)
{
whatis *wi;
int result;
- while (isspace((unsigned char)*data))
+ while (ISSPACE(*data))
data++;
if (*data == '/') {
char *ptr;
ptr = ++data;
- while ((*ptr != '\0') && !isspace((unsigned char)*ptr))
+ while ((*ptr != '\0') && !ISSPACE(*ptr))
if (*ptr++ == '/')
data = ptr;
}
@@ -463,17 +477,17 @@
*tree = wi;
}
-void
+static void
catpreprocess(char *from)
{
char *to;
to = from;
- while (isspace((unsigned char)*from)) from++;
+ while (ISSPACE(*from)) from++;
while (*from != '\0')
- if (isspace((unsigned char)*from)) {
- while (isspace((unsigned char)*++from));
+ if (ISSPACE(*from)) {
Home |
Main Index |
Thread Index |
Old Index