Skip to content

Commit ec7c8fc

Browse files
committed
STRING_ord takes chars, not bytes. local var thinko.
1 parent 4cc669c commit ec7c8fc

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

src/vm/parrot/ops/nqp.ops

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3739,19 +3739,18 @@ inline op nqp_string_equal_at(out INT, in STR, in STR, in INT) {
37393739
String_iter hay_iter;
37403740
String_iter needle_iter;
37413741

3742-
if (0 && ($3)->strlen == 1) {
3743-
STRING_ITER_INIT(interp, &hay_iter);
3744-
STRING_iter_skip(interp, $2, &hay_iter, offset);
3745-
$1 = (STRING_ord(interp, $3, 0) == STRING_ord(interp, $2, hay_iter.bytepos));
3746-
} else {
3747-
offset = (INTVAL)($4);
3742+
offset = (INTVAL)($4);
37483743

3744+
if (offset < 0) {
3745+
offset += ($2)->strlen;
37493746
if (offset < 0) {
3750-
offset += ($2)->strlen;
3751-
if (offset < 0) {
3752-
offset = 0;
3753-
}
3747+
offset = 0;
37543748
}
3749+
}
3750+
3751+
if (($3)->strlen == 1) {
3752+
$1 = (STRING_ord(interp, $3, 0) == STRING_ord(interp, $2, offset));
3753+
} else {
37553754

37563755
if (($2)->encoding == ($3)->encoding) {
37573756
STRING_ITER_INIT(interp, &hay_iter);

0 commit comments

Comments
 (0)