develooper Front page | perl.cvs.parrot | Postings from December 2008

[svn:parrot] r33417 - trunk/src/pmc

From:
julianalbo
Date:
December 1, 2008 02:08
Subject:
[svn:parrot] r33417 - trunk/src/pmc
Message ID:
20081201100809.8DE57CB9AF@x12.develooper.com
Author: julianalbo
Date: Mon Dec  1 02:08:07 2008
New Revision: 33417

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

Log:
fix is_same with pmc string and null and with null pmc, parrot-tickets#11

Modified: trunk/src/pmc/null.pmc
==============================================================================
--- trunk/src/pmc/null.pmc	(original)
+++ trunk/src/pmc/null.pmc	Mon Dec  1 02:08:07 2008
@@ -50,6 +50,19 @@
         return 0;
     }
 
+/*
+
+=item C<INTVAL is_same(PMC *value)>
+
+Returns true if value is also a null PMC, false otherwise.
+
+=cut
+
+*/
+    VTABLE INTVAL is_same(PMC *value) {
+        return PMC_IS_NULL(value);
+    }
+
 }
 
 /*

Modified: trunk/src/pmc/string.pmc
==============================================================================
--- trunk/src/pmc/string.pmc	(original)
+++ trunk/src/pmc/string.pmc	Mon Dec  1 02:08:07 2008
@@ -497,9 +497,14 @@
 
 */
     VTABLE INTVAL is_same(PMC *value) {
-        const STRING * const s = VTABLE_get_string(INTERP, SELF);
-        const STRING * const v = VTABLE_get_string(INTERP, value);
-        return (INTVAL)(value->vtable == SELF->vtable && s == v);
+        if (PMC_IS_NULL(value)) {
+            return 0;
+        }
+        else {
+            const STRING * const s = VTABLE_get_string(INTERP, SELF);
+            const STRING * const v = VTABLE_get_string(INTERP, value);
+            return (INTVAL)(value->vtable == SELF->vtable && s == v);
+        }
     }
 
 /*



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About