[BACK]Return to main.c CVS log [TXT][DIR] Up to [cvsweb.bsd.lv] / mandoc

Diff for /mandoc/main.c between version 1.276 and 1.277

version 1.276, 2016/09/18 15:22:08 version 1.277, 2016/09/18 15:47:45
Line 820  passthrough(const char *file, int fd, int synopsis_onl
Line 820  passthrough(const char *file, int fd, int synopsis_onl
         const char      *syscall;          const char      *syscall;
         char            *line, *cp;          char            *line, *cp;
         size_t           linesz;          size_t           linesz;
           ssize_t          len, written;
         int              print;          int              print;
   
         line = NULL;          line = NULL;
         linesz = 0;          linesz = 0;
   
           if (fflush(stdout) == EOF) {
                   syscall = "fflush";
                   goto fail;
           }
   
         if ((stream = fdopen(fd, "r")) == NULL) {          if ((stream = fdopen(fd, "r")) == NULL) {
                 close(fd);                  close(fd);
                 syscall = "fdopen";                  syscall = "fdopen";
Line 832  passthrough(const char *file, int fd, int synopsis_onl
Line 838  passthrough(const char *file, int fd, int synopsis_onl
         }          }
   
         print = 0;          print = 0;
         while (getline(&line, &linesz, stream) != -1) {          while ((len = getline(&line, &linesz, stream)) != -1) {
                 cp = line;                  cp = line;
                 if (synopsis_only) {                  if (synopsis_only) {
                         if (print) {                          if (print) {
                                 if ( ! isspace((unsigned char)*cp))                                  if ( ! isspace((unsigned char)*cp))
                                         goto done;                                          goto done;
                                 while (isspace((unsigned char)*cp))                                  while (isspace((unsigned char)*cp)) {
                                         cp++;                                          cp++;
                                           len--;
                                   }
                         } else {                          } else {
                                 if (strcmp(cp, synb) == 0 ||                                  if (strcmp(cp, synb) == 0 ||
                                     strcmp(cp, synr) == 0)                                      strcmp(cp, synr) == 0)
Line 847  passthrough(const char *file, int fd, int synopsis_onl
Line 855  passthrough(const char *file, int fd, int synopsis_onl
                                 continue;                                  continue;
                         }                          }
                 }                  }
                 if (fputs(cp, stdout)) {                  for (; len > 0; len -= written) {
                           if ((written = write(STDOUT_FILENO, cp, len)) != -1)
                                   continue;
                         fclose(stream);                          fclose(stream);
                         syscall = "fputs";                          syscall = "write";
                         goto fail;                          goto fail;
                 }                  }
         }          }

Legend:
Removed from v.1.276  
changed lines
  Added in v.1.277

CVSweb