cleanup env code and contains()

Switch from null terminated arrays to `wcstring_list_t` for lists of
special env var names. Rename `list_contains_string` to `contains` and
modify the latter interface to not rely on a `#define`.

Rename `list_contains_string()` to `contains()` and eliminate the
current variadic implementation. Update all callers of the removed
version to use the string list version.
This commit is contained in:
Kurtis Rader
2017-04-04 21:28:57 -07:00
parent 75600b6b53
commit 03571b82be
12 changed files with 63 additions and 98 deletions

View File

@@ -748,8 +748,10 @@ static bool append_syntax_error(parse_error_list_t *errors, size_t source_locati
}
/// Returns 1 if the specified command is a builtin that may not be used in a pipeline.
static const wcstring_list_t forbidden_pipe_commands({L"exec", L"case", L"break", L"return",
L"continue"});
static int parser_is_pipe_forbidden(const wcstring &word) {
return contains(word, L"exec", L"case", L"break", L"return", L"continue");
return contains(forbidden_pipe_commands, word);
}
bool parse_util_argument_is_help(const wchar_t *s, int min_match) {