m4-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

enable more compiler warnings


From: Eric Blake
Subject: enable more compiler warnings
Date: Thu, 26 Nov 2009 13:18:23 -0700
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.23) Gecko/20090812 Thunderbird/2.0.0.23 Mnenhy/0.7.6.666

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I'm applying this to branch-1.4, then porting to branch-1.6 and master.
It follows the lead of coreutils to enable more compiler warnings.  Many
of the changes are stylistic, but there are some real ones in there as
well (for example, using atoi is not as robust as using strtol).

- --
Don't work too hard, make some time for fun as well!

Eric Blake             address@hidden
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAksO4o8ACgkQ84KuGfSFAYCh3gCgxdJ8Z7B6VMZPBVhcpZLrFWIV
96QAnA7DE7E8GbJXFGDOe3sfqye97Gzo
=pSDH
-----END PGP SIGNATURE-----
>From 48873014007f6a22b77ed3b3fd8b01705e231715 Mon Sep 17 00:00:00 2001
From: Eric Blake <address@hidden>
Date: Fri, 20 Nov 2009 08:33:24 -0700
Subject: [PATCH 1/5] Update from gnulib.

* gnulib: Update.
* m4/gnulib-cache.m4: Use --makefile-name.
* lib/Makefile.am: Wrap the gnulib-generated file.
* tests/Makefile.am: Likewise.
* .gitignore: Track our wrappers.
* doc/m4.texinfo (Improved capitalize): Fix typo.

Signed-off-by: Eric Blake <address@hidden>
---
 .gitignore         |    6 ++++--
 ChangeLog          |   10 ++++++++++
 doc/m4.texinfo     |    2 +-
 gnulib             |    2 +-
 lib/Makefile.am    |   29 +++++++++++++++++++++++++++++
 m4/gnulib-cache.m4 |    4 ++--
 tests/Makefile.am  |   20 ++++++++++++++++++++
 7 files changed, 67 insertions(+), 6 deletions(-)
 create mode 100644 lib/Makefile.am
 create mode 100644 tests/Makefile.am

diff --git a/.gitignore b/.gitignore
index b6e029c..b88009a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -22,7 +22,8 @@ gendocs.sh
 GNUmakefile
 gnupload
 /install-sh
