source@mandoc.bsd.lv
 help / color / mirror / Atom feed
From: schwarze@mdocml.bsd.lv
To: source@mdocml.bsd.lv
Subject: mdocml: Fix a regression in term.c rev.
Date: Mon, 27 Oct 2014 09:31:04 -0400 (EDT)	[thread overview]
Message-ID: <201410271331.s9RDV480009521@krisdoz.my.domain> (raw)

Log Message:
-----------
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.

Modified Files:
--------------
    mdocml:
        chars.c
        html.c
        mandocdb.c
        term.c

Revision Data
-------------
Index: term.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/term.c,v
retrieving revision 1.229
retrieving revision 1.230
diff -Lterm.c -Lterm.c -u -p -r1.229 -r1.230
--- term.c
+++ term.c
@@ -468,9 +468,8 @@ term_word(struct termp *p, const char *w
 					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
 				} 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:
Index: chars.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/chars.c,v
retrieving revision 1.61
retrieving revision 1.62
diff -Lchars.c -Lchars.c -u -p -r1.61 -r1.62
--- chars.c
+++ chars.c
@@ -104,7 +104,7 @@ mchars_spec2cp(const struct mchars *arg,
 	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
Index: html.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/html.c,v
retrieving revision 1.177
retrieving revision 1.178
diff -Lhtml.c -Lhtml.c -u -p -r1.177 -r1.178
--- html.c
+++ html.c
@@ -457,11 +457,12 @@ print_encode(struct html *h, const char 
 			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)
Index: mandocdb.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mandocdb.c,v
retrieving revision 1.166
retrieving revision 1.167
diff -Lmandocdb.c -Lmandocdb.c -u -p -r1.166 -r1.167
--- mandocdb.c
+++ mandocdb.c
@@ -1903,7 +1903,7 @@ render_key(struct mchars *mc, struct str
 		 */
 
 		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)))
--
 To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv

                 reply	other threads:[~2014-10-27 13:31 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=201410271331.s9RDV480009521@krisdoz.my.domain \
    --to=schwarze@mdocml.bsd.lv \
    --cc=source@mdocml.bsd.lv \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).