This makes us require library initialization. To avoid requiring an
explicit call, we implicitly initialize the library when it is first
required. Bring in Gnulib's threading library to do this in a
thread-safe manner when available.
/ltmain.sh
/depcomp
/missing
/ltmain.sh
/depcomp
/missing
/stamp-h1
/install-sh
/arg-nonnull.h
/stamp-h1
/install-sh
/arg-nonnull.h
SUBDIRS = lib .
AM_CPPFLAGS = -I$(top_builddir)/src -I$(top_srcdir)/src \
-I$(top_builddir)/lib -I$(top_srcdir)/lib \
SUBDIRS = lib .
AM_CPPFLAGS = -I$(top_builddir)/src -I$(top_srcdir)/src \
-I$(top_builddir)/lib -I$(top_srcdir)/lib \
+ -DBISON_LOCALEDIR=\"$(BISON_LOCALEDIR)\" \
-DLOCALEDIR=\"$(localedir)\"
MAINTAINERCLEANFILES = src/scan.c src/scan.h src/scan.stamp \
-DLOCALEDIR=\"$(localedir)\"
MAINTAINERCLEANFILES = src/scan.c src/scan.h src/scan.stamp \
dist_man_MANS = doc/man/cdecl99.1 doc/man/libcdecl.3
include_HEADERS = src/cdecl.h
dist_man_MANS = doc/man/cdecl99.1 doc/man/libcdecl.3
include_HEADERS = src/cdecl.h
-noinst_HEADERS = src/typemap.h src/output.h src/scan.h src/parse.h
+noinst_HEADERS = src/typemap.h src/output.h src/scan.h src/parse.h src/i18n.h
noinst_DATA = $(MOFILES)
lib_LTLIBRARIES = libcdecl.la
libcdecl_la_LDFLAGS = -export-symbols-regex '^cdecl_[[:lower:]]'
libcdecl_la_SOURCES = src/scan.c src/parse.c src/parse-decl.c src/typemap.c \
noinst_DATA = $(MOFILES)
lib_LTLIBRARIES = libcdecl.la
libcdecl_la_LDFLAGS = -export-symbols-regex '^cdecl_[[:lower:]]'
libcdecl_la_SOURCES = src/scan.c src/parse.c src/parse-decl.c src/typemap.c \
- src/output.c src/explain.c src/declare.c
-libcdecl_la_LIBADD = $(LTLIBINTL)
+ src/output.c src/explain.c src/declare.c src/i18n.c
+libcdecl_la_LIBADD = $(LTLIBINTL) $(LTLIBTHREAD)
bin_PROGRAMS = cdecl99
cdecl99_SOURCES = src/cdecl99.c
bin_PROGRAMS = cdecl99
cdecl99_SOURCES = src/cdecl99.c
AC_ARG_VAR([BISON], [Command to invoke GNU Bison. Defaults to bison.])
AC_ARG_VAR([BISONFLAGS], [Additional options to pass to Bison.])
AC_CHECK_PROGS([BISON], [bison], [bison])
AC_ARG_VAR([BISON], [Command to invoke GNU Bison. Defaults to bison.])
AC_ARG_VAR([BISONFLAGS], [Additional options to pass to Bison.])
AC_CHECK_PROGS([BISON], [bison], [bison])
AC_CONFIG_FILES([
lib/Makefile
AC_CONFIG_FILES([
lib/Makefile
.Pp
.Nm
is intended to be portable to any system with a working C implementation that
.Pp
.Nm
is intended to be portable to any system with a working C implementation that
-at least makes an effort to support C99. The library maintains no global state
-and thus all functions should be safe for use in a multi-threaded environment.
+at least makes an effort to support C99. The library is thread-safe when
+appropriate facilities exist and are enabled at build time.
.Sh ABSTRACT SYNTAX TREE
The functions in
.Nm
.Sh ABSTRACT SYNTAX TREE
The functions in
.Nm
stdint_h.m4
stdio_h.m4
stdlib_h.m4
stdint_h.m4
stdio_h.m4
stdlib_h.m4
threadlib.m4
uintmax_t.m4
unistd_h.m4
threadlib.m4
uintmax_t.m4
unistd_h.m4
# Specification in the form of a command-line invocation:
# Specification in the form of a command-line invocation:
-# gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=. --conditional-dependencies --libtool --macro-prefix=gl --no-vc-files getopt-gnu gettext readline
+# gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=. --conditional-dependencies --libtool --macro-prefix=gl --no-vc-files getopt-gnu gettext lock readline
# Specification in the form of a few gnulib-tool.m4 macro invocations:
gl_LOCAL_DIR([])
gl_MODULES([
getopt-gnu
gettext
# Specification in the form of a few gnulib-tool.m4 macro invocations:
gl_LOCAL_DIR([])
gl_MODULES([
getopt-gnu
gettext
--- /dev/null
+#include <config.h>
+#include <stdio.h>
+#include <assert.h>
+#include <glthread/lock.h>
+#include <gettext.h>
+#include "i18n.h"
+
+static void initialize(void)
+{
+ bindtextdomain(PACKAGE, LOCALEDIR);
+ bindtextdomain("bison-runtime", BISON_LOCALEDIR);
+}
+
+void cdecl__init_i18n(void)
+{
+ gl_once_define(static, initialized);
+
+ int err = glthread_once(&initialized, initialize);
+ assert(err == 0);
+}
--- /dev/null
+#ifndef CDECL_I18N_H_
+#define CDECL_I18N_H_
+
+#include <gettext.h>
+
+#define _(s) dgettext(PACKAGE, s)
+#define N_(s) s
+
+void cdecl__init_i18n(void);
+
+#endif
#include "typemap.h"
#include "parse.h"
#include "scan.h"
#include "typemap.h"
#include "parse.h"
#include "scan.h"
/*
* Determine if a declarator declares an identifier (other than a function
/*
* Determine if a declarator declares an identifier (other than a function
struct cdecl *decl;
int rc;
struct cdecl *decl;
int rc;
rc = cdecl__yylex_init(&scanner);
if (rc != 0)
return NULL;
rc = cdecl__yylex_init(&scanner);
if (rc != 0)
return NULL;
struct cdecl *decl;
int rc;
struct cdecl *decl;
int rc;
rc = cdecl__yylex_init_extra(true, &scanner);
if (rc != 0)
return NULL;
rc = cdecl__yylex_init_extra(true, &scanner);
if (rc != 0)
return NULL;
#include <assert.h>
#include <stdbool.h>
#include <assert.h>
#include <stdbool.h>