pkgsrc-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[pkgsrc/trunk]: pkgsrc/lang/nawk Remove hard-coded limit on FS. Merge minor p...
details: https://anonhg.NetBSD.org/pkgsrc/rev/461617a45ac0
branches: trunk
changeset: 546295:461617a45ac0
user: joerg <joerg%pkgsrc.org@localhost>
date: Tue Aug 26 14:46:21 2008 +0000
description:
Remove hard-coded limit on FS. Merge minor performance improvements.
Bump revision.
diffstat:
lang/nawk/Makefile | 3 ++-
lang/nawk/files/awk.h | 3 +--
lang/nawk/files/lib.c | 21 +++++++++++++++------
lang/nawk/files/tran.c | 3 +--
4 files changed, 19 insertions(+), 11 deletions(-)
diffs (96 lines):
diff -r 4c5f8590fb0e -r 461617a45ac0 lang/nawk/Makefile
--- a/lang/nawk/Makefile Tue Aug 26 14:45:19 2008 +0000
+++ b/lang/nawk/Makefile Tue Aug 26 14:46:21 2008 +0000
@@ -1,6 +1,7 @@
-# $NetBSD: Makefile,v 1.32 2008/06/19 18:36:51 joerg Exp $
+# $NetBSD: Makefile,v 1.33 2008/08/26 14:46:21 joerg Exp $
DISTNAME= nawk-20050424
+PKGREVISION= 1
CATEGORIES= lang
MASTER_SITES= # empty
DISTFILES= # empty
diff -r 4c5f8590fb0e -r 461617a45ac0 lang/nawk/files/awk.h
--- a/lang/nawk/files/awk.h Tue Aug 26 14:45:19 2008 +0000
+++ b/lang/nawk/files/awk.h Tue Aug 26 14:46:21 2008 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: awk.h,v 1.1 2006/07/14 14:23:06 jlam Exp $ */
+/* $NetBSD: awk.h,v 1.2 2008/08/26 14:46:21 joerg Exp $ */
/****************************************************************
Copyright (C) Lucent Technologies 1997
@@ -68,7 +68,6 @@
extern int errorflag; /* 1 if error has occurred */
extern int donefld; /* 1 if record broken into fields */
extern int donerec; /* 1 if record is valid (no fld has changed */
-extern char inputFS[]; /* FS at time of input, for field splitting */
extern int dbg;
diff -r 4c5f8590fb0e -r 461617a45ac0 lang/nawk/files/lib.c
--- a/lang/nawk/files/lib.c Tue Aug 26 14:45:19 2008 +0000
+++ b/lang/nawk/files/lib.c Tue Aug 26 14:46:21 2008 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lib.c,v 1.1 2006/07/14 14:23:06 jlam Exp $ */
+/* $NetBSD: lib.c,v 1.2 2008/08/26 14:46:21 joerg Exp $ */
/****************************************************************
Copyright (C) Lucent Technologies 1997
@@ -42,7 +42,9 @@
int fieldssize = RECSIZE;
Cell **fldtab; /* pointers to Cells */
-char inputFS[100] = " ";
+char static_inputFS[16] = " ";
+size_t len_inputFS = sizeof(static_inputFS) - 1;
+char *inputFS = static_inputFS;
#define MAXFLD 200
int nfields = MAXFLD; /* last allocated slot for $i */
@@ -186,10 +188,17 @@
int sep, c;
char *rr, *buf = *pbuf;
int bufsize = *pbufsize;
+ size_t len;
- if (strlen(*FS) >= sizeof(inputFS))
- FATAL("field separator %.10s... is too long", *FS);
- strcpy(inputFS, *FS); /* for subsequent field splitting */
+ if ((len = strlen(*FS)) <= len_inputFS) {
+ strcpy(inputFS, *FS); /* for subsequent field splitting */
+ } else {
+ inputFS = malloc(len + 1);
+ if (inputFS == NULL)
+ FATAL("field separator %.10s... is too long", *FS);
+ len_inputFS = len;
+ memcpy(inputFS, *FS, len + 1);
+ }
if ((sep = **RS) == 0) {
sep = '\n';
while ((c=getc(inf)) == '\n' && c != EOF) /* skip leading \n's */
@@ -276,7 +285,7 @@
}
fr = fields;
i = 0; /* number of fields accumulated here */
- if (strlen(inputFS) > 1) { /* it's a regular expression */
+ if (inputFS[0] && inputFS[1]) { /* it's a regular expression */
i = refldbld(r, inputFS);
} else if ((sep = *inputFS) == ' ') { /* default whitespace */
for (i = 0; ; ) {
diff -r 4c5f8590fb0e -r 461617a45ac0 lang/nawk/files/tran.c
--- a/lang/nawk/files/tran.c Tue Aug 26 14:45:19 2008 +0000
+++ b/lang/nawk/files/tran.c Tue Aug 26 14:46:21 2008 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: tran.c,v 1.1 2006/07/14 14:23:06 jlam Exp $ */
+/* $NetBSD: tran.c,v 1.2 2008/08/26 14:46:21 joerg Exp $ */
/****************************************************************
Copyright (C) Lucent Technologies 1997
@@ -405,7 +405,6 @@
p = (char *) malloc(strlen(s)+1);
if (p == NULL)
FATAL("out of space in tostring on %s", s);
- strcpy(p, s);
return(p);
}
Home |
Main Index |
Thread Index |
Old Index