diff options
author | ridiculousfish <corydoras@ridiculousfish.com> | 2013-10-06 13:08:57 -0700 |
---|---|---|
committer | ridiculousfish <corydoras@ridiculousfish.com> | 2013-10-06 13:08:57 -0700 |
commit | dd91779442125ca46a434cd94cc51ae32e43bee1 (patch) | |
tree | e023ebb7a8a0e6f9c6c4a394158773ced0c98a82 /parse_util.cpp | |
parent | e58b73179f4727c79465c6f273aef377b9bb8bee (diff) | |
parent | fab7299d49492ce548d4ceed66d3acbd05dd99c7 (diff) |
Merge branch 'master' into ast_no_templates
Conflicts:
configure.ac
exec.cpp
Diffstat (limited to 'parse_util.cpp')
-rw-r--r-- | parse_util.cpp | 40 |
1 files changed, 22 insertions, 18 deletions
diff --git a/parse_util.cpp b/parse_util.cpp index 6f291345..5b807059 100644 --- a/parse_util.cpp +++ b/parse_util.cpp @@ -381,6 +381,11 @@ static void job_or_process_extent(const wchar_t *buff, break; } + + default: + { + break; + } } } @@ -411,35 +416,34 @@ void parse_util_token_extent(const wchar_t *buff, const wchar_t **prev_begin, const wchar_t **prev_end) { - const wchar_t *begin, *end; - long pos; - const wchar_t *a = NULL, *b = NULL, *pa = NULL, *pb = NULL; CHECK(buff,); assert(cursor_pos >= 0); - parse_util_cmdsubst_extent(buff, cursor_pos, &begin, &end); + const wchar_t *cmdsubst_begin, *cmdsubst_end; + parse_util_cmdsubst_extent(buff, cursor_pos, &cmdsubst_begin, &cmdsubst_end); - if (!end || !begin) + if (!cmdsubst_end || !cmdsubst_begin) { return; } - pos = cursor_pos - (begin - buff); + /* pos is equivalent to cursor_pos within the range of the command substitution {begin, end} */ + long offset_within_cmdsubst = cursor_pos - (cmdsubst_begin - buff); - a = buff + pos; + a = cmdsubst_begin + offset_within_cmdsubst; b = a; - pa = buff + pos; + pa = cmdsubst_begin + offset_within_cmdsubst; pb = pa; - assert(begin >= buff); - assert(begin <= (buff+wcslen(buff))); - assert(end >= begin); - assert(end <= (buff+wcslen(buff))); + assert(cmdsubst_begin >= buff); + assert(cmdsubst_begin <= (buff+wcslen(buff))); + assert(cmdsubst_end >= cmdsubst_begin); + assert(cmdsubst_end <= (buff+wcslen(buff))); - const wcstring buffcpy = wcstring(begin, end-begin); + const wcstring buffcpy = wcstring(cmdsubst_begin, cmdsubst_end-cmdsubst_begin); tokenizer_t tok(buffcpy.c_str(), TOK_ACCEPT_UNFINISHED | TOK_SQUASH_ERRORS); for (; tok_has_next(&tok); tok_next(&tok)) @@ -460,9 +464,9 @@ void parse_util_token_extent(const wchar_t *buff, cursor is between two tokens, so we set it to a zero element string and break */ - if (tok_begin > pos) + if (tok_begin > offset_within_cmdsubst) { - a = b = (wchar_t *)buff + pos; + a = b = cmdsubst_begin + offset_within_cmdsubst; break; } @@ -470,9 +474,9 @@ void parse_util_token_extent(const wchar_t *buff, If cursor is inside the token, this is the token we are looking for. If so, set a and b and break */ - if ((tok_last_type(&tok) == TOK_STRING) && (tok_end >= pos)) + if ((tok_last_type(&tok) == TOK_STRING) && (tok_end >= offset_within_cmdsubst)) { - a = begin + tok_get_pos(&tok); + a = cmdsubst_begin + tok_get_pos(&tok); b = a + wcslen(tok_last(&tok)); break; } @@ -482,7 +486,7 @@ void parse_util_token_extent(const wchar_t *buff, */ if (tok_last_type(&tok) == TOK_STRING) { - pa = begin + tok_get_pos(&tok); + pa = cmdsubst_begin + tok_get_pos(&tok); pb = pa + wcslen(tok_last(&tok)); } } |