diff options
author | Tom Tromey <tromey@adacore.com> | 2020-10-21 08:54:17 -0600 |
---|---|---|
committer | Tom Tromey <tromey@adacore.com> | 2020-10-21 11:52:17 -0600 |
commit | 0d01fbe64f6f3f66fb6bd3b4e79e389e600b69a2 (patch) | |
tree | 454f3fb08e8503fa243a44badf74f05a9a7128d9 /libctf | |
parent | ffd73a8b9ed30934b3cd00c15f5aa041621dcf9c (diff) | |
download | fsf-binutils-gdb-0d01fbe64f6f3f66fb6bd3b4e79e389e600b69a2.zip fsf-binutils-gdb-0d01fbe64f6f3f66fb6bd3b4e79e389e600b69a2.tar.gz fsf-binutils-gdb-0d01fbe64f6f3f66fb6bd3b4e79e389e600b69a2.tar.bz2 |
Remove libctf/mkerrors.sed
This patch removes libctf/mkerrors.sed, replacing it with a macro in
ctf-api.h. This simplifies the build and avoids possible unportable
code in the sed script.
2020-10-21 Tom Tromey <tromey@adacore.com>
* ctf-api.h (_CTF_ERRORS): New macro.
libctf/ChangeLog
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.
Diffstat (limited to 'libctf')
-rw-r--r-- | libctf/ChangeLog | 12 | ||||
-rw-r--r-- | libctf/Makefile.am | 5 | ||||
-rw-r--r-- | libctf/Makefile.in | 15 | ||||
-rw-r--r-- | libctf/ctf-error.c | 27 | ||||
-rw-r--r-- | libctf/mkerrors.sed | 28 |
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; - } |