=================================================================== RCS file: /cvs/mandoc/term_ascii.c,v retrieving revision 1.26 retrieving revision 1.32 diff -u -p -r1.26 -r1.32 --- mandoc/term_ascii.c 2014/07/27 21:52:16 1.26 +++ mandoc/term_ascii.c 2014/08/17 22:10:29 1.32 @@ -1,4 +1,4 @@ -/* $Id: term_ascii.c,v 1.26 2014/07/27 21:52:16 schwarze Exp $ */ +/* $Id: term_ascii.c,v 1.32 2014/08/17 22:10:29 schwarze Exp $ */ /* * Copyright (c) 2010, 2011 Kristaps Dzonsons * Copyright (c) 2014 Ingo Schwarze @@ -15,21 +15,19 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#ifdef HAVE_CONFIG_H #include "config.h" -#endif #include -#ifdef USE_WCHAR -# include +#if HAVE_WCHAR +#include #endif #include #include #include #include -#ifdef USE_WCHAR -# include +#if HAVE_WCHAR +#include #endif #include "mandoc.h" @@ -38,17 +36,6 @@ #include "term.h" #include "main.h" -/* - * Sadly, this doesn't seem to be defined on systems even when they - * support it. For the time being, remove it and let those compiling - * the software decide for themselves what to use. - */ -#if 0 -#if ! defined(__STDC_ISO_10646__) -# undef USE_WCHAR -#endif -#endif - static struct termp *ascii_init(enum termenc, char *); static double ascii_hspan(const struct termp *, const struct roffsu *); @@ -60,7 +47,7 @@ static void ascii_endline(struct termp *); static void ascii_letter(struct termp *, int); static void ascii_setwidth(struct termp *, int, size_t); -#ifdef USE_WCHAR +#if HAVE_WCHAR static void locale_advance(struct termp *, size_t); static void locale_endline(struct termp *); static void locale_letter(struct termp *, int); @@ -92,7 +79,7 @@ ascii_init(enum termenc enc, char *outopts) p->setwidth = ascii_setwidth; p->width = ascii_width; -#ifdef USE_WCHAR +#if HAVE_WCHAR if (TERMENC_ASCII != enc) { v = TERMENC_LOCALE == enc ? setlocale(LC_ALL, "") : @@ -232,38 +219,49 @@ ascii_hspan(const struct termp *p, const struct roffsu double r; /* - * Approximate based on character width. These are generated - * entirely by eyeballing the screen, but appear to be correct. + * Approximate based on character width. + * None of these will be actually correct given that an inch on + * the screen depends on character size, terminal, etc., etc. */ - switch (su->unit) { + case SCALE_BU: + r = su->scale * 10.0 / 240.0; + break; case SCALE_CM: - r = 4 * su->scale; + r = su->scale * 10.0 / 2.54; break; + case SCALE_FS: + r = su->scale * 2730.666; + break; case SCALE_IN: - r = 10 * su->scale; + r = su->scale * 10.0; break; + case SCALE_MM: + r = su->scale / 100.0; + break; case SCALE_PC: - r = (10 * su->scale) / 6; + r = su->scale * 10.0 / 6.0; break; case SCALE_PT: - r = (10 * su->scale) / 72; + r = su->scale * 10.0 / 72.0; break; - case SCALE_MM: - r = su->scale / 1000; - break; case SCALE_VS: - r = su->scale * 2 - 1; + r = su->scale * 2.0 - 1.0; break; - default: + case SCALE_EN: + /* FALLTHROUGH */ + case SCALE_EM: r = su->scale; break; + default: + abort(); + /* NOTREACHED */ } return(r); } -#ifdef USE_WCHAR +#if HAVE_WCHAR static size_t locale_width(const struct termp *p, int c) {