You are viewing a plain text version of this content. The canonical link for it is here.
Posted to win32-msi-cvs@httpd.apache.org by wr...@apache.org on 2007/12/26 21:15:42 UTC

svn commit: r606942 [1/5] - in /httpd/httpd/win32-msi/trunk/awk: FIXES README awk.h awkgram.y b.c buildwin.bat lex.c lib.c main.c makefile makefile.win maketab.c parse.c proctab.c proto.h run.c tran.c vcvars32.bat ytab.c ytab.h ytabc.bak ytabh.bak

Author: wrowe
Date: Wed Dec 26 12:15:40 2007
New Revision: 606942

URL: http://svn.apache.org/viewvc?rev=606942&view=rev
Log:
Import 2007-10-23 distribution from http://www.cs.princeton.edu/~bwk/btl.mirror/index.html

Added:
    httpd/httpd/win32-msi/trunk/awk/buildwin.bat   (with props)
    httpd/httpd/win32-msi/trunk/awk/makefile.win   (with props)
    httpd/httpd/win32-msi/trunk/awk/proctab.c
    httpd/httpd/win32-msi/trunk/awk/vcvars32.bat   (with props)
    httpd/httpd/win32-msi/trunk/awk/ytabc.bak   (with props)
    httpd/httpd/win32-msi/trunk/awk/ytabh.bak   (with props)
Modified:
    httpd/httpd/win32-msi/trunk/awk/FIXES
    httpd/httpd/win32-msi/trunk/awk/README
    httpd/httpd/win32-msi/trunk/awk/awk.h
    httpd/httpd/win32-msi/trunk/awk/awkgram.y
    httpd/httpd/win32-msi/trunk/awk/b.c
    httpd/httpd/win32-msi/trunk/awk/lex.c
    httpd/httpd/win32-msi/trunk/awk/lib.c
    httpd/httpd/win32-msi/trunk/awk/main.c
    httpd/httpd/win32-msi/trunk/awk/makefile
    httpd/httpd/win32-msi/trunk/awk/maketab.c
    httpd/httpd/win32-msi/trunk/awk/parse.c
    httpd/httpd/win32-msi/trunk/awk/proto.h
    httpd/httpd/win32-msi/trunk/awk/run.c
    httpd/httpd/win32-msi/trunk/awk/tran.c
    httpd/httpd/win32-msi/trunk/awk/ytab.c
    httpd/httpd/win32-msi/trunk/awk/ytab.h

Modified: httpd/httpd/win32-msi/trunk/awk/FIXES
URL: http://svn.apache.org/viewvc/httpd/httpd/win32-msi/trunk/awk/FIXES?rev=606942&r1=606941&r2=606942&view=diff
==============================================================================
--- httpd/httpd/win32-msi/trunk/awk/FIXES (original)
+++ httpd/httpd/win32-msi/trunk/awk/FIXES Wed Dec 26 12:15:40 2007
@@ -25,6 +25,243 @@
 This file lists all bug fixes, changes, etc., made since the AWK book
 was sent to the printers in August, 1987.
 
+Oct 23, 2007:
+	minor fix in lib.c: increase inputFS to 100, change malloc
+	for fields to n+1.  
+
+	fixed memory fault caused by out of order test in setsval.
+
+	thanks to david o'brien, freebsd, for both fixes.
+
+May 1, 2007:
+	fiddle in makefile to fix for BSD make; thanks to igor sobrado.
+
+Mar 31, 2007:
+	fixed some null pointer refs calling adjbuf.
+
+Feb 21, 2007:
+	fixed a bug in matching the null RE in sub and gsub.  thanks to al aho
+	who actually did the fix (in b.c), and to wolfgang seeberg for finding
+	it and providing a very compact test case.
+
+	fixed quotation in b.c; thanks to Hal Pratt and the Princeton Dante
+	Project.
+
+	removed some no-effect asserts in run.c.
+
+	fiddled maketab.c to not complain about bison-generated values.
+
+	removed the obsolete -V argument; fixed --version to print the
+	version and exit.
+
+	fixed wording and an outright error in the usage message; thanks to igor
+	sobrado and jason mcintyre.
+
+	fixed a bug in -d that caused core dump if no program followed.
+
+Jan 1, 2007:
+	dropped mac.code from makefile; there are few non-MacOSX
+	mac's these days.
+
+Jan 17, 2006:
+	system() not flagged as unsafe in the unadvertised -safe option.
+	found it while enhancing tests before shipping the ;login: article.
+	practice what you preach.
+
+	removed the 9-years-obsolete -mr and -mf flags.
+
+	added -version and --version options.
+
+	core dump on linux with BEGIN {nextfile}, now fixed.
+
+	removed some #ifdef's in run.c and lex.c that appear to no 
+	longer be necessary.
+
+Apr 24, 2005:
+	modified lib.c so that values of $0 et al are preserved in the END
+	block, apparently as required by posix.  thanks to havard eidnes
+	for the report and code.
+
+Jan 14, 2005:
+	fixed infinite loop in parsing, originally found by brian tsang.
+	thanks to arnold robbins for a suggestion that started me
+	rethinking it.
+
+Dec 31, 2004:
+	prevent overflow of -f array in main, head off potential error in 
+	call of SYNTAX(), test malloc return in lib.c, all with thanks to 
+	todd miller.
+
+Dec 22, 2004:
+	cranked up size of NCHARS; coverity thinks it can be overrun with
+	smaller size, and i think that's right.  added some assertions to b.c
+	to catch places where it might overrun.  the RE code is still fragile.
+
+Dec 5, 2004:
+	fixed a couple of overflow problems with ridiculous field numbers:
+	e.g., print $(2^32-1).  thanks to ruslan ermilov, giorgos keramidas
+	and david o'brien at freebsd.org for patches.  this really should
+	be re-done from scratch.
+
+Nov 21, 2004:
+	fixed another 25-year-old RE bug, in split.  it's another failure
+	to (re-)initialize.  thanks to steve fisher for spotting this and
+	providing a good test case.
+
+Nov 22, 2003:
+	fixed a bug in regular expressions that dates (so help me) from 1977;
+	it's been there from the beginning.  an anchored longest match that
+	was longer than the number of states triggered a failure to initialize
+	the machine properly.  many thanks to moinak ghosh for not only finding
+	this one but for providing a fix, in some of the most mysterious
+	code known to man.
+
+	fixed a storage leak in call() that appears to have been there since
+	1983 or so -- a function without an explicit return that assigns a 
+	string to a parameter leaked a Cell.  thanks to moinak ghosh for 
+	spotting this very subtle one.
+
+Jul 31, 2003:
+	fixed, thanks to andrey chernov and ruslan ermilov, a bug in lex.c
+	that mis-handled the character 255 in input.  (it was being compared
+	to EOF with a signed comparison.)
+
+Jul 29, 2003:
+	fixed (i think) the long-standing botch that included the beginning of
+	line state ^ for RE's in the set of valid characters; this led to a
+	variety of odd problems, including failure to properly match certain
+	regular expressions in non-US locales.  thanks to ruslan for keeping
+	at this one.
+
+Jul 28, 2003:
+	n-th try at getting internationalization right, with thanks to volker
+	kiefel, arnold robbins and ruslan ermilov for advice, though they
+	should not be blamed for the outcome.  according to posix, "."  is the
+	radix character in programs and command line arguments regardless of
+	the locale; otherwise, the locale should prevail for input and output
+	of numbers.  so it's intended to work that way.
+	
+	i have rescinded the attempt to use strcoll in expanding shorthands in
+	regular expressions (cclenter).  its properties are much too
+	surprising; for example [a-c] matches aAbBc in locale en_US but abBcC
+	in locale fr_CA.  i can see how this might arise by implementation
+	but i cannot explain it to a human user.  (this behavior can be seen
+	in gawk as well; we're leaning on the same library.)
+
+	the issue appears to be that strcoll is meant for sorting, where
+	merging upper and lower case may make sense (though note that unix
+	sort does not do this by default either).  it is not appropriate
+	for regular expressions, where the goal is to match specific
+	patterns of characters.  in any case, the notations [:lower:], etc.,
+	are available in awk, and they are more likely to work correctly in
+	most locales.
+
+	a moratorium is hereby declared on internationalization changes.
+	i apologize to friends and colleagues in other parts of the world.
+	i would truly like to get this "right", but i don't know what
+	that is, and i do not want to keep making changes until it's clear.
+
+Jul 4, 2003:
+	fixed bug that permitted non-terminated RE, as in "awk /x".
+
+Jun 1, 2003:
+	subtle change to split: if source is empty, number of elems
+	is always 0 and the array is not set.
+
+Mar 21, 2003:
+	added some parens to isblank, in another attempt to make things
+	internationally portable.
+
+Mar 14, 2003:
+	the internationalization changes, somewhat modified, are now
+	reinstated.  in theory awk will now do character comparisons
+	and case conversions in national language, but "." will always
+	be the decimal point separator on input and output regardless
+	of national language.  isblank(){} has an #ifndef.
+
+	this no longer compiles on windows: LC_MESSAGES isn't defined
+	in vc6++.
+
+	fixed subtle behavior in field and record splitting: if FS is
+	a single character and RS is not empty, \n is NOT a separator.
+	this tortuous reading is found in the awk book; behavior now
+	matches gawk and mawk.
+
+Dec 13, 2002:
+	for the moment, the internationalization changes of nov 29 are
+	rolled back -- programs like x = 1.2 don't work in some locales,
+	because the parser is expecting x = 1,2.  until i understand this
+	better, this will have to wait.
+
+Nov 29, 2002:
+	modified b.c (with tiny changes in main and run) to support
+	locales, using strcoll and iswhatever tests for posix character
+	classes.  thanks to ruslan ermilov (ru@freebsd.org) for code.
+	the function isblank doesn't seem to have propagated to any
+	header file near me, so it's there explicitly.  not properly
+	tested on non-ascii character sets by me.
+
+Jun 28, 2002:
+	modified run/format() and tran/getsval() to do a slightly better
+	job on using OFMT for output from print and CONVFMT for other
+	number->string conversions, as promised by posix and done by 
+	gawk and mawk.  there are still places where it doesn't work
+	right if CONVFMT is changed; by then the STR attribute of the
+	variable has been irrevocably set.  thanks to arnold robbins for
+	code and examples.
+
+	fixed subtle bug in format that could get core dump.  thanks to
+	Jaromir Dolecek <jd...@NetBSD.org> for finding and fixing.
+	minor cleanup in run.c / format() at the same time.
+
+	added some tests for null pointers to debugging printf's, which
+	were never intended for external consumption.  thanks to dave
+	kerns (dkerns@lucent.com) for pointing this out.
+
+	GNU compatibility: an empty regexp matches anything (thanks to
+	dag-erling smorgrav, des@ofug.org).  subject to reversion if
+	this does more harm than good.
+
+	pervasive small changes to make things more const-correct, as
+	reported by gcc's -Wwrite-strings.  as it says in the gcc manual,
+	this may be more nuisance than useful.  provoked by a suggestion
+	and code from arnaud desitter, arnaud@nimbus.geog.ox.ac.uk
+
+	minor documentation changes to note that this now compiles out
+	of the box on Mac OS X.
+
+Feb 10, 2002:
+	changed types in posix chars structure to quiet solaris cc.
+
+Jan 1, 2002:
+	fflush() or fflush("") flushes all files and pipes.
+
+	length(arrayname) returns number of elements; thanks to 
+	arnold robbins for suggestion.
+
+	added a makefile.win to make it easier to build on windows.
+	based on dan allen's buildwin.bat.
+
+Nov 16, 2001:
+	added support for posix character class names like [:digit:],
+	which are not exactly shorter than [0-9] and perhaps no more
+	portable.  thanks to dag-erling smorgrav for code.
+
+Feb 16, 2001:
+	removed -m option; no longer needed, and it was actually
+	broken (noted thanks to volker kiefel).
+
+Feb 10, 2001:
+	fixed an appalling bug in gettok: any sequence of digits, +,-, E, e,
+	and period was accepted as a valid number if it started with a period.
+	this would never have happened with the lex version.
+
+	other 1-character botches, now fixed, include a bare $ and a
+	bare " at the end of the input.
+
+Feb 7, 2001:
+	more (const char *) casts in b.c and tran.c to silence warnings.
+
 Nov 15, 2000:
 	fixed a bug introduced in august 1997 that caused expressions
 	like $f[1] to be syntax errors.  thanks to arnold robbins for
@@ -68,7 +305,7 @@
 	jon bentley for the test case that found it.
 
 	added test in envinit to catch environment "variables" with
-	names begining with '='; thanks to Berend Hasselman.
+	names beginning with '='; thanks to Berend Hasselman.
 
 Jul 28, 1999:
 	added test in defn() to catch function foo(foo), which
@@ -305,7 +542,7 @@
 	some awful behaviors.)
 
 Apr 29, 1996:
