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, &tail, 0);
-
- if ( errno ) return 0;
-
- while ( tail != end ) {
- if ( !isspace(*tail++) ) return 0;
- }
-
- return 1;
+ int flags = grok_number(pv, len, NULL);
+ return ( flags && !(flags & IS_NUMBER_NOT_INT) );
}
return 0;
break;
ok( !eval { $foo->i("1.3"); 1 }, "Int" );
ok( !eval { $foo->i("foo"); 1 }, "Int" );
ok( !eval { $foo->i(undef); 1 }, "Int" );
+ok( !eval { $foo->i(\undef); 1 }, "Int" );
ok( !eval { $foo->s(undef); 1 }, "Str" );
ok( !eval { $foo->s([]); 1 }, "Str" );
ok( !eval { $foo->o({}); 1 }, "Object" );