Module Name: src Committed By: asau Date: Sun Mar 1 00:51:08 UTC 2015
Modified Files: src/usr.bin/sed: compile.c extern.h process.c Log Message: Move run-time data structures into processing part. To generate a diff of this commit: cvs rdiff -u -r1.44 -r1.45 src/usr.bin/sed/compile.c cvs rdiff -u -r1.16 -r1.17 src/usr.bin/sed/extern.h cvs rdiff -u -r1.48 -r1.49 src/usr.bin/sed/process.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/usr.bin/sed/compile.c diff -u src/usr.bin/sed/compile.c:1.44 src/usr.bin/sed/compile.c:1.45 --- src/usr.bin/sed/compile.c:1.44 Sat Feb 28 21:56:53 2015 +++ src/usr.bin/sed/compile.c Sun Mar 1 00:51:08 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: compile.c,v 1.44 2015/02/28 21:56:53 asau Exp $ */ +/* $NetBSD: compile.c,v 1.45 2015/03/01 00:51:08 asau Exp $ */ /*- * Copyright (c) 1992 Diomidis Spinellis. @@ -38,7 +38,7 @@ #endif #include <sys/cdefs.h> -__RCSID("$NetBSD: compile.c,v 1.44 2015/02/28 21:56:53 asau Exp $"); +__RCSID("$NetBSD: compile.c,v 1.45 2015/03/01 00:51:08 asau Exp $"); #ifdef __FBSDID __FBSDID("$FreeBSD: head/usr.bin/sed/compile.c 259132 2013-12-09 18:57:20Z eadler $"); #endif @@ -154,9 +154,6 @@ compile(void) *compile_stream(&prog) = NULL; fixuplabel(prog, NULL); uselabel(); - if (appendnum > 0) - appends = xmalloc(sizeof(struct s_appends) * appendnum); - match = xmalloc((maxnsub + 1) * sizeof(regmatch_t)); } #define EATSPACE() do { \ Index: src/usr.bin/sed/extern.h diff -u src/usr.bin/sed/extern.h:1.16 src/usr.bin/sed/extern.h:1.17 --- src/usr.bin/sed/extern.h:1.16 Sun Mar 1 00:38:01 2015 +++ src/usr.bin/sed/extern.h Sun Mar 1 00:51:08 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: extern.h,v 1.16 2015/03/01 00:38:01 asau Exp $ */ +/* $NetBSD: extern.h,v 1.17 2015/03/01 00:51:08 asau Exp $ */ /*- * Copyright (c) 1992 Diomidis Spinellis. @@ -56,8 +56,6 @@ struct s_flist { extern struct s_compunit *script; extern struct s_flist *files; extern struct s_command *prog; -extern struct s_appends *appends; -extern regmatch_t *match; extern size_t maxnsub; extern size_t appendnum; extern int aflag, nflag; Index: src/usr.bin/sed/process.c diff -u src/usr.bin/sed/process.c:1.48 src/usr.bin/sed/process.c:1.49 --- src/usr.bin/sed/process.c:1.48 Sun Mar 1 00:38:01 2015 +++ src/usr.bin/sed/process.c Sun Mar 1 00:51:08 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: process.c,v 1.48 2015/03/01 00:38:01 asau Exp $ */ +/* $NetBSD: process.c,v 1.49 2015/03/01 00:51:08 asau Exp $ */ /*- * Copyright (c) 1992 Diomidis Spinellis. @@ -38,7 +38,7 @@ #endif #include <sys/cdefs.h> -__RCSID("$NetBSD: process.c,v 1.48 2015/03/01 00:38:01 asau Exp $"); +__RCSID("$NetBSD: process.c,v 1.49 2015/03/01 00:51:08 asau Exp $"); #ifdef __FBSDID __FBSDID("$FreeBSD: head/usr.bin/sed/process.c 192732 2009-05-25 06:45:33Z brian $"); #endif @@ -104,7 +104,7 @@ static u_long linenum; static int rval; /* Exit status */ -struct s_appends *appends; /* Array of pointers to strings to append. */ +static struct s_appends *appends; /* Array of pointers to strings to append. */ static size_t appendx; /* Index into appends array. */ size_t appendnum; /* Size of appends array. */ @@ -113,7 +113,7 @@ static int sdone; /* If any substitutes /* Iov structure for 'w' commands. */ static regex_t *defpreg; size_t maxnsub; -regmatch_t *match; +static regmatch_t *match; #define OUT() do {fwrite(ps, 1, psl, outfile); fputc('\n', outfile);} while (0) @@ -125,6 +125,10 @@ process(void) size_t oldpsl = 0; char *p; + if (appendnum > 0) + appends = xmalloc(sizeof(struct s_appends) * appendnum); + match = xmalloc((maxnsub + 1) * sizeof(regmatch_t)); + p = NULL; for (linenum = 0; mf_fgets(&PS, REPLACE);) {