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

Commit502dc6d

Browse files
committed
Make PostgresVersion code a bit more robust and simple.
per gripe from Alvaro Herrera.
1 parent8aba932 commit502dc6d

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

‎src/test/perl/PostgresVersion.pm

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ PostgresVersion - class representing PostgreSQL version numbers
3434
3535
=head1DESCRIPTION
3636
37-
PostgresVersionencapsulated Postgres version numbers, providing parsing
37+
PostgresVersionencapsulates Postgres version numbers, providing parsing
3838
of common version formats and comparison operations.
3939
4040
=cut
@@ -73,25 +73,22 @@ sub new
7373
my$class =shift;
7474
my$arg =shift;
7575

76+
chomp$arg;
77+
7678
# Accept standard formats, in case caller has handed us the output of a
7779
# postgres command line tool
78-
$arg =$1
79-
if ($arg =~m/\(?PostgreSQL\)? (\d+(?:\.\d+)*(?:devel)?)/);
80+
my$devel;
81+
($arg,$devel) = ($1,$2)
82+
if ($arg =~m/^(?:\(?PostgreSQL\)? )?(\d+(?:\.\d+)*)(devel)?/);
8083

8184
# Split into an array
8285
my@result =split(/\./,$arg);
8386

8487
# Treat development versions as having a minor/micro version one less than
8588
# the first released version of that branch.
86-
if ($result[$#result] =~m/^(\d+)devel$/)
87-
{
88-
pop(@result);
89-
push(@result,$1, -1);
90-
}
89+
push@result, -1if ($devel);
9190

92-
my$res = [@result];
93-
bless$res,$class;
94-
return$res;
91+
returnbless \@result,$class;
9592
}
9693

9794

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp