mirror of
https://github.com/fish-shell/fish-shell.git
synced 2025-01-20 18:18:47 +08:00
Clean up job_or_process_extent
This had a bad merge which happened to work, plus some other nonsense.
This commit is contained in:
parent
2fed311d4c
commit
9652b3e11b
|
@ -289,14 +289,13 @@ void parse_util_cmdsubst_extent(const wchar_t *buff, size_t cursor_pos, const wc
|
||||||
|
|
||||||
/// Get the beginning and end of the job or process definition under the cursor.
|
/// Get the beginning and end of the job or process definition under the cursor.
|
||||||
static void job_or_process_extent(const wchar_t *buff, size_t cursor_pos, const wchar_t **a,
|
static void job_or_process_extent(const wchar_t *buff, size_t cursor_pos, const wchar_t **a,
|
||||||
const wchar_t **b, int process) {
|
const wchar_t **b, bool process) {
|
||||||
assert(buff && "Null buffer");
|
assert(buff && "Null buffer");
|
||||||
const wchar_t *begin, *end;
|
const wchar_t *begin = nullptr, *end = nullptr;
|
||||||
wchar_t *buffcpy;
|
|
||||||
int finished = 0;
|
int finished = 0;
|
||||||
|
|
||||||
if (a) *a = 0;
|
if (a) *a = nullptr;
|
||||||
if (b) *b = 0;
|
if (b) *b = nullptr;
|
||||||
parse_util_cmdsubst_extent(buff, cursor_pos, &begin, &end);
|
parse_util_cmdsubst_extent(buff, cursor_pos, &begin, &end);
|
||||||
if (!end || !begin) {
|
if (!end || !begin) {
|
||||||
return;
|
return;
|
||||||
|
@ -307,11 +306,10 @@ static void job_or_process_extent(const wchar_t *buff, size_t cursor_pos, const
|
||||||
|
|
||||||
if (a) *a = begin;
|
if (a) *a = begin;
|
||||||
if (b) *b = end;
|
if (b) *b = end;
|
||||||
buffcpy = wcsndup(begin, end - begin);
|
|
||||||
assert(buffcpy != NULL);
|
|
||||||
|
|
||||||
tokenizer_t tok(buffcpy, TOK_ACCEPT_UNFINISHED);
|
const wcstring buffcpy(begin, end);
|
||||||
for (maybe_t<tok_t> token = tok.next(); token && !finished; token = tok.next())
|
tokenizer_t tok(buffcpy.c_str(), TOK_ACCEPT_UNFINISHED);
|
||||||
|
maybe_t<tok_t> token{};
|
||||||
while ((token = tok.next()) && !finished) {
|
while ((token = tok.next()) && !finished) {
|
||||||
size_t tok_begin = token->offset;
|
size_t tok_begin = token->offset;
|
||||||
|
|
||||||
|
@ -339,17 +337,15 @@ static void job_or_process_extent(const wchar_t *buff, size_t cursor_pos, const
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
free(buffcpy);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void parse_util_process_extent(const wchar_t *buff, size_t pos, const wchar_t **a,
|
void parse_util_process_extent(const wchar_t *buff, size_t pos, const wchar_t **a,
|
||||||
const wchar_t **b) {
|
const wchar_t **b) {
|
||||||
job_or_process_extent(buff, pos, a, b, 1);
|
job_or_process_extent(buff, pos, a, b, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void parse_util_job_extent(const wchar_t *buff, size_t pos, const wchar_t **a, const wchar_t **b) {
|
void parse_util_job_extent(const wchar_t *buff, size_t pos, const wchar_t **a, const wchar_t **b) {
|
||||||
job_or_process_extent(buff, pos, a, b, 0);
|
job_or_process_extent(buff, pos, a, b, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void parse_util_token_extent(const wchar_t *buff, size_t cursor_pos, const wchar_t **tok_begin,
|
void parse_util_token_extent(const wchar_t *buff, size_t cursor_pos, const wchar_t **tok_begin,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user