source@mandoc.bsd.lv
 help / color / Atom feed
* docbook2mdoc: support hexadecimal character entities; patch from Hiltjo 
@ 2019-05-07 23:42 schwarze
  0 siblings, 0 replies; only message in thread
From: schwarze @ 2019-05-07 23:42 UTC (permalink / raw)
  To: source

Log Message:
-----------
support hexadecimal character entities;
patch from Hiltjo Posthuma <hiltjo at codemadness at org>,
tweaked by me

Modified Files:
--------------
    docbook2mdoc:
        parse.c

Revision Data
-------------
Index: parse.c
===================================================================
RCS file: /home/cvs/mdocml/docbook2mdoc/parse.c,v
retrieving revision 1.59
retrieving revision 1.60
diff -Lparse.c -Lparse.c -u -p -r1.59 -r1.60
--- parse.c
+++ parse.c
@@ -376,7 +376,7 @@ xml_entity(struct parse *p, const char *
 	struct pnode		*n;
 	const char		*ccp;
 	char			*cp;
-	unsigned int		 codepoint;
+	long			 codepoint;
 	enum pstate		 pstate;
 
 	if (p->del > 0)
@@ -421,8 +421,16 @@ xml_entity(struct parse *p, const char *
 			}
 		}
 		if (*name == '#') {
-			codepoint = strtonum(name + 1, 0, 0x10ffff, &ccp);
-			if (ccp == NULL) {
+			errno = 0;
+			if (name[1] == 'x') {
+				ccp = name + 2;
+				codepoint = strtol(ccp, &cp, 16);
+			} else {
+				ccp = name + 1;
+				codepoint = strtol(ccp, &cp, 10);
+			}
+			if (*ccp != '\0' && *cp == '\0' && errno != ERANGE &&
+			    codepoint >= 0 && codepoint <= 0x10ffff) {
 				n = pnode_alloc(p->cur);
 				xasprintf(&n->b, "\\[u%4.4X]", codepoint);
 				goto done;
--
 To unsubscribe send an email to source+unsubscribe@mandoc.bsd.lv

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, back to index

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-07 23:42 docbook2mdoc: support hexadecimal character entities; patch from Hiltjo schwarze

source@mandoc.bsd.lv

Archives are clonable: git clone --mirror http://inbox.vuxu.org/mandoc-source

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://inbox.vuxu.org/vuxu.archive.mandoc.source


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git