From 92fdf009cbcd13ca1dc9f592b2e7b5fbd84276b9 Mon Sep 17 00:00:00 2001 From: yanyiwu Date: Fri, 18 Mar 2016 14:05:18 +0800 Subject: [PATCH] Upgrade limonp to v0.5.6 to fix hidden trouble. --- ChangeLog.md | 4 ++++ deps/limonp/StringUtil.hpp | 9 +++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index 83d0cda..1128bf2 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -1,5 +1,9 @@ # CppJieba ChangeLog +## next version + ++ Upgrade limonp to v0.5.6 to fix hidden trouble. + ## v4.5.1 + Upgrade limonp to v0.5.5 to solve macro name conficts in some special case. diff --git a/deps/limonp/StringUtil.hpp b/deps/limonp/StringUtil.hpp index 41d451e..c08ae8f 100644 --- a/deps/limonp/StringUtil.hpp +++ b/deps/limonp/StringUtil.hpp @@ -78,13 +78,18 @@ inline string& Lower(string& str) { return str; } +inline bool IsSpace(unsigned c) { + // when passing large int as the argument of isspace, it core dump, so here need a type cast. + return c > 0xff ? false : std::isspace(c & 0xff); +} + inline std::string& LTrim(std::string &s) { - s.erase(s.begin(), std::find_if(s.begin(), s.end(), std::not1(std::ptr_fun(std::isspace)))); + s.erase(s.begin(), std::find_if(s.begin(), s.end(), std::not1(std::ptr_fun(IsSpace)))); return s; } inline std::string& RTrim(std::string &s) { - s.erase(std::find_if(s.rbegin(), s.rend(), std::not1(std::ptr_fun(std::isspace))).base(), s.end()); + s.erase(std::find_if(s.rbegin(), s.rend(), std::not1(std::ptr_fun(IsSpace))).base(), s.end()); return s; }