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

Diff for /mandoc/roff_term.c between version 1.19 and 1.22

version 1.19, 2019/01/04 03:24:33 version 1.22, 2020/09/03 20:43:15
Line 1 
Line 1 
 /*      $Id$ */  /* $OpenBSD$ */
 /*  /*
  * Copyright (c) 2010,2014,2015,2017-2019 Ingo Schwarze <schwarze@openbsd.org>   * Copyright (c) 2010,2014,2015,2017-2020 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 14 
Line 14 
  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF   * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.   * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */   */
   #include "config.h"
   
 #include <sys/types.h>  #include <sys/types.h>
   
 #include <assert.h>  #include <assert.h>
Line 155  static void
Line 157  static void
 roff_term_pre_po(ROFF_TERM_ARGS)  roff_term_pre_po(ROFF_TERM_ARGS)
 {  {
         struct roffsu    su;          struct roffsu    su;
         static int       po, polast;          static int       po, pouse, polast;
         int              ponew;          int              ponew;
   
           /* Revert the currently active page offset. */
           p->tcol->offset -= pouse;
   
           /* Determine the requested page offset. */
         if (n->child != NULL &&          if (n->child != NULL &&
             a2roffsu(n->child->string, &su, SCALE_EM) != NULL) {              a2roffsu(n->child->string, &su, SCALE_EM) != NULL) {
                 ponew = term_hen(p, &su);                  ponew = term_hen(p, &su);
Line 166  roff_term_pre_po(ROFF_TERM_ARGS)
Line 172  roff_term_pre_po(ROFF_TERM_ARGS)
                         ponew += po;                          ponew += po;
         } else          } else
                 ponew = polast;                  ponew = polast;
   
           /* Remeber both the previous and the newly requested offset. */
         polast = po;          polast = po;
         po = ponew;          po = ponew;
   
         ponew = po - polast + (int)p->tcol->offset;          /* Truncate to the range [-offset, 60], remember, and apply it. */
         p->tcol->offset = ponew > 0 ? ponew : 0;          pouse = po >= 60 ? 60 :
               po < -(int)p->tcol->offset ? -p->tcol->offset : po;
           p->tcol->offset += pouse;
 }  }
   
 static void  static void
Line 208  roff_term_pre_ti(ROFF_TERM_ARGS)
Line 218  roff_term_pre_ti(ROFF_TERM_ARGS)
 {  {
         struct roffsu    su;          struct roffsu    su;
         const char      *cp;          const char      *cp;
           const size_t     maxoff = 72;
         int              len, sign;          int              len, sign;
   
         roff_term_pre_br(p, n);          roff_term_pre_br(p, n);
Line 228  roff_term_pre_ti(ROFF_TERM_ARGS)
Line 239  roff_term_pre_ti(ROFF_TERM_ARGS)
                 return;                  return;
         len = term_hen(p, &su);          len = term_hen(p, &su);
   
         if (sign == 0) {          switch (sign) {
           case 1:
                   if (p->tcol->offset + len <= maxoff)
                           p->ti = len;
                   else if (p->tcol->offset < maxoff)
                           p->ti = maxoff - p->tcol->offset;
                   else
                           p->ti = 0;
                   break;
           case -1:
                   if ((size_t)len < p->tcol->offset)
                           p->ti = -len;
                   else
                           p->ti = -p->tcol->offset;
                   break;
           default:
                   if ((size_t)len > maxoff)
                           len = maxoff;
                 p->ti = len - p->tcol->offset;                  p->ti = len - p->tcol->offset;
                 p->tcol->offset = len;                  break;
         } else if (sign == 1) {  
                 p->ti = len;  
                 p->tcol->offset += len;  
         } else if ((size_t)len < p->tcol->offset) {  
                 p->ti = -len;  
                 p->tcol->offset -= len;  
         } else {  
                 p->ti = -p->tcol->offset;  
                 p->tcol->offset = 0;  
         }          }
           p->tcol->offset += p->ti;
 }  }

Legend:
Removed from v.1.19  
changed lines
  Added in v.1.22

CVSweb