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

Diff for /mandoc/tbl_layout.c between version 1.49 and 1.51

version 1.49, 2020/09/01 18:25:28 version 1.51, 2025/01/05 18:14:39
Line 1 
Line 1 
 /*      $Id$ */  /*      $Id$ */
 /*  /*
    * Copyright (c) 2012, 2014, 2015, 2017, 2020, 2021, 2025
    *               Ingo Schwarze <schwarze@openbsd.org>
  * Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>   * Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
  * Copyright (c) 2012, 2014, 2015, 2017 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 66  mods(struct tbl_node *tbl, struct tbl_cell *cp,
Line 67  mods(struct tbl_node *tbl, struct tbl_cell *cp,
 {  {
         char            *endptr;          char            *endptr;
         unsigned long    spacing;          unsigned long    spacing;
         size_t           sz;          int              isz;
           enum mandoc_esc  fontesc;
   
 mod:  mod:
         while (p[*pos] == ' ' || p[*pos] == '\t')          while (p[*pos] == ' ' || p[*pos] == '\t')
Line 105  mod:
Line 107  mod:
   
         switch (tolower((unsigned char)p[(*pos)++])) {          switch (tolower((unsigned char)p[(*pos)++])) {
         case 'b':          case 'b':
                 cp->flags |= TBL_CELL_BOLD;                  cp->font = ESCAPE_FONTBOLD;
                 goto mod;                  goto mod;
         case 'd':          case 'd':
                 cp->flags |= TBL_CELL_BALIGN;                  cp->flags |= TBL_CELL_BALIGN;
Line 116  mod:
Line 118  mod:
         case 'f':          case 'f':
                 break;                  break;
         case 'i':          case 'i':
                 cp->flags |= TBL_CELL_ITALIC;                  cp->font = ESCAPE_FONTITALIC;
                 goto mod;                  goto mod;
         case 'm':          case 'm':
                 mandoc_msg(MANDOCERR_TBLLAYOUT_MOD, ln, *pos, "m");                  mandoc_msg(MANDOCERR_TBLLAYOUT_MOD, ln, *pos, "m");
Line 135  mod:
Line 137  mod:
                 cp->flags |= TBL_CELL_UP;                  cp->flags |= TBL_CELL_UP;
                 goto mod;                  goto mod;
         case 'w':          case 'w':
                 sz = 0;  
                 if (p[*pos] == '(') {                  if (p[*pos] == '(') {
                         (*pos)++;                          (*pos)++;
                         while (p[*pos + sz] != '\0' && p[*pos + sz] != ')')                          isz = 0;
                                 sz++;                          if (roff_evalnum(ln, p, pos, &isz, 'n', 1) == 0 ||
                 } else                              p[*pos] != ')')
                         while (isdigit((unsigned char)p[*pos + sz]))                                  mandoc_msg(MANDOCERR_TBLLAYOUT_WIDTH,
                                 sz++;                                      ln, *pos, "%s", p + *pos);
                 if (sz) {                          else {
                         free(cp->wstr);                                  /* Convert from BU to EN and round. */
                         cp->wstr = mandoc_strndup(p + *pos, sz);                                  cp->width = (isz + 11) /24;
                         *pos += sz;  
                         if (p[*pos] == ')')  
                                 (*pos)++;                                  (*pos)++;
                           }
                   } else {
                           cp->width = 0;
                           while (isdigit((unsigned char)p[*pos])) {
                                   cp->width *= 10;
                                   cp->width += p[(*pos)++] - '0';
                           }
                           if (cp->width == 0)
                                   mandoc_msg(MANDOCERR_TBLLAYOUT_WIDTH,
                                       ln, *pos, "%s", p + *pos);
                 }                  }
                 goto mod;                  goto mod;
         case 'x':          case 'x':
Line 170  mod:
Line 179  mod:
                 goto mod;                  goto mod;
         }          }
   
           while (p[*pos] == ' ' || p[*pos] == '\t')
                   (*pos)++;
   
         /* Ignore parenthised font names for now. */          /* Ignore parenthised font names for now. */
   
         if (p[*pos] == '(')          if (p[*pos] == '(')
                 goto mod;                  goto mod;
   
         /* Support only one-character font-names for now. */          isz = 0;
           if (p[*pos] != '\0')
                   isz++;
           if (strchr(" \t.", p[*pos + isz]) == NULL)
                   isz++;
   
           fontesc = mandoc_font(p + *pos, isz);
   
         if (p[*pos] == '\0' || (p[*pos + 1] != ' ' && p[*pos + 1] != '.')) {          switch (fontesc) {
           case ESCAPE_FONTPREV:
           case ESCAPE_ERROR:
                 mandoc_msg(MANDOCERR_FT_BAD,                  mandoc_msg(MANDOCERR_FT_BAD,
                     ln, *pos, "TS %s", p + *pos - 1);                      ln, *pos, "TS %s", p + *pos - 1);
                 if (p[*pos] != '\0')                  break;
                         (*pos)++;  
                 if (p[*pos] != '\0')  
                         (*pos)++;  
                 goto mod;  
         }  
   
         switch (p[(*pos)++]) {  
         case '3':  
         case 'B':  
                 cp->flags |= TBL_CELL_BOLD;  
                 goto mod;  
         case '2':  
         case 'I':  
                 cp->flags |= TBL_CELL_ITALIC;  
                 goto mod;  
         case '1':  
         case 'R':  
                 goto mod;  
         default:          default:
                 mandoc_msg(MANDOCERR_FT_BAD,                  cp->font = fontesc;
                     ln, *pos - 1, "TS f%c", p[*pos - 1]);                  break;
                 goto mod;  
         }          }
           *pos += isz;
           goto mod;
 }  }
   
 static void  static void
Line 362  cell_alloc(struct tbl_node *tbl, struct tbl_row *rp, e
Line 365  cell_alloc(struct tbl_node *tbl, struct tbl_row *rp, e
   
         p = mandoc_calloc(1, sizeof(*p));          p = mandoc_calloc(1, sizeof(*p));
         p->spacing = SIZE_MAX;          p->spacing = SIZE_MAX;
           p->font = ESCAPE_FONTROMAN;
         p->pos = pos;          p->pos = pos;
   
         if ((pp = rp->last) != NULL) {          if ((pp = rp->last) != NULL) {

Legend:
Removed from v.1.49  
changed lines
  Added in v.1.51

CVSweb