[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.91 and 1.95

version 1.91, 2009/10/18 13:34:17 version 1.95, 2009/10/24 05:52:14
Line 23 
Line 23 
 #include <stdlib.h>  #include <stdlib.h>
 #include <string.h>  #include <string.h>
   
   #include "out.h"
 #include "term.h"  #include "term.h"
 #include "mdoc.h"  #include "mdoc.h"
 #include "chars.h"  #include "chars.h"
Line 235  static const struct termact termacts[MDOC_MAX] = {
Line 236  static const struct termact termacts[MDOC_MAX] = {
         { NULL, termp____post }, /* %Q */          { NULL, termp____post }, /* %Q */
         { termp_sp_pre, NULL }, /* br */          { termp_sp_pre, NULL }, /* br */
         { termp_sp_pre, NULL }, /* sp */          { termp_sp_pre, NULL }, /* sp */
           { NULL, termp____post }, /* %U */
 };  };
   
 #ifdef __linux__  #ifdef __linux__
Line 346  print_node(DECL_ARGS)
Line 348  print_node(DECL_ARGS)
 static void  static void
 print_foot(DECL_ARGS)  print_foot(DECL_ARGS)
 {  {
         struct tm       *tm;          char             buf[DATESIZ];
         char            *buf, *os;          char            *os;
   
         /*          /*
          * Output the footer in new-groff style, that is, three columns           * Output the footer in new-groff style, that is, three columns
Line 357  print_foot(DECL_ARGS)
Line 359  print_foot(DECL_ARGS)
          * SYSTEM                  DATE                    SYSTEM           * SYSTEM                  DATE                    SYSTEM
          */           */
   
         if (NULL == (buf = malloc(p->rmargin)))  
                 err(EXIT_FAILURE, "malloc");  
         if (NULL == (os = malloc(p->rmargin)))          if (NULL == (os = malloc(p->rmargin)))
                 err(EXIT_FAILURE, "malloc");                  err(EXIT_FAILURE, "malloc");
   
         tm = localtime(&m->date);          time2a(m->date, buf, DATESIZ);
   
         if (0 == strftime(buf, p->rmargin, "%B %e, %Y", tm))  
                 err(EXIT_FAILURE, "strftime");  
   
         (void)strlcpy(os, m->os, p->rmargin);          (void)strlcpy(os, m->os, p->rmargin);
   
         term_vspace(p);          term_vspace(p);
Line 397  print_foot(DECL_ARGS)
Line 394  print_foot(DECL_ARGS)
         p->rmargin = p->maxrmargin;          p->rmargin = p->maxrmargin;
         p->flags = 0;          p->flags = 0;
   
         free(buf);  
         free(os);          free(os);
 }  }
   
Line 475  print_head(DECL_ARGS)
Line 471  print_head(DECL_ARGS)
 static size_t  static size_t
 arg2height(const struct mdoc_node *n)  arg2height(const struct mdoc_node *n)
 {  {
         int              r;          struct roffsu    su;
   
         assert(MDOC_TEXT == n->type);          assert(MDOC_TEXT == n->type);
         assert(n->string);          assert(n->string);
           if ( ! a2roffsu(n->string, &su, SCALE_VS))
                   SCALE_VS_INIT(&su, strlen(n->string));
   
         if ((r = a2height(n->string)) < 0)          return(term_vspan(&su));
                 return(1);  
   
         return((size_t)r);  
 }  }
   
   
 static size_t  static size_t
 arg2width(const struct mdoc_argv *arg, int pos)  arg2width(const struct mdoc_argv *arg, int pos)
 {  {
         int              r;          struct roffsu    su;
   
         assert(arg->value[pos]);          assert(arg->value[pos]);
         if ('\0' == arg->value[pos][0])          if ( ! a2roffsu(arg->value[pos], &su, SCALE_MAX))
                 return(2);                  SCALE_HS_INIT(&su, strlen(arg->value[pos]));
   
         if ((r = a2width(arg->value[pos])) >= 0)          /* XXX: pachemu? */
                 return((size_t)r);          return(term_hspan(&su) + 2);
   
         return(strlen(arg->value[pos]) + 2);  
 }  }
   
   
 /* FIXME: put in utility file for front-ends. */  
 static int  static int
 arg_listtype(const struct mdoc_node *n)  arg_listtype(const struct mdoc_node *n)
 {  {
Line 548  arg_listtype(const struct mdoc_node *n)
Line 540  arg_listtype(const struct mdoc_node *n)
 static size_t  static size_t
 arg2offs(const struct mdoc_argv *arg)  arg2offs(const struct mdoc_argv *arg)
 {  {
         int              r;          struct roffsu    su;
   
         if ('\0' == arg->value[0][0])          if ('\0' == arg->value[0][0])
                 return(0);                  return(0);
Line 558  arg2offs(const struct mdoc_argv *arg)
Line 550  arg2offs(const struct mdoc_argv *arg)
                 return(INDENT + 1);                  return(INDENT + 1);
         else if (0 == strcmp(arg->value[0], "indent-two"))          else if (0 == strcmp(arg->value[0], "indent-two"))
                 return((INDENT + 1) * 2);                  return((INDENT + 1) * 2);
         else if ((r = a2width(arg->value[0])) >= 0)          else if ( ! a2roffsu(arg->value[0], &su, SCALE_MAX))
                 return((size_t)r);                  SCALE_HS_INIT(&su, strlen(arg->value[0]));
   
         return(strlen(arg->value[0]));          return(term_hspan(&su));
 }  }
   
   
Line 2014  termp_ap_pre(DECL_ARGS)
Line 2006  termp_ap_pre(DECL_ARGS)
 static void  static void
 termp____post(DECL_ARGS)  termp____post(DECL_ARGS)
 {  {
   
           /* TODO: %U. */
   
         p->flags |= TERMP_NOSPACE;          p->flags |= TERMP_NOSPACE;
         switch (n->tok) {          switch (n->tok) {

Legend:
Removed from v.1.91  
changed lines
  Added in v.1.95

CVSweb