aboutsummaryrefslogtreecommitdiffstats
path: root/global-functions
diff options
context:
space:
mode:
authorGravatar Christian Hesse <mail@eworm.de>2019-02-08 20:15:49 +0100
committerGravatar Christian Hesse <mail@eworm.de>2019-02-08 20:15:49 +0100
commitdb2c4fbf3972074c7e9ce978a906b8bbb437a0d2 (patch)
treec644de1c339c6830d069b69f2e7270929125ef2c /global-functions
parent6a48c8b5e7d2ddc9c7feb75860c6fba0a61f8187 (diff)
global-functions: prevent infinite loop in $CharacterReplace
Diffstat (limited to 'global-functions')
-rw-r--r--global-functions4
1 files changed, 4 insertions, 0 deletions
diff --git a/global-functions b/global-functions
index 50d0eed..6e5dd5d 100644
--- a/global-functions
+++ b/global-functions
@@ -47,6 +47,10 @@
:local ReplaceWith [ :tostr $3 ];
:local Len [ :len $ReplaceFrom ];
+ :if ($ReplaceFrom = "") do={
+ :return $String;
+ }
+
:while ($String ~ $ReplaceFrom) do={
:local Pos [ :find $String $ReplaceFrom ];
:set String ([ :pick $String 0 $Pos ] . $ReplaceWith . [ :pick $String ($Pos + $Len) 999 ]);