View | Details | Raw Unified | Return to bug 125348
Collapse All | Expand All

(-)nawk/files/patch-proto.h (+10 lines)
Line 0 Link Here
1
--- proto.h.orig	2003/10/26 11:34:23	1.5
2
+++ proto.h	2007/11/06 23:07:52	1.5.22.1
3
@@ -112,6 +112,7 @@ extern	double	getfval(Cell *);
4
 extern	char	*getsval(Cell *);
5
 extern	char	*getpssval(Cell *);     /* for print */
6
 extern	char	*tostring(const char *);
7
+extern	char	*tostringN(const char *, size_t n);
8
 extern	char	*qstring(const char *, int);
9
 
10
 extern	void	recinit(unsigned int);
(-)nawk/files/patch-tran.c (+42 lines)
Line 0 Link Here
1
--- tran.c.orig	2005/07/03 15:18:11	1.6
2
+++ tran.c	2007/11/06 23:07:52	1.9.10.1
3
@@ -210,7 +210,10 @@ Cell *setsymtab(const char *n, const cha
4
 	int h;
5
 	Cell *p;
6
 
7
-	if (n != NULL && (p = lookup(n, tp)) != NULL) {
8
+	if (n == NULL)
9
+		n = "";
10
+
11
+	if ((p = lookup(n, tp)) != NULL) {
12
 		   dprintf( ("setsymtab found %p: n=%s s=\"%s\" f=%g t=%o\n",
13
 			p, NN(p->nval), NN(p->sval), p->fval, p->tval) );
14
 		return(p);
15
@@ -282,6 +285,7 @@ Awkfloat setfval(Cell *vp, Awkfloat f)	/
16
 {
17
 	int fldno;
18
 
19
+	f += 0.0;		/* normalise negative zero to positive zero */
20
 	if ((vp->tval & (NUM | STR)) == 0) 
21
 		funnyvar(vp, "assign to");
22
 	if (isfld(vp)) {
23
@@ -400,7 +404,18 @@ char *tostring(const char *s)	/* make a 
24
 {
25
 	char *p;
26
 
27
-	p = (char *) malloc(strlen(s)+1);
28
+	p = strdup(s);
29
+	if (p == NULL)
30
+		FATAL("out of space in tostring on %s", s);
31
+	strcpy(p, s);
32
+	return(p);
33
+}
34
+
35
+char *tostringN(const char *s, size_t n)	/* make a copy of string s */
36
+{
37
+	char *p;
38
+
39
+	p = malloc(n);
40
 	if (p == NULL)
41
 		FATAL("out of space in tostring on %s", s);
42
 	strcpy(p, s);

Return to bug 125348