aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXin LI <delphij@FreeBSD.org>2013-01-02 21:53:45 +0000
committerXin LI <delphij@FreeBSD.org>2013-01-02 21:53:45 +0000
commitc323c12cd8cea3384b83ddef0592138f8eccbe70 (patch)
treeedbe0c815ff6e60da0ddf4265407ce18f44b668f
parentb0f5e94e3f34717e78a265dc61c6c45406a258d0 (diff)
downloadsrc-c323c12cd8cea3384b83ddef0592138f8eccbe70.tar.gz
src-c323c12cd8cea3384b83ddef0592138f8eccbe70.zip
Vendor import of bwk's Dec 20, 2012 version.vendor/one-true-awk/20121220
Notes
Notes: svn path=/vendor/one-true-awk/dist/; revision=244978 svn path=/vendor/one-true-awk/20121220/; revision=244979; tag=vendor/one-true-awk/20121220
-rw-r--r--FIXES16
-rw-r--r--main.c2
-rw-r--r--makefile10
-rw-r--r--proto.h4
-rw-r--r--run.c5
-rw-r--r--tran.c2
6 files changed, 29 insertions, 10 deletions
diff --git a/FIXES b/FIXES
index a708027461ce..c78aabc511f3 100644
--- a/FIXES
+++ b/FIXES
@@ -25,6 +25,22 @@ THIS SOFTWARE.
This file lists all bug fixes, changes, etc., made since the AWK book
was sent to the printers in August, 1987.
+Dec 20, 2012:
+ fiddled makefile to get correct yacc and bison flags. pick yacc
+ (linux) or bison (mac) as necessary.
+
+ added __attribute__((__noreturn__)) to a couple of lines in
+ proto.h, to silence someone's enthusiastic checker.
+
+ fixed obscure call by value bug in split(a[1],a) reported on
+ 9fans. the management of temporary values is just a mess; i
+ took a shortcut by making an extra string copy. thanks
+ to paul patience and arnold robbins for passing it on and for
+ proposed patches.
+
+ tiny fiddle in setfval to eliminate -0 results in T.expr, which
+ has irritated me for 20+ years.
+
Aug 10, 2011:
another fix to avoid core dump with delete(ARGV); again, many thanks
to ruslan ermilov.
diff --git a/main.c b/main.c
index 3c4dbf56af33..4b659974b056 100644
--- a/main.c
+++ b/main.c
@@ -22,7 +22,7 @@ ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
THIS SOFTWARE.
****************************************************************/
-const char *version = "version 20110810";
+const char *version = "version 20121220";
#define DEBUG
#include <stdio.h>
diff --git a/makefile b/makefile
index 52c7424b34c1..88f992421561 100644
--- a/makefile
+++ b/makefile
@@ -26,15 +26,15 @@ CFLAGS = -g
CFLAGS = -O2
CFLAGS =
-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 -g -Wall -pedantic
CC = gcc -O4 -Wall -pedantic -fno-strict-aliasing
-YACC = bison -y
-YACC = yacc
-YFLAGS = -d
+YACC = bison -d -y
+YACC = yacc -d -S
+#YFLAGS = -d -S
+ # -S uses sprintf in yacc parser instead of sprint
OFILES = b.o main.o parse.o proctab.o tran.o lib.o run.o lex.o
diff --git a/proto.h b/proto.h
index e4de112723f4..9a657ef73ec1 100644
--- a/proto.h
+++ b/proto.h
@@ -46,7 +46,7 @@ extern void freetr(Node *);
extern int hexstr(uschar **);
extern int quoted(uschar **);
extern char *cclenter(const char *);
-extern void overflo(const char *);
+extern void overflo(const char *) __attribute__((__noreturn__));
extern void cfoll(fa *, Node *);
extern int first(Node *);
extern void follow(Node *);
@@ -132,7 +132,7 @@ extern void fpecatch(int);
extern void bracecheck(void);
extern void bcheck2(int, int, int);
extern void SYNTAX(const char *, ...);
-extern void FATAL(const char *, ...);
+extern void FATAL(const char *, ...) __attribute__((__noreturn__));
extern void WARNING(const char *, ...);
extern void error(void);
extern void eprint(void);
diff --git a/run.c b/run.c
index 553081f0fced..6c4ce10a2eeb 100644
--- a/run.c
+++ b/run.c
@@ -1210,13 +1210,13 @@ Cell *dopa2(Node **a, int n) /* a[0], a[1] { a[2] } */
Cell *split(Node **a, int nnn) /* split(a[0], a[1], a[2]); a[3] is type */
{
Cell *x = 0, *y, *ap;
- char *s;
+ char *s, *origs;
int sep;
char *t, temp, num[50], *fs = 0;
int n, tempstat, arg3type;
y = execute(a[0]); /* source string */
- s = getsval(y);
+ origs = s = strdup(getsval(y));
arg3type = ptoi(a[3]);
if (a[2] == 0) /* fs string */
fs = *FS;
@@ -1336,6 +1336,7 @@ Cell *split(Node **a, int nnn) /* split(a[0], a[1], a[2]); a[3] is type */
}
tempfree(ap);
tempfree(y);
+ free(origs);
if (a[2] != 0 && arg3type == STRING) {
tempfree(x);
}
diff --git a/tran.c b/tran.c
index e9d77506a34d..a9fa3259f437 100644
--- a/tran.c
+++ b/tran.c
@@ -298,6 +298,8 @@ Awkfloat setfval(Cell *vp, Awkfloat f) /* set float val of a Cell */
xfree(vp->sval); /* free any previous string */
vp->tval &= ~STR; /* mark string invalid */
vp->tval |= NUM; /* mark number ok */
+ if (f == -0) /* who would have thought this possible? */
+ f = 0;
dprintf( ("setfval %p: %s = %g, t=%o\n", (void*)vp, NN(vp->nval), f, vp->tval) );
return vp->fval = f;
}