[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Groff] Conditional problem: "!" operator after "&"
From: |
Ralph Corderoy |
Subject: |
Re: [Groff] Conditional problem: "!" operator after "&" |
Date: |
Wed, 28 Jul 2010 15:23:25 +0100 |
Hi Larry,
> I'm seeing this in both the release and this morning's CVS versions. A
> test file that illustrates the issue:
I think this matches Kernighan's CSTR 54.
> mac-lkollar:/tmp lkollar$ cat -n test.t
> 1 .nr NCS 1
> 2 .nr SIP 1
> 3 .LP
> 4 This is a test,
> 5 .if \n[NCS]&!\n[SIP] .nop NCS only.
> 6 .if !\n[NCS]&\n[SIP] .nop SIP only.
> 7 .if \n[NCS]&\n[SIP] .nop NCS and SIP.
> 8 .if !\n[NCS]&!\n[SIP] .nop actually it isn't because nothing is
> defined!
> mac-lkollar:/tmp lkollar$
>
> Running groff on this file produces the warnings:
>
> test.t:5: warning: numeric expression expected (got `!')
> test.t:8: warning: numeric expression expected (got `!')
The `!' for logical not is part of .if, not an operator in general
expressions. It is only allowed immediately after the `if' and negates
the whole of the following expression.
This may help. Note the parenthesis are required.
$ cat test.t
.if (\na=0)&(\nb=0) .tm x 0
.if (\na=0)&(\nb=1) .tm x 1
.if (\na=1)&(\nb=0) .tm x 2
.if (\na=1)&(\nb=1) .tm x 3
.
.if !\na .if !\nb .tm y 0
.if !\na .if \nb .tm y 1
.if \na .if !\nb .tm y 2
.if \na .if \nb .tm y 3
.
.if !\na&\nb .tm z 012
.if \na&\nb .tm z 3
$
$ for a in 0 1; do
> for b in 0 1; do
> echo = $a $b
> troff -ra=$a -rb=$b <test.t >/dev/null
> done
> done
= 0 0
x 0
y 0
z 012
= 0 1
x 1
y 1
z 012
= 1 0
x 2
y 2
z 012
= 1 1
x 3
y 3
z 3
$
Cheers,
Ralph.