summaryrefslogtreecommitdiff
path: root/usr/src
diff options
context:
space:
mode:
authornakanon <none@none>2006-08-25 11:18:25 -0700
committernakanon <none@none>2006-08-25 11:18:25 -0700
commit8ef4c21a581c38a44ac18b7363c4928cb3222303 (patch)
tree3b6bb4a7d6e76e0b306c125e7275425045123dd4 /usr/src
parenta45425f41711cb2537626070b6729a455bce89dc (diff)
downloadillumos-joyent-8ef4c21a581c38a44ac18b7363c4928cb3222303.tar.gz
6446725 After 111111-06, nawk gets "out of space in adjust_buf"
Diffstat (limited to 'usr/src')
-rw-r--r--usr/src/cmd/awk/awk.h8
-rw-r--r--usr/src/cmd/awk/lib.c30
-rw-r--r--usr/src/cmd/awk/tran.c21
3 files changed, 22 insertions, 37 deletions
diff --git a/usr/src/cmd/awk/awk.h b/usr/src/cmd/awk/awk.h
index 808c3282b8..fa5b3df0e2 100644
--- a/usr/src/cmd/awk/awk.h
+++ b/usr/src/cmd/awk/awk.h
@@ -2,9 +2,8 @@
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
@@ -21,7 +20,7 @@
*/
/*
- * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -296,7 +295,6 @@ extern void r_expand_buf(uchar **, size_t *, size_t);
extern int donefld;
extern int donerec;
-extern uchar *recdata;
extern uchar *record;
extern size_t record_size;
diff --git a/usr/src/cmd/awk/lib.c b/usr/src/cmd/awk/lib.c
index 063883122a..ded064c6c3 100644
--- a/usr/src/cmd/awk/lib.c
+++ b/usr/src/cmd/awk/lib.c
@@ -2,9 +2,8 @@
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
@@ -21,7 +20,7 @@
*/
/*
- * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -34,7 +33,6 @@
#include "awk.h"
#include "y.tab.h"
-uchar *recdata;
uchar *record;
size_t record_size;
@@ -124,7 +122,7 @@ getrec(uchar **bufp, size_t *bufsizep)
free(nbuf);
if (c != 0 || buf[0] != '\0') { /* normal record */
- if (buf == record) {
+ if (bufp == &record) {
if (!(recloc->tval & DONTFREE))
xfree(recloc->sval);
recloc->sval = record;
@@ -466,34 +464,28 @@ recbld(void)
int i;
uchar *p;
size_t cnt, len, olen;
- static uchar *rec;
- size_t osize, nsize;
if (donerec == 1)
return;
- /* sync up rec size */
- adjust_buf(&rec, record_size);
cnt = 0;
olen = strlen((char *)*OFS);
for (i = 1; i <= *NF; i++) {
p = getsval(getfld(i));
len = strlen((char *)p);
- osize = record_size;
- nsize = cnt + len + olen;
- expand_buf(&rec, &record_size, nsize);
- if (osize != record_size)
- adjust_buf(&recdata, record_size);
- (void) memcpy(&rec[cnt], p, len);
+ expand_buf(&record, &record_size, cnt + len + olen);
+ (void) memcpy(&record[cnt], p, len);
cnt += len;
if (i < *NF) {
- (void) memcpy(&rec[cnt], *OFS, olen);
+ (void) memcpy(&record[cnt], *OFS, olen);
cnt += olen;
}
}
- rec[cnt] = '\0';
+ record[cnt] = '\0';
dprintf(("in recbld FS=%o, recloc=%p\n", **FS, (void *)recloc));
+ if (!(recloc->tval & DONTFREE))
+ xfree(recloc->sval);
recloc->tval = REC | STR | DONTFREE;
- recloc->sval = record = rec;
+ recloc->sval = record;
dprintf(("in recbld FS=%o, recloc=%p\n", **FS, (void *)recloc));
dprintf(("recbld = |%s|\n", record));
donerec = 1;
diff --git a/usr/src/cmd/awk/tran.c b/usr/src/cmd/awk/tran.c
index 0541e62b67..e8e42d780e 100644
--- a/usr/src/cmd/awk/tran.c
+++ b/usr/src/cmd/awk/tran.c
@@ -2,9 +2,8 @@
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
@@ -21,7 +20,7 @@
*/
/*
- * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -75,16 +74,13 @@ static void rehash(Array *);
void
syminit(void)
{
- Cell *p;
+ init_buf(&record, &record_size, LINE_INCR);
- init_buf(&recdata, &record_size, LINE_INCR);
- record = recdata;
-
- p = getfld(0);
/* initialize $0 */
- p->nval = (uchar*) "$0";
- p->sval = recdata;
- p->tval = REC|STR|DONTFREE;
+ recloc = getfld(0);
+ recloc->nval = (uchar *)"$0";
+ recloc->sval = record;
+ recloc->tval = REC|STR|DONTFREE;
symtab = makesymtab(NSYMTAB);
(void) setsymtab((uchar *)"0", (uchar *)"0", 0.0,
@@ -93,7 +89,6 @@ syminit(void)
nullloc = setsymtab((uchar *)"$zero&null", (uchar *)"", 0.0,
NUM|STR|CON|DONTFREE, symtab);
nullnode = valtonode(nullloc, CCON);
- recloc = getfld(0);
FS = &setsymtab((uchar *)"FS", (uchar *)" ", 0.0,
STR|DONTFREE, symtab)->sval;
RS = &setsymtab((uchar *)"RS", (uchar *)"\n", 0.0,