summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chars.c2
-rw-r--r--html.c9
-rw-r--r--mandocdb.c2
-rw-r--r--term.c10
4 files changed, 11 insertions, 12 deletions
diff --git a/chars.c b/chars.c
index 950f9edc..6c217e43 100644
--- a/chars.c
+++ b/chars.c
@@ -104,7 +104,7 @@ mchars_spec2cp(const struct mchars *arg, const char *p, size_t sz)
const struct ln *ln;
ln = find(arg, p, sz);
- return(ln != NULL ? ln->unicode : sz == 1 ? *p : -1);
+ return(ln != NULL ? ln->unicode : sz == 1 ? *p : 0xFFFD);
}
char
diff --git a/html.c b/html.c
index f1d3ad1a..95cd163e 100644
--- a/html.c
+++ b/html.c
@@ -457,11 +457,12 @@ print_encode(struct html *h, const char *p, int norecurse)
break;
case ESCAPE_SPECIAL:
c = mchars_spec2cp(h->symtab, seq, len);
- if (c > 0)
+ if (c <= 0)
+ break;
+ if (c < 0x20 || c > 0x7e)
printf("&#%d;", c);
- else if (-1 == c && 1 == len &&
- !print_escape(*seq))
- putchar((int)*seq);
+ else if ( ! print_escape(c))
+ putchar(c);
break;
case ESCAPE_NOSPACE:
if ('\0' == *p)
diff --git a/mandocdb.c b/mandocdb.c
index 3c212fc6..d03416b5 100644
--- a/mandocdb.c
+++ b/mandocdb.c
@@ -1903,7 +1903,7 @@ render_key(struct mchars *mc, struct str *key)
*/
if (write_utf8) {
- if (0 == (u = mchars_spec2cp(mc, seq, len)))
+ if ((u = mchars_spec2cp(mc, seq, len)) <= 0)
continue;
cpp = utfbuf;
if (0 == (sz = utf8(u, utfbuf)))
diff --git a/term.c b/term.c
index 8f395a9e..97f6d2bc 100644
--- a/term.c
+++ b/term.c
@@ -468,9 +468,8 @@ term_word(struct termp *p, const char *word)
encode(p, cp, ssz);
} else {
uc = mchars_spec2cp(p->symtab, seq, sz);
- if (uc <= 0)
- uc = 0xFFFD;
- encode1(p, uc);
+ if (uc > 0)
+ encode1(p, uc);
}
break;
case ESCAPE_FONTBOLD:
@@ -705,9 +704,8 @@ term_strlen(const struct termp *p, const char *cp)
} else {
c = mchars_spec2cp(p->symtab,
seq, ssz);
- if (c <= 0)
- c = 0xFFFD;
- sz += cond_width(p, c, &skip);
+ if (c > 0)
+ sz += cond_width(p, c, &skip);
}
break;
case ESCAPE_SKIPCHAR: