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

Diff for /texi2mdoc/util.c between version 1.3 and 1.4

version 1.3, 2015/02/21 12:44:45 version 1.4, 2015/02/21 17:00:33
Line 67  texiexit(struct texi *p)
Line 67  texiexit(struct texi *p)
         for (i = 0; i < p->dirsz; i++)          for (i = 0; i < p->dirsz; i++)
                 free(p->dirs[i]);                  free(p->dirs[i]);
   
           for (i = 0; i < p->indexsz; i++)
                   free(p->indexs[i]);
   
         for (i = 0; i < p->valsz; i++) {          for (i = 0; i < p->valsz; i++) {
                 free(p->vals[i].value);                  free(p->vals[i].value);
                 free(p->vals[i].key);                  free(p->vals[i].key);
         }          }
   
         free(p->vals);          free(p->vals);
           free(p->indexs);
         free(p->dirs);          free(p->dirs);
         free(p->subtitle);          free(p->subtitle);
         free(p->title);          free(p->title);
Line 429  enum texicmd
Line 433  enum texicmd
 texicmd(struct texi *p, const char *buf,  texicmd(struct texi *p, const char *buf,
         size_t pos, size_t sz, size_t *end)          size_t pos, size_t sz, size_t *end)
 {  {
         size_t   i, len;          size_t   i, len, toksz;
   
         assert('@' == buf[pos]);          assert('@' == buf[pos]);
   
Line 452  texicmd(struct texi *p, const char *buf, 
Line 456  texicmd(struct texi *p, const char *buf, 
                 return(TEXICMD__MAX);                  return(TEXICMD__MAX);
         }          }
   
           /* Scan to the end of the possible command name. */
         for (*end = pos; *end < sz && ! ismspace(buf[*end]); (*end)++)          for (*end = pos; *end < sz && ! ismspace(buf[*end]); (*end)++)
                 if ((*end > pos && ('@' == buf[*end] ||                  if ((*end > pos && ('@' == buf[*end] ||
                           '{' == buf[*end] || '}' == buf[*end])))                            '{' == buf[*end] || '}' == buf[*end])))
                         break;                          break;
   
           /* Look for the command. */
         len = *end - pos;          len = *end - pos;
         for (i = 0; i < TEXICMD__MAX; i++) {          for (i = 0; i < TEXICMD__MAX; i++) {
                 if (len != texitoks[i].len)                  if (len != texitoks[i].len)
Line 465  texicmd(struct texi *p, const char *buf, 
Line 471  texicmd(struct texi *p, const char *buf, 
                         return(i);                          return(i);
         }          }
   
           /* Look for it in our indices. */
           for (i = 0; i < p->indexsz; i++) {
                   toksz = strlen(p->indexs[i]);
                   if (len != 5 + toksz)
                           continue;
                   if (strncmp(&buf[pos], p->indexs[i], toksz))
                           continue;
                   if (0 == strncmp(&buf[pos + toksz], "index", 5))
                           return(TEXICMD_INDEX);
           }
   
         texiwarn(p, "bad command: @%.*s", (int)len, &buf[pos]);          texiwarn(p, "bad command: @%.*s", (int)len, &buf[pos]);
         return(TEXICMD__MAX);          return(TEXICMD__MAX);
 }  }
Line 924  valueadd(struct texi *p, char *key, char *val)
Line 941  valueadd(struct texi *p, char *key, char *val)
                 free(p->vals[i].value);                  free(p->vals[i].value);
                 p->vals[i].value = val;                  p->vals[i].value = val;
         } else {          } else {
                   /* FIXME: reallocarray() */
                 p->vals = realloc(p->vals,                  p->vals = realloc(p->vals,
                         (p->valsz + 1) *                          (p->valsz + 1) *
                          sizeof(struct texivalue));                           sizeof(struct texivalue));
                 if (NULL == p->vals) {                  if (NULL == p->vals)
                         perror(NULL);                          texiabort(p, NULL);
                         exit(EXIT_FAILURE);  
                 }  
                 p->vals[p->valsz].key = key;                  p->vals[p->valsz].key = key;
                 p->vals[p->valsz].value = val;                  p->vals[p->valsz].value = val;
                 p->valsz++;                  p->valsz++;

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.4

CVSweb