From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Kevin Ryde Newsgroups: gmane.lisp.guile.devel Subject: Re: Text collation Date: Tue, 05 Dec 2006 11:38:04 +1100 Message-ID: <87k617kwib.fsf@zip.com.au> References: <877j00cirs.fsf@laas.fr> <87hcz3mqhr.fsf@zip.com.au> <87r6x0qjyy.fsf@laas.fr> <87fyc1df70.fsf@zip.com.au> <87zma9m07p.fsf@laas.fr> NNTP-Posting-Host: dough.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: sea.gmane.org 1165279114 19520 80.91.229.10 (5 Dec 2006 00:38:34 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Tue, 5 Dec 2006 00:38:34 +0000 (UTC) Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Tue Dec 05 01:38:32 2006 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by dough.gmane.org with esmtp (Exim 4.50) id 1GrOKN-00029s-88 for guile-devel@m.gmane.org; Tue, 05 Dec 2006 01:38:31 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GrOKM-00034z-La for guile-devel@m.gmane.org; Mon, 04 Dec 2006 19:38:30 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1GrOKI-000338-FE for guile-devel@gnu.org; Mon, 04 Dec 2006 19:38:26 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1GrOKE-000308-CO for guile-devel@gnu.org; Mon, 04 Dec 2006 19:38:25 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GrOKC-0002zo-Uk for guile-devel@gnu.org; Mon, 04 Dec 2006 19:38:21 -0500 Original-Received: from [61.8.2.215] (helo=mailout1.pacific.net.au) by monty-python.gnu.org with esmtp (Exim 4.52) id 1GrOKC-0004ps-Ds for guile-devel@gnu.org; Mon, 04 Dec 2006 19:38:21 -0500 Original-Received: from mailproxy2.pacific.net.au (mailproxy2.pacific.net.au [61.8.2.163]) by mailout1.pacific.net.au (Postfix) with ESMTP id 694BD5A3CF6 for ; Tue, 5 Dec 2006 11:38:09 +1100 (EST) Original-Received: from localhost (ppp2E12.dyn.pacific.net.au [61.8.46.18]) by mailproxy2.pacific.net.au (Postfix) with ESMTP id 6B92927409 for ; Tue, 5 Dec 2006 11:38:08 +1100 (EST) Original-Received: from gg by localhost with local (Exim 4.63) (envelope-from ) id 1GrOJw-0003B5-TZ for guile-devel@gnu.org; Tue, 05 Dec 2006 11:38:05 +1100 Original-To: Guile-Devel Mail-Copies-To: never In-Reply-To: <87zma9m07p.fsf@laas.fr> (Ludovic =?iso-8859-1?Q?Court=E8s's?= message of "Thu, 30 Nov 2006 16:19:06 +0100") User-Agent: Gnus/5.110006 (No Gnus v0.6) Emacs/21.4 (gnu/linux) X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.devel:6289 Archived-At: --=-=-= Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable ludovic.courtes@laas.fr (Ludovic Court=E8s) writes: > > I've written a wrapper for `nl_langinfo ()' as part of the `i18n' module What do other schemes or lisps do? I had an idea one of the srfis had some bits but they weren't great. I started a localeconv bit (below) using a vector for all info, though I'm now inclined to think a function with a symbol arg would be friendlier than a big object return. (langinfo 'thousands-sep) =3D> "," Or "localeinfo" or "localeconv" or something. In my charting program I made a separate function for each of the few bits I wanted, (locale-decimal-point) =3D> "." (locale-d-fmt) =3D> "%d/%m/%y" One cute thing about that is that the user can override to personal preferences by `set!'ing in a new function, like having "%b" for the month in the date format. --=-=-= Content-Type: text/x-csrc Content-Disposition: attachment; filename=localeconv.c #define _GNU_SOURCE /* ask glibc for C99 lconv fields */ #include SCM_DEFINE (scm_localeconv, "localeconv", 0, 0, 0, (), "Return an ``lconv'' object representing current locale specific\n" "information.") #define FUNC_NAME s_scm_localtime { SCM result; const struct lconv *l; #define LCONV_STR(idx, field) \ SCM_VECTOR_SET (result, idx, scm_makfrom0str (l->field)) #define LCONV_INT(idx, field) \ SCM_VECTOR_SET (result, idx, SCM_MAKINUM (l->field)) /* group array ends with either 0 or CHAR_MAX */ #define LCONV_GRP(idx, field) \ do { \ SCM vec; \ int n, i; \ for (i = 0; l->field[i] != 0 && l->field[i] != CHAR_MAX; i++) \ ; \ n = i + 1; /* number of elements */ \ vec = scm_c_make_vector (n, SCM_BOOL_F); \ for (i = 0; i < n; i++) \ SCM_VECTOR_SET (result, idx, SCM_MAKINUM (l->field[i])); \ SCM_VECTOR_SET (result, idx, vec); \ } while (0) result = scm_c_make_vector (11, SCM_BOOL_F); SCM_DEFER_INTS; LCONV_STR ( 0, decimal_point); LCONV_STR ( 1, thousands_sep); LCONV_GRP ( 2, grouping); LCONV_STR ( 3, int_curr_symbol); LCONV_STR ( 4, currency_symbol); LCONV_STR ( 5, mon_decimal_point); LCONV_STR ( 6, mon_thousands_sep); LCONV_GRP ( 7, mon_grouping); LCONV_STR ( 8, positive_sign); LCONV_STR ( 9, negative_sign); LCONV_INT (10, int_frac_digits); LCONV_INT (11, frac_digits); LCONV_INT (12, p_cs_precedes); LCONV_INT (13, p_sep_by_space); LCONV_INT (14, n_cs_precedes); LCONV_INT (15, n_sep_by_space); LCONV_INT (16, p_sign_posn); LCONV_INT (17, n_sign_posn); /* C99 extras, apparently */ #if HAVE_LCONV_INT_P_CS_PRECEDES LCONV_INT (18, int_p_cs_precedes); LCONV_INT (19, int_p_sep_by_space); LCONV_INT (20, int_n_cs_precedes); LCONV_INT (21, int_n_sep_by_space); LCONV_INT (22, int_p_sign_posn); LCONV_INT (23, int_n_sign_posn); #endif return result; } --=-=-= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Guile-devel mailing list Guile-devel@gnu.org http://lists.gnu.org/mailman/listinfo/guile-devel --=-=-=--