mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-06-04 07:21:14 -03:00
Remove a bunch of dead code identified by cppcheck
This commit is contained in:
79
path.cpp
79
path.cpp
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user