[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.38 and 1.42

version 1.38, 2009/07/13 07:23:07 version 1.42, 2009/07/15 08:20:43
Line 407  print_foot(struct termp *p, const struct mdoc_meta *me
Line 407  print_foot(struct termp *p, const struct mdoc_meta *me
   
         tm = localtime(&meta->date);          tm = localtime(&meta->date);
   
         if (0 == strftime(buf, p->rmargin, "%B %d, %Y", tm))          if (0 == strftime(buf, p->rmargin, "%B %e, %Y", tm))
                 err(1, "strftime");                  err(1, "strftime");
   
         (void)strlcpy(os, meta->os, p->rmargin);          (void)strlcpy(os, meta->os, p->rmargin);
Line 517  print_head(struct termp *p, const struct mdoc_meta *me
Line 517  print_head(struct termp *p, const struct mdoc_meta *me
 static size_t  static size_t
 arg_width(const struct mdoc_argv *arg, int pos)  arg_width(const struct mdoc_argv *arg, int pos)
 {  {
         size_t           v;  
         int              i, len;          int              i, len;
           const char      *p;
   
         assert(pos < (int)arg->sz && pos >= 0);          assert(pos < (int)arg->sz && pos >= 0);
         assert(arg->value[pos]);          assert(arg->value[pos]);
   
         if (0 == (len = (int)strlen(arg->value[pos])))          p = arg->value[pos];
   
           if (0 == (len = (int)strlen(p)))
                 return(0);                  return(0);
   
         for (i = 0; i < len - 1; i++)          for (i = 0; i < len - 1; i++)
                 if ( ! isdigit((u_char)arg->value[pos][i]))                  if ( ! isdigit((u_char)p[i]))
                         break;                          break;
   
         if (i == len - 1) {          if (i == len - 1)
                 if ('n' == arg->value[pos][len - 1] ||                  if ('n' == p[len - 1] || 'm' == p[len - 1])
                                 'm' == arg->value[pos][len - 1]) {                          return((size_t)atoi(p) + 2);
                         v = (size_t)atoi(arg->value[pos]);  
                         return(v + 2);  
                 }  
   
         }          return((size_t)len + 2);
         return(strlen(arg->value[pos]) + 2);  
 }  }
   
   
Line 586  arg_listtype(const struct mdoc_node *n)
Line 584  arg_listtype(const struct mdoc_node *n)
 static size_t  static size_t
 arg_offset(const struct mdoc_argv *arg)  arg_offset(const struct mdoc_argv *arg)
 {  {
           int              len, i;
           const char      *p;
   
         assert(*arg->value);          assert(*arg->value);
         if (0 == strcmp(*arg->value, "left"))          p = *arg->value;
   
           if (0 == strcmp(p, "left"))
                 return(0);                  return(0);
         if (0 == strcmp(*arg->value, "indent"))          if (0 == strcmp(p, "indent"))
                 return(INDENT + 1);                  return(INDENT + 1);
         if (0 == strcmp(*arg->value, "indent-two"))          if (0 == strcmp(p, "indent-two"))
                 return((INDENT + 1) * 2);                  return((INDENT + 1) * 2);
   
         /* FIXME: needs to support field-widths (10n, etc.). */          if (0 == (len = (int)strlen(p)))
                   return(0);
   
         return(strlen(*arg->value));          for (i = 0; i < len - 1; i++)
                   if ( ! isdigit((u_char)p[i]))
                           break;
   
           if (i == len - 1)
                   if ('n' == p[len - 1] || 'm' == p[len - 1])
                           return((size_t)atoi(p));
   
           return((size_t)len);
 }  }
   
   
Line 700  termp_it_pre(DECL_ARGS)
Line 711  termp_it_pre(DECL_ARGS)
 {  {
         const struct mdoc_node *bl, *n;          const struct mdoc_node *bl, *n;
         char                    buf[7];          char                    buf[7];
         int                     i, type, keys[3], vals[3], sv;          int                     i, type, keys[3], vals[3];
         size_t                  width, offset;          size_t                  width, offset;
   
         if (MDOC_BLOCK == node->type)          if (MDOC_BLOCK == node->type)
Line 769  termp_it_pre(DECL_ARGS)
Line 780  termp_it_pre(DECL_ARGS)
                         width = 5;                          width = 5;
                 break;                  break;
         case (MDOC_Hang):          case (MDOC_Hang):
                 /* FALLTHROUGH */                  if (0 == width)
                           width = 8;
                   break;
         case (MDOC_Tag):          case (MDOC_Tag):
                 if (0 == width)                  if (0 == width)
                         width = 10;                          width = 10;
Line 787  termp_it_pre(DECL_ARGS)
Line 800  termp_it_pre(DECL_ARGS)
         case (MDOC_Diag):          case (MDOC_Diag):
                 term_word(p, "\\ ");                  term_word(p, "\\ ");
                 /* FALLTHROUGH */                  /* FALLTHROUGH */
         case (MDOC_Hang):  
                 /* FALLTHROUGH */  
         case (MDOC_Inset):          case (MDOC_Inset):
                 if (MDOC_BODY == node->type)                  if (MDOC_BODY == node->type)
                         p->flags &= ~TERMP_NOSPACE;                          p->flags &= ~TERMP_NOSPACE;
Line 829  termp_it_pre(DECL_ARGS)
Line 840  termp_it_pre(DECL_ARGS)
         case (MDOC_Enum):          case (MDOC_Enum):
                 /* FALLTHROUGH */                  /* FALLTHROUGH */
         case (MDOC_Hyphen):          case (MDOC_Hyphen):
                 /* FALLTHROUGH */                  if (MDOC_HEAD == node->type)
                           p->flags |= TERMP_NOBREAK;
                   else
                           p->flags |= TERMP_NOLPAD;
                   break;
         case (MDOC_Hang):          case (MDOC_Hang):
                 /* FALLTHROUGH */                  if (MDOC_HEAD == node->type)
                           p->flags |= TERMP_NOBREAK;
                   else
                           p->flags |= TERMP_NOLPAD;
   
                   if (MDOC_HEAD == node->type)
                           p->flags |= TERMP_HANG;
                   break;
         case (MDOC_Tag):          case (MDOC_Tag):
                 if (MDOC_HEAD == node->type)                  if (MDOC_HEAD == node->type)
                         p->flags |= TERMP_NOBREAK;                          p->flags |= TERMP_NOBREAK;
                 else                  else
                         p->flags |= TERMP_NOLPAD;                          p->flags |= TERMP_NOLPAD;
   
                 if (MDOC_HEAD == node->type && MDOC_Hang == type)                  if (MDOC_HEAD != node->type)
                         p->flags |= TERMP_NONOBREAK;                          break;
                   if (NULL == node->next || NULL == node->next->child)
                 if (MDOC_HEAD == node->type && MDOC_Tag == type)                          p->flags |= TERMP_DANGLE;
                         if (NULL == node->next ||  
                                         NULL == node->next->child)  
                                 p->flags |= TERMP_NONOBREAK;  
                 break;                  break;
         case (MDOC_Column):          case (MDOC_Column):
                 if (MDOC_HEAD == node->type) {                  if (MDOC_HEAD == node->type) {
Line 902  termp_it_pre(DECL_ARGS)
Line 921  termp_it_pre(DECL_ARGS)
          * HEAD character (temporarily bold, in some cases).           * HEAD character (temporarily bold, in some cases).
          */           */
   
         sv = p->flags;  
         if (MDOC_HEAD == node->type)          if (MDOC_HEAD == node->type)
                 switch (type) {                  switch (type) {
                 case (MDOC_Bullet):                  case (MDOC_Bullet):
                         p->flags |= TERMP_BOLD;                          p->flags |= TERMP_BOLD;
                         term_word(p, "\\[bu]");                          term_word(p, "\\[bu]");
                           p->flags &= ~TERMP_BOLD;
                         break;                          break;
                 case (MDOC_Dash):                  case (MDOC_Dash):
                         /* FALLTHROUGH */                          /* FALLTHROUGH */
                 case (MDOC_Hyphen):                  case (MDOC_Hyphen):
                         p->flags |= TERMP_BOLD;                          p->flags |= TERMP_BOLD;
                         term_word(p, "\\(hy");                          term_word(p, "\\(hy");
                           p->flags &= ~TERMP_BOLD;
                         break;                          break;
                 case (MDOC_Enum):                  case (MDOC_Enum):
                         (pair->ppair->ppair->count)++;                          (pair->ppair->ppair->count)++;
Line 925  termp_it_pre(DECL_ARGS)
Line 945  termp_it_pre(DECL_ARGS)
                         break;                          break;
                 }                  }
   
         p->flags = sv; /* Restore saved flags. */  
   
         /*          /*
          * If we're not going to process our children, indicate so here.           * If we're not going to process our children, indicate so here.
          */           */
Line 1122  termp_nd_pre(DECL_ARGS)
Line 1140  termp_nd_pre(DECL_ARGS)
         if (MDOC_BODY != node->type)          if (MDOC_BODY != node->type)
                 return(1);                  return(1);
   
         /*  
          * XXX: signed off by jmc@openbsd.org.  This technically  
          * produces a minus sign after the Nd, which is wrong, but is  
          * consistent with the historic OpenBSD tmac file.  
          */  
 #if defined(__OpenBSD__) || defined(__linux__)  #if defined(__OpenBSD__) || defined(__linux__)
         term_word(p, "\\-");          term_word(p, "\\(en");
 #else  #else
         term_word(p, "\\(em");          term_word(p, "\\(em");
 #endif  #endif

Legend:
Removed from v.1.38  
changed lines
  Added in v.1.42

CVSweb