# New Ticket Created by  Steve Fink 
# Please include the string:  [netlabs #579]
# in the subject line of all future correspondence about this issue. 
# <URL: http://bugs6.perl.org/rt2/Ticket/Display.html?id=579 >


This is a patch to the hashtable test suite, but the bug looks like it
might be in string.c:

            /* transcode first so we know the length and avoid infanticide */
            if (a->type != b->type || a->encoding != b->encoding) {
                b = string_transcode(interpreter, b, a->encoding, a->type,
                                     NULL);
            }
            result = string_make(interpreter, NULL, a->bufused + b->bufused,
                                 a->encoding, 0, a->type);

a is coming in marked as UTF-32, which seems incorrect (I can view
a->bufstart as a plain char*, and it has more than one letter in it.)
b comes in as usascii, which is correct. b gets transcoded to UTF-32.
Then when string_make() is called, b's bufstart seems to get wiped
out.

I don't have time to look into this yet, but I thought this might be
immediately obvious to someone else.

Index: t/pmc/perlhash.t
===================================================================
RCS file: /home/perlcvs/parrot/t/pmc/perlhash.t,v
retrieving revision 1.10
diff -u -r1.10 perlhash.t
--- t/pmc/perlhash.t    15 May 2002 01:45:11 -0000      1.10
+++ t/pmc/perlhash.t    15 May 2002 16:22:38 -0000
@@ -1,6 +1,6 @@
 #! perl
 
-use Parrot::Test tests => 8;
+use Parrot::Test tests => 9;
 use Test::More;
 
 output_is(<<'CODE', <<OUTPUT, "simple set / get");
@@ -178,6 +178,73 @@
 ok 1
 ok 2
 ok 3
+OUTPUT
+
+output_is(<<CODE, <<OUTPUT, "stress test");
+       new     P0, PerlHash
+
+        set I0, 200
+        set S0, "mikey"
+        set_keyed P0, S0, "base"
+        concat S1, S0, "s"
+        set_keyed P0, S1, "bases"
+        set S2, I0
+        concat S1, S0, S2
+        set_keyed P0, S1, "start"
+        get_keyed S3, P0, "mikey"
+        print S3
+        print "\\n"
+        get_keyed S3, P0, "mikeys"
+        print S3
+        print "\\n"
+        get_keyed S3, P0, "mikey200"
+        print S3
+        print "\\n"
+LOOP:
+        eq I0, 0, DONE
+        sub I0, I0, 1
+        set S2, I0
+        concat S1, S0, S2
+        concat S4, S0, S2
+        eq S1, S4, L1
+        print "concat mismatch: "
+        print S1
+        print " vs "
+        print S4
+        print "\\n"
+L1:
+        set_keyed P0, S1, I0
+        get_keyed I1, P0, S1
+        eq I0, I1, L2
+        print "lookup mismatch: "
+        print I0
+        print " vs "
+        print I1
+        print "\\n"
+L2:
+        branch LOOP
+DONE:
+        get_keyed I0, P0, "mikey199"
+        print I0
+        print "\\n"
+        get_keyed I0, P0, "mikey1"
+        print I0
+        print "\\n"
+        get_keyed I0, P0, "mikey23"
+        print I0
+        print "\\n"
+        get_keyed I0, P0, "mikey832"
+        print I0
+        print "\\n"
+        end
+CODE
+base
+bases
+start
+199
+1
+23
+0
 OUTPUT
 
 1;

Reply via email to