mirror of
https://github.com/fish-shell/fish-shell.git
synced 2025-02-21 09:58:54 +08:00
Remove some dead code
This commit is contained in:
parent
4f01eef88d
commit
273afca3da
53
src/cancellable.h
Normal file
53
src/cancellable.h
Normal file
@ -0,0 +1,53 @@
|
||||
#ifndef FISH_CANCELLABLE_H
|
||||
#define FISH_CANCELLABLE_H
|
||||
|
||||
#include "maybe.h"
|
||||
|
||||
/// A simple value type representing cancellation via a signal.
|
||||
struct cancellation_t {
|
||||
int signal;
|
||||
|
||||
explicit cancellation_t(int sig) : signal(sig) {}
|
||||
};
|
||||
|
||||
/// A cancellable_t<T> is a wrapper around T which may be cancelled, for example by a signal.
|
||||
template <typename T>
|
||||
class cancellable_t : private maybe_t<T> {
|
||||
using super = maybe_t<T>;
|
||||
|
||||
public:
|
||||
/// Construct from a T.
|
||||
/* implicit */ cancellable_t(T &&v) : super(v) {}
|
||||
/* implicit */ cancellable_t(const T &v) : super(v) {}
|
||||
|
||||
/// Construct from a cancellation.
|
||||
/* implicit */ cancellable_t(cancellation_t c) : super(none()), signal_(c.signal) {}
|
||||
|
||||
cancellable_t(const cancellable_t &) = default;
|
||||
cancellable_t(cancellable_t &&) = default;
|
||||
|
||||
/// Access the cancellation signal, if this was cancelled.
|
||||
int signal() const {
|
||||
assert(!has_value() && "Not cancelled");
|
||||
return signal_;
|
||||
}
|
||||
|
||||
/// \return whether this was cancelled.
|
||||
bool is_cancelled() const { return !has_value(); }
|
||||
|
||||
// Expose maybe_t<T>::value and dereferencing.
|
||||
using super::has_value;
|
||||
using super::value;
|
||||
using super::operator->;
|
||||
using super::operator*;
|
||||
|
||||
/// Notice we don't compare signals when checking for equality.
|
||||
bool operator==(const cancellable_t &rhs) const { super::operator==(rhs); }
|
||||
bool operator!=(const cancellable_t &rhs) const { super::operator!=(rhs); }
|
||||
|
||||
private:
|
||||
// The cancellation signal.
|
||||
int signal_{0};
|
||||
};
|
||||
|
||||
#endif
|
@ -250,38 +250,6 @@ bool is_windows_subsystem_for_linux() {
|
||||
}
|
||||
#endif // HAVE_BACKTRACE_SYMBOLS
|
||||
|
||||
int fgetws2(wcstring *s, FILE *f) {
|
||||
int i = 0;
|
||||
wint_t c;
|
||||
|
||||
while (true) {
|
||||
errno = 0;
|
||||
|
||||
c = std::fgetwc(f);
|
||||
if (errno == EILSEQ || errno == EINTR) {
|
||||
continue;
|
||||
}
|
||||
|
||||
switch (c) {
|
||||
// End of line.
|
||||
case WEOF:
|
||||
case L'\n':
|
||||
case L'\0': {
|
||||
return i;
|
||||
}
|
||||
// Ignore carriage returns.
|
||||
case L'\r': {
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
i++;
|
||||
s->push_back(static_cast<wchar_t>(c));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Converts the narrow character string \c in into its wide equivalent, and return it.
|
||||
///
|
||||
/// The string may contain embedded nulls.
|
||||
|
14
src/common.h
14
src/common.h
@ -269,14 +269,6 @@ std::shared_ptr<T> move_to_sharedptr(T &&v) {
|
||||
/// Print a stack trace to stderr.
|
||||
void show_stackframe(const wchar_t msg_level, int frame_count = 100, int skip_levels = 0);
|
||||
|
||||
/// Read a line from the stream f into the string. Returns the number of bytes read or -1 on
|
||||
/// failure.
|
||||
///
|
||||
/// If the carriage return character is encountered, it is ignored. fgetws() considers the line to
|
||||
/// end if reading the file results in either a newline (L'\n') character, the null (L'\\0')
|
||||
/// character or the end of file (WEOF) character.
|
||||
int fgetws2(wcstring *s, FILE *f);
|
||||
|
||||
/// Returns a wide character string equivalent of the specified multibyte character string.
|
||||
///
|
||||
/// This function encodes illegal character sequences in a reversible way using the private use
|
||||
@ -768,12 +760,6 @@ std::unique_ptr<T> make_unique(Args &&... args) {
|
||||
/// \param in the position of the opening quote.
|
||||
wchar_t *quote_end(const wchar_t *pos);
|
||||
|
||||
/// A call to this function will reset the error counter. Some functions print out non-critical
|
||||
/// error messages. These should check the error_count before, and skip printing the message if
|
||||
/// MAX_ERROR_COUNT messages have been printed. The error_reset() should be called after each
|
||||
/// interactive command executes, to allow new messages to be printed.
|
||||
void error_reset();
|
||||
|
||||
/// This function should be called after calling `setlocale()` to perform fish specific locale
|
||||
/// initialization.
|
||||
void fish_setlocale();
|
||||
|
Loading…
x
Reference in New Issue
Block a user