Following is patch 1 for gawk-2.15. This fixes two fairly obscure bugs and fixes various portability problems and GNUically-incorrect Makefile practices (more to come in 2.16). Apply with "patch -p1". diff -cr gawk-2.15/NEWS gawk-2.15.1/NEWS *** gawk-2.15/NEWS Fri May 7 14:11:19 1993 --- gawk-2.15.1/NEWS Tue May 18 13:27:27 1993 *************** *** 1,3 **** --- 1,32 ---- + Changes from 2.15 to 2.15.1 + --------------------------- + + Close stdout and stderr before all redirections on program exit. This allows + detection of write errors and also fixes the messages test on Solaris 2.x. + + Removed YYMAXDEPTH define in awk.y which was limiting the parser stack depth. + + Changes to config/bsd44, Makefile.bsd44 and configure to bring it into line + with the BSD4.4 release. + + Changed Makefile to use prefix, exec_prefix, bindir etc. + + make install now installs info files. + + make install now sets permissions on installed files. + + Make targets added: uninstall, distclean, mostlyclean and realclean. + + Added config.h to cleaner and clobber make targets. + + Changes to config/{hpux8x,sysv3,sysv4,ultrix41} to deal with alloca(). + + Change to getopt.h for portability. + + Added more special cases to the getpgrp() call. + + Added README.ibmrt-aos and config/ibmrt-aos. + Changes from 2.14 to 2.15 --------------------------- diff -cr gawk-2.15/Makefile.bsd44 gawk-2.15.1/Makefile.bsd44 *** gawk-2.15/Makefile.bsd44 Wed Jul 8 21:54:34 1992 --- gawk-2.15.1/Makefile.bsd44 Mon May 17 09:39:26 1993 *************** *** 1,8 **** PROG= awk ! SRCS= main.c eval.c builtin.c msg.c iop.c io.c field.c array.c \ node.c version.c missing.c re.c awk.c regex.c dfa.c DPADD= ${LIBM} LDADD= -lm ! CFLAGS+= -g .include --- 1,12 ---- PROG= awk ! SRCS= main.c eval.c builtin.c msg.c iop.c io.c field.c getopt1.c \ ! getopt.c array.c \ node.c version.c missing.c re.c awk.c regex.c dfa.c DPADD= ${LIBM} LDADD= -lm ! CFLAGS+=-I${.CURDIR} -DGAWK ! BINDIR= /usr/bin ! MANDIR= /usr/share/man/cat ! CLEANFILES+=awk.c y.tab.h awk.0 .include diff -cr gawk-2.15/Makefile.in gawk-2.15.1/Makefile.in *** gawk-2.15/Makefile.in Mon May 10 10:35:52 1993 --- gawk-2.15.1/Makefile.in Tue May 18 13:08:01 1993 *************** *** 22,31 **** # User tunable macros -- CHANGE THESE IN Makefile.in RATHER THAN IN # Makefile, OR configure WILL OVERWRITE YOUR CHANGES ! DESTDIR= ! BINDIR= /usr/local/bin ! MANDIR= /usr/local/man/man1 ! MANEXT= 1 # CFLAGS: options to the C compiler # --- 22,37 ---- # User tunable macros -- CHANGE THESE IN Makefile.in RATHER THAN IN # Makefile, OR configure WILL OVERWRITE YOUR CHANGES ! prefix = /usr/local ! exec_prefix = $(prefix) ! binprefix = ! manprefix = ! ! bindir = $(exec_prefix)/bin ! libdir = $(exec_prefix)/lib ! mandir = $(prefix)/man/man1 ! manext = .1 ! infodir = $(prefix)/info # CFLAGS: options to the C compiler # *************** *** 141,147 **** REL=2.15 # rules to build gawk ! gawk: $(ALLOBJS) $(GNUOBJS) $(REOBJS) $(CC) -o gawk $(CFLAGS) $(ALLOBJS) $(GNUOBJS) $(REOBJS) -lm $(LIBS) $(AWKOBJS) regex.o dfa.o: awk.h dfa.h regex.h --- 147,153 ---- REL=2.15 # rules to build gawk ! gawk: $(ALLOBJS) $(GNUOBJS) $(REOBJS) $(CC) -o gawk $(CFLAGS) $(ALLOBJS) $(GNUOBJS) $(REOBJS) -lm $(LIBS) $(AWKOBJS) regex.o dfa.o: awk.h dfa.h regex.h *************** *** 150,158 **** getopt1.o: getopt.h ! main.o: patchlevel.h ! awktab.c: awk.y $(PARSER) -v awk.y ##MAKE_VMS-Posix## mv ytab.c awktab.c ##MAKE_VMS-Posix## dummy.awk_tab.target: --- 156,164 ---- getopt1.o: getopt.h ! main.o: patchlevel.h ! awktab.c: awk.y $(PARSER) -v awk.y ##MAKE_VMS-Posix## mv ytab.c awktab.c ##MAKE_VMS-Posix## dummy.awk_tab.target: *************** *** 159,173 **** sed '/^extern char .malloc(), .realloc();$$/d' y.tab.c >awktab.c rm y.tab.c ! config.h: config.in @echo You must provide a config.h! @echo Run \"./configure\" to build it for known systems @echo or copy config.in to config.h and edit it.; exit 1 ! install: gawk ! cp gawk $(DESTDIR)$(BINDIR) ! cp gawk.1 $(DESTDIR)$(MANDIR)/gawk.$(MANEXT) # ALLOCA: uncomment this if your system (notably System V boxen) # does not have alloca in /lib/libc.a or /lib/libPW.a # --- 165,183 ---- sed '/^extern char .malloc(), .realloc();$$/d' y.tab.c >awktab.c rm y.tab.c ! config.h: config.in @echo You must provide a config.h! @echo Run \"./configure\" to build it for known systems @echo or copy config.in to config.h and edit it.; exit 1 ! install: gawk ! cp gawk $(bindir) && chmod 755 $(bindir)/gawk ! cp gawk.1 $(mandir)/gawk$(manext) && chmod 644 $(mandir)/gawk$(manext) ! cp gawk.info* $(infodir) && chmod 644 $(infodir)/gawk.info* + uninstall: + rm -f $(bindir)/gawk $(mandir)/gawk$(manext) $(infodir)/gawk.info* + # ALLOCA: uncomment this if your system (notably System V boxen) # does not have alloca in /lib/libc.a or /lib/libPW.a # *************** *** 178,192 **** # One of these rules should have already been selected by running configure. ! ##MAKE_ALLOCA_S## alloca.o: alloca.s ##MAKE_ALLOCA_S## /lib/cpp < alloca.s | sed '/^#/d' > t.s ##MAKE_ALLOCA_S## as t.s -o alloca.o ##MAKE_ALLOCA_S## rm t.s ! ##MAKE_ALLOCA_C## alloca.o: alloca.c # auxiliary rules for release maintenance ! lint: $(ALLSRC) lint -hcbax $(FLAGS) $(ALLSRC) xref: --- 188,202 ---- # One of these rules should have already been selected by running configure. ! ##MAKE_ALLOCA_S## alloca.o: alloca.s ##MAKE_ALLOCA_S## /lib/cpp < alloca.s | sed '/^#/d' > t.s ##MAKE_ALLOCA_S## as t.s -o alloca.o ##MAKE_ALLOCA_S## rm t.s ! ##MAKE_ALLOCA_C## alloca.o: alloca.c # auxiliary rules for release maintenance ! lint: $(ALLSRC) lint -hcbax $(FLAGS) $(ALLSRC) xref: *************** *** 193,208 **** cxref -c $(FLAGS) $(ALLSRC) | grep -v ' /' >xref clean: ! rm -rf *.o core awk.output gmon.out make.out y.output \ ! *.orig *.rej */*.orig */*.rej cleaner: clean ! rm -f gawk awktab.c Makefile ! clobber: clean ! rm -f $(ALLDOC) gawk.log ! gawk.dvi: gawk.texi tex gawk.texi; texindex gawk.?? tex gawk.texi; texindex gawk.?? tex gawk.texi --- 203,226 ---- cxref -c $(FLAGS) $(ALLSRC) | grep -v ' /' >xref clean: ! rm -rf gawk *.o core ! ! distclean: clean ! rm -f Makefile *.orig *.rej */*.orig */*.rej awk.output gmon.out \ ! make.out y.output config.h ! ! mostlyclean: clean ! ! realclean: distclean ! rm -f awktab.c $(ALLDOC) cleaner: clean ! rm -f gawk awktab.c Makefile config.h ! clobber: clean ! rm -f $(ALLDOC) gawk.log config.h ! gawk.dvi: gawk.texi tex gawk.texi; texindex gawk.?? tex gawk.texi; texindex gawk.?? tex gawk.texi *************** *** 250,256 **** pstroff -man gawk.1 > gawk-ps-$(REL)/gawk.1.ps tar -cf - gawk-ps-$(REL) | gzip > gawk-ps-$(REL).tar.z ! release: gawk-src-$(REL).tar.z gawk-doc-$(REL).tar.z gawk-ps-$(REL).tar.z \ gawk-test-$(REL).tar.z test: gawk --- 268,274 ---- pstroff -man gawk.1 > gawk-ps-$(REL)/gawk.1.ps tar -cf - gawk-ps-$(REL) | gzip > gawk-ps-$(REL).tar.z ! release: gawk-src-$(REL).tar.z gawk-doc-$(REL).tar.z gawk-ps-$(REL).tar.z \ gawk-test-$(REL).tar.z test: gawk diff -cr gawk-2.15/README.ibmrt-aos gawk-2.15.1/README.ibmrt-aos *** gawk-2.15/README.ibmrt-aos Tue May 18 12:46:14 1993 --- gawk-2.15.1/README.ibmrt-aos Tue May 18 12:45:06 1993 *************** *** 0 **** --- 1,20 ---- + From: karl@cs.umb.edu (Karl Berry) + Newsgroups: gnu.utils.bug + Subject: gawk 2.15/ibm rt/compile errors + Date: 17 May 1993 23:16:11 -0400 + Organization: GNUs Not Usenet + + gawk 2.15 on an IBM RT running AOS, configured as bsd43, needs the + following additional definitions (although I suppose this will be + irrelevant when you switch to Autoconf). + + -DTZSET_MISSING -DFMOD_MISSING -DCHAR_UNSIGNED + + [ Fixed in 2.15.1 -- configure as ibmrt-aos ] + + Also, missing/strftime.c did not compile, because it does not handle the + case where the system provides neither tzname nor the tm_zone member, + but instead has the timezone function. I used the strftime.c from the + find 3.8 distribution. + + [ Not fixed in 2.15.1 ] diff -cr gawk-2.15/awk.y gawk-2.15.1/awk.y *** gawk-2.15/awk.y Wed May 12 09:52:14 1993 --- gawk-2.15.1/awk.y Wed May 12 22:16:23 1993 *************** *** 28,36 **** #define YYDEBUG 12 #endif - #define YYMAXDEPTH 300 - #define YYSSIZE YYMAXDEPTH - #include "awk.h" static void yyerror (); /* va_alist */ --- 28,33 ---- diff -cr gawk-2.15/builtin.c gawk-2.15.1/builtin.c *** gawk-2.15/builtin.c Fri May 7 13:50:33 1993 --- gawk-2.15.1/builtin.c Tue May 18 09:59:40 1993 *************** *** 76,88 **** if (fwrite(ptr, size, count, fp) != count) goto wrerror; if (flush ! && ((fp == stdout && output_is_tty) ! || (rp && (rp->flag & RED_NOBUF)))) { fflush(fp); if (ferror(fp)) goto wrerror; } return; wrerror: fatal("%s to \"%s\" failed (%s)", from, rp ? rp->value : "standard output", --- 76,89 ---- if (fwrite(ptr, size, count, fp) != count) goto wrerror; if (flush ! && ((fp == stdout && output_is_tty) ! || (rp && (rp->flag & RED_NOBUF)))) { fflush(fp); if (ferror(fp)) goto wrerror; } return; + wrerror: fatal("%s to \"%s\" failed (%s)", from, rp ? rp->value : "standard output", diff -cr gawk-2.15/config/bsd44 gawk-2.15.1/config/bsd44 *** gawk-2.15/config/bsd44 Thu Jul 9 23:23:30 1992 --- gawk-2.15.1/config/bsd44 Mon May 17 09:36:20 1993 *************** *** 1,5 **** For generic 4.4 alpha - STRTOD_MISSING 1 HAVE_UNDERSCORE_SETJMP 1 STDC_HEADERS 1 ALLOCA_PROTO 1 --- 1,4 ---- diff -cr gawk-2.15/config/hpux8x gawk-2.15.1/config/hpux8x *** gawk-2.15/config/hpux8x Sun May 2 00:30:10 1993 --- gawk-2.15.1/config/hpux8x Wed May 12 22:14:31 1993 *************** *** 1,3 **** --- 1,4 ---- HPPA running HP-UX 8.x STDC_HEADERS 1 RANDOM_MISSING 1 + MAKE_ALLOCA_PW diff -cr gawk-2.15/config/ibmrt-aos gawk-2.15.1/config/ibmrt-aos *** gawk-2.15/config/ibmrt-aos Tue May 18 12:46:35 1993 --- gawk-2.15.1/config/ibmrt-aos Tue May 18 12:43:39 1993 *************** *** 0 **** --- 1,19 ---- + For generic 4.3 BSD machine. + SIGTYPE int + HAVE_UNDERSCORE_SETJMP 1 + MEMCMP_MISSING 1 + MEMCPY_MISSING 1 + MEMSET_MISSING 1 + STRCASE_MISSING 1 + STRCHR_MISSING 1 + STRERROR_MISSING 1 + STRFTIME_MISSING 1 + STRTOD_MISSING 1 + STRTOL_MISSING 1 + NON_STD_SPRINTF 1 + VPRINTF_MISSING 1 + BSDSTDIO 1 + TZNAME_MISSING 1 + TZSET_MISSING 1 + FMOD_MISSING 1 + CHAR_UNSIGNED 1 diff -cr gawk-2.15/config/sysv3 gawk-2.15.1/config/sysv3 *** gawk-2.15/config/sysv3 Fri Apr 26 21:50:15 1991 --- gawk-2.15.1/config/sysv3 Wed May 12 22:14:31 1993 *************** *** 4,6 **** --- 4,7 ---- STRCASE_MISSING 1 STRERROR_MISSING 1 STRFTIME_MISSING 1 + MAKE_ALLOCA_C diff -cr gawk-2.15/config/sysv4 gawk-2.15.1/config/sysv4 *** gawk-2.15/config/sysv4 Thu May 9 22:10:07 1991 --- gawk-2.15.1/config/sysv4 Wed May 12 22:14:31 1993 *************** *** 2,4 **** --- 2,5 ---- RANDOM_MISSING 1 STRCASE_MISSING 1 STDC_HEADERS 1 + MAKE_ALLOCA_C diff -cr gawk-2.15/config/ultrix41 gawk-2.15.1/config/ultrix41 *** gawk-2.15/config/ultrix41 Tue Jul 2 10:06:20 1991 --- gawk-2.15.1/config/ultrix41 Wed May 12 22:14:31 1993 *************** *** 1,3 **** --- 1,4 ---- DECstation running Ultrix 4.1 (and 4.2??) STDC_HEADERS 1 #define Ultrix41 1 + MAKE_ALLOCA_C diff -cr gawk-2.15/configure gawk-2.15.1/configure *** gawk-2.15/configure Mon Jul 6 12:05:07 1992 --- gawk-2.15.1/configure Mon May 17 09:42:07 1993 *************** *** 16,21 **** --- 16,25 ---- # echo #echo lines to stdout sed -n '/^#echo /s///p' config/$1 + case "$1" in + bsd44) ln -s Makefile.bsd44 Makefile ; exit 0 ;; + esac + sed -n '/^MAKE_.*/s//s,^##&## ,,/p' config/$1 >sedscr if [ -s sedscr ] then diff -cr gawk-2.15/getopt.h gawk-2.15.1/getopt.h *** gawk-2.15/getopt.h Tue Sep 22 22:53:29 1992 --- gawk-2.15.1/getopt.h Tue May 11 12:01:05 1993 *************** *** 94,100 **** --- 94,107 ---- }; #if __STDC__ + #if defined(__GNU_LIBRARY__) + /* Many other libraries have conflicting prototypes for getopt, with + differences in the consts, in stdlib.h. To avoid compilation + errors, only prototype getopt for the GNU C library. */ extern int getopt (int argc, char *const *argv, const char *shortopts); + #else /* not __GNU_LIBRARY__ */ + extern int getopt (); + #endif /* not __GNU_LIBRARY__ */ extern int getopt_long (int argc, char *const *argv, const char *shortopts, const struct option *longopts, int *longind); extern int getopt_long_only (int argc, char *const *argv, diff -cr gawk-2.15/io.c gawk-2.15.1/io.c *** gawk-2.15/io.c Wed May 5 20:42:56 1993 --- gawk-2.15.1/io.c Tue May 18 13:17:50 1993 *************** *** 58,63 **** --- 58,64 ---- static int do_pathopen P((char *file)); extern FILE *fdopen(); + extern FILE *popen(); static struct redirect *red_head = NULL; *************** *** 466,471 **** --- 467,474 ---- if (rp == NULL) return 0; + if (rp->fp == stdout || rp->fp == stderr) + return 0; errno = 0; if ((rp->flag & (RED_PIPE|RED_WRITE)) == (RED_PIPE|RED_WRITE)) status = pclose(rp->fp); *************** *** 516,522 **** warning("error writing standard output (%s).", strerror(errno)); status++; } - errno = 0; if (fflush(stderr)) { warning("error writing standard error (%s).", strerror(errno)); status++; --- 519,524 ---- *************** *** 524,530 **** for (rp = red_head; rp != NULL; rp = rp->next) /* flush both files and pipes, what the heck */ if ((rp->flag & RED_WRITE) && rp->fp != NULL) { - errno = 0; if (fflush(rp->fp)) { warning("%s flush of \"%s\" failed (%s).", (rp->flag & RED_PIPE) ? "pipe" : --- 526,531 ---- *************** *** 542,547 **** --- 543,557 ---- register struct redirect *next; int status = 0; + errno = 0; + if (fclose(stdout)) { + warning("error writing standard output (%s).", strerror(errno)); + status++; + } + if (fclose(stderr)) { + warning("error writing standard error (%s).", strerror(errno)); + status++; + } for (rp = red_head; rp != NULL; rp = next) { next = rp->next; if (close_redir(rp)) *************** *** 695,701 **** int i; if (name[6] == 'g') ! #if defined(__svr4__) || defined(i860) sprintf(tbuf, "%d\n", getpgrp()); #else sprintf(tbuf, "%d\n", getpgrp(getpid())); --- 705,712 ---- int i; if (name[6] == 'g') ! /* following #if will improve in 2.16 */ ! #if defined(__svr4__) || defined(i860) || defined(_AIX) || defined(BSD4_4) sprintf(tbuf, "%d\n", getpgrp()); #else sprintf(tbuf, "%d\n", getpgrp(getpid())); diff -cr gawk-2.15/patchlevel.h gawk-2.15.1/patchlevel.h *** gawk-2.15/patchlevel.h Wed Nov 4 16:57:18 1992 --- gawk-2.15.1/patchlevel.h Tue May 11 12:00:00 1993 *************** *** 1 **** ! #define PATCHLEVEL 0 --- 1 ---- ! #define PATCHLEVEL 1 diff -cr gawk-2.15/awktab.c gawk-2.15.1/awktab.c *** gawk-2.15/awktab.c Tue May 18 13:31:46 1993 --- gawk-2.15.1/awktab.c Mon May 17 12:46:23 1993 *************** *** 47,55 **** #define YYDEBUG 12 #endif - #define YYMAXDEPTH 300 - #define YYSSIZE YYMAXDEPTH - #include "awk.h" static void yyerror (); /* va_alist */ --- 47,52 ----