From nobody  Thu Sep  4 06:24:46 1997
Received: (from nobody@localhost)
          by hub.freebsd.org (8.8.7/8.8.7) id GAA27103;
          Thu, 4 Sep 1997 06:24:46 -0700 (PDT)
Message-Id: <199709041324.GAA27103@hub.freebsd.org>
Date: Thu, 4 Sep 1997 06:24:46 -0700 (PDT)
From: odip@bionet.nsc.ru
To: freebsd-gnats-submit@freebsd.org
Subject: Locale bug in /usr/bin/write
X-Send-Pr-Version: www-1.0

>Number:         4466
>Category:       bin
>Synopsis:       Locale bug in /usr/bin/write
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    ache
>State:          closed
>Quarter:
>Keywords:
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Sep  4 06:30:00 PDT 1997
>Closed-Date:    Sun Sep 14 17:08:33 PDT 1997
>Last-Modified:  Sun Sep 14 17:09:04 PDT 1997
>Originator:     Dmitry Grigorovich
>Release:        FreeBSD 2.2-970618-RELENG
>Organization:
Institute of Cytology and Genetics, Russia
>Environment:
FreeBSD elemental.bionet.nsc.ru 2.2-970618-RELENG FreeBSD 2.2-970618-RELENG #0:
Tue Sep  2 17:15:16 NSS 1997     root@elemental.bionet.nsc.ru:/usr/src/sys/compile/ODIP  i386

>Description:
The program /usr/bin/write not setup locale information,
and when print some native specific symbols ( with codes
in range 0x80-0xFF ) it prints next three codes: 'M', '-', char&~0x80,
because function isprint(char) on such symbols is false !

>How-To-Repeat:
Try setup native locale, e.g. KOI8-R
then write to self some native symbols and you see problem !


>Fix:
#### patch /usr/src/usr.bin/write/write.c ####
--- write.c.orig        Sat Oct 26 22:29:24 1996
+++ write.c     Thu Sep  4 20:03:00 1997
@@ -56,6 +56,8 @@
 #include <stdio.h>
 #include <string.h>

+#include <locale.h>
+
 extern int errno;

 main(argc, argv)
@@ -68,6 +70,8 @@
        int msgsok, myttyfd;
        char tty[MAXPATHLEN], *mytty, *ttyname();
        void done();
+
+       (void)setlocale(LC_CTYPE, "");

        /* check that sender has write enabled */
        if (isatty(fileno(stdin)))

>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->ache 
Responsible-Changed-By: wosch 
Responsible-Changed-When: Sun Sep 14 12:34:39 PDT 1997 
Responsible-Changed-Why:  
Internationalization is Andrey A. Chernov area. 
State-Changed-From-To: open->closed 
State-Changed-By: ache 
State-Changed-When: Sun Sep 14 17:08:33 PDT 1997 
State-Changed-Why:  
Fixed in write.c v1.8 
>Unformatted:
