=================================================================== RCS file: /cvs/mandoc/term_ascii.c,v retrieving revision 1.38 retrieving revision 1.41 diff -u -p -r1.38 -r1.41 --- mandoc/term_ascii.c 2014/10/28 17:36:19 1.38 +++ mandoc/term_ascii.c 2014/12/19 17:12:04 1.41 @@ -1,4 +1,4 @@ -/* $Id: term_ascii.c,v 1.38 2014/10/28 17:36:19 schwarze Exp $ */ +/* $Id: term_ascii.c,v 1.41 2014/12/19 17:12:04 schwarze Exp $ */ /* * Copyright (c) 2010, 2011 Kristaps Dzonsons * Copyright (c) 2014 Ingo Schwarze @@ -19,6 +19,7 @@ #include +#include #if HAVE_WCHAR #include #endif @@ -68,6 +69,9 @@ ascii_init(enum termenc enc, const struct mchars *mcha p->symtab = mchars; p->tabwidth = 5; p->defrmargin = p->lastrmargin = 78; + p->fontq = mandoc_reallocarray(NULL, + (p->fontsz = 8), sizeof(enum termfont)); + p->fontq[0] = p->fontl = TERMFONT_NONE; p->begin = ascii_begin; p->end = ascii_end; @@ -158,12 +162,14 @@ ascii_setwidth(struct termp *p, int iop, size_t width) { p->rmargin = p->defrmargin; - if (0 < iop) + if (iop > 0) p->defrmargin += width; - else if (0 > iop) + else if (iop == 0) + p->defrmargin = width ? width : p->lastrmargin; + else if (p->defrmargin > width) p->defrmargin -= width; else - p->defrmargin = width ? width : p->lastrmargin; + p->defrmargin = 0; p->lastrmargin = p->rmargin; p->rmargin = p->maxrmargin = p->defrmargin; } @@ -337,8 +343,7 @@ ascii_uc2str(int uc) "j", "DZ", "Dz", "dz", "'\bG", "'\bg", "HV", "W", "`\bN", "`\bn", "A", "a", "'\bAE","'\bae","O", "o"}; - if (uc < 0) - return(""); + assert(uc >= 0); if ((size_t)uc < sizeof(tab)/sizeof(tab[0])) return(tab[uc]); return(mchars_uc2str(uc));