[Catalyst] Catalyst::Helper passes %T to POSIX::strftime - causes infinite loop under Win32

Christopher H. Laco claco at chrislaco.com
Tue Jul 17 17:40:01 GMT 2007


bits wrote:
> Catalyst::Helper::_mk_changes calls POSIX::strftime on line 390:
>     my $time =3D strftime('%Y-%m-%d %T', localtime time);
> =

> the %T parameter causes my Activestate Perl 5.8.8 820 to infinite loop.  =

> =

> =

> In fact,
>    perl -MPOSIX -e "print POSIX::strftime('%T', localtime time);"
> also infinite loops.
> =

> Nice.  =

> =

> =

> The perldoc for POSIX states in the strftime notes:
> "If you want your code to be portable, your format (fmt ) argument should
> use only the conversion specifiers defined by the ANSI C standard (C89, to
> play safe). These are aAbBcdHIjmMpSUwWxXyYZ% ."
> =

> %T is not in the list.  On all the systems I have at my disposal, %H:%M:%S
> produces equivalent output and uses only the conversion specifiers they
> recommend.
> =

> =

> For the sake of saving the next soul who wants to use Catalyst under Win3=
2,
> which apparently doesn't like %T, suggest changing to:
> =

>     my $time =3D strftime('%Y-%m-%d %H:%M:%S', localtime time);
> =

> =

> =

> --- Helper.pm   Wed Jul 11 03:24:55 2007
> +++ Helper.pm.orig      Mon Oct 30 18:00:42 2006
> @@ -387,7 +387,7 @@
>  sub _mk_changes {
>      my $self =3D shift;
>      my $dir  =3D $self->{dir};
> -    my $time =3D strftime('%Y-%m-%d %H:%M:%S', localtime time);
> +    my $time =3D strftime('%Y-%m-%d %T', localtime time);
>      $self->render_file( 'changes', "$dir\/Changes", { time =3D> $time } =
);
>  }
> =


Just for the sake of mentioning it...SVK had similiar problems under
win32 with %T and also the zone info....

Here was the final patch:

> sub time2str {
>     my ($format, $time) =3D @_;
>     if (IS_WIN32) {
>         require Date::Format;
>         goto \&Date::Format::time2str;
>     }
> =

>     require POSIX;
>     return POSIX::strftime($format, localtime($time) );
> }

Not necessarily the solution, but an illustration of one possible
solution...

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 187 bytes
Desc: OpenPGP digital signature
Url : http://lists.scsys.co.uk/pipermail/catalyst/attachments/20070717/8824=
ae49/signature.pgp


More information about the Catalyst mailing list