fix static linking setlocale(3) problem, reported by Aran Clauson

at current-users, thanks a lot!
This commit is contained in:
tnozaki 2009-03-09 02:22:25 +00:00
parent ffbff10ba1
commit c7281b0c86
2 changed files with 34 additions and 19 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: generic_lc_template.h,v 1.2 2009/01/11 02:46:28 christos Exp $ */
/* $NetBSD: generic_lc_template.h,v 1.3 2009/03/09 02:22:25 tnozaki Exp $ */
/*-
* Copyright (c)2008 Citrus Project,
@ -29,17 +29,10 @@
#ifndef _GENERIC_LC_TEMPLATE_H_
#define _GENERIC_LC_TEMPLATE_H_
#ifdef __lint__
#define STATIC /**/
#else
#define STATIC static
#endif
#define _LOCALE_CATEGORY_ENTRY(name) \
STATIC const _locale_category_t name##desc = { \
const _locale_category_t name##desc = { \
.category = _CATEGORY_ID, \
.setlocale = &name##setlocale, \
}; \
__link_set_add_data(all_categories, name##desc)
}
#endif /*_GENERIC_LC_TEMPLATE_H_*/

View File

@ -1,4 +1,4 @@
/* $NetBSD: setlocale.c,v 1.56 2009/01/11 02:46:29 christos Exp $ */
/* $NetBSD: setlocale.c,v 1.57 2009/03/09 02:22:25 tnozaki Exp $ */
/*-
* Copyright (c)2008 Citrus Project,
@ -28,7 +28,7 @@
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
__RCSID("$NetBSD: setlocale.c,v 1.56 2009/01/11 02:46:29 christos Exp $");
__RCSID("$NetBSD: setlocale.c,v 1.57 2009/03/09 02:22:25 tnozaki Exp $");
#endif /* LIBC_SCCS and not lint */
#include <sys/cdefs.h>
@ -47,15 +47,37 @@ const char *_PathLocale = NULL;
__link_set_decl(all_categories, _locale_category_t);
#ifndef __lint__
static
extern const _locale_category_t _generic_LC_ALL_desc;
extern const _locale_category_t _dummy_LC_COLLATE_desc;
#ifdef WITH_RUNE
extern const _locale_category_t _citrus_LC_CTYPE_desc;
extern const _locale_category_t _citrus_LC_MONETARY_desc;
extern const _locale_category_t _citrus_LC_NUMERIC_desc;
extern const _locale_category_t _citrus_LC_TIME_desc;
extern const _locale_category_t _citrus_LC_MESSAGES_desc;
#else
extern const _locale_category_t _localeio_LC_CTYPE_desc;
extern const _locale_category_t _localeio_LC_MONETARY_desc;
extern const _locale_category_t _localeio_LC_NUMERIC_desc;
extern const _locale_category_t _localeio_LC_TIME_desc;
extern const _locale_category_t _localeio_LC_MESSAGES_desc;
#endif
const _locale_category_t dummy = {
.category = _LC_LAST, /* XXX */
.setlocale = NULL,
};
__link_set_add_data(all_categories, dummy);
__link_set_add_data(all_categories, _generic_LC_ALL_desc);
__link_set_add_data(all_categories, _dummy_LC_COLLATE_desc);
#ifdef WITH_RUNE
__link_set_add_data(all_categories, _citrus_LC_CTYPE_desc);
__link_set_add_data(all_categories, _citrus_LC_MONETARY_desc);
__link_set_add_data(all_categories, _citrus_LC_NUMERIC_desc);
__link_set_add_data(all_categories, _citrus_LC_TIME_desc);
__link_set_add_data(all_categories, _citrus_LC_MESSAGES_desc);
#else
__link_set_add_data(all_categories, _localeio_LC_CTYPE_desc);
__link_set_add_data(all_categories, _localeio_LC_MONETARY_desc);
__link_set_add_data(all_categories, _localeio_LC_NUMERIC_desc);
__link_set_add_data(all_categories, _localeio_LC_TIME_desc);
__link_set_add_data(all_categories, _localeio_LC_MESSAGES_desc);
#endif
_locale_category_t *
_find_category(int category)