Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 3 May 2011 11:37:03 +0000 (UTC)
From:      Ruslan Ermilov <ru@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-vendor@freebsd.org
Subject:   svn commit: r221379 - vendor/one-true-awk/dist
Message-ID:  <201105031137.p43Bb32Q091458@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: ru
Date: Tue May  3 11:37:03 2011
New Revision: 221379
URL: http://svn.freebsd.org/changeset/base/221379

Log:
  Vendor import of bwk's 1-May-2011 release.

Modified:
  vendor/one-true-awk/dist/FIXES
  vendor/one-true-awk/dist/README
  vendor/one-true-awk/dist/b.c
  vendor/one-true-awk/dist/lib.c
  vendor/one-true-awk/dist/main.c
  vendor/one-true-awk/dist/makefile
  vendor/one-true-awk/dist/run.c

Modified: vendor/one-true-awk/dist/FIXES
==============================================================================
--- vendor/one-true-awk/dist/FIXES	Tue May  3 11:23:40 2011	(r221378)
+++ vendor/one-true-awk/dist/FIXES	Tue May  3 11:37:03 2011	(r221379)
@@ -25,6 +25,32 @@ THIS SOFTWARE.
 This file lists all bug fixes, changes, etc., made since the AWK book
 was sent to the printers in August, 1987.
 
+May 1, 2011:
+	after advice from todd miller, kevin lo, ruslan ermilov,
+	and arnold robbins, changed srand() to return the previous
+	seed (which is 1 on the first call of srand).  the seed is
+	an Awkfloat internally though converted to unsigned int to
+	pass to the library srand().  thanks, everyone. 
+
+	fixed a subtle (and i hope low-probability) overflow error
+	in fldbld, by adding space for one extra \0.  thanks to 
+	robert bassett for spotting this one and providing a fix.
+
+	removed the files related to compilation on windows.  i no
+	longer have anything like a current windows environment, so
+	i can't test any of it.
+
+May 23, 2010:
+	fixed long-standing overflow bug in run.c; many thanks to
+	nelson beebe for spotting it and providing the fix.
+
+	fixed bug that didn't parse -vd=1 properly; thanks to santiago
+	vila for spotting it.
+
+Feb 8, 2010:
+	i give up.  replaced isblank with isspace in b.c; there are
+	no consistent header files.
+
 Nov 26, 2009:
 	fixed a long-standing issue with when FS takes effect.  a
 	change to FS is now noticed immediately for subsequent splits.

Modified: vendor/one-true-awk/dist/README
==============================================================================
--- vendor/one-true-awk/dist/README	Tue May  3 11:23:40 2011	(r221378)
+++ vendor/one-true-awk/dist/README	Tue May  3 11:37:03 2011	(r221379)
@@ -29,7 +29,7 @@ by Al Aho, Brian Kernighan, and Peter We
 Changes, mostly bug fixes and occasional enhancements, are listed
 in FIXES.  If you distribute this code further, please please please
 distribute FIXES with it.  If you find errors, please report them
-to bwk@bell-labs.com.  Thanks.
+to bwk@cs.princeton.edu.  Thanks.
 
 The program itself is created by
 	make

Modified: vendor/one-true-awk/dist/b.c
==============================================================================
--- vendor/one-true-awk/dist/b.c	Tue May  3 11:23:40 2011	(r221378)
+++ vendor/one-true-awk/dist/b.c	Tue May  3 11:37:03 2011	(r221379)
@@ -734,7 +734,7 @@ Node *unary(Node *np)
 /* #define HAS_ISBLANK */
 #ifndef HAS_ISBLANK
 
-int (isblank)(int c)
+int (xisblank)(int c)
 {
 	return c==' ' || c=='\t';
 }
@@ -748,7 +748,7 @@ struct charclass {
 } charclasses[] = {
 	{ "alnum",	5,	isalnum },
 	{ "alpha",	5,	isalpha },
-	{ "blank",	5,	isblank },
+	{ "blank",	5,	isspace }, /* was isblank */
 	{ "cntrl",	5,	iscntrl },
 	{ "digit",	5,	isdigit },
 	{ "graph",	5,	isgraph },

Modified: vendor/one-true-awk/dist/lib.c
==============================================================================
--- vendor/one-true-awk/dist/lib.c	Tue May  3 11:23:40 2011	(r221378)
+++ vendor/one-true-awk/dist/lib.c	Tue May  3 11:37:03 2011	(r221379)
@@ -256,6 +256,7 @@ void fldbld(void)	/* create fields from 
 {
 	/* this relies on having fields[] the same length as $0 */
 	/* the fields are all stored in this one array with \0's */
+	/* possibly with a final trailing \0 not associated with any field */
 	char *r, *fr, sep;
 	Cell *p;
 	int i, j, n;
@@ -268,7 +269,7 @@ void fldbld(void)	/* create fields from 
 	n = strlen(r);
 	if (n > fieldssize) {
 		xfree(fields);
-		if ((fields = (char *) malloc(n+1)) == NULL)
+		if ((fields = (char *) malloc(n+2)) == NULL) /* possibly 2 final \0s */
 			FATAL("out of space for fields in fldbld %d", n);
 		fieldssize = n;
 	}

