From e8a6b875601fccdd709f6c1501a45f0878fe9f33 Mon Sep 17 00:00:00 2001 From: Pau Espin Pedrol Date: Wed, 17 Apr 2024 19:13:22 +0200 Subject: [PATCH] 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 --- library/Misc_Helpers.ttcn | 17 +++++++++++++++++ library/Osmocom_VTY_Functions.ttcn | 17 ----------------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/library/Misc_Helpers.ttcn b/library/Misc_Helpers.ttcn index dda2c2c16..33ea66639 100644 --- a/library/Misc_Helpers.ttcn +++ b/library/Misc_Helpers.ttcn @@ -61,4 +61,21 @@ function f_addrstr2addr(charstring addr) return octetstring { } } +/* 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 3dd04298e..6b0883f9b 100644 --- a/library/Osmocom_VTY_Functions.ttcn +++ b/library/Osmocom_VTY_Functions.ttcn @@ -228,23 +228,6 @@ function f_vty_transceive_match_regexp_retry(TELNETasp_PT pt, charstring cmd, ch 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.