In perl.git, the branch blead has been updated

<http://perl5.git.perl.org/perl.git/commitdiff/ded2eedcb4ea5645092eea71df32e0f737b89d90?hp=86b22379fed2b21897f767d5f96d76a24dd46436>

- Log -----------------------------------------------------------------
commit ded2eedcb4ea5645092eea71df32e0f737b89d90
Author: Craig A. Berry <[email protected]>
Date:   Tue Jun 29 07:14:39 2010 -0500

    Remove alloca() use from Time::Piece for portability.
    
    In 1.17, T::P started using its own strptime (almost) everywhere,
    and this _strptime contains a single reference to alloca().  The
    Linux and BSD man pages recommend against using alloca(), the
    function  doesn't exist on HP-UX or VMS, and it's impossible to
    error check it.  So replace it here with malloc().
    
    If getting three or four bytes from the heap instead of the stack
    is considered a problem, an alternative would be researching the
    maximum length of a timezone name and using an automatic variable
    to hold it.
-----------------------------------------------------------------------

Summary of changes:
 cpan/Time-Piece/Piece.pm |    2 +-
 cpan/Time-Piece/Piece.xs |   23 +++++++----------------
 2 files changed, 8 insertions(+), 17 deletions(-)

diff --git a/cpan/Time-Piece/Piece.pm b/cpan/Time-Piece/Piece.pm
index 2afbdba..a3f7fb6 100644
--- a/cpan/Time-Piece/Piece.pm
+++ b/cpan/Time-Piece/Piece.pm
@@ -19,7 +19,7 @@ our %EXPORT_TAGS = (
     ':override' => 'internal',
     );
 
-our $VERSION = '1.20';
+our $VERSION = '1.20_01';
 
 bootstrap Time::Piece $VERSION;
 
diff --git a/cpan/Time-Piece/Piece.xs b/cpan/Time-Piece/Piece.xs
index 0bbefd3..5d3f992 100644
--- a/cpan/Time-Piece/Piece.xs
+++ b/cpan/Time-Piece/Piece.xs
@@ -307,19 +307,6 @@ my_mini_mktime(struct tm *ptm)
 #       define strncasecmp(x,y,n) strnicmp(x,y,n)
 #   endif
 
-#if defined(WIN32)
-#if defined(__BORLANDC__)
-void * __cdecl _EXPFUNC alloca(_SIZE_T __size);
-#else
-#define alloca _alloca
-#endif
-#else
-#if defined(_SGIAPI) || defined( __sgi ) || ( defined (__SVR4) && defined 
(__sun) )
-/* required for IRIX and Solaris */
-#include <alloca.h>
-#endif
-#endif
-
 /* strptime copied from freebsd with the following copyright: */
 /*
  * Copyright (c) 1994 Powerdog Industries.  All rights reserved.
@@ -916,15 +903,19 @@ label:
                        for (cp = buf; *cp && isupper((unsigned char)*cp); 
++cp) 
                             {/*empty*/}
                        if (cp - buf) {
-                               zonestr = (char *)alloca(cp - buf + 1);
+                               zonestr = malloc(cp - buf + 1);
+                               if (!zonestr) {
+                                   errno = ENOMEM;
+                                   return 0;
+                               }
                                strncpy(zonestr, buf, cp - buf);
                                zonestr[cp - buf] = '\0';
                                my_tzset(aTHX);
                                if (0 == strcmp(zonestr, "GMT")) {
                                    got_GMT = 1;
-                               } else {
-                                   return 0;
                                }
+                               free(zonestr);
+                               if (!got_GMT) return 0;
                                buf += cp - buf;
                        }
                        }

--
Perl5 Master Repository

Reply via email to