Remove a bunch of dead code identified by cppcheck

This commit is contained in:
ridiculousfish
2014-10-31 01:15:50 -07:00
parent a529fc9d83
commit 7ac593273e
20 changed files with 14 additions and 462 deletions

View File

@@ -141,85 +141,6 @@ bool path_get_path(const wcstring &cmd, wcstring *out_path)
return path_get_path_core(cmd, out_path, env_get_string(L"PATH"));
}
bool path_get_cdpath_string(const wcstring &dir_str, wcstring &result, const env_var_t &cdpath)
{
wchar_t *res = 0;
int err = ENOENT;
bool success = false;
const wchar_t *const dir = dir_str.c_str();
if (dir[0] == L'/'|| (wcsncmp(dir, L"./", 2)==0))
{
struct stat buf;
if (wstat(dir, &buf) == 0)
{
if (S_ISDIR(buf.st_mode))
{
result = dir_str;
success = true;
}
else
{
err = ENOTDIR;
}
}
}
else
{
wcstring path = L".";
// Respect CDPATH
env_var_t cdpath = env_get_string(L"CDPATH");
if (! cdpath.missing_or_empty())
{
path = cdpath.c_str();
}
wcstokenizer tokenizer(path, ARRAY_SEP_STR);
wcstring next_path;
while (tokenizer.next(next_path))
{
expand_tilde(next_path);
if (next_path.size() == 0) continue;
wcstring whole_path = next_path;
append_path_component(whole_path, dir);
struct stat buf;
if (wstat(whole_path, &buf) == 0)
{
if (S_ISDIR(buf.st_mode))
{
result = whole_path;
success = true;
break;
}
else
{
err = ENOTDIR;
}
}
else
{
if (lwstat(whole_path, &buf) == 0)
{
err = EROTTEN;
}
}
}
}
if (!success)
{
errno = err;
}
return res;
}
bool path_get_cdpath(const wcstring &dir, wcstring *out, const wchar_t *wd, const env_vars_snapshot_t &env_vars)
{
int err = ENOENT;