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

Diff for /mandoc/man_term.c between version 1.78 and 1.86

version 1.78, 2010/06/26 15:36:37 version 1.86, 2010/12/05 16:14:16
Line 1 
Line 1 
 /*      $Id$ */  /*      $Id$ */
 /*  /*
  * Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@bsd.lv>   * Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv>
  *   *
  * Permission to use, copy, modify, and distribute this software for any   * Permission to use, copy, modify, and distribute this software for any
  * purpose with or without fee is hereby granted, provided that the above   * purpose with or without fee is hereby granted, provided that the above
Line 28 
Line 28 
   
 #include "mandoc.h"  #include "mandoc.h"
 #include "out.h"  #include "out.h"
 #include "regs.h"  
 #include "man.h"  #include "man.h"
 #include "term.h"  #include "term.h"
 #include "chars.h"  #include "chars.h"
Line 93  static int    pre_RS(DECL_ARGS);
Line 92  static int    pre_RS(DECL_ARGS);
 static  int               pre_SH(DECL_ARGS);  static  int               pre_SH(DECL_ARGS);
 static  int               pre_SS(DECL_ARGS);  static  int               pre_SS(DECL_ARGS);
 static  int               pre_TP(DECL_ARGS);  static  int               pre_TP(DECL_ARGS);
 static  int               pre_br(DECL_ARGS);  
 static  int               pre_fi(DECL_ARGS);  
 static  int               pre_ign(DECL_ARGS);  static  int               pre_ign(DECL_ARGS);
 static  int               pre_nf(DECL_ARGS);  static  int               pre_in(DECL_ARGS);
   static  int               pre_literal(DECL_ARGS);
 static  int               pre_sp(DECL_ARGS);  static  int               pre_sp(DECL_ARGS);
   
 static  void              post_IP(DECL_ARGS);  static  void              post_IP(DECL_ARGS);
Line 107  static void    post_SS(DECL_ARGS);
Line 105  static void    post_SS(DECL_ARGS);
 static  void              post_TP(DECL_ARGS);  static  void              post_TP(DECL_ARGS);
   
 static  const struct termact termacts[MAN_MAX] = {  static  const struct termact termacts[MAN_MAX] = {
         { pre_br, NULL, MAN_NOTEXT }, /* br */          { pre_sp, NULL, MAN_NOTEXT }, /* br */
         { NULL, NULL, 0 }, /* TH */          { NULL, NULL, 0 }, /* TH */
         { pre_SH, post_SH, 0 }, /* SH */          { pre_SH, post_SH, 0 }, /* SH */
         { pre_SS, post_SS, 0 }, /* SS */          { pre_SS, post_SS, 0 }, /* SS */
Line 131  static const struct termact termacts[MAN_MAX] = {
Line 129  static const struct termact termacts[MAN_MAX] = {
         { NULL, NULL, MAN_NOTEXT }, /* na */          { NULL, NULL, MAN_NOTEXT }, /* na */
         { pre_I, NULL, 0 }, /* i */          { pre_I, NULL, 0 }, /* i */
         { pre_sp, NULL, MAN_NOTEXT }, /* sp */          { pre_sp, NULL, MAN_NOTEXT }, /* sp */
         { pre_nf, NULL, 0 }, /* nf */          { pre_literal, NULL, 0 }, /* nf */
         { pre_fi, NULL, 0 }, /* fi */          { pre_literal, NULL, 0 }, /* fi */
         { NULL, NULL, 0 }, /* r */          { NULL, NULL, 0 }, /* r */
         { NULL, NULL, 0 }, /* RE */          { NULL, NULL, 0 }, /* RE */
         { pre_RS, post_RS, 0 }, /* RS */          { pre_RS, post_RS, 0 }, /* RS */
         { pre_ign, NULL, 0 }, /* DT */          { pre_ign, NULL, 0 }, /* DT */
         { pre_ign, NULL, 0 }, /* UC */          { pre_ign, NULL, 0 }, /* UC */
         { pre_ign, NULL, 0 }, /* PD */          { pre_ign, NULL, 0 }, /* PD */
         { pre_sp, NULL, MAN_NOTEXT }, /* Sp */  
         { pre_nf, NULL, 0 }, /* Vb */  
         { pre_fi, NULL, 0 }, /* Ve */  
         { pre_ign, NULL, 0 }, /* AT */          { pre_ign, NULL, 0 }, /* AT */
           { pre_in, NULL, MAN_NOTEXT }, /* in */
 };  };
   
   
