diff options
author | John Wiegley <johnw@newartisans.com> | 2004-08-17 16:41:07 -0400 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2004-08-17 16:41:07 -0400 |
commit | bbcb49fed27ea7d2052724fbee79f42c9bc744bc (patch) | |
tree | 094e1b10bcac1ba2d2c5ac7103b9b9ffe150ff79 /util.h | |
parent | 019a42f199494c86b0aeea59caf9421d96a2c009 (diff) | |
download | fork-ledger-bbcb49fed27ea7d2052724fbee79f42c9bc744bc.tar.gz fork-ledger-bbcb49fed27ea7d2052724fbee79f42c9bc744bc.tar.bz2 fork-ledger-bbcb49fed27ea7d2052724fbee79f42c9bc744bc.zip |
fixes
Diffstat (limited to 'util.h')
-rw-r--r-- | util.h | 38 |
1 files changed, 38 insertions, 0 deletions
@@ -0,0 +1,38 @@ +#ifndef _UTIL_H +#define _UTIL_H + +inline char * skip_ws(char * ptr) { + while (*ptr == ' ' || *ptr == '\t' || *ptr == '\n') + ptr++; + return ptr; +} + +inline char peek_next_nonws(std::istream& in) { + char c = in.peek(); + while (! in.eof() && std::isspace(c)) { + in.get(c); + c = in.peek(); + } + return c; +} + +#define READ_INTO(str, targ, size, var, cond) { \ + char * _p = targ; \ + var = str.peek(); \ + while (! str.eof() && (cond)) { \ + str.get(var); \ + if (str.eof()) \ + break; \ + if (var == '\\') { \ + str.get(var); \ + if (in.eof()) \ + break; \ + } \ + *_p++ = var; \ + var = str.peek(); \ + } \ + assert(_p < targ + ((size) - 1)); \ + *_p = '\0'; \ +} + +#endif // _UTIL_H |