[BACK]Return to tbl_term.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / mandoc

Diff for /src/usr.bin/mandoc/tbl_term.c between version 1.2 and 1.3

version 1.2, 2010/10/15 21:33:47 version 1.3, 2010/10/15 22:07:12
Line 29 
Line 29 
 /* FIXME: `n' modifier doesn't always do the right thing. */  /* FIXME: `n' modifier doesn't always do the right thing. */
 /* FIXME: `n' modifier doesn't use the cell-spacing buffer. */  /* FIXME: `n' modifier doesn't use the cell-spacing buffer. */
   
 static  void             calc_data(struct tbl_data *);  static  void             calc_data(struct termp *, struct tbl_data *);
 static  void             calc_data_literal(struct tbl_data *);  static  void             calc_data_literal(struct termp *, struct tbl_data *);
 static  void             calc_data_number(struct tbl_data *);  static  void             calc_data_number(struct termp *, struct tbl_data *);
 static  void             calc_data_spanner(struct tbl_data *);  static  void             calc_data_spanner(struct termp *, struct tbl_data *);
 static  inline void      write_char(struct termp *, char, int);  static  inline void      write_char(struct termp *, char, int);
 static  void             write_data(struct termp *,  static  void             write_data(struct termp *,
                                 const struct tbl_data *, int);                                  const struct tbl_data *, int);
Line 119 
Line 119 
   
   
 int  int
 tbl_calc_term(struct tbl *tbl)  tbl_calc_term(struct termp *p, struct tbl *tbl)
 {  {
         struct tbl_span *span;          struct tbl_span *span;
         struct tbl_data *data;          struct tbl_data *data;
Line 137 
Line 137 
                 if (TBL_DATA_NDHORIZ & span->flags)                  if (TBL_DATA_NDHORIZ & span->flags)
                         continue;                          continue;
                 TAILQ_FOREACH(data, &span->data, entries)                  TAILQ_FOREACH(data, &span->data, entries)
                         calc_data(data);                          calc_data(p, data);
         }          }
   
         /* Calculate width as the simple spanner value. */          /* Calculate width as the simple spanner value. */
Line 145 
Line 145 
         TAILQ_FOREACH(head, &tbl->head, entries)          TAILQ_FOREACH(head, &tbl->head, entries)
                 switch (head->pos) {                  switch (head->pos) {
                 case (TBL_HEAD_VERT):                  case (TBL_HEAD_VERT):
                         head->width = 1;                          head->width = term_len(p, 1);
                         break;                          break;
                 case (TBL_HEAD_DVERT):                  case (TBL_HEAD_DVERT):
                         head->width = 2;                          head->width = term_len(p, 2);
                         break;                          break;
                 default:                  default:
                         break;                          break;
Line 247 
Line 247 
   
   
 static void  static void
 calc_data_spanner(struct tbl_data *data)  calc_data_spanner(struct termp *p, struct tbl_data *data)
 {  {
   
         /* N.B., these are horiz spanners (not vert) so always 1. */          /* N.B., these are horiz spanners (not vert) so always 1. */
         data->cell->head->width = 1;          data->cell->head->width = term_len(p, 1);
 }  }
   
   
 static void  static void
 calc_data_number(struct tbl_data *data)  calc_data_number(struct termp *p, struct tbl_data *data)
 {  {
         int              sz, d;          int              sz, d;
         char            *dp, pnt;          char            *dp, pnt;
Line 273 
Line 273 
         /* TODO: use spacing modifier. */          /* TODO: use spacing modifier. */
   
         assert(data->string);          assert(data->string);
         sz = (int)strlen(data->string);          sz = (int)term_strlen(p, data->string);
         pnt = data->span->tbl->decimal;          pnt = data->span->tbl->decimal;
   
         if (NULL == (dp = strchr(data->string, pnt)))          dp = strchr(data->string, pnt);
                 d = sz + 1;          d = dp ? sz - (int)term_strlen(p, dp) : sz;
         else          d += term_len(p, 1);
                 d = (int)(dp - data->string) + 1;  
   
         sz += 2;          sz += term_len(p, 2);
   
         if (data->cell->head->decimal > d) {          if (data->cell->head->decimal > d) {
                 sz += data->cell->head->decimal - d;                  sz += data->cell->head->decimal - d;
Line 298 
Line 297 
   
   
 static void  static void
 calc_data_literal(struct tbl_data *data)  calc_data_literal(struct termp *p, struct tbl_data *data)
 {  {
         int              sz, bufsz;          int              sz, bufsz;
   
Line 309 
Line 308 
          */           */
   
         assert(data->string);          assert(data->string);
         sz = (int)strlen(data->string);          sz = (int)term_strlen(p, data->string);
   
         switch (data->cell->pos) {          switch (data->cell->pos) {
         case (TBL_CELL_LONG):          case (TBL_CELL_LONG):
Line 326 
Line 325 
                 bufsz = bufsz > data->cell->spacing ?                  bufsz = bufsz > data->cell->spacing ?
                         bufsz : data->cell->spacing;                          bufsz : data->cell->spacing;
   
         sz += bufsz;          sz += term_len(p, bufsz);
         if (data->cell->head->width < sz)          if (data->cell->head->width < sz)
                 data->cell->head->width = sz;                  data->cell->head->width = sz;
 }  }
   
   
 static void  static void
 calc_data(struct tbl_data *data)  calc_data(struct termp *p, struct tbl_data *data)
 {  {
   
         switch (data->cell->pos) {          switch (data->cell->pos) {
         case (TBL_CELL_HORIZ):          case (TBL_CELL_HORIZ):
                 /* FALLTHROUGH */                  /* FALLTHROUGH */
         case (TBL_CELL_DHORIZ):          case (TBL_CELL_DHORIZ):
                 calc_data_spanner(data);                  calc_data_spanner(p, data);
                 break;                  break;
         case (TBL_CELL_LONG):          case (TBL_CELL_LONG):
                 /* FALLTHROUGH */                  /* FALLTHROUGH */
Line 349 
Line 348 
         case (TBL_CELL_LEFT):          case (TBL_CELL_LEFT):
                 /* FALLTHROUGH */                  /* FALLTHROUGH */
         case (TBL_CELL_RIGHT):          case (TBL_CELL_RIGHT):
                 calc_data_literal(data);                  calc_data_literal(p, data);
                 break;                  break;
         case (TBL_CELL_NUMBER):          case (TBL_CELL_NUMBER):
                 calc_data_number(data);                  calc_data_number(p, data);
                 break;                  break;
         default:          default:
                 abort();                  abort();
Line 391 
Line 390 
          * and the maximum decimal; right-pad by the remaining amount.           * and the maximum decimal; right-pad by the remaining amount.
          */           */
   
         sz = (int)strlen(data->string);          sz = (int)term_strlen(p, data->string);
         pnt = data->span->tbl->decimal;          pnt = data->span->tbl->decimal;
   
         if (NULL == (dp = strchr(data->string, pnt))) {          if (NULL == (dp = strchr(data->string, pnt))) {

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3