[svn:parrot] r48532 - in branches/substr_eq_at/src: ops string

chromatic at svn.parrot.org chromatic at svn.parrot.org
Mon Aug 16 19:14:06 UTC 2010


Author: chromatic
Date: Mon Aug 16 19:14:05 2010
New Revision: 48532
URL: https://trac.parrot.org/parrot/changeset/48532

Log:
[str] Fixed cmp_str_at opcode.

Parrot_str_compare_opcode() still needs work for STRINGs with differing
encodings as well as unsanitized length parameters, but all of Patrick's tests
pass now.

Modified:
   branches/substr_eq_at/src/ops/core_ops.c
   branches/substr_eq_at/src/string/api.c

Modified: branches/substr_eq_at/src/ops/core_ops.c
==============================================================================
--- branches/substr_eq_at/src/ops/core_ops.c	Mon Aug 16 18:55:16 2010	(r48531)
+++ branches/substr_eq_at/src/ops/core_ops.c	Mon Aug 16 19:14:05 2010	(r48532)
@@ -26375,56 +26375,56 @@
 opcode_t *
 Parrot_cmp_str_at_i_s_s_i_ic(opcode_t *cur_opcode, PARROT_INTERP)  {
     const Parrot_Context * const CUR_CTX = Parrot_pcc_get_context_struct(interp, interp->ctx);
-    IREG(1) = Parrot_str_compare_offset(interp, SREG(2), SREG(3), IREG(4), IREG(5));
+    IREG(1) = Parrot_str_compare_offset(interp, SREG(2), SREG(3), IREG(4), cur_opcode[5]);
 
 return (opcode_t *)cur_opcode + 6;}
 
 opcode_t *
 Parrot_cmp_str_at_i_sc_s_i_ic(opcode_t *cur_opcode, PARROT_INTERP)  {
     const Parrot_Context * const CUR_CTX = Parrot_pcc_get_context_struct(interp, interp->ctx);
-    IREG(1) = Parrot_str_compare_offset(interp, CONST(2).u.string, SREG(3), IREG(4), IREG(5));
+    IREG(1) = Parrot_str_compare_offset(interp, CONST(2).u.string, SREG(3), IREG(4), cur_opcode[5]);
 
 return (opcode_t *)cur_opcode + 6;}
 
 opcode_t *
 Parrot_cmp_str_at_i_s_sc_i_ic(opcode_t *cur_opcode, PARROT_INTERP)  {
     const Parrot_Context * const CUR_CTX = Parrot_pcc_get_context_struct(interp, interp->ctx);
-    IREG(1) = Parrot_str_compare_offset(interp, SREG(2), CONST(3).u.string, IREG(4), IREG(5));
+    IREG(1) = Parrot_str_compare_offset(interp, SREG(2), CONST(3).u.string, IREG(4), cur_opcode[5]);
 
 return (opcode_t *)cur_opcode + 6;}
 
 opcode_t *
 Parrot_cmp_str_at_i_sc_sc_i_ic(opcode_t *cur_opcode, PARROT_INTERP)  {
     const Parrot_Context * const CUR_CTX = Parrot_pcc_get_context_struct(interp, interp->ctx);
-    IREG(1) = Parrot_str_compare_offset(interp, CONST(2).u.string, CONST(3).u.string, IREG(4), IREG(5));
+    IREG(1) = Parrot_str_compare_offset(interp, CONST(2).u.string, CONST(3).u.string, IREG(4), cur_opcode[5]);
 
 return (opcode_t *)cur_opcode + 6;}
 
 opcode_t *
 Parrot_cmp_str_at_i_s_s_ic_ic(opcode_t *cur_opcode, PARROT_INTERP)  {
     const Parrot_Context * const CUR_CTX = Parrot_pcc_get_context_struct(interp, interp->ctx);
-    IREG(1) = Parrot_str_compare_offset(interp, SREG(2), SREG(3), cur_opcode[4], IREG(5));
+    IREG(1) = Parrot_str_compare_offset(interp, SREG(2), SREG(3), cur_opcode[4], cur_opcode[5]);
 
 return (opcode_t *)cur_opcode + 6;}
 
 opcode_t *
 Parrot_cmp_str_at_i_sc_s_ic_ic(opcode_t *cur_opcode, PARROT_INTERP)  {
     const Parrot_Context * const CUR_CTX = Parrot_pcc_get_context_struct(interp, interp->ctx);
-    IREG(1) = Parrot_str_compare_offset(interp, CONST(2).u.string, SREG(3), cur_opcode[4], IREG(5));
+    IREG(1) = Parrot_str_compare_offset(interp, CONST(2).u.string, SREG(3), cur_opcode[4], cur_opcode[5]);
 
 return (opcode_t *)cur_opcode + 6;}
 
 opcode_t *
 Parrot_cmp_str_at_i_s_sc_ic_ic(opcode_t *cur_opcode, PARROT_INTERP)  {
     const Parrot_Context * const CUR_CTX = Parrot_pcc_get_context_struct(interp, interp->ctx);
-    IREG(1) = Parrot_str_compare_offset(interp, SREG(2), CONST(3).u.string, cur_opcode[4], IREG(5));
+    IREG(1) = Parrot_str_compare_offset(interp, SREG(2), CONST(3).u.string, cur_opcode[4], cur_opcode[5]);
 
 return (opcode_t *)cur_opcode + 6;}
 
 opcode_t *
 Parrot_cmp_str_at_i_sc_sc_ic_ic(opcode_t *cur_opcode, PARROT_INTERP)  {
     const Parrot_Context * const CUR_CTX = Parrot_pcc_get_context_struct(interp, interp->ctx);
-    IREG(1) = Parrot_str_compare_offset(interp, CONST(2).u.string, CONST(3).u.string, cur_opcode[4], IREG(5));
+    IREG(1) = Parrot_str_compare_offset(interp, CONST(2).u.string, CONST(3).u.string, cur_opcode[4], cur_opcode[5]);
 
 return (opcode_t *)cur_opcode + 6;}
 

Modified: branches/substr_eq_at/src/string/api.c
==============================================================================
--- branches/substr_eq_at/src/string/api.c	Mon Aug 16 18:55:16 2010	(r48531)
+++ branches/substr_eq_at/src/string/api.c	Mon Aug 16 19:14:05 2010	(r48532)
@@ -1350,6 +1350,9 @@
 {
     ASSERT_ARGS(Parrot_str_compare_offset)
 
+    if (a->encoding == b->encoding)
+        return memcmp(a->strstart + offset, b->strstart, length);
+
     /* do these make sense? */
     if (STRING_IS_NULL(b))
         return a && (a->strlen != 0);
@@ -1360,7 +1363,7 @@
     ASSERT_STRING_SANITY(a);
     ASSERT_STRING_SANITY(b);
 
-    /* XXX: sanitize offset */
+    /* XXX: sanitize offset, make length work */
     return CHARSET_COMPARE_OFFSET(interp, a, b, offset);
 }
 


More information about the parrot-commits mailing list