[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.4 and 1.9

version 1.4, 2011/01/03 14:57:04 version 1.9, 2011/01/04 13:21:45
Line 40  static void   tbl_data_number(struct termp *, 
Line 40  static void   tbl_data_number(struct termp *, 
 static  void             tbl_data_literal(struct termp *,  static  void             tbl_data_literal(struct termp *,
                                 const struct tbl_dat *,                                  const struct tbl_dat *,
                                 const struct termp_tbl *);                                  const struct termp_tbl *);
 static  void             tbl_data_spanner(struct termp *,  
                                 const struct tbl_dat *,  
                                 const struct termp_tbl *);  
 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 termp_tbl *);                                  const struct termp_tbl *);
Line 209  tbl_hframe(struct termp *tp, const struct tbl_span *sp
Line 206  tbl_hframe(struct termp *tp, const struct tbl_span *sp
                         TBL_OPT_DBOX & sp->tbl->opts))                          TBL_OPT_DBOX & sp->tbl->opts))
                 return;                  return;
   
         tp->flags |= TERMP_NONOSPACE;  
         tp->flags |= TERMP_NOSPACE;  
   
         /*          /*
          * Print out the horizontal part of a frame or double frame.  A           * Print out the horizontal part of a frame or double frame.  A
          * double frame has an unbroken `-' outer line the width of the           * double frame has an unbroken `-' outer line the width of the
Line 261  tbl_data(struct termp *tp, const struct tbl *tbl,
Line 255  tbl_data(struct termp *tp, const struct tbl *tbl,
         switch (dp->pos) {          switch (dp->pos) {
         case (TBL_DATA_HORIZ):          case (TBL_DATA_HORIZ):
                 /* FALLTHROUGH */                  /* FALLTHROUGH */
           case (TBL_DATA_NHORIZ):
                   tbl_char(tp, '-', tbp->width);
                   return;
           case (TBL_DATA_NDHORIZ):
                   /* FALLTHROUGH */
         case (TBL_DATA_DHORIZ):          case (TBL_DATA_DHORIZ):
                 tbl_data_spanner(tp, dp, tbp);                  tbl_char(tp, '=', tbp->width);
                 return;                  return;
         default:          default:
                 break;                  break;
