and don't forget the line ending mod in here as well!
[spider.git] / perl / IntMsg.pm
index 6e588b3ef7ddbb86c0165e229d37181c08179253..190d0b43c49b4bcaafb8c6d62511af31d30a2270 100644 (file)
 package IntMsg;
 
 use strict;
+
+use vars qw($VERSION $BRANCH);
+$VERSION = sprintf( "%d.%03d", q$Revision$ =~ /(\d+)\.(\d+)/ );
+$BRANCH = sprintf( "%d.%03d", q$Revision$ =~ /\d+\.\d+\.(\d+)\.(\d+)/ ) || 0;
+$main::build += $VERSION;
+$main::branch += $BRANCH;
+
 use Msg;
 
 use vars qw(@ISA);
@@ -27,12 +34,12 @@ sub dequeue
 {
        my $conn = shift;
 
-       if ($conn->{msg} =~ /\n/) {
-               my @lines = split /\r?\n/, $conn->{msg};
-               if ($conn->{msg} =~ /\n$/) {
+       if ($conn && $conn->{msg} =~ /\cJ/) {
+               my @lines =  $conn->{msg} =~ /([^\cM\cJ]*)\cM?\cJ/g;
+               if ($conn->{msg} =~ /\cJ$/) {
                        delete $conn->{msg};
                } else {
-                       $conn->{msg} = pop @lines;
+                       $conn->{msg} =~ s/([^\cM\cJ]*)\cM?\cJ//g;
                }
                for (@lines) {
                        if (defined $_) {
@@ -41,7 +48,7 @@ sub dequeue
                        } else {
                                $_ = '';
                        }
-                       &{$conn->{rproc}}($conn, $_);
+                       &{$conn->{rproc}}($conn, $_) if exists $conn->{rproc};
                }
        }
 }