[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.164 and 1.168

version 1.164, 2014/12/24 09:58:35 version 1.168, 2015/01/30 22:04:44
Line 1 
Line 1 
 /*      $Id$ */  /*      $Id$ */
 /*  /*
  * Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>   * Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
  * Copyright (c) 2010-2014 Ingo Schwarze <schwarze@openbsd.org>   * Copyright (c) 2010-2015 Ingo Schwarze <schwarze@openbsd.org>
  *   *
  * 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 47  struct mtermp {
Line 47  struct mtermp {
   
 #define DECL_ARGS         struct termp *p, \  #define DECL_ARGS         struct termp *p, \
                           struct mtermp *mt, \                            struct mtermp *mt, \
                           const struct man_node *n, \                            struct man_node *n, \
                           const struct man_meta *meta                            const struct man_meta *meta
   
 struct  termact {  struct  termact {
Line 114  static const struct termact termacts[MAN_MAX] = {
Line 114  static const struct termact termacts[MAN_MAX] = {
         { pre_I, NULL, 0 }, /* I */          { pre_I, NULL, 0 }, /* I */
         { pre_alternate, NULL, 0 }, /* IR */          { pre_alternate, NULL, 0 }, /* IR */
         { pre_alternate, NULL, 0 }, /* RI */          { pre_alternate, NULL, 0 }, /* RI */
         { pre_ign, NULL, MAN_NOTEXT }, /* na */  
         { pre_sp, NULL, MAN_NOTEXT }, /* sp */          { pre_sp, NULL, MAN_NOTEXT }, /* sp */
         { pre_literal, NULL, 0 }, /* nf */          { pre_literal, NULL, 0 }, /* nf */
         { pre_literal, NULL, 0 }, /* fi */          { pre_literal, NULL, 0 }, /* fi */
Line 280  static int
Line 279  static int
 pre_alternate(DECL_ARGS)  pre_alternate(DECL_ARGS)
 {  {
         enum termfont            font[2];          enum termfont            font[2];
         const struct man_node   *nn;          struct man_node         *nn;
         int                      savelit, i;          int                      savelit, i;
   
         switch (n->tok) {          switch (n->tok) {
Line 643  static int
Line 642  static int
 pre_TP(DECL_ARGS)  pre_TP(DECL_ARGS)
 {  {
         struct roffsu            su;          struct roffsu            su;
         const struct man_node   *nn;          struct man_node         *nn;
         int                      len, savelit;          int                      len, savelit;
   
         switch (n->type) {          switch (n->type) {
Line 840  static int
Line 839  static int
 pre_RS(DECL_ARGS)  pre_RS(DECL_ARGS)
 {  {
         struct roffsu    su;          struct roffsu    su;
         int              len;  
   
         switch (n->type) {          switch (n->type) {
         case MAN_BLOCK:          case MAN_BLOCK:
Line 852  pre_RS(DECL_ARGS)
Line 850  pre_RS(DECL_ARGS)
                 break;                  break;
         }          }
   
         len = SHRT_MAX + 1;          n = n->parent->head;
         if ((n = n->parent->head->child) != NULL &&          n->aux = SHRT_MAX + 1;
             a2roffsu(n->string, &su, SCALE_EN))          if (n->child != NULL && a2roffsu(n->child->string, &su, SCALE_EN))
                 len = term_hspan(p, &su);                  n->aux = term_hspan(p, &su);
         if (len > SHRT_MAX)          if (n->aux < 0 && (size_t)(-n->aux) > mt->offset)
                 len = term_len(p, p->defindent);                  n->aux = -mt->offset;
           else if (n->aux > SHRT_MAX)
                   n->aux = term_len(p, p->defindent);
   
         if (len > 0 || (size_t)(-len) < mt->offset)          mt->offset += n->aux;
                 mt->offset += len;  
         else  
                 mt->offset = 0;  
         p->offset = mt->offset;          p->offset = mt->offset;
         p->rmargin = p->maxrmargin;          p->rmargin = p->maxrmargin;
   
Line 876  pre_RS(DECL_ARGS)
Line 873  pre_RS(DECL_ARGS)
 static void  static void
 post_RS(DECL_ARGS)  post_RS(DECL_ARGS)
 {  {
         struct roffsu    su;  
         int              len;  
   
         switch (n->type) {          switch (n->type) {
         case MAN_BLOCK:          case MAN_BLOCK:
Line 889  post_RS(DECL_ARGS)
Line 884  post_RS(DECL_ARGS)
                 break;                  break;
         }          }
   
         len = SHRT_MAX + 1;          mt->offset -= n->parent->head->aux;
         if ((n = n->parent->head->child) != NULL &&  
             a2roffsu(n->string, &su, SCALE_EN))  
                 len = term_hspan(p, &su);  
         if (len > SHRT_MAX)  
                 len = term_len(p, p->defindent);  
   
         if (len < 0 || (size_t)len < mt->offset)  
                 mt->offset -= len;  
         else  
                 mt->offset = 0;  
         p->offset = mt->offset;          p->offset = mt->offset;
   
         if (--mt->lmarginsz < MAXMARGINS)          if (--mt->lmarginsz < MAXMARGINS)
Line 964  print_man_node(DECL_ARGS)
Line 949  print_man_node(DECL_ARGS)
                  * Tables are preceded by a newline.  Then process a                   * Tables are preceded by a newline.  Then process a
                  * table line, which will cause line termination,                   * table line, which will cause line termination,
                  */                   */
                 if (TBL_SPAN_FIRST & n->span->flags)                  if (n->span->prev == NULL)
                         term_newln(p);                          term_newln(p);
                 term_tbl(p, n->span);                  term_tbl(p, n->span);
                 return;                  return;
Line 1022  static void
Line 1007  static void
 print_man_nodelist(DECL_ARGS)  print_man_nodelist(DECL_ARGS)
 {  {
   
         print_man_node(p, mt, n, meta);          while (n != NULL) {
         if ( ! n->next)                  print_man_node(p, mt, n, meta);
                 return;                  n = n->next;
         print_man_nodelist(p, mt, n->next, meta);          }
 }  }
   
 static void  static void

Legend:
Removed from v.1.164  
changed lines
  Added in v.1.168

CVSweb