mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-06-10 12:51:15 -03:00
Clean up some tokenization
Remove TOK_NONE Turn token_type into an enum class Make next() turn a maybe_t<tok_t> instead of a bool
This commit is contained in:
@@ -100,12 +100,11 @@ static void write_part(const wchar_t *begin, const wchar_t *end, int cut_at_curs
|
||||
wcstring out;
|
||||
wcstring buff(begin, end - begin);
|
||||
tokenizer_t tok(buff.c_str(), TOK_ACCEPT_UNFINISHED);
|
||||
tok_t token;
|
||||
while (tok.next(&token)) {
|
||||
if ((cut_at_cursor) && (token.offset + token.length >= pos)) break;
|
||||
while (auto token = tok.next()) {
|
||||
if ((cut_at_cursor) && (token->offset + token->length >= pos)) break;
|
||||
|
||||
if (token.type == TOK_STRING) {
|
||||
wcstring tmp = tok.text_of(token);
|
||||
if (token->type == token_type_t::string) {
|
||||
wcstring tmp = tok.text_of(*token);
|
||||
unescape_string_in_place(&tmp, UNESCAPE_INCOMPLETE);
|
||||
out.append(tmp);
|
||||
out.push_back(L'\n');
|
||||
|
||||
Reference in New Issue
Block a user