mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-06-02 05:41:16 -03:00
Resurrect io_print
This commit is contained in:
19
src/io.cpp
19
src/io.cpp
@@ -222,21 +222,15 @@ void io_chain_t::append(const io_chain_t &chain) {
|
||||
this->insert(this->end(), chain.begin(), chain.end());
|
||||
}
|
||||
|
||||
#if 0
|
||||
// This isn't used so the lint tools were complaining about its presence. I'm keeping it in the
|
||||
// source because it could be useful for debugging.
|
||||
void io_print(const io_chain_t &chain)
|
||||
{
|
||||
if (chain.empty())
|
||||
{
|
||||
std::fwprintf(stderr, L"Empty chain %p\n", &chain);
|
||||
void io_chain_t::print() const {
|
||||
if (this->empty()) {
|
||||
std::fwprintf(stderr, L"Empty chain %p\n", this);
|
||||
return;
|
||||
}
|
||||
|
||||
std::fwprintf(stderr, L"Chain %p (%ld items):\n", &chain, (long)chain.size());
|
||||
for (size_t i=0; i < chain.size(); i++)
|
||||
{
|
||||
const shared_ptr<io_data_t> &io = chain.at(i);
|
||||
std::fwprintf(stderr, L"Chain %p (%ld items):\n", this, (long)this->size());
|
||||
for (size_t i = 0; i < this->size(); i++) {
|
||||
const auto &io = this->at(i);
|
||||
if (io.get() == nullptr)
|
||||
{
|
||||
std::fwprintf(stderr, L"\t(null)\n");
|
||||
@@ -248,7 +242,6 @@ void io_print(const io_chain_t &chain)
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
int move_fd_to_unused(int fd, const io_chain_t &io_chain, bool cloexec) {
|
||||
if (fd < 0 || io_chain.io_for_fd(fd).get() == nullptr) {
|
||||
|
||||
7
src/io.h
7
src/io.h
@@ -346,6 +346,9 @@ class io_chain_t : public std::vector<io_data_ref_t> {
|
||||
/// \return the last io redirection in the chain for the specified file descriptor, or nullptr
|
||||
/// if none.
|
||||
io_data_ref_t io_for_fd(int fd) const;
|
||||
|
||||
/// Output debugging information to stderr.
|
||||
void print() const;
|
||||
};
|
||||
|
||||
/// Helper type returned from making autoclose pipes.
|
||||
@@ -436,9 +439,5 @@ struct io_streams_t {
|
||||
explicit io_streams_t(size_t read_limit) : out(read_limit), err(read_limit), stdin_fd(-1) {}
|
||||
};
|
||||
|
||||
#if 0
|
||||
// Print debug information about the specified IO redirection chain to stderr.
|
||||
void io_print(const io_chain_t &chain);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user