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

Diff for /mandoc/roff.c between version 1.395 and 1.399

version 1.395, 2022/08/16 17:30:11 version 1.399, 2023/10/23 20:25:02
Line 1 
Line 1 
 /* $Id$ */  /* $Id$ */
 /*  /*
  * Copyright (c) 2010-2015, 2017-2022 Ingo Schwarze <schwarze@openbsd.org>   * Copyright (c) 2010-2015, 2017-2023 Ingo Schwarze <schwarze@openbsd.org>
  * Copyright (c) 2008-2012, 2014 Kristaps Dzonsons <kristaps@bsd.lv>   * Copyright (c) 2008-2012, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
  *   *
  * Permission to use, copy, modify, and distribute this software for any   * Permission to use, copy, modify, and distribute this software for any
Line 1362  roff_expand(struct roff *r, struct buf *buf, int ln, i
Line 1362  roff_expand(struct roff *r, struct buf *buf, int ln, i
         const char      *res;           /* the string to be pasted */          const char      *res;           /* the string to be pasted */
         const char      *src;           /* source for copying */          const char      *src;           /* source for copying */
         char            *dst;           /* destination for copying */          char            *dst;           /* destination for copying */
           enum mandoc_esc  subtype;       /* return value from roff_escape */
         int              iesc;          /* index of leading escape char */          int              iesc;          /* index of leading escape char */
         int              inam;          /* index of the escape name */          int              inam;          /* index of the escape name */
         int              iarg;          /* index beginning the argument */          int              iarg;          /* index beginning the argument */
Line 1387  roff_expand(struct roff *r, struct buf *buf, int ln, i
Line 1388  roff_expand(struct roff *r, struct buf *buf, int ln, i
                  */                   */
   
                 if (buf->buf[pos] != ec) {                  if (buf->buf[pos] != ec) {
                         if (ec != ASCII_ESC && buf->buf[pos] == '\\') {                          if (buf->buf[pos] == '\\') {
                                 roff_expand_patch(buf, pos, "\\e", pos + 1);                                  roff_expand_patch(buf, pos, "\\e", pos + 1);
                                 pos++;                                  pos++;
                         }                          }
Line 1449  roff_expand(struct roff *r, struct buf *buf, int ln, i
Line 1450  roff_expand(struct roff *r, struct buf *buf, int ln, i
                                 break;                                  break;
   
                         /*                          /*
                          * If not overriden,                           * If not overridden,
                          * let \*(.T through to the formatters.                           * let \*(.T through to the formatters.
                          */                           */
   
Line 1551  roff_expand(struct roff *r, struct buf *buf, int ln, i
Line 1552  roff_expand(struct roff *r, struct buf *buf, int ln, i
                         res = ubuf;                          res = ubuf;
                         break;                          break;
                 case 'w':                  case 'w':
                         (void)snprintf(ubuf, sizeof(ubuf),                          rsz = 0;
                             "%d", (iendarg - iarg) * 24);                          subtype = ESCAPE_UNDEF;
                           while (iarg < iendarg) {
                                   asz = subtype == ESCAPE_SKIPCHAR ? 0 : 1;
                                   if (buf->buf[iarg] != '\\') {
                                           rsz += asz;
                                           iarg++;
                                           continue;
                                   }
                                   switch ((subtype = roff_escape(buf->buf, 0,
                                       iarg, NULL, NULL, NULL, NULL, &iarg))) {
                                   case ESCAPE_SPECIAL:
                                   case ESCAPE_NUMBERED:
                                   case ESCAPE_UNICODE:
                                   case ESCAPE_OVERSTRIKE:
                                   case ESCAPE_UNDEF:
                                           break;
                                   case ESCAPE_DEVICE:
                                           asz *= 8;
                                           break;
                                   case ESCAPE_EXPAND:
                                           abort();
                                   default:
                                           continue;
                                   }
                                   rsz += asz;
                           }
                           (void)snprintf(ubuf, sizeof(ubuf), "%d", rsz * 24);
                         res = ubuf;                          res = ubuf;
                         break;                          break;
                 default:                  default:
Line 1632  roff_getarg(struct roff *r, char **cpp, int ln, int *p
Line 1659  roff_getarg(struct roff *r, char **cpp, int ln, int *p
                                 cp++;                                  cp++;
                                 break;                                  break;
                         case '\\':                          case '\\':
                                 /*                                  cp[-pairs] = '\\';
                                  * Signal to roff_expand() that an escape  
                                  * sequence resulted from copy-in processing  
                                  * and needs to be checked or interpolated.  
                                  */  
                                 cp[-pairs] = ASCII_ESC;  
                                 newesc = 1;                                  newesc = 1;
                                 pairs++;                                  pairs++;
                                 cp++;                                  cp++;
Line 1694  roff_getarg(struct roff *r, char **cpp, int ln, int *p
Line 1716  roff_getarg(struct roff *r, char **cpp, int ln, int *p
         buf.buf = start;          buf.buf = start;
         buf.sz = strlen(start) + 1;          buf.sz = strlen(start) + 1;
         buf.next = NULL;          buf.next = NULL;
         if (roff_expand(r, &buf, ln, 0, ASCII_ESC) & ROFF_IGN) {          if (roff_expand(r, &buf, ln, 0, '\\') == ROFF_IGN) {
                 free(buf.buf);                  free(buf.buf);
                 buf.buf = mandoc_strdup("");                  buf.buf = mandoc_strdup("");
         }          }
Line 2479  roff_getnum(const char *v, int *pos, int *res, int fla
Line 2501  roff_getnum(const char *v, int *pos, int *res, int fla
  * Evaluate a string comparison condition.   * Evaluate a string comparison condition.
  * The first character is the delimiter.   * The first character is the delimiter.
  * Succeed if the string up to its second occurrence   * Succeed if the string up to its second occurrence
  * matches the string up to its third occurence.   * matches the string up to its third occurrence.
  * Advance the cursor after the third occurrence   * Advance the cursor after the third occurrence
  * or lacking that, to the end of the line.   * or lacking that, to the end of the line.
  */   */
Line 4371  roff_getformat(const struct roff *r)
Line 4393  roff_getformat(const struct roff *r)
  * return zero and don't change the current position.   * return zero and don't change the current position.
  * If the control character has been set with `.cc', then let that grain   * If the control character has been set with `.cc', then let that grain
  * precedence.   * precedence.
  * This is slighly contrary to groff, where using the non-breaking   * This is slightly contrary to groff, where using the non-breaking
  * control character when `cc' has been invoked will cause the   * control character when `cc' has been invoked will cause the
  * non-breaking macro contents to be printed verbatim.   * non-breaking macro contents to be printed verbatim.
  */   */

Legend:
Removed from v.1.395  
changed lines
  Added in v.1.399

CVSweb