Finish deprecating stack refs with &
This commit is contained in:
parent
41c0ea851a
commit
052316261a
@ -344,7 +344,7 @@ env_t *new_compilation_unit(CORD libname)
|
||||
{"as_c_string", "Text$as_c_string", "func(text:Text -> CString)"},
|
||||
{"codepoint_names", "Text$codepoint_names", "func(text:Text -> [Text])"},
|
||||
{"ends_with", "Text$ends_with", "func(text,suffix:Text -> Bool)"},
|
||||
{"find", "Text$find", "func(text:Text, pattern:Pattern, start=1, length=!&Int64 -> Int)"},
|
||||
{"find", "Text$find", "func(text:Text, pattern:Pattern, start=1 -> Int)"},
|
||||
{"find_all", "Text$find_all", "func(text:Text, pattern:Pattern -> [Text])"},
|
||||
{"from_bytes", "Text$from_bytes", "func(bytes:[Byte] -> Text)"},
|
||||
{"from_c_string", "Text$from_str", "func(str:CString -> Text)"},
|
||||
|
@ -796,14 +796,14 @@ static int64_t _find(Text_t text, Pattern_t pattern, int64_t first, int64_t last
|
||||
return -1;
|
||||
}
|
||||
|
||||
public Int_t Text$find(Text_t text, Pattern_t pattern, Int_t from_index, int64_t *match_length)
|
||||
public Int_t Text$find(Text_t text, Pattern_t pattern, Int_t from_index)
|
||||
{
|
||||
int64_t first = Int_to_Int64(from_index, false);
|
||||
if (first == 0) fail("Invalid index: 0");
|
||||
if (first < 0) first = text.length + first + 1;
|
||||
if (first > text.length || first < 1)
|
||||
return I(0);
|
||||
int64_t found = _find(text, pattern, first-1, text.length-1, match_length);
|
||||
int64_t found = _find(text, pattern, first-1, text.length-1, NULL);
|
||||
return I(found+1);
|
||||
}
|
||||
|
||||
@ -1081,17 +1081,17 @@ public Array_t Text$split(Text_t text, Pattern_t pattern)
|
||||
|
||||
Array_t chunks = {};
|
||||
|
||||
Int_t i = I_small(1);
|
||||
int64_t i = 0;
|
||||
for (;;) {
|
||||
int64_t len = 0;
|
||||
Int_t found = Text$find(text, pattern, i, &len);
|
||||
if (I_is_zero(found)) break;
|
||||
Text_t chunk = Text$slice(text, i, Int$minus(found, I_small(1)));
|
||||
int64_t found = _find(text, pattern, i, text.length-1, &len);
|
||||
if (found < 0) break;
|
||||
Text_t chunk = Text$slice(text, I(i+1), I(found));
|
||||
Array$insert(&chunks, &chunk, I_small(0), sizeof(Text_t));
|
||||
i = Int$plus(found, I(MAX(len, 1)));
|
||||
i = found + MAX(len, 1);
|
||||
}
|
||||
|
||||
Text_t last_chunk = Text$slice(text, i, I(text.length));
|
||||
Text_t last_chunk = Text$slice(text, I(i+1), I(text.length));
|
||||
Array$insert(&chunks, &last_chunk, I_small(0), sizeof(Text_t));
|
||||
|
||||
return chunks;
|
||||
|
@ -18,7 +18,7 @@ Pattern_t Pattern$escape_text(Text_t text);
|
||||
Text_t Text$replace_all(Text_t text, Table_t replacements, Pattern_t backref_pat, bool recursive);
|
||||
Array_t Text$split(Text_t text, Pattern_t pattern);
|
||||
Text_t Text$trim(Text_t text, Pattern_t pattern, bool trim_left, bool trim_right);
|
||||
Int_t Text$find(Text_t text, Pattern_t pattern, Int_t i, int64_t *match_length);
|
||||
Int_t Text$find(Text_t text, Pattern_t pattern, Int_t i);
|
||||
Array_t Text$find_all(Text_t text, Pattern_t pattern);
|
||||
PUREFUNC bool Text$has(Text_t text, Pattern_t pattern);
|
||||
Array_t Text$matches(Text_t text, Pattern_t pattern);
|
||||
|
@ -195,12 +195,6 @@ func main():
|
||||
>> " one two three ":find($/{id}/, start=5)
|
||||
= 8
|
||||
|
||||
>> len := 0[64]
|
||||
>> " one ":find($/{id}/, length=&len)
|
||||
= 4
|
||||
>> len
|
||||
= 3[64]
|
||||
|
||||
!! Test text slicing:
|
||||
>> "abcdef":slice()
|
||||
= "abcdef"
|
||||
|
Loading…
Reference in New Issue
Block a user