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 22720 invoked from network); 30 May 2022 23:04:24 -0000 Received: from bsd.lv (HELO mandoc.bsd.lv) (66.111.2.12) by inbox.vuxu.org with ESMTPUTF8; 30 May 2022 23:04:24 -0000 Received: from fantadrom.bsd.lv (localhost [127.0.0.1]) by mandoc.bsd.lv (OpenSMTPD) with ESMTP id ec28f6f1 for ; Mon, 30 May 2022 18:04:21 -0500 (EST) Received: from localhost (mandoc.bsd.lv [local]) by mandoc.bsd.lv (OpenSMTPD) with ESMTPA id 6fb25c21 for ; Mon, 30 May 2022 18:04:21 -0500 (EST) Date: Mon, 30 May 2022 18:04:21 -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: Dummy implementation of the roff(7) \V (interpolate environment X-Mailer: activitymail 1.26, http://search.cpan.org/dist/activitymail/ Content-Type: text/plain; charset=utf-8 Message-ID: <33658b2e94200a81@mandoc.bsd.lv> Log Message: ----------- Dummy implementation of the roff(7) \V (interpolate environment variable) escape sequence. This is needed to get \V into the correct parsing class, ESCAPE_EXPAND. It is intentional that mandoc(1) output is *not* influenced by environment variables, so interpolate the name of the variable with some decorating punctuation rather than interpolating its value. Modified Files: -------------- mandoc: roff.c roff_escape.c roff.7 mandoc/regress/roff/esc: Makefile Added Files: ----------- mandoc/regress/roff/esc: V1.in V1.out_ascii V1.out_lint Revision Data ------------- Index: roff.7 =================================================================== RCS file: /home/cvs/mandoc/mandoc/roff.7,v retrieving revision 1.117 retrieving revision 1.118 diff -Lroff.7 -Lroff.7 -u -p -r1.117 -r1.118 --- roff.7 +++ roff.7 @@ -2188,12 +2188,16 @@ Horizontal tab; ignored by Move up by half a line; ignored by .Xr mandoc 1 . .It Ic \eV[ Ns Ar name Ns Ic \&] -Interpolate an environment variable; ignored by -.Xr mandoc 1 . +Interpolate an environment variable. For short names, there are variants .Ic \eV Ns Ar c and .Ic \eV( Ns Ar cc . +This escape sequence is intentionally unsupported; +.Xr mandoc 1 +prints the string +.Dq Pf $ Brq Ar name +instead of inspecting the environment. .It Ic \ev\(aq Ns Ar number Ns Ic \(aq Vertical motion; ignored by .Xr mandoc 1 . Index: roff_escape.c =================================================================== RCS file: /home/cvs/mandoc/mandoc/roff_escape.c,v retrieving revision 1.2 retrieving revision 1.3 diff -Lroff_escape.c -Lroff_escape.c -u -p -r1.2 -r1.3 --- roff_escape.c +++ roff_escape.c @@ -157,13 +157,13 @@ roff_escape(const char *buf, const int l case '$': case '*': + case 'V': case 'n': rval = ESCAPE_EXPAND; break; case 'F': case 'M': case 'O': - case 'V': case 'Y': case 'g': case 'k': Index: roff.c =================================================================== RCS file: /home/cvs/mandoc/mandoc/roff.c,v retrieving revision 1.388 retrieving revision 1.389 diff -Lroff.c -Lroff.c -u -p -r1.388 -r1.389 --- roff.c +++ roff.c @@ -1529,6 +1529,12 @@ roff_expand(struct roff *r, struct buf * ubuf[1] = '\0'; res = ubuf; break; + case 'V': + mandoc_msg(MANDOCERR_UNSUPP, ln, iesc, + "%.*s", iend - iesc, buf->buf + iesc); + roff_expand_patch(buf, iendarg, "}", iend); + roff_expand_patch(buf, iesc, "${", iarg); + continue; case 'n': if (iendarg > iarg) (void)snprintf(ubuf, sizeof(ubuf), "%d", @@ -1567,9 +1573,8 @@ roff_expand_patch(struct buf *buf, int s { char *nbuf; - buf->buf[start] = '\0'; - buf->sz = mandoc_asprintf(&nbuf, "%s%s%s", buf->buf, repl, - buf->buf + end) + 1; + buf->sz = mandoc_asprintf(&nbuf, "%.*s%s%s", start, buf->buf, + repl, buf->buf + end) + 1; free(buf->buf); buf->buf = nbuf; } --- /dev/null +++ regress/roff/esc/V1.out_ascii @@ -0,0 +1,11 @@ +ESC-V1(1) General Commands Manual ESC-V1(1) + +NNAAMMEE + esc-V1 - interpolate environment variables + +DDEESSCCRRIIPPTTIIOONN + single-character name: "${N}" + double-character name: "${VN}" + multi-character name: "${VARNAME}" + +OpenBSD May 31, 2022 ESC-V1(1) --- /dev/null +++ regress/roff/esc/V1.out_lint @@ -0,0 +1,3 @@ +mandoc: V1.in:6:25: UNSUPP: unsupported feature: \VN +mandoc: V1.in:8:25: UNSUPP: unsupported feature: \V(VN +mandoc: V1.in:10:24: UNSUPP: unsupported feature: \V[VARNAME] Index: Makefile =================================================================== RCS file: /home/cvs/mandoc/mandoc/regress/roff/esc/Makefile,v retrieving revision 1.11 retrieving revision 1.12 diff -Lregress/roff/esc/Makefile -Lregress/roff/esc/Makefile -u -p -r1.11 -r1.12 --- regress/roff/esc/Makefile +++ regress/roff/esc/Makefile @@ -1,10 +1,10 @@ -# $OpenBSD: Makefile,v 1.21 2022/05/20 13:06:27 schwarze Exp $ +# $OpenBSD: Makefile,v 1.22 2022/05/30 22:50:40 schwarze Exp $ REGRESS_TARGETS = one two multi comment -REGRESS_TARGETS += B bs_man bs_mdoc c c_man E1 e f h hneg l O1 o p r w z +REGRESS_TARGETS += B bs_man bs_mdoc c c_man E1 e f h hneg l O1 o p r V1 w z REGRESS_TARGETS += ignore invalid unsupp HTML_TARGETS = f -LINT_TARGETS = comment B h l O1 r w ignore invalid unsupp +LINT_TARGETS = comment B h l O1 r V1 w ignore invalid unsupp # mandoc defects: # - \h with a negative argument replaces output characters @@ -12,5 +12,10 @@ LINT_TARGETS = comment B h l O1 r w ign # - \r does not return to the previous output line SKIP_GROFF = hneg r + +# intentional difference: +# - mandoc does not inspect the environment + +SKIP_GROFF += V1 .include --- /dev/null +++ regress/roff/esc/V1.in @@ -0,0 +1,10 @@ +.\" $OpenBSD: V1.in,v 1.1 2022/05/30 22:50:40 schwarze Exp $ +.TH ESC-V1 1 "May 31, 2022" +.SH NAME +esc-V1 \- interpolate environment variables +.SH DESCRIPTION +single-character name: "\VN" +.br +double-character name: "\V(VN" +.br +multi-character name: "\V[VARNAME]" -- To unsubscribe send an email to source+unsubscribe@mandoc.bsd.lv