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

Diff for /src/usr.bin/man/Attic/man.c between version 1.40 and 1.41

version 1.40, 2010/10/22 14:08:53 version 1.41, 2011/05/25 14:36:04
Line 77 
Line 77 
 static void      build_page(char *, char **);  static void      build_page(char *, char **);
 static void      cat(char *);  static void      cat(char *);
 static char     *check_pager(char *);  static char     *check_pager(char *);
 static int       cleanup(void);  static int       cleanup(int);
 static void      how(char *);  static void      how(char *);
 static void      jump(char **, char *, char *);  static void      jump(char **, char *, char *);
 static int       manual(char *, TAG *, glob_t *);  static int       manual(char *, TAG *, glob_t *);
Line 242 
Line 242 
   
         /* 6: If nothing found, we're done. */          /* 6: If nothing found, we're done. */
         if (!found) {          if (!found) {
                 (void)cleanup();                  (void)cleanup(0);
                 exit (1);                  exit (1);
         }          }
   
Line 253 
Line 253 
                                 continue;                                  continue;
                         cat(*ap);                          cat(*ap);
                 }                  }
                 exit (cleanup());                  exit (cleanup(0));
         }          }
         if (f_how) {          if (f_how) {
                 for (ap = pg.gl_pathv; *ap != NULL; ++ap) {                  for (ap = pg.gl_pathv; *ap != NULL; ++ap) {
Line 261 
Line 261 
                                 continue;                                  continue;
                         how(*ap);                          how(*ap);
                 }                  }
                 exit(cleanup());                  exit(cleanup(0));
         }          }
         if (f_where) {          if (f_where) {
                 for (ap = pg.gl_pathv; *ap != NULL; ++ap) {                  for (ap = pg.gl_pathv; *ap != NULL; ++ap) {
Line 269 
Line 269 
                                 continue;                                  continue;
                         (void)puts(*ap);                          (void)puts(*ap);
                 }                  }
                 exit(cleanup());                  exit(cleanup(0));
         }          }
   
         /*          /*
Line 283 
Line 283 
         }          }
         if ((cmd = malloc(len)) == NULL) {          if ((cmd = malloc(len)) == NULL) {
                 warn(NULL);                  warn(NULL);
                 (void)cleanup();                  (void)cleanup(0);
                 exit(1);                  exit(1);
         }          }
         p = cmd;          p = cmd;
Line 304 
Line 304 
         /* Use system(3) in case someone's pager is "pager arg1 arg2". */          /* Use system(3) in case someone's pager is "pager arg1 arg2". */
         (void)system(cmd);          (void)system(cmd);
   
         exit(cleanup());          exit(cleanup(0));
 }  }
   
 /*  /*
Line 445 
Line 445 
                     GLOB_APPEND | GLOB_BRACE | GLOB_NOSORT | GLOB_QUOTE,                      GLOB_APPEND | GLOB_BRACE | GLOB_NOSORT | GLOB_QUOTE,
                     NULL, pg)) {                      NULL, pg)) {
                         warn("globbing");                          warn("globbing");
                         (void)cleanup();                          (void)cleanup(0);
                         exit(1);                          exit(1);
                 }                  }
                 if (pg->gl_matchc == 0)                  if (pg->gl_matchc == 0)
Line 534 
Line 534 
                 if ((ep = malloc(sizeof(ENTRY))) == NULL ||                  if ((ep = malloc(sizeof(ENTRY))) == NULL ||
                     (ep->s = strdup(page)) == NULL) {                      (ep->s = strdup(page)) == NULL) {
                         warn(NULL);                          warn(NULL);
                         (void)cleanup();                          (void)cleanup(0);
                         exit(1);                          exit(1);
                 }                  }
                 TAILQ_INSERT_TAIL(&missp->list, ep, q);                  TAILQ_INSERT_TAIL(&missp->list, ep, q);
Line 597 
Line 597 
         (void)strlcpy(tpath, _PATH_TMPFILE, sizeof(tpath));          (void)strlcpy(tpath, _PATH_TMPFILE, sizeof(tpath));
         if ((fd = mkstemp(tpath)) == -1) {          if ((fd = mkstemp(tpath)) == -1) {
                 warn("%s", tpath);                  warn("%s", tpath);
                 (void)cleanup();                  (void)cleanup(0);
                 exit(1);                  exit(1);
         }          }
         (void)snprintf(buf, sizeof(buf), "%s > %s", fmt, tpath);          (void)snprintf(buf, sizeof(buf), "%s > %s", fmt, tpath);
Line 606 
Line 606 
         (void)close(fd);          (void)close(fd);
         if ((*pathp = strdup(tpath)) == NULL) {          if ((*pathp = strdup(tpath)) == NULL) {
                 warn(NULL);                  warn(NULL);
                 (void)cleanup();                  (void)cleanup(0);
                 exit(1);                  exit(1);
         }          }
   
         /* Link the built file into the remove-when-done list. */          /* Link the built file into the remove-when-done list. */
         if ((ep = malloc(sizeof(ENTRY))) == NULL) {          if ((ep = malloc(sizeof(ENTRY))) == NULL) {
                 warn(NULL);                  warn(NULL);
                 (void)cleanup();                  (void)cleanup(0);
                 exit(1);                  exit(1);
         }          }
         ep->s = *pathp;          ep->s = *pathp;
   
           sigprocmask(SIG_BLOCK, &blocksigs, &osigs);
         TAILQ_INSERT_TAIL(&intmpp->list, ep, q);          TAILQ_INSERT_TAIL(&intmpp->list, ep, q);
           sigprocmask(SIG_SETMASK, &osigs, NULL);
 }  }
   
 /*  /*
Line 634 
Line 637 
   
         if (!(fp = fopen(fname, "r"))) {          if (!(fp = fopen(fname, "r"))) {
                 warn("%s", fname);                  warn("%s", fname);
                 (void)cleanup();                  (void)cleanup(0);
                 exit (1);                  exit (1);
         }          }
 #define S1      "SYNOPSIS"  #define S1      "SYNOPSIS"
Line 691 
Line 694 
   
         if ((fd = open(fname, O_RDONLY, 0)) < 0) {          if ((fd = open(fname, O_RDONLY, 0)) < 0) {
                 warn("%s", fname);                  warn("%s", fname);
                 (void)cleanup();                  (void)cleanup(0);
                 exit(1);                  exit(1);
         }          }
         while ((n = read(fd, buf, sizeof(buf))) > 0)          while ((n = read(fd, buf, sizeof(buf))) > 0)
                 if (write(STDOUT_FILENO, buf, n) != n) {                  if (write(STDOUT_FILENO, buf, n) != n) {
                         warn("write");                          warn("write");
                         (void)cleanup();                          (void)cleanup(0);
                         exit (1);                          exit (1);
                 }                  }
         if (n == -1) {          if (n == -1) {
                 warn("read");                  warn("read");
                 (void)cleanup();                  (void)cleanup(0);
                 exit(1);                  exit(1);
         }          }
         (void)close(fd);          (void)close(fd);
Line 765 
Line 768 
 static void  static void
 onsig(int signo)  onsig(int signo)
 {  {
         (void)cleanup();        /* XXX signal race */          (void)cleanup(1);
   
         (void)signal(signo, SIG_DFL);          (void)signal(signo, SIG_DFL);
         (void)kill(getpid(), signo);          (void)kill(getpid(), signo);
