pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/36592?usp=email )
Change subject: Move f_strstr_count() Osmocom_VTY_Functions.ttcn -> Misc_Helpers.ttcn ......................................................................
Move f_strstr_count() 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: I105844d2bcab6c24624be1224c1ba78b69d4b44c --- M library/Misc_Helpers.ttcn M library/Osmocom_VTY_Functions.ttcn 2 files changed, 29 insertions(+), 17 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-ttcn3-hacks refs/changes/92/36592/1
diff --git a/library/Misc_Helpers.ttcn b/library/Misc_Helpers.ttcn index dda2c2c..33ea666 100644 --- a/library/Misc_Helpers.ttcn +++ b/library/Misc_Helpers.ttcn @@ -61,4 +61,21 @@ } }
+/* Return a count of how many times sub_str occurs in str. */ +function f_strstr_count(in charstring str, in charstring sub_str) return integer +{ + var integer count := 0; + var integer pos := 0; + + while (true) { + var integer at := f_strstr(str, sub_str, pos); + if (at < 0) { + break; + } + count := count + 1; + pos := at + 1; + } + return count; +} + } diff --git a/library/Osmocom_VTY_Functions.ttcn b/library/Osmocom_VTY_Functions.ttcn index 3dd0429..6b0883f 100644 --- a/library/Osmocom_VTY_Functions.ttcn +++ b/library/Osmocom_VTY_Functions.ttcn @@ -228,23 +228,6 @@ return ""; }
-/* Return a count of how many times sub_str occurs in str. */ -function f_strstr_count(in charstring str, in charstring sub_str) return integer -{ - var integer count := 0; - var integer pos := 0; - - while (true) { - var integer at := f_strstr(str, sub_str, pos); - if (at < 0) { - break; - } - count := count + 1; - pos := at + 1; - } - return count; -} - private type record of charstring StrList;
/* Perform a 'show talloc-context' to get a count of the given object_strs that are still allocated.