Update configure probes for CFLAGS needed for ARM CRC instructions.
[pgsql.git] / src / tools / win32tzlist.pl
blob17d45b957058c14a74eda957c36c5ebe846d6033
1 #################################################################
3 # win32tzlist.pl -- compare Windows timezone information
5 # Copyright (c) 2008-2024, PostgreSQL Global Development Group
7 # src/tools/win32tzlist.pl
8 #################################################################
11 # This script compares the timezone information in the Windows registry
12 # with that in src/bin/initdb/findtimezone.c. A list of changes will be
13 # written to stdout - no attempt is made to automatically edit the file.
15 # Run the script from the top-level PG source directory.
18 use strict;
19 use warnings FATAL => 'all';
21 use Config;
23 our $HKEY_LOCAL_MACHINE;
25 BEGIN
27 if ($Config{osname} eq 'MSWin32' || $Config{osname} eq 'msys')
29 require Win32::Registry;
30 Win32::Registry->import;
34 my $tzfile = 'src/bin/initdb/findtimezone.c';
37 # Fetch all timezones in the registry
39 my $basekey;
40 $HKEY_LOCAL_MACHINE->Open(
41 "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Time Zones", $basekey)
42 or die $!;
44 my @subkeys;
45 $basekey->GetKeys(\@subkeys);
47 my @system_zones;
49 foreach my $keyname (@subkeys)
51 my $subkey;
52 my %vals;
54 $basekey->Open($keyname, $subkey) or die $!;
55 $subkey->GetValues(\%vals) or die $!;
56 $subkey->Close();
58 die "Incomplete timezone data for $keyname!\n"
59 unless ($vals{Std} && $vals{Dlt} && $vals{Display});
60 push @system_zones,
62 'std' => $vals{Std}->[2],
63 'dlt' => $vals{Dlt}->[2],
64 'display' => clean_displayname($vals{Display}->[2]),
68 $basekey->Close();
71 # Fetch all timezones currently in the file
73 my @file_zones;
74 my $pgtz;
75 open(my $tzfh, '<', $tzfile) or die "Could not open $tzfile!\n";
77 local $/ = undef;
78 $pgtz = <$tzfh>;
80 close($tzfh);
82 # Attempt to locate and extract the complete win32_tzmap struct
83 $pgtz =~ /win32_tzmap\[\] =\s+{\s+\/\*[^\/]+\*\/\s+(.+?)};/gs
84 or die "Could not locate struct win32_tzmap in $tzfile!";
85 $pgtz = $1;
87 # Extract each individual record from the struct
88 while ($pgtz =~
89 m/{\s+\/\*(.+?)\*\/\s+"([^"]+)",\s+"([^"]+)",\s+"([^"]+)",?\s+},/gs)
91 push @file_zones,
93 'display' => clean_displayname($1),
94 'std' => $2,
95 'dlt' => $3,
96 'match' => $4,
101 # Look for anything that has changed
103 my @add;
105 for my $sys (@system_zones)
107 my $match = 0;
108 for my $file (@file_zones)
110 if ($sys->{std} eq $file->{std})
112 $match = 1;
113 if ($sys->{dlt} ne $file->{dlt})
115 print
116 "Timezone $sys->{std}, changed name of daylight zone!\n";
118 if ($sys->{display} ne $file->{display})
120 print
121 "Timezone $sys->{std} changed displayname ('$sys->{display}' from '$file->{display}')!\n";
123 last;
126 unless ($match)
128 push @add, $sys;
132 if (@add)
134 print "\n\nOther than that, add the following timezones:\n";
135 for my $z (@add)
137 print
138 "\t{\n\t\t/* $z->{display} */\n\t\t\"$z->{std}\", \"$z->{dlt}\",\n\t\t\"FIXME\"\n\t},\n";
142 sub clean_displayname
144 my $dn = shift;
146 $dn =~ s/\*//gs;
147 $dn =~ s/\s+/ /gs;
148 $dn =~ s/^\s+//gs;
149 $dn =~ s/\s+$//gs;
150 return $dn;