Blob
Date:
Fri Aug 26 22:03:55 2022
UTC
Message:
refactor the parsing into the module
change the mscan format string to siplify the parsing, and refactor
the parsing code into the module for reuse.
pe is an exception in that it doesn't care about the format string, it
just need to decide if the current line starts a new thread or not,
that's why it doesn't use the newly introduced `parse'. The new
format simplifies pe too though.
#!/usr/bin/env perluse open ":std", ":encoding(UTF-8)";use strict;use warnings;use v5.32;use IO::Poll qw(POLLOUT);use OpenBSD::Pledge;use OpenBSD::Unveil;my $jobs = $ENV{'MAKE_JOBS'} // 1;my $poll = IO::Poll->new();for (1..$jobs) {open(my $kid, '|-', './mexp') or die "can't exec ./mexp: $!";$poll->mask($kid => POLLOUT);}sub process {die "poll: $!" if $poll->poll() == -1;my @handles = $poll->handles(POLLOUT) or die "no procs ready?";my $handle = $handles[int(rand(@handles))];print $handle $_ foreach @_;}unveil("./mexp", "rx") or die "unveil mexp: $!";pledge("stdio proc exec") or die "pledge: $!";my @thread;while (<>) {print; # continue the pipelinemy $new_thread = m/^-/;if ($new_thread && @thread) {process @thread;@thread = ();}push @thread, $_;}process @thread if @thread;
Omar Polo