Move f_str_split() Osmocom_VTY_Functions.ttcn -> Misc_Helpers.ttcn

This is quite a generic string handling function which fits better
in a generic utility file like Misc_Helpers.ttcn.

Change-Id: I54eff3eea60ed0624919baebfe0ff7393414d6b8
This commit is contained in:
Pau Espin 2024-04-17 19:16:17 +02:00
parent e266a1735d
commit 7d7d90f358
2 changed files with 19 additions and 19 deletions

View File

@ -79,4 +79,23 @@ function f_strstr_count(in charstring str, in charstring sub_str) return integer
return count;
}
function f_str_split(charstring str, charstring delim := "\n") return ro_charstring
{
var integer pos := 0;
var ro_charstring parts := {};
var integer delim_pos;
var integer end := lengthof(str);
while (pos < end) {
delim_pos := f_strstr(str, delim, pos);
if (delim_pos < 0) {
delim_pos := end;
}
if (delim_pos > pos) {
parts := parts & { substr(str, pos, delim_pos - pos) };
}
pos := delim_pos + 1;
}
return parts;
}
}

View File

@ -274,25 +274,6 @@ function f_verify_talloc_count(TELNETasp_PT pt, StrList object_strs, integer exp
Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "talloc count mismatch");
}
public function f_str_split(charstring str, charstring delim := "\n") return ro_charstring
{
var integer pos := 0;
var ro_charstring parts := {};
var integer delim_pos;
var integer end := lengthof(str);
while (pos < end) {
delim_pos := f_strstr(str, delim, pos);
if (delim_pos < 0) {
delim_pos := end;
}
if (delim_pos > pos) {
parts := parts & { substr(str, pos, delim_pos - pos) };
}
pos := delim_pos + 1;
}
return parts;
}
public function f_verify_talloc_bytes(TELNETasp_PT pt, ro_charstring object_strs, integer expect_bytes := 0,
integer attempts := 5, float wait_time := 3.0)
{