Line 779 
Line 782 
  *      Clean up temporary files, show any error messages.   *      Clean up temporary files, show any error messages.
  */   */
 static int  static int
 cleanup(void)  cleanup(int insig)
 {  {
         TAG *intmpp, *missp;          TAG *intmpp, *missp;
         ENTRY *ep;          ENTRY *ep;
         int rval;          int rval = 0;
   
         rval = 0;          if (insig == 0) {
         ep = (missp = getlist("_missing")) == NULL ?                  ep = (missp = getlist("_missing")) == NULL ?
             NULL : TAILQ_FIRST(&missp->list);                      NULL : TAILQ_FIRST(&missp->list);
         if (ep != NULL)                  if (ep != NULL)
                 for (; ep != NULL; ep = TAILQ_NEXT(ep, q)) {                          for (; ep != NULL; ep = TAILQ_NEXT(ep, q)) {
                         if (section)                                  if (section)
                                 warnx("no entry for %s in section %s of the manual.",                                          warnx("no entry for %s in "
                                         ep->s, section->s);                                              "section %s of the manual.",
                         else                                                  ep->s, section->s);
                                 warnx("no entry for %s in the manual.", ep->s);                                  else
                         rval = 1;                                          warnx("no entry for %s in the manual.",
                 }                                              ep->s);
                                   rval = 1;
                           }
           }
   
         ep = (intmpp = getlist("_intmp")) == NULL ?          ep = (intmpp = getlist("_intmp")) == NULL ?
             NULL : TAILQ_FIRST(&intmpp->list);              NULL : TAILQ_FIRST(&intmpp->list);

Legend:
Removed from v.1.40  
changed lines
  Added in v.1.41