Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/libc Extract the data for nl_langinfo directly from the ...



details:   https://anonhg.NetBSD.org/src/rev/adb519cb3a3f
branches:  trunk
changeset: 789497:adb519cb3a3f
user:      joerg <joerg%NetBSD.org@localhost>
date:      Tue Aug 20 19:58:30 2013 +0000

description:
Extract the data for nl_langinfo directly from the corresponding
part implementation using a category/offset table.

diffstat:

 lib/libc/citrus/citrus_lc_ctype.c     |    7 +-
 lib/libc/locale/global_locale.c       |   66 +--------------
 lib/libc/locale/nb_lc_messages_misc.h |    8 +-
 lib/libc/locale/nb_lc_monetary_misc.h |    5 +-
 lib/libc/locale/nb_lc_numeric_misc.h  |    6 +-
 lib/libc/locale/nb_lc_time_misc.h     |   27 +-----
 lib/libc/locale/nl_langinfo.c         |  149 ++++++++++++++++++++++++++++++++-
 lib/libc/locale/setlocale_local.h     |    3 +-
 8 files changed, 150 insertions(+), 121 deletions(-)

diffs (truncated from 440 to 300 lines):

diff -r ca12beaa0af3 -r adb519cb3a3f lib/libc/citrus/citrus_lc_ctype.c
--- a/lib/libc/citrus/citrus_lc_ctype.c Tue Aug 20 19:19:23 2013 +0000
+++ b/lib/libc/citrus/citrus_lc_ctype.c Tue Aug 20 19:58:30 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: citrus_lc_ctype.c,v 1.13 2013/08/19 22:43:28 joerg Exp $ */
+/* $NetBSD: citrus_lc_ctype.c,v 1.14 2013/08/20 19:58:30 joerg Exp $ */
 
 /*-
  * Copyright (c)2008 Citrus Project,
@@ -28,7 +28,7 @@
 
 #include <sys/cdefs.h>
 #if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: citrus_lc_ctype.c,v 1.13 2013/08/19 22:43:28 joerg Exp $");
+__RCSID("$NetBSD: citrus_lc_ctype.c,v 1.14 2013/08/20 19:58:30 joerg Exp $");
 #endif /* LIBC_SCCS and not lint */
 
 #include "reentrant.h"
@@ -100,10 +100,7 @@
     _RuneLocale * __restrict data)
 {
        _DIAGASSERT(cache != NULL);
-       _DIAGASSERT(cache->items != NULL);
        _DIAGASSERT(data != NULL);
-
-       cache->items[(size_t)CODESET] = data->rl_codeset;
 }
 
 static __inline void
diff -r ca12beaa0af3 -r adb519cb3a3f lib/libc/locale/global_locale.c
--- a/lib/libc/locale/global_locale.c   Tue Aug 20 19:19:23 2013 +0000
+++ b/lib/libc/locale/global_locale.c   Tue Aug 20 19:58:30 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: global_locale.c,v 1.19 2013/08/19 22:43:28 joerg Exp $ */
+/* $NetBSD: global_locale.c,v 1.20 2013/08/20 19:58:30 joerg Exp $ */
 
 /*-
  * Copyright (c)2008 Citrus Project,
@@ -28,7 +28,7 @@
 
 #include <sys/cdefs.h>
 #if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: global_locale.c,v 1.19 2013/08/19 22:43:28 joerg Exp $");
+__RCSID("$NetBSD: global_locale.c,v 1.20 2013/08/20 19:58:30 joerg Exp $");
 #endif /* LIBC_SCCS and not lint */
 
 #include <sys/types.h>
@@ -137,69 +137,8 @@
        .int_n_sign_posn        = NBCHAR_MAX,
 };
 
