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

Diff for /docbook2mdoc/statistics.c between version 1.24 and 1.26

version 1.24, 2019/04/14 14:00:17 version 1.26, 2019/04/14 16:26:34
Line 46 
Line 46 
  *   *
  * Example usage:   * Example usage:
  * statistics tgroup colspec < filenames.txt | grep colspec   * statistics tgroup colspec < filenames.txt | grep colspec
    *
    * Synchronized with parse.c up to rev. 1.42.
  */   */
   
 struct entry {  struct entry {
Line 209  parse_file(int fd, char *fname)
Line 211  parse_file(int fd, char *fname)
         size_t           rlen;  /* Number of bytes in b[]. */          size_t           rlen;  /* Number of bytes in b[]. */
         size_t           poff;  /* Parse offset in b[]. */          size_t           poff;  /* Parse offset in b[]. */
         size_t           pend;  /* Offset of the end of the current word. */          size_t           pend;  /* Offset of the end of the current word. */
         int              in_tag, in_arg, in_quotes, elem_end;          int              in_tag, in_arg, in_quotes, in_doctype, elem_end;
   
         rlen = 0;          rlen = 0;
         in_tag = in_arg = in_quotes = 0;          in_tag = in_arg = in_quotes = in_doctype = 0;
         while ((rsz = read(fd, b + rlen, sizeof(b) - rlen - 1)) >= 0) {          while ((rsz = read(fd, b + rlen, sizeof(b) - rlen - 1)) >= 0) {
                 if ((rlen += rsz) == 0)                  if ((rlen += rsz) == 0)
                         break;                          break;
Line 249  parse_file(int fd, char *fname)
Line 251  parse_file(int fd, char *fname)
                                 if (elem_end)                                  if (elem_end)
                                         stack_pop(NULL);                                          stack_pop(NULL);
                         } else if (in_tag) {                          } else if (in_tag) {
                                   if (in_doctype && b[pend] == '[') {
                                           in_tag = in_doctype = 0;
                                           pend++;
                                           continue;
                                   }
                                 if (advance(b, rlen, &pend, " =>") && rsz > 0)                                  if (advance(b, rlen, &pend, " =>") && rsz > 0)
                                         break;                                          break;
                                 elem_end = 0;                                  elem_end = 0;
Line 299  parse_file(int fd, char *fname)
Line 306  parse_file(int fd, char *fname)
                                 if (b[++poff] == '/') {                                  if (b[++poff] == '/') {
                                         elem_end = 1;                                          elem_end = 1;
                                         poff++;                                          poff++;
                                   } else if (strcasecmp(b + poff,
                                       "!DOCTYPE") == 0) {
                                           in_doctype = 1;
                                 } else if (b[poff] != '!' && b[poff] != '?') {                                  } else if (b[poff] != '!' && b[poff] != '?') {
                                         table_add(stacki > 0 ?                                          table_add(stacki > 0 ?
                                             stack[stacki - 1] : "ROOT",                                              stack[stacki - 1] : "ROOT",
                                             b + poff);                                              b + poff);
                                         stack_push(b + poff);                                          stack_push(b + poff);
                                           if (strcmp(b + poff, "sbr") == 0)
                                                   elem_end = 1;
                                 }                                  }
                                 if (elem_end)                                  if (elem_end)
                                         stack_pop(b + poff);                                          stack_pop(b + poff);
Line 314  parse_file(int fd, char *fname)
Line 326  parse_file(int fd, char *fname)
                         }                          }
                 }                  }
                 assert(poff > 0);                  assert(poff > 0);
                 memmove(b, b + poff, rlen - poff);  
                 rlen -= poff;                  rlen -= poff;
                   memmove(b, b + poff, rlen);
         }          }
         if (rsz < 0)          if (rsz < 0)
                 perror(fname);                  perror(fname);

Legend:
Removed from v.1.24  
changed lines
  Added in v.1.26

CVSweb