[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Groff] .IP quoting incompatibility
From: |
Colin Watson |
Subject: |
[Groff] .IP quoting incompatibility |
Date: |
Tue, 12 Jun 2001 12:46:49 +0100 |
User-agent: |
Mutt/1.3.18i |
Here's an example, stripped down from pod2man's output for perlvar(1)
with recent versions of Perl, which behaves differently with UNIX [1]
and GNU [2] 'nroff -man'.
.de Ip \" List item
.br
.ie \\n(.$>=3 .ne \\$3
.el .ne 3
.IP "\\$1" \\$2
..
.TH FOO 1 ""
.SH NAME
.if n .Ip "$""""" 8
.el .Ip "$""""" 8
UNIX outputs $" while GNU outputs $"" (in compatibility mode too).
Something similar to this (pod2man has been rewritten since in the form
of Pod::Man) is Debian bug #20277 (http://bugs.debian.org/20277).
Fabrizio said back then that latin1 and ascii output were broken, but ps
was fine; $" now seems to go missing in the PostScript output for
perlvar(1), although I don't have a test case for that yet.
I can imagine that pod2man could be improved - it doesn't need to
enclose arguments in double quotes half as much as it does. In any case,
I don't know enough to say where the bug is: is it in pod2man or groff?
For what it's worth, here's the relevant bit of current Pod::Man:
# Given a command and a single argument that may or may not contain double
# quotes, handle double-quote formatting for it. If there are no double
# quotes, just return the command followed by the argument in double quotes.
# If there are double quotes, use an if statement to test for nroff, and for
# nroff output the command followed by the argument in double quotes with
# embedded double quotes doubled. For other formatters, remap paired double
# quotes to LQUOTE and RQUOTE.
sub switchquotes {
my $self = shift;
my $command = shift;
local $_ = shift;
my $extra = shift;
s/\\\*\([LR]\"/\"/g;
# We also have to deal with \*C` and \*C', which are used to add the
# quotes around C<> text, since they may expand to " and if they do this
# confuses the .SH macros and the like no end. Expand them ourselves.
# If $extra is set, we're dealing with =item, which in most nroff macro
# sets requires an extra level of quoting of double quotes.
my $c_is_quote = ($$self{LQUOTE} =~ /\"/) || ($$self{RQUOTE} =~ /\"/);
if (/\"/ || ($c_is_quote && /\\\*\(C[\'\`]/)) {
s/\"/\"\"/g;
my $troff = $_;
$troff =~ s/\"\"([^\"]*)\"\"/\`\`$1\'\'/g;
s/\\\*\(C\`/$$self{LQUOTE}/g;
s/\\\*\(C\'/$$self{RQUOTE}/g;
$troff =~ s/\\\*\(C[\'\`]//g;
s/\"/\"\"/g if $extra;
$troff =~ s/\"/\"\"/g if $extra;
$_ = qq("$_") . ($extra ? " $extra" : '');
$troff = qq("$troff") . ($extra ? " $extra" : '');
return ".if n $command $_\n.el $command $troff\n";
} else {
$_ = qq("$_") . ($extra ? " $extra" : '');
return "$command $_\n";
}
}
[1] Tested on Solaris 2.6 to 2.8, AIX 4.3 and 5.1, HP-UX 10.20 and
11.00, UnixWare 7.1.1, and OSF/1 4.0.
[2] At least from 1.15 onwards.
Thanks,
--
Colin Watson address@hidden
- [Groff] .IP quoting incompatibility,
Colin Watson <=