-static const char * const _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 struct _locale_cache_t _global_cache = {
     .ldata = __UNCONST(&_C_ldata),
-    .items = __UNCONST(&_C_items[0]),
 };
 
 __dso_protected struct _locale _lc_global_locale = {
@@ -232,7 +171,6 @@
 
 static const struct _locale_cache_t _C_cache = {
     .ldata = __UNCONST(&_C_ldata),
-    .items = __UNCONST(&_C_items[0]),
 };
 
 __dso_protected const struct _locale _lc_C_locale = {
diff -r ca12beaa0af3 -r adb519cb3a3f lib/libc/locale/nb_lc_messages_misc.h
--- a/lib/libc/locale/nb_lc_messages_misc.h     Tue Aug 20 19:19:23 2013 +0000
+++ b/lib/libc/locale/nb_lc_messages_misc.h     Tue Aug 20 19:58:30 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: nb_lc_messages_misc.h,v 1.5 2013/08/19 09:12:58 joerg Exp $ */
+/* $NetBSD: nb_lc_messages_misc.h,v 1.6 2013/08/20 19:58:30 joerg Exp $ */
 
 /*-
  * Copyright (c)2008 Citrus Project,
@@ -39,13 +39,7 @@
     _MessagesLocale * __restrict data)
 {
        _DIAGASSERT(cache != NULL);
-       _DIAGASSERT(cache->items != NULL);
        _DIAGASSERT(data != NULL);
-
-       cache->items[(size_t)YESSTR ] = data->yesstr;
-       cache->items[(size_t)YESEXPR] = data->yesexpr;
-       cache->items[(size_t)NOSTR  ] = data->nostr;
-       cache->items[(size_t)NOEXPR ] = data->noexpr;
 }
 
 /* ARGSUSED */
diff -r ca12beaa0af3 -r adb519cb3a3f lib/libc/locale/nb_lc_monetary_misc.h
--- a/lib/libc/locale/nb_lc_monetary_misc.h     Tue Aug 20 19:19:23 2013 +0000
+++ b/lib/libc/locale/nb_lc_monetary_misc.h     Tue Aug 20 19:58:30 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: nb_lc_monetary_misc.h,v 1.5 2013/08/19 09:12:58 joerg Exp $ */
+/* $NetBSD: nb_lc_monetary_misc.h,v 1.6 2013/08/20 19:58:30 joerg Exp $ */
 
 /*-
  * Copyright (c)2008 Citrus Project,
@@ -42,7 +42,6 @@
 
        _DIAGASSERT(cache != NULL);
        _DIAGASSERT(cache->ldata != NULL);
-       _DIAGASSERT(cache->items != NULL);
        _DIAGASSERT(data != NULL);
 
        ldata = cache->ldata;
@@ -68,8 +67,6 @@
        ldata->int_n_sep_by_space = data->int_n_sep_by_space;
        ldata->int_p_sign_posn    = data->int_p_sign_posn;
        ldata->int_n_sign_posn    = data->int_n_sign_posn;
-
-       cache->items[(size_t)CRNCYSTR] = NULL; /* NOT IMPLEMENTED YET */
 }
 
 /* ARGSUSED */
diff -r ca12beaa0af3 -r adb519cb3a3f lib/libc/locale/nb_lc_numeric_misc.h
--- a/lib/libc/locale/nb_lc_numeric_misc.h      Tue Aug 20 19:19:23 2013 +0000
+++ b/lib/libc/locale/nb_lc_numeric_misc.h      Tue Aug 20 19:58:30 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: nb_lc_numeric_misc.h,v 1.5 2013/08/19 09:12:58 joerg Exp $ */
+/* $NetBSD: nb_lc_numeric_misc.h,v 1.6 2013/08/20 19:58:30 joerg Exp $ */
 
 /*-
  * Copyright (c)2008 Citrus Project,
@@ -42,16 +42,12 @@
 
        _DIAGASSERT(cache != NULL);
        _DIAGASSERT(cache->ldata != NULL);
-       _DIAGASSERT(cache->items != NULL);
        _DIAGASSERT(data != NULL);
 
        ldata = cache->ldata;
        ldata->decimal_point = __UNCONST(data->decimal_point);
        ldata->thousands_sep = __UNCONST(data->thousands_sep);
        ldata->grouping      = __UNCONST(data->grouping);
-
-       cache->items[(size_t)RADIXCHAR] = data->decimal_point;
-       cache->items[(size_t)THOUSEP  ] = data->thousands_sep;
 }
 
 /* ARGSUSED */
diff -r ca12beaa0af3 -r adb519cb3a3f lib/libc/locale/nb_lc_time_misc.h
--- a/lib/libc/locale/nb_lc_time_misc.h Tue Aug 20 19:19:23 2013 +0000
+++ b/lib/libc/locale/nb_lc_time_misc.h Tue Aug 20 19:58:30 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: nb_lc_time_misc.h,v 1.6 2013/08/19 09:12:58 joerg Exp $ */
+/* $NetBSD: nb_lc_time_misc.h,v 1.7 2013/08/20 19:58:30 joerg Exp $ */
 
 /*-
  * Copyright (c)2008 Citrus Project,
@@ -45,33 +45,8 @@
 _PREFIX(build_cache)(struct _locale_cache_t * __restrict cache,
     _TimeLocale * __restrict data)
 {
-       size_t i;
-
        _DIAGASSERT(cache != NULL);
-       _DIAGASSERT(cache->items != NULL);
        _DIAGASSERT(data != NULL);
-
-        for (i = (size_t)ABDAY_1; i <= ABDAY_7;  ++i)
-               cache->items[i] = data->abday[ABDAY_IDX(i)];
-        for (i = (size_t)DAY_1;   i <= DAY_7;    ++i)
-               cache->items[i] = data->day[DAY_IDX(i)];
-        for (i = (size_t)ABMON_1; i <= ABMON_12; ++i)
-               cache->items[i] = data->abmon[ABMON_IDX(i)];
-        for (i = (size_t)MON_1;   i <= MON_12;   ++i)
-               cache->items[i] = data->mon[MON_IDX(i)];
-        for (i = (size_t)AM_STR;  i <= PM_STR;   ++i)
-               cache->items[i] = data->am_pm[AM_PM_IDX(i)];
-       cache->items[(size_t)D_T_FMT    ] = data->d_t_fmt;
-       cache->items[(size_t)D_FMT      ] = data->d_fmt;
-       cache->items[(size_t)T_FMT      ] = data->t_fmt;
-       cache->items[(size_t)T_FMT_AMPM ] = data->t_fmt_ampm;
-
-       /* NOT IMPLEMENTED YET */
-       cache->items[(size_t)ERA        ] = NULL;
-       cache->items[(size_t)ERA_D_FMT  ] = NULL;
-       cache->items[(size_t)ERA_D_T_FMT] = NULL;
-       cache->items[(size_t)ERA_T_FMT  ] = NULL;
-       cache->items[(size_t)ALT_DIGITS ] = NULL;
 }
 
 /* ARGSUSED */
