[perl-ExtUtils-PkgConfig] Correctly handle major-only versions, like '2'



commit 046f0bd582e44283b0b76d3af5d43e8e2089bd36
Author: Torsten SchÃnfeld <kaffeetisch gmx de>
Date:   Sat Apr 21 19:31:23 2012 +0200

    Correctly handle major-only versions, like '2'
    
    https://rt.cpan.org/Ticket/Display.html?id=68246

 Changes                   |    3 +++
 MANIFEST                  |    1 +
 lib/ExtUtils/PkgConfig.pm |    1 +
 t/4.t                     |    9 ++++++++-
 t/test_short.pc           |   10 ++++++++++
 5 files changed, 23 insertions(+), 1 deletions(-)
---
diff --git a/Changes b/Changes
index eb57d09..5a19940 100644
--- a/Changes
+++ b/Changes
@@ -1,5 +1,8 @@
 Revision history for Perl extension ExtUtils::PkgConfig.
 
+<next>
+        - Correctly handle major-only versions, like '2' (RT #68246).
+
 1.12  Sun Oct 19 13:56:07 CEST 2008
 	- Try to fix a test failure.
 
diff --git a/MANIFEST b/MANIFEST
index 46b1627..56f922f 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -13,3 +13,4 @@ t/4.t
 t/swallow_stderr.inc
 t/test_glib-2.0.pc
 t/test_non_numeric.pc
+t/test_short.pc
diff --git a/lib/ExtUtils/PkgConfig.pm b/lib/ExtUtils/PkgConfig.pm
index 8f807b4..6fc85f6 100644
--- a/lib/ExtUtils/PkgConfig.pm
+++ b/lib/ExtUtils/PkgConfig.pm
@@ -142,6 +142,7 @@ sub create_version_macros {
 
 		if( %data ) {
 			my @modversion = split /\./, $data{modversion};
+			$modversion[1] = 0 unless defined $modversion[1];
 			$modversion[2] = 0 unless defined $modversion[2];
 
 			# If a version part contains non-numeric characters,
diff --git a/t/4.t b/t/4.t
index 52302d7..a729b5c 100644
--- a/t/4.t
+++ b/t/4.t
@@ -5,7 +5,7 @@
 use strict;
 use warnings;
 
-use Test::More tests => 20;
+use Test::More tests => 24;
 use ExtUtils::PkgConfig;
 
 require 't/swallow_stderr.inc';
@@ -32,6 +32,13 @@ ok (contains ($macros, 'TEST_MINOR_VERSION (0)'));
 ok (contains ($macros, 'TEST_MICRO_VERSION (4)'));
 ok (contains ($macros, 'TEST_CHECK_VERSION'));
 
+# Check that '2' is turned into 2.0.0
+$macros = ExtUtils::PkgConfig->create_version_macros (qw/test_short/, 'TEST');
+ok (contains ($macros, 'TEST_MAJOR_VERSION (2)'));
+ok (contains ($macros, 'TEST_MINOR_VERSION (0)'));
+ok (contains ($macros, 'TEST_MICRO_VERSION (0)'));
+ok (contains ($macros, 'TEST_CHECK_VERSION'));
+
 swallow_stderr (sub {
 	eval {
 		ExtUtils::PkgConfig->create_version_macros (qw/__bad__/, 'BAD');
diff --git a/t/test_short.pc b/t/test_short.pc
new file mode 100644
index 0000000..5b68831
--- /dev/null
+++ b/t/test_short.pc
@@ -0,0 +1,10 @@
+prefix=/usr
+exec_prefix=/usr
+libdir=/usr/lib
+includedir=/usr/include
+
+Name: TestShort
+Description: Bla blub
+Version: 2
+Libs: -L${libdir} -ltest-short
+Cflags: -I${includedir}/test-short



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]