dist_man_MANS = doc/man/cdecl99.1 doc/man/libcdecl.3
include_HEADERS = src/cdecl.h
-noinst_HEADERS = conf_pre.h conf_post.h src/typemap.h src/output.h src/scan.h \
- src/parse.h src/i18n.h src/normalize.h src/error.h src/history.h \
- test/declgen.h test/test.h
+noinst_HEADERS = conf_pre.h conf_post.h src/scan.h src/parse.h \
+ test/declgen.h test/test.h
noinst_DATA = $(MOFILES)
lib_LTLIBRARIES = libcdecl.la
-libcdecl_la_LDFLAGS = -no-undefined \
- -export-symbols-regex '^cdecl_[[:lower:]]'
+libcdecl_la_LDFLAGS = -export-symbols-regex '^cdecl_[[:lower:]]' \
+ -no-undefined
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 src/i18n.c src/error.c \
- src/normalize.c
+ src/output.c src/explain.c src/declare.c src/i18n.c \
+ src/error.c src/normalize.c src/cdecl-internal.h
libcdecl_la_LIBADD = libgnu.la $(LTLIBINTL) $(LTLIBTHREAD)
$(libcdecl_la_OBJECTS): $(gnulib_headers)
--- /dev/null
+/*
+ * Internal declarations for libcdecl.
+ * Copyright © 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 <https://www.gnu.org/licenses/>.
+ */
+#ifndef CDECL_INTERNAL_H_
+#define CDECL_INTERNAL_H_
+
+#include <stddef.h>
+#include <gettext.h>
+
+#define _(s) dgettext(PACKAGE, s)
+#define N_(s) s
+
+struct cdecl_error;
+struct cdecl_declspec;
+
+void cdecl__init_i18n(void);
+
+const char *cdecl__strerror(unsigned code);
+void cdecl__set_error(const struct cdecl_error *err);
+
+unsigned long cdecl__build_typemap(struct cdecl_declspec *s);
+struct cdecl_declspec *cdecl__normalize_specs(struct cdecl_declspec *specs);
+
+size_t cdecl__advance_(char **buf, size_t *n, size_t amount);
+size_t cdecl__advance(char **buf, size_t *n, size_t amount);
+size_t cdecl__explain_specs(char *buf, size_t n, struct cdecl_declspec *s,
+ unsigned mask);
+size_t cdecl__explain_pre_specs(char *buf, size_t n, struct cdecl_declspec *s);
+size_t cdecl__explain_post_specs(char *buf, size_t n, struct cdecl_declspec *s);
+
+#endif
#include <errno.h>
#include <locale.h>
#include <assert.h>
-#include "history.h"
-#include "cdecl.h"
#include <getopt.h>
#include <gettext.h>
#include <mbswidth.h>
#include "cdecl99.h"
+#include "cdecl.h"
static const char *progname = "cdecl99";
for (; (line = readline("> ")); free(line)) {
if (!is_blank_line(line))
- cdecl_add_history(line);
+ add_history(line);
if (run_command(line, true) > 0)
break;
int run_command_explain(const char *arg);
int run_command_declare(const char *cmdarg);
+#if HAVE_RL_ADD_HISTORY && HAVE_READLINE_HISTORY_H
+# include <readline/history.h>
+#else
+static inline void add_history(const char *str)
+{
+}
+#endif
+
#endif
/*
* Render C declarations.
- * Copyright © 2011 Nick Bowler
+ * 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
* 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 <stdbool.h>
#include <assert.h>
#include "cdecl.h"
-#include "output.h"
+#include "cdecl-internal.h"
static size_t declare_specs(char *buf, size_t n, struct cdecl_declspec *s)
{
+/*
+ * Error handling for libcdecl.
+ * Copyright © 2011-2012, 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 <stdlib.h>
#include <string.h>
#include <assert.h>
#include <glthread/lock.h>
#include <glthread/tls.h>
+
#include "cdecl.h"
-#include "error.h"
-#include "i18n.h"
+#include "cdecl-internal.h"
gl_once_define(static, tls_initialized);
static gl_tls_key_t tls_key;
+++ /dev/null
-#ifndef CDECL_ERROR_H_
-#define CDECL_ERROR_H_
-
-struct cdecl_error;
-const char *cdecl__strerror(unsigned code);
-void cdecl__set_error(const struct cdecl_error *err);
-
-#endif
/*
* Render C declarations as English.
- * Copyright © 2011 Nick Bowler
+ * 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
* 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 <stdlib.h>
#include <assert.h>
#include "cdecl.h"
-#include "output.h"
+#include "cdecl-internal.h"
/*
* Renders the start of the thing being declared. If top is true, print
+++ /dev/null
-/*
- * Simple wrappers around libhistory to stub out unavailable functions.
- * Copyright © 2012 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/>.
- */
-
-#if HAVE_READLINE_HISTORY_H
-# include <readline/history.h>
-#endif
-
-#if HAVE_RL_ADD_HISTORY
-static inline void cdecl_add_history(const char *str)
-{
- add_history(str);
-}
-#else
-static inline void cdecl_add_history(const char *str)
-{
-}
-#endif
/*
* Library initialization.
- * Copyright © 2011 Nick Bowler
+ * 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
* 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 <glthread/lock.h>
-#include <gettext.h>
-#include "i18n.h"
+
+#include "cdecl-internal.h"
static void initialize(void)
{
+++ /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
/*
* Normalize C declaration specifier lists.
- * Copyright © 2011 Nick Bowler
+ * 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
* 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 <stdlib.h>
#include <assert.h>
#include "cdecl.h"
-#include "normalize.h"
+#include "cdecl-internal.h"
/*
* Totally order the declaration specifier types by defining an injection into
+++ /dev/null
-#ifndef CDECL_NORMALIZE_H_
-#define CDECL_NORMALIZE_H_
-
-struct cdecl_declspec;
-struct cdecl_declspec *cdecl__normalize_specs(struct cdecl_declspec *specs);
-
-#endif
/*
* Helper functions for outputting text.
- * Copyright © 2011 Nick Bowler
+ * 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
#include <stdio.h>
#include <assert.h>
-#include "typemap.h"
-#include "output.h"
#include "cdecl.h"
+#include "cdecl-internal.h"
size_t cdecl__advance_(char **buf, size_t *n, size_t amount)
{
+++ /dev/null
-#ifndef CDECL_OUTPUT_H_
-#define CDECL_OUTPUT_H_
-
-#include <stddef.h>
-#include "cdecl.h"
-
-size_t cdecl__advance_(char **buf, size_t *n, size_t amount);
-size_t cdecl__advance(char **buf, size_t *n, size_t amount);
-size_t cdecl__explain_specs(char *buf, size_t n, struct cdecl_declspec *s,
- unsigned mask);
-size_t cdecl__explain_pre_specs(char *buf, size_t n, struct cdecl_declspec *s);
-size_t cdecl__explain_post_specs(char *buf, size_t n, struct cdecl_declspec *s);
-
-#endif
/*
* Parse and validate C declarations.
- * Copyright © 2011-2012, 2020 Nick Bowler
+ * Copyright © 2011-2012, 2020-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
#include <stdbool.h>
#include "cdecl.h"
-#include "typemap.h"
+#include "cdecl-internal.h"
#include "parse.h"
#include "scan.h"
-#include "i18n.h"
-#include "normalize.h"
/*
* Verify the declaration specifiers of a declaration. If top is true, treat
%code top {
/*
* Parser for C declarations.
- * Copyright © 2011 Nick Bowler
+ * Copyright © 2011-2012, 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
#include <stdbool.h>
#include "scan.h"
-#include "error.h"
#include "cdecl.h"
+#include "cdecl-internal.h"
#define FAIL(msg) do { \
yyerror(&yylloc, NULL, NULL, msg); \
/*
* Helpers for dealing with type specifiers.
- * Copyright © 2011 Nick Bowler
+ * 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
* 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 <stdbool.h>
#include <assert.h>
+
#include "cdecl.h"
-#include "typemap.h"
+#include "cdecl-internal.h"
/*
* We can represent type specifiers as a bitmap, which gives us a finite
+++ /dev/null
-#ifndef CDECL_TYPEMAP_H_
-#define CDECL_TYPEMAP_H_
-
-#include "cdecl.h"
-
-unsigned long cdecl__build_typemap(struct cdecl_declspec *s);
-
-#endif