Front page | perl.perl5.porters |
Postings from May 2008
Time-Piece-1.13 test failures on HP-UX
From:
Gisle Aas
Date:
May 22, 2008 15:21
Subject:
Time-Piece-1.13 test failures on HP-UX
Message ID:
EB1DA83A-AA9C-4BA4-A09D-AB6DC5E00EB9@activestate.com
This is the conversation I had with Matt about this issue and the
patch I provided for fixing it.
--Gisle
Begin forwarded message:
> From: Gisle Aas <gisle@activestate.com>
> Date: May 5, 2008 11:30:12 GMT+02:00
> To: matt@sergeant.org
> Cc: Jan Dubois <jand@activestate.com>
> Subject: Time-Piece test failures on HP-UX
>
> Hi Matt,
>
> I just wanted to let you know that we experience test failures with
> Time-Piece-1.13's t/07arith.t test on HP-UX. The reason is that
> the system strptime() function on HP-UX returns NULL for dates like
> "2001-02-29". For now I've fixed our copy by simply using the
> bundled strptime even on HP-UX with the patch below.
>
> A better fix would probably be to rework add_months() to not rely
> on strptime being able to parse illegal dates.
>
> Regards,
> Gisle
>
>
>
>
> Index: main/Camel/src/cpan/T/Time/Time-Piece/main/Piece.xs
> --- main/Camel/src/cpan/T/Time/Time-Piece/main/Piece.xs.~1~ Mon
> May 5 11:24:20 2008
> +++ main/Camel/src/cpan/T/Time/Time-Piece/main/Piece.xs Mon May 5
> 11:24:20 2008
> @@ -184,8 +184,10 @@
> }
>
> /* No strptime on Win32 or QNX4 */
> -#if defined(WIN32) || (defined(__QNX__) && defined(__WATCOMC__))
> +#if defined(WIN32) || (defined(__QNX__) && defined(__WATCOMC__))
> || defined(__hpux)
> +#ifndef __hpux
> #define strncasecmp(x,y,n) strnicmp(x,y,n)
> +#endif
>
> #if defined(WIN32)
> #define alloca _alloca
> End of Patch.
Begin forwarded message:
> From: Matt Sergeant <matt@sergeant.org>
> Date: May 5, 2008 15:06:15 GMT+02:00
> To: Gisle Aas <gisle@activestate.com>
> Cc: Jan Dubois <jand@activestate.com>
> Subject: Re: Time-Piece test failures on HP-UX
>
> On 5-May-08, at 5:30 AM, Gisle Aas wrote:
>
>> I just wanted to let you know that we experience test failures
>> with Time-Piece-1.13's t/07arith.t test on HP-UX. The reason is
>> that the system strptime() function on HP-UX returns NULL for
>> dates like "2001-02-29". For now I've fixed our copy by simply
>> using the bundled strptime even on HP-UX with the patch below.
>>
>> A better fix would probably be to rework add_months() to not rely
>> on strptime being able to parse illegal dates.
>
> Hmm, any idea what posix says about this?
>
> Matt.
Begin forwarded message:
> From: Gisle Aas <gisle@activestate.com>
> Date: May 5, 2008 17:04:40 GMT+02:00
> To: Matt Sergeant <matt@sergeant.org>
> Cc: Jan Dubois <jand@activestate.com>
> Subject: Re: Time-Piece test failures on HP-UX
>
> On May 5, 2008, at 15:06, Matt Sergeant wrote:
>
>> On 5-May-08, at 5:30 AM, Gisle Aas wrote:
>>
>>> I just wanted to let you know that we experience test failures
>>> with Time-Piece-1.13's t/07arith.t test on HP-UX. The reason is
>>> that the system strptime() function on HP-UX returns NULL for
>>> dates like "2001-02-29". For now I've fixed our copy by simply
>>> using the bundled strptime even on HP-UX with the patch below.
>>>
>>> A better fix would probably be to rework add_months() to not rely
>>> on strptime being able to parse illegal dates.
>>
>> Hmm, any idea what posix says about this?
>
> It doesn't appear that it says anything about this kind of behaviour.
>
> http://www.opengroup.org/onlinepubs/009695399/functions/
> strptime.html
>
> --Gisle
>
Begin forwarded message:
> From: Gisle Aas <gisle@activestate.com>
> Date: May 6, 2008 22:06:11 GMT+02:00
> To: Matt Sergeant <matt@sergeant.org>
> Cc: Jan Dubois <jand@activestate.com>
> Subject: Re: Time-Piece test failures on HP-UX
>
> On May 5, 2008, at 15:06, Matt Sergeant wrote:
>
>> On 5-May-08, at 5:30 AM, Gisle Aas wrote:
>>
>>> I just wanted to let you know that we experience test failures
>>> with Time-Piece-1.13's t/07arith.t test on HP-UX. The reason is
>>> that the system strptime() function on HP-UX returns NULL for
>>> dates like "2001-02-29". For now I've fixed our copy by simply
>>> using the bundled strptime even on HP-UX with the patch below.
>>>
>>> A better fix would probably be to rework add_months() to not rely
>>> on strptime being able to parse illegal dates.
>>
>
> This is such a patch:
>
> Index: Piece.pm
> --- Piece.pm.~1~ Tue May 6 22:00:41 2008
> +++ Piece.pm Tue May 6 22:00:41 2008
> @@ -607,12 +607,8 @@
> $final_month = $final_month % 12;
> }
>
> - my $string = ($time->year + $num_years) . "-" .
> - ($final_month + 1) . "-" .
> - ($time->mday) . " " . $time->hms;
> - my $format = "%Y-%m-%d %H:%M:%S";
> - #warn("Parsing string: $string\n");
> - my @vals = _strptime($string, $format);
> + my @vals = _mini_mktime($time->sec, $time->min, $time->hour,
> + $time->mday, $final_month, $time->year
> - 1900 + $num_years);
> # warn(sprintf("got vals: %d-%d-%d %d:%d:%d\n", reverse(@vals)));
> return scalar $time->_mktime(\@vals, $time->[c_islocal]);
> }
> ==== //depot/Piece.xs#5 - /Users/gisle/camel/src/cpan/T/Time/Time-
> Piece/main/Piece.xs ====
> Index: Piece.xs
> --- Piece.xs.~1~ Tue May 6 22:00:41 2008
> +++ Piece.xs Tue May 6 22:00:41 2008
> @@ -915,3 +915,37 @@
> PUSHs(sv_2mortal(newSViv(0)));
> /* islocal */
> PUSHs(sv_2mortal(newSViv(0)));
> +
> +void
> +_mini_mktime(int sec, int min, int hour, int mday, int mon, int year)
> + PREINIT:
> + struct tm mytm;
> + time_t t;
> + PPCODE:
> + t = 0;
> + mytm = *gmtime(&t);
> +
> + mytm.tm_sec = sec;
> + mytm.tm_min = min;
> + mytm.tm_hour = hour;
> + mytm.tm_mday = mday;
> + mytm.tm_mon = mon;
> + mytm.tm_year = year;
> +
> + my_mini_mktime(&mytm);
> +
> + EXTEND(SP, 11);
> + PUSHs(sv_2mortal(newSViv(mytm.tm_sec)));
> + PUSHs(sv_2mortal(newSViv(mytm.tm_min)));
> + PUSHs(sv_2mortal(newSViv(mytm.tm_hour)));
> + PUSHs(sv_2mortal(newSViv(mytm.tm_mday)));
> + PUSHs(sv_2mortal(newSViv(mytm.tm_mon)));
> + PUSHs(sv_2mortal(newSViv(mytm.tm_year)));
> + PUSHs(sv_2mortal(newSViv(mytm.tm_wday)));
> + PUSHs(sv_2mortal(newSViv(mytm.tm_yday)));
> + /* isdst */
> + PUSHs(sv_2mortal(newSViv(0)));
> + /* epoch */
> + PUSHs(sv_2mortal(newSViv(0)));
> + /* islocal */
> + PUSHs(sv_2mortal(newSViv(0)));
> End of Patch.
>
-
Time-Piece-1.13 test failures on HP-UX
by Gisle Aas