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

Diff for /mandoc/roff.c between version 1.359 and 1.363

version 1.359, 2018/12/31 08:18:12 version 1.363, 2019/02/06 21:11:43
Line 1 
Line 1 
 /*      $Id$ */  /*      $Id$ */
 /*  /*
  * Copyright (c) 2008-2012, 2014 Kristaps Dzonsons <kristaps@bsd.lv>   * Copyright (c) 2008-2012, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
  * Copyright (c) 2010-2015, 2017, 2018 Ingo Schwarze <schwarze@openbsd.org>   * Copyright (c) 2010-2015, 2017-2019 Ingo Schwarze <schwarze@openbsd.org>
  *   *
  * Permission to use, copy, modify, and distribute this software for any   * Permission to use, copy, modify, and distribute this software for any
  * purpose with or without fee is hereby granted, provided that the above   * purpose with or without fee is hereby granted, provided that the above
Line 889  roff_node_alloc(struct roff_man *man, int line, int po
Line 889  roff_node_alloc(struct roff_man *man, int line, int po
                 n->flags |= NODE_SYNPRETTY;                  n->flags |= NODE_SYNPRETTY;
         else          else
                 n->flags &= ~NODE_SYNPRETTY;                  n->flags &= ~NODE_SYNPRETTY;
         if (man->flags & ROFF_NOFILL)          if ((man->flags & (ROFF_NOFILL | ROFF_NONOFILL)) == ROFF_NOFILL)
                 n->flags |= NODE_NOFILL;                  n->flags |= NODE_NOFILL;
         else          else
                 n->flags &= ~NODE_NOFILL;                  n->flags &= ~NODE_NOFILL;
Line 2537  roff_evalcond(struct roff *r, int ln, char *v, int *po
Line 2537  roff_evalcond(struct roff *r, int ln, char *v, int *po
                         roff_getstrn(r, name, sz, &deftype);                          roff_getstrn(r, name, sz, &deftype);
                         istrue = !!deftype;                          istrue = !!deftype;
                 }                  }
                 *pos = cp - v;                  *pos = (name + sz) - v;
                 return istrue == wanttrue;                  return istrue == wanttrue;
         default:          default:
                 break;                  break;
Line 2683  roff_ds(ROFF_ARGS)
Line 2683  roff_ds(ROFF_ARGS)
                 return ROFF_IGN;                  return ROFF_IGN;
   
         namesz = roff_getname(r, &string, ln, pos);          namesz = roff_getname(r, &string, ln, pos);
         if (name[namesz] == '\\')          switch (name[namesz]) {
           case '\\':
                 return ROFF_IGN;                  return ROFF_IGN;
           case '\t':
                   string = buf->buf + pos + namesz;
                   break;
           default:
                   break;
           }
   
         /* Read past the initial double-quote, if any. */          /* Read past the initial double-quote, if any. */
         if (*string == '"')          if (*string == '"')
Line 3060  roff_nr(ROFF_ARGS)
Line 3067  roff_nr(ROFF_ARGS)
                 return ROFF_IGN;                  return ROFF_IGN;
   
         keysz = roff_getname(r, &val, ln, pos);          keysz = roff_getname(r, &val, ln, pos);
         if (key[keysz] == '\\')          if (key[keysz] == '\\' || key[keysz] == '\t')
                 return ROFF_IGN;                  return ROFF_IGN;
   
         sign = *val;          sign = *val;
Line 3124  roff_rm(ROFF_ARGS)
Line 3131  roff_rm(ROFF_ARGS)
                 namesz = roff_getname(r, &cp, ln, (int)(cp - buf->buf));                  namesz = roff_getname(r, &cp, ln, (int)(cp - buf->buf));
                 roff_setstrn(&r->strtab, name, namesz, NULL, 0, 0);                  roff_setstrn(&r->strtab, name, namesz, NULL, 0, 0);
                 roff_setstrn(&r->rentab, name, namesz, NULL, 0, 0);                  roff_setstrn(&r->rentab, name, namesz, NULL, 0, 0);
                 if (name[namesz] == '\\')                  if (name[namesz] == '\\' || name[namesz] == '\t')
                         break;                          break;
         }          }
         return ROFF_IGN;          return ROFF_IGN;
