[svn:parrot] r48800 - in trunk: src/pmc t/pmc

nwellnhof at svn.parrot.org nwellnhof at svn.parrot.org
Sun Sep 5 16:14:02 UTC 2010


Author: nwellnhof
Date: Sun Sep  5 16:14:02 2010
New Revision: 48800
URL: https://trac.parrot.org/parrot/changeset/48800

Log:
[pmc] Fix String.is_integer

Modified:
   trunk/src/pmc/string.pmc
   trunk/t/pmc/string.t

Modified: trunk/src/pmc/string.pmc
==============================================================================
--- trunk/src/pmc/string.pmc	Sun Sep  5 13:20:27 2010	(r48799)
+++ trunk/src/pmc/string.pmc	Sun Sep  5 16:14:02 2010	(r48800)
@@ -724,18 +724,18 @@
 
     METHOD is_integer(STRING *src) {
         INTVAL         i;
-        unsigned char *p;
+        char          *p;
         const INTVAL   len = Parrot_str_length(INTERP, src);
 
         if (!len)
             RETURN(INTVAL 0);
 
-        if (src->charset != Parrot_ascii_charset_ptr)
+        if (src->encoding != Parrot_fixed_8_encoding_ptr)
             Parrot_ex_throw_from_c_args(INTERP, NULL, EXCEPTION_INVALID_ENCODING,
-                "Can't is_integer non-ascii");
+                "Can't is_integer non fixed_8");
 
         i = 0;
-        p = (unsigned char *)Buffer_bufstart(src);
+        p = src->strstart;
 
         if (p[i] == '-' || p[i] == '+' ||
             (p[i] >= '0' && p[i] <= '9')) {

Modified: trunk/t/pmc/string.t
==============================================================================
--- trunk/t/pmc/string.t	Sun Sep  5 13:20:27 2010	(r48799)
+++ trunk/t/pmc/string.t	Sun Sep  5 16:14:02 2010	(r48800)
@@ -19,7 +19,7 @@
 .sub main :main
     .include 'test_more.pir'
 
-    plan(120)
+    plan(121)
 
     set_or_get_strings()
     setting_integers()
@@ -586,6 +586,11 @@
 
   $I0 = $P0.'is_integer'('+1')
   ok( $I0, '... +1' )
+
+  $S0 = 'abc123abc'
+  $S1 = substr $S0, 3, 3
+  $I0 = $P0.'is_integer'($S1)
+  ok( $I0, '... substr' )
 .end
 
 .sub instantiate_str


More information about the parrot-commits mailing list