From 85fee191d6003659f0c16e118bba4b3bc2312cfe Mon Sep 17 00:00:00 2001 From: Graham Barr Date: Fri, 26 Oct 2001 14:47:16 +0000 Subject: Net::Cmd - Ensure we don't insert an extra CR during LF=>CRLF when the CR already exists --- Net/Cmd.pm | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Net/Cmd.pm b/Net/Cmd.pm index a23a437..40510e5 100644 --- a/Net/Cmd.pm +++ b/Net/Cmd.pm @@ -1,4 +1,4 @@ -# Net::Cmd.pm $Id: //depot/libnet/Net/Cmd.pm#25 $ +# Net::Cmd.pm $Id: //depot/libnet/Net/Cmd.pm#26 $ # # Copyright (c) 1995-1997 Graham Barr . All rights reserved. # This program is free software; you can redistribute it and/or @@ -20,7 +20,7 @@ BEGIN { } } -$VERSION = "2.19"; +$VERSION = "2.20"; @ISA = qw(Exporter); @EXPORT = qw(CMD_INFO CMD_OK CMD_MORE CMD_REJECT CMD_ERROR CMD_PENDING); @@ -403,7 +403,9 @@ sub datasend print STDERR $b,join("\n$b",split(/\n/,$line)),"\n"; } - $line =~ s/\n/\015\012/sgo; + # Translate LF => CRLF, but not if the LF is + # already preceeded by a CR + $line =~ s/\G()\n|([^\r\n])\n/$+\015\012/sgo; ${*$cmd}{'net_cmd_lastch'} ||= " "; $line = ${*$cmd}{'net_cmd_lastch'} . $line; @@ -639,6 +641,6 @@ it under the same terms as Perl itself. =for html
-I<$Id: //depot/libnet/Net/Cmd.pm#25 $> +I<$Id: //depot/libnet/Net/Cmd.pm#26 $> =cut -- cgit v1.2.3-24-ge0c7