Line 272  tbl_data(struct termp *tp, const struct tbl *tbl,
Line 271  tbl_data(struct termp *tp, const struct tbl *tbl,
   
         switch (pos) {          switch (pos) {
         case (TBL_CELL_HORIZ):          case (TBL_CELL_HORIZ):
                 /* FALLTHROUGH */                  tbl_char(tp, '-', tbp->width);
                   break;
         case (TBL_CELL_DHORIZ):          case (TBL_CELL_DHORIZ):
                 tbl_data_spanner(tp, dp, tbp);                  tbl_char(tp, '=', tbp->width);
                 break;                  break;
         case (TBL_CELL_LONG):          case (TBL_CELL_LONG):
                 /* FALLTHROUGH */                  /* FALLTHROUGH */
Line 318  tbl_vframe(struct termp *tp, const struct tbl *tbl)
Line 318  tbl_vframe(struct termp *tp, const struct tbl *tbl)
                 term_word(tp, "|");                  term_word(tp, "|");
 }  }
   
   
 static inline void  static inline void
 tbl_char(struct termp *tp, char c, int len)  tbl_char(struct termp *tp, char c, int len)
 {  {
Line 335  tbl_char(struct termp *tp, char c, int len)
Line 334  tbl_char(struct termp *tp, char c, int len)
 }  }
   
 static void  static void
 tbl_data_spanner(struct termp *tp,  
                 const struct tbl_dat *dp,  
                 const struct termp_tbl *tblp)  
 {  
   
         switch (dp->pos) {  
         case (TBL_DATA_HORIZ):  
         case (TBL_DATA_NHORIZ):  
                 tbl_char(tp, '-', tblp->width);  
                 break;  
         case (TBL_DATA_DHORIZ):  
         case (TBL_DATA_NDHORIZ):  
                 tbl_char(tp, '=', tblp->width);  
                 break;  
         default:  
                 break;  
         }  
 }  
   
 static void  
 tbl_data_literal(struct termp *tp,  tbl_data_literal(struct termp *tp,
                 const struct tbl_dat *dp,                  const struct tbl_dat *dp,
                 const struct termp_tbl *tblp)                  const struct termp_tbl *tblp)
Line 397  tbl_data_number(struct termp *tp, const struct tbl *tb
Line 376  tbl_data_number(struct termp *tp, const struct tbl *tb
                 const struct tbl_dat *dp,                  const struct tbl_dat *dp,
                 const struct termp_tbl *tblp)                  const struct termp_tbl *tblp)
 {  {
         char            *decp;          char            *decp, buf[2];
         int              d, padl, sz;          int              d, padl, sz, psz, ssz, i;
   
         /*          /*
          * See calc_data_number().  Left-pad by taking the offset of our           * See calc_data_number().  Left-pad by taking the offset of our
          * and the maximum decimal; right-pad by the remaining amount.           * and the maximum decimal; right-pad by the remaining amount.
          */           */
   
         sz = (int)strlen(dp->string);          sz = term_strlen(tp, dp->string);
           psz = term_strlen(tp, ".");
   
         if (NULL == (decp = strchr(dp->string, tbl->decimal))) {          if (NULL != (decp = strchr(dp->string, tbl->decimal))) {
                 d = sz + 1;                  buf[1] = '\0';
         } else {                  for (ssz = i = 0; decp != &dp->string[i]; i++) {
                 d = (int)(decp - dp->string) + 1;                          buf[0] = dp->string[i];
         }                          ssz += term_strlen(tp, buf);
                   }
                   d = ssz + psz;
           } else
                   d = sz + psz;
   
         assert(d <= tblp->decimal);          assert(d <= tblp->decimal);
         assert(sz - d <= tblp->width - tblp->decimal);          assert(sz - d <= tblp->width - tblp->decimal);
   
         padl = tblp->decimal - d + 1;          padl = tblp->decimal - d + term_len(tp, 1);
         assert(tblp->width - sz - padl);          assert(tblp->width - sz - padl);
   
         tbl_char(tp, ASCII_NBRSP, padl);          tbl_char(tp, ASCII_NBRSP, padl);
Line 471  static void
Line 455  static void
 tbl_calc_data(struct termp *tp, const struct tbl *tbl,  tbl_calc_data(struct termp *tp, const struct tbl *tbl,
                 const struct tbl_dat *dp, struct termp_tbl *tblp)                  const struct tbl_dat *dp, struct termp_tbl *tblp)
 {  {
           int              sz;
   
         /* Branch down into data sub-types. */          /* Branch down into data sub-types. */
   
Line 478  tbl_calc_data(struct termp *tp, const struct tbl *tbl,
Line 463  tbl_calc_data(struct termp *tp, const struct tbl *tbl,
         case (TBL_CELL_HORIZ):          case (TBL_CELL_HORIZ):
                 /* FALLTHROUGH */                  /* FALLTHROUGH */
         case (TBL_CELL_DHORIZ):          case (TBL_CELL_DHORIZ):
                 tblp->width = 1;                  sz = term_len(tp, 1);
                   if (tblp->width < sz)
                           tblp->width = sz;
                 break;                  break;
         case (TBL_CELL_LONG):          case (TBL_CELL_LONG):
                 /* FALLTHROUGH */                  /* FALLTHROUGH */
Line 502  static void
Line 489  static void
 tbl_calc_data_number(struct termp *tp, const struct tbl *tbl,  tbl_calc_data_number(struct termp *tp, const struct tbl *tbl,
                 const struct tbl_dat *dp, struct termp_tbl *tblp)                  const struct tbl_dat *dp, struct termp_tbl *tblp)
 {  {
         int              sz, d;          int              sz, d, psz, i, ssz;
         char            *cp;          char            *cp, buf[2];
   
         /*          /*
          * First calculate number width and decimal place (last + 1 for           * First calculate number width and decimal place (last + 1 for
Line 517  tbl_calc_data_number(struct termp *tp, const struct tb
Line 504  tbl_calc_data_number(struct termp *tp, const struct tb
         /* TODO: use spacing modifier. */          /* TODO: use spacing modifier. */
   
         assert(dp->string);          assert(dp->string);
         sz = (int)strlen(dp->string);          sz = term_strlen(tp, dp->string);
           psz = term_strlen(tp, ".");
   
         if (NULL == (cp = strchr(dp->string, tbl->decimal)))          if (NULL != (cp = strchr(dp->string, tbl->decimal))) {
                 d = sz + 1;                  buf[1] = '\0';
         else                  for (ssz = i = 0; cp != &dp->string[i]; i++) {
                 d = (int)(cp - dp->string) + 1;                          buf[0] = dp->string[i];
                           ssz += term_strlen(tp, buf);
                   }
                   d = ssz + psz;
           } else
                   d = sz + psz;
   
         sz += 2;          sz += term_len(tp, 2);
   
         if (tblp->decimal > d) {          if (tblp->decimal > d) {
                 sz += tblp->decimal - d;                  sz += tblp->decimal - d;
Line 543  tbl_calc_data_literal(struct termp *tp, 
Line 536  tbl_calc_data_literal(struct termp *tp, 
                 const struct tbl_dat *dp,                  const struct tbl_dat *dp,
                 struct termp_tbl *tblp)                  struct termp_tbl *tblp)
 {  {
         int              sz, bufsz;          int              sz, bufsz, spsz;
   
         /*          /*
          * Calculate our width and use the spacing, with a minimum           * Calculate our width and use the spacing, with a minimum
Line 558  tbl_calc_data_literal(struct termp *tp, 
Line 551  tbl_calc_data_literal(struct termp *tp, 
         case (TBL_CELL_LONG):          case (TBL_CELL_LONG):
                 /* FALLTHROUGH */                  /* FALLTHROUGH */
         case (TBL_CELL_CENTRE):          case (TBL_CELL_CENTRE):
                 bufsz = 2;                  bufsz = term_len(tp, 2);
                 break;                  break;
         default:          default:
                 bufsz = 1;                  bufsz = term_len(tp, 1);
                 break;                  break;
         }          }
   
           spsz = 0;
         if (dp->layout->spacing)          if (dp->layout->spacing)
                 bufsz = bufsz > dp->layout->spacing ?                  spsz = term_len(tp, dp->layout->spacing);
                         bufsz : dp->layout->spacing;  
           if (spsz)
                   bufsz = bufsz > spsz ?  bufsz : spsz;
   
         sz += bufsz;          sz += bufsz;
         if (tblp->width < sz)          if (tblp->width < sz)

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.9

CVSweb