From a26a98cb989ef775f1f15fdd9b330267f98b6453 Mon Sep 17 00:00:00 2001 From: Fysiks Date: Wed, 13 Feb 2013 00:40:57 -0800 Subject: [PATCH] Fix incorrect result for replace_all (bug 5064, r=dvander). Former-commit-id: e3824c4c87c43734e6c5d4831f2ca7cece0a5147 --- plugins/include/string.inc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/include/string.inc b/plugins/include/string.inc index 48063c2c..7a5674a5 100755 --- a/plugins/include/string.inc +++ b/plugins/include/string.inc @@ -238,6 +238,8 @@ stock replace_all(string[], len, const what[], const with[]) while (replace(string[pos], len - pos, what, with) != 0) { + total++; + /* jump to position after replacement */ pos += with_len; @@ -261,7 +263,6 @@ stock replace_all(string[], len, const what[], const with[]) /* otherwise, reposition and update counters */ pos += temp_pos; - total++; } return total;