diff -r ca12beaa0af3 -r adb519cb3a3f lib/libc/locale/nl_langinfo.c
--- a/lib/libc/locale/nl_langinfo.c     Tue Aug 20 19:19:23 2013 +0000
+++ b/lib/libc/locale/nl_langinfo.c     Tue Aug 20 19:58:30 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: nl_langinfo.c,v 1.16 2013/08/19 08:03:34 joerg Exp $ */
+/* $NetBSD: nl_langinfo.c,v 1.17 2013/08/20 19:58:30 joerg Exp $ */
 
 /*-
  * Copyright (c)2008 Citrus Project,
@@ -27,17 +27,141 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: nl_langinfo.c,v 1.16 2013/08/19 08:03:34 joerg Exp $");
+__RCSID("$NetBSD: nl_langinfo.c,v 1.17 2013/08/20 19:58:30 joerg Exp $");
 
 #include "namespace.h"
 #include <sys/types.h>
+#include <sys/localedef.h>
 #include <langinfo.h>
+#include <stddef.h>
 #define __SETLOCALE_SOURCE__
 #include <locale.h>
 #include <stdlib.h>
+#include <string.h>
 
+#include "runetype_local.h"
 #include "setlocale_local.h"
 
+static const char langinfo_category[] = {
+    [ D_T_FMT ] = LC_TIME,
+    [ D_FMT ] = LC_TIME,
+    [ T_FMT ] = LC_TIME,
+    [ T_FMT_AMPM ] = LC_TIME,
+    [ AM_STR ] = LC_TIME,
+    [ PM_STR ] = LC_TIME,
+    [ DAY_1 ] = LC_TIME,
+    [ DAY_2 ] = LC_TIME,
+    [ DAY_3 ] = LC_TIME,
+    [ DAY_4 ] = LC_TIME,
+    [ DAY_5 ] = LC_TIME,
+    [ DAY_6 ] = LC_TIME,
+    [ DAY_7 ] = LC_TIME,
+    [ ABDAY_1 ] = LC_TIME,
+    [ ABDAY_2 ] = LC_TIME,
+    [ ABDAY_3 ] = LC_TIME,
+    [ ABDAY_4 ] = LC_TIME,
+    [ ABDAY_5 ] = LC_TIME,
+    [ ABDAY_6 ] = LC_TIME,
+    [ ABDAY_7 ] = LC_TIME,
+    [ MON_1 ] = LC_TIME,
+    [ MON_2 ] = LC_TIME,
+    [ MON_3 ] = LC_TIME,
+    [ MON_4 ] = LC_TIME,
+    [ MON_5 ] = LC_TIME,
+    [ MON_6 ] = LC_TIME,
+    [ MON_7 ] = LC_TIME,



Home | Main Index | Thread Index | Old Index