From: Yuval Kogman Date: Tue, 19 Aug 2008 23:09:46 +0000 (+0000) Subject: fix integer TC X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=0be3b17fbf10b94affa54a7d557b831b8d6ea849;p=gitmo%2FMoose.git fix integer TC --- diff --git a/Moose.xs b/Moose.xs index 38130aa..e30b35e 100644 --- a/Moose.xs +++ b/Moose.xs @@ -345,14 +345,23 @@ STATIC bool check_sv_type (TC type, SV *sv) { if ( SvIOK(sv) ) { return 1; } else if ( SvPOK(sv) ) { + /* FIXME i really don't like this */ int i; STRLEN len; char *pv = SvPV(sv, len); char *end = pv + len; + char *tail = end; errno = 0; - i = strtol(pv, &end, 0); - return !errno; + i = strtol(pv, &tail, 0); + + if ( errno ) return 0; + + while ( tail != end ) { + if ( !isspace(*tail++) ) return 0; + } + + return 1; } return 0; break; diff --git a/t/700_xs/001_basic.t b/t/700_xs/001_basic.t index 41dfd9f..1dea63e 100644 --- a/t/700_xs/001_basic.t +++ b/t/700_xs/001_basic.t @@ -217,6 +217,7 @@ ok( eval { $foo->a([]); 1 }, "ArrayRef" ); ok( eval { $foo->i(3); 1 }, "Int" ); ok( eval { $foo->i("3"); 1 }, "Int" ); ok( eval { $foo->i("-3"); 1 }, "Int" ); +ok( eval { $foo->i(" -3 "); 1 }, "Int" ); ok( eval { $foo->s("foo"); 1 }, "Str" ); ok( eval { $foo->s(""); 1 }, "Str" ); ok( eval { $foo->s(4); 1 }, "Str" );