From eced21209cdad6cf4ff64c6008b71b45a226d905 Mon Sep 17 00:00:00 2001 From: mike Date: Mon, 6 Aug 2001 22:01:31 +0000 Subject: 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 --- bin/ed/sub.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) (limited to 'bin/ed/sub.c') diff --git a/bin/ed/sub.c b/bin/ed/sub.c index 3221373..1d53848 100644 --- a/bin/ed/sub.c +++ b/bin/ed/sub.c @@ -27,12 +27,8 @@ */ #ifndef lint -#if 0 -static char * const rcsid = "@(#)sub.c,v 1.1 1994/02/01 00:34:44 alm Exp"; -#else -static char * const rcsid = +static const char rcsid[] = "$FreeBSD$"; -#endif #endif /* not lint */ #include "ed.h" @@ -86,7 +82,8 @@ extract_subst_template() if (*ibufp == '%' && *(ibufp + 1) == delimiter) { ibufp++; - if (!rhbuf) sprintf(errmsg, "no previous substitution"); + if (!rhbuf) + errmsg = "no previous substitution"; return rhbuf; } while (*ibufp != delimiter) { @@ -124,8 +121,8 @@ search_and_replace(pat, gflag, kth) int kth; { undo_t *up; - char *txt; - char *eot; + const char *txt; + const char *eot; long lc; long xa = current_addr; int nsubs = 0; @@ -163,7 +160,7 @@ search_and_replace(pat, gflag, kth) } current_addr = xa; if (nsubs == 0 && !(gflag & GLB)) { - sprintf(errmsg, "no match"); + errmsg = "no match"; return ERR; } else if ((gflag & (GPR | GLS | GNP)) && display_lines(current_addr, current_addr, gflag) < 0) @@ -222,7 +219,7 @@ substitute_matching_text(pat, lp, gflag, kth) i = eot - txt; REALLOC(rbuf, rbufsz, off + i + 2, ERR); if (i > 0 && !rm[0].rm_eo && (gflag & GSG)) { - sprintf(errmsg, "infinite substitution loop"); + errmsg = "infinite substitution loop"; return ERR; } if (isbinary) @@ -238,7 +235,7 @@ substitute_matching_text(pat, lp, gflag, kth) return offset to end of modified text */ int apply_subst_template(boln, rm, off, re_nsub) - char *boln; + const char *boln; regmatch_t *rm; int off; int re_nsub; -- cgit v1.1