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=UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 24059 invoked from network); 27 Apr 2022 13:41:48 -0000 Received: from bsd.lv (HELO mandoc.bsd.lv) (66.111.2.12) by inbox.vuxu.org with ESMTPUTF8; 27 Apr 2022 13:41:48 -0000 Received: from fantadrom.bsd.lv (localhost [127.0.0.1]) by mandoc.bsd.lv (OpenSMTPD) with ESMTP id a39fe348 for ; Wed, 27 Apr 2022 08:41:45 -0500 (EST) Received: from localhost (mandoc.bsd.lv [local]) by mandoc.bsd.lv (OpenSMTPD) with ESMTPA id 461fa279 for ; Wed, 27 Apr 2022 08:41:45 -0500 (EST) Date: Wed, 27 Apr 2022 08:41:45 -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: Fix three bugs regarding the interaction of \z and \h: 1. X-Mailer: activitymail 1.26, http://search.cpan.org/dist/activitymail/ Content-Type: text/plain; charset=utf-8 Message-ID: <3365192425994f92@mandoc.bsd.lv> Log Message: ----------- Fix three bugs regarding the interaction of \z and \h: 1. The combination \z\h is a no-op whatever the argument may be. In the past, the \z only affected the first space character generated by the \h, which was wrong. 2. For the conbination \zX\h with a positive argument, the first space resulting from the \h is not printed but consumed by the \z. 3. For the combination \zX\h with a negative argument, application of the \z needs to be completed before the \h can be started. In the past, if this combination occurred at the beginning of an output line, the \h backed up to the beginning of the line and after that, the \z attempted to back up even further, triggering an assertion. Bugs found during an audit of assignments to termp->col that i started after the bugfix tbl_term.c rev. 1.65. The assertion triggered by bug 3 was *not* yet found by afl(1). Modified Files: -------------- mandoc: term.c mandoc/regress/roff/esc: Makefile z.in z.out_ascii Added Files: ----------- mandoc/regress/roff/esc: hneg.in hneg.out_ascii Revision Data ------------- Index: term.c =================================================================== RCS file: /home/cvs/mandoc/mandoc/term.c,v retrieving revision 1.285 retrieving revision 1.286 diff -Lterm.c -Lterm.c -u -p -r1.285 -r1.286 --- term.c +++ term.c @@ -628,6 +628,10 @@ term_word(struct termp *p, const char *w encode(p, "utf8", 4); continue; case ESCAPE_HORIZ: + if (p->flags & TERMP_BACKAFTER) { + p->flags &= ~TERMP_BACKAFTER; + continue; + } if (*seq == '|') { seq++; uc = -p->col; @@ -636,12 +640,22 @@ term_word(struct termp *p, const char *w if (a2roffsu(seq, &su, SCALE_EM) == NULL) continue; uc += term_hen(p, &su); - if (uc > 0) { + if (uc >= 0) { while (uc > 0) { - bufferc(p, ASCII_NBRSP); uc -= term_len(p, 1); + if (p->flags & TERMP_BACKBEFORE) + p->flags &= ~TERMP_BACKBEFORE; + else + bufferc(p, ASCII_NBRSP); } - } else if (p->col > (size_t)(-uc)) { + continue; + } + if (p->flags & TERMP_BACKBEFORE) { + p->flags &= ~TERMP_BACKBEFORE; + assert(p->col > 0); + p->col--; + } + if (p->col >= (size_t)(-uc)) { p->col += uc; } else { uc += p->col; --- /dev/null +++ regress/roff/esc/hneg.out_ascii @@ -0,0 +1,10 @@ +ESC-HNEG(1) General Commands Manual ESC-HNEG(1) + +NNAAMMEE + eesscc--hhnneegg - the roff escape h sequence with a negative argument + +DDEESSCCRRIIPPTTIIOONN + simple: >ddxxbboolldd< single z with nospace escape: > new line< single z with overstrike: >abc< + single z with h escape: >m< + single z with char and h with positive argument: >a b< + single z with char and h with zero argument: >ab< single z near the end of the line: >< double z: >x< -OpenBSD July 4, 2017 OpenBSD +OpenBSD April 27, 2022 OpenBSD --- /dev/null +++ regress/roff/esc/hneg.in @@ -0,0 +1,11 @@ +.\" $OpenBSD: hneg.in,v 1.1 2022/04/27 13:30:19 schwarze Exp $ +.Dd $Mdocdate: April 27 2022 $ +.Dt ESC-HNEG 1 +.Os +.Sh NAME +.Nm esc-hneg +.Nd the roff escape h sequence with a negative argument +.Sh DESCRIPTION +simple: >abc\h'-3'd< +.br +after z escape: >ab\zc\h'-2'd< Index: z.in =================================================================== RCS file: /home/cvs/mandoc/mandoc/regress/roff/esc/z.in,v retrieving revision 1.2 retrieving revision 1.3 diff -Lregress/roff/esc/z.in -Lregress/roff/esc/z.in -u -p -r1.2 -r1.3 --- regress/roff/esc/z.in +++ regress/roff/esc/z.in @@ -1,4 +1,4 @@ -.\" $OpenBSD: z.in,v 1.3 2017/07/04 14:53:27 schwarze Exp $ +.\" $OpenBSD: z.in,v 1.4 2022/04/27 13:30:19 schwarze Exp $ .Dd $Mdocdate$ .Dt ESC-Z 1 .Os @@ -19,6 +19,12 @@ single z with nospace escape: >\z\c new line< .br single z with overstrike: >\z\o'ab'c< +.br +single z with h escape: >\z\h'3'm\z\h'-3'< +.br +single z with char and h with positive argument: >\za\h'3'b< +.br +single z with char and h with zero argument: >\za\h'0'b< .br single z near the end of the line: >\z< .br Index: Makefile =================================================================== RCS file: /home/cvs/mandoc/mandoc/regress/roff/esc/Makefile,v retrieving revision 1.8 retrieving revision 1.9 diff -Lregress/roff/esc/Makefile -Lregress/roff/esc/Makefile -u -p -r1.8 -r1.9 --- regress/roff/esc/Makefile +++ regress/roff/esc/Makefile @@ -1,8 +1,15 @@ -# $OpenBSD: Makefile,v 1.18 2022/04/13 13:11:33 schwarze Exp $ +# $OpenBSD: Makefile,v 1.19 2022/04/27 13:30:19 schwarze Exp $ -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 = one two multi +REGRESS_TARGETS += B bs_man bs_mdoc c c_man E1 e f h hneg l O1 o p w z REGRESS_TARGETS += ignore invalid unsupp HTML_TARGETS = f LINT_TARGETS = B h l O1 w ignore invalid unsupp + +# mandoc defect: +# - \h with a negative argument replaces output characters +# instead of overstriking them + +SKIP_GROFF = hneg .include -- To unsubscribe send an email to source+unsubscribe@mandoc.bsd.lv