Subject: | Remove use of POSIX so Pod::Man will work with miniperl |
I'm working on changing MakeMaker in the Perl core so it's built as a
normal module in ext/ rather than being scattered around lib/. It makes
integration between p5p and CPAN a whole lot easier.
ext/ modules are built with miniperl. miniperl can't load dynamic
modules like Fcntl. POSIX loads Fcntl and MakeMaker loads Pod::Man. So
MakeMaker won't build with miniperl.
This patch removes the single use of POSIX from Pod::Man, strftime(),
and replaces it with the equivalent pure Perl code. It hope you don't
mind the inconvenience.
Subject: | 0001-Remove-use-of-POSIX-from-Pod-Man-else-MakeMaker-won.patch |
From 59220bf4e77e35b4875b6b6bb89002621af9bc6d Mon Sep 17 00:00:00 2001
From: Michael G. Schwern <schwern@pobox.com>
Date: Tue, 24 Feb 2009 14:36:00 -0800
Subject: [PATCH] Remove use of POSIX from Pod::Man else MakeMaker won't build in the core.
Can't use POSIX::strftime(), which uses Fcntl, because MakeMaker
uses this and it has to build with miniperl which can't use dynamic
libraries.
---
lib/Pod/Man.pm | 8 ++++++--
t/devise_date.t | 15 +++++++++++++++
2 files changed, 21 insertions(+), 2 deletions(-)
create mode 100644 t/devise_date.t
diff --git a/lib/Pod/Man.pm b/lib/Pod/Man.pm
index 71a4d7a..866c2e1 100644
--- a/lib/Pod/Man.pm
+++ b/lib/Pod/Man.pm
@@ -32,7 +32,6 @@ use vars qw(@ISA %ESCAPES $PREAMBLE $VERSION);
use Carp qw(croak);
use Pod::Simple ();
-use POSIX qw(strftime);
@ISA = qw(Pod::Simple);
@@ -853,7 +852,12 @@ sub devise_date {
} else {
$time = time;
}
- return strftime ('%Y-%m-%d', localtime $time);
+
+ # Can't use POSIX::strftime(), which uses Fcntl, because MakeMaker
+ # uses this and it has to work in the core which can't load dynamic
+ # libraries.
+ my($year, $month, $day) = (localtime $time)[5,4,3];
+ return sprintf("%04d-%02d-%02d", $year + 1900, $month + 1, $day);
}
# Print out the preamble and the title. The meaning of the arguments to .TH
diff --git a/t/devise_date.t b/t/devise_date.t
new file mode 100644
index 0000000..3cce9f5
--- /dev/null
+++ b/t/devise_date.t
@@ -0,0 +1,15 @@
+#!/usr/bin/perl -w
+
+# In order for MakeMaker to build in the core, nothing can use
+# Fcntl which includes POSIX. devise_date()'s use of strftime()
+# was replaced. This tests that it's identical.
+
+use strict;
+
+use Test::More tests => 1;
+
+use Pod::Man;
+use POSIX qw(strftime);
+
+my $parser = Pod::Man->new;
+is $parser->devise_date, strftime("%Y-%m-%d", localtime);
--
1.6.1.2