-	replaced uchar by uschar everwhere; apparently some compilers
+	replaced uchar by uschar everywhere; apparently some compilers
 	usurp this name and this causes conflicts.
 
 	fixed call to time in run.c (bltin); arg is time_t *.

Modified: httpd/httpd/win32-msi/trunk/awk/README
URL: http://svn.apache.org/viewvc/httpd/httpd/win32-msi/trunk/awk/README?rev=606942&r1=606941&r2=606942&view=diff
==============================================================================
--- httpd/httpd/win32-msi/trunk/awk/README (original)
+++ httpd/httpd/win32-msi/trunk/awk/README Wed Dec 26 12:15:40 2007
@@ -40,23 +40,23 @@
 conflicts: 43 shift/reduce, 85 reduce/reduce
 	mv y.tab.c ytab.c
 	mv y.tab.h ytab.h
-	cc -O -c ytab.c
-	cc -O -c b.c
-	cc -O -c main.c
-	cc -O -c parse.c
-	cc -O maketab.c -o maketab
+	cc -c ytab.c
+	cc -c b.c
+	cc -c main.c
+	cc -c parse.c
+	cc maketab.c -o maketab
 	./maketab >proctab.c
-	cc -O -c proctab.c
-	cc -O -c tran.c
-	cc -O -c lib.c
-	cc -O -c run.c
-	cc -O -c lex.c
-	cc -O ytab.o b.o main.o parse.o proctab.o tran.o lib.o run.o lex.o -lm
+	cc -c proctab.c
+	cc -c tran.c
+	cc -c lib.c
+	cc -c run.c
+	cc -c lex.c
+	cc ytab.o b.o main.o parse.o proctab.o tran.o lib.o run.o lex.o -lm
 
 This produces an executable a.out; you will eventually want to
 move this to some place like /usr/bin/awk.
 
