diff --git a/docs/embed.pod b/docs/embed.pod index 84df8c4..14f001c 100644 --- a/docs/embed.pod +++ b/docs/embed.pod @@ -1379,8 +1379,6 @@ The list may also be augmented if additional functionality is required. =item C -=item C - =item C =item C diff --git a/docs/pdds/pdd17_pmc.pod b/docs/pdds/pdd17_pmc.pod index 1f1431c..3e2f5a4 100644 --- a/docs/pdds/pdd17_pmc.pod +++ b/docs/pdds/pdd17_pmc.pod @@ -1356,8 +1356,7 @@ modifying the value of I. =item substr - void substr(INTERP, PMC *self, INTVAL offset, INTVAL length, PMC *dest) - STRING* substr_str(INTERP, PMC *self, INTVAL offset, INTVAL length) + STRING* substr(INTERP, PMC *self, INTVAL offset, INTVAL length) Extracts the string starting at I with size I and return it as a PMC in I or as a string return value. diff --git a/docs/pdds/pdd28_strings.pod b/docs/pdds/pdd28_strings.pod index b7ec5c2..6eb16b2 100644 --- a/docs/pdds/pdd28_strings.pod +++ b/docs/pdds/pdd28_strings.pod @@ -702,11 +702,6 @@ strings, and -1 if the passed in string argument is shorter. =item substr Extract a substring of a given length starting from a given offset (in -graphemes) and store the result in the string argument. - -=item substr_str - -Extract a substring of a given length starting from a given offset (in graphemes) and return the string. =item exists_keyed diff --git a/src/ops/core_ops.c b/src/ops/core_ops.c index 53512e1..fcd4c35 100644 --- a/src/ops/core_ops.c +++ b/src/ops/core_ops.c @@ -20397,28 +20397,28 @@ Parrot_substr_s_sc_ic_ic(opcode_t *cur_opcode, PARROT_INTERP) { opcode_t * Parrot_substr_s_p_i_i(opcode_t *cur_opcode, PARROT_INTERP) { - SREG(1) = VTABLE_substr_str(interp, PREG(2), IREG(3), IREG(4)); + SREG(1) = VTABLE_substr(interp, PREG(2), IREG(3), IREG(4)); PARROT_GC_WRITE_BARRIER(interp, CURRENT_CONTEXT(interp)); return (opcode_t *)cur_opcode + 5; } opcode_t * Parrot_substr_s_p_ic_i(opcode_t *cur_opcode, PARROT_INTERP) { - SREG(1) = VTABLE_substr_str(interp, PREG(2), ICONST(3), IREG(4)); + SREG(1) = VTABLE_substr(interp, PREG(2), ICONST(3), IREG(4)); PARROT_GC_WRITE_BARRIER(interp, CURRENT_CONTEXT(interp)); return (opcode_t *)cur_opcode + 5; } opcode_t * Parrot_substr_s_p_i_ic(opcode_t *cur_opcode, PARROT_INTERP) { - SREG(1) = VTABLE_substr_str(interp, PREG(2), IREG(3), ICONST(4)); + SREG(1) = VTABLE_substr(interp, PREG(2), IREG(3), ICONST(4)); PARROT_GC_WRITE_BARRIER(interp, CURRENT_CONTEXT(interp)); return (opcode_t *)cur_opcode + 5; } opcode_t * Parrot_substr_s_p_ic_ic(opcode_t *cur_opcode, PARROT_INTERP) { - SREG(1) = VTABLE_substr_str(interp, PREG(2), ICONST(3), ICONST(4)); + SREG(1) = VTABLE_substr(interp, PREG(2), ICONST(3), ICONST(4)); PARROT_GC_WRITE_BARRIER(interp, CURRENT_CONTEXT(interp)); return (opcode_t *)cur_opcode + 5; } diff --git a/src/ops/string.ops b/src/ops/string.ops index d3ce85f..4e6ce44 100644 --- a/src/ops/string.ops +++ b/src/ops/string.ops @@ -261,7 +261,7 @@ inline op substr(out STR, in STR, in INT, in INT) :base_core { } inline op substr(out STR, invar PMC, in INT, in INT) :base_core { - $1 = VTABLE_substr_str(interp, $2, $3, $4); + $1 = VTABLE_substr(interp, $2, $3, $4); } inline op replace(out STR, in STR, in INT, in INT, in STR) :base_core { diff --git a/src/pmc/scalar.pmc b/src/pmc/scalar.pmc index 79bf4d3..8c35b9b 100644 --- a/src/pmc/scalar.pmc +++ b/src/pmc/scalar.pmc @@ -819,7 +819,7 @@ Always returns true. /* -=item C +=item C Returns the substring of length C of the scalar starting at C. @@ -828,7 +828,7 @@ C. */ - VTABLE STRING *substr_str(INTVAL offset, INTVAL length) { + VTABLE STRING *substr(INTVAL offset, INTVAL length) { return STRING_substr(INTERP, VTABLE_get_string(INTERP, SELF), offset, length); } diff --git a/src/pmc/string.pmc b/src/pmc/string.pmc index 289d0f4..7967e50 100644 --- a/src/pmc/string.pmc +++ b/src/pmc/string.pmc @@ -345,24 +345,7 @@ is smaller. /* -=item C - -Extracts the substring starting at C, with size -C, and places it in C. - -=cut - -*/ - VTABLE void substr(INTVAL offset, INTVAL length, PMC *dest) { - STRING *str_val, *s2; - GET_ATTR_str_val(INTERP, SELF, str_val); - s2 = STRING_substr(INTERP, str_val, offset, length); - VTABLE_set_string_native(INTERP, dest, s2); - } - -/* - -=item C +=item C Extracts the substring starting at C, with size C, and returns it. @@ -370,7 +353,7 @@ C, and returns it. =cut */ - VTABLE STRING *substr_str(INTVAL offset, INTVAL length) { + VTABLE STRING *substr(INTVAL offset, INTVAL length) { STRING *str_val; GET_ATTR_str_val(INTERP, SELF, str_val); return STRING_substr(INTERP, str_val, offset, length); diff --git a/src/pmc/stringbuilder.pmc b/src/pmc/stringbuilder.pmc index 8310749..24f864c 100644 --- a/src/pmc/stringbuilder.pmc +++ b/src/pmc/stringbuilder.pmc @@ -309,13 +309,13 @@ For testing purpose only? /* -=item C +=item C =cut */ - VTABLE STRING *substr_str(INTVAL offset, INTVAL length) { + VTABLE STRING *substr(INTVAL offset, INTVAL length) { STRING *buffer; GET_ATTR_buffer(INTERP, SELF, buffer); /* We must clone here becase we can reallocate buffer behind the scene... */ diff --git a/src/vtable.tbl b/src/vtable.tbl index 6691e70..52b6289 100644 --- a/src/vtable.tbl +++ b/src/vtable.tbl @@ -206,8 +206,7 @@ PMC* repeat_int(INTVAL value, PMC* dest) void i_repeat(PMC* value) :write void i_repeat_int(INTVAL value) :write -void substr(INTVAL offset, INTVAL length, PMC* dest) -STRING* substr_str(INTVAL offset, INTVAL length) +STRING* substr(INTVAL offset, INTVAL length) [EXISTS] INTVAL exists_keyed(PMC* key) diff --git a/t/src/extend_vtable.t b/t/src/extend_vtable.t index ad70267..c5dc563 100644 --- a/t/src/extend_vtable.t +++ b/t/src/extend_vtable.t @@ -10,7 +10,7 @@ use File::Spec::Functions; plan skip_all => 'src/parrot_config.o does not exist' unless -e catfile(qw/src parrot_config.o/); -plan tests => 139; +plan tests => 138; =head1 NAME @@ -458,19 +458,7 @@ extend_vtable_output_is(<<'CODE', <<'OUTPUT', "Parrot_PMC_substr" ); Parrot_PMC_assign_string_native(interp, pmc_string, string); - Parrot_PMC_substr(interp, pmc_string, 0, 2, pmc_string2); - Parrot_printf(interp, "%P\n", pmc_string2); -CODE -FO -Done! -OUTPUT - -extend_vtable_output_is(<<'CODE', <<'OUTPUT', "Parrot_PMC_substr_str" ); - string = createstring(interp, "FOO"); - - Parrot_PMC_assign_string_native(interp, pmc_string, string); - - string2 = Parrot_PMC_substr_str(interp, pmc_string, 0, 1); + string2 = Parrot_PMC_substr(interp, pmc_string, 0, 1); Parrot_printf(interp, "%S\n", string2); CODE F diff --git a/tools/dev/vtablize.pl b/tools/dev/vtablize.pl index c9da536..b4ea8e1 100755 --- a/tools/dev/vtablize.pl +++ b/tools/dev/vtablize.pl @@ -182,8 +182,7 @@ s/^(\s*)(PMC\s+\*repeat\(PMC\s+\*\w*,\s+PMC\s+\*\w*\)\s+{)/$1VTABLE $2/; s/^(\s*)(PMC\s+\*repeat_int\(INTVAL\s+\w*,\s+PMC\s+\*\w*\)\s+{)/$1VTABLE $2/; s/^(\s*)(void\s+i_repeat\(PMC\s+\*\w*\)\s+{)/$1VTABLE $2/; s/^(\s*)(void\s+i_repeat_int\(INTVAL\s+\w*\)\s+{)/$1VTABLE $2/; -s/^(\s*)(void\s+substr\(INTVAL\s+\w*,\s+INTVAL\s+\w*,\s+PMC\s+\*\w*\)\s+{)/$1VTABLE $2/; -s/^(\s*)(STRING\s+\*substr_str\(INTVAL\s+\w*,\s+INTVAL\s+\w*\)\s+{)/$1VTABLE $2/; +s/^(\s*)(STRING\s+\*substr\(INTVAL\s+\w*,\s+INTVAL\s+\w*\)\s+{)/$1VTABLE $2/; s/^(\s*)(INTVAL\s+exists_keyed\(PMC\s+\*\w*\)\s+{)/$1VTABLE $2/; s/^(\s*)(INTVAL\s+exists_keyed_int\(INTVAL\s+\w*\)\s+{)/$1VTABLE $2/; s/^(\s*)(INTVAL\s+exists_keyed_str\(STRING\s+\*\w*\)\s+{)/$1VTABLE $2/;