diff options
author | ridiculousfish <corydoras@ridiculousfish.com> | 2012-11-21 22:23:48 -0800 |
---|---|---|
committer | ridiculousfish <corydoras@ridiculousfish.com> | 2012-11-21 22:23:48 -0800 |
commit | 6fc9e6f21ed8e6ebc2c6254426d1dc33f6bce636 (patch) | |
tree | 9bc04fd96159a2c86cd1b90d0b7fc80568ea8424 /tokenizer.cpp | |
parent | 7117c4a5ee4ebcdaa8ff692b9cc18fb87e6d8038 (diff) |
Make tok_first return a wcstring instead of a wchar_t*
Diffstat (limited to 'tokenizer.cpp')
-rw-r--r-- | tokenizer.cpp | 32 |
1 files changed, 17 insertions, 15 deletions
diff --git a/tokenizer.cpp b/tokenizer.cpp index 378fed1d..84702b55 100644 --- a/tokenizer.cpp +++ b/tokenizer.cpp @@ -642,24 +642,26 @@ const wchar_t *tok_string(tokenizer_t *tok) return tok?tok->orig_buff:0; } -wchar_t *tok_first(const wchar_t *str) +wcstring tok_first(const wchar_t *str) { - wchar_t *res=0; - - CHECK(str, 0); - - tokenizer_t t(str, TOK_SQUASH_ERRORS); - switch (tok_last_type(&t)) + wcstring result; + if (str) { - case TOK_STRING: -// fwprintf( stderr, L"Got token %ls\n", tok_last( &t )); - res = wcsdup(tok_last(&t)); - break; - default: - break; + tokenizer_t t(str, TOK_SQUASH_ERRORS); + switch (tok_last_type(&t)) + { + case TOK_STRING: + { + const wchar_t *tmp = tok_last(&t); + if (tmp != NULL) + result = tmp; + break; + } + default: + break; + } } - - return res; + return result; } int tok_get_pos(tokenizer_t *tok) |