aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--src/builtin.cpp2
-rw-r--r--src/builtin_set.cpp3
-rw-r--r--src/env.cpp6
-rw-r--r--src/env_universal_common.cpp4
-rw-r--r--src/fallback.cpp3
-rw-r--r--src/parse_execution.cpp3
-rw-r--r--src/parse_tree.h11
-rw-r--r--src/wildcard.cpp38
-rw-r--r--src/wildcard.h3
9 files changed, 32 insertions, 41 deletions
diff --git a/src/builtin.cpp b/src/builtin.cpp
index ae6c85b2..d79c8880 100644
--- a/src/builtin.cpp
+++ b/src/builtin.cpp
@@ -1705,7 +1705,6 @@ static unsigned int builtin_echo_digit(wchar_t wc, unsigned int base)
static bool builtin_echo_parse_numeric_sequence(const wchar_t *str, size_t *consumed, unsigned char *out_val)
{
bool success = false;
- unsigned char val = 0; //resulting character
unsigned int start = 0; //the first character of the numeric part of the sequence
unsigned int base = 0, max_digits = 0;
@@ -1731,6 +1730,7 @@ static bool builtin_echo_parse_numeric_sequence(const wchar_t *str, size_t *cons
if (base != 0)
{
unsigned int idx;
+ unsigned char val = 0; //resulting character
for (idx = start; idx < start + max_digits; idx++)
{
unsigned int digit = builtin_echo_digit(str[idx], base);
diff --git a/src/builtin_set.cpp b/src/builtin_set.cpp
index c3cde791..ec530599 100644
--- a/src/builtin_set.cpp
+++ b/src/builtin_set.cpp
@@ -431,7 +431,6 @@ static int builtin_set(parser_t &parser, io_streams_t &streams, wchar_t **argv)
int retcode=0;
int scope;
int slice=0;
- int i;
const wchar_t *bad_char = NULL;
@@ -793,7 +792,7 @@ static int builtin_set(parser_t &parser, io_streams_t &streams, wchar_t **argv)
else
{
wcstring_list_t val;
- for (i=w.woptind; i<argc; i++)
+ for (int i=w.woptind; i<argc; i++)
val.push_back(argv[i]);
retcode = my_env_set(dest, val, scope, streams);
}
diff --git a/src/env.cpp b/src/env.cpp
index f6a0104b..e6deec52 100644
--- a/src/env.cpp
+++ b/src/env.cpp
@@ -593,7 +593,6 @@ int env_set(const wcstring &key, const wchar_t *val, env_mode_flags_t var_mode)
{
ASSERT_IS_MAIN_THREAD();
bool has_changed_old = has_changed_exported;
- bool has_changed_new = false;
int done=0;
if (val && contains(key, L"PWD", L"HOME"))
@@ -685,7 +684,7 @@ int env_set(const wcstring &key, const wchar_t *val, env_mode_flags_t var_mode)
else
{
// Determine the node
-
+ bool has_changed_new = false;
env_node_t *preexisting_node = env_get_node(key);
bool preexisting_entry_exportv = false;
if (preexisting_node != NULL)
@@ -1315,7 +1314,6 @@ static void update_export_array_if_necessary(bool recalc)
if (has_changed_exported)
{
std::map<wcstring, wcstring> vals;
- size_t i;
debug(4, L"env_export_arr() recalc");
@@ -1324,7 +1322,7 @@ static void update_export_array_if_necessary(bool recalc)
if (uvars())
{
const wcstring_list_t uni = uvars()->get_names(true, false);
- for (i=0; i<uni.size(); i++)
+ for (size_t i=0; i<uni.size(); i++)
{
const wcstring &key = uni.at(i);
const env_var_t val = uvars()->get(key);
diff --git a/src/env_universal_common.cpp b/src/env_universal_common.cpp
index c67fa415..bb181504 100644
--- a/src/env_universal_common.cpp
+++ b/src/env_universal_common.cpp
@@ -1210,11 +1210,11 @@ class universal_notifier_shmem_poller_t : public universal_notifier_t
{
int err = errno;
report_error(err, L"Unable to memory map shared memory object with path '%s'", path);
- region = NULL;
+ this->region = NULL;
}
else
{
- region = static_cast<universal_notifier_shmem_t*>(addr);
+ this->region = static_cast<universal_notifier_shmem_t*>(addr);
}
}
diff --git a/src/fallback.cpp b/src/fallback.cpp
index c94a55c7..6b4b8b0a 100644
--- a/src/fallback.cpp
+++ b/src/fallback.cpp
@@ -1363,13 +1363,12 @@ struct interval
static int bisearch(wchar_t ucs, const struct interval *table, int max)
{
int min = 0;
- int mid;
if (ucs < table[0].first || ucs > table[max].last)
return 0;
while (max >= min)
{
- mid = (min + max) / 2;
+ int mid = (min + max) / 2;
if (ucs > table[mid].last)
min = mid + 1;
else if (ucs < table[mid].first)
diff --git a/src/parse_execution.cpp b/src/parse_execution.cpp
index 0ea0aba9..061ca03e 100644
--- a/src/parse_execution.cpp
+++ b/src/parse_execution.cpp
@@ -536,7 +536,6 @@ parse_execution_result_t parse_execution_context_t::run_for_statement(const pars
parse_execution_result_t parse_execution_context_t::run_switch_statement(const parse_node_t &statement)
{
assert(statement.type == symbol_switch_statement);
- const parse_node_t *matching_case_item = NULL;
parse_execution_result_t result = parse_execution_success;
@@ -590,6 +589,7 @@ parse_execution_result_t parse_execution_context_t::run_switch_statement(const p
const parse_node_t *case_item_list = get_child(statement, 3, symbol_case_item_list);
/* Loop while we don't have a match but do have more of the list */
+ const parse_node_t *matching_case_item = NULL;
while (matching_case_item == NULL && case_item_list != NULL)
{
if (should_cancel_execution(sb))
@@ -990,7 +990,6 @@ parse_execution_result_t parse_execution_context_t::determine_arguments(const pa
{
this->report_errors(errors);
return parse_execution_errored;
- break;
}
case EXPAND_WILDCARD_NO_MATCH:
diff --git a/src/parse_tree.h b/src/parse_tree.h
index 4d0ad4a6..d7b296ae 100644
--- a/src/parse_tree.h
+++ b/src/parse_tree.h
@@ -112,7 +112,16 @@ public:
wcstring describe(void) const;
/* Constructor */
- explicit parse_node_t(parse_token_type_t ty) : source_start(SOURCE_OFFSET_INVALID), source_length(0), parent(NODE_OFFSET_INVALID), child_start(0), child_count(0), type(ty), flags(0), tag(0)
+ explicit parse_node_t(parse_token_type_t ty) :
+ source_start(SOURCE_OFFSET_INVALID),
+ source_length(0),
+ parent(NODE_OFFSET_INVALID),
+ child_start(0),
+ child_count(0),
+ type(ty),
+ keyword(parse_keyword_none),
+ flags(0),
+ tag(0)
{
}
diff --git a/src/wildcard.cpp b/src/wildcard.cpp
index 6ba4b1a2..db211818 100644
--- a/src/wildcard.cpp
+++ b/src/wildcard.cpp
@@ -139,7 +139,7 @@ bool wildcard_has(const wcstring &str, bool internal)
\param wc The wildcard.
\param is_first Whether files beginning with dots should not be matched against wildcards.
*/
-static enum fuzzy_match_type_t wildcard_match_internal(const wchar_t *str, const wchar_t *wc, bool leading_dots_fail_to_match, bool is_first, enum fuzzy_match_type_t max_type)
+static enum fuzzy_match_type_t wildcard_match_internal(const wchar_t *str, const wchar_t *wc, bool leading_dots_fail_to_match, bool is_first)
{
if (*str == 0 && *wc==0)
{
@@ -154,13 +154,6 @@ static enum fuzzy_match_type_t wildcard_match_internal(const wchar_t *str, const
return wcscmp(str, wc) ? fuzzy_match_none : fuzzy_match_exact;
}
- /* Hackish fuzzy match support */
- if (! wildcard_has(wc, true))
- {
- const string_fuzzy_match_t match = string_fuzzy_match_string(wc, str);
- return (match.type <= max_type ? match.type : fuzzy_match_none);
- }
-
if (*wc == ANY_STRING || *wc == ANY_STRING_RECURSIVE)
{
/* Ignore hidden file */
@@ -178,7 +171,7 @@ static enum fuzzy_match_type_t wildcard_match_internal(const wchar_t *str, const
/* Try all submatches */
do
{
- enum fuzzy_match_type_t subresult = wildcard_match_internal(str, wc+1, leading_dots_fail_to_match, false, max_type);
+ enum fuzzy_match_type_t subresult = wildcard_match_internal(str, wc+1, leading_dots_fail_to_match, false);
if (subresult != fuzzy_match_none)
{
return subresult;
@@ -201,11 +194,11 @@ static enum fuzzy_match_type_t wildcard_match_internal(const wchar_t *str, const
return fuzzy_match_none;
}
- return wildcard_match_internal(str+1, wc+1, leading_dots_fail_to_match, false, max_type);
+ return wildcard_match_internal(str+1, wc+1, leading_dots_fail_to_match, false);
}
else if (*wc == *str)
{
- return wildcard_match_internal(str+1, wc+1, leading_dots_fail_to_match, false, max_type);
+ return wildcard_match_internal(str+1, wc+1, leading_dots_fail_to_match, false);
}
return fuzzy_match_none;
@@ -237,14 +230,19 @@ static wcstring resolve_description(wcstring *completion, const wchar_t *explici
}
}
-/* A transient parameter pack needed by wildcard_complete.f */
+/* A transient parameter pack needed by wildcard_complete. */
struct wc_complete_pack_t
{
const wcstring &orig; // the original string, transient
const wchar_t *desc; // literal description
wcstring(*desc_func)(const wcstring &); // function for generating descriptions
expand_flags_t expand_flags;
- wc_complete_pack_t(const wcstring &str) : orig(str) {}
+ wc_complete_pack_t(const wcstring &str, const wchar_t *des, wcstring(*df)(const wcstring &), expand_flags_t fl) :
+ orig(str),
+ desc(des),
+ desc_func(df),
+ expand_flags(fl)
+ {}
};
/* Weirdly specific and non-reusable helper function that makes its one call site much clearer */
@@ -412,24 +410,16 @@ bool wildcard_complete(const wcstring &str,
{
// Note out may be NULL
assert(wc != NULL);
- wc_complete_pack_t params(str);
- params.desc = desc;
- params.desc_func = desc_func;
- params.expand_flags = expand_flags;
+ wc_complete_pack_t params(str, desc, desc_func, expand_flags);
return wildcard_complete_internal(str.c_str(), wc, params, flags, out, true /* first call */);
}
bool wildcard_match(const wcstring &str, const wcstring &wc, bool leading_dots_fail_to_match)
{
- enum fuzzy_match_type_t match = wildcard_match_internal(str.c_str(), wc.c_str(), leading_dots_fail_to_match, true /* first */, fuzzy_match_exact);
+ enum fuzzy_match_type_t match = wildcard_match_internal(str.c_str(), wc.c_str(), leading_dots_fail_to_match, true /* first */);
return match != fuzzy_match_none;
}
-
-enum fuzzy_match_type_t wildcard_match_fuzzy(const wcstring &str, const wcstring &wc, bool leading_dots_fail_to_match, enum fuzzy_match_type_t max_type)
-{
- return wildcard_match_internal(str.c_str(), wc.c_str(), leading_dots_fail_to_match, true /* first */, max_type);
-}
/**
Obtain a description string for the file specified by the filename.
@@ -827,7 +817,7 @@ class wildcard_expander_t
public:
- wildcard_expander_t(const wcstring pref, const wcstring &orig_base, const wchar_t *orig_wc, expand_flags_t f, std::vector<completion_t> *r) :
+ wildcard_expander_t(const wcstring &pref, const wcstring &orig_base, const wchar_t *orig_wc, expand_flags_t f, std::vector<completion_t> *r) :
prefix(pref),
original_base(orig_base),
original_wildcard(orig_wc),
diff --git a/src/wildcard.h b/src/wildcard.h
index 87ae147d..3a9a869f 100644
--- a/src/wildcard.h
+++ b/src/wildcard.h
@@ -77,9 +77,6 @@ int wildcard_expand_string(const wcstring &wc, const wcstring &working_directory
*/
bool wildcard_match(const wcstring &str, const wcstring &wc, bool leading_dots_fail_to_match = false);
-/* Like wildcard_match, but returns a fuzzy match type */
-enum fuzzy_match_type_t wildcard_match_fuzzy(const wcstring &str, const wcstring &wc, bool leading_dots_fail_to_match = false, enum fuzzy_match_type_t max_type = fuzzy_match_none);
-
/** Check if the specified string contains wildcards */
bool wildcard_has(const wcstring &, bool internal);
bool wildcard_has(const wchar_t *, bool internal);