aboutsummaryrefslogtreecommitdiff
path: root/bin/ed/re.c
diff options
context:
space:
mode:
authorMike Barcroft <mike@FreeBSD.org>2001-08-06 22:01:31 +0000
committerMike Barcroft <mike@FreeBSD.org>2001-08-06 22:01:31 +0000
commita4616748ab35cbec2b9601dec15cab58a809e7d5 (patch)
tree0469fc49295a48c1140722bbff569214e2135f58 /bin/ed/re.c
parent1e1bbe0f97e5529441c15ba7ed4c4e66b18a363e (diff)
Notes
Diffstat (limited to 'bin/ed/re.c')
-rw-r--r--bin/ed/re.c23
1 files changed, 11 insertions, 12 deletions
diff --git a/bin/ed/re.c b/bin/ed/re.c
index 523e2a4494d6c..52dacdcf6244b 100644
--- a/bin/ed/re.c
+++ b/bin/ed/re.c
@@ -27,12 +27,8 @@
*/
#ifndef lint
-#if 0
-static char * const rcsid = "@(#)re.c,v 1.6 1994/02/01 00:34:43 alm Exp";
-#else
-static char * const rcsid =
+static const char rcsid[] =
"$FreeBSD$";
-#endif
#endif /* not lint */
#include "ed.h"
@@ -40,7 +36,7 @@ static char * const rcsid =
extern int patlock;
-char errmsg[PATH_MAX + 40] = "";
+const char *errmsg = "";
/* get_compiled_pattern: return pointer to compiled pattern from command
buffer */
@@ -48,16 +44,18 @@ pattern_t *
get_compiled_pattern()
{
static pattern_t *exp = NULL;
+ static char error[1024];
char *exps;
char delimiter;
int n;
if ((delimiter = *ibufp) == ' ') {
- sprintf(errmsg, "invalid pattern delimiter");
+ errmsg = "invalid pattern delimiter";
return NULL;
} else if (delimiter == '\n' || *++ibufp == '\n' || *ibufp == delimiter) {
- if (!exp) sprintf(errmsg, "no previous pattern");
+ if (!exp)
+ errmsg = "no previous pattern";
return exp;
} else if ((exps = extract_pattern(delimiter)) == NULL)
return NULL;
@@ -66,12 +64,13 @@ get_compiled_pattern()
regfree(exp);
else if ((exp = (pattern_t *) malloc(sizeof(pattern_t))) == NULL) {
fprintf(stderr, "%s\n", strerror(errno));
- sprintf(errmsg, "out of memory");
+ errmsg = "out of memory";
return NULL;
}
patlock = 0;
if ((n = regcomp(exp, exps, 0))) {
- regerror(n, exp, errmsg, sizeof errmsg);
+ regerror(n, exp, error, sizeof error);
+ errmsg = error;
free(exp);
return exp = NULL;
}
@@ -97,13 +96,13 @@ extract_pattern(delimiter)
break;
case '[':
if ((nd = parse_char_class(++nd)) == NULL) {
- sprintf(errmsg, "unbalanced brackets ([])");
+ errmsg = "unbalanced brackets ([])";
return NULL;
}
break;
case '\\':
if (*++nd == '\n') {
- sprintf(errmsg, "trailing backslash (\\)");
+ errmsg = "trailing backslash (\\)";
return NULL;
}
break;