Skip to content

Commit 3d9e892

Browse files
committed
man: fix po4a's incorrect handling of \& in doblequotes
Namely do `s/\\&"/\\(dq/` only until after we handle all the quotes that might separate commands' arguments. Closes: mquinson#445 Signed-off-by: Alexander Golubev <[email protected]>
1 parent 849b10e commit 3d9e892

File tree

6 files changed

+26
-8
lines changed

6 files changed

+26
-8
lines changed

lib/Locale/Po4a/Man.pm

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1674,25 +1674,25 @@ sub splitargs {
16741674
# anymore. Let's play safe.
16751675
$arguments =~ s/\\ /$nbs/g;
16761676
$arguments =~ s/^ +//;
1677-
$arguments =~ s/\\&"/\\(dq/g;
16781677
$arguments =~ s/^ *//;
16791678
while ( length $arguments ) {
1679+
my $a;
16801680
if ( $arguments =~ s/^"((?:[^"]|"")*)"(?!") *// ) {
1681-
my $a = $1;
1681+
$a = $1;
16821682
$a =~ s/""/"/g if defined $a;
1683-
push @args, $a;
16841683
} elsif ( $arguments =~ s/^"((?:[^"]|"")*) *$// ) {
16851684

16861685
# Unterminated quote, but this seems to be handled by removing
16871686
# the trailing spaces and closing the quotes.
1688-
my $a = $1;
1687+
$a = $1;
16891688
$a =~ s/""/"/g if defined $a;
1690-
push @args, $a;
16911689
} elsif ( $arguments =~ s/^([^ ]+) *// ) {
1692-
push @args, $1;
1690+
$a = $1;
16931691
} else {
16941692
die wrap_ref_mod( $ref, "po4a::man", dgettext( "po4a", "Cannot parse command arguments: %s" ), $arguments );
16951693
}
1694+
$a =~ s/\\&"/\\(dq/g if (defined $a);
1695+
push @args, $a;
16961696
}
16971697
if ( $debug{'splitargs'} ) {
16981698
print STDERR "ARGS=";

t/fmt/man/quotes.man

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,5 @@ should be equivalent to:
3333

3434
.BI "-help"""a "-h"a "-?"a "/?"
3535

36+
.\" Some shinenigans with \&, see https://github.com/mquinson/po4a/issues/445
37+
.BI "[\& ]\&" \&"text\&" "[\& \&"" ]\&" "[\& \&"" ]\&

t/fmt/man/quotes.norm

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,5 @@ should be equivalent to:
3737

3838
\fB\-help"\fP\fIa\fP\fB\-h\fP\fIa\fP\fB\-?\fP\fIa\fP\fB/?\fP
3939

40+
.\" Some shinenigans with \&, see https://github.com/mquinson/po4a/issues/445
41+
\fB[\& ]\&\fP\fI"text"\fP\fB[\& " ]\&\fP\fI[\& " ]\&\fP

t/fmt/man/quotes.po

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
msgid ""
88
msgstr ""
99
"Project-Id-Version: PACKAGE VERSION\n"
10-
"POT-Creation-Date: 2020-04-26 22:14+0200\n"
10+
"POT-Creation-Date: 2024-11-12 14:36+0300\n"
1111
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
1212
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
1313
"Language-Team: LANGUAGE <[email protected]>\n"
@@ -83,3 +83,9 @@ msgstr "THIS ALSO:"
8383
#: quotes.man:31 quotes.man:35
8484
msgid "B<-help\">I<a>B<-h>I<a>B<-?>I<a>B</?>"
8585
msgstr "B<-HELP\">I<1>B<-h>I<1>B<-?>I<1>B</?>"
86+
87+
#. Some shinenigans with \&, see https://github.com/mquinson/po4a/issues/445
88+
#. type: Plain text
89+
#: quotes.man:37
90+
msgid "B<[\\& ]\\&>I<\"text\">B<[\\& \" ]\\&>I<[\\& \" ]\\&>"
91+
msgstr "B<[\\& ]\\&>I<\"TEXT\">B<[\\& \" ]\\&>I<[\\& \" ]\\&>"

t/fmt/man/quotes.pot

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
msgid ""
88
msgstr ""
99
"Project-Id-Version: PACKAGE VERSION\n"
10-
"POT-Creation-Date: 2020-04-26 22:14+0200\n"
10+
"POT-Creation-Date: 2024-11-12 14:36+0300\n"
1111
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
1212
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
1313
"Language-Team: LANGUAGE <[email protected]>\n"
@@ -83,3 +83,9 @@ msgstr ""
8383
#: quotes.man:31 quotes.man:35
8484
msgid "B<-help\">I<a>B<-h>I<a>B<-?>I<a>B</?>"
8585
msgstr ""
86+
87+
#. Some shinenigans with \&, see https://github.com/mquinson/po4a/issues/445
88+
#. type: Plain text
89+
#: quotes.man:37
90+
msgid "B<[\\& ]\\&>I<\"text\">B<[\\& \" ]\\&>I<[\\& \" ]\\&>"
91+
msgstr ""

t/fmt/man/quotes.trans

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,5 @@ SHOULD BE EQUIVALENT TO:
3737

3838
\fB\-HELP"\fP\fI1\fP\fB\-h\fP\fI1\fP\fB\-?\fP\fI1\fP\fB/?\fP
3939

40+
.\" Some shinenigans with \&, see https://github.com/mquinson/po4a/issues/445
41+
\fB[\& ]\&\fP\fI"TEXT"\fP\fB[\& " ]\&\fP\fI[\& " ]\&\fP

0 commit comments

Comments
 (0)