diff options
author | ridiculousfish <corydoras@ridiculousfish.com> | 2013-09-30 14:55:25 -0700 |
---|---|---|
committer | ridiculousfish <corydoras@ridiculousfish.com> | 2013-09-30 14:55:25 -0700 |
commit | 2f33e5919d2e3eb1a08cdd44a34f779a50ad2242 (patch) | |
tree | 686fa4673d372cbd882873b8bf45234d9bea8ad7 /tokenizer.cpp | |
parent | cbe615224da57e96cfe609eb92f115e0d45f0f28 (diff) |
Better error messages for `EDITOR=vim git...` type commands.
Diffstat (limited to 'tokenizer.cpp')
-rw-r--r-- | tokenizer.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/tokenizer.cpp b/tokenizer.cpp index 62094f92..567b03dc 100644 --- a/tokenizer.cpp +++ b/tokenizer.cpp @@ -641,6 +641,31 @@ void tok_next(tokenizer_t *tok) } +enum token_type tok_peek_next(tokenizer_t *tok, wcstring *out_next_string) +{ + if (out_next_string != NULL) + { + out_next_string->clear(); + } + + enum token_type result = TOK_END; + if (tok_has_next(tok)) + { + int saved = tok_get_pos(tok); + tok_next(tok); + result = tok_last_type(tok); + + if (out_next_string != NULL) + { + const wchar_t *last = tok_last(tok); + out_next_string->assign(last ? last : L""); + } + + tok_set_pos(tok, saved); + } + return result; +} + const wchar_t *tok_string(tokenizer_t *tok) { return tok?tok->orig_buff:0; |