From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from krisdoz.my.domain (kristaps@localhost [127.0.0.1]) by krisdoz.my.domain (8.14.3/8.14.3) with ESMTP id o77KXtnx005063 for ; Sat, 7 Aug 2010 16:33:55 -0400 (EDT) Received: (from kristaps@localhost) by krisdoz.my.domain (8.14.3/8.14.3/Submit) id o77KXtE8017883; Sat, 7 Aug 2010 16:33:55 -0400 (EDT) Date: Sat, 7 Aug 2010 16:33:55 -0400 (EDT) Message-Id: <201008072033.o77KXtE8017883@krisdoz.my.domain> X-Mailinglist: mdocml-source Reply-To: source@mdocml.bsd.lv MIME-Version: 1.0 From: kristaps@mdocml.bsd.lv To: source@mdocml.bsd.lv Subject: mdocml: "Groff allows the initial macro on a line to be delimited by a X-Mailer: activitymail 1.26, http://search.cpan.org/dist/activitymail/ Content-Type: text/plain; charset=utf-8 Log Message: ----------- "Groff allows the initial macro on a line to be delimited by a space of by a tab; so allow the tab in mandoc, too." Original problem noted by schwarze@. Sync with OpenBSD. Modified Files: -------------- mdocml: mdoc.c Revision Data ------------- Index: mdoc.c =================================================================== RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mdoc.c,v retrieving revision 1.159 retrieving revision 1.160 diff -Lmdoc.c -Lmdoc.c -u -p -r1.159 -r1.160 --- mdoc.c +++ mdoc.c @@ -764,11 +764,11 @@ mdoc_pmacro(struct mdoc *m, int ln, char i = offs; - /* Accept whitespace after the initial control char. */ + /* Accept tabs/whitespace after the initial control char. */ - if (' ' == buf[i]) { + if (' ' == buf[i] || '\t' == buf[i]) { i++; - while (buf[i] && ' ' == buf[i]) + while (buf[i] && (' ' == buf[i] || '\t' == buf[i])) i++; if ('\0' == buf[i]) return(1); @@ -776,15 +776,19 @@ mdoc_pmacro(struct mdoc *m, int ln, char sv = i; - /* Copy the first word into a nil-terminated buffer. */ + /* + * Copy the first word into a nil-terminated buffer. Stop + * copying when a tab, space, or eoln is encountered. + */ for (j = 0; j < 4; j++, i++) { if ('\0' == (mac[j] = buf[i])) break; - else if (' ' == buf[i]) + else if (' ' == buf[i] || '\t' == buf[i]) break; /* Check for invalid characters. */ + /* TODO: remove me, already done in main.c. */ if (isgraph((u_char)buf[i])) continue; @@ -807,7 +811,12 @@ mdoc_pmacro(struct mdoc *m, int ln, char return(1); } - /* The macro is sane. Jump to the next word. */ + /* Disregard the first trailing tab, if applicable. */ + + if ('\t' == buf[i]) + i++; + + /* Jump to the next non-whitespace word. */ while (buf[i] && ' ' == buf[i]) i++; -- To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv