From: schwarze@mdocml.bsd.lv
To: source@mdocml.bsd.lv
Subject: mdocml: Escape sequences terminate high-level macro names, and when
Date: Tue, 18 Nov 2014 22:08:17 -0500 (EST) [thread overview]
Message-ID: <201411190308.sAJ38H8j018233@krisdoz.my.domain> (raw)
Log Message:
-----------
Escape sequences terminate high-level macro names, and when doing so,
they are ignored, just in the same way as for request names
and for low-level macro names.
This also cures a warning in the pod2man(1) preamble.
Modified Files:
--------------
mdocml:
man.c
mdoc.c
Revision Data
-------------
Index: man.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/man.c,v
retrieving revision 1.142
retrieving revision 1.143
diff -Lman.c -Lman.c -u -p -r1.142 -r1.143
--- man.c
+++ man.c
@@ -483,35 +483,50 @@ man_ptext(struct man *man, int line, cha
static int
man_pmacro(struct man *man, int ln, char *buf, int offs)
{
- char mac[5];
struct man_node *n;
+ const char *cp;
enum mant tok;
int i, ppos;
int bline;
+ char mac[5];
ppos = offs;
/*
* Copy the first word into a nil-terminated buffer.
- * Stop copying when a tab, space, or eoln is encountered.
+ * Stop when a space, tab, escape, or eoln is encountered.
*/
i = 0;
- while (i < 4 && '\0' != buf[offs] && ' ' != buf[offs] &&
- '\t' != buf[offs])
+ while (i < 4 && strchr(" \t\\", buf[offs]) == NULL)
mac[i++] = buf[offs++];
mac[i] = '\0';
tok = (i > 0 && i < 4) ? man_hash_find(mac) : MAN_MAX;
- if (MAN_MAX == tok) {
+ if (tok == MAN_MAX) {
mandoc_msg(MANDOCERR_MACRO, man->parse,
ln, ppos, buf + ppos - 1);
return(1);
}
- /* The macro is sane. Jump to the next word. */
+ /* Skip a leading escape sequence or tab. */
+
+ switch (buf[offs]) {
+ case '\\':
+ cp = buf + offs + 1;
+ mandoc_escape(&cp, NULL, NULL);
+ offs = cp - buf;
+ break;
+ case '\t':
+ offs++;
+ break;
+ default:
+ break;
+ }
+
+ /* Jump to the next non-whitespace word. */
while (buf[offs] && ' ' == buf[offs])
offs++;
Index: mdoc.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mdoc.c,v
retrieving revision 1.228
retrieving revision 1.229
diff -Lmdoc.c -Lmdoc.c -u -p -r1.228 -r1.229
--- mdoc.c
+++ mdoc.c
@@ -734,37 +734,47 @@ mdoc_ptext(struct mdoc *mdoc, int line,
static int
mdoc_pmacro(struct mdoc *mdoc, int ln, char *buf, int offs)
{
+ struct mdoc_node *n;
+ const char *cp;
enum mdoct tok;
int i, sv;
char mac[5];
- struct mdoc_node *n;
sv = offs;
/*
* Copy the first word into a nil-terminated buffer.
- * Stop copying when a tab, space, or eoln is encountered.
+ * Stop when a space, tab, escape, or eoln is encountered.
*/
i = 0;
- while (i < 4 && '\0' != buf[offs] && ' ' != buf[offs] &&
- '\t' != buf[offs])
+ while (i < 4 && strchr(" \t\\", buf[offs]) == NULL)
mac[i++] = buf[offs++];
mac[i] = '\0';
tok = (i > 1 && i < 4) ? mdoc_hash_find(mac) : MDOC_MAX;
- if (MDOC_MAX == tok) {
+ if (tok == MDOC_MAX) {
mandoc_msg(MANDOCERR_MACRO, mdoc->parse,
ln, sv, buf + sv - 1);
return(1);
}
- /* Disregard the first trailing tab, if applicable. */
+ /* Skip a leading escape sequence or tab. */
- if ('\t' == buf[offs])
+ switch (buf[offs]) {
+ case '\\':
+ cp = buf + offs + 1;
+ mandoc_escape(&cp, NULL, NULL);
+ offs = cp - buf;
+ break;
+ case '\t':
offs++;
+ break;
+ default:
+ break;
+ }
/* Jump to the next non-whitespace word. */
--
To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv
reply other threads:[~2014-11-19 3:08 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=201411190308.sAJ38H8j018233@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).