On Sun, May 08, 2005 at 11:45:08PM +0200, Jens Rieks wrote: > Hi, > > C<is_cclass> is now implemented. The second part (find_(not_)cclass) will > follow tomorrow.
The attached patch file adjusts C<is_cclass> to always return false for offsets beyond the end of the string, and updates t/op/string_cclass.t to test this. Pm
Index: charset/iso-8859-1.c =================================================================== --- charset/iso-8859-1.c (revision 8017) +++ charset/iso-8859-1.c (working copy) @@ -322,8 +322,9 @@ is_cclass(Interp *interpreter, PARROT_CCLASS_FLAGS flags, STRING *source_string, UINTVAL offset) { UINTVAL codepoint; + if (offset >= source_string->strlen) return 0; + codepoint = ENCODING_GET_CODEPOINT(interpreter, source_string, offset); - if (codepoint >= sizeof(Parrot_ascii_typetable) / sizeof(Parrot_ascii_typetable[0])) { return 0; } Index: charset/ascii.c =================================================================== --- charset/ascii.c (revision 8017) +++ charset/ascii.c (working copy) @@ -555,8 +555,9 @@ is_cclass(Interp *interpreter, PARROT_CCLASS_FLAGS flags, STRING *source_string, UINTVAL offset) { UINTVAL codepoint; + if (offset >= source_string->strlen) return 0; + codepoint = ENCODING_GET_CODEPOINT(interpreter, source_string, offset); - if (codepoint >= sizeof(Parrot_ascii_typetable) / sizeof(Parrot_ascii_typetable[0])) { return 0; } Index: t/op/string_cclass.t =================================================================== --- t/op/string_cclass.t (revision 8017) +++ t/op/string_cclass.t (working copy) @@ -61,40 +61,40 @@ $I2 = is_cclass code, str, $I0 print $I2 inc $I0 - if $I0 < $I1 goto loop + if $I0 <= $I1 goto loop print "\n" .end CODE -000110000000 -110000000000 -110110000000 -000001100000 -110101100000 -001000000110 -110111110101 -110111110001 -000000000110 -001000001010 -000000010001 -110111100000 -001000000000 -001000000110 -111000000110 -000110010001 -000110000000 -110000000000 -110110000000 -000001100000 -110101100000 -001000000110 -110111110101 -110111110001 -000000000110 -001000001010 -000000010001 -110111100000 -001000000000 -001000000110 -111000000110 -000110010001 +0001100000000 +1100000000000 +1101100000000 +0000011000000 +1101011000000 +0010000001100 +1101111101010 +1101111100010 +0000000001100 +0010000010100 +0000000100010 +1101111000000 +0010000000000 +0010000001100 +1110000001100 +0001100100010 +0001100000000 +1100000000000 +1101100000000 +0000011000000 +1101011000000 +0010000001100 +1101111101010 +1101111100010 +0000000001100 +0010000010100 +0000000100010 +1101111000000 +0010000000000 +0010000001100 +1110000001100 +0001100100010 OUT