From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-0.0 required=5.0 tests=T_SCC_BODY_TEXT_LINE, UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 21215 invoked from network); 6 Jun 2022 19:23:45 -0000 Received: from bsd.lv (HELO mandoc.bsd.lv) (66.111.2.12) by inbox.vuxu.org with ESMTPUTF8; 6 Jun 2022 19:23:45 -0000 Received: from fantadrom.bsd.lv (localhost [127.0.0.1]) by mandoc.bsd.lv (OpenSMTPD) with ESMTP id a5e1ee03 for ; Mon, 6 Jun 2022 14:23:43 -0500 (EST) Received: from localhost (mandoc.bsd.lv [local]) by mandoc.bsd.lv (OpenSMTPD) with ESMTPA id 9997acbe for ; Mon, 6 Jun 2022 14:23:43 -0500 (EST) Date: Mon, 6 Jun 2022 14:23:43 -0500 (EST) X-Mailinglist: mandoc-source Reply-To: source@mandoc.bsd.lv MIME-Version: 1.0 From: schwarze@mandoc.bsd.lv To: source@mandoc.bsd.lv Subject: mandoc: To better match groff parsing, reject digits and some X-Mailer: activitymail 1.26, http://search.cpan.org/dist/activitymail/ Content-Type: text/plain; charset=utf-8 Message-ID: <3365a9f56006aaa7@mandoc.bsd.lv> Log Message: ----------- To better match groff parsing, reject digits and some mathematical operators as argument delimiters for some escape sequences that take numerical arguments, in the same way as it had already been done for \h. Argument delimiter parsing for escape sequences taking numerical arguments is not perfect yet. In particular, when a character representing a scaling unit is abused as the argument delimiter, parsing for that character becomes context-dependent, and it is no longer possible to find the end of the escape sequence without calling the full numerical expression parser, which i refrain from attempting in this commit. For now, continuing to misparse insane constructions like \Bc1c+1cc (which is valid in groff and resolves to "1" because 1c+1c = two centimeters is a valid numerical expression and 'c' is also a valid delimiter) is a small price to pay for keeping complexity at bay and for not losing focus in the ongoing series of refinements. Modified Files: -------------- mandoc: roff_escape.c Revision Data ------------- Index: roff_escape.c =================================================================== RCS file: /home/cvs/mandoc/mandoc/roff_escape.c,v retrieving revision 1.11 retrieving revision 1.12 diff -Lroff_escape.c -Lroff_escape.c -u -p -r1.11 -r1.12 --- roff_escape.c +++ roff_escape.c @@ -1,4 +1,4 @@ -/* $OpenBSD$ */ +/* $Id$ */ /* * Copyright (c) 2011, 2012, 2013, 2014, 2015, 2017, 2018, 2020, 2022 * Ingo Schwarze @@ -270,12 +270,14 @@ roff_escape(const char *buf, const int l goto out_sub; if (term == '\b') { - if ((buf[inam] == 'N' && isdigit((unsigned char)buf[iarg])) || - (buf[inam] == 'h' && strchr(" %&()*+-./0123456789:<=>", - buf[iarg]) != NULL)) { - iendarg = iend = iarg + 1; - rval = ESCAPE_ERROR; - goto out; + if (strchr("BDHLRSvxNhl", buf[inam]) != NULL && + strchr(" %&()*+-./0123456789:<=>", buf[iarg]) != NULL) { + if (rval != ESCAPE_EXPAND) + rval = ESCAPE_ERROR; + if (buf[inam] != 'D') { + iendarg = iend = iarg + 1; + goto out; + } } term = buf[iarg++]; } else if (term == '\0' && maxl == INT_MAX) { -- To unsubscribe send an email to source+unsubscribe@mandoc.bsd.lv