aboutsummaryrefslogtreecommitdiff
path: root/libctf
diff options
context:
space:
mode:
Diffstat (limited to 'libctf')
-rw-r--r--libctf/ChangeLog12
-rw-r--r--libctf/Makefile.am5
-rw-r--r--libctf/Makefile.in15
-rw-r--r--libctf/ctf-error.c27
-rw-r--r--libctf/mkerrors.sed28
5 files changed, 31 insertions, 56 deletions
diff --git a/libctf/ChangeLog b/libctf/ChangeLog
index e193436..a9aaea6 100644
--- a/libctf/ChangeLog
+++ b/libctf/ChangeLog
@@ -1,3 +1,15 @@
+2020-10-21 Tom Tromey <tromey@adacore.com>
+
+ * mkerrors.sed: Remove.
+ * ctf-error.c (_CTF_FIRST): New define.
+ (_CTF_ITEM): Define this, not _CTF_STR.
+ (_ctf_errlist, _ctf_erridx): Use _CTF_ERRORS.
+ (ERRSTRFIELD): Rewrite.
+ (ERRSTRFIELD1): Remove.
+ * Makefile.in: Rebuild.
+ * Makefile.am (BUILT_SOURCES): Remove.
+ (ctf-error.h): Remove.
+
2020-08-27 Nick Alcock <nick.alcock@oracle.com>
* ctf-subr.c (open_errors): New list.
diff --git a/libctf/Makefile.am b/libctf/Makefile.am
index d762b0a..fc1f229 100644
--- a/libctf/Makefile.am
+++ b/libctf/Makefile.am
@@ -55,8 +55,3 @@ libctf_la_CPPFLAGS = $(AM_CPPFLAGS) -DNOBFD=0
libctf_la_DEPENDENCIES = @BFD_DEPENDENCIES@
libctf_la_LDFLAGS = $(libctf_nobfd_la_LDFLAGS)
libctf_la_SOURCES = $(libctf_nobfd_la_SOURCES) ctf-open-bfd.c
-
-BUILT_SOURCES = ctf-error.h
-
-ctf-error.h: $(srcdir)/mkerrors.sed $(srcdir)/../include/ctf-api.h
- sed -nf $(srcdir)/mkerrors.sed < $(srcdir)/../include/ctf-api.h > $@
diff --git a/libctf/Makefile.in b/libctf/Makefile.in
index f43c095..23b83b2 100644
--- a/libctf/Makefile.in
+++ b/libctf/Makefile.in
@@ -465,8 +465,7 @@ libctf_la_CPPFLAGS = $(AM_CPPFLAGS) -DNOBFD=0
libctf_la_DEPENDENCIES = @BFD_DEPENDENCIES@
libctf_la_LDFLAGS = $(libctf_nobfd_la_LDFLAGS)
libctf_la_SOURCES = $(libctf_nobfd_la_SOURCES) ctf-open-bfd.c
-BUILT_SOURCES = ctf-error.h
-all: $(BUILT_SOURCES) config.h
+all: config.h
$(MAKE) $(AM_MAKEFLAGS) all-am
.SUFFIXES:
@@ -1133,15 +1132,13 @@ distcleancheck: distclean
$(distcleancheck_listfiles) ; \
exit 1; } >&2
check-am: all-am
-check: $(BUILT_SOURCES)
- $(MAKE) $(AM_MAKEFLAGS) check-am
+check: check-am
all-am: Makefile $(LTLIBRARIES) $(HEADERS) config.h
installdirs:
for dir in "$(DESTDIR)$(libdir)" "$(DESTDIR)$(includedir)"; do \
test -z "$$dir" || $(MKDIR_P) "$$dir"; \
done
-install: $(BUILT_SOURCES)
- $(MAKE) $(AM_MAKEFLAGS) install-am
+install: install-am
install-exec: install-exec-am
install-data: install-data-am
uninstall: uninstall-am
@@ -1171,7 +1168,6 @@ distclean-generic:
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@echo "it deletes files that may require special tools to rebuild."
- -test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES)
clean: clean-am
clean-am: clean-generic clean-libLTLIBRARIES clean-libtool \
@@ -1246,7 +1242,7 @@ ps-am:
uninstall-am: uninstall-includeHEADERS uninstall-libLTLIBRARIES
-.MAKE: all check install install-am install-strip
+.MAKE: all install-am install-strip
.PHONY: CTAGS GTAGS TAGS all all-am am--refresh check check-am clean \
clean-cscope clean-generic clean-libLTLIBRARIES clean-libtool \
@@ -1270,9 +1266,6 @@ uninstall-am: uninstall-includeHEADERS uninstall-libLTLIBRARIES
.PRECIOUS: Makefile
-ctf-error.h: $(srcdir)/mkerrors.sed $(srcdir)/../include/ctf-api.h
- sed -nf $(srcdir)/mkerrors.sed < $(srcdir)/../include/ctf-api.h > $@
-
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:
diff --git a/libctf/ctf-error.c b/libctf/ctf-error.c
index 9611e36..cb46a82 100644
--- a/libctf/ctf-error.c
+++ b/libctf/ctf-error.c
@@ -24,10 +24,13 @@
/* This construct is due to Bruno Haible: much thanks. */
/* Give each structure member a unique name. The name does not matter, so we
- use the line number in ctf-error.h to uniquify them. */
+ use the enum constant to uniquify them. */
-#define ERRSTRFIELD(line) ERRSTRFIELD1 (line)
-#define ERRSTRFIELD1(line) ctf_errstr##line
+#define ERRSTRFIELD(N) ctf_errstr##N
+
+/* In this file, we want to treat the first item of the ctf error
+ macro like subsequent items. */
+#define _CTF_FIRST(NAME, VALUE) _CTF_ITEM(NAME, VALUE)
/* The error message strings, each in a unique structure member precisely big
enough for that error, plus a str member to access them all as a string
@@ -37,17 +40,17 @@ static const union _ctf_errlist_t
{
__extension__ struct
{
-#define _CTF_STR(n, s) char ERRSTRFIELD (__LINE__) [sizeof (s)];
-#include "ctf-error.h"
-#undef _CTF_STR
+#define _CTF_ITEM(n, s) char ERRSTRFIELD (n) [sizeof (s)];
+_CTF_ERRORS
+#undef _CTF_ITEM
};
char str[1];
} _ctf_errlist =
{
{
-#define _CTF_STR(n, s) N_(s),
-#include "ctf-error.h"
-#undef _CTF_STR
+#define _CTF_ITEM(n, s) N_(s),
+_CTF_ERRORS
+#undef _CTF_ITEM
}
};
@@ -55,9 +58,9 @@ static const union _ctf_errlist_t
static const unsigned int _ctf_erridx[] =
{
-#define _CTF_STR(n, s) [n - ECTF_BASE] = offsetof (union _ctf_errlist_t, ERRSTRFIELD (__LINE__)),
-#include "ctf-error.h"
-#undef _CTF_STR
+#define _CTF_ITEM(n, s) [n - ECTF_BASE] = offsetof (union _ctf_errlist_t, ERRSTRFIELD (n)),
+_CTF_ERRORS
+#undef _CTF_ITEM
};
const char *
diff --git a/libctf/mkerrors.sed b/libctf/mkerrors.sed
deleted file mode 100644
index ddd4d22..0000000
--- a/libctf/mkerrors.sed
+++ /dev/null
@@ -1,28 +0,0 @@
-#
-# Copyright (C) 2020 Free Software Foundation, Inc.
-#
-# This file 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 2 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; see the file COPYING. If not see
-# <http://www.gnu.org/licenses/>.
-#
-
-# Only process lines in the error-define block
-/= ECTF_BASE/,/ECTF_NERR/ {
- # Do not process non-errors (braces, ECTF_NERR, etc).
- /^ *ECTF_/!n;
- # Strip out the base initializer.
- s, = ECTF_BASE,,;
- # Transform errors into _STR(...).
- s@^ *\(ECTF_[^[:blank:],]*\),\{0,1\}[[:blank:]]*/\* \(.*\). \*/$@_CTF_STR (\1, "\2")@;
- p;
- }