From d9b42cd7a2f941fd04a7d99cf93c278db5ba0aae Mon Sep 17 00:00:00 2001 From: zawz Date: Fri, 12 Feb 2021 10:19:09 +0100 Subject: [PATCH] include 'getopts' as cmdvar --- src/parse.cpp | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/src/parse.cpp b/src/parse.cpp index 52aa04f..237f250 100644 --- a/src/parse.cpp +++ b/src/parse.cpp @@ -18,7 +18,7 @@ bool g_bash=false; #define PARSE_ERROR(str, i) ztd::format_error(str, "", in, i) // constants -const std::vector posix_cmdvar = { "export", "unset", "local", "read" }; +const std::vector posix_cmdvar = { "export", "unset", "local", "read", "getopts" }; const std::vector bash_cmdvar = { "readonly", "declare", "typeset" }; const std::vector arithmetic_precedence_operators = { "!", "~", "+", "-" }; @@ -65,14 +65,6 @@ bool valid_name(std::string const& str) // string utils -bool word_is_reserved_out(std::string const in) -{ - for(auto it: out_reserved_words) - if(in == it) - return true; - return false; -} - bool word_eq(const char* word, const char* in, uint32_t size, uint32_t start, const char* end_set=NULL) { uint32_t wordsize=strlen(word); @@ -1532,7 +1524,7 @@ std::pair parse_block(const char* in, uint32_t size, uint32_t ret = pp.first; i = pp.second; } - else if(word_is_reserved_out(word)) + else if(is_in_vector(word, out_reserved_words)) // is a reserved word { throw PARSE_ERROR( "Unexpected '"+word+"'" + expecting(g_expecting) , i); }