-lib
+/lib/*
+!/lib/Makefile.am
 link-warning.h
 m4-*
 Makefile.in
@@ -31,4 +32,5 @@ Makefile
 stamp-h
 stamp-h1
 stamp-h.in
-tests
+/tests/*
+!/tests/Makefile.am
diff --git a/ChangeLog b/ChangeLog
index b22db9e..6a35474 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2009-11-25  Eric Blake  <address@hidden>
+
+       Update from gnulib.
+       * gnulib: Update.
+       * m4/gnulib-cache.m4: Use --makefile-name.
+       * lib/Makefile.am: Wrap the gnulib-generated file.
+       * tests/Makefile.am: Likewise.
+       * .gitignore: Track our wrappers.
+       * doc/m4.texinfo (Improved capitalize): Fix typo.
+
 2009-10-05  Eric Blake  <address@hidden>

        Update from gnulib.
diff --git a/doc/m4.texinfo b/doc/m4.texinfo
index 89a80a7..2cf86d4 100644
--- a/doc/m4.texinfo
+++ b/doc/m4.texinfo
@@ -8529,7 +8529,7 @@ Improved capitalize
 necessitating another round of @code{changequote}.

 In the fixed version below, (also shipped as
address@hidden@value{VERSION}/@/examples/@/capitalize.m4}), @code{capitalize}
address@hidden@value{VERSION}/@/examples/@/capitalize2.m4}), @code{capitalize}
 uses the alternate quotes of @samp{<<[} and @samp{]>>} (the longer
 strings are chosen so as to be less likely to appear in the text being
 converted).  The helpers @code{_to_alt} and @code{_from_alt} merely
diff --git a/gnulib b/gnulib
index c844d0c..23cd741 160000
--- a/gnulib
+++ b/gnulib
@@ -1 +1 @@
-Subproject commit c844d0cacce3176e8ca09d890bfb21a77819243b
+Subproject commit 23cd74133c81b80d335c701848b71d85a53402c6
diff --git a/lib/Makefile.am b/lib/Makefile.am
new file mode 100644
index 0000000..eb04128
--- /dev/null
+++ b/lib/Makefile.am
@@ -0,0 +1,29 @@
+## Makefile.am - template for generating Makefile via Automake
+##
+## Copyright (C) 2009 Free Software Foundation, Inc.
+##
+## This file is part of GNU M4.
+##
+## GNU M4 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.
+##
+## GNU M4 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/>.
+
+BUILT_SOURCES =
+CLEANFILES =
+EXTRA_DIST =
+MOSTLYCLEANDIRS =
+MOSTLYCLEANFILES =
+SUFFIXES =
+
+noinst_LIBRARIES = libm4.a
+
+include gnulib.mk
diff --git a/m4/gnulib-cache.m4 b/m4/gnulib-cache.m4
index a2dade3..10458b3 100644
--- a/m4/gnulib-cache.m4
+++ b/m4/gnulib-cache.m4
@@ -15,7 +15,7 @@


 # Specification in the form of a command-line invocation:
-#   gnulib-tool --import --dir=. --local-dir=local --lib=libm4 
--source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests 
--aux-dir=build-aux --with-tests --avoid=lock-tests --avoid=tls-tests 
--no-libtool --macro-prefix=M4 announce-gen assert autobuild avltree-oset 
binary-io c-stack clean-temp cloexec close-stream closein config-h dirname 
error execute fdl-1.3 fflush filenamecat fopen fopen-safer fseeko gendocs 
getopt-gnu git-version-gen gnu-web-doc-update gnumakefile gnupload gpl-3.0 
intprops memchr2 mkstemp obstack pipe progname regex sigaction stdbool stdint 
stdlib-safer strsignal strstr strtod strtol unlocked-io update-copyright 
vc-list-files verror version-etc version-etc-fsf wait-process xalloc xprintf 
xvasprintf-posix
+#   gnulib-tool --import --dir=. --local-dir=local --lib=libm4 
--source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests 
--aux-dir=build-aux --with-tests --avoid=lock-tests --avoid=tls-tests 
--makefile-name=gnulib.mk --no-libtool --macro-prefix=M4 announce-gen assert 
autobuild avltree-oset binary-io c-stack clean-temp cloexec close-stream 
closein config-h dirname error execute fdl-1.3 fflush filenamecat fopen 
fopen-safer fseeko gendocs getopt-gnu git-version-gen gnu-web-doc-update 
gnumakefile gnupload gpl-3.0 intprops memchr2 mkstemp obstack pipe progname 
regex sigaction stdbool stdint stdlib-safer strsignal strstr strtod strtol 
unlocked-io update-copyright vc-list-files verror version-etc version-etc-fsf 
wait-process xalloc xprintf xvasprintf-posix

 # Specification in the form of a few gnulib-tool.m4 macro invocations:
 gl_LOCAL_DIR([local])
@@ -81,6 +81,6 @@ gl_DOC_BASE([doc])
 gl_TESTS_BASE([tests])
 gl_WITH_TESTS
 gl_LIB([libm4])
-gl_MAKEFILE_NAME([])
+gl_MAKEFILE_NAME([gnulib.mk])
 gl_MACRO_PREFIX([M4])
 gl_PO_DOMAIN([])
diff --git a/tests/Makefile.am b/tests/Makefile.am
new file mode 100644
index 0000000..2cdfaf0
--- /dev/null
+++ b/tests/Makefile.am
@@ -0,0 +1,20 @@
+## Makefile.am - template for generating Makefile via Automake
+##
+## Copyright (C) 2009 Free Software Foundation, Inc.
+##
+## This file is part of GNU M4.
+##
+## GNU M4 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.
+##
+## GNU M4 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 gnulib.mk
-- 
1.6.5.rc1


>From f1cf39048ffda00d41d1f60add63f3b6591b5d07 Mon Sep 17 00:00:00 2001
From: Eric Blake <address@hidden>
Date: Fri, 20 Nov 2009 08:51:20 -0700
Subject: [PATCH 2/5] Use gnulib maintainer-makefile module.

* m4/gnulib-cache.m4: Import maintainer-makefile module.
* cfg.mk (local-checks-to-skip): Drop changelog-check; add
sc_cast_of_x_alloc_return_value.
(gnulib_dir, gnu_rel_host, url_dir_list): Delete; provided by
maint.mk.
(config_h_header, old_NEWS_hash): New macros.
* .prev-version: New file.
* maint.mk: Remove from version control; use gnulib instead.
* .gitignore: Update.
* HACKING: Update.

Signed-off-by: Eric Blake <address@hidden>
(cherry picked from commit 260383467b3ae57f2cb3c6821718b99fdf278c4b)
---
 .cvsignore           |    1 +
 .gitignore           |    1 +
 .prev-version        |    1 +
 ChangeLog            |   12 +++
 HACKING              |    6 +-
 build-aux/.cvsignore |    1 +
 build-aux/.gitignore |    1 +
 cfg.mk               |   30 ++-----
 m4/gnulib-cache.m4   |    3 +-
 maint.mk             |  225 --------------------------------------------------
 10 files changed, 32 insertions(+), 249 deletions(-)
 create mode 100644 .prev-version
 delete mode 100644 maint.mk

diff --git a/.cvsignore b/.cvsignore
index 89903ca..1e719de 100644
--- a/.cvsignore
+++ b/.cvsignore
@@ -28,3 +28,4 @@ stamp-h
 stamp-h1
 stamp-h.in
 tests
+maint.mk
diff --git a/.gitignore b/.gitignore
index b88009a..7f5b72e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -26,6 +26,7 @@ gnupload
 !/lib/Makefile.am
 link-warning.h
 m4-*
+/maint.mk
 Makefile.in
 Makefile
 /missing
diff --git a/.prev-version b/.prev-version
new file mode 100644
index 0000000..acd81d7
--- /dev/null
+++ b/.prev-version
@@ -0,0 +1 @@
+1.4.13
diff --git a/ChangeLog b/ChangeLog
index 6a35474..1bb57d3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,17 @@
 2009-11-25  Eric Blake  <address@hidden>

+       Use gnulib maintainer-makefile module.
+       * m4/gnulib-cache.m4: Import maintainer-makefile module.
+       * cfg.mk (local-checks-to-skip): Drop changelog-check; add
+       sc_cast_of_x_alloc_return_value.
+       (gnulib_dir, gnu_rel_host, url_dir_list): Delete; provided by
+       maint.mk.
+       (config_h_header, old_NEWS_hash): New macros.
+       * .prev-version: New file.
+       * maint.mk: Remove from version control; use gnulib instead.
+       * .gitignore: Update.
+       * HACKING: Update.
+
        Update from gnulib.
        * gnulib: Update.
        * m4/gnulib-cache.m4: Use --makefile-name.
diff --git a/HACKING b/HACKING
index 09a79df..2f91e38 100644
--- a/HACKING
+++ b/HACKING
@@ -255,9 +255,9 @@ yyyy-mm-dd  Name of Author  <address@hidden>  (tiny change)
 * Run `make maintainer-distcheck'.  If there are any problems, fix them,
   run `git tag -d v<version>' and start again from the `git commit' step.

-* Run `make <target> PREV_VERSION=maj.min[.mic[alpha]]', with target set
-  to `major', `alpha', or `beta' as appropriate.  This will run various
-  additional checks and create diff files from the previous version.
+* Run `make <target>', with target set to `stable', `alpha', or `beta'
+  as appropriate.  This will run various additional checks and create
+  diff files from the previous version.

 * Run './build-aux/gnupload --to [dest].gnu.org:m4 [files]' to create
   detached gpg signature and clear signed directive files, and upload
diff --git a/build-aux/.cvsignore b/build-aux/.cvsignore
index 17512d0..16ef012 100644
--- a/build-aux/.cvsignore
+++ b/build-aux/.cvsignore
@@ -7,3 +7,4 @@ gnupload
 link-warning.h
 update-copyright
 vc-list-files
+useless-if-before-free
diff --git a/build-aux/.gitignore b/build-aux/.gitignore
index 7587f4b..e7a0cfc 100644
--- a/build-aux/.gitignore
+++ b/build-aux/.gitignore
@@ -7,3 +7,4 @@
 /link-warning.h
 /update-copyright
 /vc-list-files
+/useless-if-before-free
diff --git a/cfg.mk b/cfg.mk
index c63b953..00a9e56 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -15,31 +15,21 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.

-# Use alpha.gnu.org for alpha and beta releases.
-# Use ftp.gnu.org for major releases.
-gnu_ftp_host-alpha = alpha.gnu.org
-gnu_ftp_host-beta = alpha.gnu.org
-gnu_ftp_host-major = ftp.gnu.org
-gnu_rel_host = $(gnu_ftp_host-$(RELEASE_TYPE))
-
 # Used in maint.mk's web-manual rule
 manual_title = GNU macro processor

-url_dir_list = \
-  ftp://$(gnu_rel_host)/gnu/m4
-
 # The GnuPG ID of the key used to sign the tarballs.
 gpg_key_ID = F4850180

-# Tests not to run as part of "make distcheck".
-# Exclude changelog-check here so that there's less churn in ChangeLog
-# files -- otherwise, you'd need to have the upcoming version number
-# at the top of the file for each `make distcheck' run.
-local-checks-to-skip = changelog-check
-
-# The local directory containing the checked-out copy of gnulib used in this
-# release.  Used solely to get gnulib's SHA1 for the "announcement" target.
-gnulib_dir = $(srcdir)/gnulib
-
 # Always use longhand copyrights.
 update-copyright-env = UPDATE_COPYRIGHT_USE_INTERVALS=0
+
+# Tests not to run as part of "make syntax-check".
+# M4 intentionally uses a coding style that compiles under C++.
+local-checks-to-skip = sc_cast_of_x_alloc_return_value
+
+# Our files include "m4.h", which in turn includes <config.h> first.
+config_h_header = "m4\.h"
+
+# Hash of NEWS contents, to ensure we don't add entries to wrong section.
+old_NEWS_hash = 0330971054cd4fb4e94b85fe367980f2
diff --git a/m4/gnulib-cache.m4 b/m4/gnulib-cache.m4
index 10458b3..92cfe55 100644
--- a/m4/gnulib-cache.m4
+++ b/m4/gnulib-cache.m4
@@ -15,7 +15,7 @@


 # Specification in the form of a command-line invocation:
-#   gnulib-tool --import --dir=. --local-dir=local --lib=libm4 
--source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests 
--aux-dir=build-aux --with-tests --avoid=lock-tests --avoid=tls-tests 
--makefile-name=gnulib.mk --no-libtool --macro-prefix=M4 announce-gen assert 
autobuild avltree-oset binary-io c-stack clean-temp cloexec close-stream 
closein config-h dirname error execute fdl-1.3 fflush filenamecat fopen 
fopen-safer fseeko gendocs getopt-gnu git-version-gen gnu-web-doc-update 
gnumakefile gnupload gpl-3.0 intprops memchr2 mkstemp obstack pipe progname 
regex sigaction stdbool stdint stdlib-safer strsignal strstr strtod strtol 
unlocked-io update-copyright vc-list-files verror version-etc version-etc-fsf 
wait-process xalloc xprintf xvasprintf-posix
+#   gnulib-tool --import --dir=. --local-dir=local --lib=libm4 
--source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests 
--aux-dir=build-aux --with-tests --avoid=lock-tests --avoid=tls-tests 
--makefile-name=gnulib.mk --no-libtool --macro-prefix=M4 announce-gen assert 
autobuild avltree-oset binary-io c-stack clean-temp cloexec close-stream 
closein config-h dirname error execute fdl-1.3 fflush filenamecat fopen 
fopen-safer fseeko gendocs getopt-gnu git-version-gen gnu-web-doc-update 
gnumakefile gnupload gpl-3.0 intprops maintainer-makefile memchr2 mkstemp 
obstack pipe progname regex sigaction stdbool stdint stdlib-safer strsignal 
strstr strtod strtol unlocked-io update-copyright vc-list-files verror 
version-etc version-etc-fsf wait-process xalloc xprintf xvasprintf-posix

 # Specification in the form of a few gnulib-tool.m4 macro invocations:
 gl_LOCAL_DIR([local])
@@ -48,6 +48,7 @@ gl_MODULES([
   gnupload
   gpl-3.0
   intprops
+  maintainer-makefile
   memchr2
   mkstemp
   obstack
diff --git a/maint.mk b/maint.mk
deleted file mode 100644
index a50c727..0000000
--- a/maint.mk
+++ /dev/null
@@ -1,225 +0,0 @@
-## maint.mk -- Makefile rules for m4 maintainers -*-Makefile-*-
-##
-## Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Free Software
-## Foundation, Inc.
-##
-## This file is part of GNU M4.
-##
-## GNU M4 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.
-##
-## GNU M4 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/>.
-
-# This is reported not to work with make-3.79.1
-# ME := $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST))
-ME := maint.mk
-
-# Override this in cfg.mk if you use a non-standard build-aux directory.
-build_aux ?= $(srcdir)/build-aux
-
-# Do not save the original name or timestamp in the .tar.gz file.
-# Use --rsyncable if available.
-gzip_rsyncable := \
-  $(shell gzip --help 2>/dev/null|grep rsyncable >/dev/null && echo 
--rsyncable)
-GZIP_ENV = '--no-name --best $(gzip_rsyncable)'
-
-GIT = git
-VC = $(GIT)
-VC-tag = git tag -s -m '$(VERSION)' -u $(gpg_key_ID)
-
-VC_LIST = $(build_aux)/vc-list-files -C $(srcdir)
-
-VC_LIST_EXCEPT = \
-  $(VC_LIST) | if test -f $(srcdir)/.x-$@; then grep -vEf $(srcdir)/.x-$@; 
else grep -v ChangeLog; fi
-
-VERSION_REGEXP = $(subst .,\.,$(VERSION))
-my_distdir = $(PACKAGE)-$(VERSION)
-
-# Ensure that we use only the standard $(VAR) notation,
-# not @...@ in Makefile.am, now that we can rely on automake
-# to emit a definition for each substituted variable.
-makefile-check:
-       grep -nE '@[A-Z_0-9]+@' `find $(srcdir) -name Makefile.am` \
-         && { echo '$(ME): use $$(...), not @...@' 1>&2; exit 1; } || :
-
-news-date-check: NEWS version-check
-       today=`date +%Y-%m-%d`;                                         \
-       if head $(srcdir)/NEWS | grep '^\*.* $(VERSION_REGEXP) ('$$today')' \
-           >/dev/null; then                                            \
-         :;                                                            \
-       else                                                            \
-         echo "version or today's date is not in NEWS" 1>&2;           \
-         exit 1;                                                       \
-       fi
-
-changelog-check:
-       if head $(srcdir)/ChangeLog | grep 'Version $(VERSION_REGEXP)\.$$' \
-           >/dev/null; then                                            \
-         :;                                                            \
-       else                                                            \
-         echo "$(VERSION) not in ChangeLog" 1>&2;                      \
-         exit 1;                                                       \
-       fi
-
-m4-check:
-       @grep -n 'AC_DEFUN([^[]' $(srcdir)/m4/*.m4 \
-         && { echo '$(ME): quote the first arg to AC_DEFUN' 1>&2; \
-              exit 1; } || :
-
-vc-diff-check:
-       (CDPATH=; cd $(srcdir) && $(VC) diff) > vc-diffs || :
-       if test -s vc-diffs; then                               \
-         cat vc-diffs;                                         \
-         echo "Some files are locally modified:" 1>&2;         \
-         exit 1;                                               \
-       else                                                    \
-         rm vc-diffs;                                          \
-       fi
-
-maintainer-distcheck:
-       $(MAKE) distcheck
-       $(MAKE) my-distcheck
-
-# Don't make a distribution if checks fail.
-# Also, make sure the NEWS file is up-to-date.
-vc-dist: $(local-check) vc-diff-check maintainer-distcheck
-       $(MAKE) dist
-
-# Use this to make sure we don't run these programs when building
-# from a virgin tgz file, below.
-null_AM_MAKEFLAGS = \
-  ACLOCAL=false \
-  AUTOCONF=false \
-  AUTOMAKE=false \
-  AUTOHEADER=false \
-  MAKEINFO=false
-
-# Use -Wformat -Werror to detect format-string/arg-list mismatches.
-# Also, check for shadowing problems with -Wshadow, and for pointer
-# arithmetic problems with -Wpointer-arith.
-# These CFLAGS are pretty strict.  If you build this target, you probably
-# have to have a recent version of gcc and glibc headers.
-TMPDIR ?= /tmp
-t=$(TMPDIR)/$(PACKAGE)/test
-my-distcheck: $(local-check) check
-       -rm -rf $(t)
-       mkdir -p $(t)
-       GZIP=$(GZIP_ENV) $(AMTAR) -C $(t) -zxf $(distdir).tar.gz
-       cd $(t)/$(distdir)                              \
-         && ./configure                                \
-         && $(MAKE) CFLAGS='$(warn_cflags)'            \
-             AM_MAKEFLAGS='$(null_AM_MAKEFLAGS)'       \
-         && $(MAKE) dvi                                \
-         && $(MAKE) check                              \
-         && $(MAKE) distclean
-       (cd $(t) && mv $(distdir) $(distdir).old        \
-         && $(AMTAR) -zxf - ) < $(distdir).tar.gz
-       diff -ur $(t)/$(distdir).old $(t)/$(distdir)
-       -rm -rf $(t)
-       @echo "========================"; \
-       echo "$(distdir).tar.gz is ready for distribution"; \
-       echo "========================"
-
-gnulib-version = $$(cd $(gnulib_dir) && git describe)
-
-announcement: NEWS ChangeLog $(rel-files)
-       @$(srcdir)/build-aux/announce-gen                               \
-           --release-type=$(RELEASE_TYPE)                              \
-           --package=$(PACKAGE)                                        \
-           --prev=$(PREV_VERSION)                                      \
-           --curr=$(VERSION)                                           \
-           --gpg-key-id=$(gpg_key_ID)                                  \
-           --news=$(srcdir)/NEWS                                       \
-           --bootstrap-tools=autoconf,automake,gnulib                  \
-           --gnulib-version=$(gnulib-version)                          \
-           $(addprefix --url-dir=, $(url_dir_list))
-
-.PHONY: alpha beta major
-alpha beta major: $(local-check) version-check
-       test $@ = major                                         \
-         && { echo $(VERSION) | grep -E '^[0-9]+(\.[0-9]+)+$$' \
-              || { echo "invalid version string: $(VERSION)" 1>&2; exit 1;};}\
-         || :
-       $(MAKE) vc-dist
-       $(MAKE) news-date-check changelog-check
-       $(MAKE) deltas
-       $(MAKE) -s announcement RELEASE_TYPE=$@ > /tmp/announce-$(my_distdir)
-
-.PHONY: version-check
-version-check:
-       @case $(VERSION) in \
-       *[acegikmoqsuwy]) \
-         echo "Version \`$(VERSION)' is not a releasable version, please 
read:"; \
-         echo "    http://www.gnu.org/software/libtool/contribute.html";; \
-         exit 1; \
-         ;; \
-       esac
-       @if test -z "$(PREV_VERSION)"; \
-               then echo "PREV_VERSION is not set"; exit 1; fi
-
-.PHONY: prev-tarball
-prev-tarball: version-check
-## Make sure we have the previous release tarball in the tree.
-       @ofile="$(PACKAGE)-$(PREV_VERSION).tar.gz"; \
-       if test -f $$ofile; then :; \
-       else echo "Cannot make deltas without $$ofile"; exit 1; fi
-
-.PHONY: new-tarball
-new-tarball:
-## Make sure we have the new release tarball in the tree.
-       @ofile="$(PACKAGE)-$(VERSION).tar.gz"; \
-       if test -f $$ofile; then :; \
-       else echo "Cannot make deltas without $$ofile"; exit 1; fi
-
-.PHONY: deltas
-deltas: delta-diff
-
-DIFF = diff
-DIFF_OPTIONS = -ruNp
-
-.PHONY: delta-diff
-delta-diff: prev-tarball new-tarball
-## Unpack the tarballs somewhere to diff them
-       rm -rf delta-diff
-       mkdir delta-diff
-       ofile="../$(PACKAGE)-$(PREV_VERSION)-$(VERSION).diff.gz"; \
-       cd delta-diff \
-       && tar xzf "../$(PACKAGE)-$(PREV_VERSION).tar.gz" \
-       && tar xzf "../$(PACKAGE)-$(VERSION).tar.gz" \
-       && $(DIFF) $(DIFF_OPTIONS) \
-               $(PACKAGE)-$(PREV_VERSION) $(PACKAGE)-$(VERSION) \
-               | GZIP=$(GZIP_ENV) gzip -c > $$ofile
-       rm -rf delta-diff
-
-.PHONY: web-manual
-web-manual:
-       @cd '$(srcdir)/doc' ; \
-         $(SHELL) ../build-aux/gendocs.sh -o '$(abs_builddir)/doc/manual' \
-           --email $(PACKAGE_BUGREPORT) $(PACKAGE) \
-           "$(PACKAGE_NAME) - $(manual_title)"
-       @echo " *** Upload the doc/manual directory to web-cvs."
-
-# If you want to set UPDATE_COPYRIGHT_* environment variables,
-# put the assignments in this variable.
-update-copyright-env ?=
-
-# Run this rule once per year (usually early in January)
-# to update all FSF copyright year lists in your project.
-# If you have an additional project-specific rule,
-# add it in cfg.mk along with a line 'update-copyright: prereq'.
-# By default, exclude all variants of COPYING; you can also
-# add exemptions (such as ChangeLog..* for rotated change logs)
-# in the file .x-update-copyright.
-.PHONY: update-copyright
-update-copyright:
-       grep -l -w Copyright $$($(VC_LIST_EXCEPT))              \
-               $(srcdir)/ChangeLog | grep -v COPYING           \
-         | $(update-copyright-env) xargs $(build_aux)/$@
-- 
1.6.5.rc1


>From 268b47589e681e3fe46650e3b1b6f36d8557097b Mon Sep 17 00:00:00 2001
From: Eric Blake <address@hidden>
Date: Thu, 26 Nov 2009 05:28:53 -0700
Subject: [PATCH 3/5] Silence syntax-check warnings.

* src/m4.h (STREQ): New macro.
* src/builtin.c (find_builtin_by_name): Use it.
* src/input.c (set_word_regexp): Likewise.
* src/m4.c (process_file): Likewise.
(main): Consistently spell warning, and mark output strings.
Avoid unsafe parsing functions.
(process_file): Mark output strings.
* src/output.c (make_diversion): Likewise.
* src/format.c (arg_int, arg_long, arg_double): New helpers.
(ARG_INT, ARG_LONG, ARG_DOUBLE): Use them to detect parse errors.
* BACKLOG: Avoid whitespace problems.
* TODO: Likewise.
* HACKING: Likewise.
* examples/esyscmd.m4: Likewise.
* examples/file.m4: Likewise.
* examples/fstab.m4: Likewise.
* examples/patsubst.m4: Likewise.
---
 BACKLOG              |    4 +-
 ChangeLog            |   19 ++++++++++++
 HACKING              |    2 +-
 TODO                 |    4 +-
 examples/esyscmd.m4  |    2 +-
 examples/file.m4     |    2 +-
 examples/fstab.m4    |    3 +-
 examples/patsubst.m4 |    2 +-
 src/builtin.c        |    2 +-
 src/format.c         |   78 ++++++++++++++++++++++++++++++++++++++++++++++++--
 src/input.c          |    2 +-
 src/m4.c             |   20 ++++++------
 src/m4.h             |    3 ++
 src/output.c         |    2 +-
 14 files changed, 119 insertions(+), 26 deletions(-)

diff --git a/BACKLOG b/BACKLOG
index 6cd9a92..557831f 100644
--- a/BACKLOG
+++ b/BACKLOG
@@ -7,7 +7,7 @@ rmail/announce

 rmail/changeword
  1. 02 Sep 94 <pinard> Re: Prerelease: GNU m4 1.2.3
- 2. 05 Sep 94 <address@hidden> Re: Prerelease: GNU m4 1.2.3 
+ 2. 05 Sep 94 <address@hidden> Re: Prerelease: GNU m4 1.2.3

 rmail/configuration
  1. 03 Nov 94 <address@hidden> Re: m4 1.3 on DEC OSF/1 3.0
@@ -37,7 +37,7 @@ rmail/floating-point
 13. 28 Oct 94 <address@hidden> Re: enhancement to m4 eval()

 rmail/format-rewrite
- 1. 25 Jun 94 <address@hidden> Re: Prerelease: GNU m4 1.1.3 
+ 1. 25 Jun 94 <address@hidden> Re: Prerelease: GNU m4 1.1.3

 rmail/named-formals
  1. 30 Sep 94 <address@hidden> m4 macros with named formal parameters
diff --git a/ChangeLog b/ChangeLog
index 1bb57d3..96adc97 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,24 @@
 2009-11-25  Eric Blake  <address@hidden>

+       Silence syntax-check warnings.
+       * src/m4.h (STREQ): New macro.
+       * src/builtin.c (find_builtin_by_name): Use it.
+       * src/input.c (set_word_regexp): Likewise.
+       * src/m4.c (process_file): Likewise.
+       (main): Consistently spell warning, and mark output strings.
+       Avoid unsafe parsing functions.
+       (process_file): Mark output strings.
+       * src/output.c (make_diversion): Likewise.
+       * src/format.c (arg_int, arg_long, arg_double): New helpers.
+       (ARG_INT, ARG_LONG, ARG_DOUBLE): Use them to detect parse errors.
+       * BACKLOG: Avoid whitespace problems.
+       * TODO: Likewise.
+       * HACKING: Likewise.
+       * examples/esyscmd.m4: Likewise.
+       * examples/file.m4: Likewise.
+       * examples/fstab.m4: Likewise.
+       * examples/patsubst.m4: Likewise.
+
        Use gnulib maintainer-makefile module.
        * m4/gnulib-cache.m4: Import maintainer-makefile module.
        * cfg.mk (local-checks-to-skip): Drop changelog-check; add
diff --git a/HACKING b/HACKING
index 2f91e38..8f5088f 100644
--- a/HACKING
+++ b/HACKING
@@ -290,7 +290,7 @@ yyyy-mm-dd  Name of Author  <address@hidden>  (tiny change)
       co directory/m4.txt
   After making edits, mail the diff to <address@hidden>.

--- 
+
 Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Free Software
 Foundation, Inc.

diff --git a/TODO b/TODO
index 81e1b89..d10dfaa 100644
--- a/TODO
+++ b/TODO
@@ -5,7 +5,7 @@ of these ideas, listed more or less in decreasing order of 
priority.

 * Features or problems
   - Fix format() builtin to handle %c more like printf(1) in the shell
-        http://lists.gnu.org/archive/html/bug-m4/2007-05/msg00047.html
+       http://lists.gnu.org/archive/html/bug-m4/2007-05/msg00047.html
     Also, gnulib needs help to overcome mingw bugs related to format().
   - Update documentation from accumulated mail about it
   - Study synclines at the very beginning of each diverted sequence
@@ -30,7 +30,7 @@ of these ideas, listed more or less in decreasing order of 
priority.

        GNU m4 is lousy regarding NULs in streams (this would require
        maintaining the string lengths, and avoiding strlen, strcpy,
-       etc.). 
+       etc.).
 
 Local Variables:
 mode: outline
diff --git a/examples/esyscmd.m4 b/examples/esyscmd.m4
index b839148..0e8634d 100644
--- a/examples/esyscmd.m4
+++ b/examples/esyscmd.m4
@@ -1,5 +1,5 @@
 define(`hostname', esyscmd(`hostname'))dnl
 `hostname = >>'hostname`<<'
-define(`hostname', 
+define(`hostname',
 pushdef(`_tmp', `$1')_tmp(translit(esyscmd(`hostname'), `.', 
`,'))`'popdef(`_tmp'))dnl
 `hostname = >>'hostname`<<'
diff --git a/examples/file.m4 b/examples/file.m4
index e7db5f1..ff56153 100644
--- a/examples/file.m4
+++ b/examples/file.m4
@@ -1,5 +1,5 @@
 changequote([[,]])dnl
-define([[quoteall]], [[patsubst([[[[$*]]]], [[,[       ]+]], [[,]])]])dnl
+define([[quoteall]], [[patsubst([[[[$*]]]], [[,[        ]+]], [[,]])]])dnl
 define([[group]], quoteall(include([[/etc/group]])))dnl
 dnl
 group()dnl
diff --git a/examples/fstab.m4 b/examples/fstab.m4
index dbf538a..8d10e17 100644
--- a/examples/fstab.m4
+++ b/examples/fstab.m4
@@ -1,7 +1,6 @@
-define(`concat', `translit(``$*'', `   ')')
+define(`concat', `translit(``$*'', `    ')')
 define(`fsent', `format(`%-25s %-16s nfs    %-16s 0 0', `$1:$2', `$3', 
concat$4)')

 fsent(freja, /home/gevn, /home/gevn, (rw, soft, bg, grpid))
 fsent(freja, /home/freja, /home/freja, (rw, soft, grpid))
 fsent(rimfaxe, /home/rimfaxe, /home/rimfaxe, (rw, soft, bg))
-
diff --git a/examples/patsubst.m4 b/examples/patsubst.m4
index 3b390ae..8569066 100644
--- a/examples/patsubst.m4
+++ b/examples/patsubst.m4
@@ -5,4 +5,4 @@ patsubst(`GNUs not Unix', `\<\w', `\0=')
 patsubst(`GNUs not Unix', `\w*', `(\0)')
 patsubst(`GNUs not Unix', `\w+', `(\0)')
 patsubst(`GNUs not Unix', `\w+')
-patsubst(`GNUs  not     Unix', `[      ]+', ` ')
+patsubst(`GNUs  not  '`         Unix', `[       ]+', ` ')
diff --git a/src/builtin.c b/src/builtin.c
index 5a097f3..b8487a7 100644
--- a/src/builtin.c
+++ b/src/builtin.c
@@ -197,7 +197,7 @@ find_builtin_by_name (const char *name)
   const builtin *bp;

   for (bp = &builtin_tab[0]; bp->name != NULL; bp++)
-    if (strcmp (bp->name, name) == 0)
+    if (STREQ (bp->name, name))
       return bp;
   return bp + 1;
 }
diff --git a/src/format.c b/src/format.c
index a0519a0..dc9d5e6 100644
--- a/src/format.c
+++ b/src/format.c
@@ -27,13 +27,85 @@
 /* Simple varargs substitute.  We assume int and unsigned int are the
    same size; likewise for long and unsigned long.  */