Modified: vendor/one-true-awk/dist/main.c
==============================================================================
--- vendor/one-true-awk/dist/main.c	Tue May  3 11:23:40 2011	(r221378)
+++ vendor/one-true-awk/dist/main.c	Tue May  3 11:37:03 2011	(r221379)
@@ -22,7 +22,7 @@ ARISING OUT OF OR IN CONNECTION WITH THE
 THIS SOFTWARE.
 ****************************************************************/
 
-const char	*version = "version 20091126";
+const char	*version = "version 20110501";
 
 #define DEBUG
 #include <stdio.h>
@@ -38,6 +38,7 @@ extern	char	**environ;
 extern	int	nfields;
 
 int	dbg	= 0;
+Awkfloat	srand_seed = 1;
 char	*cmdname;	/* gets argv[0] for error messages */
 extern	FILE	*yyin;	/* lex input file */
 char	*lexprog;	/* points to program argument if it exists */
@@ -67,6 +68,10 @@ int main(int argc, char *argv[])
 		exit(1);
 	}
 	signal(SIGFPE, fpecatch);
+
+	srand_seed = 1;
+	srand(srand_seed);
+
 	yyin = NULL;
 	symtab = makesymtab(NSYMTAB/NSYMTAB);
 	while (argc > 1 && argv[1][0] == '-' && argv[1][1] != '\0') {
@@ -113,6 +118,8 @@ int main(int argc, char *argv[])
 		case 'v':	/* -v a=1 to be done NOW.  one -v for each */
 			if (argv[1][2] == '\0' && --argc > 1 && isclvar((++argv)[1]))
 				setclvar(argv[1]);
+			else if (argv[1][2] != '\0')
+				setclvar(&argv[1][2]);
 			break;
 		case 'd':
 			dbg = atoi(&argv[1][2]);

Modified: vendor/one-true-awk/dist/makefile
==============================================================================
--- vendor/one-true-awk/dist/makefile	Tue May  3 11:23:40 2011	(r221378)
+++ vendor/one-true-awk/dist/makefile	Tue May  3 11:37:03 2011	(r221379)
@@ -26,13 +26,12 @@ CFLAGS = -g
 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 = cc
+CC = gcc -Wall -g -Wwrite-strings
+CC = gcc -fprofile-arcs -ftest-coverage # then gcov f1.c; cat f1.c.gcov
 CC = gcc -O4
 
-
 YACC = bison -y
 YACC = yacc
 YFLAGS = -d
@@ -40,13 +39,13 @@ YFLAGS = -d
 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
+	maketab.c parse.c lib.c run.c tran.c proctab.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
+	lib.c run.c tran.c 
 
-SHIP = README FIXES $(SOURCE) ytab[ch].bak makefile makefile.win \
-	vcvars32.bat buildwin.bat awk.1
+SHIP = README FIXES $(SOURCE) ytab[ch].bak makefile  \
+	 awk.1
 
 a.out:	ytab.o $(OFILES)
 	$(CC) $(CFLAGS) ytab.o $(OFILES) $(ALLOC)  -lm

Modified: vendor/one-true-awk/dist/run.c
==============================================================================
--- vendor/one-true-awk/dist/run.c	Tue May  3 11:23:40 2011	(r221378)
+++ vendor/one-true-awk/dist/run.c	Tue May  3 11:37:03 2011	(r221379)
@@ -66,6 +66,7 @@ void tempfree(Cell *p) {
 
 jmp_buf env;
 extern	int	pairstack[];
+extern	Awkfloat	srand_seed;
 
 Node	*winner = NULL;	/* root of parse tree */
 Cell	*tmps;		/* free temporary cells for execution */
@@ -1466,6 +1467,7 @@ Cell *bltin(Node **a, int n)	/* builtin 
 	Cell *x, *y;
 	Awkfloat u;
 	int t;
+	Awkfloat tmp;
 	char *p, *buf;
 	Node *nextarg;
 	FILE *fp;
@@ -1517,7 +1519,10 @@ Cell *bltin(Node **a, int n)	/* builtin 
 			u = time((time_t *)0);
 		else
 			u = getfval(x);
+		tmp = u;
 		srand((unsigned int) u);
+		u = srand_seed;
+		srand_seed = tmp;
 		break;
 	case FTOUPPER:
 	case FTOLOWER:
@@ -1887,9 +1892,10 @@ Cell *gsub(Node **a, int nnn)	/* global 
 		adjbuf(&buf, &bufsz, 1+strlen(sptr)+pb-buf, 0, &pb, "gsub");
 		while ((*pb++ = *sptr++) != 0)
 			;
-	done:	if (pb > buf + bufsz)
-			FATAL("gsub result2 %.30s too big; can't happen", buf);
-		*pb = '\0';
+	done:	if (pb < buf + bufsz)
+			*pb = '\0';
+		else if (*(pb-1) != '\0')
+			FATAL("gsub result2 %.30s truncated; can't happen", buf);
 		setsval(x, buf);	/* BUG: should be able to avoid copy + free */
 		pfa->initstat = tempstat;
 	}



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201105031137.p43Bb32Q091458>