Commit Graph

21 Commits

Author SHA1 Message Date
theraven
0f6ef690b3 Implement xlocale APIs from Darwin, mainly for use by libc++. This adds a
load of _l suffixed versions of various standard library functions that use
the global locale, making them take an explicit locale parameter.  Also
adds support for per-thread locales.  This work was funded by the FreeBSD
Foundation.

Please test any code you have that uses the C standard locale functions!

Reviewed by:    das (gdtoa changes)
Approved by:    dim (mentor)
2011-11-20 14:45:42 +00:00
cracauer
3d4c1b73b9 Fix PR
http://www.freebsd.org/cgi/query-pr.cgi?pr=bin/143350
Empty string test gone wrong.

Testing this requires that you have a locale that has the sign string
unset but has int_n_sign_posn set (the default locale falls through to
use "()" around negative numbers which is probably another bug).

I created that setup by hand and indeed without this fix negative
numbers are put out as positive numbers (doesn't fall through to use
"-" as default indicator).

Unfixed example in nl_NL.ISO8859-1 with lc->negative_sign set to empty
string:
  strfmon(buf, sizeof(buf), "%-8i", -42.0);
==>
example2: 'EUR  42,00' 'Eu 42,00'

Fixed:
example2: 'EUR  42,00-' 'Eu 42,00-'

This file and suggested fix are identical in at least freebsd-8.
Backport might be appropriate but some expert on locales should
probably have a look at us defaulting to negative numbers in
parenthesis when LC_* is default.  That doesn't look right and is not
what other OSes are doing.

PR:		143350
Submitted by:	Corinna Vinschen
Reviewed by:	bug reporter submitted, tested by me
2010-02-10 00:02:09 +00:00
ru
c17c108c2a Stricter check for integer overflow. 2008-04-24 07:49:00 +00:00
ru
27e53e835a Don't forget to free() currency_symbol and asciivalue when multiple
conversion specifiers for them are present.

Submitted by:	Maxim Dounin <mdounin@mdounin.ru>
Obtained from:	NetBSD (partially)
MFC after:	3 days
2008-04-19 07:22:58 +00:00
ru
b15775c48a Better strfmon(3) conversion specifiers sanity checking.
There were no checks for left and right precisions at all, and
a check for field width had integer overflow bug.

Reported by:	Maksymilian Arciemowicz
Security:	http://securityreason.com/achievement_securityalert/53
Submitted by:	Maxim Dounin <mdounin@mdounin.ru>
MFC after:	3 days
2008-04-19 07:18:22 +00:00
delphij
b612c0d58d Use calloc() instaed of zeroing memory ourselves. 2008-04-13 08:05:08 +00:00
stefanf
f9e069084c Include a couple of headers to ensure consistency between the prototype and
the function definition.
2005-09-12 19:52:42 +00:00
ache
2bb5966d5b According to C99 decimal_point can't be empty 2003-03-20 08:18:55 +00:00
tjr
f027795617 Remove unused variable: ntmp. 2003-01-03 23:34:26 +00:00
tjr
cf318b70e5 Fix a typo causing incorrect formatting for negative values in some locales
(at least the French ones), a memory leak upon successful termination, a
pointer arithmetic error causing heap corruption, and an off-by-one bug
causing incorrect amounts of padding at the right of the value.
2002-10-12 04:38:35 +00:00
tjr
ce2f2cf1be Save errno around calls to free(); at least some code paths clobber it
and we are not interested in any errors it may report.
2002-10-11 23:31:50 +00:00
tjr
91e28cff5e Use the new struct lconv members to determine how to format international
monetary values.
2002-10-11 23:08:03 +00:00
tjr
27cfe623e7 Non-negative amounts should not have an extra space in front of them
when the `(' flag is used.
2002-10-11 23:04:59 +00:00
tjr
5bbd2d0ed6 "Left precision" and "right precision" are not flags, but separate parts
of the format string that appear after the field width.
2002-10-11 22:59:22 +00:00
mike
a33d7be6d9 Add restrict type-qualifier. 2002-09-20 08:24:01 +00:00
alfred
1ee311b26d Assume __STDC__, remove non-__STDC__ code.
Submitted by: keramida
2002-05-28 17:03:12 +00:00
obrien
d90536e35b Fix the style of the SCM ID's.
I believe have made all of libc .c's as consistent as possible.
2002-03-22 21:53:29 +00:00
phantom
43b8ed47bd Add my e-mail to copyrights 2001-12-11 16:00:47 +00:00
mike
c097487da5 style(9)
Silence from:	phantom
2001-09-17 00:23:19 +00:00
phantom
ef56905cb0 correctly wrap macros with { } 2001-09-06 09:26:28 +00:00
phantom
2b26e9313c Add strfmon(3) implementation. It still contains few XXX's because I lost
my last version of this work due to HDD crash, but this version cleanly
passed all POSIX and SuSv2 tests. I am working on testing scripts which
should test this implementation against all locales and surely more fixes
will come soon.

Reviewed by:	ache, silence at -audit & -developers
2001-09-05 18:50:02 +00:00