+/* Parse STR as an integer, reporting warnings.  */
+static int
+arg_int (const char *str)
+{
+  char *endp;
+  long value;
+  size_t len = strlen (str);
+
+  if (!len)
+    {
+      M4ERROR ((warning_status, 0, _("empty string treated as 0")));
+      return 0;
+    }
+  errno = 0;
+  value = strtol (str, &endp, 10);
+  if (endp - str != len)
+    M4ERROR ((warning_status, 0, _("non-numeric argument %s"), str));
+  else if (isspace (to_uchar (*str)))
+    M4ERROR ((warning_status, 0, _("leading whitespace ignored")));
+  else if (errno == ERANGE || (int) value != value)
+    M4ERROR ((warning_status, 0, _("numeric overflow detected")));
+  return value;
+}
+
+/* Parse STR as a long, reporting warnings.  */
+static long
+arg_long (const char *str)
+{
+  char *endp;
+  long value;
+  size_t len = strlen (str);
+
+  if (!len)
+    {
+      M4ERROR ((warning_status, 0, _("empty string treated as 0")));
+      return 0L;
+    }
+  errno = 0;
+  value = strtol (str, &endp, 10);
+  if (endp - str != len)
+    M4ERROR ((warning_status, 0, _("non-numeric argument %s"), str));
+  else if (isspace (to_uchar (*str)))
+    M4ERROR ((warning_status, 0, _("leading whitespace ignored")));
+  else if (errno == ERANGE)
+    M4ERROR ((warning_status, 0, _("numeric overflow detected")));
+  return value;
+}
+
+/* Parse STR as a double, reporting warnings.  */
+static double
+arg_double (const char *str)
+{
+  char *endp;
+  double value;
+  size_t len = strlen (str);
+
+  if (!len)
+    {
+      M4ERROR ((warning_status, 0, _("empty string treated as 0")));
+      return 0.0;
+    }
+  errno = 0;
+  value = strtod (str, &endp);
+  if (endp - str != len)
+    M4ERROR ((warning_status, 0, _("non-numeric argument %s"), str));
+  else if (isspace (to_uchar (*str)))
+    M4ERROR ((warning_status, 0, _("leading whitespace ignored")));
+  else if (errno == ERANGE)
+    M4ERROR ((warning_status, 0, _("numeric overflow detected")));
+  return value;
+}
+
 #define ARG_INT(argc, argv) \
        ((argc == 0) ? 0 : \
-        (--argc, argv++, atoi (TOKEN_DATA_TEXT (argv[-1]))))
+        (--argc, argv++, arg_int (TOKEN_DATA_TEXT (argv[-1]))))

 #define ARG_LONG(argc, argv) \
        ((argc == 0) ? 0 : \
-        (--argc, argv++, atol (TOKEN_DATA_TEXT (argv[-1]))))
+        (--argc, argv++, arg_long (TOKEN_DATA_TEXT (argv[-1]))))

 #define ARG_STR(argc, argv) \
        ((argc == 0) ? "" : \
@@ -41,7 +113,7 @@

 #define ARG_DOUBLE(argc, argv) \
        ((argc == 0) ? 0 : \
-        (--argc, argv++, strtod (TOKEN_DATA_TEXT (argv[-1]), NULL)))
+        (--argc, argv++, arg_double (TOKEN_DATA_TEXT (argv[-1]))))
 

 /*------------------------------------------------------------------.
diff --git a/src/input.c b/src/input.c
index 63480be..fb61ba1 100644
--- a/src/input.c
+++ b/src/input.c
@@ -767,7 +767,7 @@ set_word_regexp (const char *regexp)
   const char *msg;
   struct re_pattern_buffer new_word_regexp;

-  if (!*regexp || !strcmp (regexp, DEFAULT_WORD_REGEXP))
+  if (!*regexp || STREQ (regexp, DEFAULT_WORD_REGEXP))
     {
       default_word_regexp = true;
       return;
diff --git a/src/m4.c b/src/m4.c
index 914655a..584fb0f 100644
--- a/src/m4.c
+++ b/src/m4.c
@@ -319,7 +319,7 @@ static const struct option long_options[] =
 static void
 process_file (const char *name)
 {
-  if (strcmp (name, "-") == 0)
+  if (STREQ (name, "-"))
     {
       /* If stdin is a terminal, we want to allow 'm4 - file -'
         to read input from stdin twice, like GNU cat.  Besides,
@@ -333,7 +333,7 @@ process_file (const char *name)
       FILE *fp = m4_path_search (name, &full_name);
       if (fp == NULL)
        {
-         error (0, errno, "cannot open `%s'", name);
+         error (0, errno, _("cannot open `%s'"), name);
          /* Set the status to EXIT_FAILURE, even though we
             continue to process files after a missing file.  */
          retcode = EXIT_FAILURE;
