simplify and clarify valid identifiers

This is the first step in addressing issue #3965. It renames some of the
functions involved in validating variable and function names to clarify
their purpose. It also augments the documentation to make the rules for
such identifiers clearly documented.
This commit is contained in:
Kurtis Rader
2017-04-19 23:43:02 -07:00
parent 15e1f4349b
commit 275d658616
13 changed files with 72 additions and 90 deletions

View File

@@ -844,7 +844,7 @@ void parse_util_expand_variable_error(const wcstring &token, size_t global_token
if (closing_bracket != wcstring::npos) {
size_t var_start = dollar_pos + 2, var_end = closing_bracket;
var_name = wcstring(token, var_start, var_end - var_start);
looks_like_variable = wcsvarname(var_name) == NULL;
looks_like_variable = valid_var_name(var_name);
}
if (looks_like_variable) {
append_syntax_error(
@@ -1026,7 +1026,7 @@ parser_test_error_bits_t parse_util_detect_errors_in_argument(const parse_node_t
wchar_t next_char = idx + 1 < unesc_size ? unesc.at(idx + 1) : L'\0';
if (next_char != VARIABLE_EXPAND && next_char != VARIABLE_EXPAND_SINGLE &&
!wcsvarchr(next_char)) {
!valid_var_name_char(next_char)) {
err = 1;
if (out_errors) {
// We have something like $$$^.... Back up until we reach the first $.