summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2010-07-21 20:35:03 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2010-07-21 20:35:03 +0000
commit1b939f3fc9a59c4dd5ac04a9c995a8457d4ee32a (patch)
treea3a2b528ee1e0f2ca5ccac1c1261a4a0683a01f3
parent52a2d24a5977427830c9757b19fb36e1d1ac5307 (diff)
downloadmandoc-1b939f3fc9a59c4dd5ac04a9c995a8457d4ee32a.tar.gz
mandoc-1b939f3fc9a59c4dd5ac04a9c995a8457d4ee32a.tar.zst
mandoc-1b939f3fc9a59c4dd5ac04a9c995a8457d4ee32a.zip
Accomodate for groff's crappy behaviour wherein an unrecognised
single-character escape (and ONLY this type of escape) will map back into itself: "If a backslash is followed by a character that does not constitute a defined escape sequence the backslash is silently ignored and the character maps to itself." (From groff.7.) Found by Jason McIntyre.
-rw-r--r--html.c14
-rw-r--r--mandoc.c4
-rw-r--r--out.c4
-rw-r--r--out.h7
-rw-r--r--term.c13
5 files changed, 27 insertions, 15 deletions
diff --git a/html.c b/html.c
index 5e19b09c..070562fb 100644
--- a/html.c
+++ b/html.c
@@ -1,4 +1,4 @@
-/* $Id: html.c,v 1.107 2010/07/16 22:33:30 kristaps Exp $ */
+/* $Id: html.c,v 1.108 2010/07/21 20:35:03 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -88,7 +88,8 @@ static const char *const htmlattrs[ATTR_MAX] = {
"summary",
};
-static void print_spec(struct html *, const char *, size_t);
+static void print_spec(struct html *, enum roffdeco,
+ const char *, size_t);
static void print_res(struct html *, const char *, size_t);
static void print_ctag(struct html *, enum htmltag);
static void print_doctype(struct html *);
@@ -215,7 +216,7 @@ print_gen_head(struct html *h)
static void
-print_spec(struct html *h, const char *p, size_t len)
+print_spec(struct html *h, enum roffdeco d, const char *p, size_t len)
{
int cp;
const char *rhs;
@@ -224,6 +225,9 @@ print_spec(struct html *h, const char *p, size_t len)
if ((cp = chars_spec2cp(h->symtab, p, len)) > 0) {
printf("&#%d;", cp);
return;
+ } else if (-1 == cp && DECO_SSPECIAL == d) {
+ fwrite(p, 1, len, stdout);
+ return;
} else if (-1 == cp)
return;
@@ -342,8 +346,10 @@ print_encode(struct html *h, const char *p, int norecurse)
case (DECO_RESERVED):
print_res(h, seq, sz);
break;
+ case (DECO_SSPECIAL):
+ /* FALLTHROUGH */
case (DECO_SPECIAL):
- print_spec(h, seq, sz);
+ print_spec(h, deco, seq, sz);
break;
case (DECO_PREVIOUS):
/* FALLTHROUGH */
diff --git a/mandoc.c b/mandoc.c
index c001b637..69972c04 100644
--- a/mandoc.c
+++ b/mandoc.c
@@ -1,4 +1,4 @@
-/* $Id: mandoc.c,v 1.24 2010/07/18 22:55:06 kristaps Exp $ */
+/* $Id: mandoc.c,v 1.25 2010/07/21 20:35:03 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -314,7 +314,7 @@ mandoc_eos(const char *p, size_t sz, int enclosed)
*/
found = 0;
- for (q = p + sz - 1; q >= p; q--) {
+ for (q = p + (int)sz - 1; q >= p; q--) {
switch (*q) {
case ('\"'):
/* FALLTHROUGH */
diff --git a/out.c b/out.c
index 1077aaed..62fda5cf 100644
--- a/out.c
+++ b/out.c
@@ -1,4 +1,4 @@
-/* $Id: out.c,v 1.20 2010/07/19 07:53:40 kristaps Exp $ */
+/* $Id: out.c,v 1.21 2010/07/21 20:35:03 kristaps Exp $ */
/*
* Copyright (c) 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -278,7 +278,7 @@ a2roffdeco(enum roffdeco *d, const char **word, size_t *sz)
*d = DECO_NOSPACE;
return(i);
default:
- *d = DECO_SPECIAL;
+ *d = DECO_SSPECIAL;
i--;
lim = 1;
break;
diff --git a/out.h b/out.h
index fd1e5bd8..13665e46 100644
--- a/out.h
+++ b/out.h
@@ -1,4 +1,4 @@
-/* $Id: out.h,v 1.13 2010/07/18 22:55:06 kristaps Exp $ */
+/* $Id: out.h,v 1.14 2010/07/21 20:35:03 kristaps Exp $ */
/*
* Copyright (c) 2009 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -37,8 +37,9 @@ enum roffscale {
enum roffdeco {
DECO_NONE,
- DECO_SPECIAL,
- DECO_RESERVED,
+ DECO_SPECIAL, /* special character */
+ DECO_SSPECIAL, /* single-char special */
+ DECO_RESERVED, /* reserved word */
DECO_BOLD,
DECO_ITALIC,
DECO_ROMAN,
diff --git a/term.c b/term.c
index de8c3380..dd7aac50 100644
--- a/term.c
+++ b/term.c
@@ -1,4 +1,4 @@
-/* $Id: term.c,v 1.162 2010/07/17 12:01:43 kristaps Exp $ */
+/* $Id: term.c,v 1.163 2010/07/21 20:35:03 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010 Ingo Schwarze <schwarze@openbsd.org>
@@ -34,7 +34,8 @@
#include "term.h"
#include "main.h"
-static void spec(struct termp *, const char *, size_t);
+static void spec(struct termp *, enum roffdeco,
+ const char *, size_t);
static void res(struct termp *, const char *, size_t);
static void buffera(struct termp *, const char *, size_t);
static void bufferc(struct termp *, char);
@@ -360,7 +361,7 @@ term_vspace(struct termp *p)
static void
-spec(struct termp *p, const char *word, size_t len)
+spec(struct termp *p, enum roffdeco d, const char *word, size_t len)
{
const char *rhs;
size_t sz;
@@ -368,6 +369,8 @@ spec(struct termp *p, const char *word, size_t len)
rhs = chars_spec2str(p->symtab, word, len, &sz);
if (rhs)
encode(p, rhs, sz);
+ else if (DECO_SSPECIAL == d)
+ encode(p, word, len);
}
@@ -519,7 +522,9 @@ term_word(struct termp *p, const char *word)
res(p, seq, ssz);
break;
case (DECO_SPECIAL):
- spec(p, seq, ssz);
+ /* FALLTHROUGH */
+ case (DECO_SSPECIAL):
+ spec(p, deco, seq, ssz);
break;
case (DECO_BOLD):
term_fontrepl(p, TERMFONT_BOLD);