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

Diff for /mandoc/tbl_term.c between version 1.11 and 1.14

version 1.11, 2011/01/05 15:37:23 version 1.14, 2011/01/08 17:00:27
Line 27 
Line 27 
 #include "out.h"  #include "out.h"
 #include "term.h"  #include "term.h"
   
 /* FIXME: `n' modifier doesn't always do the right thing. */  
 /* FIXME: `n' modifier doesn't use the cell-spacing buffer. */  
   
 static  size_t  term_tbl_len(size_t, void *);  static  size_t  term_tbl_len(size_t, void *);
 static  size_t  term_tbl_strlen(const char *, void *);  static  size_t  term_tbl_strlen(const char *, void *);
 static  void    tbl_char(struct termp *, char, int);  static  void    tbl_char(struct termp *, char, size_t);
 static  void    tbl_data(struct termp *, const struct tbl *,  static  void    tbl_data(struct termp *, const struct tbl *,
                         const struct tbl_dat *,                          const struct tbl_dat *,
                         const struct roffcol *);                          const struct roffcol *);
Line 67  term_tbl(struct termp *tp, const struct tbl_span *sp)
Line 64  term_tbl(struct termp *tp, const struct tbl_span *sp)
         const struct tbl_head   *hp;          const struct tbl_head   *hp;
         const struct tbl_dat    *dp;          const struct tbl_dat    *dp;
         struct roffcol          *col;          struct roffcol          *col;
         int                      rmargin, maxrmargin;          size_t                   rmargin, maxrmargin;
   
         rmargin = tp->rmargin;          rmargin = tp->rmargin;
         maxrmargin = tp->maxrmargin;          maxrmargin = tp->maxrmargin;
Line 165  tbl_hrule(struct termp *tp, const struct tbl_span *sp)
Line 162  tbl_hrule(struct termp *tp, const struct tbl_span *sp)
 {  {
         const struct tbl_head *hp;          const struct tbl_head *hp;
         char             c;          char             c;
         int              width;          size_t           width;
   
         /*          /*
          * An hrule extends across the entire table and is demarked by a           * An hrule extends across the entire table and is demarked by a
Line 202  static void
Line 199  static void
 tbl_hframe(struct termp *tp, const struct tbl_span *sp)  tbl_hframe(struct termp *tp, const struct tbl_span *sp)
 {  {
         const struct tbl_head *hp;          const struct tbl_head *hp;
         int              width;          size_t           width;
   
         if ( ! (TBL_OPT_BOX & sp->tbl->opts ||          if ( ! (TBL_OPT_BOX & sp->tbl->opts ||
                         TBL_OPT_DBOX & sp->tbl->opts))                          TBL_OPT_DBOX & sp->tbl->opts))
Line 272  tbl_data(struct termp *tp, const struct tbl *tbl,
Line 269  tbl_data(struct termp *tp, const struct tbl *tbl,
                 break;                  break;
         }          }
   
         pos = dp->layout ? dp->layout->pos : TBL_CELL_LEFT;          pos = dp && dp->layout ? dp->layout->pos : TBL_CELL_LEFT;
   
         switch (pos) {          switch (pos) {
         case (TBL_CELL_HORIZ):          case (TBL_CELL_HORIZ):
Line 324  tbl_vframe(struct termp *tp, const struct tbl *tbl)
Line 321  tbl_vframe(struct termp *tp, const struct tbl *tbl)
 }  }
   
 static void  static void
 tbl_char(struct termp *tp, char c, int len)  tbl_char(struct termp *tp, char c, size_t len)
 {  {
         int             i, sz;          size_t          i, sz;
         const char      cp[2] = {c, '\0'};          char            cp[2];
   
           cp[0] = c;
           cp[1] = '\0';
   
         sz = term_strlen(tp, cp);          sz = term_strlen(tp, cp);
   
         for (i = 0; i < len; i += sz)          for (i = 0; i < len; i += sz)
Line 339  static void
Line 339  static void
 tbl_literal(struct termp *tp, const struct tbl_dat *dp,  tbl_literal(struct termp *tp, const struct tbl_dat *dp,
                 const struct roffcol *col)                  const struct roffcol *col)
 {  {
         int              padl, padr, ssz;          size_t           padl, padr, ssz;
         enum tbl_cellt   pos;          enum tbl_cellt   pos;
           const char      *str;
   
         padl = padr = 0;          padl = padr = 0;
   
         pos = dp->layout ? dp->layout->pos : TBL_CELL_LEFT;          pos = dp && dp->layout ? dp->layout->pos : TBL_CELL_LEFT;
           str = dp && dp->string ? dp->string : "";
   
         ssz = term_len(tp, 1);          ssz = term_len(tp, 1);
   
         switch (pos) {          switch (pos) {
         case (TBL_CELL_LONG):          case (TBL_CELL_LONG):
                 padl = ssz;                  padl = ssz;
                 padr = col->width - term_strlen(tp, dp->string) - ssz;                  padr = col->width - term_strlen(tp, str) - ssz;
                 break;                  break;
         case (TBL_CELL_CENTRE):          case (TBL_CELL_CENTRE):
                 padl = col->width - term_strlen(tp, dp->string);                  padl = col->width - term_strlen(tp, str);
                 if (padl % 2)                  if (padl % 2)
                         padr++;                          padr++;
                 padl /= 2;                  padl /= 2;
                 padr += padl;                  padr += padl;
                 break;                  break;
         case (TBL_CELL_RIGHT):          case (TBL_CELL_RIGHT):
                 padl = col->width - term_strlen(tp, dp->string);                  padl = col->width - term_strlen(tp, str);
                 break;                  break;
         default:          default:
                 padr = col->width - term_strlen(tp, dp->string);                  padr = col->width - term_strlen(tp, str);
                 break;                  break;
         }          }
   
         tbl_char(tp, ASCII_NBRSP, padl);          tbl_char(tp, ASCII_NBRSP, padl);
         term_word(tp, dp->string);          term_word(tp, str);
         tbl_char(tp, ASCII_NBRSP, padr);          tbl_char(tp, ASCII_NBRSP, padr);
 }  }
   
Line 388  tbl_number(struct termp *tp, const struct tbl *tbl,
Line 391  tbl_number(struct termp *tp, const struct tbl *tbl,
          * and the maximum decimal; right-pad by the remaining amount.           * and the maximum decimal; right-pad by the remaining amount.
          */           */
   
         str = "";          str = dp && dp->string ? dp->string : "";
         if (dp->string)  
                 str = dp->string;  
   
         sz = term_strlen(tp, str);          sz = term_strlen(tp, str);
   
Line 415  tbl_number(struct termp *tp, const struct tbl *tbl,
Line 416  tbl_number(struct termp *tp, const struct tbl *tbl,
         padl = col->decimal - d;          padl = col->decimal - d;
   
         tbl_char(tp, ASCII_NBRSP, padl);          tbl_char(tp, ASCII_NBRSP, padl);
         term_word(tp, dp->string);          term_word(tp, str);
         tbl_char(tp, ASCII_NBRSP, col->width - sz - padl);          tbl_char(tp, ASCII_NBRSP, col->width - sz - padl);
 }  }
   

Legend:
Removed from v.1.11  
changed lines
  Added in v.1.14

CVSweb