Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/lib/libc/locale Provide a const copy of global_locale for li...
details: https://anonhg.NetBSD.org/src/rev/b89101ff3dd7
branches: trunk
changeset: 786096:b89101ff3dd7
user: joerg <joerg%NetBSD.org@localhost>
date: Sun Apr 14 23:44:53 2013 +0000
description:
Provide a const copy of global_locale for libc-internal use.
This will be used by *_l when a NULL pointer is given.
diffstat:
lib/libc/locale/Makefile.inc | 4 +-
lib/libc/locale/c_locale.c | 174 ++++++++++++++++++++++++++++++++++++++
lib/libc/locale/setlocale_local.h | 3 +-
3 files changed, 178 insertions(+), 3 deletions(-)
diffs (213 lines):
diff -r 0b81991c631f -r b89101ff3dd7 lib/libc/locale/Makefile.inc
--- a/lib/libc/locale/Makefile.inc Sun Apr 14 23:30:15 2013 +0000
+++ b/lib/libc/locale/Makefile.inc Sun Apr 14 23:44:53 2013 +0000
@@ -1,12 +1,12 @@
# from: @(#)Makefile.inc 5.1 (Berkeley) 2/18/91
-# $NetBSD: Makefile.inc,v 1.60 2012/01/20 16:31:29 joerg Exp $
+# $NetBSD: Makefile.inc,v 1.61 2013/04/14 23:44:53 joerg Exp $
# locale sources
.PATH: ${ARCHDIR}/locale ${.CURDIR}/locale
SRCS+= _def_messages.c _def_monetary.c _def_numeric.c _def_time.c \
setlocale.c __mb_cur_max.c \
- current_locale.c global_locale.c fix_grouping.c \
+ current_locale.c c_locale.c global_locale.c fix_grouping.c \
localeconv.c nl_langinfo.c \
generic_lc_all.c dummy_lc_collate.c \
wcstol.c wcstoll.c wcstoimax.c wcstoul.c wcstoull.c wcstoumax.c \
diff -r 0b81991c631f -r b89101ff3dd7 lib/libc/locale/c_locale.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/libc/locale/c_locale.c Sun Apr 14 23:44:53 2013 +0000
@@ -0,0 +1,174 @@
+/* $NetBSD: c_locale.c,v 1.1 2013/04/14 23:44:54 joerg Exp $ */
+
+/*-
+ * Copyright (c)2008 Citrus Project,
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__RCSID("$NetBSD: c_locale.c,v 1.1 2013/04/14 23:44:54 joerg Exp $");
+
+#include <sys/types.h>
+#include <sys/ctype_bits.h>
+#include <sys/localedef.h>
+#include <langinfo.h>
+#include <limits.h>
+#define __SETLOCALE_SOURCE__
+#include <locale.h>
+#include <stdlib.h>
+
+#include "runetype_local.h"
+#include "setlocale_local.h"
+
+#ifndef NBCHAR_MAX
+#define NBCHAR_MAX (char)CHAR_MAX
+#endif
+
+static const struct lconv _C_ldata = {
+ .decimal_point = __UNCONST("."),
+ .thousands_sep = __UNCONST(""),
+ .grouping = __UNCONST(""),
+ .int_curr_symbol = __UNCONST(""),
+ .currency_symbol = __UNCONST(""),
+ .mon_decimal_point = __UNCONST(""),
+ .mon_thousands_sep = __UNCONST(""),
+ .mon_grouping = __UNCONST(""),
+ .positive_sign = __UNCONST(""),
+ .negative_sign = __UNCONST(""),
+ .int_frac_digits = NBCHAR_MAX,
+ .frac_digits = NBCHAR_MAX,
+ .p_cs_precedes = NBCHAR_MAX,
+ .p_sep_by_space = NBCHAR_MAX,
+ .n_cs_precedes = NBCHAR_MAX,
+ .n_sep_by_space = NBCHAR_MAX,
+ .p_sign_posn = NBCHAR_MAX,
+ .n_sign_posn = NBCHAR_MAX,
+ .int_p_cs_precedes = NBCHAR_MAX,
+ .int_n_cs_precedes = NBCHAR_MAX,
+ .int_p_sep_by_space = NBCHAR_MAX,
+ .int_n_sep_by_space = NBCHAR_MAX,
+ .int_p_sign_posn = NBCHAR_MAX,
+ .int_n_sign_posn = NBCHAR_MAX,
+};
+
+static const char *_C_items[(size_t)ALT_DIGITS + 1] = {
+ [(size_t)D_T_FMT ] = "%a %b %e %H:%M:%S %Y",
+ [(size_t)D_FMT ] = "%m/%d/%y",
+ [(size_t)T_FMT ] = "%H:%M:%S",
+ [(size_t)T_FMT_AMPM ] = "%I:%M:%S %p",
+ [(size_t)AM_STR ] = "AM",
+ [(size_t)PM_STR ] = "PM",
+ [(size_t)DAY_1 ] = "Sun",
+ [(size_t)DAY_2 ] = "Mon",
+ [(size_t)DAY_3 ] = "Tue",
+ [(size_t)DAY_4 ] = "Wed",
+ [(size_t)DAY_5 ] = "Thu",
+ [(size_t)DAY_6 ] = "Fri",
+ [(size_t)DAY_7 ] = "Sat",
+ [(size_t)ABDAY_1 ] = "Sunday",
+ [(size_t)ABDAY_2 ] = "Monday",
+ [(size_t)ABDAY_3 ] = "Tuesday",
+ [(size_t)ABDAY_4 ] = "Wednesday",
+ [(size_t)ABDAY_5 ] = "Thursday",
+ [(size_t)ABDAY_6 ] = "Friday",
+ [(size_t)ABDAY_7 ] = "Saturday",
+ [(size_t)MON_1 ] = "Jan",
+ [(size_t)MON_2 ] = "Feb",
+ [(size_t)MON_3 ] = "Mar",
+ [(size_t)MON_4 ] = "Apr",
+ [(size_t)MON_5 ] = "May",
+ [(size_t)MON_6 ] = "Jun",
+ [(size_t)MON_7 ] = "Jul",
+ [(size_t)MON_8 ] = "Aug",
+ [(size_t)MON_9 ] = "Sep",
+ [(size_t)MON_10 ] = "Oct",
+ [(size_t)MON_11 ] = "Nov",
+ [(size_t)MON_12 ] = "Dec",
+ [(size_t)ABMON_1 ] = "January",
+ [(size_t)ABMON_2 ] = "February",
+ [(size_t)ABMON_3 ] = "March",
+ [(size_t)ABMON_4 ] = "April",
+ [(size_t)ABMON_5 ] = "May",
+ [(size_t)ABMON_6 ] = "June",
+ [(size_t)ABMON_7 ] = "July",
+ [(size_t)ABMON_8 ] = "August",
+ [(size_t)ABMON_9 ] = "September",
+ [(size_t)ABMON_10 ] = "October",
+ [(size_t)ABMON_11 ] = "November",
+ [(size_t)ABMON_12 ] = "December",
+ [(size_t)RADIXCHAR ] = ".",
+ [(size_t)THOUSEP ] = "",
+ [(size_t)YESSTR ] = "yes",
+ [(size_t)YESEXPR ] = "^[Yy]",
+ [(size_t)NOSTR ] = "no",
+ [(size_t)NOEXPR ] = "^[Nn]",
+ [(size_t)CRNCYSTR ] = NULL,
+ [(size_t)CODESET ] = "646",
+ [(size_t)ERA ] = NULL,
+ [(size_t)ERA_D_FMT ] = NULL,
+ [(size_t)ERA_D_T_FMT] = NULL,
+ [(size_t)ERA_T_FMT ] = NULL,
+ [(size_t)ALT_DIGITS ] = NULL,
+};
+
+static const struct _locale_cache_t _C_cache = {
+ .ctype_tab = (const unsigned short *)&_C_ctype_tab_[0],
+ .tolower_tab = (const short *)&_C_tolower_tab_[0],
+ .toupper_tab = (const short *)&_C_toupper_tab_[0],
+ .mb_cur_max = (size_t)1,
+ .ldata = __UNCONST(&_C_ldata),
+ .items = __UNCONST(&_C_items[0]),
+
+#ifdef __BUILD_LEGACY
+ .compat_bsdctype = (const unsigned char *)&_C_compat_bsdctype[0],
+#endif
+};
+
+static const struct _locale __C_locale = {
+ .cache = __UNCONST(&_C_cache),
+ .query = { _C_LOCALE },
+ .part_name = {
+ [(size_t)LC_ALL ] = _C_LOCALE,
+ [(size_t)LC_COLLATE ] = _C_LOCALE,
+ [(size_t)LC_CTYPE ] = _C_LOCALE,
+ [(size_t)LC_MONETARY] = _C_LOCALE,
+ [(size_t)LC_NUMERIC ] = _C_LOCALE,
+ [(size_t)LC_TIME ] = _C_LOCALE,
+ [(size_t)LC_MESSAGES] = _C_LOCALE,
+ },
+ .part_impl = {
+ [(size_t)LC_ALL ] = (_locale_part_t)NULL,
+ [(size_t)LC_COLLATE ] = (_locale_part_t)NULL,
+ [(size_t)LC_CTYPE ] = (_locale_part_t)
+ __UNCONST(&_DefaultRuneLocale),
+ [(size_t)LC_MONETARY] = (_locale_part_t)
+ __UNCONST(&_DefaultMonetaryLocale),
+ [(size_t)LC_NUMERIC ] = (_locale_part_t)
+ __UNCONST(&_DefaultNumericLocale),
+ [(size_t)LC_MESSAGES] = (_locale_part_t)
+ __UNCONST(&_DefaultMessagesLocale),
+ },
+};
+
+__dso_hidden struct _locale *_C_locale = __UNCONST(&__C_locale);
diff -r 0b81991c631f -r b89101ff3dd7 lib/libc/locale/setlocale_local.h
--- a/lib/libc/locale/setlocale_local.h Sun Apr 14 23:30:15 2013 +0000
+++ b/lib/libc/locale/setlocale_local.h Sun Apr 14 23:44:53 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: setlocale_local.h,v 1.10 2013/04/14 23:30:16 joerg Exp $ */
+/* $NetBSD: setlocale_local.h,v 1.11 2013/04/14 23:44:54 joerg Exp $ */
/*-
* Copyright (c)2008 Citrus Project,
@@ -92,6 +92,7 @@
}
extern struct _locale _global_locale;
+extern __dso_hidden struct _locale *_C_locale;
extern size_t __mb_len_max_runtime;
#endif /*_SETLOCALE_LOCAL_H_*/
Home |
Main Index |
Thread Index |
Old Index