Line 250  pre_I(DECL_ARGS)
Line 246  pre_I(DECL_ARGS)
   
 /* ARGSUSED */  /* ARGSUSED */
 static int  static int
 pre_fi(DECL_ARGS)  pre_literal(DECL_ARGS)
 {  {
   
         mt->fl &= ~MANT_LITERAL;          term_newln(p);
           switch (n->tok) {
           case (MAN_nf):
                   mt->fl |= MANT_LITERAL;
                   break;
           default:
                   mt->fl &= ~MANT_LITERAL;
                   break;
           }
   
         return(1);          return(1);
 }  }
   
   
 /* ARGSUSED */  
 static int  
 pre_nf(DECL_ARGS)  
 {  
   
         mt->fl |= MANT_LITERAL;  
         return(MAN_Vb != n->tok);  
 }  
   
   
 /* ARGSUSED */  /* ARGSUSED */
 static int  static int
 pre_RB(DECL_ARGS)  pre_RB(DECL_ARGS)
Line 354  pre_B(DECL_ARGS)
Line 350  pre_B(DECL_ARGS)
   
 /* ARGSUSED */  /* ARGSUSED */
 static int  static int
 pre_sp(DECL_ARGS)  pre_in(DECL_ARGS)
 {  {
         size_t           i, len;          int              len, less;
           size_t           v;
           const char      *cp;
   
         len = n->child ?          term_newln(p);
                 a2height(p, n->child->string) : term_len(p, 1);  
   
         if (0 == len)          if (NULL == n->child) {
                 term_newln(p);                  p->offset = mt->offset;
         for (i = 0; i <= len; i++)                  return(0);
                 term_vspace(p);          }
   
           cp = n->child->string;
           less = 0;
   
           if ('-' == *cp)
                   less = -1;
           else if ('+' == *cp)
                   less = 1;
           else
                   cp--;
   
           if ((len = a2width(p, ++cp)) < 0)
                   return(0);
   
           v = (size_t)len;
   
           if (less < 0)
                   p->offset -= p->offset > v ? v : p->offset;
           else if (less > 0)
                   p->offset += v;
           else
                   p->offset = v;
   
         return(0);          return(0);
 }  }
   
   
 /* ARGSUSED */  /* ARGSUSED */
 static int  static int
 pre_br(DECL_ARGS)  pre_sp(DECL_ARGS)
 {  {
           size_t           i, len;
   
         term_newln(p);          switch (n->tok) {
           case (MAN_br):
                   len = 0;
                   break;
           default:
                   len = n->child ? a2height(p, n->child->string) : 1;
                   break;
           }
   
           if (0 == len)
                   term_newln(p);
           for (i = 0; i < len; i++)
                   term_vspace(p);
   
         return(0);          return(0);
 }  }
   
Line 877  print_man_foot(struct termp *p, const void *arg)
Line 910  print_man_foot(struct termp *p, const void *arg)
         p->flags |= TERMP_NOSPACE | TERMP_NOBREAK;          p->flags |= TERMP_NOSPACE | TERMP_NOBREAK;
         p->rmargin = p->maxrmargin - term_strlen(p, buf);          p->rmargin = p->maxrmargin - term_strlen(p, buf);
         p->offset = 0;          p->offset = 0;
   
           /* term_strlen() can return zero. */
           if (p->rmargin == p->maxrmargin)
                   p->rmargin--;
   
         if (meta->source)          if (meta->source)
                 term_word(p, meta->source);                  term_word(p, meta->source);

Legend:
Removed from v.1.78  
changed lines
  Added in v.1.86

CVSweb