Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/sed Move run-time data structures into processing part.
details: https://anonhg.NetBSD.org/src/rev/7f621b35429e
branches: trunk
changeset: 336425:7f621b35429e
user: asau <asau%NetBSD.org@localhost>
date: Sun Mar 01 00:51:08 2015 +0000
description:
Move run-time data structures into processing part.
diffstat:
usr.bin/sed/compile.c | 7 ++-----
usr.bin/sed/extern.h | 4 +---
usr.bin/sed/process.c | 12 ++++++++----
3 files changed, 11 insertions(+), 12 deletions(-)
diffs (93 lines):
diff -r 3a2544a635b9 -r 7f621b35429e usr.bin/sed/compile.c
--- a/usr.bin/sed/compile.c Sun Mar 01 00:38:01 2015 +0000
+++ b/usr.bin/sed/compile.c Sun Mar 01 00:51:08 2015 +0000
@@ -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_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 { \
diff -r 3a2544a635b9 -r 7f621b35429e usr.bin/sed/extern.h
--- a/usr.bin/sed/extern.h Sun Mar 01 00:38:01 2015 +0000
+++ b/usr.bin/sed/extern.h Sun Mar 01 00:51:08 2015 +0000
@@ -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 @@
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;
diff -r 3a2544a635b9 -r 7f621b35429e usr.bin/sed/process.c
--- a/usr.bin/sed/process.c Sun Mar 01 00:38:01 2015 +0000
+++ b/usr.bin/sed/process.c Sun Mar 01 00:51:08 2015 +0000
@@ -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 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 @@
/* 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 @@
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);) {
Home |
Main Index |
Thread Index |
Old Index