From gpr@nvnpp.vrn.ru  Mon Mar 11 22:36:09 2002
Return-Path: <gpr@nvnpp.vrn.ru>
Received: from ic.vrn.ru (ic.vrn.ru [195.98.64.65])
	by hub.freebsd.org (Postfix) with ESMTP id 6D32837B432
	for <FreeBSD-gnats-submit@freebsd.org>; Mon, 11 Mar 2002 22:35:53 -0800 (PST)
Received: from relay.nvnpp.vrn.ru ([195.98.93.102])
	by ic.vrn.ru (8.11.6/8.11.1) with ESMTP id g2C6ZmH63549
	for <FreeBSD-gnats-submit@freebsd.org>; Tue, 12 Mar 2002 09:35:48 +0300 (MSK)
	(envelope-from gpr@nvnpp.vrn.ru)
Received: from nvnpp.vrn.ru by relay.nvnpp.vrn.ru
	with SMTP (MDaemon.v3.1.0.R)
	for <FreeBSD-gnats-submit@freebsd.org>; Tue, 12 Mar 2002 09:35:41 +0300
Received: from fbsd.nvnpp.vrn.ru by nvnpp.vrn.ru
	with SMTP (MDaemon.PRO.v5.0.4.R)
	for <FreeBSD-gnats-submit@freebsd.org>; Tue, 12 Mar 2002 09:34:56 +0300
Received: from gpr by fbsd.nvnpp.vrn.ru with local (Exim 3.33 #1)
	id 16kfsi-0004bX-00
	for FreeBSD-gnats-submit@freebsd.org; Tue, 12 Mar 2002 09:35:32 +0300
Message-Id: <E16kfsi-0004bX-00@fbsd.nvnpp.vrn.ru>
Date: Tue, 12 Mar 2002 09:35:32 +0300
From: Gennady Proskurin <gpr@nvnpp.vrn.ru>
Sender: Gennady Proskurin <gpr@fbsd.nvnpp.vrn.ru>
Reply-To: Gennady Proskurin <gpr@nvnpp.vrn.ru>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: strings(1) does'n print russian characters
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         35812
>Category:       bin
>Synopsis:       strings(1) does'n print russian characters
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Mar 11 22:40:00 PST 2002
>Closed-Date:    Sat Aug 31 15:50:41 PDT 2002
>Last-Modified:  Sat Aug 31 22:00:02 PDT 2002
>Originator:     Gennady Proskurin
>Release:        FreeBSD 5.0-CURRENT i386
>Organization:
>Environment:
System: FreeBSD gpr.nvnpp.lan 5.0-CURRENT FreeBSD 5.0-CURRENT #4: Mon Mar 11 09:59:59 MSK 2002 gpr@gpr.nvnpp.lan:/usr/obj/usr/src/sys/gpr i386

	
>Description:
strings(1) does'n print russian characters due to incorrect type cast.
	
>How-To-Repeat:
	echo 'some russian chars' | strings
	
>Fix:

--- /usr/src/usr.bin/strings/strings.c.orig	Tue Mar 12 09:16:05 2002
+++ /usr/src/usr.bin/strings/strings.c	Tue Mar 12 09:16:07 2002
@@ -184,7 +184,7 @@
 				else
 					printf("%s", bfr);
 				while ((ch = getch()) != EOF && ISSTR(ch))
-					putchar((char)ch);
+					putchar((unsigned char)ch);
 				putchar('\n');
 			}
 			cnt = 0;
	


>Release-Note:
>Audit-Trail:

