diff --git a/po/check-markup b/po/check-markup
index 61bee8d42b85e997b9250d62917d6b723a007cb7..eaf2cdf353bddafeb91ace8ec41a48299ccc978c 100755 (executable)
--- a/po/check-markup
+++ b/po/check-markup
}
# Returns true iff successful.
-sub check_str ($) {
- my ($str) = @_;
+sub check_str ($$) {
+ my ($certainly_pango_str, $str) = @_;
$str =~ s/\A"// or die "Bug: No leading `\"' in `$str'";
$str =~ s/"\Z// or die "Bug: No trailing `\"' in `$str'";
}
}
- if ($str =~ m{&#[^0-9]+;}) {
- po_error("Entity declaration error (must look like '{')");
+ if (($str =~ m{&#[^0-9]+;}) or ($str =~ m{&#x[^0-9a-fA-F]+;})) {
+ po_error("Entity declaration error (must look like '{' or '@' and be in ASCII)");
+ return 0;
+ }
+
+ if (($str =~ m{&#[^0-9]+}) or ($str =~ m{&#x[^0-9a-fA-F]+})) {
+ po_error("Entity declaration error 2 (must look like '{' or '@' and be in ASCII)");
+ return 0;
+ }
+
+ if (($str =~ m{&#(?![0-9]{2,4};)}) or ($str =~ m{&#x(?![0-9a-fA-F]{2,4};)})) {
+ po_error("Entity declaration error 3 (must look like '{' or '@' and be in ASCII)");
return 0;
}
return 0;
}
- if (!$is_xml) {
+ if (!$is_xml and !$certainly_pango_str) {
$str =~ s/<(?:defs|image|rect|svg)>//g;
$str =~ s/<[ 01]//g;
$str =~ s/\A>+//;
$str =~ s/[^<>]*\Z//;
if ($str =~ /\A([<>])\Z/) {
- if ($is_xml) {
+ if ($is_xml or $certainly_pango_str) {
po_error("Unescaped `$1'");
return 0;
} else {
return 1;
}
-sub check_strs (@) {
+sub check_strs ($@) {
+ my $is_pango_str = shift(@_);
if ($#_ < 1) {
die "check_strs: expecting >= 2 strings";
}
if ((($_[0] eq '""') && ($_[1] =~ /Project-Id-Version:.*POT-Creation-Date:/s))
- or ($_[0] eq '"> and < scale by:"')) {
+ or ($_[0] eq '"> and < scale by:"')
+ or $is_pango_str == 0)
+ {
# Not a Pango string.
return 1;
}
foreach my $str (@_) {
- $str eq '""' or check_str($str) or return 0;
+ $str eq '""' or check_str($is_pango_str - 1, $str) or return 0;
}
return 1;
}
next ENTRY;
}
- s/"\n"//g;
+ # Concatenate multi-line string literals.
+ s/"\n\s*"//g;
- if (!m{\A${com}*msgid[^\n]*\n${com}*msgstr[^\n]*\n${com}*\Z} &&
- !m{\A${com}*msgid[^\n]*\n${com}*msgid_plural[^\n]*\n${com}*(msgstr\[[^\n]*\n${com}*)+\Z}) {
+ if (!m{\A${com}*
+ (?:msgctxt[^\n]*\n)?
+ msgid[^\n]*\n
+ ${com}*
+ (?:
+ msgstr[^\n]*\n
+ ${com}*
+ | msgid_plural[^\n]*\n
+ ${com}*
+ (?:msgstr\[[^\n]*\n${com}*)+
+ )\Z}x)
+ {
po_error('Not in msg format');
next ENTRY;
}
- if (!m{\A${com}*msgid ${str}\s*\n${com}*msgstr ${str}\s*\n${com}*\Z} &&
- !m{\A${com}*msgid ${str}\s*\n${com}*msgid_plural ${str}\s*\n${com}*(msgstr\[\d+\] ${str}\s*\n${com}*)+\Z}) {
+ if (!m{
+ \A${com}*
+ (?:msgctxt\ ${str}\s*\n)?
+ msgid\ ${str}\s*\n
+ ${com}*
+ (?:
+ msgstr\ ${str}\s*\n
+ ${com}*
+ | msgid_plural\ ${str}\s*\n
+ ${com}*
+ (?:msgstr\[\d+\]\ ${str}\s*\n${com}*)+
+ )\Z}x)
+ {
po_error('Mismatched quotes');
next ENTRY;
}
- if (m{\n\#,\ fuzzy}) {
+ if (m{\n\#(?:,\ [-a-z0-9]+)*,\ fuzzy}) {
# Fuzzy entries aren't used, so ignore them.
# (This prevents warnings about mismatching <>/ pattern.)
next ENTRY;
}
- if (m{\A${com}*msgid\ (${str})\n
- ${com}*msgstr\ (${str})\n
- ${com}*\Z}x) {
- check_strs($1, $2) or next ENTRY;
+ # 0 for known not pango format, 2 for known pango format.
+ my $is_pango_format = 1;
+ if (m{\n\#\.\ .*\bxgettext:(no-)?pango-format\s}) {
+ $is_pango_format = ( defined($1) ? 0 : 2 );
}
- elsif (m{\A${com}*msgid\ (${str})\n
- ${com}*msgid_plural\ (${str})\n
- ((?:${com}*msgstr\[\d+\]\ ${str}\n${com}*)+)\Z}x) {
+ if (m{\n\#(?:,\ [-a-z0-9+])*,\ (no-)?pango-format[,\n]}) {
+ $is_pango_format = ( defined($1) ? 0 : 2 );
+ }
+ if (m{\n\#:\ \.\./share/extensions/[-a-zA-Z0-9_]+\.(?:inx|py)(?:\.h)?:}) {
+ $is_pango_format = 0;
+ }
+
+ if (m{\A
+ ${com}*
+ (?:msgctxt\ ${str}\s*\n)?
+ msgid\ (${str})\n
+ ${com}*
+ msgstr\ (${str})\n
+ ${com}*
+ \Z}x)
+ {
+ check_strs($is_pango_format, $1, $2) or next ENTRY;
+ }
+ elsif (m{\A
+ ${com}*
+ (?:msgctxt\ ${str}\s*\n)?
+ msgid\ (${str})\n
+ ${com}*
+ msgid_plural\ (${str})\n
+ ((?:${com}*msgstr\[\d+\]\ ${str}\n${com}*)+)
+ \Z}x)
+ {
my ($s1, $s2, $rest) = ($1, $2, $3);
my @strs = ($s1, $s2);
while ($rest =~ s/\A${com}*msgstr\[\d+\]\ (${str})\n${com}*//) {
push @strs, ($1);
}
$rest eq '' or die "BUG: unparsed plural entries `$rest'";
- check_strs(@strs) or next ENTRY;
+ check_strs($is_pango_format, @strs) or next ENTRY;
}
elsif (m{$str[ \t]}) {
po_error('Trailing whitespace');
# Some makefiles (currently the top-level Makefile.am) expect this script to
# exit 1 if any problems found.
exit $rc;
+
+
+# vi: set autoindent shiftwidth=4 tabstop=8 encoding=utf-8 softtabstop=4 filetype=perl :