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

Diff for /mandoc/mdoc_term.c between version 1.125 and 1.126

version 1.125, 2010/05/17 22:11:42 version 1.126, 2010/05/17 23:57:06
Line 61  static int   arg_getattrs(const int *, int *, size_t,
Line 61  static int   arg_getattrs(const int *, int *, size_t,
                         const struct mdoc_node *);                          const struct mdoc_node *);
 static  int       arg_getattr(int, const struct mdoc_node *);  static  int       arg_getattr(int, const struct mdoc_node *);
 static  int       arg_disptype(const struct mdoc_node *);  static  int       arg_disptype(const struct mdoc_node *);
 static  int       arg_listtype(const struct mdoc_node *);  
 static  void      print_bvspace(struct termp *,  static  void      print_bvspace(struct termp *,
                         const struct mdoc_node *,                          const struct mdoc_node *,
                         const struct mdoc_node *);                          const struct mdoc_node *);
Line 512  arg_disptype(const struct mdoc_node *n)
Line 511  arg_disptype(const struct mdoc_node *n)
 }  }
   
   
 static int  
 arg_listtype(const struct mdoc_node *n)  
 {  
         int              i, len;  
   
         assert(MDOC_BLOCK == n->type);  
   
         len = (int)(n->args ? n->args->argc : 0);  
   
         for (i = 0; i < len; i++)  
                 switch (n->args->argv[i].arg) {  
                 case (MDOC_Bullet):  
                         /* FALLTHROUGH */  
                 case (MDOC_Dash):  
                         /* FALLTHROUGH */  
                 case (MDOC_Enum):  
                         /* FALLTHROUGH */  
                 case (MDOC_Hyphen):  
                         /* FALLTHROUGH */  
                 case (MDOC_Tag):  
                         /* FALLTHROUGH */  
                 case (MDOC_Inset):  
                         /* FALLTHROUGH */  
                 case (MDOC_Diag):  
                         /* FALLTHROUGH */  
                 case (MDOC_Item):  
                         /* FALLTHROUGH */  
                 case (MDOC_Column):  
                         /* FALLTHROUGH */  
                 case (MDOC_Hang):  
                         /* FALLTHROUGH */  
                 case (MDOC_Ohang):  
                         return(n->args->argv[i].arg);  
                 default:  
                         break;  
                 }  
   
         return(-1);  
 }  
   
   
 static size_t  static size_t
 a2offs(const struct mdoc_argv *arg)  a2offs(const struct mdoc_argv *arg)
 {  {
Line 655  print_bvspace(struct termp *p, 
Line 613  print_bvspace(struct termp *p, 
   
         /* A `-column' does not assert vspace within the list. */          /* A `-column' does not assert vspace within the list. */
   
         if (MDOC_Bl == bl->tok && arg_hasattr(MDOC_Column, bl))          if (MDOC_Bl == bl->tok && LIST_diag == bl->data.list)
                 if (n->prev && MDOC_It == n->prev->tok)                  if (n->prev && MDOC_It == n->prev->tok)
                         return;                          return;
   
         /* A `-diag' without body does not vspace. */          /* A `-diag' without body does not vspace. */
   
         if (MDOC_Bl == bl->tok && arg_hasattr(MDOC_Diag, bl))          if (MDOC_Bl == bl->tok && LIST_diag == bl->data.list)
                 if (n->prev && MDOC_It == n->prev->tok) {                  if (n->prev && MDOC_It == n->prev->tok) {
                         assert(n->prev->body);                          assert(n->prev->body);
                         if (NULL == n->prev->body->child)                          if (NULL == n->prev->body->child)
Line 705  termp_it_pre(DECL_ARGS)
Line 663  termp_it_pre(DECL_ARGS)
 {  {
         const struct mdoc_node *bl, *nn;          const struct mdoc_node *bl, *nn;
         char                    buf[7];          char                    buf[7];
         int                     i, type, keys[3], vals[3];          int                     i, keys[3], vals[3];
         size_t                  width, offset, ncols, dcol;          size_t                  width, offset, ncols, dcol;
           enum mdoc_list          type;
   
         if (MDOC_BLOCK == n->type) {          if (MDOC_BLOCK == n->type) {
                 print_bvspace(p, n->parent->parent, n);                  print_bvspace(p, n->parent->parent, n);
Line 725  termp_it_pre(DECL_ARGS)
Line 684  termp_it_pre(DECL_ARGS)
   
         arg_getattrs(keys, vals, 3, bl);          arg_getattrs(keys, vals, 3, bl);
   
         type = arg_listtype(bl);          type = bl->data.list;
         assert(-1 != type);  
   
         /*          /*
          * First calculate width and offset.  This is pretty easy unless           * First calculate width and offset.  This is pretty easy unless
Line 740  termp_it_pre(DECL_ARGS)
Line 698  termp_it_pre(DECL_ARGS)
                 offset = a2offs(&bl->args->argv[vals[1]]);                  offset = a2offs(&bl->args->argv[vals[1]]);
   
         switch (type) {          switch (type) {
         case (MDOC_Column):          case (LIST_column):
                 if (MDOC_BODY == n->type)                  if (MDOC_BODY == n->type)
                         break;                          break;
                 /*                  /*
Line 798  termp_it_pre(DECL_ARGS)
Line 756  termp_it_pre(DECL_ARGS)
          */           */
   
         switch (type) {          switch (type) {
         case (MDOC_Bullet):          case (LIST_bullet):
                 /* FALLTHROUGH */                  /* FALLTHROUGH */
         case (MDOC_Dash):          case (LIST_dash):
                 /* FALLTHROUGH */                  /* FALLTHROUGH */
         case (MDOC_Hyphen):          case (LIST_hyphen):
                 if (width < 4)                  if (width < 4)
                         width = 4;                          width = 4;
                 break;                  break;
         case (MDOC_Enum):          case (LIST_enum):
                 if (width < 5)                  if (width < 5)
                         width = 5;                          width = 5;
                 break;                  break;
         case (MDOC_Hang):          case (LIST_hang):
                 if (0 == width)                  if (0 == width)
                         width = 8;                          width = 8;
                 break;                  break;
         case (MDOC_Column):          case (LIST_column):
                 /* FALLTHROUGH */                  /* FALLTHROUGH */
         case (MDOC_Tag):          case (LIST_tag):
                 if (0 == width)                  if (0 == width)
                         width = 10;                          width = 10;
                 break;                  break;
Line 832  termp_it_pre(DECL_ARGS)
Line 790  termp_it_pre(DECL_ARGS)
         p->flags |= TERMP_NOSPACE;          p->flags |= TERMP_NOSPACE;
   
         switch (type) {          switch (type) {
         case (MDOC_Diag):          case (LIST_diag):
                 if (MDOC_BODY == n->type)                  if (MDOC_BODY == n->type)
                         term_word(p, "\\ \\ ");                          term_word(p, "\\ \\ ");
                 break;                  break;
         case (MDOC_Inset):          case (LIST_inset):
                 if (MDOC_BODY == n->type)                  if (MDOC_BODY == n->type)
                         term_word(p, "\\ ");                          term_word(p, "\\ ");
                 break;                  break;
Line 847  termp_it_pre(DECL_ARGS)
Line 805  termp_it_pre(DECL_ARGS)
         p->flags |= TERMP_NOSPACE;          p->flags |= TERMP_NOSPACE;
   
         switch (type) {          switch (type) {
         case (MDOC_Diag):          case (LIST_diag):
                 if (MDOC_HEAD == n->type)                  if (MDOC_HEAD == n->type)
                         term_fontpush(p, TERMFONT_BOLD);                          term_fontpush(p, TERMFONT_BOLD);
                 break;                  break;
Line 863  termp_it_pre(DECL_ARGS)
Line 821  termp_it_pre(DECL_ARGS)
          */           */
   
         switch (type) {          switch (type) {
         case (MDOC_Bullet):          case (LIST_bullet):
                 /* FALLTHROUGH */                  /* FALLTHROUGH */
         case (MDOC_Dash):          case (LIST_dash):
                 /* FALLTHROUGH */                  /* FALLTHROUGH */
         case (MDOC_Enum):          case (LIST_enum):
                 /* FALLTHROUGH */                  /* FALLTHROUGH */
         case (MDOC_Hyphen):          case (LIST_hyphen):
                 if (MDOC_HEAD == n->type)                  if (MDOC_HEAD == n->type)
                         p->flags |= TERMP_NOBREAK;                          p->flags |= TERMP_NOBREAK;
                 else                  else
                         p->flags |= TERMP_NOLPAD;                          p->flags |= TERMP_NOLPAD;
                 break;                  break;
         case (MDOC_Hang):          case (LIST_hang):
                 if (MDOC_HEAD == n->type)                  if (MDOC_HEAD == n->type)
                         p->flags |= TERMP_NOBREAK;                          p->flags |= TERMP_NOBREAK;
                 else                  else
Line 898  termp_it_pre(DECL_ARGS)
Line 856  termp_it_pre(DECL_ARGS)
                 } else                  } else
                         p->flags |= TERMP_HANG;                          p->flags |= TERMP_HANG;
                 break;                  break;
         case (MDOC_Tag):          case (LIST_tag):
                 if (MDOC_HEAD == n->type)                  if (MDOC_HEAD == n->type)
                         p->flags |= TERMP_NOBREAK | TERMP_TWOSPACE;                          p->flags |= TERMP_NOBREAK | TERMP_TWOSPACE;
                 else                  else
Line 909  termp_it_pre(DECL_ARGS)
Line 867  termp_it_pre(DECL_ARGS)
                 if (NULL == n->next || NULL == n->next->child)                  if (NULL == n->next || NULL == n->next->child)
                         p->flags |= TERMP_DANGLE;                          p->flags |= TERMP_DANGLE;
                 break;                  break;
         case (MDOC_Column):          case (LIST_column):
                 if (MDOC_HEAD == n->type) {                  if (MDOC_HEAD == n->type) {
                         assert(n->next);                          assert(n->next);
                         if (MDOC_BODY == n->next->type)                          if (MDOC_BODY == n->next->type)
Line 920  termp_it_pre(DECL_ARGS)
Line 878  termp_it_pre(DECL_ARGS)
                                 p->flags |= TERMP_NOLPAD;                                  p->flags |= TERMP_NOLPAD;
                 }                  }
                 break;                  break;
         case (MDOC_Diag):          case (LIST_diag):
                 if (MDOC_HEAD == n->type)                  if (MDOC_HEAD == n->type)
                         p->flags |= TERMP_NOBREAK;                          p->flags |= TERMP_NOBREAK;
                 break;                  break;
Line 937  termp_it_pre(DECL_ARGS)
Line 895  termp_it_pre(DECL_ARGS)
         p->offset += offset;          p->offset += offset;
   
         switch (type) {          switch (type) {
         case (MDOC_Hang):          case (LIST_hang):
                 /*                  /*
                  * Same stipulation as above, regarding `-hang'.  We                   * Same stipulation as above, regarding `-hang'.  We
                  * don't want to recalculate rmargin and offsets when                   * don't want to recalculate rmargin and offsets when
Line 948  termp_it_pre(DECL_ARGS)
Line 906  termp_it_pre(DECL_ARGS)
                                  MDOC_Bd == n->next->child->tok))                                   MDOC_Bd == n->next->child->tok))
                         break;                          break;
                 /* FALLTHROUGH */                  /* FALLTHROUGH */
         case (MDOC_Bullet):          case (LIST_bullet):
                 /* FALLTHROUGH */                  /* FALLTHROUGH */
         case (MDOC_Dash):          case (LIST_dash):
                 /* FALLTHROUGH */                  /* FALLTHROUGH */
         case (MDOC_Enum):          case (LIST_enum):
                 /* FALLTHROUGH */                  /* FALLTHROUGH */
         case (MDOC_Hyphen):          case (LIST_hyphen):
                 /* FALLTHROUGH */                  /* FALLTHROUGH */
         case (MDOC_Tag):          case (LIST_tag):
                 assert(width);                  assert(width);
                 if (MDOC_HEAD == n->type)                  if (MDOC_HEAD == n->type)
                         p->rmargin = p->offset + width;                          p->rmargin = p->offset + width;
                 else                  else
                         p->offset += width;                          p->offset += width;
                 break;                  break;
         case (MDOC_Column):          case (LIST_column):
                 assert(width);                  assert(width);
                 p->rmargin = p->offset + width;                  p->rmargin = p->offset + width;
                 /*                  /*
Line 986  termp_it_pre(DECL_ARGS)
Line 944  termp_it_pre(DECL_ARGS)
   
         if (MDOC_HEAD == n->type)          if (MDOC_HEAD == n->type)
                 switch (type) {                  switch (type) {
                 case (MDOC_Bullet):                  case (LIST_bullet):
                         term_fontpush(p, TERMFONT_BOLD);                          term_fontpush(p, TERMFONT_BOLD);
                         term_word(p, "\\[bu]");                          term_word(p, "\\[bu]");
                         term_fontpop(p);                          term_fontpop(p);
                         break;                          break;
                 case (MDOC_Dash):                  case (LIST_dash):
                         /* FALLTHROUGH */                          /* FALLTHROUGH */
                 case (MDOC_Hyphen):                  case (LIST_hyphen):
                         term_fontpush(p, TERMFONT_BOLD);                          term_fontpush(p, TERMFONT_BOLD);
                         term_word(p, "\\(hy");                          term_word(p, "\\(hy");
                         term_fontpop(p);                          term_fontpop(p);
                         break;                          break;
                 case (MDOC_Enum):                  case (LIST_enum):
                         (pair->ppair->ppair->count)++;                          (pair->ppair->ppair->count)++;
                         snprintf(buf, sizeof(buf), "%d.",                          snprintf(buf, sizeof(buf), "%d.",
                                         pair->ppair->ppair->count);                                          pair->ppair->ppair->count);
Line 1013  termp_it_pre(DECL_ARGS)
Line 971  termp_it_pre(DECL_ARGS)
          */           */
   
         switch (type) {          switch (type) {
         case (MDOC_Bullet):          case (LIST_bullet):
                 /* FALLTHROUGH */                  /* FALLTHROUGH */
         case (MDOC_Item):          case (LIST_item):
                 /* FALLTHROUGH */                  /* FALLTHROUGH */
         case (MDOC_Dash):          case (LIST_dash):
                 /* FALLTHROUGH */                  /* FALLTHROUGH */
         case (MDOC_Hyphen):          case (LIST_hyphen):
                 /* FALLTHROUGH */                  /* FALLTHROUGH */
         case (MDOC_Enum):          case (LIST_enum):
                 if (MDOC_HEAD == n->type)                  if (MDOC_HEAD == n->type)
                         return(0);                          return(0);
                 break;                  break;
         case (MDOC_Column):          case (LIST_column):
                 if (MDOC_BODY == n->type)                  if (MDOC_BODY == n->type)
                         return(0);                          return(0);
                 break;                  break;
Line 1041  termp_it_pre(DECL_ARGS)
Line 999  termp_it_pre(DECL_ARGS)
 static void  static void
 termp_it_post(DECL_ARGS)  termp_it_post(DECL_ARGS)
 {  {
         int                type;          enum mdoc_list     type;
   
         if (MDOC_BLOCK == n->type)          if (MDOC_BLOCK == n->type)
                 return;                  return;
   
         type = arg_listtype(n->parent->parent->parent);          type = n->parent->parent->parent->data.list;
         assert(-1 != type);  
   
         switch (type) {          switch (type) {
         case (MDOC_Item):          case (LIST_item):
                 /* FALLTHROUGH */                  /* FALLTHROUGH */
         case (MDOC_Diag):          case (LIST_diag):
                 /* FALLTHROUGH */                  /* FALLTHROUGH */
         case (MDOC_Inset):          case (LIST_inset):
                 if (MDOC_BODY == n->type)                  if (MDOC_BODY == n->type)
                         term_flushln(p);                          term_flushln(p);
                 break;                  break;
         case (MDOC_Column):          case (LIST_column):
                 if (MDOC_HEAD == n->type)                  if (MDOC_HEAD == n->type)
                         term_flushln(p);                          term_flushln(p);
                 break;                  break;

Legend:
Removed from v.1.125  
changed lines
  Added in v.1.126

CVSweb