groff
[Top][All Lists]
Advanced

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

Re: groff 1.23.0.rc4 on Solaris 11 OpenIndiana


From: Ralph Corderoy
Subject: Re: groff 1.23.0.rc4 on Solaris 11 OpenIndiana
Date: Sun, 16 Apr 2023 11:40:11 +0100

Hi Branden,

> pdfpic.tmac does a pretty hairy thing.
>
>     .  \" Get image dimensions.  The `tr` command to strip null bytes is
>     .  \" distasteful, but its necessity is imposed on us.  See
>     .  \" <https://gitlab.freedesktop.org/poppler/poppler/-/issues/776>.
>     .  ec @
>     .  sy pdfinfo @$1 | \
>     tr -d '\000' | \
>     grep "Page *size" | \
>     sed -e 's/Page *size: *\\([[:digit:].]*\\) *x *\\([[:digit:].]*\\).*$/\
>     .nr pdfpic*width (p;\\1)\\n\
>     .nr pdfpic*height  (p;\\2)/' \
>     > @*[pdfpic*temporary-file]
>     .  ec

Doesn't that look a bit odd?  Both tr and sed want to see a single
backslash in their argv[] string.  tr for \000 and sed for \( and \).
The arguments to both are in sh's single quotes.  Yet the backslashes
for tr are single whereas sed's are doubled.

This suggests some variation between sh implementations.  I'd double
tr's to \\000.

Also, the grep isn't needed if the sed is made -n and the s/// becomes
s///p.  This would also remove the oddity of using "" for grep when
nothing in its argument needs interpolation.

And there is an extra space after ‘height’.

If the multi-line sed is a portability problem.  And it probably isn't.
Then the sed could just replace with /\1 \2/ and the pipeline captured
in ‘set $(...)’.  Then the .nr could be printed using the shell's $1
and $2.

-- 
Cheers, Ralph.



reply via email to

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