cvsuser     05/04/04 01:12:11

  Modified:    charset  unicode.c
               encodings utf8.c
               t/op     string_cs.t
  Log:
  fix 2 unicode issues: #34660, #34661
  
  Revision  Changes    Path
  1.5       +13 -4     parrot/charset/unicode.c
  
  Index: unicode.c
  ===================================================================
  RCS file: /cvs/public/parrot/charset/unicode.c,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- unicode.c 2 Mar 2005 17:00:49 -0000       1.4
  +++ unicode.c 4 Apr 2005 08:12:09 -0000       1.5
  @@ -299,10 +299,19 @@
   }
   
   static size_t
  -compute_hash(Interp *interpreter, STRING *source_string)
  +compute_hash(Interp *interpreter, STRING *src)
   {
  -    UNIMPL;
  -    return 0;
  +    String_iter iter;
  +    size_t hashval = 0;
  +    UINTVAL offs, c;
  +
  +    ENCODING_ITER_INIT(interpreter, src, &iter);
  +    for (offs = 0; offs < src->strlen; ++offs) {
  +        c = iter.get_and_advance(interpreter, &iter);
  +        hashval += hashval << 5;
  +        hashval += c;
  +    }
  +    return hashval;
   }
   
   CHARSET *
  
  
  
  1.26      +3 -2      parrot/encodings/utf8.c
  
  Index: utf8.c
  ===================================================================
  RCS file: /cvs/public/parrot/encodings/utf8.c,v
  retrieving revision 1.25
  retrieving revision 1.26
  diff -u -r1.25 -r1.26
  --- utf8.c    7 Mar 2005 16:44:23 -0000       1.25
  +++ utf8.c    4 Apr 2005 08:12:10 -0000       1.26
  @@ -274,10 +274,11 @@
       const STRING *s = i->str;
       unsigned char *new_pos, *pos;
   
  -    assert(i->bytepos < PObj_buflen(s) - 4);
       pos = (unsigned char *)s->strstart + i->bytepos;
       new_pos = utf8_encode(pos, c);
       i->bytepos += (new_pos - pos);
  +    /* XXX possible buffer overrun exception? */
  +    assert(i->bytepos < PObj_buflen(s));
       i->charpos++;
   }
   
  
  
  
  1.9       +27 -2     parrot/t/op/string_cs.t
  
  Index: string_cs.t
  ===================================================================
  RCS file: /cvs/public/parrot/t/op/string_cs.t,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- string_cs.t       2 Mar 2005 13:47:33 -0000       1.8
  +++ string_cs.t       4 Apr 2005 08:12:10 -0000       1.9
  @@ -16,7 +16,7 @@
   
   =cut
   
  -use Parrot::Test tests => 28;
  +use Parrot::Test tests => 30;
   use Test::More;
   
   output_is( <<'CODE', <<OUTPUT, "basic syntax" );
  @@ -445,3 +445,28 @@
   6
   OUTPUT
   
  +pir_output_is( <<'CODE', <<'OUTPUT', "bug #34661 literal" );
  +.sub main @MAIN
  +    $S0 = unicode:"\"]\nif I3 == "
  +    print "ok 1\n"
  +.end
  +CODE
  +ok 1
  +OUTPUT
  +
  +pir_output_is( <<'CODE', <<'OUTPUT', "todo #34660 hash" );
  +.sub main @MAIN
  +    $P0 = new Integer
  +    $P0 = 42
  +    store_global "Foo", unicode:"Bar", $P0
  +    print "ok 1\n"
  +    $P1 = find_global "Foo", "Bar"
  +    print "ok 2\n"
  +    print $P1
  +    print "\n"
  +.end
  +CODE
  +ok 1
  +ok 2
  +42
  +OUTPUT
  
  
  

Reply via email to