Bug 49996 - [PATCH] The port net/tcpshow does not use locale
Summary: [PATCH] The port net/tcpshow does not use locale
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: Normal Affects Only Me
Assignee: David E. O'Brien
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-03-14 05:20 UTC by Eugene Grosbein
Modified: 2003-03-24 08:14 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Eugene Grosbein 2003-03-14 05:20:04 UTC
	
	tcpshow is nice utility allowing to watch application traffic
	in real time. It uses isprint() and replaces unprintable characters
	with a dot ('.'). Unfortunately, it does not use setlocale()
	and cannot show 8-bit national characters even if terminal can.

Fix: Add the following patch to the port. It enables tcpshow
	to understand LC_CTYPE and LC_ALL (in this order).



Eugene Grosbein--zUa0lsWFme10EjBXFYYt7pB7G5LOP4s2h9UZp0rCbYeO22Pz
Content-Type: text/plain; name="file.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="file.diff"

--- tcpshow.c.orig	Fri Mar 14 12:00:19 2003
+++ tcpshow.c	Fri Mar 14 12:07:07 2003
@@ -205,6 +205,7 @@
 #include <unistd.h>
 #include <stdlib.h>
 #include <stdio.h>
+#include <locale.h>
 
 
 /* Some general defines.                                                    */
@@ -1262,6 +1263,15 @@
 
 }
 
+void checklocale(void) {
+
+  char *lc;
+  
+  if ((lc = getenv("LC_CTYPE")) != NULL) setlocale(LC_CTYPE,lc);
+  else if ((lc = getenv("LC_ALL")) != NULL) setlocale(LC_ALL,lc);
+  
+  return;
+}
 
 /****==========------------------------------------------------==========****/
 /*                                                                          */
@@ -1302,6 +1312,8 @@
       }
       else error("Unknown command line flag");
 
+   checklocale();
+   
    if (!cookedFlag)
       forkTcpdump(argc, argv);
    elif (argc != 0)
How-To-Repeat: 	
	Use tcpshow in an environment where traffic contain
	national characters. All of them are replaced with dots.
Comment 1 Tilman Keskinoz freebsd_committer freebsd_triage 2003-03-22 21:05:07 UTC
Responsible Changed
From-To: freebsd-ports-bugs->obrien

Over to Maintainer
Comment 2 David E. O'Brien freebsd_committer freebsd_triage 2003-03-24 08:14:19 UTC
State Changed
From-To: open->closed

committed, thanks!