From 17189b81062b78baf4da1cf1ee494dc66bf1f736 Mon Sep 17 00:00:00 2001 From: Alexis Hildebrandt Date: Tue, 20 Jan 2015 21:53:44 +0100 Subject: [fix] Make trim function trim trailing whitespace std::isspace(*e) returns false for the end of c-string null-byte. Bugzilla: 1106 --- src/report.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/report.cc') diff --git a/src/report.cc b/src/report.cc index 4b240611..2ce70151 100644 --- a/src/report.cc +++ b/src/report.cc @@ -631,7 +631,7 @@ value_t report_t::fn_trim(call_scope_t& args) while (*p && std::isspace(*p)) p++; - const char * e = buf.get() + temp.length(); + const char * e = buf.get() + temp.length() - 1; while (e > p && std::isspace(*e)) e--; @@ -643,7 +643,7 @@ value_t report_t::fn_trim(call_scope_t& args) return string_value(empty_string); } else { - return string_value(string(p, static_cast(e - p))); + return string_value(string(p, static_cast(e - p + 1))); } } -- cgit v1.2.3