-If your system is does not have yacc or bison (the GNU
+If your system does not have yacc or bison (the GNU
 equivalent), you must compile the pieces manually.  We have
 included yacc output in ytab.c and ytab.h, and backup copies in
 case you overwrite them.  We have also included a copy of
@@ -68,16 +68,27 @@
 may raise some new complaint; reports of difficulties are
 welcome.
 
-This also compiles with Visual C++ on Windows 95 and Windows NT,
+This also compiles with Visual C++ on all flavors of Windows,
 *if* you provide versions of popen and pclose.  The file
 missing95.c contains versions that can be used to get started
 with, though the underlying support has mysterious properties,
-the symptom of which can be truncated pipe output.  Beware.
+the symptom of which can be truncated pipe output.  Beware.  The
+file makefile.win gives hints on how to proceed; if you run
+vcvars32.bat, it will set up necessary paths and parameters so
+you can subsequently run nmake -f makefile.win.  Beware also that
+when running on Windows under command.com, various quoting
+conventions are different from Unix systems: single quotes won't
+work around arguments, and various characters like % are
+interpreted within double quotes.
 
-This is also said to compile on Macintosh systems, using the
+This compiles without change on Macintosh OS X using gcc and
+the standard developer tools.
+
+This is also said to compile on Macintosh OS 9 systems, using the
 file "buildmac" provided by Dan Allen (danallen@microsoft.com),
-to whom many thanks.  Dan also provided buildwin.bat, a simple
-script for compiling on NT if you prefer.
+to whom many thanks.
 
 The version of malloc that comes with some systems is sometimes
 astonishly slow.  If awk seems slow, you might try fixing that.
+More generally, turning on optimization can significantly improve
+awk's speed, perhaps by 1/3 for highest levels.

Modified: httpd/httpd/win32-msi/trunk/awk/awk.h
URL: http://svn.apache.org/viewvc/httpd/httpd/win32-msi/trunk/awk/awk.h?rev=606942&r1=606941&r2=606942&view=diff
==============================================================================
--- httpd/httpd/win32-msi/trunk/awk/awk.h (original)
+++ httpd/httpd/win32-msi/trunk/awk/awk.h Wed Dec 26 12:15:40 2007
@@ -22,14 +22,18 @@
 THIS SOFTWARE.
 ****************************************************************/
 
+#include <assert.h>
+
 typedef double	Awkfloat;
 
 /* unsigned char is more trouble than it's worth */
 
 typedef	unsigned char uschar;
 
-#define	xfree(a)	{ if ((a) != NULL) { free((char *) a); a = NULL; } }
+#define	xfree(a)	{ if ((a) != NULL) { free((void *) (a)); (a) = NULL; } }
 
+#define	NN(p)	((p) ? (p) : "(null)")	/* guaranteed non-null for dprintf 
+*/
 #define	DEBUG
 #ifdef	DEBUG
 			/* uses have to be doubly parenthesized */
@@ -38,8 +42,6 @@
 #	define	dprintf(x)
 #endif
 
-extern	char	errbuf[];
-
 extern int	compile_time;	/* 1 if compiling, 0 if running */
 extern int	safe;		/* 0 => unsafe, 1 => safe */
 
@@ -199,7 +201,7 @@
 
 /* structures used by regular expression matching machinery, mostly b.c: */
 
-#define NCHARS	(256+1)		/* 256 handles 8-bit chars; 128 does 7-bit */
+#define NCHARS	(256+3)		/* 256 handles 8-bit chars; 128 does 7-bit */
 				/* watch out in match(), etc. */
 #define NSTATES	32
 

Modified: httpd/httpd/win32-msi/trunk/awk/awkgram.y
URL: http://svn.apache.org/viewvc/httpd/httpd/win32-msi/trunk/awk/awkgram.y?rev=606942&r1=606941&r2=606942&view=diff
==============================================================================
--- httpd/httpd/win32-msi/trunk/awk/awkgram.y (original)
+++ httpd/httpd/win32-msi/trunk/awk/awkgram.y Wed Dec 26 12:15:40 2007
@@ -50,7 +50,7 @@
 %token	<i>	NL ',' '{' '(' '|' ';' '/' ')' '}' '[' ']'
 %token	<i>	ARRAY
 %token	<i>	MATCH NOTMATCH MATCHOP
-%token	<i>	FINAL DOT ALL CCL NCCL CHAR OR STAR QUEST PLUS
+%token	<i>	FINAL DOT ALL CCL NCCL CHAR OR STAR QUEST PLUS EMPTYRE
 %token	<i>	AND BOR APPEND EQ GE GT LE LT NE IN
 %token	<i>	ARG BLTIN BREAK CLOSE CONTINUE DELETE DO EXIT FOR FUNC 
 %token	<i>	SUB GSUB IF INDEX LSUBSTR MATCHFCN NEXT NEXTFILE

Modified: httpd/httpd/win32-msi/trunk/awk/b.c
URL: http://svn.apache.org/viewvc/httpd/httpd/win32-msi/trunk/awk/b.c?rev=606942&r1=606941&r2=606942&view=diff
==============================================================================
--- httpd/httpd/win32-msi/trunk/awk/b.c (original)
+++ httpd/httpd/win32-msi/trunk/awk/b.c Wed Dec 26 12:15:40 2007
@@ -22,7 +22,7 @@
 THIS SOFTWARE.
 ****************************************************************/
 
-/* lasciate ogne speranza, voi ch'entrate. */
+/* lasciate ogne speranza, voi ch'intrate. */
 
 #define	DEBUG
 
@@ -33,7 +33,7 @@
 #include "awk.h"
 #include "ytab.h"
 
-#define	HAT	(NCHARS-2)	/* matches ^ in regular expr */
+#define	HAT	(NCHARS+2)	/* matches ^ in regular expr */
 				/* NCHARS is 2**n */
 #define MAXLIN 22
 
@@ -44,10 +44,11 @@
 #define parent(v)	(v)->nnext
 
 #define LEAF	case CCL: case NCCL: case CHAR: case DOT: case FINAL: case ALL:
+#define ELEAF	case EMPTYRE:		/* empty string in regexp */
 #define UNARY	case STAR: case PLUS: case QUEST:
 
 /* encoding in tree Nodes:
-	leaf (CCL, NCCL, CHAR, DOT, FINAL, ALL):
+	leaf (CCL, NCCL, CHAR, DOT, FINAL, ALL, EMPTYRE):
 		left is index, right contains value or pointer to value
 	unary (STAR, PLUS, QUEST): left is child, right is null
 	binary (CAT, OR): left and right are children
@@ -75,7 +76,7 @@
 fa	*fatab[NFA];
 int	nfatab	= 0;	/* entries in fatab */
 
-fa *makedfa(char *s, int anchor)	/* returns dfa for reg expr s */
+fa *makedfa(const char *s, int anchor)	/* returns dfa for reg expr s */
 {
 	int i, use, nuse;
 	fa *pfa;
@@ -93,7 +94,7 @@
 		return mkdfa(s, anchor);
 	for (i = 0; i < nfatab; i++)	/* is it there already? */
 		if (fatab[i]->anchor == anchor
-		  && strcmp(fatab[i]->restr, s) == 0) {
+		  && strcmp((const char *) fatab[i]->restr, s) == 0) {
 			fatab[i]->use = now++;
 			return fatab[i];
 		}
@@ -117,7 +118,7 @@
 	return pfa;
 }
 
-fa *mkdfa(char *s, int anchor)	/* does the real work of making a dfa */
+fa *mkdfa(const char *s, int anchor)	/* does the real work of making a dfa */
 				/* anchor = 1 for anchored matches, else 0 */
 {
 	Node *p, *p1;
@@ -182,6 +183,7 @@
 void penter(Node *p)	/* set up parent pointers and leaf indices */
 {
 	switch (type(p)) {
+	ELEAF
 	LEAF
 		info(p) = poscnt;
 		poscnt++;
@@ -206,6 +208,7 @@
 void freetr(Node *p)	/* free parse tree */
 {
 	switch (type(p)) {
+	ELEAF
 	LEAF
 		xfree(p);
 		break;
@@ -282,7 +285,7 @@
 	return c;
 }
 
-char *cclenter(char *argp)	/* add a character class */
+char *cclenter(const char *argp)	/* add a character class */
 {
 	int i, c, c2;
 	uschar *p = (uschar *) argp;
@@ -309,7 +312,7 @@
 					continue;
 				}
 				while (c < c2) {
-					if (!adjbuf((char **) &buf, &bufsz, bp-buf+2, 100, (char **) &bp, 0))
+					if (!adjbuf((char **) &buf, &bufsz, bp-buf+2, 100, (char **) &bp, "cclenter1"))
 						FATAL("out of space for character class [%.10s...] 2", p);
 					*bp++ = ++c;
 					i++;
@@ -317,7 +320,7 @@
 				continue;
 			}
 		}
-		if (!adjbuf((char **) &buf, &bufsz, bp-buf+2, 100, (char **) &bp, 0))
+		if (!adjbuf((char **) &buf, &bufsz, bp-buf+2, 100, (char **) &bp, "cclenter2"))
 			FATAL("out of space for character class [%.10s...] 3", p);
 		*bp++ = c;
 		i++;
@@ -328,7 +331,7 @@
 	return (char *) tostring((char *) buf);
 }
 
-void overflo(char *s)
+void overflo(const char *s)
 {
 	FATAL("regular expression too big: %.30s...", s);
 }
@@ -339,6 +342,7 @@
 	int *p;
 
 	switch (type(v)) {
+	ELEAF
 	LEAF
 		f->re[info(v)].ltype = type(v);
 		f->re[info(v)].lval.np = right(v);
@@ -375,11 +379,12 @@
 }
 
 int first(Node *p)	/* collects initially active leaves of p into setvec */
-			/* returns 1 if p matches empty string */
+			/* returns 0 if p matches empty string */
 {
 	int b, lp;
 
 	switch (type(p)) {
+	ELEAF
 	LEAF
 		lp = info(p);	/* look for high-water mark of subscripts */
 		while (setcnt >= maxsetvec || lp >= maxsetvec) {	/* guessing here! */
@@ -389,6 +394,10 @@
 			if (setvec == 0 || tmpset == 0)
 				overflo("out of space in first()");
 		}
+		if (type(p) == EMPTYRE) {
+			setvec[lp] = 0;
+			return(0);
+		}
 		if (setvec[lp] != 1) {
 			setvec[lp] = 1;
 			setcnt++;
@@ -446,7 +455,7 @@
 	}
 }
 
-int member(int c, char *sarg)	/* is c in s? */
+int member(int c, const char *sarg)	/* is c in s? */
 {
 	uschar *s = (uschar *) sarg;
 
@@ -456,7 +465,7 @@
 	return(0);
 }
 
-int match(fa *f, char *p0)	/* shortest match ? */
+int match(fa *f, const char *p0)	/* shortest match ? */
 {
 	int s, ns;
 	uschar *p = (uschar *) p0;
@@ -465,6 +474,7 @@
 	if (f->out[s])
 		return(1);
 	do {
+		/* assert(*p < NCHARS); */
 		if ((ns = f->gototab[s][*p]) != 0)
 			s = ns;
 		else
@@ -475,14 +485,19 @@
 	return(0);
 }
 
-int pmatch(fa *f, char *p0)	/* longest match, for sub */
+int pmatch(fa *f, const char *p0)	/* longest match, for sub */
 {
 	int s, ns;
 	uschar *p = (uschar *) p0;
 	uschar *q;
 	int i, k;
 
-	s = f->reset ? makeinit(f,1) : f->initstat;
+	/* s = f->reset ? makeinit(f,1) : f->initstat; */
+	if (f->reset) {
+		f->initstat = s = makeinit(f,1);
+	} else {
+		s = f->initstat;
+	}
 	patbeg = (char *) p;
 	patlen = -1;
 	do {
@@ -490,6 +505,7 @@
 		do {
 			if (f->out[s])		/* final state */
 				patlen = q-p;
+			/* assert(*q < NCHARS); */
 			if ((ns = f->gototab[s][*q]) != 0)
 				s = ns;
 			else
@@ -528,20 +544,26 @@
 	return (0);
 }
 
-int nematch(fa *f, char *p0)	/* non-empty match, for sub */
+int nematch(fa *f, const char *p0)	/* non-empty match, for sub */
 {
 	int s, ns;
 	uschar *p = (uschar *) p0;
 	uschar *q;
 	int i, k;
 
-	s = f->reset ? makeinit(f,1) : f->initstat;
+	/* s = f->reset ? makeinit(f,1) : f->initstat; */
+	if (f->reset) {
+		f->initstat = s = makeinit(f,1);
+	} else {
+		s = f->initstat;
+	}
 	patlen = -1;
 	while (*p) {
 		q = p;
 		do {
 			if (f->out[s])		/* final state */
 				patlen = q-p;
+			/* assert(*q < NCHARS); */
 			if ((ns = f->gototab[s][*q]) != 0)
 				s = ns;
 			else
@@ -580,15 +602,18 @@
 	return (0);
 }
 
-Node *reparse(char *p)	/* parses regular expression pointed to by p */
+Node *reparse(const char *p)	/* parses regular expression pointed to by p */
 {			/* uses relex() to scan regular expression */
 	Node *np;
 
 	dprintf( ("reparse <%s>\n", p) );
 	lastre = prestr = (uschar *) p;	/* prestr points to string to be parsed */
 	rtok = relex();
-	if (rtok == '\0')
-		FATAL("empty regular expression");
+	/* GNU compatibility: an empty regexp matches anything */
+	if (rtok == '\0') {
+		/* FATAL("empty regular expression"); previous */
+		return(op2(EMPTYRE, NIL, NIL));
+	}
 	np = regexp();
 	if (rtok != '\0')
 		FATAL("syntax error in regular expression %s at %s", lastre, prestr);
@@ -612,6 +637,9 @@
 	case ALL:
 		rtok = relex();
 		return (unary(op2(ALL, NIL, NIL)));
+	case EMPTYRE:
+		rtok = relex();
+		return (unary(op2(ALL, NIL, NIL)));
 	case DOT:
 		rtok = relex();
 		return (unary(op2(DOT, NIL, NIL)));
@@ -651,7 +679,7 @@
 Node *concat(Node *np)
 {
 	switch (rtok) {
-	case CHAR: case DOT: case ALL: case CCL: case NCCL: case '$': case '(':
+	case CHAR: case DOT: case ALL: case EMPTYRE: case CCL: case NCCL: case '$': case '(':
 		return (concat(op2(CAT, np, primary())));
 	}
 	return (np);
@@ -683,6 +711,56 @@
 	}
 }
 
+/*
+ * Character class definitions conformant to the POSIX locale as
+ * defined in IEEE P1003.1 draft 7 of June 2001, assuming the source
+ * and operating character sets are both ASCII (ISO646) or supersets
+ * thereof.
+ *
+ * Note that to avoid overflowing the temporary buffer used in
+ * relex(), the expanded character class (prior to range expansion)
+ * must be less than twice the size of their full name.
+ */
+
+/* Because isblank doesn't show up in any of the header files on any
+ * system i use, it's defined here.  if some other locale has a richer
+ * definition of "blank", define HAS_ISBLANK and provide your own
+ * version.
+ * the parentheses here are an attempt to find a path through the maze
+ * of macro definition and/or function and/or version provided.  thanks
+ * to nelson beebe for the suggestion; let's see if it works everywhere.
+ */
+
+#ifndef HAS_ISBLANK
+
+int (isblank)(int c)
+{
+	return c==' ' || c=='\t';
+}
+
+#endif
+
+struct charclass {
+	const char *cc_name;
+	int cc_namelen;
+	int (*cc_func)(int);
+} charclasses[] = {
+	{ "alnum",	5,	isalnum },
+	{ "alpha",	5,	isalpha },
+	{ "blank",	5,	isblank },
+	{ "cntrl",	5,	iscntrl },
+	{ "digit",	5,	isdigit },
+	{ "graph",	5,	isgraph },
+	{ "lower",	5,	islower },
+	{ "print",	5,	isprint },
+	{ "punct",	5,	ispunct },
+	{ "space",	5,	isspace },
+	{ "upper",	5,	isupper },
+	{ "xdigit",	6,	isxdigit },
+	{ NULL,		0,	NULL },
+};
+
+
 int relex(void)		/* lexical analyzer for reparse */
 {
 	int c, n;
@@ -690,6 +768,8 @@
 	static uschar *buf = 0;
 	static int bufsz = 100;
 	uschar *bp;
+	struct charclass *cc;
+	int i;
 
 	switch (c = *prestr++) {
 	case '|': return OR;
@@ -719,8 +799,8 @@
 		}
 		else
 			cflag = 0;
-		n = 2 * strlen(prestr)+1;
-		if (!adjbuf((char **) &buf, &bufsz, n, n, (char **) &bp, 0))
+		n = 2 * strlen((const char *) prestr)+1;
+		if (!adjbuf((char **) &buf, &bufsz, n, n, (char **) &bp, "relex1"))
 			FATAL("out of space for reg expr %.10s...", lastre);
 		for (; ; ) {
 			if ((c = *prestr++) == '\\') {
@@ -730,6 +810,24 @@
 				*bp++ = c;
 			/* } else if (c == '\n') { */
 			/* 	FATAL("newline in character class %.20s...", lastre); */
+			} else if (c == '[' && *prestr == ':') {
+				/* POSIX char class names, Dag-Erling Smorgrav, des@ofug.org */
+				for (cc = charclasses; cc->cc_name; cc++)
+					if (strncmp((const char *) prestr + 1, (const char *) cc->cc_name, cc->cc_namelen) == 0)
+						break;
+				if (cc->cc_name != NULL && prestr[1 + cc->cc_namelen] == ':' &&
+				    prestr[2 + cc->cc_namelen] == ']') {
+					prestr += cc->cc_namelen + 3;
+					for (i = 0; i < NCHARS; i++) {
+						if (!adjbuf((char **) &buf, &bufsz, bp-buf+1, 100, (char **) &bp, "relex2"))
+						    FATAL("out of space for reg expr %.10s...", lastre);
+						if (cc->cc_func(i)) {
+							*bp++ = i;
+							n++;
+						}
+					}
+				} else
+					*bp++ = c;
 			} else if (c == '\0') {
 				FATAL("nonterminated character class %.20s", lastre);
 			} else if (bp == buf) {	/* 1st char is special */
@@ -752,8 +850,7 @@
 	int i, j, k;
 	int *p, *q;
 
-	if (c < 0 || c > 255)
-		FATAL("can't happen: neg char %d in cgoto", c);
+	assert(c == HAT || c < NCHARS);
 	while (f->accept >= maxsetvec) {	/* guessing here! */
 		maxsetvec *= 4;
 		setvec = (int *) realloc(setvec, maxsetvec * sizeof(int));
@@ -771,6 +868,7 @@
 			if ((k == CHAR && c == ptoi(f->re[p[i]].lval.np))
 			 || (k == DOT && c != 0 && c != HAT)
 			 || (k == ALL && c != 0)
+			 || (k == EMPTYRE && c != 0)
 			 || (k == CCL && member(c, (char *) f->re[p[i]].lval.up))
 			 || (k == NCCL && !member(c, (char *) f->re[p[i]].lval.up) && c != 0 && c != HAT)) {
 				q = f->re[p[i]].lfollow;

Added: httpd/httpd/win32-msi/trunk/awk/buildwin.bat
URL: http://svn.apache.org/viewvc/httpd/httpd/win32-msi/trunk/awk/buildwin.bat?rev=606942&view=auto
==============================================================================
--- httpd/httpd/win32-msi/trunk/awk/buildwin.bat (added)
+++ httpd/httpd/win32-msi/trunk/awk/buildwin.bat Wed Dec 26 12:15:40 2007
@@ -0,0 +1,12 @@
+@echo off
+rem buildwin.bat - build AWK under Windows NT using Visual C++.
+rem 22 Jan 1999 - Created by Dan Allen.
+rem
+rem If you delete the call to setlocal it will probably work under Win95/Win98 as well.
+
+setlocal 
+set cl=-w -Ox -QIfdiv- -nologo -link -nologo setargv.obj
+
+cl maketab.c -o maketab.exe
+maketab.exe > proctab.c
+cl -o awk.exe b.c main.c parse.c proctab.c tran.c lib.c run.c lex.c ytab.c missing95.c

Propchange: httpd/httpd/win32-msi/trunk/awk/buildwin.bat
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: httpd/httpd/win32-msi/trunk/awk/lex.c
URL: http://svn.apache.org/viewvc/httpd/httpd/win32-msi/trunk/awk/lex.c?rev=606942&r1=606941&r2=606942&view=diff
==============================================================================
--- httpd/httpd/win32-msi/trunk/awk/lex.c (original)
+++ httpd/httpd/win32-msi/trunk/awk/lex.c Wed Dec 26 12:15:40 2007
@@ -38,7 +38,7 @@
 int	parencnt = 0;
 
 typedef struct Keyword {
-	char	*word;
+	const char *word;
 	int	sub;
 	int	type;
 } Keyword;
@@ -89,12 +89,7 @@
 	{ "while",	WHILE,		WHILE },
 };
 
-#define DEBUG
-#ifdef	DEBUG
 #define	RET(x)	{ if(dbg)printf("lex %s\n", tokname(x)); return(x); }
-#else
-#define	RET(x)	return(x)
-#endif
 
 int peek(void)
 {
@@ -105,7 +100,7 @@
 
 int gettok(char **pbuf, int *psz)	/* get next input token */
 {
-	int c;
+	int c, retc;
 	char *buf = *pbuf;
 	int sz = *psz;
 	char *bp = buf;
@@ -122,7 +117,7 @@
 	if (isalpha(c) || c == '_') {	/* it's a varname */
 		for ( ; (c = input()) != 0; ) {
 			if (bp-buf >= sz)
-				if (!adjbuf(&buf, &sz, bp-buf+2, 100, &bp, 0))
+				if (!adjbuf(&buf, &sz, bp-buf+2, 100, &bp, "gettok"))
 					FATAL( "out of space for name %.10s...", buf );
 			if (isalnum(c) || c == '_')
 				*bp++ = c;
@@ -133,12 +128,13 @@
 			}
 		}
 		*bp = 0;
-	} else {	/* it's a number */
+		retc = 'a';	/* alphanumeric */
+	} else {	/* maybe it's a number, but could be . */
 		char *rem;
 		/* read input until can't be a number */
 		for ( ; (c = input()) != 0; ) {
 			if (bp-buf >= sz)
-				if (!adjbuf(&buf, &sz, bp-buf+2, 100, &bp, 0))
+				if (!adjbuf(&buf, &sz, bp-buf+2, 100, &bp, "gettok"))
 					FATAL( "out of space for number %.10s...", buf );
 			if (isdigit(c) || c == 'e' || c == 'E' 
 			  || c == '.' || c == '+' || c == '-')
@@ -150,12 +146,19 @@
 		}
 		*bp = 0;
 		strtod(buf, &rem);	/* parse the number */
-		unputstr(rem);		/* put rest back for later */
-		rem[0] = 0;
+		if (rem == buf) {	/* it wasn't a valid number at all */
+			buf[1] = 0;	/* return one character as token */
+			retc = buf[0];	/* character is its own type */
+			unputstr(rem+1); /* put rest back for later */
+		} else {	/* some prefix was a number */
+			unputstr(rem);	/* put rest back for later */
+			rem[0] = 0;	/* truncate buf after number part */
+			retc = '0';	/* type is number */
+		}
 	}
 	*pbuf = buf;
 	*psz = sz;
-	return buf[0];
+	return retc;
 }
 
 int	word(char *);
@@ -168,7 +171,7 @@
 {
 	int c;
 	static char *buf = 0;
-	static int bufsize = 500;
+	static int bufsize = 5; /* BUG: setting this small causes core dump! */
 
 	if (buf == 0 && (buf = (char *) malloc(bufsize)) == NULL)
 		FATAL( "out of space in yylex" );
@@ -186,7 +189,7 @@
 			return 0;
 		if (isalpha(c) || c == '_')
 			return word(buf);
-		if (isdigit(c) || c == '.') {
+		if (isdigit(c)) {
 			yylval.cp = setsymtab(buf, tostring(buf), atof(buf), CON|NUM, symtab);
 			/* should this also have STR set? */
 			RET(NUMBER);
@@ -311,6 +314,9 @@
 				}
 				yylval.cp = setsymtab(buf, "", 0.0, STR|NUM, symtab);
 				RET(IVAR);
+			} else if (c == 0) {	/*  */
+				SYNTAX( "unexpected end of input after $" );
+				RET(';');
 			} else {
 				unputstr(buf);
 				RET(INDIRECT);
@@ -358,7 +364,7 @@
 	if (buf == 0 && (buf = (char *) malloc(bufsz)) == NULL)
 		FATAL("out of space for strings");
 	for (bp = buf; (c = input()) != '"'; ) {
-		if (!adjbuf(&buf, &bufsz, bp-buf+2, 500, &bp, 0))
+		if (!adjbuf(&buf, &bufsz, bp-buf+2, 500, &bp, "string"))
 			FATAL("out of space for string %.10s...", buf);
 		switch (c) {
 		case '\n':
@@ -366,6 +372,8 @@
 		case 0:
 			SYNTAX( "non-terminated string %.10s...", buf );
 			lineno++;
+			if (c == 0)	/* hopeless */
+				FATAL( "giving up" );
 			break;
 		case '\\':
 			c = input();
@@ -450,12 +458,13 @@
 	int c, n;
 
 	n = binsearch(w, keywords, sizeof(keywords)/sizeof(keywords[0]));
+/* BUG: this ought to be inside the if; in theory could fault (daniel barrett) */
 	kp = keywords + n;
 	if (n != -1) {	/* found in table */
 		yylval.i = kp->sub;
 		switch (kp->type) {	/* special handling */
-		case FSYSTEM:
-			if (safe)
+		case BLTIN:
+			if (kp->sub == FSYSTEM && safe)
 				SYNTAX( "system is unsafe" );
 			RET(kp->type);
 		case FUNC:
@@ -487,7 +496,7 @@
 	}
 }
 
-void startreg(void)	/* next call to yyles will return a regular expression */
+void startreg(void)	/* next call to yylex will return a regular expression */
 {
 	reg = 1;
 }
@@ -503,7 +512,7 @@
 		FATAL("out of space for rex expr");
 	bp = buf;
 	for ( ; (c = input()) != '/' && c != 0; ) {
-		if (!adjbuf(&buf, &bufsz, bp-buf+3, 500, &bp, 0))
+		if (!adjbuf(&buf, &bufsz, bp-buf+3, 500, &bp, "regexpr"))
 			FATAL("out of space for reg expr %.10s...", buf);
 		if (c == '\n') {
 			SYNTAX( "newline in regular expression %.10s...", buf ); 
@@ -517,6 +526,8 @@
 		}
 	}
 	*bp = 0;
+	if (c == 0)
+		SYNTAX("non-terminated regular expression %.10s...", buf);
 	yylval.s = tostring(buf);
 	unput('/');
 	RET(REGEXPR);
@@ -536,9 +547,9 @@
 	extern char *lexprog;
 
 	if (yysptr > yysbuf)
-		c = *--yysptr;
+		c = (uschar)*--yysptr;
 	else if (lexprog != NULL) {	/* awk '...' */
-		if ((c = *lexprog) != 0)
+		if ((c = (uschar)*lexprog) != 0)
 			lexprog++;
 	} else				/* awk -f ... */
 		c = pgetc();
@@ -562,7 +573,7 @@
 		ep = ebuf + sizeof(ebuf) - 1;
 }
 
-void unputstr(char *s)	/* put a string back on input */
+void unputstr(const char *s)	/* put a string back on input */
 {
 	int i;
 

Modified: httpd/httpd/win32-msi/trunk/awk/lib.c
URL: http://svn.apache.org/viewvc/httpd/httpd/win32-msi/trunk/awk/lib.c?rev=606942&r1=606941&r2=606942&view=diff
==============================================================================
--- httpd/httpd/win32-msi/trunk/awk/lib.c (original)
+++ httpd/httpd/win32-msi/trunk/awk/lib.c Wed Dec 26 12:15:40 2007
@@ -42,7 +42,7 @@
 Cell	**fldtab;	/* pointers to Cells */
 char	inputFS[100] = " ";
 
-#define	MAXFLD	200
+#define	MAXFLD	2
 int	nfields	= MAXFLD;	/* last allocated slot for $i */
 
 int	donefld;	/* 1 = implies rec broken into fields */
@@ -57,13 +57,11 @@
 
 void recinit(unsigned int n)
 {
-	record = (char *) malloc(n);
-	fields = (char *) malloc(n);
-	fldtab = (Cell **) malloc((nfields+1) * sizeof(Cell *));
-	if (record == NULL || fields == NULL || fldtab == NULL)
+	if ( (record = (char *) malloc(n)) == NULL
+	  || (fields = (char *) malloc(n+1)) == NULL
+	  || (fldtab = (Cell **) malloc((nfields+1) * sizeof(Cell *))) == NULL
+	  || (fldtab[0] = (Cell *) malloc(sizeof(Cell))) == NULL )
 		FATAL("out of space for $0 and fields");
-
-	fldtab[0] = (Cell *) malloc(sizeof (Cell));
 	*fldtab[0] = dollar0;
 	fldtab[0]->sval = record;
 	fldtab[0]->nval = tostring("0");
@@ -101,12 +99,14 @@
 	infile = stdin;		/* no filenames, so use stdin */
 }
 
+static int firsttime = 1;
+
 int getrec(char **pbuf, int *pbufsize, int isrecord)	/* get next input record */
 {			/* note: cares whether buf == record */
 	int c;
-	static int firsttime = 1;
 	char *buf = *pbuf;
-	int bufsize = *pbufsize;
+	uschar saveb0;
+	int bufsize = *pbufsize, savebufsize = bufsize;
 
 	if (firsttime) {
 		firsttime = 0;
@@ -118,6 +118,7 @@
 		donefld = 0;
 		donerec = 1;
 	}
+	saveb0 = buf[0];
 	buf[0] = 0;
 	while (argno < *ARGC || infile == stdin) {
 		   dprintf( ("argno=%d, file=|%s|\n", argno, file) );
@@ -164,14 +165,15 @@
 		infile = NULL;
 		argno++;
 	}
+	buf[0] = saveb0;
 	*pbuf = buf;
-	*pbufsize = bufsize;
+	*pbufsize = savebufsize;
 	return 0;	/* true end of file */
 }
 
 void nextfile(void)
 {
-	if (infile != stdin)
+	if (infile != NULL && infile != stdin)
 		fclose(infile);
 	infile = NULL;
 	argno++;
@@ -308,6 +310,13 @@
 		}
 		*fr = 0;
 	} else if (*r != 0) {	/* if 0, it's a null field */
+		/* subtlecase : if length(FS) == 1 && length(RS > 0)
+		 * \n is NOT a field separator (cf awk book 61,84).
+		 * this variable is tested in the inner while loop.
+		 */
+		int rtest = '\n';  /* normal case */
+		if (strlen(*RS) > 0)
+			rtest = '\0';
 		for (;;) {
 			i++;
 			if (i > nfields)
@@ -316,7 +325,7 @@
 				xfree(fldtab[i]->sval);
 			fldtab[i]->sval = fr;
 			fldtab[i]->tval = FLD | STR | DONTFREE;
-			while (*r != sep && *r != '\n' && *r != '\0')	/* \n is always a separator */
+			while (*r != sep && *r != rtest && *r != '\0')	/* \n is always a separator */
 				*fr++ = *r++;
 			*fr++ = 0;
 			if (*r++ == 0)
@@ -371,7 +380,7 @@
 Cell *fieldadr(int n)	/* get nth field */
 {
 	if (n < 0)
-		FATAL("trying to access field %d", n);
+		FATAL("trying to access out of range field %d", n);
 	if (n > nfields)	/* fields after NF are empty */
 		growfldtab(n);	/* but does not increase NF */
 	return(fldtab[n]);
@@ -380,17 +389,22 @@
 void growfldtab(int n)	/* make new fields up to at least $n */
 {
 	int nf = 2 * nfields;
+	size_t s;
 
 	if (n > nf)
 		nf = n;
-	fldtab = (Cell **) realloc(fldtab, (nf+1) * (sizeof (struct Cell *)));
+	s = (nf+1) * (sizeof (struct Cell *));  /* freebsd: how much do we need? */
+	if (s / sizeof(struct Cell *) - 1 == nf) /* didn't overflow */
+		fldtab = (Cell **) realloc(fldtab, s);
+	else					/* overflow sizeof int */
+		xfree(fldtab);	/* make it null */
 	if (fldtab == NULL)
 		FATAL("out of space creating %d fields", nf);
 	makefields(nfields+1, nf);
 	nfields = nf;
 }
 
-int refldbld(char *rec, char *fs)	/* build fields from reg expr in FS */
+int refldbld(const char *rec, const char *fs)	/* build fields from reg expr in FS */
 {
 	/* this relies on having fields[] the same length as $0 */
 	/* the fields are all stored in this one array with \0's */
@@ -475,12 +489,12 @@
 
 int	errorflag	= 0;
 
-void yyerror(char *s)
+void yyerror(const char *s)
 {
-	SYNTAX(s);
+	SYNTAX("%s", s);
 }
 
-void SYNTAX(char *fmt, ...)
+void SYNTAX(const char *fmt, ...)
 {
 	extern char *cmdname, *curfname;
 	static int been_here = 0;
@@ -535,7 +549,7 @@
 		fprintf(stderr, "\t%d extra %c's\n", -n, c2);
 }
 
-void FATAL(char *fmt, ...)
+void FATAL(const char *fmt, ...)
 {
 	extern char *cmdname;
 	va_list varg;
@@ -551,7 +565,7 @@
 	exit(2);
 }
 
-void WARNING(char *fmt, ...)
+void WARNING(const char *fmt, ...)
 {
 	extern char *cmdname;
 	va_list varg;
@@ -633,7 +647,7 @@
 	}
 }
 
-double errcheck(double x, char *s)
+double errcheck(double x, const char *s)
 {
 
 	if (errno == EDOM) {
@@ -648,9 +662,9 @@
 	return x;
 }
 
-int isclvar(char *s)	/* is s of form var=something ? */
+int isclvar(const char *s)	/* is s of form var=something ? */
 {
-	char *os = s;
+	const char *os = s;
 
 	if (!isalpha((uschar) *s) && *s != '_')
 		return 0;
@@ -665,7 +679,7 @@
 /* wrong: violates 4.10.1.4 of ansi C standard */
 
 #include <math.h>
-int is_number(char *s)
+int is_number(const char *s)
 {
 	double r;
 	char *ep;

Modified: httpd/httpd/win32-msi/trunk/awk/main.c
URL: http://svn.apache.org/viewvc/httpd/httpd/win32-msi/trunk/awk/main.c?rev=606942&r1=606941&r2=606942&view=diff
==============================================================================
--- httpd/httpd/win32-msi/trunk/awk/main.c (original)
+++ httpd/httpd/win32-msi/trunk/awk/main.c Wed Dec 26 12:15:40 2007
@@ -22,11 +22,12 @@
 THIS SOFTWARE.
 ****************************************************************/
 
-char	*version = "version 20001115";
+const char	*version = "version 20070501";
 
 #define DEBUG
 #include <stdio.h>
 #include <ctype.h>
+#include <locale.h>
 #include <stdlib.h>
 #include <string.h>
 #include <signal.h>
@@ -44,7 +45,9 @@
 int	compile_time = 2;	/* for error printing: */
 				/* 2 = cmdline, 1 = compile, 0 = running */
 
-char	*pfile[20];	/* program filenames from -f's */
+#define	MAX_PFILE	20	/* max number of -f's */
+
+char	*pfile[MAX_PFILE];	/* program filenames from -f's */
 int	npfile = 0;	/* number of filenames */
 int	curpfile = 0;	/* current filename */
 
@@ -52,19 +55,27 @@
 
 int main(int argc, char *argv[])
 {
-	char *fs = NULL, *marg;
-	int temp;
+	const char *fs = NULL;
 
+	setlocale(LC_CTYPE, "");
+	setlocale(LC_NUMERIC, "C"); /* for parsing cmdline & prog */
 	cmdname = argv[0];
 	if (argc == 1) {
-		fprintf(stderr, "Usage: %s [-f programfile | 'program'] [-Ffieldsep] [-v var=value] [files]\n", cmdname);
+		fprintf(stderr, 
+		  "usage: %s [-F fs] [-v var=value] [-f progfile | 'prog'] [file ...]\n", 
+		  cmdname);
 		exit(1);
 	}
 	signal(SIGFPE, fpecatch);
 	yyin = NULL;
-	symtab = makesymtab(NSYMTAB);
+	symtab = makesymtab(NSYMTAB/NSYMTAB);
 	while (argc > 1 && argv[1][0] == '-' && argv[1][1] != '\0') {
-		if (strcmp(argv[1], "--") == 0) {	/* explicit end of args */
+		if (strcmp(argv[1],"-version") == 0 || strcmp(argv[1],"--version") == 0) {
+			printf("awk %s\n", version);
+			exit(0);
+			break;
+		}
+		if (strncmp(argv[1], "--", 2) == 0) {	/* explicit end of args */
 			argc--;
 			argv++;
 			break;
@@ -79,6 +90,8 @@
 			argv++;
 			if (argc <= 1)
 				FATAL("no program filename");
+			if (npfile >= MAX_PFILE - 1)
+				FATAL("too many -f options"); 
 			pfile[npfile++] = argv[1];
 			break;
 		case 'F':	/* set field separator */
@@ -101,31 +114,12 @@
 			if (argv[1][2] == '\0' && --argc > 1 && isclvar((++argv)[1]))
 				setclvar(argv[1]);
 			break;
-		case 'm':	/* more memory: -mr=record, -mf=fields */
-				/* no longer needed */
-			marg = argv[1];
-			if (argv[1][3])
-				temp = atoi(&argv[1][3]);
-			else {
-				argv++; argc--;
-				temp = atoi(&argv[1][0]);
-			}
-			switch (marg[2]) {
-			case 'r':	recsize = temp; break;
-			case 'f':	nfields = temp; break;
-			default: FATAL("unknown option %s\n", marg);
-			}
-			break;
 		case 'd':
 			dbg = atoi(&argv[1][2]);
 			if (dbg == 0)
 				dbg = 1;
 			printf("awk %s\n", version);
 			break;
-		case 'V':	/* added for exptools "standard" */
-			printf("awk %s\n", version);
-			exit(0);
-			break;
 		default:
 			WARNING("unknown option %s ignored", argv[1]);
 			break;
@@ -154,6 +148,7 @@
 	if (!safe)
 		envinit(environ);
 	yyparse();
+	setlocale(LC_NUMERIC, ""); /* back to whatever it is locally */
 	if (fs)
 		*FS = qstring(fs, '\0');
 	   dprintf( ("errorflag=%d\n", errorflag) );

Modified: httpd/httpd/win32-msi/trunk/awk/makefile
URL: http://svn.apache.org/viewvc/httpd/httpd/win32-msi/trunk/awk/makefile?rev=606942&r1=606941&r2=606942&view=diff
==============================================================================
--- httpd/httpd/win32-msi/trunk/awk/makefile (original)
+++ httpd/httpd/win32-msi/trunk/awk/makefile Wed Dec 26 12:15:40 2007
@@ -26,9 +26,13 @@
 CFLAGS = -O2
 CFLAGS =
 
+CC = gcc -Wall -g -Wwrite-strings
+CC = gcc -fprofile-arcs -ftest-coverage # then gcov f1.c; cat f1.c.gcov
 CC = gcc -Wall -g
-CC = /opt/pure/purify/purify cc
 CC = cc
+CC = gcc -O4
+CC = gcc -Wall -g
+
 
 YACC = bison -y
 YACC = yacc
@@ -36,11 +40,14 @@
 
 OFILES = b.o main.o parse.o proctab.o tran.o lib.o run.o lex.o
 
-SOURCE = awk.h ytab.c ytab.h proto.h awkgram.y lex.c b.c main.c maketab.c parse.c lib.c run.c tran.c proctab.c missing95.c
+SOURCE = awk.h ytab.c ytab.h proto.h awkgram.y lex.c b.c main.c \
+	maketab.c parse.c lib.c run.c tran.c proctab.c missing95.c
 
-LISTING = awk.h proto.h awkgram.y lex.c b.c main.c maketab.c parse.c lib.c run.c tran.c missing95.c
+LISTING = awk.h proto.h awkgram.y lex.c b.c main.c maketab.c parse.c \
+	lib.c run.c tran.c missing95.c
 
-SHIP = README FIXES $(SOURCE) ytab[ch].bak makefile awk.1 buildwin.bat mac.code
+SHIP = README FIXES $(SOURCE) ytab[ch].bak makefile makefile.win \
+	vcvars32.bat buildwin.bat awk.1
 
 a.out:	ytab.o $(OFILES)
 	$(CC) $(CFLAGS) ytab.o $(OFILES) $(ALLOC)  -lm
@@ -78,4 +85,4 @@
 	@echo $(LISTING)
 
 clean:
-	rm -f a.out *.o maketab # proctab.c
+	rm -f a.out *.o *.obj maketab maketab.exe *.bb *.bbg *.da *.gcov *.gcno *.gcda # proctab.c

Added: httpd/httpd/win32-msi/trunk/awk/makefile.win
URL: http://svn.apache.org/viewvc/httpd/httpd/win32-msi/trunk/awk/makefile.win?rev=606942&view=auto
==============================================================================
--- httpd/httpd/win32-msi/trunk/awk/makefile.win (added)
+++ httpd/httpd/win32-msi/trunk/awk/makefile.win Wed Dec 26 12:15:40 2007
@@ -0,0 +1,9 @@
+# vestigial makefile for microsoft c compiler on WinXX
+# run with nmake -f makefile.win
+# based on buildwin.bat
+
+awk95.exe:
+	set cl=-w -Ox -QIfdiv- -nologo -link -nologo setargv.obj
+	cl maketab.c -o maketab.exe
+	.\maketab.exe > proctab.c
+	cl -o awk95.exe b.c main.c parse.c proctab.c tran.c lib.c run.c lex.c ytab.c missing95.c

Propchange: httpd/httpd/win32-msi/trunk/awk/makefile.win
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: httpd/httpd/win32-msi/trunk/awk/maketab.c
URL: http://svn.apache.org/viewvc/httpd/httpd/win32-msi/trunk/awk/maketab.c?rev=606942&r1=606941&r2=606942&view=diff
==============================================================================
--- httpd/httpd/win32-msi/trunk/awk/maketab.c (original)
+++ httpd/httpd/win32-msi/trunk/awk/maketab.c Wed Dec 26 12:15:40 2007
@@ -36,8 +36,8 @@
 
 struct xx
 {	int token;
-	char *name;
-	char *pname;
+	const char *name;
+	const char *pname;
 } proc[] = {
 	{ PROGRAM, "program", NULL },
 	{ BOR, "boolop", " || " },
@@ -107,12 +107,12 @@
 };
 
 #define SIZE	(LASTTOKEN - FIRSTTOKEN + 1)
-char *table[SIZE];
+const char *table[SIZE];
 char *names[SIZE];
 
 int main(int argc, char *argv[])
 {
-	struct xx *p;
+	const struct xx *p;
 	int i, n, tok;
 	char c;
 	FILE *fp;
@@ -135,7 +135,7 @@
 		if (c != '#' || (n != 4 && strcmp(def,"define") != 0))	/* not a valid #define */
 			continue;
 		if (tok < FIRSTTOKEN || tok > LASTTOKEN) {
-			fprintf(stderr, "maketab funny token %d %s ignored\n", tok, buf);
+			/* fprintf(stderr, "maketab funny token %d %s ignored\n", tok, buf); */
 			continue;
 		}
 		names[tok-FIRSTTOKEN] = (char *) malloc(strlen(name)+1);

Modified: httpd/httpd/win32-msi/trunk/awk/parse.c
URL: http://svn.apache.org/viewvc/httpd/httpd/win32-msi/trunk/awk/parse.c?rev=606942&r1=606941&r2=606942&view=diff
==============================================================================
--- httpd/httpd/win32-msi/trunk/awk/parse.c (original)
+++ httpd/httpd/win32-msi/trunk/awk/parse.c Wed Dec 26 12:15:40 2007
@@ -253,7 +253,7 @@
 	dprintf( ("defining func %s (%d args)\n", v->nval, n) );
 }
 
-int isarg(char *s)		/* is s in argument list for current function? */
+int isarg(const char *s)		/* is s in argument list for current function? */
 {			/* return -1 if not, otherwise arg # */
 	extern Node *arglist;
 	Node *p = arglist;

Added: httpd/httpd/win32-msi/trunk/awk/proctab.c
URL: http://svn.apache.org/viewvc/httpd/httpd/win32-msi/trunk/awk/proctab.c?rev=606942&view=auto
==============================================================================
--- httpd/httpd/win32-msi/trunk/awk/proctab.c (added)
+++ httpd/httpd/win32-msi/trunk/awk/proctab.c Wed Dec 26 12:15:40 2007
@@ -0,0 +1,207 @@
+#include <stdio.h>
+#include "awk.h"
+#include "ytab.h"
+
+static char *printname[93] = {
+	(char *) "FIRSTTOKEN",	/* 258 */
+	(char *) "PROGRAM",	/* 259 */
+	(char *) "PASTAT",	/* 260 */
+	(char *) "PASTAT2",	/* 261 */
+	(char *) "XBEGIN",	/* 262 */
+	(char *) "XEND",	/* 263 */
+	(char *) "NL",	/* 264 */
+	(char *) "ARRAY",	/* 265 */
+	(char *) "MATCH",	/* 266 */
+	(char *) "NOTMATCH",	/* 267 */
+	(char *) "MATCHOP",	/* 268 */
+	(char *) "FINAL",	/* 269 */
+	(char *) "DOT",	/* 270 */
+	(char *) "ALL",	/* 271 */
+	(char *) "CCL",	/* 272 */
+	(char *) "NCCL",	/* 273 */
+	(char *) "CHAR",	/* 274 */
+	(char *) "OR",	/* 275 */
+	(char *) "STAR",	/* 276 */
+	(char *) "QUEST",	/* 277 */
+	(char *) "PLUS",	/* 278 */
+	(char *) "EMPTYRE",	/* 279 */
+	(char *) "AND",	/* 280 */
+	(char *) "BOR",	/* 281 */
+	(char *) "APPEND",	/* 282 */
+	(char *) "EQ",	/* 283 */
+	(char *) "GE",	/* 284 */
+	(char *) "GT",	/* 285 */
+	(char *) "LE",	/* 286 */
+	(char *) "LT",	/* 287 */
+	(char *) "NE",	/* 288 */
+	(char *) "IN",	/* 289 */
+	(char *) "ARG",	/* 290 */
+	(char *) "BLTIN",	/* 291 */
+	(char *) "BREAK",	/* 292 */
+	(char *) "CLOSE",	/* 293 */
+	(char *) "CONTINUE",	/* 294 */
+	(char *) "DELETE",	/* 295 */
+	(char *) "DO",	/* 296 */
+	(char *) "EXIT",	/* 297 */
+	(char *) "FOR",	/* 298 */
+	(char *) "FUNC",	/* 299 */
+	(char *) "SUB",	/* 300 */
+	(char *) "GSUB",	/* 301 */
+	(char *) "IF",	/* 302 */
+	(char *) "INDEX",	/* 303 */
+	(char *) "LSUBSTR",	/* 304 */
+	(char *) "MATCHFCN",	/* 305 */
+	(char *) "NEXT",	/* 306 */
+	(char *) "NEXTFILE",	/* 307 */
+	(char *) "ADD",	/* 308 */
+	(char *) "MINUS",	/* 309 */
+	(char *) "MULT",	/* 310 */
+	(char *) "DIVIDE",	/* 311 */
+	(char *) "MOD",	/* 312 */
+	(char *) "ASSIGN",	/* 313 */
+	(char *) "ASGNOP",	/* 314 */
+	(char *) "ADDEQ",	/* 315 */
+	(char *) "SUBEQ",	/* 316 */
+	(char *) "MULTEQ",	/* 317 */
+	(char *) "DIVEQ",	/* 318 */
+	(char *) "MODEQ",	/* 319 */
+	(char *) "POWEQ",	/* 320 */
+	(char *) "PRINT",	/* 321 */
+	(char *) "PRINTF",	/* 322 */
+	(char *) "SPRINTF",	/* 323 */
+	(char *) "ELSE",	/* 324 */
+	(char *) "INTEST",	/* 325 */
+	(char *) "CONDEXPR",	/* 326 */
+	(char *) "POSTINCR",	/* 327 */
+	(char *) "PREINCR",	/* 328 */
+	(char *) "POSTDECR",	/* 329 */
+	(char *) "PREDECR",	/* 330 */
+	(char *) "VAR",	/* 331 */
+	(char *) "IVAR",	/* 332 */
+	(char *) "VARNF",	/* 333 */
+	(char *) "CALL",	/* 334 */
+	(char *) "NUMBER",	/* 335 */
+	(char *) "STRING",	/* 336 */
+	(char *) "REGEXPR",	/* 337 */
+	(char *) "GETLINE",	/* 338 */
+	(char *) "SUBSTR",	/* 339 */
+	(char *) "SPLIT",	/* 340 */
+	(char *) "RETURN",	/* 341 */
+	(char *) "WHILE",	/* 342 */
+	(char *) "CAT",	/* 343 */
+	(char *) "UMINUS",	/* 344 */
+	(char *) "NOT",	/* 345 */
+	(char *) "POWER",	/* 346 */
+	(char *) "INCR",	/* 347 */
+	(char *) "DECR",	/* 348 */
+	(char *) "INDIRECT",	/* 349 */
+	(char *) "LASTTOKEN",	/* 350 */
+};
+
+
+Cell *(*proctab[93])(Node **, int) = {
+	nullproc,	/* FIRSTTOKEN */
+	program,	/* PROGRAM */
+	pastat,	/* PASTAT */
+	dopa2,	/* PASTAT2 */
+	nullproc,	/* XBEGIN */
+	nullproc,	/* XEND */
+	nullproc,	/* NL */
+	array,	/* ARRAY */
+	matchop,	/* MATCH */
+	matchop,	/* NOTMATCH */
+	nullproc,	/* MATCHOP */
+	nullproc,	/* FINAL */
+	nullproc,	/* DOT */
+	nullproc,	/* ALL */
+	nullproc,	/* CCL */
+	nullproc,	/* NCCL */
+	nullproc,	/* CHAR */
+	nullproc,	/* OR */
+	nullproc,	/* STAR */
+	nullproc,	/* QUEST */
+	nullproc,	/* PLUS */
+	nullproc,	/* EMPTYRE */
+	boolop,	/* AND */
+	boolop,	/* BOR */
+	nullproc,	/* APPEND */
+	relop,	/* EQ */
+	relop,	/* GE */
+	relop,	/* GT */
+	relop,	/* LE */
+	relop,	/* LT */
+	relop,	/* NE */
+	instat,	/* IN */
+	arg,	/* ARG */
+	bltin,	/* BLTIN */
+	jump,	/* BREAK */
+	closefile,	/* CLOSE */
+	jump,	/* CONTINUE */
+	awkdelete,	/* DELETE */
+	dostat,	/* DO */
+	jump,	/* EXIT */
+	forstat,	/* FOR */
+	nullproc,	/* FUNC */
+	sub,	/* SUB */
+	gsub,	/* GSUB */
+	ifstat,	/* IF */
+	sindex,	/* INDEX */
+	nullproc,	/* LSUBSTR */
+	matchop,	/* MATCHFCN */
+	jump,	/* NEXT */
+	jump,	/* NEXTFILE */
+	arith,	/* ADD */
+	arith,	/* MINUS */
+	arith,	/* MULT */
+	arith,	/* DIVIDE */
+	arith,	/* MOD */
+	assign,	/* ASSIGN */
+	nullproc,	/* ASGNOP */
+	assign,	/* ADDEQ */
+	assign,	/* SUBEQ */
+	assign,	/* MULTEQ */
+	assign,	/* DIVEQ */
+	assign,	/* MODEQ */
+	assign,	/* POWEQ */
+	printstat,	/* PRINT */
+	awkprintf,	/* PRINTF */
+	awksprintf,	/* SPRINTF */
+	nullproc,	/* ELSE */
+	intest,	/* INTEST */
+	condexpr,	/* CONDEXPR */
+	incrdecr,	/* POSTINCR */
+	incrdecr,	/* PREINCR */
+	incrdecr,	/* POSTDECR */
+	incrdecr,	/* PREDECR */
+	nullproc,	/* VAR */
+	nullproc,	/* IVAR */
+	getnf,	/* VARNF */
+	call,	/* CALL */
+	nullproc,	/* NUMBER */
+	nullproc,	/* STRING */
+	nullproc,	/* REGEXPR */
+	getline,	/* GETLINE */
+	substr,	/* SUBSTR */
+	split,	/* SPLIT */
+	jump,	/* RETURN */
+	whilestat,	/* WHILE */
+	cat,	/* CAT */
+	arith,	/* UMINUS */
+	boolop,	/* NOT */
+	arith,	/* POWER */
+	nullproc,	/* INCR */
+	nullproc,	/* DECR */
+	indirect,	/* INDIRECT */
+	nullproc,	/* LASTTOKEN */
+};
+
+char *tokname(int n)
+{
+	static char buf[100];
+
+	if (n < FIRSTTOKEN || n > LASTTOKEN) {
+		sprintf(buf, "token %d", n);
+		return buf;
+	}
+	return printname[n-FIRSTTOKEN];
+}

Modified: httpd/httpd/win32-msi/trunk/awk/proto.h
URL: http://svn.apache.org/viewvc/httpd/httpd/win32-msi/trunk/awk/proto.h?rev=606942&r1=606941&r2=606942&view=diff
==============================================================================
--- httpd/httpd/win32-msi/trunk/awk/proto.h (original)
+++ httpd/httpd/win32-msi/trunk/awk/proto.h Wed Dec 26 12:15:40 2007
@@ -33,28 +33,28 @@
 extern	void	startreg(void);
 extern	int	input(void);
 extern	void	unput(int);
-extern	void	unputstr(char *);
+extern	void	unputstr(const char *);
 extern	int	yylook(void);
 extern	int	yyback(int *, int);
 extern	int	yyinput(void);
 
-extern	fa	*makedfa(char *, int);
-extern	fa	*mkdfa(char *, int);
+extern	fa	*makedfa(const char *, int);
+extern	fa	*mkdfa(const char *, int);
 extern	int	makeinit(fa *, int);
 extern	void	penter(Node *);
 extern	void	freetr(Node *);
 extern	int	hexstr(char **);
 extern	int	quoted(char **);
-extern	char	*cclenter(char *);
-extern	void	overflo(char *);
+extern	char	*cclenter(const char *);
+extern	void	overflo(const char *);
 extern	void	cfoll(fa *, Node *);
 extern	int	first(Node *);
 extern	void	follow(Node *);
-extern	int	member(int, char *);
-extern	int	match(fa *, char *);
-extern	int	pmatch(fa *, char *);
-extern	int	nematch(fa *, char *);
-extern	Node	*reparse(char *);
+extern	int	member(int, const char *);
+extern	int	match(fa *, const char *);
+extern	int	pmatch(fa *, const char *);
+extern	int	nematch(fa *, const char *);
+extern	Node	*reparse(const char *);
 extern	Node	*regexp(void);
 extern	Node	*primary(void);
 extern	Node	*concat(Node *);
@@ -87,7 +87,7 @@
 extern	Node	*pa2stat(Node *, Node *, Node *);
 extern	Node	*linkum(Node *, Node *);
 extern	void	defn(Cell *, Node *, Node *);
-extern	int	isarg(char *);
+extern	int	isarg(const char *);
 extern	char	*tokname(int);
 extern	Cell	*(*proctab[])(Node **, int);
 extern	int	ptoi(void *);
@@ -98,18 +98,19 @@
 extern	void	envinit(char **);
 extern	Array	*makesymtab(int);
 extern	void	freesymtab(Cell *);
-extern	void	freeelem(Cell *, char *);
-extern	Cell	*setsymtab(char *, char *, double, unsigned int, Array *);
-extern	int	hash(char *, int);
+extern	void	freeelem(Cell *, const char *);
+extern	Cell	*setsymtab(const char *, const char *, double, unsigned int, Array *);
+extern	int	hash(const char *, int);
 extern	void	rehash(Array *);
-extern	Cell	*lookup(char *, Array *);
+extern	Cell	*lookup(const char *, Array *);
 extern	double	setfval(Cell *, double);
-extern	void	funnyvar(Cell *, char *);
-extern	char	*setsval(Cell *, char *);
+extern	void	funnyvar(Cell *, const char *);
+extern	char	*setsval(Cell *, const char *);
 extern	double	getfval(Cell *);
 extern	char	*getsval(Cell *);
-extern	char	*tostring(char *);
-extern	char	*qstring(char *, int);
+extern	char	*getpssval(Cell *);     /* for print */
+extern	char	*tostring(const char *);
+extern	char	*qstring(const char *, int);
 
 extern	void	recinit(unsigned int);
 extern	void	initgetrec(void);
@@ -123,24 +124,24 @@
 extern	void	fldbld(void);
 extern	void	cleanfld(int, int);
 extern	void	newfld(int);
-extern	int	refldbld(char *, char *);
+extern	int	refldbld(const char *, const char *);
 extern	void	recbld(void);
 extern	Cell	*fieldadr(int);
-extern	void	yyerror(char *);
+extern	void	yyerror(const char *);
 extern	void	fpecatch(int);
 extern	void	bracecheck(void);
 extern	void	bcheck2(int, int, int);
-extern	void	SYNTAX(char *, ...);
-extern	void	FATAL(char *, ...);
-extern	void	WARNING(char *, ...);
+extern	void	SYNTAX(const char *, ...);
+extern	void	FATAL(const char *, ...);
+extern	void	WARNING(const char *, ...);
 extern	void	error(void);
 extern	void	eprint(void);
 extern	void	bclass(int);
-extern	double	errcheck(double, char *);
-extern	int	isclvar(char *);
-extern	int	is_number(char *);
+extern	double	errcheck(double, const char *);
+extern	int	isclvar(const char *);
+extern	int	is_number(const char *);
 
-extern	int	adjbuf(char **pb, int *sz, int min, int q, char **pbp, char *what);
+extern	int	adjbuf(char **pb, int *sz, int min, int q, char **pbp, const char *what);
 extern	void	run(Node *);
 extern	Cell	*execute(Node *);
 extern	Cell	*program(Node **, int);
@@ -162,7 +163,7 @@
 extern	Cell	*indirect(Node **, int);
 extern	Cell	*substr(Node **, int);
 extern	Cell	*sindex(Node **, int);
-extern	int	format(char **, int *, char *, Node *);
+extern	int	format(char **, int *, const char *, Node *);
 extern	Cell	*awksprintf(Node **, int);
 extern	Cell	*awkprintf(Node **, int);
 extern	Cell	*arith(Node **, int);
@@ -183,8 +184,8 @@
 extern	Cell	*printstat(Node **, int);
 extern	Cell	*nullproc(Node **, int);
 extern	FILE	*redirect(int, Node *);
-extern	FILE	*openfile(int, char *);
-extern	char	*filename(FILE *);
+extern	FILE	*openfile(int, const char *);
+extern	const char	*filename(FILE *);
 extern	Cell	*closefile(Node **, int);
 extern	void	closeall(void);
 extern	Cell	*sub(Node **, int);

Modified: httpd/httpd/win32-msi/trunk/awk/run.c
URL: http://svn.apache.org/viewvc/httpd/httpd/win32-msi/trunk/awk/run.c?rev=606942&r1=606941&r2=606942&view=diff
==============================================================================
--- httpd/httpd/win32-msi/trunk/awk/run.c (original)
+++ httpd/httpd/win32-msi/trunk/awk/run.c Wed Dec 26 12:15:40 2007
@@ -26,6 +26,7 @@
 #include <stdio.h>
 #include <ctype.h>
 #include <setjmp.h>
+#include <limits.h>
 #include <math.h>
 #include <string.h>
 #include <stdlib.h>
@@ -48,19 +49,20 @@
 }
 */
 
-#ifdef _NFILE
-#ifndef FOPEN_MAX
-#define FOPEN_MAX _NFILE
-#endif
-#endif
-
-#ifndef	FOPEN_MAX
-#define	FOPEN_MAX	40	/* max number of open files */
-#endif
-
-#ifndef RAND_MAX
-#define RAND_MAX	32767	/* all that ansi guarantees */
-#endif
+/* do we really need these? */
+/* #ifdef _NFILE */
+/* #ifndef FOPEN_MAX */
+/* #define FOPEN_MAX _NFILE */
+/* #endif */
+/* #endif */
+/*  */
+/* #ifndef	FOPEN_MAX */
+/* #define	FOPEN_MAX	40 */	/* max number of open files */
+/* #endif */
+/*  */
+/* #ifndef RAND_MAX */
+/* #define RAND_MAX	32767 */	/* all that ansi guarantees */
+/* #endif */
 
 jmp_buf env;
 extern	int	pairstack[];
@@ -90,7 +92,7 @@
 
 /* buffer memory management */
 int adjbuf(char **pbuf, int *psiz, int minlen, int quantum, char **pbptr,
-	char *whatrtn)
+	const char *whatrtn)
 /* pbuf:    address of pointer to buffer being managed
  * psiz:    address of buffer size variable
  * minlen:  minimum length of buffer needed
@@ -109,6 +111,7 @@
 		if (rminlen)
 			minlen += quantum - rminlen;
 		tbuf = (char *) realloc(*pbuf, minlen);
+		dprintf( ("adjbuf %s: %d %d (pbuf=%p, tbuf=%p)\n", whatrtn, *psiz, minlen, *pbuf, tbuf) );
 		if (tbuf == NULL) {
 			if (whatrtn)
 				FATAL("out of memory in %s", whatrtn);
@@ -219,6 +222,7 @@
 {
 	static Cell newcopycell = { OCELL, CCOPY, 0, "", 0.0, NUM|STR|DONTFREE };
 	int i, ncall, ndef;
+	int freed = 0; /* handles potential double freeing when fcn & param share a tempcell */
 	Node *x;
 	Cell *args[NARGS], *oargs[NARGS];	/* BUG: fixed size arrays */
 	Cell *y, *z, *fcn;
@@ -247,7 +251,7 @@
 		y = execute(x);
 		oargs[i] = y;
 		   dprintf( ("args[%d]: %s %f <%s>, t=%o\n",
-			   i, y->nval, y->fval, isarr(y) ? "(array)" : y->sval, y->tval) );
+			   i, NN(y->nval), y->fval, isarr(y) ? "(array)" : NN(y->sval), y->tval) );
 		if (isfcn(y))
 			FATAL("can't use function %s as argument in %s", y->nval, s);
 		if (isarr(y))
@@ -296,12 +300,18 @@
 		} else if (t != y) {	/* kludge to prevent freeing twice */
 			t->csub = CTEMP;
 			tempfree(t);
+		} else if (t == y && t->csub == CCOPY) {
+			t->csub = CTEMP;
+			tempfree(t);
+			freed = 1;
 		}
 	}
 	tempfree(fcn);
 	if (isexit(y) || isnext(y))
 		return y;
-	tempfree(y);		/* this can free twice! */
+	if (freed == 0) {
+		tempfree(y);	/* don't free twice! */
+	}
 	z = fp->retval;			/* return value */
 	   dprintf( ("%s returns %g |%s| %o\n", s, getfval(z), getsval(z), z->tval) );
 	fp--;
@@ -455,7 +465,7 @@
 	for (np = a[1]; np; np = np->nnext) {
 		y = execute(np);	/* subscript */
 		s = getsval(y);
-		if (!adjbuf(&buf, &bufsz, strlen(buf)+strlen(s)+nsub+1, recsize, 0, 0))
+		if (!adjbuf(&buf, &bufsz, strlen(buf)+strlen(s)+nsub+1, recsize, 0, "array"))
 			FATAL("out of memory for %s[%s...]", x->nval, buf);
 		strcat(buf, s);
 		if (np->nnext)
@@ -463,7 +473,7 @@
 		tempfree(y);
 	}
 	if (!isarr(x)) {
-		   dprintf( ("making %s into an array\n", x->nval) );
+		   dprintf( ("making %s into an array\n", NN(x->nval)) );
 		if (freeable(x))
 			xfree(x->sval);
 		x->tval &= ~(STR|NUM|DONTFREE);
@@ -502,7 +512,7 @@
 		for (np = a[1]; np; np = np->nnext) {
 			y = execute(np);	/* subscript */
 			s = getsval(y);
-			if (!adjbuf(&buf, &bufsz, strlen(buf)+strlen(s)+nsub+1, recsize, 0, 0))
+			if (!adjbuf(&buf, &bufsz, strlen(buf)+strlen(s)+nsub+1, recsize, 0, "awkdelete"))
 				FATAL("out of memory deleting %s[%s...]", x->nval, buf);
 			strcat(buf, s);	
 			if (np->nnext)
@@ -541,7 +551,7 @@
 	for (p = a[0]; p; p = p->nnext) {
 		x = execute(p);	/* expr */
 		s = getsval(x);
-		if (!adjbuf(&buf, &bufsz, strlen(buf)+strlen(s)+nsub+1, recsize, 0, 0))
+		if (!adjbuf(&buf, &bufsz, strlen(buf)+strlen(s)+nsub+1, recsize, 0, "intest"))
 			FATAL("out of memory deleting %s[%s...]", x->nval, buf);
 		strcat(buf, s);
 		tempfree(x);
@@ -564,7 +574,7 @@
 	char *s, *t;
 	int i;
 	fa *pfa;
-	int (*mf)(fa *, char *) = match, mode = 0;
+	int (*mf)(fa *, const char *) = match, mode = 0;
 
 	if (n == MATCHFCN) {
 		mf = pmatch;
@@ -669,7 +679,7 @@
 void tfree(Cell *a)	/* free a tempcell */
 {
 	if (freeable(a)) {
-		   dprintf( ("freeing %s %s %o\n", a->nval, a->sval, a->tval) );
+		   dprintf( ("freeing %s %s %o\n", NN(a->nval), NN(a->sval), a->tval) );
 		xfree(a->sval);
 	}
 	if (a == tmps)
@@ -698,12 +708,16 @@
 
 Cell *indirect(Node **a, int n)	/* $( a[0] ) */
 {
+	Awkfloat val;
 	Cell *x;
 	int m;
 	char *s;
 
 	x = execute(a[0]);
-	m = (int) getfval(x);
+	val = getfval(x);	/* freebsd: defend against super large field numbers */
+	if ((Awkfloat)INT_MAX < val)
+		FATAL("trying to access out of range field %s", x->nval);
+	m = (int) val;
 	if (m == 0 && !is_number(s = getsval(x)))	/* suspicion! */
 		FATAL("illegal field $(%s), name \"%s\"", s, x->nval);
 		/* BUG: can x->nval ever be null??? */
@@ -790,10 +804,11 @@
 
 #define	MAXNUMSIZE	50
 
-int format(char **pbuf, int *pbufsize, char *s, Node *a)	/* printf-like conversions */
+int format(char **pbuf, int *pbufsize, const char *s, Node *a)	/* printf-like conversions */
 {
 	char *fmt;
-	char *p, *t, *os;
+	char *p, *t;
+	const char *os;
 	Cell *x;
 	int flag = 0, n;
 	int fmtwd; /* format width */
@@ -806,7 +821,7 @@
 	if ((fmt = (char *) malloc(fmtsz)) == NULL)
 		FATAL("out of memory in format()");
 	while (*s) {
-		adjbuf(&buf, &bufsize, MAXNUMSIZE+1+p-buf, recsize, &p, "format");
+		adjbuf(&buf, &bufsize, MAXNUMSIZE+1+p-buf, recsize, &p, "format1");
 		if (*s != '%') {
 			*p++ = *s++;
 			continue;
@@ -820,9 +835,9 @@
 		fmtwd = atoi(s+1);
 		if (fmtwd < 0)
 			fmtwd = -fmtwd;
-		adjbuf(&buf, &bufsize, fmtwd+1+p-buf, recsize, &p, "format");
+		adjbuf(&buf, &bufsize, fmtwd+1+p-buf, recsize, &p, "format2");
 		for (t = fmt; (*t++ = *s) != '\0'; s++) {
-			if (!adjbuf(&fmt, &fmtsz, MAXNUMSIZE+1+t-fmt, recsize, &t, 0))
+			if (!adjbuf(&fmt, &fmtsz, MAXNUMSIZE+1+t-fmt, recsize, &t, "format3"))
 				FATAL("format item %.30s... ran format() out of memory", os);
 			if (isalpha((uschar)*s) && *s != 'l' && *s != 'h' && *s != 'L')
 				break;	/* the ansi panoply */
@@ -840,31 +855,31 @@
 		*t = '\0';
 		if (fmtwd < 0)
 			fmtwd = -fmtwd;
-		adjbuf(&buf, &bufsize, fmtwd+1+p-buf, recsize, &p, "format");
+		adjbuf(&buf, &bufsize, fmtwd+1+p-buf, recsize, &p, "format4");
 
 		switch (*s) {
 		case 'f': case 'e': case 'g': case 'E': case 'G':
-			flag = 1;
+			flag = 'f';
 			break;
 		case 'd': case 'i':
-			flag = 2;
+			flag = 'd';
 			if(*(s-1) == 'l') break;
 			*(t-1) = 'l';
 			*t = 'd';
 			*++t = '\0';
 			break;
 		case 'o': case 'x': case 'X': case 'u':
-			flag = *(s-1) == 'l' ? 2 : 3;
+			flag = *(s-1) == 'l' ? 'd' : 'u';
 			break;
 		case 's':
-			flag = 4;
+			flag = 's';
 			break;
 		case 'c':
-			flag = 5;
+			flag = 'c';
 			break;
 		default:
 			WARNING("weird printf conversion %s", fmt);
-			flag = 0;
+			flag = '?';
 			break;
 		}
 		if (a == NULL)
@@ -874,38 +889,42 @@
 		n = MAXNUMSIZE;
 		if (fmtwd > n)
 			n = fmtwd;
-		adjbuf(&buf, &bufsize, 1+n+p-buf, recsize, &p, "format");
+		adjbuf(&buf, &bufsize, 1+n+p-buf, recsize, &p, "format5");
 		switch (flag) {
-		case 0:	sprintf(p, "%s", fmt);	/* unknown, so dump it too */
+		case '?':	sprintf(p, "%s", fmt);	/* unknown, so dump it too */
 			t = getsval(x);
 			n = strlen(t);
 			if (fmtwd > n)
 				n = fmtwd;
-			adjbuf(&buf, &bufsize, 1+strlen(p)+n+p-buf, recsize, &p, "format");
+			adjbuf(&buf, &bufsize, 1+strlen(p)+n+p-buf, recsize, &p, "format6");
 			p += strlen(p);
 			sprintf(p, "%s", t);
 			break;
-		case 1:	sprintf(p, fmt, getfval(x)); break;
-		case 2:	sprintf(p, fmt, (long) getfval(x)); break;
-		case 3:	sprintf(p, fmt, (int) getfval(x)); break;
-		case 4:
+		case 'f':	sprintf(p, fmt, getfval(x)); break;
+		case 'd':	sprintf(p, fmt, (long) getfval(x)); break;
+		case 'u':	sprintf(p, fmt, (int) getfval(x)); break;
+		case 's':
 			t = getsval(x);
 			n = strlen(t);
 			if (fmtwd > n)
 				n = fmtwd;
-			if (!adjbuf(&buf, &bufsize, 1+n+p-buf, recsize, &p, 0))
+			if (!adjbuf(&buf, &bufsize, 1+n+p-buf, recsize, &p, "format7"))
 				FATAL("huge string/format (%d chars) in printf %.30s... ran format() out of memory", n, t);
 			sprintf(p, fmt, t);
 			break;
-		case 5:
+		case 'c':
 			if (isnum(x)) {
 				if (getfval(x))
 					sprintf(p, fmt, (int) getfval(x));
-				else
-					*p++ = '\0';
+				else {
+					*p++ = '\0'; /* explicit null byte */
+					*p = '\0';   /* next output will start here */
+				}
 			} else
 				sprintf(p, fmt, getsval(x)[0]);
 			break;
+		default:
+			FATAL("can't happen: bad conversion %c in format()", flag);
 		}
 		tempfree(x);
 		p += strlen(p);
@@ -1210,13 +1229,13 @@
 	sep = *fs;
 	ap = execute(a[1]);	/* array name */
 	freesymtab(ap);
-	   dprintf( ("split: s=|%s|, a=%s, sep=|%s|\n", s, ap->nval, fs) );
+	   dprintf( ("split: s=|%s|, a=%s, sep=|%s|\n", s, NN(ap->nval), fs) );
 	ap->tval &= ~STR;
 	ap->tval |= ARR;
 	ap->sval = (char *) makesymtab(NSYMTAB);
 
 	n = 0;
-	if ((*s != '\0' && strlen(fs) > 1) || arg3type == REGEXPR) {	/* reg expr */
+	if (*s != '\0' && (strlen(fs) > 1 || arg3type == REGEXPR)) {	/* reg expr */
 		fa *pfa;
 		if (arg3type == REGEXPR) {	/* it's ready already */
 			pfa = (fa *) a[2];
@@ -1245,6 +1264,8 @@
 					goto spdone;
 				}
 			} while (nematch(pfa,s));
+			pfa->initstat = tempstat; 	/* bwk: has to be here to reset */
+							/* cf gsub and refldbld */
 		}
 		n++;
 		sprintf(num, "%d", n);
@@ -1448,13 +1469,18 @@
 	char *p, *buf;
 	Node *nextarg;
 	FILE *fp;
+	void flush_all(void);
 
 	t = ptoi(a[0]);
 	x = execute(a[1]);
 	nextarg = a[1]->nnext;
 	switch (t) {
 	case FLENGTH:
-		u = strlen(getsval(x)); break;
+		if (isarr(x))
+			u = ((Array *) x->sval)->nelem;	/* GROT.  should be function*/
+		else
+			u = strlen(getsval(x));
+		break;
 	case FLOG:
 		u = errcheck(log(getfval(x)), "log"); break;
 	case FINT:
@@ -1499,11 +1525,11 @@
 		if (t == FTOUPPER) {
 			for (p = buf; *p; p++)
 				if (islower((uschar) *p))
-					*p = toupper(*p);
+					*p = toupper((uschar)*p);
 		} else {
 			for (p = buf; *p; p++)
 				if (isupper((uschar) *p))
-					*p = tolower(*p);
+					*p = tolower((uschar)*p);
 		}
 		tempfree(x);
 		x = gettemp();
@@ -1511,7 +1537,10 @@
 		free(buf);
 		return x;
 	case FFLUSH:
-		if ((fp = openfile(FFLUSH, getsval(x))) == NULL)
+		if (isrec(x) || strlen(getsval(x)) == 0) {
+			flush_all();	/* fflush() or fflush("") -> all */
+			u = 0;
+		} else if ((fp = openfile(FFLUSH, getsval(x))) == NULL)
 			u = EOF;
 		else
 			u = fflush(fp);
@@ -1543,7 +1572,7 @@
 		fp = redirect(ptoi(a[1]), a[2]);
 	for (x = a[0]; x != NULL; x = x->nnext) {
 		y = execute(x);
-		fputs(getsval(y), fp);
+		fputs(getpssval(y), fp);
 		tempfree(y);
 		if (x->nnext == NULL)
 			fputs(*ORS, fp);
@@ -1582,7 +1611,7 @@
 
 struct files {
 	FILE	*fp;
-	char	*fname;
+	const char	*fname;
 	int	mode;	/* '|', 'a', 'w' => LE/LT, GT */
 } files[FOPEN_MAX] ={
 	{ NULL,  "/dev/stdin",  LT },	/* watch out: don't free this! */
@@ -1597,9 +1626,9 @@
 	files[2].fp = stderr;
 }
 
-FILE *openfile(int a, char *us)
+FILE *openfile(int a, const char *us)
 {
-	char *s = us;
+	const char *s = us;
 	int i, m;
 	FILE *fp = 0;
 
@@ -1643,7 +1672,7 @@
 	return fp;
 }
 
-char *filename(FILE *fp)
+const char *filename(FILE *fp)
 {
 	int i;
 
@@ -1700,6 +1729,15 @@
 				WARNING( "i/o error occurred while closing %s", files[i].fname );
 		}
 	}
+}
+
+void flush_all(void)
+{
+	int i;
+
+	for (i = 0; i < FOPEN_MAX; i++)
+		if (files[i].fp)
+			fflush(files[i].fp);
 }
 
 void backsub(char **pb_ptr, char **sptr_ptr);

Modified: httpd/httpd/win32-msi/trunk/awk/tran.c
URL: http://svn.apache.org/viewvc/httpd/httpd/win32-msi/trunk/awk/tran.c?rev=606942&r1=606941&r2=606942&view=diff
==============================================================================
--- httpd/httpd/win32-msi/trunk/awk/tran.c (original)
+++ httpd/httpd/win32-msi/trunk/awk/tran.c Wed Dec 26 12:15:40 2007
@@ -51,6 +51,7 @@
 Awkfloat *RSTART;	/* start of re matched with ~; origin 1 (!) */
 Awkfloat *RLENGTH;	/* length of same */
 
+Cell	*fsloc;		/* FS */
 Cell	*nrloc;		/* NR */
 Cell	*nfloc;		/* NF */
 Cell	*fnrloc;	/* FNR */
@@ -73,7 +74,8 @@
 	nullloc = setsymtab("$zero&null", "", 0.0, NUM|STR|CON|DONTFREE, symtab);
 	nullnode = celltonode(nullloc, CCON);
 
-	FS = &setsymtab("FS", " ", 0.0, STR|DONTFREE, symtab)->sval;
+	fsloc = setsymtab("FS", " ", 0.0, STR|DONTFREE, symtab);
+	FS = &fsloc->sval;
 	RS = &setsymtab("RS", "\n", 0.0, STR|DONTFREE, symtab)->sval;
 	OFS = &setsymtab("OFS", " ", 0.0, STR|DONTFREE, symtab)->sval;
 	ORS = &setsymtab("ORS", "\n", 0.0, STR|DONTFREE, symtab)->sval;
@@ -170,14 +172,17 @@
 				xfree(cp->sval);
 			temp = cp->cnext;	/* avoids freeing then using */
 			free(cp); 
+			tp->nelem--;
 		}
 		tp->tab[i] = 0;
 	}
+	if (tp->nelem != 0)
+		WARNING("can't happen: inconsistent element count freeing %s", ap->nval);
 	free(tp->tab);
 	free(tp);
 }
 
-void freeelem(Cell *ap, char *s)	/* free elem s from ap (i.e., ap["s"] */
+void freeelem(Cell *ap, const char *s)	/* free elem s from ap (i.e., ap["s"] */
 {
 	Array *tp;
 	Cell *p, *prev = NULL;
@@ -200,14 +205,14 @@
 		}
 }
 
-Cell *setsymtab(char *n, char *s, Awkfloat f, unsigned t, Array *tp)
+Cell *setsymtab(const char *n, const char *s, Awkfloat f, unsigned t, Array *tp)
 {
 	int h;
 	Cell *p;
 
 	if (n != NULL && (p = lookup(n, tp)) != NULL) {
 		   dprintf( ("setsymtab found %p: n=%s s=\"%s\" f=%g t=%o\n",
-			p, p->nval, p->sval, p->fval, p->tval) );
+			p, NN(p->nval), NN(p->sval), p->fval, p->tval) );
 		return(p);
 	}
 	p = (Cell *) malloc(sizeof(Cell));
@@ -230,7 +235,7 @@
 	return(p);
 }
 
-int hash(char *s, int n)	/* form hash value for string s */
+int hash(const char *s, int n)	/* form hash value for string s */
 {
 	unsigned hashval;
 
@@ -261,7 +266,7 @@
 	tp->size = nsz;
 }
 
-Cell *lookup(char *s, Array *tp)	/* look for s in tp */
+Cell *lookup(const char *s, Array *tp)	/* look for s in tp */
 {
 	Cell *p;
 	int h;
@@ -293,11 +298,11 @@
 		xfree(vp->sval); /* free any previous string */
 	vp->tval &= ~STR;	/* mark string invalid */
 	vp->tval |= NUM;	/* mark number ok */
-	   dprintf( ("setfval %p: %s = %g, t=%o\n", vp, vp->nval, f, vp->tval) );
+	   dprintf( ("setfval %p: %s = %g, t=%o\n", vp, NN(vp->nval), f, vp->tval) );
 	return vp->fval = f;
 }
 
-void funnyvar(Cell *vp, char *rw)
+void funnyvar(Cell *vp, const char *rw)
 {
 	if (isarr(vp))
 		FATAL("can't %s %s; it's an array name.", rw, vp->nval);
@@ -307,12 +312,13 @@
 		vp, vp->nval, vp->sval, vp->fval, vp->tval);
 }
 
-char *setsval(Cell *vp, char *s)	/* set string val of a Cell */
+char *setsval(Cell *vp, const char *s)	/* set string val of a Cell */
 {
 	char *t;
 	int fldno;
 
-	   dprintf( ("starting setsval %p: %s = \"%s\", t=%o\n", vp, vp->nval, s, vp->tval) );
+	   dprintf( ("starting setsval %p: %s = \"%s\", t=%o, r,f=%d,%d\n", 
+		vp, NN(vp->nval), s, vp->tval, donerec, donefld) );
 	if ((vp->tval & (NUM | STR)) == 0)
 		funnyvar(vp, "assign to");
 	if (isfld(vp)) {
@@ -326,12 +332,13 @@
 		donerec = 1;
 	}
 	t = tostring(s);	/* in case it's self-assign */
-	vp->tval &= ~NUM;
-	vp->tval |= STR;
 	if (freeable(vp))
 		xfree(vp->sval);
+	vp->tval &= ~NUM;
+	vp->tval |= STR;
 	vp->tval &= ~DONTFREE;
-	   dprintf( ("setsval %p: %s = \"%s (%p)\", t=%o\n", vp, vp->nval, t,t, vp->tval) );
+	   dprintf( ("setsval %p: %s = \"%s (%p) \", t=%o r,f=%d,%d\n", 
+		vp, NN(vp->nval), t,t, vp->tval, donerec, donefld) );
 	return(vp->sval = t);
 }
 
@@ -348,11 +355,11 @@
 		if (is_number(vp->sval) && !(vp->tval&CON))
 			vp->tval |= NUM;	/* make NUM only sparingly */
 	}
-	   dprintf( ("getfval %p: %s = %g, t=%o\n", vp, vp->nval, vp->fval, vp->tval) );
+	   dprintf( ("getfval %p: %s = %g, t=%o\n", vp, NN(vp->nval), vp->fval, vp->tval) );
 	return(vp->fval);
 }
 
-char *getsval(Cell *vp)	/* get string val of a Cell */
+static char *get_str_val(Cell *vp, char **fmt)        /* get string val of a Cell */
 {
 	char s[100];	/* BUG: unchecked */
 	double dtemp;
@@ -369,16 +376,27 @@
 		if (modf(vp->fval, &dtemp) == 0)	/* it's integral */
 			sprintf(s, "%.30g", vp->fval);
 		else
-			sprintf(s, *CONVFMT, vp->fval);
+			sprintf(s, *fmt, vp->fval);
 		vp->sval = tostring(s);
 		vp->tval &= ~DONTFREE;
 		vp->tval |= STR;
 	}
-	   dprintf( ("getsval %p: %s = \"%s (%p)\", t=%o\n", vp, vp->nval, vp->sval, vp->sval, vp->tval) );
+	   dprintf( ("getsval %p: %s = \"%s (%p)\", t=%o\n", vp, NN(vp->nval), vp->sval, vp->sval, vp->tval) );
 	return(vp->sval);
 }
 
-char *tostring(char *s)	/* make a copy of string s */
+char *getsval(Cell *vp)       /* get string val of a Cell */
+{
+      return get_str_val(vp, CONVFMT);
+}
+
+char *getpssval(Cell *vp)     /* get string val of a Cell for print */
+{
+      return get_str_val(vp, OFMT);
+}
+
+
+char *tostring(const char *s)	/* make a copy of string s */
 {
 	char *p;
 
@@ -389,14 +407,14 @@
 	return(p);
 }
 
-char *qstring(char *is, int delim)	/* collect string up to next delim */
+char *qstring(const char *is, int delim)	/* collect string up to next delim */
 {
-	char *os = is;
+	const char *os = is;
 	int c, n;
 	uschar *s = (uschar *) is;
 	uschar *buf, *bp;
 
-	if ((buf = (uschar *) malloc(strlen(s)+3)) == NULL)
+	if ((buf = (uschar *) malloc(strlen(is)+3)) == NULL)
 		FATAL( "out of space in qstring(%s)", s);
 	for (bp = buf; (c = *s) != delim; s++) {
 		if (c == '\n')

Added: httpd/httpd/win32-msi/trunk/awk/vcvars32.bat
URL: http://svn.apache.org/viewvc/httpd/httpd/win32-msi/trunk/awk/vcvars32.bat?rev=606942&view=auto
==============================================================================
--- httpd/httpd/win32-msi/trunk/awk/vcvars32.bat (added)
+++ httpd/httpd/win32-msi/trunk/awk/vcvars32.bat Wed Dec 26 12:15:40 2007
@@ -0,0 +1,33 @@
+@echo off
+rem
+rem Root of Visual Developer Studio Common files.
+set VSCommonDir=C:\PROGRA~1\MICROS~3\Common
+
+rem
+rem Root of Visual Developer Studio installed files.
+rem
+set MSDevDir=C:\PROGRA~1\MICROS~3\Common\msdev98
+
+rem
+rem Root of Visual C++ installed files.
+rem
+set MSVCDir=C:\PROGRA~1\MICROS~3\VC98
+
+rem
+rem VcOsDir is used to help create either a Windows 95 or Windows NT specific path.
+rem
+set VcOsDir=WIN95
+if "%OS%" == "Windows_NT" set VcOsDir=WINNT
+
+rem
+echo Setting environment for using Microsoft Visual C++ tools.
+rem
+
+if "%OS%" == "Windows_NT" set PATH=%MSDevDir%\BIN;%MSVCDir%\BIN;%VSCommonDir%\TOOLS\%VcOsDir%;%VSCommonDir%\TOOLS;%PATH%
+if "%OS%" == "" set PATH="%MSDevDir%\BIN";"%MSVCDir%\BIN";"%VSCommonDir%\TOOLS\%VcOsDir%";"%VSCommonDir%\TOOLS";"%windir%\SYSTEM";"%PATH%"
+set INCLUDE=%MSVCDir%\ATL\INCLUDE;%MSVCDir%\INCLUDE;%MSVCDir%\MFC\INCLUDE;%INCLUDE%
+set LIB=%MSVCDir%\LIB;%MSVCDir%\MFC\LIB;%LIB%
+
+set VcOsDir=
+set VSCommonDir=
+

Propchange: httpd/httpd/win32-msi/trunk/awk/vcvars32.bat
------------------------------------------------------------------------------
    svn:eol-style = native



---------------------------------------------------------------------
To unsubscribe, e-mail: win32-msi-cvs-unsubscribe@httpd.apache.org
For additional commands, e-mail: win32-msi-cvs-help@httpd.apache.org