]> git.draconx.ca Git - cdecl99.git/commitdiff
Consolidate header files.
authorNick Bowler <nbowler@draconx.ca>
Tue, 2 Mar 2021 05:13:56 +0000 (00:13 -0500)
committerNick Bowler <nbowler@draconx.ca>
Wed, 3 Mar 2021 01:23:59 +0000 (20:23 -0500)
There is no need for this quantity of tiny header files.  We can simply
use a single internal header file for libcdecl, and a single internal
header file for cdecl99, including all necessary declarations.

19 files changed:
Makefile.am
src/cdecl-internal.h [new file with mode: 0644]
src/cdecl99.c
src/cdecl99.h
src/declare.c
src/error.c
src/error.h [deleted file]
src/explain.c
src/history.h [deleted file]
src/i18n.c
src/i18n.h [deleted file]
src/normalize.c
src/normalize.h [deleted file]
src/output.c
src/output.h [deleted file]
src/parse-decl.c
src/parse.y
src/typemap.c
src/typemap.h [deleted file]

index ce76be1d0589b9d1d38a2b94749c787a3fb5f458..ffbc85f0947334ee519b75c1a8698e2723cc9e0e 100644 (file)
@@ -35,18 +35,17 @@ EXTRA_DIST = bootstrap $(DX_BASEDIR)/scripts/fix-gnulib.pl m4/gnulib-cache.m4 \
 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 = 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
 
 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 \
 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)
 
 libcdecl_la_LIBADD = libgnu.la $(LTLIBINTL) $(LTLIBTHREAD)
 $(libcdecl_la_OBJECTS): $(gnulib_headers)
 
diff --git a/src/cdecl-internal.h b/src/cdecl-internal.h
new file mode 100644 (file)
index 0000000..2140006
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * 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
index 18c6a5d8676e4f671e8ecc6145cb37dd8b779d85..00053b26c83a19378a94cfd26cf634a86380deca 100644 (file)
@@ -25,8 +25,6 @@
 #include <errno.h>
 #include <locale.h>
 #include <assert.h>
 #include <errno.h>
 #include <locale.h>
 #include <assert.h>
-#include "history.h"
-#include "cdecl.h"
 
 #include <getopt.h>
 #include <gettext.h>
 
 #include <getopt.h>
 #include <gettext.h>
@@ -36,6 +34,7 @@
 #include <mbswidth.h>
 
 #include "cdecl99.h"
 #include <mbswidth.h>
 
 #include "cdecl99.h"
+#include "cdecl.h"
 
 static const char *progname = "cdecl99";
 
 
 static const char *progname = "cdecl99";
 
