=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/mandoc/roff_term.c,v retrieving revision 1.20 retrieving revision 1.21 diff -c -r1.20 -r1.21 *** src/usr.bin/mandoc/roff_term.c 2020/09/03 17:37:06 1.20 --- src/usr.bin/mandoc/roff_term.c 2020/09/03 20:33:20 1.21 *************** *** 1,6 **** ! /* $OpenBSD: roff_term.c,v 1.20 2020/09/03 17:37:06 schwarze Exp $ */ /* ! * Copyright (c) 2010,2014,2015,2017-2019 Ingo Schwarze * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above --- 1,6 ---- ! /* $OpenBSD: roff_term.c,v 1.21 2020/09/03 20:33:20 schwarze Exp $ */ /* ! * Copyright (c) 2010,2014,2015,2017-2020 Ingo Schwarze * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above *************** *** 155,163 **** roff_term_pre_po(ROFF_TERM_ARGS) { struct roffsu su; ! static int po, polast; int ponew; if (n->child != NULL && a2roffsu(n->child->string, &su, SCALE_EM) != NULL) { ponew = term_hen(p, &su); --- 155,167 ---- roff_term_pre_po(ROFF_TERM_ARGS) { struct roffsu su; ! static int po, pouse, polast; int ponew; + /* Revert the currently active page offset. */ + p->tcol->offset -= pouse; + + /* Determine the requested page offset. */ if (n->child != NULL && a2roffsu(n->child->string, &su, SCALE_EM) != NULL) { ponew = term_hen(p, &su); *************** *** 166,176 **** ponew += po; } else ponew = polast; polast = po; po = ponew; ! ponew = po - polast + (int)p->tcol->offset; ! p->tcol->offset = ponew > 0 ? ponew : 0; } static void --- 170,184 ---- ponew += po; } else ponew = polast; + + /* Remeber both the previous and the newly requested offset. */ polast = po; po = ponew; ! /* Truncate to the range [-offset, 60], remember, and apply it. */ ! pouse = po >= 60 ? 60 : ! po < -(int)p->tcol->offset ? -p->tcol->offset : po; ! p->tcol->offset += pouse; } static void