Date: Fri, 14 Mar 2003 12:18:15 +0700 (KRAT) From: Eugene Grosbein <eugen@grosbein.pp.ru> To: FreeBSD-gnats-submit@FreeBSD.org Cc: obrien@FreeBSD.org Subject: ports/49996: [PATCH] The port net/tcpshow does not use locale Message-ID: <200303140518.h2E5IFam093142@gw2.svzserv.kemerovo.su>
next in thread | raw e-mail | index | archive | help
>Number: 49996 >Category: ports >Synopsis: [PATCH] The port net/tcpshow does not use locale >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-ports-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Thu Mar 13 21:20:04 PST 2003 >Closed-Date: >Last-Modified: >Originator: Eugene Grosbein >Release: FreeBSD 4.8-RC i386 >Organization: Svyaz Service JSC >Environment: System: FreeBSD gw2.svzserv.kemerovo.su 4.8-RC FreeBSD 4.8-RC #12: Tue Mar 4 02:15:40 KRAT 2003 sa@gw2.svzserv.kemerovo.su:/usr/obj/usr/src/sys/GW2 i386 >Description: 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. >How-To-Repeat: Use tcpshow in an environment where traffic contain national characters. All of them are replaced with dots. >Fix: Add the following patch to the port. It enables tcpshow to understand LC_CTYPE and LC_ALL (in this order). --- 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) Eugene Grosbein >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-ports-bugs" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200303140518.h2E5IFam093142>