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
diff --git a/library/Misc_Helpers.ttcn b/library/Misc_Helpers.ttcn
index cbc1e70..fd2e7bb 100644
--- a/library/Misc_Helpers.ttcn
+++ b/library/Misc_Helpers.ttcn
@@ -79,4 +79,24 @@
return count;
}
+type record of charstring ro_charstring;
+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;
+}
+
}