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

Diff for /texi2mdoc/main.c between version 1.8 and 1.9

version 1.8, 2015/02/18 12:03:21 version 1.9, 2015/02/18 14:52:45
Line 135  enum texicmd {
Line 135  enum texicmd {
         TEXICMD_UREF,          TEXICMD_UREF,
         TEXICMD_URL,          TEXICMD_URL,
         TEXICMD_VAR,          TEXICMD_VAR,
           TEXICMD_VSKIP,
         TEXICMD_W,          TEXICMD_W,
         TEXICMD_XREF,          TEXICMD_XREF,
         TEXICMD__MAX          TEXICMD__MAX
Line 200  struct texi {
Line 201  struct texi {
 /* Texi disregards spaces and tabs. */  /* Texi disregards spaces and tabs. */
 #define isws(_x) \  #define isws(_x) \
         (' ' == (_x) || '\t' == (_x))          (' ' == (_x) || '\t' == (_x))
   #define ismspace(_x) \
           (isws((_x) || '\n' == (_x)))
   
 static  void doblock(struct texi *, enum texicmd, const char *, size_t, size_t *);  static  void doblock(struct texi *, enum texicmd, const char *, size_t, size_t *);
 static  void dobracket(struct texi *, enum texicmd, const char *, size_t, size_t *);  static  void dobracket(struct texi *, enum texicmd, const char *, size_t, size_t *);
Line 334  static const struct texitok texitoks[TEXICMD__MAX] = {
Line 337  static const struct texitok texitoks[TEXICMD__MAX] = {
         { dolink, "uref", 4 }, /* TEXICMD_UREF */          { dolink, "uref", 4 }, /* TEXICMD_UREF */
         { dolink, "url", 3 }, /* TEXICMD_URL */          { dolink, "url", 3 }, /* TEXICMD_URL */
         { doliteral, "var", 3 }, /* TEXICMD_VAR */          { doliteral, "var", 3 }, /* TEXICMD_VAR */
           { dosp, "vskip", 5 }, /* TEXICMD_VSKIP */
         { dobracket, "w", 1 }, /* TEXICMD_W */          { dobracket, "w", 1 }, /* TEXICMD_W */
         { dolink, "xref", 4 }, /* TEXICMD_XREF */          { dolink, "xref", 4 }, /* TEXICMD_XREF */
 };  };
Line 534  advancenext(struct texi *p, const char *buf, size_t sz
Line 538  advancenext(struct texi *p, const char *buf, size_t sz
 {  {
   
         if (p->literal) {          if (p->literal) {
                 while (*pos < sz && isspace(buf[*pos])) {                  while (*pos < sz && ismspace(buf[*pos])) {
                         if (*pos && '\n' == buf[*pos] &&                          if (*pos && '\n' == buf[*pos] &&
                                 '\\' == buf[*pos - 1])                                  '\\' == buf[*pos - 1])
                                 texiputchar(p, 'e');                                  texiputchar(p, 'e');
Line 544  advancenext(struct texi *p, const char *buf, size_t sz
Line 548  advancenext(struct texi *p, const char *buf, size_t sz
                 return(*pos);                  return(*pos);
         }          }
   
         while (*pos < sz && isspace(buf[*pos])) {          while (*pos < sz && ismspace(buf[*pos])) {
                 p->seenws = 1;                  p->seenws = 1;
                 /*                  /*
                  * If it looks like we've printed a double-line, then                   * If it looks like we've printed a double-line, then
Line 606  texiword(struct texi *p, const char *buf, 
Line 610  texiword(struct texi *p, const char *buf, 
   
         p->seenws = 0;          p->seenws = 0;
   
         while (*pos < sz && ! isspace(buf[*pos])) {          while (*pos < sz && ! ismspace(buf[*pos])) {
                 switch (buf[*pos]) {                  switch (buf[*pos]) {
                 case ('@'):                  case ('@'):
                 case ('}'):                  case ('}'):
Line 644  texicmd(struct texi *p, const char *buf, 
Line 648  texicmd(struct texi *p, const char *buf, 
   
         assert('@' == buf[pos]);          assert('@' == buf[pos]);
   
         if (++pos >= sz)          if ((*end = pos) == sz)
                 return(TEXICMD__MAX);                  return(TEXICMD__MAX);
           else if ((*end = ++pos) == sz)
                   return(TEXICMD__MAX);
   
         /* Alphabetic commands are special. */          /* Alphabetic commands are special. */
         if ( ! isalpha(buf[pos])) {          if ( ! isalpha(buf[pos])) {
                 *end = pos + 1;                  if ((*end = pos + 1) == sz)
                           return(TEXICMD__MAX);
                 for (i = 0; i < TEXICMD__MAX; i++) {                  for (i = 0; i < TEXICMD__MAX; i++) {
                         if (1 != texitoks[i].len)                          if (1 != texitoks[i].len)
                                 continue;                                  continue;
Line 660  texicmd(struct texi *p, const char *buf, 
Line 667  texicmd(struct texi *p, const char *buf, 
                 return(TEXICMD__MAX);                  return(TEXICMD__MAX);
         }          }
   
         for (*end = pos; *end < sz && ! isspace(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;
Line 692  parsearg(struct texi *p, const char *buf, 
Line 699  parsearg(struct texi *p, const char *buf, 
         size_t           end;          size_t           end;
         enum texicmd     cmd;          enum texicmd     cmd;
   
         while (*pos < sz && isspace(buf[*pos]))          while (*pos < sz && ismspace(buf[*pos]))
                 advance(p, buf, pos);                  advance(p, buf, pos);
         if (*pos == sz || (0 == num && '{' != buf[*pos]))          if (*pos == sz || (0 == num && '{' != buf[*pos]))
                 return(0);                  return(0);
Line 739  parsebracket(struct texi *p, const char *buf, size_t s
Line 746  parsebracket(struct texi *p, const char *buf, size_t s
         size_t           end;          size_t           end;
         enum texicmd     cmd;          enum texicmd     cmd;
   
         while (*pos < sz && isspace(buf[*pos]))          while (*pos < sz && ismspace(buf[*pos]))
                 advance(p, buf, pos);                  advance(p, buf, pos);
   
         if (*pos == sz || '{' != buf[*pos])          if (*pos == sz || '{' != buf[*pos])
Line 1066  doinline(struct texi *p, const char *buf, 
Line 1073  doinline(struct texi *p, const char *buf, 
         parsebracket(p, buf, sz, pos);          parsebracket(p, buf, sz, pos);
         if (*pos < sz - 1 &&          if (*pos < sz - 1 &&
                  ismpunct(buf[*pos]) &&                   ismpunct(buf[*pos]) &&
                  isspace(buf[*pos + 1])) {                   ismspace(buf[*pos + 1])) {
                 texiputchar(p, ' ');                  texiputchar(p, ' ');
                 texiputchar(p, buf[*pos]);                  texiputchar(p, buf[*pos]);
                 advance(p, buf, pos);                  advance(p, buf, pos);
Line 1365  dolink(struct texi *p, enum texicmd cmd, 
Line 1372  dolink(struct texi *p, enum texicmd cmd, 
   
         if (*pos < sz - 1 &&          if (*pos < sz - 1 &&
                  ismpunct(buf[*pos]) &&                   ismpunct(buf[*pos]) &&
                  isspace(buf[*pos + 1])) {                   ismspace(buf[*pos + 1])) {
                 texiputchar(p, ' ');                  texiputchar(p, ' ');
                 texiputchar(p, buf[*pos]);                  texiputchar(p, buf[*pos]);
                 advance(p, buf, pos);                  advance(p, buf, pos);
Line 1479  doitem(struct texi *p, enum texicmd cmd, 
Line 1486  doitem(struct texi *p, enum texicmd cmd, 
   
         if (TEXILIST_ITEM == p->list)          if (TEXILIST_ITEM == p->list)
                 teximacroclose(p);                  teximacroclose(p);
         else          else if (p->outcol > 0)
                 texiputchar(p, '\n');                  texiputchar(p, '\n');
 }  }
   

Legend:
Removed from v.1.8  
changed lines
  Added in v.1.9

CVSweb