the libroff point. This clears up a nice chunk of code.
-/* $Id: chars.c,v 1.45 2011/05/24 21:24:16 kristaps Exp $ */
+/* $Id: chars.c,v 1.46 2011/05/24 21:31:23 kristaps Exp $ */
/*
* Copyright (c) 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2011 Ingo Schwarze <schwarze@openbsd.org>
return(ln->unicode);
}
-
-/*
- * Reserved word to Unicode codepoint.
- */
-int
-mchars_res2cp(struct mchars *arg, const char *p, size_t sz)
-{
- const struct ln *ln;
-
- ln = find(arg, p, sz);
- if (NULL == ln)
- return(-1);
- return(ln->unicode);
-}
-
/*
* Numbered character string to ASCII codepoint.
* This can only be a printable character (i.e., alnum, punct, space) so
return(ln->ascii);
}
-/*
- * Reserved word to string array.
- */
-const char *
-mchars_res2str(struct mchars *arg, const char *p, size_t sz, size_t *rsz)
-{
- const struct ln *ln;
-
- ln = find(arg, p, sz);
- if (NULL == ln)
- return(NULL);
-
- *rsz = strlen(ln->ascii);
- return(ln->ascii);
-}
-
static const struct ln *
find(struct mchars *tab, const char *p, size_t sz)
{
-/* $Id: html.c,v 1.145 2011/05/18 23:59:08 kristaps Exp $ */
+/* $Id: html.c,v 1.146 2011/05/24 21:31:23 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2011 Ingo Schwarze <schwarze@openbsd.org>
static void bufncat(struct html *, const char *, size_t);
static void print_spec(struct html *, const char *, size_t);
-static void print_res(struct html *, const char *, size_t);
static void print_ctag(struct html *, enum htmltag);
static int print_encode(struct html *, const char *, int);
static void print_metaf(struct html *, enum mandoc_esc);
fwrite(rhs, 1, sz, stdout);
}
-
-static void
-print_res(struct html *h, const char *p, size_t len)
-{
- int cp;
- const char *rhs;
- size_t sz;
-
- if ((cp = mchars_res2cp(h->symtab, p, len)) > 0) {
- printf("&#%d;", cp);
- return;
- } else if (-1 == cp)
- return;
-
- if (NULL != (rhs = mchars_res2str(h->symtab, p, len, &sz)))
- fwrite(rhs, 1, sz, stdout);
-}
-
-
static void
print_metaf(struct html *h, enum mandoc_esc deco)
{
/* FALLTHROUGH */
case (ESCAPE_NUMBERED):
/* FALLTHROUGH */
- case (ESCAPE_PREDEF):
- /* FALLTHROUGH */
case (ESCAPE_SPECIAL):
sz++;
break;
if ('\0' != c)
putchar(c);
break;
- case (ESCAPE_PREDEF):
- print_res(h, seq, len);
- break;
case (ESCAPE_SPECIAL):
print_spec(h, seq, len);
break;
-.\" $Id: mandoc.3,v 1.8 2011/05/17 12:22:15 kristaps Exp $
+.\" $Id: mandoc.3,v 1.9 2011/05/24 21:31:23 kristaps Exp $
.\"
.\" Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
.\" Copyright (c) 2010 Ingo Schwarze <schwarze@openbsd.org>
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
-.Dd $Mdocdate: May 17 2011 $
+.Dd $Mdocdate: May 24 2011 $
.Dt MANDOC 3
.Os
.Sh NAME
.Nm mchars_free ,
.Nm mchars_num2char ,
.Nm mchars_num2uc ,
-.Nm mchars_res2cp ,
-.Nm mchars_res2str ,
.Nm mchars_spec2cp ,
.Nm mchars_spec2str ,
.Nm mdoc_meta ,
.Ft int
.Fn mchars_num2uc "const char *cp" "size_t sz"
.Ft "const char *"
-.Fo mchars_res2str
-.Fa "struct mchars *p"
-.Fa "const char *cp"
-.Fa "size_t sz"
-.Fa "size_t *rsz"
-.Fc
-.Ft int
-.Fo mchars_res2cp
-.Fa "struct mchars *p"
-.Fa "const char *cp"
-.Fa "size_t sz"
-.Ft "const char *"
-.Fc
-.Ft "const char *"
.Fo mchars_spec2str
.Fa "struct mchars *p"
.Fa "const char *cp"
Convert a hexadecimal character index (e.g., the \e[uNNNN] escape) into
a Unicode codepoint.
Returns \e0 (the nil character) if the input sequence is malformed.
-.It Fn mchars_res2cp
-Convert a predefined character into a valid Unicode codepoint.
-Returns \-1 on failure and 0 if no code-point exists (if this occurs,
-the caller should fall back to
-.Fn mchars_res2str ) .
-.It Fn mchars_res2str
-Convert a predefined character into an ASCII string.
-Returns NULL on failure.
.It Fn mchars_spec2cp
Convert a special character into a valid Unicode codepoint.
Returns \-1 on failure and 0 if no code-point exists (if this occurs,
-/* $Id: mandoc.c,v 1.52 2011/05/15 15:30:33 kristaps Exp $ */
+/* $Id: mandoc.c,v 1.53 2011/05/24 21:31:23 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2011 Ingo Schwarze <schwarze@openbsd.org>
if (ESCAPE_ERROR == gly)
gly = ESCAPE_IGNORE;
/* FALLTHROUGH */
- case ('*'):
- if (ESCAPE_ERROR == gly)
- gly = ESCAPE_PREDEF;
- /* FALLTHROUGH */
case ('f'):
if (ESCAPE_ERROR == gly)
gly = ESCAPE_FONT;
-/* $Id: mandoc.h,v 1.76 2011/05/17 11:50:20 kristaps Exp $ */
+/* $Id: mandoc.h,v 1.77 2011/05/24 21:31:23 kristaps Exp $ */
/*
* Copyright (c) 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
*
ESCAPE_ERROR = 0, /* bail! unparsable escape */
ESCAPE_IGNORE, /* escape to be ignored */
ESCAPE_SPECIAL, /* a regular special character */
- ESCAPE_PREDEF, /* a predefined special character */
ESCAPE_FONT, /* a generic font mode */
ESCAPE_FONTBOLD, /* bold font mode */
ESCAPE_FONTITALIC, /* italic font mode */
int mchars_num2uc(const char *, size_t);
const char *mchars_spec2str(struct mchars *, const char *, size_t, size_t *);
int mchars_spec2cp(struct mchars *, const char *, size_t);
-const char *mchars_res2str(struct mchars *, const char *, size_t, size_t *);
-int mchars_res2cp(struct mchars *, const char *, size_t);
void mchars_free(struct mchars *);
-/* $Id: term.c,v 1.196 2011/05/20 15:44:55 kristaps Exp $ */
+/* $Id: term.c,v 1.197 2011/05/24 21:31:23 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010, 2011 Ingo Schwarze <schwarze@openbsd.org>
break;
encode1(p, uc);
continue;
- case (ESCAPE_PREDEF):
- uc = mchars_res2cp(p->symtab, seq, sz);
- if (uc <= 0)
- break;
- encode1(p, uc);
- continue;
case (ESCAPE_SPECIAL):
uc = mchars_spec2cp(p->symtab, seq, sz);
if (uc <= 0)
if ('\0' != c)
encode(p, &c, 1);
break;
- case (ESCAPE_PREDEF):
- cp = mchars_res2str(p->symtab, seq, sz, &ssz);
- if (NULL != cp)
- encode(p, cp, ssz);
- break;
case (ESCAPE_SPECIAL):
cp = mchars_spec2str(p->symtab, seq, sz, &ssz);
if (NULL != cp)
break;
sz += (*p->width)(p, c);
continue;
- case (ESCAPE_PREDEF):
- c = mchars_res2cp
- (p->symtab, seq, ssz);
- if (c <= 0)
- break;
- sz += (*p->width)(p, c);
- continue;
case (ESCAPE_SPECIAL):
c = mchars_spec2cp
(p->symtab, seq, ssz);
if ('\0' != c)
sz += (*p->width)(p, c);
break;
- case (ESCAPE_PREDEF):
- rhs = mchars_res2str
- (p->symtab, seq, ssz, &rsz);
- break;
case (ESCAPE_SPECIAL):
rhs = mchars_spec2str
(p->symtab, seq, ssz, &rsz);