summaryrefslogtreecommitdiffstats
path: root/bin/ed/re.c
diff options
context:
space:
mode:
authormike <mike@FreeBSD.org>2001-08-06 22:01:31 +0000
committermike <mike@FreeBSD.org>2001-08-06 22:01:31 +0000
commiteced21209cdad6cf4ff64c6008b71b45a226d905 (patch)
tree0469fc49295a48c1140722bbff569214e2135f58 /bin/ed/re.c
parente7f429490d285f94132046b59db80b6d1fe253c4 (diff)
downloadFreeBSD-src-eced21209cdad6cf4ff64c6008b71b45a226d905.zip
FreeBSD-src-eced21209cdad6cf4ff64c6008b71b45a226d905.tar.gz
o Correctly define rcsid.
o Add consts where appropriate. o Rename some variables that were shadowing global declarations. o Remove register storage-classes. o Make errmsg a const, so we can just set error messages instead of using sprintf/strcpy. o Set WARNS=2 Reviewed by: bde, des
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 523e2a4..52dacdc 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;
OpenPOWER on IntegriCloud