-while (<STDIN>) {
- my $addr;
- my $n;
- my $awaiting = "";
-
- CLASSIFY: {
-
- my $thread = "";
- if ( $_ =~ /^(0x[[:xdigit:]]+):/ ) {
- $thr_addr{$1} = ++$thr_nums unless defined $thr_addr{$1};
- $thread = "thread" . $thr_addr{$1} . ":";
- $_ =~ s/^[^:]*://;
- }
-
- # Transform window pointer addresses so it's easier to compare logs
- $awaiting = "curscr" if ( $_ =~ /creating curscr/ );
- $awaiting = "newscr" if ( $_ =~ /creating newscr/ );
- $awaiting = "stdscr" if ( $_ =~ /creating stdscr/ );
- $awaiting = "screen" if ( $_ =~ /^(\+ )*called {new_prescr\(\)/ );
- if ( $_ =~ /^create :window 0x([[:xdigit:]]+)/ ) {
- $addr = "0x$1";
- if ( $awaiting eq "curscr" ) {
- $curscr = $addr;
- }
- elsif ( $awaiting eq "newscr" ) {
- $newscr = $addr;
+sub muncher($) {
+ my $STDIN = shift;
+
+ while (<$STDIN>) {
+ my $addr;
+ my $n;
+ my $awaiting = "";
+
+ CLASSIFY: {
+
+ # just in case someone tries a file with cr/lf line-endings:
+ $_ =~ s/\r\n/\n/g;
+ $_ =~ s/\r/\n/g;
+
+ my $thread = "";
+ if ( $_ =~ /^(0x[[:xdigit:]]+):/ ) {
+ $thr_addr{$1} = ++$thr_nums unless defined $thr_addr{$1};
+ $thread = "thread" . $thr_addr{$1} . ":";
+ $_ =~ s/^[^:]*://;