diff --git a/ed.c b/ed.c
index 184ed30..c7648eb 100644
--- a/ed.c
+++ b/ed.c
_AT_@ -316,7 +316,7 @@ inject(char *s)
}
static void
-clearbuf()
+clearbuf(void)
{
if (scratch)
close(scratch);
_AT_@ -328,7 +328,7 @@ clearbuf()
}
static void
-setscratch()
+setscratch(void)
{
int r, k;
char *dir;
_AT_@ -407,7 +407,7 @@ match(int num)
}
static int
-rematch(int num)
+rematch(void)
{
regoff_t off = matchs[0].rm_eo;
_AT_@ -451,18 +451,14 @@ getnum(void)
for (ln = 0; isdigit(c = input()); ln += n) {
if (ln > INT_MAX/10)
- goto invalid;
+ error("invalid address");
n = c - '0';
ln *= 10;
if (INT_MAX - ln < n)
- goto invalid;
+ error("invalid address");
}
back(c);
return ln;
-
-invalid:
- error("invalid address");
- return -1; /* not reached */
}
static int
_AT_@ -525,7 +521,7 @@ address(int *line)
num = isdigit(back(input())) ? getnum() : 1;
num *= sign;
if (INT_MAX - ln < num)
- goto invalid;
+ error("invalid address");
ln += num;
}
back(c);
_AT_@ -534,14 +530,10 @@ address(int *line)
error("invalid address");
*line = ln;
return 1;
-
-invalid:
- error("invalid address");
- return -1; /* not reached */
}
static void
-getlst()
+getlst(void)
{
int ln, c;
_AT_@ -589,7 +581,7 @@ deflines(int def1, int def2)
}
static void
-dowrite(char *fname, int trunc)
+dowrite(const char *fname, int trunc)
{
FILE *fp;
int i, line;
_AT_@ -604,13 +596,13 @@ dowrite(char *fname, int trunc)
curln = line2;
if (fclose(fp))
error("input/output error");
- strcpy(savfname, fname);
+ estrlcpy(savfname, fname, sizeof(savfname));
modflag = 0;
curln = line;
}
static void
-doread(char *fname)
+doread(const char *fname)
{
size_t cnt;
ssize_t n;
_AT_@ -735,7 +727,7 @@ getfname(char comm)
} else {
*bp = '\0';
if (savfname[0] == '\0' || comm == 'e' || comm == 'f')
- strcpy(savfname, fname);
+ estrlcpy(savfname, fname, sizeof(savfname));
return fname;
}
return NULL; /* not reached */
_AT_@ -1010,7 +1002,7 @@ subline(int num, int nth)
static size_t siz, cap;
i = changed = siz = 0;
- for (m = match(num); m; m = rematch(num)) {
+ for (m = match(num); m; m = rematch()) {
addpre(&s, &cap, &siz);
changed |= addsub(&s, &cap, &siz, nth, ++i);
if (eol || bol)
Received on Fri Oct 07 2016 - 15:15:33 CEST