~nabijaczleweli/voreutils

203b6658f896339ee0bf261261a5786fdedb52f8 — наб 5 days ago f8da734
The filter is very obviously not prefix :v
1 files changed, 10 insertions(+), 4 deletions(-)

M cmd/who.cpp
M cmd/who.cpp => cmd/who.cpp +10 -4
@@ 42,6 42,14 @@ using namespace std::literals;
	"       %1$s [-s] [-{T|w}] [-HaIL]  [-ublrpdt] am I\n"


static_assert(USER_PROCESS >= 0);
static_assert(BOOT_TIME >= 0);
static_assert(LOGIN_PROCESS >= 0);
static_assert(RUN_LVL >= 0);
static_assert(DEAD_PROCESS >= 0);
static_assert(INIT_PROCESS >= 0);
static_assert(OLD_TIME >= 0);
static_assert(NEW_TIME >= 0);
static_assert(USER_PROCESS < 16);
static_assert(BOOT_TIME < 16);
static_assert(LOGIN_PROCESS < 16);


@@ 226,7 234,7 @@ int main(int argc, const char * const * argv) {
				continue;

			auto ut_line = vore::utmpx::line(utx);
			if(ut_line.substr(0, filter.size()) != filter)  // std::string_view::starts_with() is C++20
			if(!filter.empty() && ut_line != filter)
				continue;

			std::optional<struct stat> sb;


@@ 342,9 350,7 @@ int main(int argc, const char * const * argv) {
											break;
										}
								} else if(lookup) {  // && !ips
									struct addrinfo hints {
										.ai_flags = AI_CANONNAME | AI_IDN | AI_CANONIDN
									};
									const struct addrinfo hints { .ai_flags = AI_CANONNAME | AI_IDN | AI_CANONIDN };
									if(struct addrinfo * ai; !getaddrinfo(MAYBE_DUPA(host), nullptr, &hints, &ai)) {
										l.emplace_back(std::move((std::string{'('} += ai->ai_canonname) += ')'));
										freeaddrinfo(ai);