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

Diff for /mandoc/roff.c between version 1.388 and 1.392

version 1.388, 2022/05/19 15:37:47 version 1.392, 2022/06/02 11:29:07
Line 1410  roff_expand(struct roff *r, struct buf *buf, int ln, i
Line 1410  roff_expand(struct roff *r, struct buf *buf, int ln, i
                  * it to backslashes and translate backslashes to \e.                   * it to backslashes and translate backslashes to \e.
                  */                   */
   
                 if (roff_escape(buf->buf, ln, pos,                  if (roff_escape(buf->buf, ln, pos, &iesc, &inam,
                     &iesc, &iarg, &iendarg, &iend) != ESCAPE_EXPAND) {                      &iarg, &iendarg, &iend) != ESCAPE_EXPAND) {
                         while (pos < iend) {                          while (pos < iend) {
                                 if (buf->buf[pos] == ec) {                                  if (buf->buf[pos] == ec) {
                                         buf->buf[pos] = '\\';                                          buf->buf[pos] = '\\';
Line 1428  roff_expand(struct roff *r, struct buf *buf, int ln, i
Line 1428  roff_expand(struct roff *r, struct buf *buf, int ln, i
                         continue;                          continue;
                 }                  }
   
                 /*  
                  * Treat "\E" just like "\";  
                  * it only makes a difference in copy mode.  
                  */  
   
                 inam = iesc + 1;  
                 while (buf->buf[inam] == 'E')  
                         inam++;  
   
                 /* Handle expansion. */                  /* Handle expansion. */
   
                 res = NULL;                  res = NULL;
Line 1520  roff_expand(struct roff *r, struct buf *buf, int ln, i
Line 1511  roff_expand(struct roff *r, struct buf *buf, int ln, i
                                         *dst++ = '"';                                          *dst++ = '"';
                         }                          }
                         continue;                          continue;
                   case 'A':
                           ubuf[0] = iendarg > iarg ? '1' : '0';
                           ubuf[1] = '\0';
                           res = ubuf;
                           break;
                 case 'B':                  case 'B':
                         npos = 0;                          npos = 0;
                         ubuf[0] = iendarg > iarg && iend > iendarg &&                          ubuf[0] = iendarg > iarg && iend > iendarg &&
Line 1529  roff_expand(struct roff *r, struct buf *buf, int ln, i
Line 1525  roff_expand(struct roff *r, struct buf *buf, int ln, i
                         ubuf[1] = '\0';                          ubuf[1] = '\0';
                         res = ubuf;                          res = ubuf;
                         break;                          break;
                   case 'V':
                           mandoc_msg(MANDOCERR_UNSUPP, ln, iesc,
                               "%.*s", iend - iesc, buf->buf + iesc);
                           roff_expand_patch(buf, iendarg, "}", iend);
                           roff_expand_patch(buf, iesc, "${", iarg);
                           continue;
                   case 'g':
                           break;
                 case 'n':                  case 'n':
                         if (iendarg > iarg)                          if (iendarg > iarg)
                                 (void)snprintf(ubuf, sizeof(ubuf), "%d",                                  (void)snprintf(ubuf, sizeof(ubuf), "%d",
Line 1567  roff_expand_patch(struct buf *buf, int start, const ch
Line 1571  roff_expand_patch(struct buf *buf, int start, const ch
 {  {
         char    *nbuf;          char    *nbuf;
   
         buf->buf[start] = '\0';          buf->sz = mandoc_asprintf(&nbuf, "%.*s%s%s", start, buf->buf,
         buf->sz = mandoc_asprintf(&nbuf, "%s%s%s", buf->buf, repl,              repl, buf->buf + end) + 1;
             buf->buf + end) + 1;  
         free(buf->buf);          free(buf->buf);
         buf->buf = nbuf;          buf->buf = nbuf;
 }  }

Legend:
Removed from v.1.388  
changed lines
  Added in v.1.392

CVSweb