diff -Naur m4-1.4.3.orig/COPYING m4-1.4.3/COPYING --- m4-1.4.3.orig/COPYING 2004-08-21 17:29:00.000000000 +0700 +++ m4-1.4.3/COPYING 2005-10-11 16:26:30.000000000 +0700 @@ -2,7 +2,8 @@ Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. - 675 Mass Ave, Cambridge, MA 02139, USA + 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. @@ -305,7 +306,8 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + Also add information on how to contact you by electronic and paper mail. diff -Naur m4-1.4.3.orig/ChangeLog m4-1.4.3/ChangeLog --- m4-1.4.3.orig/ChangeLog 2005-03-31 18:50:38.000000000 +0700 +++ m4-1.4.3/ChangeLog 2005-10-11 16:26:30.000000000 +0700 @@ -1,3 +1,13 @@ +2005-10-11 John Gatewood Ham (tiny changes) + + * COPYING: fix FSF address + * README: update email address for bug reports + * src/m4.c: fix return code when non-existent files are processed + * doc/m4.texinfo: Add documentation about EXIT_STATUS + * checks/Makefile.in: Add invocation_tests to 'make check' system + * checks/invocation_tests: Add tests for EXIT_STATUS behavior so + 'make check' will test the changes. + 2005-03-31 Gary V. Vaughan (tiny change) * configure.in (VERSION): Bump to 1.4.3. diff -Naur m4-1.4.3.orig/README m4-1.4.3/README --- m4-1.4.3.orig/README 2004-08-21 17:29:00.000000000 +0700 +++ m4-1.4.3/README 2005-10-11 16:26:30.000000000 +0700 @@ -25,7 +25,7 @@ feature which allows for changing the syntax of what is a "word" in `m4'. This might go away, so don't count on it yet. -Send bug reports to address@hidden'. A bug report is -an adequate description of the problem: your input, what you expected, -what you got, and why this is wrong. Diffs are welcome, but they only -describe a solution, from which the problem might be uneasy to infer. +Send bug reports to address@hidden'. A bug report is an adequate +description of the problem: your input, what you expected, what you got, +and why this is wrong. Diffs are welcome, but they only describe a +solution, from which the problem might be uneasy to infer. diff -Naur m4-1.4.3.orig/THANKS m4-1.4.3/THANKS --- m4-1.4.3.orig/THANKS 2004-08-21 17:29:00.000000000 +0700 +++ m4-1.4.3/THANKS 2005-10-11 16:26:30.000000000 +0700 @@ -33,6 +33,7 @@ Jim Meyering address@hidden Joel Sherrill address@hidden John David Anglin address@hidden +John Gatewood Ham address@hidden Joseph E. Sacco address@hidden Karl Berry address@hidden Karl Vogel address@hidden diff -Naur m4-1.4.3.orig/checks/Makefile.in m4-1.4.3/checks/Makefile.in --- m4-1.4.3.orig/checks/Makefile.in 2005-02-10 03:48:32.000000000 +0700 +++ m4-1.4.3/checks/Makefile.in 2005-10-11 16:29:43.000000000 +0700 @@ -1,5 +1,5 @@ # Makefile for GNU m4 checks directory. -# Copyright (C) 1992, 1993, 1994 Free Software Foundation, Inc. +# Copyright (C) 1992, 1993, 1994, 2005 Free Software Foundation, Inc. # 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 @@ -13,7 +13,7 @@ # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software -# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA PACKAGE = @PACKAGE@ VERSION = @VERSION@ @@ -28,7 +28,7 @@ # Vern says that the first star is required around an Alpha make bug. CHECKS = *[0-9][0-9].* -DISTFILES = Makefile.in get-them check-them stamp-checks incl.m4 foo +DISTFILES = Makefile.in get-them check-them stamp-checks incl.m4 foo invocation_tests all: stamp-checks @@ -43,7 +43,8 @@ check: stamp-checks PATH=`pwd`/../src:$$PATH; export PATH; \ - cd $(srcdir) && ./check-them $(CHECKS) + cd $(srcdir) && ./check-them $(CHECKS); \ + cd $(srcdir) && ./invocation_tests tags: diff -Naur m4-1.4.3.orig/checks/invocation_tests m4-1.4.3/checks/invocation_tests --- m4-1.4.3.orig/checks/invocation_tests 1970-01-01 07:00:00.000000000 +0700 +++ m4-1.4.3/checks/invocation_tests 2005-10-11 16:33:57.000000000 +0700 @@ -0,0 +1,77 @@ +#!/bin/sh +# Check GNU m4 exit status codes. +# Copyright (C) 2005 Free Software Foundation, Inc. +testno=0 +testcount=0 +failcount=0 +faillist="" + +testno=`expr ${testno} + 1` +testcount=`expr ${testcount} + 1` +msg="${testno}: Ensure m4 exits with non-zero exit code when fed a non-existent file as input." +echo -n "running invocation test ${testno}: " +m4 nosuchfile >/dev/null 2>&1 +if [ $? -eq 0 ] +then + failcount=`expr ${failcount} + 1` + if [ -z "${faillist}" ] + then + faillist="${msg}" + else + faillist="${faillist}\n${msg}" + fi + echo "FAIL" +else + echo "OK" +fi + +testno=`expr ${testno} + 1` +testcount=`expr ${testcount} + 1` +msg="${testno}: Ensure m4 exits with a zero exit code when fed a valid file as input." +echo -n "running invocation test ${testno}: " +m4 foo >/dev/null 2>&1 +if [ $? -ne 0 ] +then + failcount=`expr ${failcount} + 1` + if [ -z "${faillist}" ] + then + faillist="${msg}" + else + faillist="${faillist}\n${msg}" + fi + echo "FAIL" +else + echo "OK" +fi + +testno=`expr ${testno} + 1` +testcount=`expr ${testcount} + 1` +msg="${testno}: Ensure m4 exits with a zero exit code when fed a valid stream from stdin." +echo -n "running invocation test ${testno}: " +cat foo | m4 - >/dev/null 2>&1 +if [ $? -ne 0 ] +then + failcount=`expr ${failcount} + 1` + if [ -z "${faillist}" ] + then + faillist="${msg}" + else + faillist="${faillist}\n${msg}" + fi + echo "FAIL" +else + echo "OK" +fi + +# +# display test results +# +if [ -z "${faillist}" ] +then + echo "All ${testcount} checks successful" +else + echo "${failcount} of ${testcount} checks failed. Failed checks were:" + echo -e "${faillist}" + exit 1 +fi +exit 0 diff -Naur m4-1.4.3.orig/doc/m4.texinfo m4-1.4.3/doc/m4.texinfo --- m4-1.4.3.orig/doc/m4.texinfo 2005-03-31 18:17:00.000000000 +0700 +++ m4-1.4.3/doc/m4.texinfo 2005-10-11 16:26:30.000000000 +0700 @@ -57,7 +57,7 @@ @page @vskip 0pt plus 1filll -Copyright @copyright{} 1989, 1990, 1991, 1992, 1993, 1994, 2004 Free Software Foundation, Inc. +Copyright @copyright{} 1989, 1990, 1991, 1992, 1993, 1994, 2004, 2005 Free Software Foundation, Inc. Permission is granted to make and distribute verbatim copies of this manual provided the copyright notice and this permission notice @@ -258,6 +258,7 @@ * Intro:: Introduction to @code{m4} * History:: Historical references * Invoking m4:: Invoking @code{m4} +* EXIT_STATUS:: EXIT_STATUS of m4 * Bugs:: Problems and bugs * Manual:: Using this manual @end menu @@ -312,7 +313,7 @@ Originally, @code{m4} was the engine for Rational FORTRAN preprocessor, that is, the @code{ratfor} equivalent of @code{cpp}. address@hidden Invoking m4, Bugs, History, Preliminaries address@hidden Invoking m4, EXIT_STATUS, History, Preliminaries @section Invoking @code{m4} The format of the @code{m4} command is: @@ -505,7 +506,65 @@ only be read once, so the filename @file{-} should only appear once on the command line. address@hidden Bugs, Manual, Invoking m4, Preliminaries address@hidden EXIT_STATUS, Bugs, Invoking m4, Preliminaries address@hidden EXIT_STATUS of @code{m4} + address@hidden EXIT_STATUS of @code{m4} address@hidden EXIT_STATUS +The @code{m4} program will return an exit code to the process which +invokes it when @code{m4} exits. The default behavior for @code{m4} +is that the following exit values shall be returned to the process +invoking @code{m4}: + address@hidden +0 Successful address@hidden address@hidden +>0 An error occurred + address@hidden +It is possible to override this behavior by using the @code{m4exit} macro, in +which case the exit value can be specified by the input file +(@pxref{M4exit}). + address@hidden +If a non-existent file is supplied as input, for example, the exit code should +be non-zero. Assuming a bourne-style shell such as GNU bash, this could be +used like this: + address@hidden ignore address@hidden +echo -n "Enter filename:" +read FILENAME +m4 "address@hidden@}" > "address@hidden@}.out" +if [ $? -ne 0 ] +then + echo "Unable to process \"address@hidden@}\" with m4." +fi address@hidden example + address@hidden +If the user enters the text @code{nosuchfile} and indeed there is no +file by the name @code{nosuchfile}, then @code{m4} will exit with an +exit status of 1. The output of this script will look like this: + address@hidden ignore address@hidden +m4: nosuchfile: No such file or directory +Unable to process "nosuchfile" with m4. address@hidden example + address@hidden +The first line of output is from @code{m4}, the second is from the address@hidden statement. + address@hidden +If the user user enters the text @code{goodfile.m4} and indeed there +exists a readable, error-free m4 file by the name @code{goodfile.m4}, +then @code{m4} will exit with an exit status of 0. The @code{if} condition +will be false as expected, and no message will be displayed. + address@hidden Bugs, Manual, EXIT_STATUS, Preliminaries address@hidden bug @section Problems and bugs If you have problems with GNU @code{m4} or think you've found a bug, @@ -521,11 +580,9 @@ say what you expected to occur; this will help us decide whether the problem was really in the documentation. -Once you've got a precise problem, send e-mail to (Internet) address@hidden@@prep.ai.mit.edu} or (UUCP) address@hidden Please include the -version number of @code{m4} you are using. You can get this information -with the command @samp{m4 --version}. +Once you've got a precise problem, send e-mail to @file{gnu-m4@@gnu.org}. +Please include the version number of @code{m4} you are using. You can get +this information with the command @samp{m4 --version}. Non-bug suggestions are always welcome as well. If you have questions about things that are unclear in the documentation or are just obscure diff -Naur m4-1.4.3.orig/src/m4.c m4-1.4.3/src/m4.c --- m4-1.4.3.orig/src/m4.c 2005-02-10 03:58:38.000000000 +0700 +++ m4-1.4.3/src/m4.c 2005-10-11 16:26:30.000000000 +0700 @@ -1,6 +1,6 @@ /* GNU m4 -- A simple macro processor - Copyright (C) 1989, 1990, 1991, 1992, 1993, 1994, 2004 Free + Copyright (C) 1989, 1990, 1991, 1992, 1993, 1994, 2004, 2005 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify @@ -15,7 +15,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "m4.h" @@ -263,6 +263,7 @@ macro_definition *tail; macro_definition *new; int optchar; /* option character */ + int retcode = EXIT_SUCCESS; macro_definition *defines; FILE *fp; @@ -484,6 +485,14 @@ if (fp == NULL) { error (0, errno, "%s", argv[optind]); + /* + * In order not to break existing applications that may + * depend on m4 continuing past non-existent files, I + * have decided to have m4 keep going as it always has + * past errors, but I make the final exit code be + * EXIT_FAILURE in this case. + */ + retcode = EXIT_FAILURE; continue; } else @@ -506,5 +515,5 @@ undivert_all (); } - exit (EXIT_SUCCESS); + exit (retcode); }