parse_util: Remove locate_cmdsubst

We have *3* functions to find command substitutions, this is the most awkward.
This commit is contained in:
Fabian Homborg 2021-02-09 17:36:39 +01:00
parent 58177ba091
commit c1fe5be0ce
2 changed files with 1 additions and 16 deletions

View file

@ -177,11 +177,6 @@ static int parse_util_locate_brackets_of_type(const wchar_t *in, wchar_t **begin
return 1;
}
int parse_util_locate_cmdsubst(const wchar_t *in, wchar_t **begin, wchar_t **end,
bool accept_incomplete) {
return parse_util_locate_brackets_of_type(in, begin, end, accept_incomplete, L'(', L')');
}
int parse_util_locate_slice(const wchar_t *in, wchar_t **begin, wchar_t **end,
bool accept_incomplete) {
return parse_util_locate_brackets_of_type(in, begin, end, accept_incomplete, L'[', L']');
@ -254,7 +249,7 @@ void parse_util_cmdsubst_extent(const wchar_t *buff, size_t cursor_pos, const wc
const wchar_t *pos = buff;
for (;;) {
wchar_t *begin = nullptr, *end = nullptr;
if (parse_util_locate_cmdsubst(pos, &begin, &end, true) <= 0) {
if (parse_util_locate_brackets_of_type(pos, &begin, &end, true, L'(', L')') <= 0) {
// No subshell found, all done.
break;
}

View file

@ -14,16 +14,6 @@ namespace ast {
struct argument_t;
}
/// Find the beginning and end of the first subshell in the specified string.
///
/// \param in the string to search for subshells
/// \param begin the starting parenthesis of the subshell
/// \param end the ending parenthesis of the subshell
/// \param accept_incomplete whether to permit missing closing parenthesis
/// \return -1 on syntax error, 0 if no subshells exist and 1 on success
int parse_util_locate_cmdsubst(const wchar_t *in, wchar_t **begin, wchar_t **end,
bool accept_incomplete);
/// Same as parse_util_locate_cmdsubst, but handles square brackets [ ].
int parse_util_locate_slice(const wchar_t *in, wchar_t **begin, wchar_t **end,
bool accept_incomplete);