Merge pull request #379 from afh/pull/trim
[fix] Make trim function trim trailing whitespace
This commit is contained in:
commit
7690a1b587
2 changed files with 13 additions and 2 deletions
|
|
@ -631,7 +631,7 @@ value_t report_t::fn_trim(call_scope_t& args)
|
||||||
while (*p && std::isspace(*p))
|
while (*p && std::isspace(*p))
|
||||||
p++;
|
p++;
|
||||||
|
|
||||||
const char * e = buf.get() + temp.length();
|
const char * e = buf.get() + temp.length() - 1;
|
||||||
while (e > p && std::isspace(*e))
|
while (e > p && std::isspace(*e))
|
||||||
e--;
|
e--;
|
||||||
|
|
||||||
|
|
@ -643,7 +643,7 @@ value_t report_t::fn_trim(call_scope_t& args)
|
||||||
return string_value(empty_string);
|
return string_value(empty_string);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return string_value(string(p, static_cast<std::string::size_type>(e - p)));
|
return string_value(string(p, static_cast<std::string::size_type>(e - p + 1)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
11
test/regress/1106.test
Normal file
11
test/regress/1106.test
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
2015/01/20 Payee
|
||||||
|
Assets:Cash ¤ 12,34
|
||||||
|
Expenses:Food
|
||||||
|
|
||||||
|
test -F "»%(trim(' Trimmed '))«\n" reg expenses
|
||||||
|
»Trimmed«
|
||||||
|
end test
|
||||||
|
|
||||||
|
test -F "»%(trim('Trimmed'))«\n" reg expenses
|
||||||
|
»Trimmed«
|
||||||
|
end test
|
||||||
Loading…
Add table
Reference in a new issue