diff options
author | Ingo Schwarze <schwarze@openbsd.org> | 2011-10-24 20:30:57 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@openbsd.org> | 2011-10-24 20:30:57 +0000 |
commit | 6cdd3db062dd695b8fc0c10cd2e58794757dfd95 (patch) | |
tree | d6ce1cabd6a3361c1c7fcdfa98c12f885e443b27 /mandoc.c | |
parent | ac8f68ab408a1cdb2e87984318940451d4ff69d8 (diff) | |
download | mandoc-6cdd3db062dd695b8fc0c10cd2e58794757dfd95.tar.gz |
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@
Diffstat (limited to 'mandoc.c')
-rw-r--r-- | mandoc.c | 28 |
1 files changed, 22 insertions, 6 deletions
@@ -161,8 +161,7 @@ mandoc_escape(const char **end, const char **start, int *sz) 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 char **start, int *sz) case ('L'): /* FALLTHROUGH */ case ('l'): - /* FALLTHROUGH */ - case ('N'): - if (ESCAPE_ERROR == gly) - gly = ESCAPE_NUMBERED; + gly = ESCAPE_NUMBERED; /* FALLTHROUGH */ case ('S'): /* FALLTHROUGH */ @@ -241,6 +237,26 @@ mandoc_escape(const char **end, const char **start, int *sz) 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. */ |