Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 3 May 2011 11:47:19 +0000 (UTC)
From:      Ruslan Ermilov <ru@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r221381 - head/contrib/one-true-awk
Message-ID:  <201105031147.p43BlJjR091843@svn.freebsd.org>

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

Log:
  Update to a 1-May-2011 release (except for the isblank change).

Modified:
  head/contrib/one-true-awk/FIXES
  head/contrib/one-true-awk/README
  head/contrib/one-true-awk/b.c
  head/contrib/one-true-awk/lib.c
  head/contrib/one-true-awk/main.c
  head/contrib/one-true-awk/makefile
  head/contrib/one-true-awk/run.c
Directory Properties:
  head/contrib/one-true-awk/   (props changed)

Modified: head/contrib/one-true-awk/FIXES
==============================================================================
--- head/contrib/one-true-awk/FIXES	Tue May  3 11:39:00 2011	(r221380)
+++ head/contrib/one-true-awk/FIXES	Tue May  3 11:47:19 2011	(r221381)
@@ -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: head/contrib/one-true-awk/README
==============================================================================
--- head/contrib/one-true-awk/README	Tue May  3 11:39:00 2011	(r221380)
+++ head/contrib/one-true-awk/README	Tue May  3 11:47:19 2011	(r221381)
@@ -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: head/contrib/one-true-awk/b.c
==============================================================================
--- head/contrib/one-true-awk/b.c	Tue May  3 11:39:00 2011	(r221380)
+++ head/contrib/one-true-awk/b.c	Tue May  3 11:47:19 2011	(r221381)
@@ -752,7 +752,7 @@ Node *unary(Node *np)
 /* #define HAS_ISBLANK */
 #ifndef HAS_ISBLANK
 
-int (isblank)(int c)
+int (xisblank)(int c)
 {
 	return c==' ' || c=='\t';
 }
@@ -766,7 +766,11 @@ struct charclass {
 } charclasses[] = {
 	{ "alnum",	5,	isalnum },
 	{ "alpha",	5,	isalpha },
+#ifndef HAS_ISBLANK
+	{ "blank",	5,	isspace }, /* was isblank */
+#else
 	{ "blank",	5,	isblank },
+#endif
 	{ "cntrl",	5,	iscntrl },
 	{ "digit",	5,	isdigit },
 	{ "graph",	5,	isgraph },

Modified: head/contrib/one-true-awk/lib.c
==============================================================================
--- head/contrib/one-true-awk/lib.c	Tue May  3 11:39:00 2011	(r221380)
+++ head/contrib/one-true-awk/lib.c	Tue May  3 11:47:19 2011	(r221381)
@@ -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: head/contrib/one-true-awk/main.c
==============================================================================
--- head/contrib/one-true-awk/main.c	Tue May  3 11:39:00 2011	(r221380)
+++ head/contrib/one-true-awk/main.c	Tue May  3 11:47:19 2011	(r221381)
@@ -25,7 +25,7 @@ THIS SOFTWARE.
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD$");
 
-const char	*version = "version 20091126 (FreeBSD)";
+const char	*version = "version 20110501 (FreeBSD)";
 
 #define DEBUG
 #include <stdio.h>
@@ -41,6 +41,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 */
@@ -71,6 +72,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') {
@@ -120,14 +125,10 @@ int main(int argc, char *argv[])
 				WARNING("field separator FS is empty");
 			break;
 		case 'v':	/* -v a=1 to be done NOW.  one -v for each */
-			if (argv[1][2] != 0) {	/* arg is -vsomething */
-				if (argv[1][2] != 0)
-					setclvar(&argv[1][2]);
-			} else {		/* arg is -v something */
-				argc--; argv++;
-				if (argc > 1 && isclvar(argv[1]))
-					setclvar(argv[1]);
-			}
+			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: head/contrib/one-true-awk/makefile
==============================================================================
--- head/contrib/one-true-awk/makefile	Tue May  3 11:39:00 2011	(r221380)
+++ head/contrib/one-true-awk/makefile	Tue May  3 11:47:19 2011	(r221381)
@@ -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: head/contrib/one-true-awk/run.c
==============================================================================
--- head/contrib/one-true-awk/run.c	Tue May  3 11:39:00 2011	(r221380)
+++ head/contrib/one-true-awk/run.c	Tue May  3 11:47:19 2011	(r221381)
@@ -69,6 +69,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 */
@@ -1469,6 +1470,7 @@ Cell *bltin(Node **a, int n)	/* builtin 
 	Cell *x, *y;
 	Awkfloat u;
 	int t;
+	Awkfloat tmp;
 	char *p, *buf;
 	Node *nextarg;
 	FILE *fp;
@@ -1520,7 +1522,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:
@@ -1890,9 +1895,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?201105031147.p43BlJjR091843>