Resurrect io_print

This commit is contained in:
ridiculousfish
2019-12-10 17:05:17 -08:00
parent d4a3b30b73
commit 0573e95b03
2 changed files with 9 additions and 17 deletions

View File

@@ -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) {

View File

@@ -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