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

Diff for /mandoc/term.c between version 1.101 and 1.106

version 1.101, 2009/09/17 07:41:28 version 1.106, 2009/10/18 13:34:17
Line 24 
Line 24 
 #include "term.h"  #include "term.h"
 #include "man.h"  #include "man.h"
 #include "mdoc.h"  #include "mdoc.h"
   #include "main.h"
   #include "out.h"
   
 extern  void              man_run(struct termp *,  /* FIXME: accomodate non-breaking, non-collapsing white-space. */
                                 const struct man *);  /* FIXME: accomodate non-breaking, collapsing white-space. */
 extern  void              mdoc_run(struct termp *,  
                                 const struct mdoc *);  
   
 static  struct termp     *term_alloc(enum termenc);  static  struct termp     *term_alloc(enum termenc);
 static  void              term_free(struct termp *);  static  void              term_free(struct termp *);
Line 51  ascii_alloc(void)
Line 51  ascii_alloc(void)
   
   
 void  void
 terminal_man(void *arg, const struct man *man)  
 {  
         struct termp    *p;  
   
         p = (struct termp *)arg;  
         if (NULL == p->symtab)  
                 p->symtab = chars_init(CHARS_ASCII);  
   
         man_run(p, man);  
 }  
   
   
 void  
 terminal_mdoc(void *arg, const struct mdoc *mdoc)  
 {  
         struct termp    *p;  
   
         p = (struct termp *)arg;  
         if (NULL == p->symtab)  
                 p->symtab = chars_init(CHARS_ASCII);  
   
         mdoc_run(p, mdoc);  
 }  
   
   
 void  
 terminal_free(void *arg)  terminal_free(void *arg)
 {  {
   
Line 90  term_free(struct termp *p)
Line 64  term_free(struct termp *p)
   
         if (p->buf)          if (p->buf)
                 free(p->buf);                  free(p->buf);
         if (TERMENC_ASCII == p->enc && p->symtab)          if (p->symtab)
                 chars_free(p->symtab);                  chars_free(p->symtab);
   
         free(p);          free(p);
Line 156  void
Line 130  void
 term_flushln(struct termp *p)  term_flushln(struct termp *p)
 {  {
         int              i, j;          int              i, j;
         size_t           vbl, vsz, vis, maxvis, mmax, bp;          size_t           vbl, vsz, vis, maxvis, mmax, bp, os;
         static int       overstep = 0;          static int       overstep = 0;
   
         /*          /*
Line 169  term_flushln(struct termp *p)
Line 143  term_flushln(struct termp *p)
         assert(p->offset < p->rmargin);          assert(p->offset < p->rmargin);
         assert((int)(p->rmargin - p->offset) - overstep > 0);          assert((int)(p->rmargin - p->offset) - overstep > 0);
   
           /* Save the overstep. */
           os = (size_t)overstep;
   
         maxvis = /* LINTED */          maxvis = /* LINTED */
                 p->rmargin - p->offset - overstep;                  p->rmargin - p->offset - overstep;
         mmax = /* LINTED */          mmax = /* LINTED */
Line 230  term_flushln(struct termp *p)
Line 207  term_flushln(struct termp *p)
                                         putchar(' ');                                          putchar(' ');
                                 vis = 0;                                  vis = 0;
                         }                          }
                           /* Remove the overstep width. */
                           bp += os;
                           os = 0;
                 } else {                  } else {
                         for (j = 0; j < (int)vbl; j++)                          for (j = 0; j < (int)vbl; j++)
                                 putchar(' ');                                  putchar(' ');
Line 579  encode(struct termp *p, char c)
Line 559  encode(struct termp *p, char c)
         }          }
         buffer(p, c);          buffer(p, c);
 }  }
   
   
   int
   a2height(const char *p)
   {
           struct roffsu    su;
           double           r;
   
           if ( ! a2roffsu(p, &su))
                   return(-1);
   
           switch (su.unit) {
           case (SCALE_CM):
                   r = su.scale * 2;
                   break;
           case (SCALE_IN):
                   r = su.scale * 6;
                   break;
           case (SCALE_PC):
                   r = su.scale;
                   break;
           case (SCALE_PT):
                   r = su.scale / 8;
                   break;
           case (SCALE_MM):
                   r = su.scale / 1000;
                   break;
           case (SCALE_VS):
                   r = su.scale;
                   break;
           default:
                   r = su.scale - 1;
                   break;
           }
   
           if (r < 0.0)
                   r = 0.0;
           return(/* LINTED */(int)
                           r);
   }
   
   
   int
   a2width(const char *p)
   {
           struct roffsu    su;
           double           r;
   
           if ( ! a2roffsu(p, &su))
                   return(-1);
   
           switch (su.unit) {
           case (SCALE_CM):
                   r = (4 * su.scale) + 2; /* FIXME: double-check. */
                   break;
           case (SCALE_IN):
                   r = (10 * su.scale) + 2; /* FIXME: double-check. */
                   break;
           case (SCALE_PC):
                   r = (10 * su.scale) / 6; /* FIXME: double-check. */
                   break;
           case (SCALE_PT):
                   r = (10 * su.scale) / 72; /* FIXME: double-check. */
                   break;
           case (SCALE_MM):
                   r = su.scale / 1000; /* FIXME: double-check. */
                   break;
           case (SCALE_VS):
                   r = su.scale * 2 - 1; /* FIXME: double-check. */
                   break;
           default:
                   r = su.scale + 2;
                   break;
           }
   
           if (r < 0.0)
                   r = 0.0;
           return((int)/* LINTED */
                           r);
   }
   
   

Legend:
Removed from v.1.101  
changed lines
  Added in v.1.106

CVSweb