From owner-freebsd-arch Sun Jan 27 21:56:15 2002 Delivered-To: freebsd-arch@freebsd.org Received: from nagual.pp.ru (pobrecita.freebsd.ru [194.87.13.42]) by hub.freebsd.org (Postfix) with ESMTP id A8D9E37B400; Sun, 27 Jan 2002 21:56:05 -0800 (PST) Received: (from ache@localhost) by nagual.pp.ru (8.11.6/8.11.6) id g0S5txM23509; Mon, 28 Jan 2002 08:55:59 +0300 (MSK) (envelope-from ache) Date: Mon, 28 Jan 2002 08:55:58 +0300 From: "Andrey A. Chernov" To: Chad David , phantom@FreeBSD.org Cc: "Brian F. Feldman" , Bruce Evans , arch@FreeBSD.org Subject: Re: strtod() Message-ID: <20020128055557.GA23297@nagual.pp.ru> References: <20020126162924.A7726@colnta.acns.ab.ca> <200201270453.g0R4rwi92912@green.bikeshed.org> <20020127070421.GA13415@nagual.pp.ru> <20020127003719.A38420@colnta.acns.ab.ca> <20020127083529.GA13957@nagual.pp.ru> <20020127024626.B40668@colnta.acns.ab.ca> <20020127105258.GA14836@nagual.pp.ru> <20020127130625.A42735@colnta.acns.ab.ca> <20020127224529.GA20003@nagual.pp.ru> <20020127161626.A62332@colnta.acns.ab.ca> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20020127161626.A62332@colnta.acns.ab.ca> User-Agent: Mutt/1.3.27i Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Sun, Jan 27, 2002 at 16:16:26 -0700, Chad David wrote: > I don't understand what you mean. > This is locale code bug and EINVAL from strtol() really helps to find it. Try the patch below, it fix the problem (at least on my testing): --- lmonetary.c.old Thu Dec 13 12:26:25 2001 +++ lmonetary.c Mon Jan 28 08:50:21 2002 @@ -27,6 +27,7 @@ */ #include +#include #include "lmonetary.h" #include "ldpart.h" @@ -60,6 +61,14 @@ static int _monetary_using_locale; static char *_monetary_locale_buf; +static char +cnv(const char *str) { + int i = strtol(str, NULL, 10); + if (i == -1) + i = CHAR_MAX; + return (char)i; +} + int __monetary_load_locale(const char *name) { @@ -69,9 +78,22 @@ _monetary_locale_buf, "LC_MONETARY", LCMONETARY_SIZE, LCMONETARY_SIZE, (const char **)&_monetary_locale); - if (ret == 0 && _monetary_using_locale) + if (ret == 0 && _monetary_using_locale) { _monetary_locale.mon_grouping = __fix_locale_grouping_str(_monetary_locale.mon_grouping); + +#define M_ASSIGN_CHAR(NAME) (((char *)_monetary_locale.NAME)[0] = \ + cnv(_monetary_locale.NAME)) + + M_ASSIGN_CHAR(int_frac_digits); + M_ASSIGN_CHAR(frac_digits); + M_ASSIGN_CHAR(p_cs_precedes); + M_ASSIGN_CHAR(p_sep_by_space); + M_ASSIGN_CHAR(n_cs_precedes); + M_ASSIGN_CHAR(n_sep_by_space); + M_ASSIGN_CHAR(p_sign_posn); + M_ASSIGN_CHAR(n_sign_posn); + } return ret; } @@ -93,14 +115,14 @@ "mon_grouping = %s\n" "positive_sign = %s\n" "negative_sign = %s\n" - "int_frac_digits = %s\n" - "frac_digits = %s\n" - "p_cs_precedes = %s\n" - "p_sep_by_space = %s\n" - "n_cs_precedes = %s\n" - "n_sep_by_space = %s\n" - "p_sign_posn = %s\n" - "n_sign_posn = %s\n", + "int_frac_digits = %d\n" + "frac_digits = %d\n" + "p_cs_precedes = %d\n" + "p_sep_by_space = %d\n" + "n_cs_precedes = %d\n" + "n_sep_by_space = %d\n" + "p_sign_posn = %d\n" + "n_sign_posn = %d\n", _monetary_locale.int_curr_symbol, _monetary_locale.currency_symbol, _monetary_locale.mon_decimal_point, @@ -108,14 +130,14 @@ _monetary_locale.mon_grouping, _monetary_locale.positive_sign, _monetary_locale.negative_sign, - _monetary_locale.int_frac_digits, - _monetary_locale.frac_digits, - _monetary_locale.p_cs_precedes, - _monetary_locale.p_sep_by_space, - _monetary_locale.n_cs_precedes, - _monetary_locale.n_sep_by_space, - _monetary_locale.p_sign_posn, - _monetary_locale.n_sign_posn + _monetary_locale.int_frac_digits[0], + _monetary_locale.frac_digits[0], + _monetary_locale.p_cs_precedes[0], + _monetary_locale.p_sep_by_space[0], + _monetary_locale.n_cs_precedes[0], + _monetary_locale.n_sep_by_space[0], + _monetary_locale.p_sign_posn[0], + _monetary_locale.n_sign_posn[0] ); } #endif /* LOCALE_DEBUG */ --- localeconv.c.old Fri Dec 21 07:27:35 2001 +++ localeconv.c Mon Jan 28 08:44:47 2002 @@ -41,8 +41,6 @@ #endif /* LIBC_SCCS and not lint */ #include -#include -#include #include "lmonetary.h" #include "lnumeric.h" @@ -58,14 +56,6 @@ int __mlocale_changed = 1; int __nlocale_changed = 1; -static char -cnv(char *str) { - int i = strtol(str, NULL, 10); - if (i == -1) - i = CHAR_MAX; - return (char)i; -} - /* * Return the current locale conversion. */ @@ -79,7 +69,7 @@ struct lc_monetary_T * mptr; #define M_ASSIGN_STR(NAME) (ret.NAME = (char*)mptr->NAME) -#define M_ASSIGN_CHAR(NAME) (ret.NAME = cnv((char*)mptr->NAME)) +#define M_ASSIGN_CHAR(NAME) (ret.NAME = mptr->NAME[0]) mptr = __get_current_monetary_locale(); M_ASSIGN_STR(int_curr_symbol); -- Andrey A. Chernov http://ache.pp.ru/ To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message