Tue Aug 26 20:26:25 2008 UTC ()
As dholland pointed out, don't leak memory when FS needs resizing more
than once. Bump revision again.


(joerg)
diff -r1.33 -r1.34 pkgsrc/lang/nawk/Makefile
diff -r1.2 -r1.3 pkgsrc/lang/nawk/files/lib.c

cvs diff -r1.33 -r1.34 pkgsrc/lang/nawk/Makefile (expand / switch to unified diff)

--- pkgsrc/lang/nawk/Makefile 2008/08/26 14:46:21 1.33
+++ pkgsrc/lang/nawk/Makefile 2008/08/26 20:26:25 1.34
@@ -1,17 +1,17 @@ @@ -1,17 +1,17 @@
1# $NetBSD: Makefile,v 1.33 2008/08/26 14:46:21 joerg Exp $ 1# $NetBSD: Makefile,v 1.34 2008/08/26 20:26:25 joerg Exp $
2 2
3DISTNAME= nawk-20050424 3DISTNAME= nawk-20050424
4PKGREVISION= 1 4PKGREVISION= 2
5CATEGORIES= lang 5CATEGORIES= lang
6MASTER_SITES= # empty 6MASTER_SITES= # empty
7DISTFILES= # empty 7DISTFILES= # empty
8 8
9MAINTAINER= jlam@NetBSD.org 9MAINTAINER= jlam@NetBSD.org
10HOMEPAGE= http://cm.bell-labs.com/who/bwk/ 10HOMEPAGE= http://cm.bell-labs.com/who/bwk/
11COMMENT= Brian Kernighan's pattern-directed scanning and processing language 11COMMENT= Brian Kernighan's pattern-directed scanning and processing language
12 12
13PKG_INSTALLATION_TYPES= overwrite pkgviews 13PKG_INSTALLATION_TYPES= overwrite pkgviews
14PKG_DESTDIR_SUPPORT= user-destdir 14PKG_DESTDIR_SUPPORT= user-destdir
15 15
16BOOTSTRAP_PKG= yes 16BOOTSTRAP_PKG= yes
17 17

cvs diff -r1.2 -r1.3 pkgsrc/lang/nawk/files/lib.c (expand / switch to unified diff)

--- pkgsrc/lang/nawk/files/lib.c 2008/08/26 14:46:21 1.2
+++ pkgsrc/lang/nawk/files/lib.c 2008/08/26 20:26:25 1.3
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: lib.c,v 1.2 2008/08/26 14:46:21 joerg Exp $ */ 1/* $NetBSD: lib.c,v 1.3 2008/08/26 20:26:25 joerg Exp $ */
2 2
3/**************************************************************** 3/****************************************************************
4Copyright (C) Lucent Technologies 1997 4Copyright (C) Lucent Technologies 1997
5All Rights Reserved 5All Rights Reserved
6 6
7Permission to use, copy, modify, and distribute this software and 7Permission to use, copy, modify, and distribute this software and
8its documentation for any purpose and without fee is hereby 8its documentation for any purpose and without fee is hereby
9granted, provided that the above copyright notice appear in all 9granted, provided that the above copyright notice appear in all
10copies and that both that the copyright notice and this 10copies and that both that the copyright notice and this
11permission notice and warranty disclaimer appear in supporting 11permission notice and warranty disclaimer appear in supporting
12documentation, and that the name Lucent Technologies or any of 12documentation, and that the name Lucent Technologies or any of
13its entities not be used in advertising or publicity pertaining 13its entities not be used in advertising or publicity pertaining
14to distribution of the software without specific, written prior 14to distribution of the software without specific, written prior
@@ -183,26 +183,28 @@ void nextfile(void) @@ -183,26 +183,28 @@ void nextfile(void)
183 argno++; 183 argno++;
184} 184}
185 185
186int readrec(char **pbuf, int *pbufsize, FILE *inf) /* read one record into buf */ 186int readrec(char **pbuf, int *pbufsize, FILE *inf) /* read one record into buf */
187{ 187{
188 int sep, c; 188 int sep, c;
189 char *rr, *buf = *pbuf; 189 char *rr, *buf = *pbuf;
190 int bufsize = *pbufsize; 190 int bufsize = *pbufsize;
191 size_t len; 191 size_t len;
192 192
193 if ((len = strlen(*FS)) <= len_inputFS) { 193 if ((len = strlen(*FS)) <= len_inputFS) {
194 strcpy(inputFS, *FS); /* for subsequent field splitting */ 194 strcpy(inputFS, *FS); /* for subsequent field splitting */
195 } else { 195 } else {
 196 if (inputFS != static_inputFS)
 197 free(inputFS);
196 inputFS = malloc(len + 1); 198 inputFS = malloc(len + 1);
197 if (inputFS == NULL) 199 if (inputFS == NULL)
198 FATAL("field separator %.10s... is too long", *FS); 200 FATAL("field separator %.10s... is too long", *FS);
199 len_inputFS = len; 201 len_inputFS = len;
200 memcpy(inputFS, *FS, len + 1); 202 memcpy(inputFS, *FS, len + 1);
201 } 203 }
202 if ((sep = **RS) == 0) { 204 if ((sep = **RS) == 0) {
203 sep = '\n'; 205 sep = '\n';
204 while ((c=getc(inf)) == '\n' && c != EOF) /* skip leading \n's */ 206 while ((c=getc(inf)) == '\n' && c != EOF) /* skip leading \n's */
205 ; 207 ;
206 if (c != EOF) 208 if (c != EOF)
207 ungetc(c, inf); 209 ungetc(c, inf);
208 } 210 }