From 8a0b324b8b94885e022c49afb19b7d3a8bcc6f37 Mon Sep 17 00:00:00 2001 From: Ingo Schwarze Date: Sun, 16 Feb 2014 12:33:39 +0000 Subject: when indenting, extend the right margin accordingly, when needed; fixes a crash reported by blambert@ and a few other, similar ones --- man_term.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'man_term.c') diff --git a/man_term.c b/man_term.c index 4bd62443..10378d3a 100644 --- a/man_term.c +++ b/man_term.c @@ -1,7 +1,7 @@ -/* $Id: man_term.c,v 1.139 2013/12/22 23:34:13 schwarze Exp $ */ +/* $Id: man_term.c,v 1.140 2014/02/16 12:33:39 schwarze Exp $ */ /* * Copyright (c) 2008-2012 Kristaps Dzonsons - * Copyright (c) 2010, 2011, 2012, 2013 Ingo Schwarze + * Copyright (c) 2010-2014 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 @@ -658,7 +658,8 @@ pre_IP(DECL_ARGS) return(0); case (MAN_BODY): p->offset = mt->offset + len; - p->rmargin = p->maxrmargin; + p->rmargin = p->maxrmargin > p->offset ? + p->maxrmargin : p->offset; break; default: break; @@ -748,7 +749,8 @@ pre_TP(DECL_ARGS) return(0); case (MAN_BODY): p->offset = mt->offset + len; - p->rmargin = p->maxrmargin; + p->rmargin = p->maxrmargin > p->offset ? + p->maxrmargin : p->offset; p->trailspace = 0; p->flags &= ~TERMP_NOBREAK; break; @@ -909,8 +911,9 @@ pre_RS(DECL_ARGS) sz = (size_t)ival; mt->offset += sz; - p->rmargin = p->maxrmargin; - p->offset = mt->offset < p->rmargin ? mt->offset : p->rmargin; + p->offset = mt->offset; + p->rmargin = p->maxrmargin > p->offset ? + p->maxrmargin : p->offset; if (++mt->lmarginsz < MAXMARGINS) mt->lmargincur = mt->lmarginsz; -- cgit v1.2.3-56-ge451