@@ -416,7 +416,7 @@ main (int argc, char *const *argv, char *const *envp)
     char *crash = getenv ("M4_CRASH");
     if (crash)
       {
-       if (!atoi (crash))
+       if (!strtol (crash, NULL, 10))
          ++*(int *) 8;
        assert (false);
        abort ();
@@ -440,14 +440,14 @@ main (int argc, char *const *argv, char *const *envp)
        /* Compatibility junk: options that other implementations
           support, but which we ignore as no-ops and don't list in
           --help.  */
-       error (0, 0, "Warning: `m4 -%c' may be removed in a future release",
+       error (0, 0, _("warning: `m4 -%c' may be removed in a future release"),
               optchar);
        break;

       case 'N':
       case DIVERSIONS_OPTION:
        /* -N became an obsolete no-op in 1.4.x.  */
-       error (0, 0, "Warning: `m4 %s' is deprecated",
+       error (0, 0, _("warning: `m4 %s' is deprecated"),
               optchar == 'N' ? "-N" : "--diversions");
        break;

@@ -488,7 +488,7 @@ main (int argc, char *const *argv, char *const *envp)
        break;

       case 'H':
-       hash_table_size = atol (optarg);
+       hash_table_size = strtol (optarg, NULL, 10);
        if (hash_table_size == 0)
          hash_table_size = HASHMAX;
        break;
@@ -498,7 +498,7 @@ main (int argc, char *const *argv, char *const *envp)
        break;

       case 'L':
-       nesting_limit = atoi (optarg);
+       nesting_limit = strtol (optarg, NULL, 10);
        break;

       case 'P':
@@ -523,13 +523,13 @@ main (int argc, char *const *argv, char *const *envp)
        debug_level = debug_decode (optarg);
        if (debug_level < 0)
          {
-           error (0, 0, "bad debug flags: `%s'", optarg);
+           error (0, 0, _("bad debug flags: `%s'"), optarg);
            debug_level = 0;
          }
        break;

       case 'e':
-       error (0, 0, "Warning: `m4 -e' is deprecated, use `-i' instead");
+       error (0, 0, _("warning: `m4 -e' is deprecated, use `-i' instead"));
        /* fall through */
       case 'i':
        interactive = true;
@@ -540,7 +540,7 @@ main (int argc, char *const *argv, char *const *envp)
        break;

       case 'l':
-       max_debug_argument_length = atoi (optarg);
+       max_debug_argument_length = strtol (optarg, NULL, 10);
        if (max_debug_argument_length <= 0)
          max_debug_argument_length = 0;
        break;
diff --git a/src/m4.h b/src/m4.h
index b82fb37..504c2e2 100644
--- a/src/m4.h
+++ b/src/m4.h
@@ -481,3 +481,6 @@ static inline unsigned char to_uchar (char ch) { return ch; 
}
 #else
 # define to_uchar(C) ((unsigned char) (C))
 #endif
+
+/* Avoid negative logic when comparing two strings.  */
+#define STREQ(a, b) (strcmp (a, b) == 0)
diff --git a/src/output.c b/src/output.c
index a39d1e5..8740f5d 100644
--- a/src/output.c
+++ b/src/output.c
@@ -729,7 +729,7 @@ make_diversion (int divnum)
        {
          assert (!output_diversion->used);
          if (!gl_oset_remove (diversion_table, output_diversion))
-           error (EXIT_FAILURE, 0, "INTERNAL ERROR: make_diversion failed");
+           assert (false);
          output_diversion->u.next = free_list;
          free_list = output_diversion;
        }
-- 
1.6.5.rc1


>From 324f56e49ed43de04cf6e648fea9d89739788f24 Mon Sep 17 00:00:00 2001
From: Eric Blake <address@hidden>
Date: Fri, 6 Nov 2009 15:28:08 -0700
Subject: [PATCH 4/5] Allow use of compiler warnings.

* m4/gnulib-cache.m4: Import manywarnings module.
* configure.ac (WERROR_CFLAGS, WARN_CFLAGS): New variables.
* src/Makefile.am (AM_CFLAGS): Use them.
* Makefile.am (DISTCHECK_CONFIGURE_FLAGS): Turn on warnings during
distcheck.
* src/m4.h (M4_GNUC_NORETURN): New macro.
(trace_post): Delete unused parameter.
* src/m4.c (usage): Mark as noreturn.
(main): Remove unused parameter.
* src/debug.c (trace_post): Likewise.
(trace_pre): Cover all enum values.
* src/symtab.c (lookup_symbol): Likewise.
* src/builtin.c (define_macro, m4_dumpdef): Likewise.
(m4_define, m4_undefine, m4_pushdef, m4_popdef, m4_sysval)
(m4_divert, m4_undivert, m4_dnl, m4_changequote, m4_changecom)
(m4_changeword, m4_syscmd, m4_include, m4_sinclude, m4_m4exit)
(m4_debugmode, m4_debugfile, m4_placeholder): Mark unused
parameters.
(mkstemp_helper): Use parameter.
(substitute): Avoid signed vs. unsigned comparison.
* src/format.c (arg_int, arg_long, arg_double): Likewise.
* src/input.c (next_token): Likewise.
* src/output.c (freeze_diversions): Likewise.
(m4_tmpname): Allow C++ compilation.
* src/freeze.c (produce_frozen_state, GET_NUMBER): Use correct
type.
* src/macro.c (call_macro): Cover all enum values.
(expand_macro): Update caller.
* src/path.c (m4_fopen): Remove unused parameter.
(m4_path_search): Update caller.

Signed-off-by: Eric Blake <address@hidden>
---
 ChangeLog          |   32 ++++++++++++++++++++++++++++
 Makefile.am        |    3 +-
 configure.ac       |   47 +++++++++++++++++++++++++++++++++++++++++
 m4/gnulib-cache.m4 |    3 +-
 src/Makefile.am    |    1 +
 src/builtin.c      |   59 ++++++++++++++++++++++++++++++---------------------
 src/debug.c        |    4 +-
 src/format.c       |    6 ++--
 src/freeze.c       |    6 ++--
 src/input.c        |    4 +-
 src/m4.c           |    4 +-
 src/m4.h           |   11 +++++----
 src/macro.c        |    3 +-
 src/output.c       |    6 +++-
 src/path.c         |    6 ++--
 src/symtab.c       |    1 +
 16 files changed, 147 insertions(+), 49 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 96adc97..5b4cc72 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,37 @@
 2009-11-25  Eric Blake  <address@hidden>

+       Allow use of compiler warnings.
+       * m4/gnulib-cache.m4: Import manywarnings module.
+       * configure.ac (WERROR_CFLAGS, WARN_CFLAGS): New variables.
+       * src/Makefile.am (AM_CFLAGS): Use them.
+       * Makefile.am (DISTCHECK_CONFIGURE_FLAGS): Turn on warnings during
+       distcheck.
+       * src/m4.h (M4_GNUC_NORETURN): New macro.
+       (trace_post): Delete unused parameter.
+       * src/m4.c (usage): Mark as noreturn.
+       (main): Remove unused parameter.
+       * src/debug.c (trace_post): Likewise.
+       (trace_pre): Cover all enum values.
+       * src/symtab.c (lookup_symbol): Likewise.
+       * src/builtin.c (define_macro, m4_dumpdef): Likewise.
+       (m4_define, m4_undefine, m4_pushdef, m4_popdef, m4_sysval)
+       (m4_divert, m4_undivert, m4_dnl, m4_changequote, m4_changecom)
+       (m4_changeword, m4_syscmd, m4_include, m4_sinclude, m4_m4exit)
+       (m4_debugmode, m4_debugfile, m4_placeholder): Mark unused
+       parameters.
+       (mkstemp_helper): Use parameter.
+       (substitute): Avoid signed vs. unsigned comparison.
+       * src/format.c (arg_int, arg_long, arg_double): Likewise.
+       * src/input.c (next_token): Likewise.
+       * src/output.c (freeze_diversions): Likewise.
+       (m4_tmpname): Allow C++ compilation.
+       * src/freeze.c (produce_frozen_state, GET_NUMBER): Use correct
+       type.
+       * src/macro.c (call_macro): Cover all enum values.
+       (expand_macro): Update caller.
+       * src/path.c (m4_fopen): Remove unused parameter.
+       (m4_path_search): Update caller.
+
        Silence syntax-check warnings.
        * src/m4.h (STREQ): New macro.
        * src/builtin.c (find_builtin_by_name): Use it.
diff --git a/Makefile.am b/Makefile.am
index a579c86..875750f 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -34,7 +34,8 @@ MAINTAINERCLEANFILES = INSTALL Makefile.in aclocal.m4 \
 ACLOCAL_AMFLAGS = -I m4
 ## Enough users install GNU M4 as gm4 that we make sure 'make installcheck'
 ## will handle that, prior to making a release.
-DISTCHECK_CONFIGURE_FLAGS = --enable-changeword --program-prefix=g
+DISTCHECK_CONFIGURE_FLAGS = --enable-changeword --program-prefix=g \
+       --enable-gcc-warnings

 BUILT_SOURCES = $(top_srcdir)/.version
 $(top_srcdir)/.version:
diff --git a/configure.ac b/configure.ac
index 1a3acae..8697c8c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -35,6 +35,53 @@ M4_EARLY
 # M4 is single-threaded; so we can optimize gnulib code by using this:
 gl_DISABLE_THREADS

+AC_ARG_ENABLE([gcc-warnings],
+  [AS_HELP_STRING([--enable-gcc-warnings],
+                  [turn on lots of GCC warnings (for developers)])],
+  [case $enableval in
+     yes|no) ;;
+     *)      AC_MSG_ERROR([bad value $enableval for gcc-warnings option]) ;;
+   esac
+   gl_gcc_warnings=$enableval],
+  [gl_gcc_warnings=no]
+)
+
+if test "$gl_gcc_warnings" = yes; then
+  gl_WARN_ADD([-Werror], [WERROR_CFLAGS])
+  AC_SUBST([WERROR_CFLAGS])
+
+  nw=
+  nw="$nw -Waggregate-return"       # C90 is anachronistic
+  nw="$nw -Wlong-long"              # C90 is anachronistic
+  nw="$nw -Wundef"                  # Warns on '#if GNULIB_FOO' etc in gnulib
+  nw="$nw -Wtraditional"            # Warns on #elif which we use often
+  nw="$nw -Wsystem-headers"         # Don't let system headers trigger warnings
+  nw="$nw -Wpadded"                 # Our structs are not packed
+  nw="$nw -Wredundant-decls"        # Gnulib has multiple decls
+  nw="$nw -Wformat-nonliteral"      # Needed in builtin.c
+  nw="$nw -Wunreachable-code"       # Needed in output.c
+  nw="$nw -Wconversion"             # Too many warnings for now
+  nw="$nw -Wsign-conversion"        # Too many warnings for now
+  nw="$nw -Wtraditional-conversion" # Too many warnings for now
+  nw="$nw -Wcast-qual"              # Too many warnings for now
+  nw="$nw -Wswitch-enum"            # Too many warnings for now
+  # This, $nw, is the list of warnings we disable.
+
+  gl_MANYWARN_ALL_GCC([ws])
+  gl_MANYWARN_COMPLEMENT([ws], [$ws], [$nw])
+  for w in $ws; do
+    gl_WARN_ADD([$w])
+  done
+
+  gl_WARN_ADD([-fdiagnostics-show-option])
+  gl_WARN_ADD([-funit-at-a-time])
+
+  AC_SUBST([WARN_CFLAGS])
+
+  AC_DEFINE([_FORTIFY_SOURCE], [2],
+    [enable compile-time and run-time bounds-checking, and some warnings])
+fi
+
 # Tandem/NSK is broken - it has 'long long int' but not
 # 'unsigned long long int', which confuses assumptions made by gnulib.
 # Simply pretend that neither type exists if both do not work.
diff --git a/m4/gnulib-cache.m4 b/m4/gnulib-cache.m4
index 92cfe55..33aa0df 100644
--- a/m4/gnulib-cache.m4
+++ b/m4/gnulib-cache.m4
@@ -15,7 +15,7 @@


 # Specification in the form of a command-line invocation:
-#   gnulib-tool --import --dir=. --local-dir=local --lib=libm4 
--source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests 
--aux-dir=build-aux --with-tests --avoid=lock-tests --avoid=tls-tests 
--makefile-name=gnulib.mk --no-libtool --macro-prefix=M4 announce-gen assert 
autobuild avltree-oset binary-io c-stack clean-temp cloexec close-stream 
closein config-h dirname error execute fdl-1.3 fflush filenamecat fopen 
fopen-safer fseeko gendocs getopt-gnu git-version-gen gnu-web-doc-update 
gnumakefile gnupload gpl-3.0 intprops maintainer-makefile memchr2 mkstemp 
obstack pipe progname regex sigaction stdbool stdint stdlib-safer strsignal 
strstr strtod strtol unlocked-io update-copyright vc-list-files verror 
version-etc version-etc-fsf wait-process xalloc xprintf xvasprintf-posix
+#   gnulib-tool --import --dir=. --local-dir=local --lib=libm4 
--source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests 
--aux-dir=build-aux --with-tests --avoid=lock-tests --avoid=tls-tests 
--makefile-name=gnulib.mk --no-libtool --macro-prefix=M4 announce-gen assert 
autobuild avltree-oset binary-io c-stack clean-temp cloexec close-stream 
closein config-h dirname error execute fdl-1.3 fflush filenamecat fopen 
fopen-safer fseeko gendocs getopt-gnu git-version-gen gnu-web-doc-update 
gnumakefile gnupload gpl-3.0 intprops maintainer-makefile manywarnings memchr2 
mkstemp obstack pipe progname regex sigaction stdbool stdint stdlib-safer 
strsignal strstr strtod strtol unlocked-io update-copyright vc-list-files 
verror version-etc version-etc-fsf wait-process xalloc xprintf xvasprintf-posix

 # Specification in the form of a few gnulib-tool.m4 macro invocations:
 gl_LOCAL_DIR([local])
@@ -49,6 +49,7 @@ gl_MODULES([
   gpl-3.0
   intprops
   maintainer-makefile
+  manywarnings
   memchr2
   mkstemp
   obstack
diff --git a/src/Makefile.am b/src/Makefile.am
index 58a5ac6..bdf52de 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -21,6 +21,7 @@

 AUTOMAKE_OPTIONS = nostdinc
 AM_CPPFLAGS = -I$(top_srcdir)/lib -I../lib
+AM_CFLAGS = $(WARN_CFLAGS) $(WERROR_CFLAGS)
 bin_PROGRAMS = m4
 m4_SOURCES = m4.h m4.c builtin.c debug.c eval.c format.c freeze.c input.c \
 macro.c output.c path.c symtab.c
diff --git a/src/builtin.c b/src/builtin.c
index b8487a7..3dcca8a 100644
--- a/src/builtin.c
+++ b/src/builtin.c
@@ -576,6 +576,7 @@ define_macro (int argc, token_data **argv, symbol_lookup 
mode)
        define_builtin (ARG (1), bp, mode);
       break;

+    case TOKEN_VOID:
     default:
       M4ERROR ((warning_status, 0,
                "INTERNAL ERROR: bad token data type in define_macro ()"));
@@ -584,13 +585,13 @@ define_macro (int argc, token_data **argv, symbol_lookup 
mode)
 }

 static void
-m4_define (struct obstack *obs, int argc, token_data **argv)
+m4_define (struct obstack *obs M4_GNUC_UNUSED, int argc, token_data **argv)
 {
   define_macro (argc, argv, SYMBOL_INSERT);
 }

 static void
-m4_undefine (struct obstack *obs, int argc, token_data **argv)
+m4_undefine (struct obstack *obs M4_GNUC_UNUSED, int argc, token_data **argv)
 {
   int i;
   if (bad_argc (argv[0], argc, 2, -1))
@@ -600,13 +601,13 @@ m4_undefine (struct obstack *obs, int argc, token_data 
**argv)
 }

 static void
-m4_pushdef (struct obstack *obs, int argc, token_data **argv)
+m4_pushdef (struct obstack *obs M4_GNUC_UNUSED, int argc, token_data **argv)
 {
   define_macro (argc, argv,  SYMBOL_PUSHDEF);
 }

 static void
-m4_popdef (struct obstack *obs, int argc, token_data **argv)
+m4_popdef (struct obstack *obs M4_GNUC_UNUSED, int argc, token_data **argv)
 {
   int i;
   if (bad_argc (argv[0], argc, 2, -1))
@@ -786,6 +787,7 @@ INTERNAL ERROR: builtin not found in builtin table"));
          DEBUG_PRINT1 ("<%s>\n", bp->name);
          break;

+       case TOKEN_VOID:
        default:
          M4ERROR ((warning_status, 0,
                    "INTERNAL ERROR: bad token data type in m4_dumpdef ()"));
@@ -941,7 +943,7 @@ builtin `%s' requested by frozen file is not supported", 
ARG (i)));
 static int sysval;

 static void
-m4_syscmd (struct obstack *obs, int argc, token_data **argv)
+m4_syscmd (struct obstack *obs M4_GNUC_UNUSED, int argc, token_data **argv)
 {
   const char *cmd = ARG (1);
   int status;
@@ -1059,7 +1061,8 @@ m4_esyscmd (struct obstack *obs, int argc, token_data 
**argv)
 }

 static void
-m4_sysval (struct obstack *obs, int argc, token_data **argv)
+m4_sysval (struct obstack *obs, int argc M4_GNUC_UNUSED,
+          token_data **argv M4_GNUC_UNUSED)
 {
   shipout_int (obs, sysval);
 }
@@ -1172,7 +1175,7 @@ m4_decr (struct obstack *obs, int argc, token_data **argv)
 `-----------------------------------------------------------------------*/

 static void
-m4_divert (struct obstack *obs, int argc, token_data **argv)
+m4_divert (struct obstack *obs M4_GNUC_UNUSED, int argc, token_data **argv)
 {
   int i = 0;

@@ -1205,7 +1208,7 @@ m4_divnum (struct obstack *obs, int argc, token_data 
**argv)
 `-----------------------------------------------------------------------*/

 static void
-m4_undivert (struct obstack *obs, int argc, token_data **argv)
+m4_undivert (struct obstack *obs M4_GNUC_UNUSED, int argc, token_data **argv)
 {
   int i, file;
   FILE *fp;
@@ -1249,7 +1252,7 @@ m4_undivert (struct obstack *obs, int argc, token_data 
**argv)
 `------------------------------------------------------------------------*/

 static void
-m4_dnl (struct obstack *obs, int argc, token_data **argv)
+m4_dnl (struct obstack *obs M4_GNUC_UNUSED, int argc, token_data **argv)
 {
   if (bad_argc (argv[0], argc, 1, 1))
     return;
@@ -1275,7 +1278,8 @@ m4_shift (struct obstack *obs, int argc, token_data 
**argv)
 `--------------------------------------------------------------------------*/

 static void
-m4_changequote (struct obstack *obs, int argc, token_data **argv)
+m4_changequote (struct obstack *obs M4_GNUC_UNUSED, int argc,
+               token_data **argv)
 {
   if (bad_argc (argv[0], argc, 1, 3))
     return;
@@ -1291,7 +1295,7 @@ m4_changequote (struct obstack *obs, int argc, token_data 
**argv)
 `--------------------------------------------------------------------*/

 static void
-m4_changecom (struct obstack *obs, int argc, token_data **argv)
+m4_changecom (struct obstack *obs M4_GNUC_UNUSED, int argc, token_data **argv)
 {
   if (bad_argc (argv[0], argc, 1, 3))
     return;
@@ -1309,7 +1313,7 @@ m4_changecom (struct obstack *obs, int argc, token_data 
**argv)
 `-----------------------------------------------------------------------*/

 static void
-m4_changeword (struct obstack *obs, int argc, token_data **argv)
+m4_changeword (struct obstack *obs M4_GNUC_UNUSED, int argc, token_data **argv)
 {
   if (bad_argc (argv[0], argc, 2, 2))
     return;
@@ -1357,7 +1361,7 @@ include (int argc, token_data **argv, bool silent)
 `------------------------------------------------*/

 static void
-m4_include (struct obstack *obs, int argc, token_data **argv)
+m4_include (struct obstack *obs M4_GNUC_UNUSED, int argc, token_data **argv)
 {
   include (argc, argv, false);
 }
@@ -1367,7 +1371,7 @@ m4_include (struct obstack *obs, int argc, token_data 
**argv)
 `----------------------------------*/

 static void
-m4_sinclude (struct obstack *obs, int argc, token_data **argv)
+m4_sinclude (struct obstack *obs M4_GNUC_UNUSED, int argc, token_data **argv)
 {
   include (argc, argv, true);
 }
@@ -1387,7 +1391,7 @@ mkstemp_helper (struct obstack *obs, const char *me, 
const char *pattern,
                size_t len)
 {
   int fd;
-  int i;
+  size_t i;
   char *name;

   /* Guarantee that there are six trailing 'X' characters, even if the
@@ -1405,7 +1409,7 @@ mkstemp_helper (struct obstack *obs, const char *me, 
const char *pattern,
   fd = mkstemp (name);
   if (fd < 0)
     {
-      M4ERROR ((0, errno, "cannot create tempfile `%s'", pattern));
+      M4ERROR ((0, errno, "%s: cannot create tempfile `%s'", me, pattern));
       obstack_free (obs, obstack_finish (obs));
     }
   else
@@ -1521,8 +1525,8 @@ m4___program__ (struct obstack *obs, int argc, token_data 
**argv)
 | arguments are present.                                                  |
 `-------------------------------------------------------------------------*/

-static void
-m4_m4exit (struct obstack *obs, int argc, token_data **argv)
+static void M4_GNUC_NORETURN
+m4_m4exit (struct obstack *obs M4_GNUC_UNUSED, int argc, token_data **argv)
 {
   int exit_code = EXIT_SUCCESS;

@@ -1609,7 +1613,7 @@ m4_traceon (struct obstack *obs, int argc, token_data 
**argv)
 `------------------------------------------------------------------------*/

 static void
-m4_traceoff (struct obstack *obs, int argc, token_data **argv)
+m4_traceoff (struct obstack *obs M4_GNUC_UNUSED, int argc, token_data **argv)
 {
   symbol *s;
   int i;
@@ -1632,7 +1636,7 @@ m4_traceoff (struct obstack *obs, int argc, token_data 
**argv)
 `----------------------------------------------------------------------*/

 static void
-m4_debugmode (struct obstack *obs, int argc, token_data **argv)
+m4_debugmode (struct obstack *obs M4_GNUC_UNUSED, int argc, token_data **argv)
 {
   int new_debug_level;
   int change_flag;
@@ -1673,6 +1677,11 @@ m4_debugmode (struct obstack *obs, int argc, token_data 
**argv)
            case '-':
              debug_level &= ~new_debug_level;
              break;
+
+           default:
+             M4ERROR ((warning_status, 0,
+                       "INTERNAL ERROR: bad flag in m4_debugmode ()"));
+             abort ();
            }
        }
     }
@@ -1684,7 +1693,7 @@ m4_debugmode (struct obstack *obs, int argc, token_data 
**argv)
 `-------------------------------------------------------------------------*/

 static void
-m4_debugfile (struct obstack *obs, int argc, token_data **argv)
+m4_debugfile (struct obstack *obs M4_GNUC_UNUSED, int argc, token_data **argv)
 {
   if (bad_argc (argv[0], argc, 1, 2))
     return;
@@ -1940,6 +1949,7 @@ substitute (struct obstack *obs, const char *victim, 
const char *repl,
            struct re_registers *regs)
 {
   int ch;
+  __re_size_t ind;
   while (1)
     {
       const char *backslash = strchr (repl, '\\');
@@ -1970,8 +1980,8 @@ Warning: \\0 will disappear, use \\& instead in 
replacements"));

        case '1': case '2': case '3': case '4': case '5': case '6':
        case '7': case '8': case '9':
-         ch -= '0';
-         if (regs->num_regs - 1 <= ch)
+         ind = ch -= '0';
+         if (regs->num_regs - 1 <= ind)
            M4ERROR ((warning_status, 0,
                      "Warning: sub-expression %d not present", ch));
          else if (regs->end[ch] > 0)
@@ -2175,7 +2185,8 @@ m4_patsubst (struct obstack *obs, int argc, token_data 
**argv)
 `--------------------------------------------------------------------*/

 void
-m4_placeholder (struct obstack *obs, int argc, token_data **argv)
+m4_placeholder (struct obstack *obs M4_GNUC_UNUSED, int argc,
+               token_data **argv)
 {
   M4ERROR ((warning_status, 0, "\
 builtin `%s' requested by frozen file is not supported", ARG (0)));
diff --git a/src/debug.c b/src/debug.c
index 0c9ee37..c13786c 100644
--- a/src/debug.c
+++ b/src/debug.c
@@ -405,6 +405,7 @@ INTERNAL ERROR: builtin not found in builtin table! 
(trace_pre ())"));
              trace_format ("<%s>", bp->name);
              break;

+           case TOKEN_VOID:
            default:
              M4ERROR ((warning_status, 0,
                        "INTERNAL ERROR: bad token data type (trace_pre ())"));
@@ -428,8 +429,7 @@ INTERNAL ERROR: builtin not found in builtin table! 
(trace_pre ())"));
 `-------------------------------------------------------------------*/

 void
-trace_post (const char *name, int id, int argc, token_data **argv,
-           const char *expanded)
+trace_post (const char *name, int id, int argc, const char *expanded)
 {
   if (debug_level & DEBUG_TRACE_CALL)
     {
diff --git a/src/format.c b/src/format.c
index dc9d5e6..d38f2d4 100644
--- a/src/format.c
+++ b/src/format.c
@@ -42,7 +42,7 @@ arg_int (const char *str)
     }
   errno = 0;
   value = strtol (str, &endp, 10);
-  if (endp - str != len)
+  if (endp - str - len)
     M4ERROR ((warning_status, 0, _("non-numeric argument %s"), str));
   else if (isspace (to_uchar (*str)))
     M4ERROR ((warning_status, 0, _("leading whitespace ignored")));
@@ -66,7 +66,7 @@ arg_long (const char *str)
     }
   errno = 0;
   value = strtol (str, &endp, 10);
-  if (endp - str != len)
+  if (endp - str - len)
     M4ERROR ((warning_status, 0, _("non-numeric argument %s"), str));
   else if (isspace (to_uchar (*str)))
     M4ERROR ((warning_status, 0, _("leading whitespace ignored")));
@@ -90,7 +90,7 @@ arg_double (const char *str)
     }
   errno = 0;
   value = strtod (str, &endp);
-  if (endp - str != len)
+  if (endp - str - len)
     M4ERROR ((warning_status, 0, _("non-numeric argument %s"), str));
   else if (isspace (to_uchar (*str)))
     M4ERROR ((warning_status, 0, _("leading whitespace ignored")));
diff --git a/src/freeze.c b/src/freeze.c
index 041bed4..518f1cb 100644
--- a/src/freeze.c
+++ b/src/freeze.c
@@ -52,7 +52,7 @@ void
 produce_frozen_state (const char *name)
 {
   FILE *file;
-  int h;
+  size_t h;
   symbol *sym;
   const builtin *bp;

@@ -207,12 +207,12 @@ reload_frozen_state (const char *name)
   do                                                           \
     {                                                          \
       unsigned int n = 0;                                      \
-      while (isdigit (character) && n <= INT_MAX / 10)         \
+      while (isdigit (character) && n <= INT_MAX / 10U)                \
        {                                                       \
          n = 10 * n + character - '0';                         \
          GET_CHARACTER;                                        \
        }                                                       \
-      if (((AllowNeg) ? INT_MIN : INT_MAX) < n                 \
+      if (((AllowNeg) ? INT_MIN : INT_MAX) + 0U < n            \
          || isdigit (character))                               \
        m4_error (EXIT_FAILURE, 0,                              \
                  _("integer overflow in frozen file"));        \
diff --git a/src/input.c b/src/input.c
index fb61ba1..740df78 100644
--- a/src/input.c
+++ b/src/input.c
@@ -913,8 +913,8 @@ next_token (token_data *td, int *line)
                                (char *) obstack_base (&token_stack),
                                obstack_object_size (&token_stack), 0, 0,
                                &regs);
-         if (startpos != 0 ||
-             regs.end [0] != obstack_object_size (&token_stack))
+         if (startpos ||
+             regs.end [0] != (regoff_t) obstack_object_size (&token_stack))
            {
              *(((char *) obstack_base (&token_stack)
                 + obstack_object_size (&token_stack)) - 1) = '\0';
diff --git a/src/m4.c b/src/m4.c
index 584fb0f..685d022 100644
--- a/src/m4.c
+++ b/src/m4.c
@@ -35,7 +35,7 @@

 #define AUTHORS "Rene' Seindal"

-static void usage (int);
+static void usage (int) M4_GNUC_NORETURN;

 /* Enable sync output for /lib/cpp (-s).  */
 int sync_output = 0;
@@ -357,7 +357,7 @@ process_file (const char *name)
 #endif

 int
-main (int argc, char *const *argv, char *const *envp)
+main (int argc, char *const *argv)
 {
   struct sigaction act;
   macro_definition *head;      /* head of deferred argument list */
diff --git a/src/m4.h b/src/m4.h
index 504c2e2..4f524ec 100644
--- a/src/m4.h
+++ b/src/m4.h
@@ -109,14 +109,15 @@ typedef unsigned int bool_bitfield;
 /* Take advantage of GNU C compiler source level optimization hints,
    using portable macros.  */
 #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 6)
-#  define M4_GNUC_ATTRIBUTE(args)      __attribute__(args)
+# define M4_GNUC_ATTRIBUTE(args)       __attribute__ (args)
 #else
-#  define M4_GNUC_ATTRIBUTE(args)
+# define M4_GNUC_ATTRIBUTE(args)
 #endif  /* __GNUC__ */

-#define M4_GNUC_UNUSED         M4_GNUC_ATTRIBUTE((__unused__))
+#define M4_GNUC_UNUSED         M4_GNUC_ATTRIBUTE ((__unused__))
 #define M4_GNUC_PRINTF(fmt, arg)                       \
-  M4_GNUC_ATTRIBUTE((__format__ (__printf__, fmt, arg)))
+  M4_GNUC_ATTRIBUTE ((__format__ (__printf__, fmt, arg)))
+#define M4_GNUC_NORETURN       M4_GNUC_ATTRIBUTE ((__noreturn__))
 
 /* File: m4.c  --- global definitions.  */

@@ -238,7 +239,7 @@ void debug_message_prefix (void);

 void trace_prepre (const char *, int);
 void trace_pre (const char *, int, int, token_data **);
-void trace_post (const char *, int, int, token_data **, const char *);
+void trace_post (const char *, int, int, const char *);
 
 /* File: input.c  --- lexical definitions.  */

diff --git a/src/macro.c b/src/macro.c
index 73547ea..04079cf 100644
--- a/src/macro.c
+++ b/src/macro.c
@@ -282,6 +282,7 @@ call_macro (symbol *sym, int argc, token_data **argv,
       expand_user_macro (expansion, sym, argc, argv);
       break;

+    case TOKEN_VOID:
     default:
       M4ERROR ((warning_status, 0,
                "INTERNAL ERROR: bad symbol type in call_macro ()"));
@@ -368,7 +369,7 @@ expand_macro (symbol *sym)
   expanded = push_string_finish ();

   if (traced)
-    trace_post (SYMBOL_NAME (sym), my_call_id, argc, argv, expanded);
+    trace_post (SYMBOL_NAME (sym), my_call_id, argc, expanded);

   current_file = loc_close_file;
   current_line = loc_close_line;
diff --git a/src/output.c b/src/output.c
index 8740f5d..4070baa 100644
--- a/src/output.c
+++ b/src/output.c
@@ -191,7 +191,8 @@ m4_tmpname (int divnum)
   if (buffer == NULL)
     {
       tail = xasprintf ("%s/m4-%d", output_temp_dir->dir_name, INT_MAX);
-      buffer = obstack_copy0 (&diversion_storage, tail, strlen (tail));
+      buffer = (char *) obstack_copy0 (&diversion_storage, tail,
+                                      strlen (tail));
       free (tail);
       tail = strrchr (buffer, '-') + 1;
     }
@@ -992,7 +993,8 @@ freeze_diversions (FILE *file)
              if (fstat (fileno (diversion->u.file), &file_stat) < 0)
                M4ERROR ((EXIT_FAILURE, errno, "cannot stat diversion"));
              if (file_stat.st_size < 0
-                 || file_stat.st_size != (unsigned long int) file_stat.st_size)
+                 || (file_stat.st_size + 0UL
+                     != (unsigned long int) file_stat.st_size))
                M4ERROR ((EXIT_FAILURE, 0, "diversion too large"));
              xfprintf (file, "D%d,%lu\n", diversion->divnum,
                        (unsigned long int) file_stat.st_size);
diff --git a/src/path.c b/src/path.c
index b846161..49e624e 100644
--- a/src/path.c
+++ b/src/path.c
@@ -108,7 +108,7 @@ add_include_directory (const char *dir)
 /* Attempt to open FILE; if it opens, verify that it is not a
    directory, and ensure it does not leak across execs.  */
 static FILE *
-m4_fopen (const char *file, const char *mode)
+m4_fopen (const char *file)
 {
   FILE *fp = fopen (file, "r");
   if (fp)
@@ -152,7 +152,7 @@ m4_path_search (const char *file, char **result)
     }

   /* Look in current working directory first.  */
-  fp = m4_fopen (file, "r");
+  fp = m4_fopen (file);
   if (fp != NULL)
     {
       if (result)
@@ -173,7 +173,7 @@ m4_path_search (const char *file, char **result)
       xfprintf (stderr, "m4_path_search (%s) -- trying %s\n", file, name);
 #endif

-      fp = m4_fopen (name, "r");
+      fp = m4_fopen (name);
       if (fp != NULL)
        {
          if (debug_level & DEBUG_TRACE_PATH)
diff --git a/src/symtab.c b/src/symtab.c
index 56e8703..eb37872 100644
--- a/src/symtab.c
+++ b/src/symtab.c
@@ -306,6 +306,7 @@ lookup_symbol (const char *name, symbol_lookup mode)
       }
       return NULL;

+    case SYMBOL_LOOKUP:
     default:
       M4ERROR ((warning_status, 0,
                "INTERNAL ERROR: invalid mode to symbol_lookup ()"));
-- 
1.6.5.rc1


>From 30cd2068dcb8b51f9fe29741732027bb00b522a5 Mon Sep 17 00:00:00 2001
From: Eric Blake <address@hidden>
Date: Thu, 26 Nov 2009 06:29:06 -0700
Subject: [PATCH 5/5] Ignore write failures before stack overflow exit.

* m4/gnulib-cache.m4: Import ignore-value module.
* src/m4.c (fault_handler): Use it to avoid compiler warning.

Signed-off-by: Eric Blake <address@hidden>
---
 ChangeLog          |    6 ++++++
 m4/gnulib-cache.m4 |    3 ++-
 src/m4.c           |   18 +++++++++++-------
 3 files changed, 19 insertions(+), 8 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 5b4cc72..19cf20d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2009-11-26  Eric Blake  <address@hidden>
+
+       Ignore write failures before stack overflow exit.
+       * m4/gnulib-cache.m4: Import ignore-value module.
+       * src/m4.c (fault_handler): Use it to avoid compiler warning.
+
 2009-11-25  Eric Blake  <address@hidden>

        Allow use of compiler warnings.
diff --git a/m4/gnulib-cache.m4 b/m4/gnulib-cache.m4
index 33aa0df..2440df0 100644
--- a/m4/gnulib-cache.m4
+++ b/m4/gnulib-cache.m4
@@ -15,7 +15,7 @@


 # Specification in the form of a command-line invocation:
-#   gnulib-tool --import --dir=. --local-dir=local --lib=libm4 
--source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests 
--aux-dir=build-aux --with-tests --avoid=lock-tests --avoid=tls-tests 
--makefile-name=gnulib.mk --no-libtool --macro-prefix=M4 announce-gen assert 
autobuild avltree-oset binary-io c-stack clean-temp cloexec close-stream 
closein config-h dirname error execute fdl-1.3 fflush filenamecat fopen 
fopen-safer fseeko gendocs getopt-gnu git-version-gen gnu-web-doc-update 
gnumakefile gnupload gpl-3.0 intprops maintainer-makefile manywarnings memchr2 
mkstemp obstack pipe progname regex sigaction stdbool stdint stdlib-safer 
strsignal strstr strtod strtol unlocked-io update-copyright vc-list-files 
verror version-etc version-etc-fsf wait-process xalloc xprintf xvasprintf-posix
+#   gnulib-tool --import --dir=. --local-dir=local --lib=libm4 
--source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests 
--aux-dir=build-aux --with-tests --avoid=lock-tests --avoid=tls-tests 
--makefile-name=gnulib.mk --no-libtool --macro-prefix=M4 announce-gen assert 
autobuild avltree-oset binary-io c-stack clean-temp cloexec close-stream 
closein config-h dirname error execute fdl-1.3 fflush filenamecat fopen 
fopen-safer fseeko gendocs getopt-gnu git-version-gen gnu-web-doc-update 
gnumakefile gnupload gpl-3.0 ignore-value intprops maintainer-makefile 
manywarnings memchr2 mkstemp obstack pipe progname regex sigaction stdbool 
stdint stdlib-safer strsignal strstr strtod strtol unlocked-io update-copyright 
vc-list-files verror version-etc version-etc-fsf wait-process xalloc xprintf 
xvasprintf-posix

 # Specification in the form of a few gnulib-tool.m4 macro invocations:
 gl_LOCAL_DIR([local])
@@ -47,6 +47,7 @@ gl_MODULES([
   gnumakefile
   gnupload
   gpl-3.0
+  ignore-value
   intprops
   maintainer-makefile
   manywarnings
diff --git a/src/m4.c b/src/m4.c
index 685d022..496b6e0 100644
--- a/src/m4.c
+++ b/src/m4.c
@@ -26,6 +26,7 @@
 #include <signal.h>

 #include "c-stack.h"
+#include "ignore-value.h"
 #include "progname.h"
 #include "version-etc.h"

@@ -147,18 +148,21 @@ fault_handler (int signo)
         async-safe.  However, the static variables that we read are
         never modified once this handler is installed, so this
         particular usage is safe.  And it seems an oversight that
-        POSIX claims strlen is not async-safe.  */
-      write (STDERR_FILENO, program_name, strlen (program_name));
-      write (STDERR_FILENO, ": ", 2);
-      write (STDERR_FILENO, program_error_message,
+        POSIX claims strlen is not async-safe.  Ignore write
+        failures, since we will exit with non-zero status anyway.  */
+#define WRITE(f, b, l) ignore_value (write (f, b, l))
+      WRITE (STDERR_FILENO, program_name, strlen (program_name));
+      WRITE (STDERR_FILENO, ": ", 2);
+      WRITE (STDERR_FILENO, program_error_message,
             strlen (program_error_message));
       if (signal_message[signo])
        {
-         write (STDERR_FILENO, ": ", 2);
-         write (STDERR_FILENO, signal_message[signo],
+         WRITE (STDERR_FILENO, ": ", 2);
+         WRITE (STDERR_FILENO, signal_message[signo],
                 strlen (signal_message[signo]));
        }
-      write (STDERR_FILENO, "\n", 1);
+      WRITE (STDERR_FILENO, "\n", 1);
+#undef WRITE
       _exit (EXIT_INTERNAL_ERROR);
     }
 }
-- 
1.6.5.rc1


reply via email to

[Prev in Thread] Current Thread [Next in Thread]