=================================================================== RCS file: /cvs/mandoc/term.c,v retrieving revision 1.147 retrieving revision 1.151 diff -u -p -r1.147 -r1.151 --- mandoc/term.c 2010/06/11 07:23:04 1.147 +++ mandoc/term.c 2010/06/27 01:26:20 1.151 @@ -1,6 +1,6 @@ -/* $Id: term.c,v 1.147 2010/06/11 07:23:04 kristaps Exp $ */ +/* $Id: term.c,v 1.151 2010/06/27 01:26:20 schwarze Exp $ */ /* - * Copyright (c) 2008, 2009 Kristaps Dzonsons + * Copyright (c) 2008, 2009 Kristaps Dzonsons * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -31,8 +31,6 @@ #include "chars.h" #include "out.h" #include "term.h" -#include "man.h" -#include "mdoc.h" #include "main.h" static void spec(struct termp *, const char *, size_t); @@ -87,9 +85,7 @@ term_alloc(enum termenc enc) exit(EXIT_FAILURE); } - p->tabwidth = 5; p->enc = enc; - p->defrmargin = 78; return(p); } @@ -484,9 +480,14 @@ term_word(struct termp *p, const char *word) } if ( ! (TERMP_NOSPACE & p->flags)) { - bufferc(p, ' '); - if (TERMP_SENTENCE & p->flags) + if ( ! (TERMP_KEEP & p->flags)) { + if (TERMP_PREKEEP & p->flags) + p->flags |= TERMP_KEEP; bufferc(p, ' '); + if (TERMP_SENTENCE & p->flags) + bufferc(p, ' '); + } else + bufferc(p, ASCII_NBRSP); } if ( ! (p->flags & TERMP_NONOSPACE)) @@ -626,8 +627,28 @@ encode(struct termp *p, const char *word, size_t sz) size_t -term_vspan(const struct roffsu *su) +term_len(const struct termp *p, size_t sz) { + + return((*p->width)(p, ' ') * sz); +} + + +size_t +term_strlen(const struct termp *p, const char *cp) +{ + size_t sz; + + for (sz = 0; *cp; cp++) + sz += (*p->width)(p, *cp); + + return(sz); +} + + +size_t +term_vspan(const struct termp *p, const struct roffsu *su) +{ double r; switch (su->unit) { @@ -662,7 +683,7 @@ term_vspan(const struct roffsu *su) size_t -term_hspan(const struct roffsu *su) +term_hspan(const struct termp *p, const struct roffsu *su) { double r;