From d02713789ba4740bf2dd56ced4858487be5cd06b Mon Sep 17 00:00:00 2001 From: Andrzej Rybczak Date: Sun, 28 Mar 2010 22:20:18 +0200 Subject: [PATCH] fix Replace() function conversion wasn't correct e.g. when passed arguments were ("a\\n\\nb", "\\n", "\n"). --- src/conv.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/conv.h b/src/conv.h index 4626650a..ffcef17e 100644 --- a/src/conv.h +++ b/src/conv.h @@ -21,6 +21,7 @@ #ifndef _CONV_H #define _CONV_H +#include #include #include "window.h" @@ -33,7 +34,8 @@ template inline size_t static_strlen(const char (&)[N]) template void Replace(std::string &s, const char (&from)[N], const char *to) { - for (size_t i = 0; (i = s.find(from, i)) != std::string::npos; i += N) + size_t to_len = strlen(to); + for (size_t i = 0; (i = s.find(from, i)) != std::string::npos; i += to_len) s.replace(i, N-1, to); }