EXTRA_libcdecl_la_DEPENDENCIES = $(shared_gl_objects)
$(libcdecl_la_OBJECTS): $(gnulib_headers)
-if USE_NLS
-libcdecl_la_SOURCES += src/i18n.c
-endif
-
EXTRA_LIBRARIES = libgnu.a
libgnu_a_SOURCES =
libgnu_a_SHORTNAME = s
#include "errmsg.h"
-gl_once_define(static, tls_initialized)
-static gl_tls_key_t tls_key;
-
struct err_state {
struct cdecl_error err;
size_t nstr;
/* This pre-initialized error is reserved for dire out-of-memory conditions. */
static struct cdecl_error err_no_mem;
+static gl_tls_key_t tls_key;
static void free_err(void *err)
{
err->str = _(&errmsgs[code]);
}
-static void initialize(void)
+static void initialize_cb(void)
{
- cdecl__init_i18n();
+#if ENABLE_NLS
+ bindtextdomain(PACKAGE, LOCALEDIR);
+ bindtextdomain("bison-runtime", BISON_LOCALEDIR);
+#endif
set_err(CDECL__ENOMEM, &err_no_mem);
gl_tls_key_init(tls_key, free_err);
}
{
void *state;
- gl_once(tls_initialized, initialize);
+ gl_once_define(static, tls_initialized)
+ gl_once(tls_initialized, initialize_cb);
state = gl_tls_get(tls_key);
if (state == &err_no_mem)
return state;
}
+
+#if ENABLE_NLS
+/*
+ * Initialize gettext indirectly via get_err_state.
+ */
+void cdecl__init_i18n(void)
+{
+ get_err_state();
+}
+#endif
+
/*
* Set the library error to one of the preset messages defined in errmsg.h
* (CDECL__Exxx).
+++ /dev/null
-/*
- * Library initialization.
- * Copyright © 2011, 2021 Nick Bowler
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include <config.h>
-#include <stdio.h>
-#include <assert.h>
-
-#include "cdecl-internal.h"
-
-#include <glthread/lock.h>
-
-static void do_init_i18n(void)
-{
- bindtextdomain(PACKAGE, LOCALEDIR);
- bindtextdomain("bison-runtime", BISON_LOCALEDIR);
-}
-
-void cdecl__init_i18n(void)
-{
- gl_once_define(static, initialized);
-
- int err = glthread_once(&initialized, do_init_i18n);
- assert(err == 0);
-}
#include "errmsg.h"
#include "tap.h"
-#if ENABLE_NLS
-void cdecl__init_i18n(void) { }
-#endif
-
static char *fmt_char(int c, char *buf)
{
int escape = 0;