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 30605 invoked from network); 13 Apr 2022 13:20:10 -0000 Received: from bsd.lv (HELO mandoc.bsd.lv) (66.111.2.12) by inbox.vuxu.org with ESMTPUTF8; 13 Apr 2022 13:20:10 -0000 Received: from fantadrom.bsd.lv (localhost [127.0.0.1]) by mandoc.bsd.lv (OpenSMTPD) with ESMTP id d826ed0c for ; Wed, 13 Apr 2022 08:20:08 -0500 (EST) Received: from localhost (mandoc.bsd.lv [local]) by mandoc.bsd.lv (OpenSMTPD) with ESMTPA id 892f3b7e for ; Wed, 13 Apr 2022 08:20:07 -0500 (EST) Date: Wed, 13 Apr 2022 08:20:07 -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: Surprisingly, groff supports multiple copy mode escapes at the X-Mailer: activitymail 1.26, http://search.cpan.org/dist/activitymail/ Content-Type: text/plain; charset=utf-8 Message-ID: <336500f0273f59f4@mandoc.bsd.lv> Log Message: ----------- Surprisingly, groff supports multiple copy mode escapes at the beginning of an escape sequence: \, \E, \EE, \EEE, and so on all do the same outside copy mode, so let them do the same in mandoc(1), too. This fixes an assertion failure triggered by \EE*X that tb@ found with afl(1). The first E was consumed by roff_expand(), but that function failed to recognize the escape sequence as the expansion of a user-defined string and handed it over to mandoc_escape(), which consumed the second E and then died on an assertion because it is not prepared to handle user-defined strings. Fix this by letting *both* functions handle arbitrary numbers of 'E's correctly. Modified Files: -------------- mandoc: mandoc.c roff.c mandoc/regress/roff/esc: Makefile Added Files: ----------- mandoc/regress/roff/esc: E1.in E1.out_ascii Revision Data ------------- Index: mandoc.c =================================================================== RCS file: /home/cvs/mandoc/mandoc/mandoc.c,v retrieving revision 1.119 retrieving revision 1.120 diff -Lmandoc.c -Lmandoc.c -u -p -r1.119 -r1.120 --- mandoc.c +++ mandoc.c @@ -1,7 +1,7 @@ -/* $Id$ */ +/* $Id$ */ /* + * Copyright (c) 2011-2015, 2017-2022 Ingo Schwarze * Copyright (c) 2008-2011, 2014 Kristaps Dzonsons - * Copyright (c) 2011-2015, 2017-2021 Ingo Schwarze * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -114,7 +114,7 @@ mandoc_escape(const char **end, const ch * it only makes a difference in copy mode. */ - if (**end == 'E') + while (**end == 'E') ++*end; /* Index: roff.c =================================================================== RCS file: /home/cvs/mandoc/mandoc/roff.c,v retrieving revision 1.380 retrieving revision 1.381 diff -Lroff.c -Lroff.c -u -p -r1.380 -r1.381 --- roff.c +++ roff.c @@ -1,6 +1,6 @@ /* $Id$ */ /* - * Copyright (c) 2010-2015, 2017-2021 Ingo Schwarze + * Copyright (c) 2010-2015, 2017-2022 Ingo Schwarze * Copyright (c) 2008-2012, 2014 Kristaps Dzonsons * * Permission to use, copy, modify, and distribute this software for any @@ -1401,7 +1401,7 @@ roff_expand(struct roff *r, struct buf * term = '\0'; cp = stesc + 1; - if (*cp == 'E') + while (*cp == 'E') cp++; esct = cp; switch (*esct) { Index: Makefile =================================================================== RCS file: /home/cvs/mandoc/mandoc/regress/roff/esc/Makefile,v retrieving revision 1.7 retrieving revision 1.8 diff -Lregress/roff/esc/Makefile -Lregress/roff/esc/Makefile -u -p -r1.7 -r1.8 --- regress/roff/esc/Makefile +++ regress/roff/esc/Makefile @@ -1,6 +1,6 @@ -# $OpenBSD: Makefile,v 1.17 2020/12/21 14:55:58 schwarze Exp $ +# $OpenBSD: Makefile,v 1.18 2022/04/13 13:11:33 schwarze Exp $ -REGRESS_TARGETS = one two multi B bs_man bs_mdoc c c_man e f h l O1 o p w z +REGRESS_TARGETS = one two multi B bs_man bs_mdoc c c_man E1 e f h l O1 o p w z REGRESS_TARGETS += ignore invalid unsupp HTML_TARGETS = f LINT_TARGETS = B h l O1 w ignore invalid unsupp --- /dev/null +++ regress/roff/esc/E1.out_ascii @@ -0,0 +1,21 @@ +ESC-E(1) General Commands Manual ESC-E(1) + +NNAAMMEE + eesscc--EE - copy-mode escaping of backslashes + +DDEESSCCRRIIPPTTIIOONN + initial text + + string expansion: myval myval myval myval + + output device: ascii ascii ascii ascii + + numerical expression test: 1 0 1 0 + + register: 1 2 3 3 + + special character: <= >= << >> + + final text + +OpenBSD April 13, 2022 OpenBSD --- /dev/null +++ regress/roff/esc/E1.in @@ -0,0 +1,27 @@ +.\" $OpenBSD: E1.in,v 1.1 2022/04/13 13:11:33 schwarze Exp $ +.Dd $Mdocdate: April 13 2022 $ +.Dt ESC-E 1 +.Os +.Sh NAME +.Nm esc-E +.Nd copy-mode escaping of backslashes +.Sh DESCRIPTION +.ds myvar myval +.nr myreg 1 1 +initial text +.Pp +string expansion: \*[myvar] \E*[myvar] \EE*[myvar] \EEE*[myvar] +.Pp +output device: \*(.T \E*[.T] \EE*(.T \EEE*(.T +.Pp +numerical expression test: \B'1' \EB'X' \EEB'2' \EEEB'Y' +.Pp +register: +\n[myreg] +\En+[myreg] +\EEn+[myreg] +\EEEn[myreg] +.Pp +special character: \(<= \E(>= \EE(<< \EEE(>> +.Pp +final text -- To unsubscribe send an email to source+unsubscribe@mandoc.bsd.lv