summaryrefslogtreecommitdiff
path: root/parse.cc
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2003-10-06 23:11:44 +0000
committerJohn Wiegley <johnw@newartisans.com>2003-10-06 23:11:44 +0000
commit331f389cc68b9ca54c50dddb58cb2e7bb3523cf6 (patch)
tree0c6ece2a578a0080fe70bf70287f587d772c9cae /parse.cc
parent260217c8ab48c6000021222e0d1c989dce80b869 (diff)
downloadfork-ledger-331f389cc68b9ca54c50dddb58cb2e7bb3523cf6.tar.gz
fork-ledger-331f389cc68b9ca54c50dddb58cb2e7bb3523cf6.tar.bz2
fork-ledger-331f389cc68b9ca54c50dddb58cb2e7bb3523cf6.zip
*** empty log message ***
Diffstat (limited to 'parse.cc')
-rw-r--r--parse.cc29
1 files changed, 12 insertions, 17 deletions
diff --git a/parse.cc b/parse.cc
index 146b93ea..88042828 100644
--- a/parse.cc
+++ b/parse.cc
@@ -16,25 +16,20 @@ static inline char * skip_ws(char * ptr)
static inline char * next_element(char * buf, bool variable = false)
{
- char * p;
-
- if (variable) {
- // Convert any tabs to spaces, for simplicity's sake
- for (p = buf; *p; p++)
- if (*p == '\t')
- *p = ' ';
+ for (char * p = buf; *p; p++) {
+ if (! (*p == ' ' || *p == '\t'))
+ continue;
- p = std::strstr(buf, " ");
- } else {
- p = std::strchr(buf, ' ');
+ if (! variable) {
+ *p = '\0';
+ return skip_ws(p + 1);
+ }
+ else if (*(p + 1) == ' ' || *(p + 1) == '\t') {
+ *p = '\0';
+ return skip_ws(p + 2);
+ }
}
-
- if (! p)
- return NULL;
-
- *p++ = '\0';
-
- return skip_ws(p);
+ return NULL;
}
static const char *formats[] = {