Subject: bin/2486: 'expr' prints odd error message LANG set to something other than 'C'
To: None <gnats-bugs@NetBSD.ORG>
From: None <>
List: netbsd-bugs
Date: 05/30/1996 15:37:16
>Number:         2486
>Category:       bin
>Synopsis:       'expr' prints odd (bogus) error message of LANG set to !'C'
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    bin-bug-people (Utility Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu May 30 15:50:05 1996
>Originator:     Chris G. Demetriou
Kernel Hackers 'r' Us
>Release:        1.2_ALPHA
System: NetBSD 1.2_ALPHA NetBSD 1.2_ALPHA (BUNNY) #48: Thu May 30 12:07:36 EDT 1996 alpha
(up to date) Also, NetBSD/i386 with a -current as of a few months ago.

	'expr' prints an odd error message if invoked with the LANG
	environment variable set to something other than 'C'.

	I've been running with LANG set to 'Pig' lately to try and
	shake out odd bugs, and this is one that cropped up.

	setenv LANG Pig
	expr 10 + 11

	This will generate output like:

	46 [bunnahabhain] cgd % expr 10 + 11
	setlocale failed, continuing with "C" locale.21
	47 [bunnahabhain] cgd % expr 10 + 11 > /dev/null
	setlocale failed, continuing with "C" locale.48 [bunnahabhain] cgd % 

	At the very least, the error message should include a newline.
	Arguably worse, this is inconsistent; none of the rest of the
	'setlocale()' uses in the source tree (that I could find) print
	an error if setlocale() fails...

	Applying the following patch to src/bin/expr/expr.c makes expr's
	use of setlocale() consistent with other programs' use of it,
	by removing the error message entirely.

Index: expr.c
RCS file: /a/cvsroot/src/bin/expr/expr.c,v
retrieving revision 1.3
diff -c -r1.3 expr.c
*** expr.c	1995/04/28 23:27:15	1.3
--- expr.c	1996/05/30 19:38:01
*** 484,493 ****
  	struct val     *vp;
! 	if (!setlocale(LC_ALL, "")) {
! 		fprintf(stderr,
! 			"setlocale failed, continuing with \"C\" locale.");
! 	}
  	av = argv + 1;
--- 484,490 ----
  	struct val     *vp;
! 	(void) setlocale(LC_ALL, "");
  	av = argv + 1;