From: "."@babolo.ru
To: gpr@nvnpp.vrn.ru
Cc: FreeBSD-gnats-submit@FreeBSD.ORG
Subject: Re: bin/35812: strings(1) does'n print russian characters
Date: Tue, 12 Mar 2002 09:56:27 +0300 (MSK)

 Gennady Proskurin writes:
 > 
 > >Number:         35812
 > >Category:       bin
 > >Synopsis:       strings(1) does'n print russian characters
 > >Confidential:   no
 > >Severity:       non-critical
 > >Priority:       low
 > >Responsible:    freebsd-bugs
 > >State:          open
 > >Quarter:        
 > >Keywords:       
 > >Date-Required:
 > >Class:          sw-bug
 > >Submitter-Id:   current-users
 > >Arrival-Date:   Mon Mar 11 22:40:00 PST 2002
 > >Closed-Date:
 > >Last-Modified:
 > >Originator:     Gennady Proskurin
 > >Release:        FreeBSD 5.0-CURRENT i386
 > >Organization:
 > >Environment:
 > System: FreeBSD gpr.nvnpp.lan 5.0-CURRENT FreeBSD 5.0-CURRENT #4: Mon Mar 11 09:59:59 MSK 2002 gpr@gpr.nvnpp.lan:/usr/obj/usr/src/sys/gpr i386
 > 
 > 	
 > >Description:
 > strings(1) does'n print russian characters due to incorrect type cast.
 > 	
 > >How-To-Repeat:
 > 	echo 'some russian chars' | strings
 > 	
 > >Fix:
 > 
 > --- /usr/src/usr.bin/strings/strings.c.orig	Tue Mar 12 09:16:05 2002
 > +++ /usr/src/usr.bin/strings/strings.c	Tue Mar 12 09:16:07 2002
 > @@ -184,7 +184,7 @@
 >  				else
 >  					printf("%s", bfr);
 >  				while ((ch = getch()) != EOF && ISSTR(ch))
 > -					putchar((char)ch);
 > +					putchar((unsigned char)ch);
 >  				putchar('\n');
 >  			}
 >  			cnt = 0;
 > 	
 > 
 > 
 > >Release-Note:
 > >Audit-Trail:
 > >Unformatted:
 One more place to patch. It is my patch I use about year:
 
 --- usr.bin/strings/strings.c	Mon Apr 23 02:38:13 2001
 +++ usr.bin/strings/strings.c	Wed Aug 22 05:05:04 2001
 @@ -170,7 +170,7 @@
  		}
  start:
  		for (cnt = 0; (ch = getch()) != EOF;) {
 -			if (ISSTR(ch)) {
 +			if (ISSTR(ch) & 0xff) {
  				if (!cnt)
  					C = bfr;
  				*C++ = ch;
 @@ -183,7 +183,7 @@
  					    foff - minlen, (char *)bfr);
  				else
  					printf("%s", bfr);
 -				while ((ch = getch()) != EOF && ISSTR(ch))
 +				while ((ch = getch()) != EOF && ISSTR(ch & 0xff))
  					putchar((char)ch);
  				putchar('\n');
  			}
 
 
 -- 
 @BABOLO      http://links.ru/

From: Peter Pentchev <roam@ringlet.net>
To: "."@babolo.ru
Cc: bug-followup@FreeBSD.org
Subject: Re: bin/35812: strings(1) does'n print russian characters
Date: Tue, 12 Mar 2002 11:14:49 +0200

 On Mon, Mar 11, 2002 at 10:50:01PM -0800, "."@babolo.ru wrote:
 >  Gennady Proskurin writes:
 >  > 
 >  > >Number:         35812
 >  > >Category:       bin
 >  > >Synopsis:       strings(1) does'n print russian characters
 >  > >Originator:     Gennady Proskurin
 >  > 	
 >  > >Description:
 >  > strings(1) does'n print russian characters due to incorrect type cast.
 >  > 	
 >  > >How-To-Repeat:
 >  > 	echo 'some russian chars' | strings
 >
 >  One more place to patch. It is my patch I use about year:
 
 Would this not be better off with another cast to unsigned char
 instead of & 0xff?
 
 G'luck,
 Peter
 
 -- 
 Peter Pentchev	roam@ringlet.net	roam@FreeBSD.org
 PGP key:	http://people.FreeBSD.org/~roam/roam.key.asc
 Key fingerprint	FDBA FD79 C26F 3C51 C95E  DF9E ED18 B68D 1619 4553
 I am jealous of the first word in this sentence.

From: Jonathan Chen <jon@FreeBSD.org>
To: freebsd-gnats-submit@FreeBSD.org, gpr@nvnpp.vrn.ru, "."@babolo.ru
Cc:  
Subject: Re: bin/35812: strings(1) does'n print russian characters
Date: Sun, 7 Jul 2002 12:50:06 -0400

 Gennady Proskurin writes:
 
 [...]
 -                                       putchar((char)ch);
 +                                       putchar((unsigned char)ch);
 
 I do not believe the type-casting is necessary, since putchar() takes an 
 int.  Casting to unsigned char (or just char for that matter) would break 
 wchar too.  Please try replacing putchar(...) with simply putchar(ch) and 
 let me know if that works.
 
 
 "."@babolo.ru writes:
 [...]
  -                      if (ISSTR(ch)) {
  +                      if (ISSTR(ch) & 0xff) {
 [...]
  -                              while ((ch = getch()) != EOF && ISSTR(ch))
  +                              while ((ch = getch()) != EOF && ISSTR(ch & 0xff
 
 The first diff here appears to be wrong, you probably meant (ch & 0xff) 
 instead of what you have.  Nevertheless, I don't think either of these 
 changes are necessary, since all the functions in ISSTR are able to take 
 integers as well.
 
 Please try strings with only the typecast removal change.  Let me know of 
 this works, and I'll commit it.  If not, something else is probably 
 broken...
 
 -Jon

From: Gennady Proskurin <gpr@nvnpp.vrn.ru>
To: Jonathan Chen <jon@FreeBSD.org>
Cc: freebsd-gnats-submit@FreeBSD.org, "."@babolo.ru
Subject: Re: bin/35812: strings(1) does'n print russian characters
Date: Thu, 11 Jul 2002 10:37:28 +0400

 Hello, Jonathan.
 
 On Sun, Jul 07, 2002 at 12:50:06PM -0400, Jonathan Chen wrote:
 
 > 
 > Gennady Proskurin writes:
 > 
 > [...]
 > -                                       putchar((char)ch);
 > +                                       putchar((unsigned char)ch);
 > 
 > I do not believe the type-casting is necessary, since putchar() takes an 
 > int.  Casting to unsigned char (or just char for that matter) would break 
 > wchar too.  Please try replacing putchar(...) with simply putchar(ch) and 
 > let me know if that works.
 > 
 > 
 > "."@babolo.ru writes:
 > [...]
 >  -                      if (ISSTR(ch)) {
 >  +                      if (ISSTR(ch) & 0xff) {
 > [...]
 >  -                              while ((ch = getch()) != EOF && ISSTR(ch))
 >  +                              while ((ch = getch()) != EOF && ISSTR(ch & 0xff
 > 
 > The first diff here appears to be wrong, you probably meant (ch & 0xff) 
 > instead of what you have.  Nevertheless, I don't think either of these 
 > changes are necessary, since all the functions in ISSTR are able to take 
 > integers as well.
 > 
 > Please try strings with only the typecast removal change.  Let me know of 
 > this works, and I'll commit it.  If not, something else is probably 
 > broken...
 
 This patches are for /usr/libexec/aout/strings, which works fine with
 locale without any patches ;). Sorry for false alarm :(
 
 /usr/libexec/elf/strings manpage says that it prints "printable" chars,
 but in fact it prints chars that printable only in C locale, because it
 uses libiberty for detect printable chars, and isprint macro from
 libiberty is documented as locale-independent.
 
 I think it should be mentioned in elf/strings manpage that it doesn't
 depend on locale to not confuse users.
 
 > 
 > -Jon
 > 
 
 -- 
 Gennady
State-Changed-From-To: open->closed 
State-Changed-By: dwmalone 
State-Changed-When: Sat Aug 31 15:48:27 PDT 2002 
State-Changed-Why:  
Submitter reckons PR can be closed (as a binutils issue at heart). 

http://www.freebsd.org/cgi/query-pr.cgi?pr=35812 

From: "."@babolo.ru
To: dwmalone@FreeBSD.ORG (David Malone)
Cc: gpr@nvnpp.vrn.ru, dwmalone@FreeBSD.ORG, freebsd-bugs@FreeBSD.ORG,
	bug-followup@FreeBSD.ORG
Subject: Re: bin/35812: strings(1) does'n print russian characters
Date: Sun, 1 Sep 2002 08:40:04 +0400 (MSD)

 David Malone writes:
 > Synopsis: strings(1) does'n print russian characters
 > 
 > State-Changed-From-To: open->closed
 > State-Changed-By: dwmalone
 > State-Changed-When: Sat Aug 31 15:48:27 PDT 2002
 > State-Changed-Why: 
 > Submitter reckons PR can be closed (as a binutils issue at heart).
 Without strings(1) patched?
 I understand (may be) binutils issue, but
 my patch bypass this issue.
 (there was a little error in my previous patch)
 
 --- usr.bin/strings/strings.c	Mon Apr 23 02:38:13 2001
 +++ usr.bin/strings/strings.c	Wed Aug 22 05:05:04 2001
 @@ -170,7 +170,7 @@
  		}
  start:
  		for (cnt = 0; (ch = getch()) != EOF;) {
 -			if (ISSTR(ch)) {
 +			if (ISSTR(ch & 0xff)) {
  				if (!cnt)
  					C = bfr;
  				*C++ = ch;
 @@ -183,7 +183,7 @@
  					    foff - minlen, (char *)bfr);
  				else
  					printf("%s", bfr);
 -				while ((ch = getch()) != EOF && ISSTR(ch))
 +				while ((ch = getch()) != EOF && ISSTR(ch & 0xff))
  					putchar((char)ch);
  				putchar('\n');
  			}
 
 
 PS
 As far as I understand without this patch
 strings(1) do not works properly with another
 locales with upper half of table used
 (europian for example)
 
 -- 
 @BABOLO      http://links.ru/

From: =?koi8-r?B?4c7E0sXKIP7F0s7P1w==?= <ache@nagual.pp.ru>
To: "."@babolo.ru
Cc: David Malone <dwmalone@FreeBSD.ORG>, gpr@nvnpp.vrn.ru,
	freebsd-bugs@FreeBSD.ORG, bug-followup@FreeBSD.ORG
Subject: Re: bin/35812: strings(1) does'n print russian characters
Date: Sun, 1 Sep 2002 08:55:05 +0400

 On Sun, Sep 01, 2002 at 08:40:04 +0400, "."@babolo.ru wrote:
 > David Malone writes:
 > > Synopsis: strings(1) does'n print russian characters
 > > 
 > > State-Changed-From-To: open->closed
 > > State-Changed-By: dwmalone
 > > State-Changed-When: Sat Aug 31 15:48:27 PDT 2002
 > > State-Changed-Why: 
 > > Submitter reckons PR can be closed (as a binutils issue at heart).
 > Without strings(1) patched?
 > I understand (may be) binutils issue, but
 > my patch bypass this issue.
 > (there was a little error in my previous patch)
 > 
 > --- usr.bin/strings/strings.c	Mon Apr 23 02:38:13 2001
 > +++ usr.bin/strings/strings.c	Wed Aug 22 05:05:04 2001
 > @@ -170,7 +170,7 @@
 >  		}
 >  start:
 >  		for (cnt = 0; (ch = getch()) != EOF;) {
 > -			if (ISSTR(ch)) {
 > +			if (ISSTR(ch & 0xff)) {
 
 This patch:
 1) Applies to source code not used for ELF binaries.
 2) Not change anything there (ch is already without sign extension).
 
 -- 
 Andrey A. Chernov
 http://ache.pp.ru/
>Unformatted:
