Commit d13db698

d13db6984168Merged

Yukihiro "Matz" Matsumoto <[email protected]> · 5 months ago · 1 file · ~1 modified

Description

String#rindex with a position argument

rindex(sub, pos) dispatches to sp_str_rindex_from (limits the search to codepoint index <= pos, negative pos counts from the end), returning the nil sentinel on a miss.

Co-Authored-By: Claude Opus 4.8 [email protected]

Details

Commit
d13db6984168
Parent
0a603d5e7987

src/codegen.cmodifiedView file

@@ -2956,6 +2956,7 @@
29562956 tr, re_lit_index(c, argv[0]), r, tr, tr, tr, tr, r, tr, tr, tr);
29572957 }
29582958 else if (!strcmp(name, "rindex") && argc == 1) { buf_printf(b, "sp_str_rindex(%s, ", r); emit_expr(c, argv[0], b); buf_puts(b, ")"); }
2959+ else if (!strcmp(name, "rindex") && argc == 2) { buf_printf(b, "sp_str_rindex_from(%s, ", r); emit_expr(c, argv[0], b); buf_puts(b, ", "); emit_expr(c, argv[1], b); buf_puts(b, ")"); }
29592960 else if (!strcmp(name, "crypt") && argc == 1) { buf_printf(b, "sp_str_crypt(%s, ", r); emit_expr(c, argv[0], b); buf_puts(b, ")"); }
29602961 else if (!strcmp(name, "scrub") && argc == 0) buf_printf(b, "sp_str_scrub(%s, 0)", r);
29612962 else if (!strcmp(name, "scrub") && argc == 1) { buf_printf(b, "sp_str_scrub(%s, ", r); emit_expr(c, argv[0], b); buf_puts(b, ")"); }