From 0b05edf26e6208a105b9209e0e66e47f24579e86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E6=99=93=E8=88=AA?= <1210603696@qq.com> Date: Wed, 24 Dec 2014 11:13:00 +0800 Subject: [PATCH] bug fix --- TinySTL/String.h | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/TinySTL/String.h b/TinySTL/String.h index dbacf1d..d53745d 100644 --- a/TinySTL/String.h +++ b/TinySTL/String.h @@ -528,9 +528,12 @@ namespace TinySTL{ } size_t string::find(const char* s, size_t pos, size_t n) const{ size_t lenghtOfS = strlen(s); - if (n < lenghtOfS) - return npos; - return find_aux(s, pos, lenghtOfS, pos + n); + //if (n < lenghtOfS) + // return npos; + //return find_aux(s, pos, lenghtOfS, pos + n); + //bug fix + //2014.12.24 + return find_aux(s, pos, n, size()); } size_t string::find(const string& str, size_t pos) const{ size_t lengthOfS = str.size(); @@ -539,7 +542,10 @@ namespace TinySTL{ return find_aux(str.cbegin(), pos, lengthOfS, size()); } size_t string::find(const char* s, size_t pos) const{ - return find(s, pos, size() - pos); + //return find(s, pos, size() - pos); + //bug fix + //2014.12.24 + return find(s, pos, strlen(s)); } size_t string::find(char c, size_t pos) const{ for (auto cit = cbegin() + pos; cit != cend(); ++cit){