From e31a1492391aa4d678a400d3a7024f93b4dec47e Mon Sep 17 00:00:00 2001 From: Ingo Schwarze Date: Mon, 27 Oct 2014 13:31:04 +0000 Subject: Fix a regression in term.c rev. 1.229 reported by bentley@: In UTF-8 output, do not print anything if mchars_spec2cp() returns 0. In particular, this repairs handling of zero-width spaces (\&). While here, let mchars_spec2cp() return 0xFFFD instead of -1 if the character is not found, simplifying the using code. In HTML output, do not print obfuscated ASCII characters and do not test for one-char escapes, mchars_spec2cp() already does that. --- term.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'term.c') diff --git a/term.c b/term.c index 017961e0..91166906 100644 --- a/term.c +++ b/term.c @@ -1,4 +1,4 @@ -/* $Id: term.c,v 1.229 2014/10/26 17:12:03 schwarze Exp $ */ +/* $Id: term.c,v 1.230 2014/10/27 13:31:04 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons * Copyright (c) 2010-2014 Ingo Schwarze @@ -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: -- cgit v1.2.3