@@ -187,7 +186,7 @@ static int repl(void)
 
        for (; (line = readline("> ")); free(line)) {
                if (!is_blank_line(line))
 
        for (; (line = readline("> ")); free(line)) {
                if (!is_blank_line(line))
-                       cdecl_add_history(line);
+                       add_history(line);
 
                if (run_command(line, true) > 0)
                        break;
 
                if (run_command(line, true) > 0)
                        break;
index 6eb1b6cb3f2e9818420b2f29cd5327529590b6ca..e1030d44994df369cab205ca93b8271703f464d5 100644 (file)
@@ -28,4 +28,12 @@ int run_command_simplify(const char *arg);
 int run_command_explain(const char *arg);
 int run_command_declare(const char *cmdarg);
 
 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
 #endif
index d5af7149e551570dee37569413eafdcd9553dfe1..4fc9feeebea7f84aa0e0dca21e234bfd7315ce6f 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *  Render C declarations.
 /*
  *  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
  *
  *  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/>.
  */
  *  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 <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)
 {
 
 static size_t declare_specs(char *buf, size_t n, struct cdecl_declspec *s)
 {
index 8d26d5b7c604db7b4ecde35ffd2985a51f327fb6..9b89bac15239c04b0cec366e05af44b103ec8e0d 100644 (file)
@@ -1,12 +1,30 @@
+/*
+ *  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 <config.h>
 #include <stdlib.h>
 #include <string.h>
 #include <assert.h>
 #include <glthread/lock.h>
 #include <glthread/tls.h>
+
 #include "cdecl.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;
 
 gl_once_define(static, tls_initialized);
 static gl_tls_key_t tls_key;
diff --git a/src/error.h b/src/error.h
deleted file mode 100644 (file)
index f7cace9..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-#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
index 1b46d20a98640d8890526577c5b3e4a2793a0db6..0f6b787afcb135122187322b668eb6f35813aa37 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *  Render C declarations as English.
 /*
  *  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
  *
  *  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
@@ -15,6 +15,7 @@
  *  You should have received a copy of the GNU General Public License
  *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
  *  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 <config.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -23,7 +24,7 @@
 #include <assert.h>
 
 #include "cdecl.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
 
 /*
  * Renders the start of the thing being declared.  If top is true, print
diff --git a/src/history.h b/src/history.h
deleted file mode 100644 (file)
index 2d519ee..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * 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
index c691443bbdc1ae0303d3ee8810fa8f350a881cdb..476386e40b084cd8b2f8d07d762bec42d951e760 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *  Library initialization.
 /*
  *  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
  *
  *  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/>.
  */
  *  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 <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)
 {
 
 static void initialize(void)
 {
diff --git a/src/i18n.h b/src/i18n.h
deleted file mode 100644 (file)
index e1b5503..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-#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
index 704d575582e10f24bdc5bc39bf0eda8f29712850..e6502d2d951123172ee691b9a35e3add8bb2f339 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *  Normalize C declaration specifier lists.
 /*
  *  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
  *
  *  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/>.
  */
  *  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 <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
 
 /*
  * Totally order the declaration specifier types by defining an injection into
diff --git a/src/normalize.h b/src/normalize.h
deleted file mode 100644 (file)
index 3785df5..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-#ifndef CDECL_NORMALIZE_H_
-#define CDECL_NORMALIZE_H_
-
-struct cdecl_declspec;
-struct cdecl_declspec *cdecl__normalize_specs(struct cdecl_declspec *specs);
-
-#endif
index 8fffd24af2e8129455e9e07f5e2ee4da356a2956..22fc2e9d0e221746a4ba2fef93de0051ac5153a6 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *  Helper functions for outputting text.
 /*
  *  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
  *
  *  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
@@ -19,9 +19,8 @@
 #include <stdio.h>
 #include <assert.h>
 
 #include <stdio.h>
 #include <assert.h>
 
-#include "typemap.h"
-#include "output.h"
 #include "cdecl.h"
 #include "cdecl.h"
+#include "cdecl-internal.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)
 {
diff --git a/src/output.h b/src/output.h
deleted file mode 100644 (file)
index 28a13de..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-#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
index 694f4ab32c3875458b8293f98d619ce3b1be707c..27577038a5dd9879d3bee532322b41a55396ba8a 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Parse and validate C declarations.
 /*
  * 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
  *
  * 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 <stdbool.h>
 
 #include "cdecl.h"
-#include "typemap.h"
+#include "cdecl-internal.h"
 #include "parse.h"
 #include "scan.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
 
 /*
  * Verify the declaration specifiers of a declaration.  If top is true, treat
index 9c644da4bf02f01b424ec92fd15ea26a29aed9a9..a14f909c530ceb58377743b331e33ae56878a813 100644 (file)
@@ -1,7 +1,7 @@
 %code top {
 /*
  *  Parser for C declarations.
 %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
  *
  *  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
@@ -32,8 +32,8 @@
 #include <stdbool.h>
 
 #include "scan.h"
 #include <stdbool.h>
 
 #include "scan.h"
-#include "error.h"
 #include "cdecl.h"
 #include "cdecl.h"
+#include "cdecl-internal.h"
 
 #define FAIL(msg) do { \
        yyerror(&yylloc, NULL, NULL, msg); \
 
 #define FAIL(msg) do { \
        yyerror(&yylloc, NULL, NULL, msg); \
index a280be20499f4777c727b0e0b761aee2764bbcb3..918a037f167e808808a30e1ecb912eecdb062876 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *  Helpers for dealing with type specifiers.
 /*
  *  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
  *
  *  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/>.
  */
  *  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 <config.h>
 #include <stdio.h>
 #include <stdbool.h>
 #include <assert.h>
+
 #include "cdecl.h"
 #include "cdecl.h"
-#include "typemap.h"
+#include "cdecl-internal.h"
 
 /*
  * We can represent type specifiers as a bitmap, which gives us a finite
 
 /*
  * We can represent type specifiers as a bitmap, which gives us a finite
diff --git a/src/typemap.h b/src/typemap.h
deleted file mode 100644 (file)
index d43afa7..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-#ifndef CDECL_TYPEMAP_H_
-#define CDECL_TYPEMAP_H_
-
-#include "cdecl.h"
-
-unsigned long cdecl__build_typemap(struct cdecl_declspec *s);
-
-#endif