mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-27 05:13:10 +00:00
drop ported C++ functions
Remove the following C++ functions/methods, which have all been ported to Rust and no longer have any callers in C++: common.cpp: - assert_is_locked/ASSERT_IS_LOCKED path.cpp: - path_make_canonical wutil.cpp: - wreadlink - fish_iswgraph - file_id_t::older_than
This commit is contained in:
parent
493cbeb84c
commit
0037e6e98d
6 changed files with 0 additions and 94 deletions
|
@ -1177,17 +1177,6 @@ void restore_term_foreground_process_group_for_exit() {
|
|||
}
|
||||
}
|
||||
|
||||
void assert_is_locked(std::mutex &mutex, const char *who, const char *caller) {
|
||||
// Note that std::mutex.try_lock() is allowed to return false when the mutex isn't
|
||||
// actually locked; fortunately we are checking the opposite so we're safe.
|
||||
if (unlikely(mutex.try_lock())) {
|
||||
FLOGF(error, L"%s is not locked when it should be in '%s'", who, caller);
|
||||
FLOG(error, L"Break on debug_thread_error to debug.");
|
||||
debug_thread_error();
|
||||
mutex.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
/// Test if the specified character is in a range that fish uses internally to store special tokens.
|
||||
///
|
||||
/// NOTE: This is used when tokenizing the input. It is also used when reading input, before
|
||||
|
|
|
@ -320,11 +320,6 @@ bool should_suppress_stderr_for_tests();
|
|||
#define likely(x) __builtin_expect(bool(x), 1)
|
||||
#define unlikely(x) __builtin_expect(bool(x), 0)
|
||||
|
||||
/// Useful macro for asserting that a lock is locked. This doesn't check whether this thread locked
|
||||
/// it, which it would be nice if it did, but here it is anyways.
|
||||
void assert_is_locked(std::mutex &mutex, const char *who, const char *caller);
|
||||
#define ASSERT_IS_LOCKED(m) assert_is_locked(m, #m, __FUNCTION__)
|
||||
|
||||
/// Format the specified size (in bytes, kilobytes, etc.) into the specified stringbuffer.
|
||||
wcstring format_size(long long sz);
|
||||
|
||||
|
|
21
src/path.cpp
21
src/path.cpp
|
@ -384,27 +384,6 @@ dir_remoteness_t path_get_data_remoteness() { return get_data_directory().remote
|
|||
|
||||
dir_remoteness_t path_get_config_remoteness() { return get_config_directory().remoteness; }
|
||||
|
||||
void path_make_canonical(wcstring &path) {
|
||||
// Ignore trailing slashes, unless it's the first character.
|
||||
size_t len = path.size();
|
||||
while (len > 1 && path.at(len - 1) == L'/') len--;
|
||||
|
||||
// Turn runs of slashes into a single slash.
|
||||
size_t trailing = 0;
|
||||
bool prev_was_slash = false;
|
||||
for (size_t leading = 0; leading < len; leading++) {
|
||||
wchar_t c = path.at(leading);
|
||||
bool is_slash = (c == '/');
|
||||
if (!prev_was_slash || !is_slash) {
|
||||
// This is either the first slash in a run, or not a slash at all.
|
||||
path.at(trailing++) = c;
|
||||
}
|
||||
prev_was_slash = is_slash;
|
||||
}
|
||||
assert(trailing <= len);
|
||||
if (trailing < len) path.resize(trailing);
|
||||
}
|
||||
|
||||
bool paths_are_equivalent(const wcstring &p1, const wcstring &p2) {
|
||||
if (p1 == p2) return true;
|
||||
|
||||
|
|
|
@ -86,10 +86,6 @@ std::vector<wcstring> path_apply_cdpath(const wcstring &dir, const wcstring &wd,
|
|||
maybe_t<wcstring> path_as_implicit_cd(const wcstring &path, const wcstring &wd,
|
||||
const environment_t &vars);
|
||||
|
||||
/// Remove double slashes and trailing slashes from a path, e.g. transform foo//bar/ into foo/bar.
|
||||
/// The string is modified in-place.
|
||||
void path_make_canonical(wcstring &path);
|
||||
|
||||
/// Check if two paths are equivalent, which means to ignore runs of multiple slashes (or trailing
|
||||
/// slashes).
|
||||
bool paths_are_equivalent(const wcstring &p1, const wcstring &p2);
|
||||
|
|
|
@ -284,29 +284,6 @@ int make_fd_blocking(int fd) {
|
|||
return err == -1 ? errno : 0;
|
||||
}
|
||||
|
||||
maybe_t<wcstring> wreadlink(const wcstring &file_name) {
|
||||
struct stat buf;
|
||||
if (lwstat(file_name, &buf) == -1) {
|
||||
return none();
|
||||
}
|
||||
ssize_t bufsize = buf.st_size + 1;
|
||||
char target_buf[bufsize];
|
||||
const std::string tmp = wcs2zstring(file_name);
|
||||
ssize_t nbytes = readlink(tmp.c_str(), target_buf, bufsize);
|
||||
if (nbytes == -1) {
|
||||
wperror(L"readlink");
|
||||
return none();
|
||||
}
|
||||
// The link might have been modified after our call to lstat. If the link now points to a path
|
||||
// that's longer than the original one, we can't read everything in our buffer. Simply give
|
||||
// up. We don't need to report an error since our only caller will already fall back to ENOENT.
|
||||
if (nbytes == bufsize) {
|
||||
return none();
|
||||
}
|
||||
|
||||
return str2wcstring(target_buf, nbytes);
|
||||
}
|
||||
|
||||
/// Wide character realpath. The last path component does not need to be valid. If an error occurs,
|
||||
/// wrealpath() returns none() and errno is likely set.
|
||||
maybe_t<wcstring> wrealpath(const wcstring &pathname) {
|
||||
|
@ -608,14 +585,6 @@ int fish_iswalnum(wint_t wc) {
|
|||
return iswalnum(wc);
|
||||
}
|
||||
|
||||
/// We need this because there are too many implementations that don't return the proper answer for
|
||||
/// some code points. See issue #3050.
|
||||
int fish_iswgraph(wint_t wc) {
|
||||
if (fish_reserved_codepoint(wc)) return 0;
|
||||
if (fish_is_pua(wc)) return 1;
|
||||
return iswgraph(wc);
|
||||
}
|
||||
|
||||
/// Convenience variants on fish_wcwswidth().
|
||||
///
|
||||
/// See fallback.h for the normal definitions.
|
||||
|
@ -870,22 +839,6 @@ static int compare(T a, T b) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
/// \return true if \param rhs has higher mtime seconds than this file_id_t.
|
||||
/// If identical, nanoseconds are compared.
|
||||
bool file_id_t::older_than(const file_id_t &rhs) const {
|
||||
int ret = compare(mod_seconds, rhs.mod_seconds);
|
||||
if (!ret) ret = compare(mod_nanoseconds, rhs.mod_nanoseconds);
|
||||
switch (ret) {
|
||||
case -1:
|
||||
return true;
|
||||
case 1:
|
||||
case 0:
|
||||
return false;
|
||||
default:
|
||||
DIE("unreachable");
|
||||
}
|
||||
}
|
||||
|
||||
int file_id_t::compare_file_id(const file_id_t &rhs) const {
|
||||
// Compare each field, stopping when we get to a non-equal field.
|
||||
int ret = 0;
|
||||
|
|
|
@ -86,9 +86,6 @@ void wperror(wcharz_t s);
|
|||
/// Wide character version of getcwd().
|
||||
wcstring wgetcwd();
|
||||
|
||||
/// Wide character version of readlink().
|
||||
maybe_t<wcstring> wreadlink(const wcstring &file_name);
|
||||
|
||||
/// Wide character version of realpath function.
|
||||
/// \returns the canonicalized path, or none if the path is invalid.
|
||||
maybe_t<wcstring> wrealpath(const wcstring &pathname);
|
||||
|
@ -139,10 +136,8 @@ inline ssize_t wwrite_to_fd(const wcstring &s, int fd) {
|
|||
// some code points. See issue #3050.
|
||||
#ifndef FISH_NO_ISW_WRAPPERS
|
||||
#define iswalnum fish_iswalnum
|
||||
#define iswgraph fish_iswgraph
|
||||
#endif
|
||||
int fish_iswalnum(wint_t wc);
|
||||
int fish_iswgraph(wint_t wc);
|
||||
|
||||
int fish_wcswidth(const wchar_t *str);
|
||||
int fish_wcswidth(const wcstring &str);
|
||||
|
@ -178,7 +173,6 @@ struct file_id_t {
|
|||
bool operator<(const file_id_t &rhs) const;
|
||||
|
||||
static file_id_t from_stat(const struct stat &buf);
|
||||
bool older_than(const file_id_t &rhs) const;
|
||||
wcstring dump() const;
|
||||
|
||||
private:
|
||||
|
|
Loading…
Reference in a new issue