1 --- setlocale.c.orig 2004-11-25 11:38:19.000000000 -0800
2 +++ setlocale.c 2005-04-27 13:37:01.000000000 -0700
5 __FBSDID("$FreeBSD: src/lib/libc/locale/setlocale.c,v 1.50 2004/01/31 19:15:32 ache Exp $");
7 +#include "xlocale_private.h"
13 #include "lmessages.h" /* for __messages_load_locale() */
14 #include "setlocale.h"
16 -#include "../stdtime/timelocal.h" /* for __time_load_locale() */
17 +#include "timelocal.h" /* for __time_load_locale() */
20 * Category names for getenv()
23 static char *currentlocale(void);
24 static char *loadlocale(int);
25 -static const char *__get_locale_env(int);
26 +__private_extern__ const char *__get_locale_env(int);
29 setlocale(category, locale)
33 - int i, j, len, saverr;
34 + int i, j, len, saverr, save__numeric_fp_cvt;
36 + locale_t save__lc_numeric_loc;
38 if (category < LC_ALL || category >= _LC_LAST) {
41 if (category != LC_ALL)
42 return (loadlocale(category));
44 + save__numeric_fp_cvt = __global_locale.__numeric_fp_cvt;
45 + save__lc_numeric_loc = __global_locale.__lc_numeric_loc;
46 + XL_RETAIN(save__lc_numeric_loc);
47 for (i = 1; i < _LC_LAST; ++i) {
48 (void)strcpy(saved_categories[i], current_categories[i]);
49 if (loadlocale(i) == NULL) {
54 + __global_locale.__numeric_fp_cvt = save__numeric_fp_cvt;
55 + __global_locale.__lc_numeric_loc = save__lc_numeric_loc;
56 + XL_RELEASE(save__lc_numeric_loc);
61 + XL_RELEASE(save__lc_numeric_loc);
62 return (currentlocale());
67 char *new = new_categories[category];
68 char *old = current_categories[category];
69 - int (*func)(const char *);
70 + int (*func)(const char *, locale_t);
75 if (strcmp(new, old) == 0)
78 - if (func(new) != _LDP_ERROR) {
79 + if (func(new, &__global_locale) != _LDP_ERROR) {
80 (void)strcpy(old, new);
83 + if (__global_locale.__numeric_fp_cvt == LC_NUMERIC_FP_SAME_LOCALE)
84 + __global_locale.__numeric_fp_cvt = LC_NUMERIC_FP_UNINITIALIZED;
87 + __global_locale.__numeric_fp_cvt = LC_NUMERIC_FP_UNINITIALIZED;
88 + XL_RELEASE(__global_locale.__lc_numeric_loc);
89 + __global_locale.__lc_numeric_loc = NULL;
99 +__private_extern__ const char *
100 __get_locale_env(category)
105 * Detect locale storage location and store its value to _PathLocale variable
108 +__private_extern__ int
109 __detect_path_locale(void)
111 if (_PathLocale == NULL) {