summaryrefslogtreecommitdiff
path: root/src/utils.h
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2009-02-22 17:51:11 -0400
committerJohn Wiegley <johnw@newartisans.com>2009-02-22 17:51:11 -0400
commitea75613760440604ba5bdc2ab7f89892dc28c079 (patch)
treec6cd3ec4871f9598dfe2191f0cb7e2933da8b920 /src/utils.h
parentf2e4f4c6d1f20949232ab776cb24bfbd2db2797b (diff)
downloadfork-ledger-ea75613760440604ba5bdc2ab7f89892dc28c079.tar.gz
fork-ledger-ea75613760440604ba5bdc2ab7f89892dc28c079.tar.bz2
fork-ledger-ea75613760440604ba5bdc2ab7f89892dc28c079.zip
--exchange option now accepts multiple commodities
They must be separated by a comma, and all whitespace is ignored.
Diffstat (limited to 'src/utils.h')
-rw-r--r--src/utils.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/utils.h b/src/utils.h
index 4beff305..38fd2439 100644
--- a/src/utils.h
+++ b/src/utils.h
@@ -522,6 +522,14 @@ inline char * skip_ws(char * ptr) {
return ptr;
}
+inline char * trim_ws(char * ptr) {
+ std::size_t len = std::strlen(ptr);
+ int i = int(len) - 1;
+ while (i >= 0 && ptr[i] == ' ' || ptr[i] == '\t' || ptr[i] == '\n')
+ ptr[i--] = '\0';
+ return skip_ws(ptr);
+}
+
inline char * next_element(char * buf, bool variable = false) {
for (char * p = buf; *p; p++) {
if (! (*p == ' ' || *p == '\t'))