Line 3192  roff_Dd(ROFF_ARGS)
Line 3199  roff_Dd(ROFF_ARGS)
 static int  static int
 roff_TE(ROFF_ARGS)  roff_TE(ROFF_ARGS)
 {  {
           r->man->flags &= ~ROFF_NONOFILL;
         if (r->tbl == NULL) {          if (r->tbl == NULL) {
                 mandoc_msg(MANDOCERR_BLK_NOTOPEN, ln, ppos, "TE");                  mandoc_msg(MANDOCERR_BLK_NOTOPEN, ln, ppos, "TE");
                 return ROFF_IGN;                  return ROFF_IGN;
Line 3336  roff_TS(ROFF_ARGS)
Line 3344  roff_TS(ROFF_ARGS)
                 mandoc_msg(MANDOCERR_BLK_BROKEN, ln, ppos, "TS breaks TS");                  mandoc_msg(MANDOCERR_BLK_BROKEN, ln, ppos, "TS breaks TS");
                 tbl_end(r->tbl, 0);                  tbl_end(r->tbl, 0);
         }          }
           r->man->flags |= ROFF_NONOFILL;
         r->tbl = tbl_alloc(ppos, ln, r->last_tbl);          r->tbl = tbl_alloc(ppos, ln, r->last_tbl);
         if (r->last_tbl == NULL)          if (r->last_tbl == NULL)
                 r->first_tbl = r->tbl;                  r->first_tbl = r->tbl;
Line 3457  roff_als(ROFF_ARGS)
Line 3466  roff_als(ROFF_ARGS)
                 return ROFF_IGN;                  return ROFF_IGN;
   
         newsz = roff_getname(r, &oldn, ln, pos);          newsz = roff_getname(r, &oldn, ln, pos);
         if (newn[newsz] == '\\' || *oldn == '\0')          if (newn[newsz] == '\\' || newn[newsz] == '\t' || *oldn == '\0')
                 return ROFF_IGN;                  return ROFF_IGN;
   
         end = oldn;          end = oldn;
Line 3687  roff_rn(ROFF_ARGS)
Line 3696  roff_rn(ROFF_ARGS)
                 return ROFF_IGN;                  return ROFF_IGN;
   
         oldsz = roff_getname(r, &newn, ln, pos);          oldsz = roff_getname(r, &newn, ln, pos);
         if (oldn[oldsz] == '\\' || *newn == '\0')          if (oldn[oldsz] == '\\' || oldn[oldsz] == '\t' || *newn == '\0')
                 return ROFF_IGN;                  return ROFF_IGN;
   
         end = newn;          end = newn;
Line 3863  roff_renamed(ROFF_ARGS)
Line 3872  roff_renamed(ROFF_ARGS)
         return ROFF_CONT;          return ROFF_CONT;
 }  }
   
   /*
    * Measure the length in bytes of the roff identifier at *cpp
    * and advance the pointer to the next word.
    */
 static size_t  static size_t
 roff_getname(struct roff *r, char **cpp, int ln, int pos)  roff_getname(struct roff *r, char **cpp, int ln, int pos)
 {  {
Line 3870  roff_getname(struct roff *r, char **cpp, int ln, int p
Line 3883  roff_getname(struct roff *r, char **cpp, int ln, int p
         size_t    namesz;          size_t    namesz;
   
         name = *cpp;          name = *cpp;
         if ('\0' == *name)          if (*name == '\0')
                 return 0;                  return 0;
   
         /* Read until end of name and terminate it with NUL. */          /* Advance cp to the byte after the end of the name. */
   
         for (cp = name; 1; cp++) {          for (cp = name; 1; cp++) {
                 if ('\0' == *cp || ' ' == *cp) {                  namesz = cp - name;
                         namesz = cp - name;                  if (*cp == '\0')
                         break;                          break;
                   if (*cp == ' ' || *cp == '\t') {
                           cp++;
                           break;
                 }                  }
                 if ('\\' != *cp)                  if (*cp != '\\')
                         continue;                          continue;
                 namesz = cp - name;                  if (cp[1] == '{' || cp[1] == '}')
                 if ('{' == cp[1] || '}' == cp[1])  
                         break;                          break;
                 cp++;                  if (*++cp == '\\')
                 if ('\\' == *cp)  
                         continue;                          continue;
                 mandoc_msg(MANDOCERR_NAMESC, ln, pos,                  mandoc_msg(MANDOCERR_NAMESC, ln, pos,
                     "%.*s", (int)(cp - name + 1), name);                      "%.*s", (int)(cp - name + 1), name);
Line 3894  roff_getname(struct roff *r, char **cpp, int ln, int p
Line 3909  roff_getname(struct roff *r, char **cpp, int ln, int p
         }          }
   
         /* Read past spaces. */          /* Read past spaces. */
         while (' ' == *cp)  
           while (*cp == ' ')
                 cp++;                  cp++;
   
         *cpp = cp;          *cpp = cp;

Legend:
Removed from v.1.359  
changed lines
  Added in v.1.363

CVSweb