From 03af7d6d9c64cc57d1d0e3280e4ed1a6308e6448 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Mon, 3 Feb 2020 21:29:21 +0100 Subject: global-functions: $CharacterReplace: do not limit string length I've tried something like this to update a device: / system script set source=[ $CharacterReplace [ get global-config-overlay source ] "GlobalConfigVersion 10" "GlobalConfigVersion 11" ] global-config-overlay; This broke with global-config-overlay longer than 999 characters. So makes sure there is no limit for string length. --- global-functions | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/global-functions b/global-functions index 05b5093..15cba35 100644 --- a/global-functions +++ b/global-functions @@ -64,7 +64,6 @@ :local String [ :tostr $1 ]; :local ReplaceFrom [ :tostr $2 ]; :local ReplaceWith [ :tostr $3 ]; - :local Len [ :len $ReplaceFrom ]; :local Return ""; :if ($ReplaceFrom = "") do={ @@ -74,7 +73,7 @@ :while ([ :typeof [ :find $String $ReplaceFrom ] ] != "nil") do={ :local Pos [ :find $String $ReplaceFrom ]; :set Return ($Return . [ :pick $String 0 $Pos ] . $ReplaceWith); - :set String [ :pick $String ($Pos + $Len) 999 ]; + :set String [ :pick $String ($Pos + [ :len $ReplaceFrom ]) [ :len $String ] ]; } :return ($Return . $String); -- cgit v1.2.3-54-g00ecf