diff options
author | John Wiegley <johnw@newartisans.com> | 2003-10-06 23:11:44 +0000 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2003-10-06 23:11:44 +0000 |
commit | 331f389cc68b9ca54c50dddb58cb2e7bb3523cf6 (patch) | |
tree | 0c6ece2a578a0080fe70bf70287f587d772c9cae /parse.cc | |
parent | 260217c8ab48c6000021222e0d1c989dce80b869 (diff) | |
download | fork-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.cc | 29 |
1 files changed, 12 insertions, 17 deletions
@@ -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[] = { |