[svn:parrot] r49225 - in branches/string_macros: compilers/pirc/src src src/ops src/pmc src/string src/string/encoding
nwellnhof at svn.parrot.org
nwellnhof at svn.parrot.org
Wed Sep 22 01:20:34 UTC 2010
Author: nwellnhof
Date: Wed Sep 22 01:20:33 2010
New Revision: 49225
URL: https://trac.parrot.org/parrot/changeset/49225
Log:
[str] Switch to STRING_compare macro
Move the whole 'compare' logic into the string vtable functions
Modified:
branches/string_macros/compilers/pirc/src/bcgen.c
branches/string_macros/src/debug.c
branches/string_macros/src/ops/cmp.ops
branches/string_macros/src/ops/core_ops.c
branches/string_macros/src/pmc/scalar.pmc
branches/string_macros/src/pmc/string.pmc
branches/string_macros/src/string/api.c
branches/string_macros/src/string/encoding/shared.c
Modified: branches/string_macros/compilers/pirc/src/bcgen.c
==============================================================================
--- branches/string_macros/compilers/pirc/src/bcgen.c Wed Sep 22 01:19:59 2010 (r49224)
+++ branches/string_macros/compilers/pirc/src/bcgen.c Wed Sep 22 01:20:33 2010 (r49225)
@@ -1079,7 +1079,7 @@
cur_name = sub->name;
out_name = Parrot_str_new(interp, outername, len);
- if (Parrot_str_compare(interp, cur_name, out_name) == 0)
+ if (STRING_equal(interp, cur_name, out_name))
return current;
return NULL;
Modified: branches/string_macros/src/debug.c
==============================================================================
--- branches/string_macros/src/debug.c Wed Sep 22 01:19:59 2010 (r49224)
+++ branches/string_macros/src/debug.c Wed Sep 22 01:20:33 2010 (r49225)
@@ -1993,17 +1993,17 @@
n = REG_STR(interp, *(int *)condition->value);
if (((condition->type & PDB_cond_gt) &&
- (Parrot_str_compare(interp, m, n) > 0)) ||
+ (STRING_compare(interp, m, n) > 0)) ||
((condition->type & PDB_cond_ge) &&
- (Parrot_str_compare(interp, m, n) >= 0)) ||
+ (STRING_compare(interp, m, n) >= 0)) ||
((condition->type & PDB_cond_eq) &&
- (Parrot_str_compare(interp, m, n) == 0)) ||
+ (STRING_compare(interp, m, n) == 0)) ||
((condition->type & PDB_cond_ne) &&
- (Parrot_str_compare(interp, m, n) != 0)) ||
+ (STRING_compare(interp, m, n) != 0)) ||
((condition->type & PDB_cond_le) &&
- (Parrot_str_compare(interp, m, n) <= 0)) ||
+ (STRING_compare(interp, m, n) <= 0)) ||
((condition->type & PDB_cond_lt) &&
- (Parrot_str_compare(interp, m, n) < 0)))
+ (STRING_compare(interp, m, n) < 0)))
return 1;
return 0;
Modified: branches/string_macros/src/ops/cmp.ops
==============================================================================
--- branches/string_macros/src/ops/cmp.ops Wed Sep 22 01:19:59 2010 (r49224)
+++ branches/string_macros/src/ops/cmp.ops Wed Sep 22 01:20:33 2010 (r49225)
@@ -280,7 +280,7 @@
}
op lt(in STR, in STR, inconst LABEL) :base_core {
- if (Parrot_str_compare(interp, $1, $2) < 0) {
+ if (STRING_compare(interp, $1, $2) < 0) {
goto OFFSET($3);
}
}
@@ -310,7 +310,7 @@
}
op lt(invar PMC, in STR, inconst LABEL) :base_core {
- if (Parrot_str_compare(interp, VTABLE_get_string(interp, $1), $2) < 0) {
+ if (STRING_compare(interp, VTABLE_get_string(interp, $1), $2) < 0) {
goto OFFSET($3);
}
}
@@ -364,7 +364,7 @@
}
op le(in STR, in STR, inconst LABEL) :base_core {
- if (Parrot_str_compare(interp, $1, $2) <= 0) {
+ if (STRING_compare(interp, $1, $2) <= 0) {
goto OFFSET($3);
}
}
@@ -394,7 +394,7 @@
}
op le(invar PMC, in STR, inconst LABEL) :base_core {
- if (Parrot_str_compare(interp, VTABLE_get_string(interp, $1), $2) <= 0) {
+ if (STRING_compare(interp, VTABLE_get_string(interp, $1), $2) <= 0) {
goto OFFSET($3);
}
}
@@ -454,7 +454,7 @@
}
op gt(invar PMC, in STR, inconst LABEL) :base_core {
- if (Parrot_str_compare(interp, VTABLE_get_string(interp, $1), $2) > 0) {
+ if (STRING_compare(interp, VTABLE_get_string(interp, $1), $2) > 0) {
goto OFFSET($3);
}
}
@@ -514,7 +514,7 @@
}
op ge(invar PMC, in STR, inconst LABEL) :base_core {
- if (Parrot_str_compare(interp, VTABLE_get_string(interp, $1), $2) >= 0) {
+ if (STRING_compare(interp, VTABLE_get_string(interp, $1), $2) >= 0) {
goto OFFSET($3);
}
}
@@ -627,7 +627,7 @@
}
inline op cmp(out INT, in STR, in STR) :base_core {
- $1 = Parrot_str_compare(interp, $2, $3);
+ $1 = STRING_compare(interp, $2, $3);
}
inline op cmp(out INT, invar PMC, invar PMC) :base_core {
@@ -650,7 +650,7 @@
inline op cmp(out INT, invar PMC, in STR) :base_core {
STRING* const l = VTABLE_get_string(interp, $2);
- $1 = Parrot_str_compare(interp, l, $3);
+ $1 = STRING_compare(interp, l, $3);
}
inline op cmp_str(out INT, invar PMC, invar PMC) :base_core {
@@ -801,7 +801,7 @@
}
inline op isle(out INT, in STR, in STR) {
- $1 = Parrot_str_compare(interp, $2, $3) <= 0;
+ $1 = STRING_compare(interp, $2, $3) <= 0;
}
inline op isle(out INT, invar PMC, invar PMC) {
@@ -829,7 +829,7 @@
}
inline op islt(out INT, in STR, in STR) {
- $1 = Parrot_str_compare(interp, $2, $3) < 0;
+ $1 = STRING_compare(interp, $2, $3) < 0;
}
inline op islt(out INT, invar PMC, invar PMC) {
Modified: branches/string_macros/src/ops/core_ops.c
==============================================================================
--- branches/string_macros/src/ops/core_ops.c Wed Sep 22 01:19:59 2010 (r49224)
+++ branches/string_macros/src/ops/core_ops.c Wed Sep 22 01:20:33 2010 (r49225)
@@ -17149,7 +17149,7 @@
opcode_t *
Parrot_lt_s_s_ic(opcode_t *cur_opcode, PARROT_INTERP) {
const Parrot_Context * const CUR_CTX = Parrot_pcc_get_context_struct(interp, interp->ctx);
- if (Parrot_str_compare(interp, SREG(1), SREG(2)) < 0) {return (opcode_t *)cur_opcode + cur_opcode[3];
+ if (STRING_compare(interp, SREG(1), SREG(2)) < 0) {return (opcode_t *)cur_opcode + cur_opcode[3];
}
return (opcode_t *)cur_opcode + 4;}
@@ -17157,7 +17157,7 @@
opcode_t *
Parrot_lt_sc_s_ic(opcode_t *cur_opcode, PARROT_INTERP) {
const Parrot_Context * const CUR_CTX = Parrot_pcc_get_context_struct(interp, interp->ctx);
- if (Parrot_str_compare(interp, CONST(1).u.string, SREG(2)) < 0) {return (opcode_t *)cur_opcode + cur_opcode[3];
+ if (STRING_compare(interp, CONST(1).u.string, SREG(2)) < 0) {return (opcode_t *)cur_opcode + cur_opcode[3];
}
return (opcode_t *)cur_opcode + 4;}
@@ -17165,7 +17165,7 @@
opcode_t *
Parrot_lt_s_sc_ic(opcode_t *cur_opcode, PARROT_INTERP) {
const Parrot_Context * const CUR_CTX = Parrot_pcc_get_context_struct(interp, interp->ctx);
- if (Parrot_str_compare(interp, SREG(1), CONST(2).u.string) < 0) {return (opcode_t *)cur_opcode + cur_opcode[3];
+ if (STRING_compare(interp, SREG(1), CONST(2).u.string) < 0) {return (opcode_t *)cur_opcode + cur_opcode[3];
}
return (opcode_t *)cur_opcode + 4;}
@@ -17225,7 +17225,7 @@
opcode_t *
Parrot_lt_p_s_ic(opcode_t *cur_opcode, PARROT_INTERP) {
const Parrot_Context * const CUR_CTX = Parrot_pcc_get_context_struct(interp, interp->ctx);
- if (Parrot_str_compare(interp, VTABLE_get_string(interp, PREG(1)), SREG(2)) < 0) {return (opcode_t *)cur_opcode + cur_opcode[3];
+ if (STRING_compare(interp, VTABLE_get_string(interp, PREG(1)), SREG(2)) < 0) {return (opcode_t *)cur_opcode + cur_opcode[3];
}
return (opcode_t *)cur_opcode + 4;}
@@ -17233,7 +17233,7 @@
opcode_t *
Parrot_lt_p_sc_ic(opcode_t *cur_opcode, PARROT_INTERP) {
const Parrot_Context * const CUR_CTX = Parrot_pcc_get_context_struct(interp, interp->ctx);
- if (Parrot_str_compare(interp, VTABLE_get_string(interp, PREG(1)), CONST(2).u.string) < 0) {return (opcode_t *)cur_opcode + cur_opcode[3];
+ if (STRING_compare(interp, VTABLE_get_string(interp, PREG(1)), CONST(2).u.string) < 0) {return (opcode_t *)cur_opcode + cur_opcode[3];
}
return (opcode_t *)cur_opcode + 4;}
@@ -17305,7 +17305,7 @@
opcode_t *
Parrot_le_s_s_ic(opcode_t *cur_opcode, PARROT_INTERP) {
const Parrot_Context * const CUR_CTX = Parrot_pcc_get_context_struct(interp, interp->ctx);
- if (Parrot_str_compare(interp, SREG(1), SREG(2)) <= 0) {return (opcode_t *)cur_opcode + cur_opcode[3];
+ if (STRING_compare(interp, SREG(1), SREG(2)) <= 0) {return (opcode_t *)cur_opcode + cur_opcode[3];
}
return (opcode_t *)cur_opcode + 4;}
@@ -17313,7 +17313,7 @@
opcode_t *
Parrot_le_sc_s_ic(opcode_t *cur_opcode, PARROT_INTERP) {
const Parrot_Context * const CUR_CTX = Parrot_pcc_get_context_struct(interp, interp->ctx);
- if (Parrot_str_compare(interp, CONST(1).u.string, SREG(2)) <= 0) {return (opcode_t *)cur_opcode + cur_opcode[3];
+ if (STRING_compare(interp, CONST(1).u.string, SREG(2)) <= 0) {return (opcode_t *)cur_opcode + cur_opcode[3];
}
return (opcode_t *)cur_opcode + 4;}
@@ -17321,7 +17321,7 @@
opcode_t *
Parrot_le_s_sc_ic(opcode_t *cur_opcode, PARROT_INTERP) {
const Parrot_Context * const CUR_CTX = Parrot_pcc_get_context_struct(interp, interp->ctx);
- if (Parrot_str_compare(interp, SREG(1), CONST(2).u.string) <= 0) {return (opcode_t *)cur_opcode + cur_opcode[3];
+ if (STRING_compare(interp, SREG(1), CONST(2).u.string) <= 0) {return (opcode_t *)cur_opcode + cur_opcode[3];
}
return (opcode_t *)cur_opcode + 4;}
@@ -17381,7 +17381,7 @@
opcode_t *
Parrot_le_p_s_ic(opcode_t *cur_opcode, PARROT_INTERP) {
const Parrot_Context * const CUR_CTX = Parrot_pcc_get_context_struct(interp, interp->ctx);
- if (Parrot_str_compare(interp, VTABLE_get_string(interp, PREG(1)), SREG(2)) <= 0) {return (opcode_t *)cur_opcode + cur_opcode[3];
+ if (STRING_compare(interp, VTABLE_get_string(interp, PREG(1)), SREG(2)) <= 0) {return (opcode_t *)cur_opcode + cur_opcode[3];
}
return (opcode_t *)cur_opcode + 4;}
@@ -17389,7 +17389,7 @@
opcode_t *
Parrot_le_p_sc_ic(opcode_t *cur_opcode, PARROT_INTERP) {
const Parrot_Context * const CUR_CTX = Parrot_pcc_get_context_struct(interp, interp->ctx);
- if (Parrot_str_compare(interp, VTABLE_get_string(interp, PREG(1)), CONST(2).u.string) <= 0) {return (opcode_t *)cur_opcode + cur_opcode[3];
+ if (STRING_compare(interp, VTABLE_get_string(interp, PREG(1)), CONST(2).u.string) <= 0) {return (opcode_t *)cur_opcode + cur_opcode[3];
}
return (opcode_t *)cur_opcode + 4;}
@@ -17465,7 +17465,7 @@
opcode_t *
Parrot_gt_p_s_ic(opcode_t *cur_opcode, PARROT_INTERP) {
const Parrot_Context * const CUR_CTX = Parrot_pcc_get_context_struct(interp, interp->ctx);
- if (Parrot_str_compare(interp, VTABLE_get_string(interp, PREG(1)), SREG(2)) > 0) {return (opcode_t *)cur_opcode + cur_opcode[3];
+ if (STRING_compare(interp, VTABLE_get_string(interp, PREG(1)), SREG(2)) > 0) {return (opcode_t *)cur_opcode + cur_opcode[3];
}
return (opcode_t *)cur_opcode + 4;}
@@ -17473,7 +17473,7 @@
opcode_t *
Parrot_gt_p_sc_ic(opcode_t *cur_opcode, PARROT_INTERP) {
const Parrot_Context * const CUR_CTX = Parrot_pcc_get_context_struct(interp, interp->ctx);
- if (Parrot_str_compare(interp, VTABLE_get_string(interp, PREG(1)), CONST(2).u.string) > 0) {return (opcode_t *)cur_opcode + cur_opcode[3];
+ if (STRING_compare(interp, VTABLE_get_string(interp, PREG(1)), CONST(2).u.string) > 0) {return (opcode_t *)cur_opcode + cur_opcode[3];
}
return (opcode_t *)cur_opcode + 4;}
@@ -17549,7 +17549,7 @@
opcode_t *
Parrot_ge_p_s_ic(opcode_t *cur_opcode, PARROT_INTERP) {
const Parrot_Context * const CUR_CTX = Parrot_pcc_get_context_struct(interp, interp->ctx);
- if (Parrot_str_compare(interp, VTABLE_get_string(interp, PREG(1)), SREG(2)) >= 0) {return (opcode_t *)cur_opcode + cur_opcode[3];
+ if (STRING_compare(interp, VTABLE_get_string(interp, PREG(1)), SREG(2)) >= 0) {return (opcode_t *)cur_opcode + cur_opcode[3];
}
return (opcode_t *)cur_opcode + 4;}
@@ -17557,7 +17557,7 @@
opcode_t *
Parrot_ge_p_sc_ic(opcode_t *cur_opcode, PARROT_INTERP) {
const Parrot_Context * const CUR_CTX = Parrot_pcc_get_context_struct(interp, interp->ctx);
- if (Parrot_str_compare(interp, VTABLE_get_string(interp, PREG(1)), CONST(2).u.string) >= 0) {return (opcode_t *)cur_opcode + cur_opcode[3];
+ if (STRING_compare(interp, VTABLE_get_string(interp, PREG(1)), CONST(2).u.string) >= 0) {return (opcode_t *)cur_opcode + cur_opcode[3];
}
return (opcode_t *)cur_opcode + 4;}
@@ -17667,21 +17667,21 @@
opcode_t *
Parrot_cmp_i_s_s(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(interp, SREG(2), SREG(3));
+ IREG(1) = STRING_compare(interp, SREG(2), SREG(3));
return (opcode_t *)cur_opcode + 4;}
opcode_t *
Parrot_cmp_i_sc_s(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(interp, CONST(2).u.string, SREG(3));
+ IREG(1) = STRING_compare(interp, CONST(2).u.string, SREG(3));
return (opcode_t *)cur_opcode + 4;}
opcode_t *
Parrot_cmp_i_s_sc(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(interp, SREG(2), CONST(3).u.string);
+ IREG(1) = STRING_compare(interp, SREG(2), CONST(3).u.string);
return (opcode_t *)cur_opcode + 4;}
@@ -17736,7 +17736,7 @@
Parrot_cmp_i_p_s(opcode_t *cur_opcode, PARROT_INTERP) {
const Parrot_Context * const CUR_CTX = Parrot_pcc_get_context_struct(interp, interp->ctx);
STRING* const l = VTABLE_get_string(interp, PREG(2));
- IREG(1) = Parrot_str_compare(interp, l, SREG(3));
+ IREG(1) = STRING_compare(interp, l, SREG(3));
return (opcode_t *)cur_opcode + 4;}
@@ -17744,7 +17744,7 @@
Parrot_cmp_i_p_sc(opcode_t *cur_opcode, PARROT_INTERP) {
const Parrot_Context * const CUR_CTX = Parrot_pcc_get_context_struct(interp, interp->ctx);
STRING* const l = VTABLE_get_string(interp, PREG(2));
- IREG(1) = Parrot_str_compare(interp, l, CONST(3).u.string);
+ IREG(1) = STRING_compare(interp, l, CONST(3).u.string);
return (opcode_t *)cur_opcode + 4;}
@@ -17946,21 +17946,21 @@
opcode_t *
Parrot_isle_i_s_s(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(interp, SREG(2), SREG(3)) <= 0;
+ IREG(1) = STRING_compare(interp, SREG(2), SREG(3)) <= 0;
return (opcode_t *)cur_opcode + 4;}
opcode_t *
Parrot_isle_i_sc_s(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(interp, CONST(2).u.string, SREG(3)) <= 0;
+ IREG(1) = STRING_compare(interp, CONST(2).u.string, SREG(3)) <= 0;
return (opcode_t *)cur_opcode + 4;}
opcode_t *
Parrot_isle_i_s_sc(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(interp, SREG(2), CONST(3).u.string) <= 0;
+ IREG(1) = STRING_compare(interp, SREG(2), CONST(3).u.string) <= 0;
return (opcode_t *)cur_opcode + 4;}
@@ -18016,21 +18016,21 @@
opcode_t *
Parrot_islt_i_s_s(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(interp, SREG(2), SREG(3)) < 0;
+ IREG(1) = STRING_compare(interp, SREG(2), SREG(3)) < 0;
return (opcode_t *)cur_opcode + 4;}
opcode_t *
Parrot_islt_i_sc_s(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(interp, CONST(2).u.string, SREG(3)) < 0;
+ IREG(1) = STRING_compare(interp, CONST(2).u.string, SREG(3)) < 0;
return (opcode_t *)cur_opcode + 4;}
opcode_t *
Parrot_islt_i_s_sc(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(interp, SREG(2), CONST(3).u.string) < 0;
+ IREG(1) = STRING_compare(interp, SREG(2), CONST(3).u.string) < 0;
return (opcode_t *)cur_opcode + 4;}
Modified: branches/string_macros/src/pmc/scalar.pmc
==============================================================================
--- branches/string_macros/src/pmc/scalar.pmc Wed Sep 22 01:19:59 2010 (r49224)
+++ branches/string_macros/src/pmc/scalar.pmc Wed Sep 22 01:20:33 2010 (r49225)
@@ -753,7 +753,7 @@
*/
MULTI INTVAL cmp_string(PMC *value) {
- return Parrot_str_compare(INTERP, SELF.get_string(),
+ return STRING_compare(INTERP, SELF.get_string(),
VTABLE_get_string(INTERP, value));
}
Modified: branches/string_macros/src/pmc/string.pmc
==============================================================================
--- branches/string_macros/src/pmc/string.pmc Wed Sep 22 01:19:59 2010 (r49224)
+++ branches/string_macros/src/pmc/string.pmc Wed Sep 22 01:20:33 2010 (r49225)
@@ -304,7 +304,7 @@
STRING *str_val;
STRING * const v = VTABLE_get_string(INTERP, value);
GET_ATTR_str_val(INTERP, SELF, str_val);
- return Parrot_str_compare(INTERP, str_val, v);
+ return STRING_compare(INTERP, str_val, v);
}
/*
@@ -349,7 +349,7 @@
STRING *str_val;
STRING * const v = VTABLE_get_string(INTERP, value);
GET_ATTR_str_val(INTERP, SELF, str_val);
- return Parrot_str_compare(INTERP, str_val, v);
+ return STRING_compare(INTERP, str_val, v);
}
/*
Modified: branches/string_macros/src/string/api.c
==============================================================================
--- branches/string_macros/src/string/api.c Wed Sep 22 01:19:59 2010 (r49224)
+++ branches/string_macros/src/string/api.c Wed Sep 22 01:20:33 2010 (r49225)
@@ -1251,7 +1251,9 @@
Compares two strings to each other. If s1 is less than s2, returns -1. If the
strings are equal, returns 0. If s1 is greater than s2, returns 2. This
comparison uses the character set collation order of the strings for
-comparison.
+comparison. The null string is considered equal to the empty string.
+
+Identical to the STRING_compare macro.
=cut
@@ -1263,17 +1265,10 @@
Parrot_str_compare(PARROT_INTERP, ARGIN_NULLOK(const STRING *s1), ARGIN_NULLOK(const STRING *s2))
{
ASSERT_ARGS(Parrot_str_compare)
- UINTVAL len1 = STRING_length(s1);
- UINTVAL len2 = STRING_length(s2);
-
- if (len2 == 0)
- return len1 != 0;
-
- if (len1 == 0)
- return -1;
- ASSERT_STRING_SANITY(s1);
- ASSERT_STRING_SANITY(s2);
+ if (s1 == NULL)
+ Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_UNEXPECTED_NULL,
+ "Invalid operation on null string");
return STRING_compare(interp, s1, s2);
}
Modified: branches/string_macros/src/string/encoding/shared.c
==============================================================================
--- branches/string_macros/src/string/encoding/shared.c Wed Sep 22 01:19:59 2010 (r49224)
+++ branches/string_macros/src/string/encoding/shared.c Wed Sep 22 01:20:33 2010 (r49225)
@@ -113,14 +113,18 @@
{
ASSERT_ARGS(encoding_compare)
String_iter l_iter, r_iter;
- UINTVAL min_len, l_len, r_len;
+ const UINTVAL l_len = STRING_length(lhs);
+ const UINTVAL r_len = STRING_length(rhs);
+ UINTVAL min_len;
+
+ if (r_len == 0)
+ return l_len != 0;
+ if (l_len == 0)
+ return -1;
STRING_ITER_INIT(interp, &l_iter);
STRING_ITER_INIT(interp, &r_iter);
- l_len = lhs->strlen;
- r_len = rhs->strlen;
-
min_len = l_len > r_len ? r_len : l_len;
while (l_iter.charpos < min_len) {
@@ -678,9 +682,16 @@
fixed8_compare(PARROT_INTERP, ARGIN(const STRING *lhs), ARGIN(const STRING *rhs))
{
ASSERT_ARGS(fixed8_compare)
- const UINTVAL l_len = lhs->strlen;
- const UINTVAL r_len = rhs->strlen;
- const UINTVAL min_len = l_len > r_len ? r_len : l_len;
+ const UINTVAL l_len = STRING_length(lhs);
+ const UINTVAL r_len = STRING_length(rhs);
+ UINTVAL min_len;
+
+ if (r_len == 0)
+ return l_len != 0;
+ if (l_len == 0)
+ return -1;
+
+ min_len = l_len > r_len ? r_len : l_len;
if (STRING_max_bytes_per_codepoint(rhs) == 1) {
const int ret_val = memcmp(lhs->strstart, rhs->strstart, min_len);
More information about the parrot-commits
mailing list