From 6db883c129fb84bbf067861a1def1fd8120a32c8 Mon Sep 17 00:00:00 2001
From: minima <minima>
Date: Wed, 14 Nov 2001 14:13:31 +0000
Subject: [PATCH] move the handling of unprintable characters out of IntMsg

---
 Changes         | 1 +
 perl/DXUtil.pm  | 2 +-
 perl/IntMsg.pm  | 1 -
 perl/console.pl | 6 +++++-
 4 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/Changes b/Changes
index bf7b49c8..632c9b16 100644
--- a/Changes
+++ b/Changes
@@ -1,6 +1,7 @@
 14Nov01=======================================================================
 1. make the number of characters of the dx comment dependant on the type of
 connection. This should mean that 'legacy' user programs can cope.
+2. move the handling of unprintable characters out of IntMsg
 07Nov01=======================================================================
 1. fix is_pctext so that it actually catches corrupt spots and announces.
 2. fix console.pl so that you can type in '0' again
diff --git a/perl/DXUtil.pm b/perl/DXUtil.pm
index ed714fe8..6cf35b2b 100644
--- a/perl/DXUtil.pm
+++ b/perl/DXUtil.pm
@@ -165,7 +165,7 @@ sub phex
 sub parray
 {
 	my $ref = shift;
-	return join(', ', @{$ref});
+	return ref $ref ? join(', ', @{$ref}) : $ref;
 }
 
 # take the arg as an array reference and print as a list of pairs
diff --git a/perl/IntMsg.pm b/perl/IntMsg.pm
index 190d0b43..95c6ac74 100644
--- a/perl/IntMsg.pm
+++ b/perl/IntMsg.pm
@@ -44,7 +44,6 @@ sub dequeue
 		for (@lines) {
 			if (defined $_) {
 				s/\%([0-9A-F][0-9A-F])/chr(hex($1))/eg;
-				s/[\x00-\x08\x0a-\x19\x1b-\x1f\x80-\x9f]/./g;         # immutable CSI sequence + control characters
 			} else {
 				$_ = '';
 			}
diff --git a/perl/console.pl b/perl/console.pl
index eae1c0ff..41fc953e 100755
--- a/perl/console.pl
+++ b/perl/console.pl
@@ -224,6 +224,9 @@ sub addtotop
 {
 	while (@_) {
 		my $inbuf = shift;
+		if ($inbuf =~ s/\x07+$//) {
+			beep();
+		}
 		push @shistory, $inbuf;
 		shift @shistory if @shistory > $maxshist;
 	}
@@ -240,6 +243,7 @@ sub rec_socket
 	if (defined $msg) {
 		my ($sort, $call, $line) = $msg =~ /^(\w)([^\|]+)\|(.*)$/;
 		
+		$line =~ s/[\x00-\x06\x08\x0a-\x19\x1b-\x1f\x80-\x9f\xf0-\xff]/./g;         # immutable CSI sequence + control characters
 		if ($sort && $sort eq 'D') {
 			$line = " " unless length($line);
 			addtotop($line);
@@ -482,7 +486,7 @@ $SIG{__DIE__} = \&sig_term;
 
 $conn->send_later("A$call|$connsort width=$cols");
 $conn->send_later("I$call|set/page $maxshist");
-$conn->send_later("I$call|set/nobeep");
+#$conn->send_later("I$call|set/nobeep");
 
 #Msg->set_event_handler(\*STDIN, "read" => \&rec_stdin);
 
-- 
2.43.0