about summary refs log tree commit
diff options
context:
space:
mode:
authorGraham Barr <gbarr@pobox.com>2001-10-26 14:47:16 +0000
committerGraham Barr <gbarr@pobox.com>2001-10-26 14:47:16 +0000
commit85fee191d6003659f0c16e118bba4b3bc2312cfe (patch)
treeff6862cfc51ef873e754e3702495a84d39fc50d8
parent2c49bd1ad119155067137abcb0610678b9606ee1 (diff)
downloadperl-libnet-85fee191d6003659f0c16e118bba4b3bc2312cfe.tar.gz
Net::Cmd
- Ensure we don't insert an extra CR during LF=>CRLF when the CR already exists

-rw-r--r--Net/Cmd.pm10
1 files 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 <gbarr@pobox.com>. 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 <hr>
 
-I<$Id: //depot/libnet/Net/Cmd.pm#25 $>
+I<$Id: //depot/libnet/Net/Cmd.pm#26 $>
 
 =cut