[BACK]Return to man.c CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / usr.bin / man

Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.

Diff for /src/usr.bin/man/man.c between version 1.38 and 1.39

version 1.38, 2009/10/06 06:43:15 version 1.39, 2009/10/07 08:30:31
Line 472  main(int argc, char **argv)
Line 472  main(int argc, char **argv)
         exit(cleanup());          exit(cleanup());
 }  }
   
   static int
   manual_find_buildkeyword(char *escpage, const char *fmt,
           struct manstate *mp, glob_t *pg, size_t cnt)
   {
           ENTRY *suffix;
           int found;
           char *p, buf[MAXPATHLEN];
   
           found = 0;
           /* Try the _build key words next. */
           TAILQ_FOREACH(suffix, &mp->buildlist->entrylist, q) {
                   for (p = suffix->s;
                       *p != '\0' && !isspace((unsigned char)*p);
                       ++p)
                           continue;
                   if (*p == '\0')
                           continue;
   
                   *p = '\0';
                   (void)snprintf(buf, sizeof(buf), fmt, escpage, suffix->s);
                   if (!fnmatch(buf, pg->gl_pathv[cnt], 0)) {
                           if (!mp->where)
                                   build_page(p + 1, &pg->gl_pathv[cnt], mp);
                           *p = ' ';
                           found = 1;
                           break;
                   }
                   *p = ' ';
           }
   
           return found;
   }
   
 /*  /*
  * manual --   * manual --
  *      Search the manuals for the pages.   *      Search the manuals for the pages.
Line 510  manual(char *page, struct manstate *mp, 
Line 543  manual(char *page, struct manstate *mp, 
   
         *eptr = '\0';          *eptr = '\0';
   
           /*
            * If 'page' is given with a full or relative path
            * then interpret it as a file specification.
            */
           if ((page[0] == '/') || (page[0] == '.')) {
                   /* check if file actually exists */
                   (void)strlcpy(buf, escpage, sizeof(buf));
                   error = glob(buf, GLOB_APPEND | GLOB_BRACE | GLOB_NOSORT, NULL, pg);
                   if (error != 0) {
                           if (error == GLOB_NOMATCH) {
                                   goto notfound;
                           } else {
                                   errx(EXIT_FAILURE, "glob failed");
                           }
                   }
   
                   if (pg->gl_matchc == 0)
                           goto notfound;
   
                   /* clip suffix for the suffix check below */
                   p = strrchr(escpage, '.');
                   if (p && p[0] == '.' && isdigit((unsigned char)p[1]))
                           p[0] = '\0';
   
                   found = 0;
                   for (cnt = pg->gl_pathc - pg->gl_matchc;
                       cnt < pg->gl_pathc; ++cnt)
                   {
                           found = manual_find_buildkeyword(escpage, "%s%s",
                                   mp, pg, cnt);
                           if (found) {
                                   anyfound = 1;
                                   if (!mp->all) {
                                           /* Delete any other matches. */
                                           while (++cnt< pg->gl_pathc)
                                                   pg->gl_pathv[cnt] = "";
                                           break;
                                   }
                                   continue;
                           }
   
                           /* It's not a man page, forget about it. */
                           pg->gl_pathv[cnt] = "";
                   }
   
     notfound:
                   if (!anyfound) {
                           if (addentry(mp->missinglist, page, 0) < 0) {
                                   warn("malloc");
                                   (void)cleanup();
                                   exit(EXIT_FAILURE);
                           }
                   }
                   free(escpage);
                   return anyfound;
           }
   
         /* For each man directory in mymanpath ... */          /* For each man directory in mymanpath ... */
         TAILQ_FOREACH(mdir, &mp->mymanpath->entrylist, q) {          TAILQ_FOREACH(mdir, &mp->mymanpath->entrylist, q) {
   
Line 576  manual(char *page, struct manstate *mp, 
Line 666  manual(char *page, struct manstate *mp, 
                                 goto next;                                  goto next;
   
                         /* Try the _build key words next. */                          /* Try the _build key words next. */
                         found = 0;                          found = manual_find_buildkeyword(escpage, "*/%s%s",
                         TAILQ_FOREACH(suffix, &mp->buildlist->entrylist, q) {                                  mp, pg, cnt);
                                 for (p = suffix->s;  
                                     *p != '\0' && !isspace((unsigned char)*p);  
                                     ++p)  
                                         continue;  
                                 if (*p == '\0')  
                                         continue;  
                                 *p = '\0';  
                                 (void)snprintf(buf,  
                                      sizeof(buf), "*/%s%s", escpage,  
                                      suffix->s);  
                                 if (!fnmatch(buf, pg->gl_pathv[cnt], 0)) {  
                                         if (!mp->where)  
                                                 build_page(p + 1,  
                                                     &pg->gl_pathv[cnt], mp);  
                                         *p = ' ';  
                                         found = 1;  
                                         break;  
                                 }  
                                 *p = ' ';  
                         }  
                         if (found) {                          if (found) {
 next:                           anyfound = 1;  next:                           anyfound = 1;
                                 if (!mp->all) {                                  if (!mp->all) {

Legend:
Removed from v.1.38  
changed lines
  Added in v.1.39

CVSweb <webmaster@jp.NetBSD.org>