The Unix Heritage Society mailing list
 help / color / Atom feed
* Re: [TUHS] eqn anomaly
@ 2020-03-11  1:46 Norman Wilson
  0 siblings, 0 replies; 2+ messages in thread
From: Norman Wilson @ 2020-03-11  1:46 UTC (permalink / raw)
  To: tuhs

On (post-)V10:

echo '.EQ
define f % $1 %
f("a,b")
.EN' | eqn

emits

.lf 1 -
.EQ
.ds 11 "\f2a,b\fP
.if 1m>\n(.v .ne 1m
.rn 11 10
\&\*(10
.EN
.lf 5

On a Linux system with GNU eqn (groff) version 1.22.3,
the output is rather more verbose (48 lines!), but
the troff result is just an a (rather than the proper
a,b) and eqn complains

eqn:<standard input>:3: newline before end of quoted text

I assume this Linux result is more or less what Doug
expects.

Norman Wilson
Toronto ON
(still heating my basement with a MicroVAX)

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [TUHS] eqn anomaly
@ 2020-03-11  1:14 Doug McIlroy
  0 siblings, 0 replies; 2+ messages in thread
From: Doug McIlroy @ 2020-03-11  1:14 UTC (permalink / raw)
  To: tuhs

I was surprised that eqn parses the macro call below as having two
arguments, each with an unmatched ".
        .EQ
        define f % $1 %
        f("a,b")
        .EN
Ralph Corderoy found that the comma can be hidden by replacing it with
\N'44'. A somewhat cleaner way to hide it is
        .EQ
        define f % $1 %
        define comma % , %
        f(a comma b)
        .EN
This works too.
        .EQ
        f(f(a comma b))
        .EN
[Note for cognoscenti. Eqn's practice in expanding macro arguments clashes
with troff's. Eqn expands nested calls after substitution in the outer
macro definition; troff expands while collecting arguments of the outer
call. I've found no documentation of the eqn behavior.]

The classical man page for eqn asserts categorically, `Strings enclosed
in double quotes " " are passed through untouched.'  Unfortunately the
version of Kernighan/Cherry User's Guide that describes macros with
arguments says little about how arguments are parsed except that they
are separated by commas--nothing about whether commas are hidden by
parentheses or quotes.

Certainly splitting at a comma in a quoted string violates the plain
meaning of the man-page assertion. If anyone has v10 (or perhaps something
else after v7) running, I'd be grateful to learn what classic eqn actually
did. I'm morally certain that if it did split and anyone had complained
to Brian, he would have fixed it.

These observations lead me to file a bug report.

Doug

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, back to index

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-11  1:46 [TUHS] eqn anomaly Norman Wilson
  -- strict thread matches above, loose matches on Subject: below --
2020-03-11  1:14 Doug McIlroy

The Unix Heritage Society mailing list

Archives are clonable: git clone --mirror http://inbox.vuxu.org/tuhs

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://inbox.vuxu.org/vuxu.archive.tuhs


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git