- $search = $pattern ? "\$ref->[1] =~ /$pattern/" : '1' ;
- $eval = qq(
- my \$c;
- my \$ref;
- for (\$c = \$#in; \$c >= 0; \$c--) {
- \$ref = \$in[\$c];
- if ($search) {
- \$count++;
- next if \$count < $from;
- push \@out, print_item(\$ref);
- last LOOP if \$count >= \$to; # stop after n
- }
- }
- );
+ $who = uc $who if defined $who;
+
+ if ($pattern) {
+ $hint = "m{\\Q$pattern\\E}i";
+ } else {
+ $hint = "!m{\\^(?:ann|rcmd|talk|chat)\\^}";
+ }
+ if ($who) {
+ $hint .= ' && ' if $hint;
+ $hint .= 'm{\\Q$who\\E}i';
+ }
+ $hint = "next unless $hint" if $hint;
+ $hint .= ";next unless /^\\d+\\^$pattern\\^/" if $pattern;
+ $hint ||= "";
+
+ $eval = qq(while (<\$fh>) {
+ $hint;
+ chomp;
+ \$ring->write(\$_);
+ } );
+
+ if (isdbg('search')) {
+ dbg("sh/log hint: $hint");
+ dbg("sh/log eval: $eval");
+ }