1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104
|
From: Ansgar Burchardt <ansgar@43-1.org>
Date: Thu, 26 Aug 2010 17:08:56 +0900
Origin: vendor
Bug-Debian: https://bugs.debian.org/558272
Bug: https://rt.cpan.org/Ticket/Display.html?id=60233
Subject: Use SvPV to strigify the SV in case it is not already a string
--- libdate-calc-perl.orig/XS.xs
+++ libdate-calc-perl/XS.xs
@@ -51,9 +51,7 @@
#define DATECALC_STRING(ref,var,len) \
- ( ref && !(SvROK(ref)) && SvPOK(ref) && \
- (var = (charptr)SvPV(ref,PL_na)) && \
- ((len = (N_int)SvCUR(ref)) | 1) )
+ ( ref && (var = (charptr)SvPV(ref,len)) )
#define DATECALC_SCALAR(ref,typ,var) \
( ref && !(SvROK(ref)) && ((var = (typ)SvIV(ref)) | 1) )
@@ -1268,7 +1266,7 @@
PPCODE:
{
charptr string;
- N_int length;
+ STRLEN length;
Z_int lang;
if ((items == 1) or (items == 2))
@@ -1295,7 +1293,7 @@
PPCODE:
{
charptr string;
- N_int length;
+ STRLEN length;
Z_int lang;
if ((items == 1) or (items == 2))
@@ -1333,7 +1331,7 @@
PPCODE:
{
charptr string;
- N_int length;
+ STRLEN length;
Z_int lang;
Z_int year;
Z_int month;
@@ -1369,7 +1367,7 @@
PPCODE:
{
charptr string;
- N_int length;
+ STRLEN length;
Z_int lang;
Z_int year;
Z_int month;
@@ -1780,8 +1778,8 @@
{
charptr string;
charptr buffer;
- N_int length;
- N_int index;
+ STRLEN length;
+ STRLEN index;
if ( DATECALC_STRING(scalar,string,length) )
{
@@ -1808,8 +1806,8 @@
{
charptr string;
charptr buffer;
- N_int length;
- N_int index;
+ STRLEN length;
+ STRLEN index;
if ( DATECALC_STRING(scalar,string,length) )
{
--- /dev/null
+++ libdate-calc-perl/t/debian-558272.t
@@ -0,0 +1,23 @@
+#! /usr/bin/perl
+
+use strict;
+use warnings;
+
+use Test::More 0.88;
+use Test::Exception;
+
+use_ok("Date::Calc");
+
+my $string = "Oct";
+$string =~ /(.*)/;
+lives_and { is Date::Calc::Decode_Month($1), 10 } 'Decode_Month($1) works';
+
+{
+ package
+ Foo;
+ use overload '""' => sub { "Nov" };
+}
+my $foo = bless {}, 'Foo';
+lives_and { is Date::Calc::Decode_Month($foo), 11 } 'Decode_Month() works with overload';
+
+done_testing();
|