From d9ee4fa8f34b7841c05778760aba1eb760e1d02a Mon Sep 17 00:00:00 2001 From: tobias Date: Fri, 9 Oct 2015 21:24:05 +0000 Subject: [PATCH] The variable errmsg can be static in main.c if code in re.c uses an own buffer to construct error messages. with input by and ok millert@ --- bin/ed/ed.h | 3 +-- bin/ed/main.c | 3 ++- bin/ed/re.c | 7 ++++--- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/bin/ed/ed.h b/bin/ed/ed.h index 459688f8980..462a1ac8c31 100644 --- a/bin/ed/ed.h +++ b/bin/ed/ed.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ed.h,v 1.20 2015/10/09 20:27:28 tobias Exp $ */ +/* $OpenBSD: ed.h,v 1.21 2015/10/09 21:24:05 tobias Exp $ */ /* $NetBSD: ed.h,v 1.23 1995/03/21 09:04:40 cgd Exp $ */ /* ed.h: type and constant definitions for the ed editor. */ @@ -202,7 +202,6 @@ extern volatile sig_atomic_t sigint; /* global vars */ extern int addr_last; extern int current_addr; -extern char errmsg[PATH_MAX + 40]; extern int first_addr; extern int lineno; extern int second_addr; diff --git a/bin/ed/main.c b/bin/ed/main.c index 14e60082b91..2489a63e1c9 100644 --- a/bin/ed/main.c +++ b/bin/ed/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.52 2015/10/09 20:27:28 tobias Exp $ */ +/* $OpenBSD: main.c,v 1.53 2015/10/09 21:24:05 tobias Exp $ */ /* $NetBSD: main.c,v 1.3 1995/03/21 09:04:44 cgd Exp $ */ /* main.c: This file contains the main control and user-interface routines @@ -72,6 +72,7 @@ static line_t *dup_line_node(line_t *); sigjmp_buf env; /* static buffers */ +static char errmsg[PATH_MAX + 40]; /* error message buffer */ static char *shcmd; /* shell command buffer */ static int shcmdsz; /* shell command buffer size */ static int shcmdi; /* shell command buffer index */ diff --git a/bin/ed/re.c b/bin/ed/re.c index 7db4096dd73..eea8c267475 100644 --- a/bin/ed/re.c +++ b/bin/ed/re.c @@ -1,4 +1,4 @@ -/* $OpenBSD: re.c,v 1.15 2015/10/09 20:27:28 tobias Exp $ */ +/* $OpenBSD: re.c,v 1.16 2015/10/09 21:24:05 tobias Exp $ */ /* $NetBSD: re.c,v 1.14 1995/03/21 09:04:48 cgd Exp $ */ /* re.c: This file contains the regular expression interface routines for @@ -36,7 +36,6 @@ static char *parse_char_class(char *); extern int patlock; -char errmsg[PATH_MAX + 40] = ""; /* get_compiled_pattern: return pointer to compiled pattern from command buffer */ @@ -44,6 +43,7 @@ regex_t * get_compiled_pattern(void) { static regex_t *exp = NULL; + char errbuf[128] = ""; char *exps; char delimiter; @@ -68,7 +68,8 @@ get_compiled_pattern(void) } patlock = 0; if ((n = regcomp(exp, exps, 0)) != 0) { - regerror(n, exp, errmsg, sizeof errmsg); + regerror(n, exp, errbuf, sizeof errbuf); + seterrmsg(errbuf); free(exp); return exp = NULL; } -- 2.20.1