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;
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" );