Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit933b466

Browse files
committed
Use 'use strict' in all Perl programs
1 parent175ff65 commit933b466

File tree

10 files changed

+87
-57
lines changed

10 files changed

+87
-57
lines changed

‎contrib/seg/seg-validate.pl

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,23 @@
11
#!/usr/bin/perl
2-
$integer ='[+-]?[0-9]+';
3-
$real ='[+-]?[0-9]+\.[0-9]+';
4-
5-
$RANGE ='(\.\.)(\.)?';
6-
$PLUMIN =q(\'\+\-\');
7-
$FLOAT ="(($integer)|($real))([eE]($integer))?";
8-
$EXTENSION ='<|>|~';
9-
10-
$boundary ="($EXTENSION)?$FLOAT";
11-
$deviation =$FLOAT;
12-
13-
$rule_1 =$boundary .$PLUMIN .$deviation;
14-
$rule_2 =$boundary .$RANGE .$boundary;
15-
$rule_3 =$boundary .$RANGE;
16-
$rule_4 =$RANGE .$boundary;
17-
$rule_5 =$boundary;
2+
3+
use strict;
4+
5+
my$integer ='[+-]?[0-9]+';
6+
my$real ='[+-]?[0-9]+\.[0-9]+';
7+
8+
my$RANGE ='(\.\.)(\.)?';
9+
my$PLUMIN =q(\'\+\-\');
10+
my$FLOAT ="(($integer)|($real))([eE]($integer))?";
11+
my$EXTENSION ='<|>|~';
12+
13+
my$boundary ="($EXTENSION)?$FLOAT";
14+
my$deviation =$FLOAT;
15+
16+
my$rule_1 =$boundary .$PLUMIN .$deviation;
17+
my$rule_2 =$boundary .$RANGE .$boundary;
18+
my$rule_3 =$boundary .$RANGE;
19+
my$rule_4 =$RANGE .$boundary;
20+
my$rule_5 =$boundary;
1821

1922

2023
print"$rule_5\n";

‎contrib/seg/sort-segments.pl

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
# this script will sort any table with the segment data type in its last column
44

5+
use strict;
6+
7+
my@rows;
8+
59
while (<>)
610
{
711
chomp;
@@ -10,11 +14,11 @@
1014

1115
foreach (
1216
sort {
13-
@ar =split("\t",$a);
14-
$valA =pop@ar;
17+
my@ar =split("\t",$a);
18+
my$valA =pop@ar;
1519
$valA =~s/[~<> ]+//g;
1620
@ar =split("\t",$b);
17-
$valB =pop@ar;
21+
my$valB =pop@ar;
1822
$valB =~s/[~<> ]+//g;
1923
$valA<=>$valB
2024
}@rows)

‎doc/src/sgml/mk_feature_tables.pl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
# doc/src/sgml/mk_feature_tables.pl
44

5+
use strict;
6+
57
my$yesno =$ARGV[0];
68

79
open PACK,$ARGV[1]ordie;

‎src/pl/plperl/plc_perlboot.pl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# src/pl/plperl/plc_perlboot.pl
22

3+
use strict;
4+
35
use 5.008001;
46
use varsqw(%_SHARED $_TD);
57

‎src/test/locale/sort-test.pl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
#! /usr/bin/perl
2+
3+
use strict;
24
use locale;
35

46
open(INFILE,"<$ARGV[0]");

‎src/tools/msvc/build.pl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
# src/tools/msvc/build.pl
44

5+
use strict;
6+
57
BEGIN
68
{
79

@@ -68,6 +70,6 @@ BEGIN
6870

6971
# report status
7072

71-
$status =$? >> 8;
73+
my$status =$? >> 8;
7274

7375
exit$status;

‎src/tools/msvc/gendef.pl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
my@def;
2-
3-
use warnings;
41
use strict;
2+
use warnings;
53
use 5.8.0;
64
use File::Spec::Functionsqw(splitpath catpath);
75
use List::Utilqw(max);
86

7+
my@def;
8+
99
#
1010
# Script that generates a .DEF file for all objects in a directory
1111
#

‎src/tools/msvc/pgflex.pl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22

33
# src/tools/msvc/pgflex.pl
44

5-
# silence flex bleatings about file path style
6-
$ENV{CYGWIN} ='nodosfilewarning';
7-
85
use strict;
96
use File::Basename;
107

8+
# silence flex bleatings about file path style
9+
$ENV{CYGWIN} ='nodosfilewarning';
10+
1111
# assume we are in the postgres source root
1212

1313
require'src/tools/msvc/buildenv.pl'if-e'src/tools/msvc/buildenv.pl';

‎src/tools/pginclude/pgcheckdefines

Lines changed: 34 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,16 @@
2020
# src/tools/pginclude/pgcheckdefines
2121
#
2222

23+
use strict;
24+
2325
use Cwd;
2426
use File::Basename;
2527

26-
$topdir = cwd();
28+
my$topdir = cwd();
2729

2830
# Programs to use
29-
$FIND ="find";
30-
$MAKE ="make";
31+
my$FIND ="find";
32+
my$MAKE ="make";
3133

3234
#
3335
# Build arrays of all the .c and .h files in the tree
@@ -38,6 +40,8 @@ $MAKE = "make";
3840
# Including these .h files would clutter the list of define'd symbols and
3941
# cause a lot of false-positive results.
4042
#
43+
my (@cfiles,@hfiles);
44+
4145
open PIPE,"$FIND * -type f -name '*.c' |"
4246
ordie"can't fork:$!";
4347
while (<PIPE>)
@@ -63,7 +67,9 @@ close PIPE or die "$FIND failed: $!";
6367
# a hash table. To cover the possibility of multiple .h files defining
6468
# the same symbol, we make each hash entry a hash of filenames.
6569
#
66-
foreach$hfile (@hfiles)
70+
my%defines;
71+
72+
foreachmy$hfile (@hfiles)
6773
{
6874
open HFILE,$hfile
6975
ordie"can't open$hfile:$!";
@@ -82,9 +88,9 @@ foreach $hfile (@hfiles)
8288
# files it #include's. Then extract all the symbols it tests for defined-ness,
8389
# and check each one against the previously built hashtable.
8490
#
85-
foreach$file (@hfiles,@cfiles)
91+
foreachmy$file (@hfiles,@cfiles)
8692
{
87-
($fname,$fpath) = fileparse($file);
93+
my($fname,$fpath) = fileparse($file);
8894
chdir$fpathordie"can't chdir to$fpath:$!";
8995

9096
#
@@ -96,23 +102,28 @@ foreach $file (@hfiles, @cfiles)
96102
# hence printing multiple definitions --- we keep the last one, which
97103
# should come from the current Makefile.
98104
#
105+
my$MAKECMD;
106+
99107
if (-f"Makefile" ||-f"GNUmakefile")
100108
{
101109
$MAKECMD ="$MAKE -qp";
102110
}
103111
else
104112
{
105-
$subdir =$fpath;
113+
my$subdir =$fpath;
106114
chop$subdir;
107-
$top_builddir ="..";
108-
$tmp =$fpath;
115+
my$top_builddir ="..";
116+
my$tmp =$fpath;
109117
while (($tmp = dirname($tmp))ne'.')
110118
{
111119
$top_builddir =$top_builddir ."/..";
112120
}
113121
$MAKECMD =
114122
"$MAKE -qp 'subdir=$subdir' 'top_builddir=$top_builddir' -f '$top_builddir/src/Makefile.global'";
115123
}
124+
125+
my ($CPPFLAGS,$CFLAGS,$CFLAGS_SL,$PTHREAD_CFLAGS,$CC);
126+
116127
open PIPE,"$MAKECMD |"
117128
ordie"can't fork:$!";
118129
while (<PIPE>)
@@ -153,15 +164,15 @@ foreach $file (@hfiles, @cfiles)
153164
# "gcc -H" reports inclusions on stderr as "... filename" where the
154165
# number of dots varies according to nesting depth.
155166
#
156-
@includes = ();
157-
$COMPILE ="$CC$CPPFLAGS$CFLAGS -H -E$fname";
167+
my@includes = ();
168+
my$COMPILE ="$CC$CPPFLAGS$CFLAGS -H -E$fname";
158169
open PIPE,"$COMPILE 2>&1 >/dev/null |"
159170
ordie"can't fork:$!";
160171
while (<PIPE>)
161172
{
162173
if (m/^\.+ (.*)/)
163174
{
164-
$include =$1;
175+
my$include =$1;
165176

166177
# Ignore system headers (absolute paths); but complain if a
167178
# .c file includes a system header before any PG header.
@@ -176,7 +187,7 @@ foreach $file (@hfiles, @cfiles)
176187
$include =~s|^\./||;
177188

178189
# Make path relative to top of tree
179-
$ipath =$fpath;
190+
my$ipath =$fpath;
180191
while ($include =~s|^\.\./||)
181192
{
182193
$ipath = dirname($ipath) ."/";
@@ -202,19 +213,17 @@ foreach $file (@hfiles, @cfiles)
202213
#
203214
open FILE,$fname
204215
ordie"can't open$file:$!";
205-
$inif = 0;
216+
my$inif = 0;
206217
while (<FILE>)
207218
{
208-
$line =$_;
219+
my$line =$_;
209220
if ($line =~m/^\s*#\s*ifdef\s+(\w+)/)
210221
{
211-
$symbol =$1;
212-
&checkit;
222+
checkit($file,$1,@includes);
213223
}
214224
if ($line =~m/^\s*#\s*ifndef\s+(\w+)/)
215225
{
216-
$symbol =$1;
217-
&checkit;
226+
checkit($file,$1,@includes);
218227
}
219228
if ($line =~m/^\s*#\s*if\s+/)
220229
{
@@ -224,8 +233,7 @@ foreach $file (@hfiles, @cfiles)
224233
{
225234
while ($line =~s/\bdefined(\s+|\s*\(\s*)(\w+)//)
226235
{
227-
$symbol =$2;
228-
&checkit;
236+
checkit($file,$2,@includes);
229237
}
230238
if (!($line =~m/\\$/))
231239
{
@@ -243,6 +251,7 @@ exit 0;
243251
# Check an is-defined reference
244252
subcheckit
245253
{
254+
my ($file,$symbol,@includes) =@_;
246255

247256
# Ignore if symbol isn't defined in any PG include files
248257
if (!defined$defines{$symbol})
@@ -258,10 +267,10 @@ sub checkit
258267
# occur after the use of the symbol. Given our normal file layout,
259268
# however, the risk is minimal.
260269
#
261-
foreach$deffile (keys %{$defines{$symbol} })
270+
foreachmy$deffile (keys %{$defines{$symbol} })
262271
{
263272
returnif$deffileeq$file;
264-
foreach$reffile (@includes)
273+
foreachmy$reffile (@includes)
265274
{
266275
returnif$deffileeq$reffile;
267276
}
@@ -273,7 +282,7 @@ sub checkit
273282
#
274283
if ($file =~m/\.h$/)
275284
{
276-
foreach$deffile (keys %{$defines{$symbol} })
285+
foreachmy$deffile (keys %{$defines{$symbol} })
277286
{
278287
returnif$deffileeq'src/include/c.h';
279288
returnif$deffileeq'src/include/postgres.h';
@@ -284,7 +293,7 @@ sub checkit
284293
}
285294

286295
#
287-
@places =keys %{$defines{$symbol} };
296+
my@places =keys %{$defines{$symbol} };
288297
print"$file references$symbol, defined in@places\n";
289298

290299
# print "includes: @includes\n";

‎src/tools/version_stamp.pl

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,18 @@
2020
# "devel", "alphaN", "betaN", "rcN".
2121
#
2222

23+
use strict;
24+
2325
# Major version is hard-wired into the script. We update it when we branch
2426
# a new development version.
25-
$majorversion = 10;
27+
my$majorversion = 10;
2628

2729
# Validate argument and compute derived variables
28-
$minor =shift;
30+
my$minor =shift;
2931
defined($minor) ||die"$0: missing required argument: minor-version\n";
3032

33+
my ($dotneeded,$numericminor);
34+
3135
if ($minor =~m/^\d+$/)
3236
{
3337
$dotneeded = 1;
@@ -58,6 +62,8 @@
5862
die"$0: minor-version must be N, devel, alphaN, betaN, or rcN\n";
5963
}
6064

65+
my$fullversion;
66+
6167
# Create various required forms of the version number
6268
if ($dotneeded)
6369
{
@@ -67,13 +73,13 @@
6773
{
6874
$fullversion =$majorversion .$minor;
6975
}
70-
$numericversion =$majorversion ."." .$numericminor;
71-
$padnumericversion =sprintf("%d%04d",$majorversion,$numericminor);
76+
my$numericversion =$majorversion ."." .$numericminor;
77+
my$padnumericversion =sprintf("%d%04d",$majorversion,$numericminor);
7278

7379
# Get the autoconf version number for eventual nag message
7480
# (this also ensures we're in the right directory)
7581

76-
$aconfver ="";
82+
my$aconfver ="";
7783
open(FILE,"configure.in") ||die"could not read configure.in:$!\n";
7884
while (<FILE>)
7985
{
@@ -90,7 +96,7 @@
9096

9197
# Update configure.in and other files that contain version numbers
9298

93-
$fixedfiles ="";
99+
my$fixedfiles ="";
94100

95101
sed_file("configure.in",
96102
"-e 's/AC_INIT(\\[PostgreSQL\\],\\[[0-9a-z.]*\\]/AC_INIT([PostgreSQL], [$fullversion]/'"

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp