[BACK]Return to apropos.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / apropos

Diff for /src/usr.bin/apropos/Attic/apropos.c between version 1.13 and 1.14

version 1.13, 2007/08/06 19:16:06 version 1.14, 2008/12/24 09:05:17
Line 62 
Line 62 
   
 #define MAXLINELEN      8192            /* max line handled */  #define MAXLINELEN      8192            /* max line handled */
   
 void apropos(char **, char *, int);  void apropos(char **, char *, int, char *, char *);
 void lowstr(char *, char *);  void lowstr(char *, char *);
 int match(char *, char *);  int match(char *, char *);
 void usage(void);  void usage(void);
Line 73 
Line 73 
         ENTRY *ep;          ENTRY *ep;
         TAG *tp;          TAG *tp;
         int ch, rv;          int ch, rv;
         char *conffile, **p, *p_augment, *p_path;          char *conffile, *machine, **p, *p_augment, *p_path, *sflag;
   
         conffile = NULL;          conffile = NULL;
         p_augment = p_path = NULL;          p_augment = p_path = NULL;
         while ((ch = getopt(argc, argv, "C:M:m:P:")) != -1)          machine = sflag = NULL;
           while ((ch = getopt(argc, argv, "C:M:m:P:S:s:")) != -1)
                 switch (ch) {                  switch (ch) {
                 case 'C':                  case 'C':
                         conffile = optarg;                          conffile = optarg;
Line 89 
Line 90 
                 case 'm':                  case 'm':
                         p_augment = optarg;                          p_augment = optarg;
                         break;                          break;
                   case 'S':
                           machine = optarg;
                           lowstr(machine, machine);
                           break;
                   case 's':
                           sflag = optarg;
                           lowstr(sflag, sflag);
                           break;
                 case '?':                  case '?':
                 default:                  default:
                         usage();                          usage();
Line 106 
Line 115 
                 lowstr(*p, *p);                  lowstr(*p, *p);
   
         if (p_augment)          if (p_augment)
                 apropos(argv, p_augment, 1);                  apropos(argv, p_augment, 1, sflag, machine);
         if (p_path || (p_path = getenv("MANPATH")))          if (p_path || (p_path = getenv("MANPATH")))
                 apropos(argv, p_path, 1);                  apropos(argv, p_path, 1, sflag, machine);
         else {          else {
                 config(conffile);                  config(conffile);
                 ep = (tp = getlist("_whatdb")) == NULL ?                  ep = (tp = getlist("_whatdb")) == NULL ?
                     NULL : TAILQ_FIRST(&tp->list);                      NULL : TAILQ_FIRST(&tp->list);
                 for (; ep != NULL; ep = TAILQ_NEXT(ep, q))                  for (; ep != NULL; ep = TAILQ_NEXT(ep, q))
                         apropos(argv, ep->s, 0);                          apropos(argv, ep->s, 0, sflag, machine);
         }          }
   
         if (!foundman)          if (!foundman)
Line 130 
Line 139 
 }  }
   
 void  void
 apropos(char **argv, char *path, int buildpath)  apropos(char **argv, char *path, int buildpath, char *sflag, char *machine)
 {  {
         char *end, *name, **p;          char *end, *name, **p;
         char buf[MAXLINELEN + 1], wbuf[MAXLINELEN + 1];          char buf[MAXLINELEN + 1], wbuf[MAXLINELEN + 1];
         char hold[MAXPATHLEN];          char hold[MAXPATHLEN];
           size_t slen = 0, mlen = 0;
   
           if (sflag)
                   slen = strlen(sflag);
           if (machine)
                   mlen = strlen(machine);
   
         for (name = path; name; name = end) {   /* through name list */          for (name = path; name; name = end) {   /* through name list */
                 if ((end = strchr(name, ':')))                  if ((end = strchr(name, ':')))
                         *end++ = '\0';                          *end++ = '\0';
Line 158 
Line 173 
                                 continue;                                  continue;
                         }                          }
                         lowstr(buf, wbuf);                          lowstr(buf, wbuf);
                           if (sflag || machine) {
                                   char *s = strstr(wbuf, ") - ");
                                   if (!s)
                                           continue;
                                   while (s > wbuf && *s != '/' && *s != '(')
                                           s--;
                                   if (machine && *s == '/' &&
                                       strncmp(s+1, machine, mlen))
                                           continue;
                                   while (s > wbuf && *s != '(')
                                           s--;
                                   if (sflag && *s == '(' &&
                                       strncmp(s+1, sflag, slen))
                                           continue;
                           }
                         for (p = argv; *p; ++p)                          for (p = argv; *p; ++p)
                                 if (match(wbuf, *p)) {                                  if (match(wbuf, *p)) {
                                         (void)printf("%s", buf);                                          (void)printf("%s", buf);
Line 217 
Line 247 
 {  {
   
         (void)fprintf(stderr,          (void)fprintf(stderr,
             "usage: apropos [-C file] [-M path] [-m path] keyword ...\n");              "usage: apropos [-C file] [-M path] [-m path] "
               "[-S subsection] [-s section]\n"
               "       keyword ...\n");
         exit(1);          exit(1);
 }  }

Legend:
Removed from v.1.13  
changed lines
  Added in v.1.14