From: Peter Eisentraut <peter@eisentraut.org>
To: pgsql-committers@lists.postgresql.org
Subject: Re: pgsql: Add missing source files to nls.mk
Date: Thu, 13 Jun 2024 10:38:39 +0200
Message-ID: <83d5ee10-b1c2-4a67-abcf-250e0e9cdc79@eisentraut.org> (raw)
In-Reply-To: <E1sHflW-001IdX-Mx@gemulon.postgresql.org>
References: <E1sHflW-001IdX-Mx@gemulon.postgresql.org>
On 13.06.24 10:25, Peter Eisentraut wrote:
> Add missing source files to nls.mk
>
> Files in common/ and fe_utils/ that contain translatable strings need
> to be listed in the nls.mk files of the programs that use them. (Not
> great, but that's the way it works for now.) This usually requires
> some manual analysis which is done about once during each major
> release beta period. This time, I wrote a hackish script that figures
> some of this out more automatically, so this update is a bit larger as
> it also includes some files that were missed in the past.
For posterity, I have attached the script that used here. I hope to
improve on this process in the future.
Attachments:pg-nls-find-missing.pl (text/x-perl-script, 1.8K) download
#!/usr/bin/perl
use strict;
use warnings;
use autodie;
use File::Spec;
# Usage: $0 SUBDIR FILENAME...
my %args = ();
my %deps = ();
my $subdir = shift @ARGV;
sub process_deps
{
my $newstuff = 0;
foreach my $filename (keys %deps)
{
my $dir;
foreach my $d ($subdir, 'src', 'src/include')
{
if (-f "$d/$filename")
{
$dir = $d;
last;
}
}
next unless $dir;
open my $fh, '<', "$dir/$filename";
while (my $line = <$fh>)
{
if ($line =~ m!^#include "([^"]+)"!)
{
my $inc = $1;
if ($inc !~ m!/! || $inc =~ m!^common/! || $inc =~ m!^fe_utils/!)
{
if (!$deps{$inc})
{
$deps{$inc} = 1;
$newstuff = 1;
}
$inc =~ s!\.h!.c!;
if (!$deps{$inc} && (-f "src/$inc" || -f "$subdir/$inc"))
{
$deps{$inc} = 1;
$newstuff = 1;
}
}
}
}
close $fh;
}
return $newstuff;
}
foreach my $arg (@ARGV)
{
$deps{$arg} = 1;
}
while (process_deps()) {}
my @FRONTEND_COMMON_GETTEXT_FILES = qw(common/logging.c);
foreach my $f (@FRONTEND_COMMON_GETTEXT_FILES)
{
delete $deps{$f};
}
foreach my $k (keys %deps)
{
delete $deps{$k};
next unless $k =~ m!\.c!;
if ($k =~ m!common/! || $k =~ m!fe_utils!)
{
$deps{"src/$k"} = 1;
}
else
{
$deps{"$subdir/$k"} = 1;
}
}
my @triggers = qw(_
pg_log_error pg_log_error_detail pg_log_error_hint
pg_log_warning pg_log_warning_detail pg_log_warning_hint
pg_log_info pg_log_info_detail pg_log_info_hint
pg_fatal pg_log_generic pg_log_generic_v
);
foreach my $fn (keys %deps)
{
local $/;
my $found = 0;
open my $fh, '<', $fn;
my $contents = <$fh>;
close $fh;
foreach my $t (@triggers)
{
$found = 1 if $contents =~ /\b$t\b/;
}
delete $deps{$fn} if !$found;
}
print join("\n", sort map { File::Spec->abs2rel($_, $subdir) } keys %deps), "\n";
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-committers@postgresql.org
Cc: peter@eisentraut.org, pgsql-committers@lists.postgresql.org
Subject: Re: pgsql: Add missing source files to nls.mk
In-Reply-To: <83d5ee10-b1c2-4a67-abcf-250e0e9cdc79@eisentraut.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox