version 1.40, 2014/11/20 13:56:20 |
version 1.44, 2015/03/27 21:33:20 |
|
|
/* $Id$ */ |
/* $Id$ */ |
/* |
/* |
* Copyright (c) 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> |
* Copyright (c) 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> |
* Copyright (c) 2014 Ingo Schwarze <schwarze@openbsd.org> |
* Copyright (c) 2014, 2015 Ingo Schwarze <schwarze@openbsd.org> |
* |
* |
* Permission to use, copy, modify, and distribute this software for any |
* Permission to use, copy, modify, and distribute this software for any |
* purpose with or without fee is hereby granted, provided that the above |
* purpose with or without fee is hereby granted, provided that the above |
* copyright notice and this permission notice appear in all copies. |
* copyright notice and this permission notice appear in all copies. |
* |
* |
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAIM ALL WARRANTIES |
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR |
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
|
|
#include "mandoc_aux.h" |
#include "mandoc_aux.h" |
#include "out.h" |
#include "out.h" |
#include "term.h" |
#include "term.h" |
|
#include "manconf.h" |
#include "main.h" |
#include "main.h" |
|
|
static struct termp *ascii_init(enum termenc, |
static struct termp *ascii_init(enum termenc, const struct mchars *, |
const struct mchars *, char *); |
const struct manoutput *); |
static double ascii_hspan(const struct termp *, |
static double ascii_hspan(const struct termp *, |
const struct roffsu *); |
const struct roffsu *); |
static size_t ascii_width(const struct termp *, int); |
static size_t ascii_width(const struct termp *, int); |
Line 58 static size_t locale_width(const struct termp *, in |
|
Line 59 static size_t locale_width(const struct termp *, in |
|
|
|
|
|
static struct termp * |
static struct termp * |
ascii_init(enum termenc enc, const struct mchars *mchars, char *outopts) |
ascii_init(enum termenc enc, const struct mchars *mchars, |
|
const struct manoutput *outopts) |
{ |
{ |
const char *toks[5]; |
|
char *v; |
char *v; |
struct termp *p; |
struct termp *p; |
|
|
Line 69 ascii_init(enum termenc enc, const struct mchars *mcha |
|
Line 70 ascii_init(enum termenc enc, const struct mchars *mcha |
|
p->symtab = mchars; |
p->symtab = mchars; |
p->tabwidth = 5; |
p->tabwidth = 5; |
p->defrmargin = p->lastrmargin = 78; |
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->begin = ascii_begin; |
p->end = ascii_end; |
p->end = ascii_end; |
Line 97 ascii_init(enum termenc enc, const struct mchars *mcha |
|
Line 101 ascii_init(enum termenc enc, const struct mchars *mcha |
|
} |
} |
#endif |
#endif |
|
|
toks[0] = "indent"; |
if (outopts->mdoc) { |
toks[1] = "width"; |
p->mdocstyle = 1; |
toks[2] = "mdoc"; |
p->defindent = 5; |
toks[3] = "synopsis"; |
} |
toks[4] = NULL; |
if (outopts->indent) |
|
p->defindent = outopts->indent; |
|
if (outopts->width) |
|
p->defrmargin = outopts->width; |
|
if (outopts->synopsisonly) |
|
p->synopsisonly = 1; |
|
|
while (outopts && *outopts) |
|
switch (getsubopt(&outopts, UNCONST(toks), &v)) { |
|
case 0: |
|
p->defindent = (size_t)atoi(v); |
|
break; |
|
case 1: |
|
p->defrmargin = (size_t)atoi(v); |
|
break; |
|
case 2: |
|
/* |
|
* Temporary, undocumented mode |
|
* to imitate mdoc(7) output style. |
|
*/ |
|
p->mdocstyle = 1; |
|
p->defindent = 5; |
|
break; |
|
case 3: |
|
p->synopsisonly = 1; |
|
break; |
|
default: |
|
break; |
|
} |
|
|
|
/* Enforce a lower boundary. */ |
|
if (p->defrmargin < 58) |
|
p->defrmargin = 58; |
|
|
|
return(p); |
return(p); |
} |
} |
|
|
void * |
void * |
ascii_alloc(const struct mchars *mchars, char *outopts) |
ascii_alloc(const struct mchars *mchars, const struct manoutput *outopts) |
{ |
{ |
|
|
return(ascii_init(TERMENC_ASCII, mchars, outopts)); |
return(ascii_init(TERMENC_ASCII, mchars, outopts)); |
} |
} |
|
|
void * |
void * |
utf8_alloc(const struct mchars *mchars, char *outopts) |
utf8_alloc(const struct mchars *mchars, const struct manoutput *outopts) |
{ |
{ |
|
|
return(ascii_init(TERMENC_UTF8, mchars, outopts)); |
return(ascii_init(TERMENC_UTF8, mchars, outopts)); |
} |
} |
|
|
void * |
void * |
locale_alloc(const struct mchars *mchars, char *outopts) |
locale_alloc(const struct mchars *mchars, const struct manoutput *outopts) |
{ |
{ |
|
|
return(ascii_init(TERMENC_LOCALE, mchars, outopts)); |
return(ascii_init(TERMENC_LOCALE, mchars, outopts)); |
Line 169 ascii_setwidth(struct termp *p, int iop, size_t width) |
|
Line 151 ascii_setwidth(struct termp *p, int iop, size_t width) |
|
p->defrmargin = 0; |
p->defrmargin = 0; |
p->lastrmargin = p->rmargin; |
p->lastrmargin = p->rmargin; |
p->rmargin = p->maxrmargin = p->defrmargin; |
p->rmargin = p->maxrmargin = p->defrmargin; |
|
} |
|
|
|
void |
|
ascii_sepline(void *arg) |
|
{ |
|
struct termp *p; |
|
size_t i; |
|
|
|
p = (struct termp *)arg; |
|
putchar('\n'); |
|
for (i = 0; i < p->defrmargin; i++) |
|
putchar('-'); |
|
putchar('\n'); |
|
putchar('\n'); |
} |
} |
|
|
static size_t |
static size_t |