source@mandoc.bsd.lv
 help / color / mirror / Atom feed
* mdocml: Handle \N numbered character escapes the same way as groff: If
@ 2011-10-24 20:30 schwarze
  0 siblings, 0 replies; only message in thread
From: schwarze @ 2011-10-24 20:30 UTC (permalink / raw)
  To: source

Log Message:
-----------
Handle \N numbered character escapes the same way as groff:
If \N is followed by a digit, ignore \N and the digit.
If \N is followed by a non-digit, the next non-digit
ends the character number; the two delimiters need not match.
Kristaps calls that "gross, but not our fault".

For now, i'm fixing \N only.  Other escapes taking numeric arguments
may or may not need similar handling, but \N is by far the most
important for practical purposes.

ok kristaps@

Modified Files:
--------------
    mdocml:
        mandoc.c

Revision Data
-------------
Index: mandoc.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mandoc.c,v
retrieving revision 1.59
retrieving revision 1.60
diff -Lmandoc.c -Lmandoc.c -u -p -r1.59 -r1.60
--- mandoc.c
+++ mandoc.c
@@ -161,8 +161,7 @@ mandoc_escape(const char **end, const ch
 	case ('V'):
 		/* FALLTHROUGH */
 	case ('Y'):
-		if (ESCAPE_ERROR == gly)
-			gly = ESCAPE_IGNORE;
+		gly = ESCAPE_IGNORE;
 		/* FALLTHROUGH */
 	case ('f'):
 		if (ESCAPE_ERROR == gly)
@@ -222,10 +221,7 @@ mandoc_escape(const char **end, const ch
 	case ('L'):
 		/* FALLTHROUGH */
 	case ('l'):
-		/* FALLTHROUGH */
-	case ('N'):
-		if (ESCAPE_ERROR == gly)
-			gly = ESCAPE_NUMBERED;
+		gly = ESCAPE_NUMBERED;
 		/* FALLTHROUGH */
 	case ('S'):
 		/* FALLTHROUGH */
@@ -240,6 +236,26 @@ mandoc_escape(const char **end, const ch
 			return(ESCAPE_ERROR);
 		term = numeric = '\'';
 		break;
+
+	/*
+	 * Special handling for the numbered character escape.
+	 * XXX Do any other escapes need similar handling?
+	 */
+	case ('N'):
+		if ('\0' == cp[i])
+			return(ESCAPE_ERROR);
+		*end = &cp[++i];
+		if (isdigit((unsigned char)cp[i-1]))
+			return(ESCAPE_IGNORE);
+		while (isdigit((unsigned char)**end))
+			(*end)++;
+		if (start)
+			*start = &cp[i];
+		if (sz)
+			*sz = *end - &cp[i];
+		if ('\0' != **end)
+			(*end)++;
+		return(ESCAPE_NUMBERED);
 
 	/* 
 	 * Sizes get a special category of their own.
--
 To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv

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

only message in thread, other threads:[~2011-10-24 20:30 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-10-24 20:30 mdocml: Handle \N numbered character escapes the same way as groff: If schwarze

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).