groff
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: ^G


From: G. Branden Robinson
Subject: Re: ^G
Date: Mon, 15 Feb 2021 16:30:43 +1100
User-agent: NeoMutt/20180716

Hi Wim and John,

At 2021-02-02T23:11:39+1100, John Gardner wrote:
> Hi Wim,
> 
> Roff syntax permits certain ASCII control characters in identifiers.
> They're typically used by older macro-packages to avoid naming
> conflicts, or in contexts when an arbitrary delimiter may appear in
> legitimate texts (such as the .tl request).

Since GNU troff's parser has a concept of "input level"--which is
mentioned but unfortunately not actually defined in our Texinfo
manual--.tl requests, among other things, are robust to this sort of
confusability.

Try the following with, say, "nroff":

        .pl 2v
        .de TL
        .  tl 'left'\\*T'right'
        ..
        .ds T You won't get it up the steps.\"
        .TL
        .cp 1
        .TL

> Acceptable control characters are:
> 
>    - ^B STX (Start of text)
>    - ^C ETX (End of text)
>    - ^E ENQ (Enquiry)
>    - ^F ACK (Acknowledge)
>    - ^G BEL (Alarm / bell)
>    - ^? DEL (Delete)
> 
> Groff also accepts ^D (End of transmission) and form feeds, although
> the latter might be unintentional.

As I understand it, there is a tradition in GNU Emacs of using ^L as a
page break character, and it is therefore an expectable character in an
otherwise "plain text" stream.  If Version 7 Unix troff didn't support
^L in identifiers, it might have been injected into groff's set to
placate the Emacs community.

Or one GNU Emacs user in particular...

> On Tue, 2 Feb 2021 at 20:23, Wim Stockman <wim.stockman@gmail.com> wrote:
> 
> > What is the purpose of this? ^G , control character.
> > I see it a lot used in the hdtbl macro set.

I'm not sure hdtbl's uses are necessary.  I see only a few usage
patterns.  It's a point worth researching.  My _expectation_ is that
arguments to the \A and \B escapes change the input level, and both of
these are groff extensions anyway, so won't work in compatibility mode.
If I'm right, then these uses of ^G can be replaced with ' or almost
anything else.

In hdmisc.tmac-u, an .index (like index(3)) string operator is defined.
I haven't looked closely, but I think the algorithm uses the ^G as a
marker that is not expected to occur in the string being searched.  But
if it does, it won't work...

In common.roff there is a third case, using \w, a portable escape.  It's
like the \A and \B case except the context should be checked to see if
it's possible that we're in compatibility mode.

This is a superficial investigation as I'm pressed for time right this
second.

My preference would be to get rid of these control characters in our
sources if possible.

$ grep -r '^G' contrib/hdtbl | cat -v
contrib/hdtbl/hdtbl.tmac-u:.    ie \B^G\\*[cols]^G \
contrib/hdtbl/hdtbl.tmac-u:.    ie \B^G\\*[cpd]^G \
contrib/hdtbl/hdtbl.tmac-u:.    ie \B^G\\*[csp]^G \
contrib/hdtbl/hdtbl.tmac-u:.      ie \B^G\\*[border]^G \
contrib/hdtbl/hdtbl.tmac-u:.    ie \B^G\\*[height]^G \
contrib/hdtbl/hdtbl.tmac-u:.    ie \B^G\\*[height]^G \
contrib/hdtbl/hdtbl.tmac-u:.    ie \B^G\\*[rowspan]^G \{\
contrib/hdtbl/hdtbl.tmac-u:.    ie \B^G\\*[colspan]^G \
contrib/hdtbl/hdtbl.tmac-u:.        ie \B^G\\*[**]^G \
contrib/hdtbl/hdtbl.tmac-u:.        ie \B^G\\$[\\n[*]]^G \
contrib/hdtbl/hdmisc.tmac-u:.  length ** \\$1^G
contrib/hdtbl/hdmisc.tmac-u:.    ds * \\$1^G\"
contrib/hdtbl/examples/common.roff:.  nr *w* (17 * \w^G\\$*^G / 10 + 4n)
contrib/hdtbl/examples/common.roff:.  if !\B^G\\$1^G \{\
contrib/hdtbl/examples/common.roff:.    ie !\B^G\\$2^G \
contrib/hdtbl/examples/common.roff:.    ie !\A^G\\$3^G \

Regards,
Branden

Attachment: signature.asc
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]