[padb-devel] [padb commit] r93 - Parse multi-line output over sockets better, the previous
codesite-noreply at google.com
codesite-noreply at google.com
Wed Jul 8 20:03:35 BST 2009
Author: apittman
Date: Wed Jul 8 12:02:34 2009
New Revision: 93
Modified:
branches/full-duplex/src/padb
Log:
Parse multi-line output over sockets better, the previous
regexp was loosing data if there was more than one line
to be read at a time. Not a problem for most things as the
comms protocol is line based but for debugging the inner
processes it made it harder.
Modified: branches/full-duplex/src/padb
==============================================================================
--- branches/full-duplex/src/padb (original)
+++ branches/full-duplex/src/padb Wed Jul 8 12:02:34 2009
@@ -3126,10 +3126,17 @@
$str =~ s/\r//g;
# Allow multi-line output here, making sure we process each line.
- while ( $str =~ /^([^\n]+)\n(.*)$/ ) {
+ while ( $str =~ /^([^\n]+)\n/ ) {
$sd->{line_cb}( $handle, $sd, $1 );
- $sd->{str} = $2;
- $str = $2;
+ my $len = length($1);
+ my $flen = length($str);
+ if ( ( $len + 1 ) != $flen ) {
+ $str = substr( $str, $len + 1, $flen - $len );
+ } else {
+ $str = "";
+
+ }
+ $sd->{str} = $str;
}
return;
More information about the padb-devel
mailing list