Loading...
--- Libc/Libc-1725.40.4/stdtime/FreeBSD/timelocal.c
+++ Libc/Libc-583/stdtime/FreeBSD/timelocal.c
@@ -28,19 +28,14 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD: src/lib/libc/stdtime/timelocal.c,v 1.25 2003/06/13 00:14:07 jkh Exp $");
-#include "xlocale_private.h"
-
#include <stddef.h>
-#include <string.h>
#include "ldpart.h"
#include "timelocal.h"
-struct xlocale_time {
- struct xlocale_component header;
- char *buffer;
- struct lc_time_T locale;
-};
+static struct lc_time_T _time_locale;
+static int _time_using_locale;
+static char *time_locale_buf;
#define LCTIME_SIZE (sizeof(struct lc_time_T) / sizeof(char *))
@@ -104,58 +99,19 @@
"%I:%M:%S %p"
};
-__private_extern__ struct lc_time_T *
-__get_current_time_locale(locale_t loc)
+struct lc_time_T *
+__get_current_time_locale(void)
{
- return (loc->_time_using_locale
- ? &XLOCALE_TIME(loc)->locale
+ return (_time_using_locale
+ ? &_time_locale
: (struct lc_time_T *)&_C_time_locale);
}
-__private_extern__ int
-__time_load_locale(const char *name, locale_t loc)
+int
+__time_load_locale(const char *name)
{
- int ret;
- struct xlocale_time *xp;
- static struct xlocale_time *cache = NULL;
-
- /* 'name' must be already checked. */
- if (strcmp(name, "C") == 0 || strcmp(name, "POSIX") == 0 ||
- strncmp(name, "C.", 2) == 0) {
- loc->_time_using_locale = 0;
- xlocale_release(loc->components[XLC_TIME]);
- loc->components[XLC_TIME] = NULL;
- return (_LDP_CACHE);
- }
-
- /*
- * If the locale name is the same as our cache, use the cache.
- */
- if (cache && cache->buffer && strcmp(name, cache->buffer) == 0) {
- loc->_time_using_locale = 1;
- xlocale_release(loc->components[XLC_TIME]);
- loc->components[XLC_TIME] = (void *)cache;
- xlocale_retain(cache);
- return (_LDP_CACHE);
- }
- if ((xp = (struct xlocale_time *)malloc(sizeof(*xp))) == NULL)
- return _LDP_ERROR;
- xp->header.header.retain_count = 1;
- xp->header.header.destructor = destruct_ldpart;
- xp->buffer = NULL;
-
- ret = __part_load_locale(name, &loc->_time_using_locale,
- &xp->buffer, "LC_TIME",
+ return (__part_load_locale(name, &_time_using_locale,
+ &time_locale_buf, "LC_TIME",
LCTIME_SIZE, LCTIME_SIZE,
- (const char **)&xp->locale);
- if (ret == _LDP_LOADED) {
- xlocale_release(loc->components[XLC_TIME]);
- loc->components[XLC_TIME] = (void *)xp;
- xlocale_release(cache);
- cache = xp;
- xlocale_retain(cache);
- } else if (ret == _LDP_ERROR)
- free(xp);
-
- return (ret);
+ (const char **)&_time_locale));
}