aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEitan Adler <eadler@FreeBSD.org>2018-06-02 08:46:09 +0000
committerEitan Adler <eadler@FreeBSD.org>2018-06-02 08:46:09 +0000
commitb274c68a206b22e5333ca00cd6adccf8a915a910 (patch)
tree0a9efb47cd85b0ec684339ab454bab7d6961df77
parentb9cedb46e27463290f32193cb07d2ee4c2536520 (diff)
downloadsrc-b274c68a206b22e5333ca00cd6adccf8a915a910.tar.gz
src-b274c68a206b22e5333ca00cd6adccf8a915a910.zip
Use stpcpy instead of home grown solution
Notes
Notes: svn path=/head/; revision=334527
-rw-r--r--usr.bin/top/display.c18
-rw-r--r--usr.bin/top/utils.c16
-rw-r--r--usr.bin/top/utils.h1
3 files changed, 11 insertions, 24 deletions
diff --git a/usr.bin/top/display.c b/usr.bin/top/display.c
index 2579df60fe39..5943986e3756 100644
--- a/usr.bin/top/display.c
+++ b/usr.bin/top/display.c
@@ -822,7 +822,7 @@ i_process(int line, char *thisline)
/* copy it in to our buffer */
base = smart_terminal ? screenbuf + lineindex(line) : screenbuf;
- p = strecpy(base, thisline);
+ p = stpcpy(base, thisline);
/* zero fill the rest of it */
bzero(p, display_width - (p - base));
@@ -861,7 +861,7 @@ u_process(int line, char *newline)
fputs(newline, stdout);
/* copy it in to the buffer */
- optr = strecpy(bufferline, newline);
+ optr = stpcpy(bufferline, newline);
/* zero fill the rest of it */
bzero(optr, display_width - (optr - bufferline));
@@ -1110,30 +1110,30 @@ static void summary_format(char *str, int *numbers, char **names)
if (thisname[0] == 'K')
{
/* yes: format it as a memory value */
- p = strecpy(p, format_k(num));
+ p = stpcpy(p, format_k(num));
/* skip over the K, since it was included by format_k */
- p = strecpy(p, thisname+1);
+ p = stpcpy(p, thisname+1);
}
/* is this number a ratio? */
else if (thisname[0] == ':')
{
(void) snprintf(rbuf, sizeof(rbuf), "%.2f",
(float)*(numbers - 2) / (float)num);
- p = strecpy(p, rbuf);
- p = strecpy(p, thisname);
+ p = stpcpy(p, rbuf);
+ p = stpcpy(p, thisname);
}
else
{
- p = strecpy(p, itoa(num));
- p = strecpy(p, thisname);
+ p = stpcpy(p, itoa(num));
+ p = stpcpy(p, thisname);
}
}
/* ignore negative numbers, but display corresponding string */
else if (num < 0)
{
- p = strecpy(p, thisname);
+ p = stpcpy(p, thisname);
}
}
diff --git a/usr.bin/top/utils.c b/usr.bin/top/utils.c
index 2278bd116797..b0e9103f7dbe 100644
--- a/usr.bin/top/utils.c
+++ b/usr.bin/top/utils.c
@@ -131,18 +131,6 @@ int digits(int val)
}
/*
- * strecpy(to, from) - copy string "from" into "to" and return a pointer
- * to the END of the string "to".
- */
-
-char *
-strecpy(char *to, const char *from)
-{
- while ((*to++ = *from++) != '\0');
- return(--to);
-}
-
-/*
* string_index(string, array) - find string in array and return index
*/
@@ -393,7 +381,7 @@ char *format_k(int amt)
}
}
- p = strecpy(p, itoa(amt));
+ p = stpcpy(p, itoa(amt));
*p++ = tag;
*p = '\0';
@@ -423,7 +411,7 @@ format_k2(unsigned long long amt)
}
}
- p = strecpy(p, itoa((int)amt));
+ p = stpcpy(p, itoa((int)amt));
*p++ = tag;
*p = '\0';
diff --git a/usr.bin/top/utils.h b/usr.bin/top/utils.h
index a53e55bea090..9e5daa7bba4b 100644
--- a/usr.bin/top/utils.h
+++ b/usr.bin/top/utils.h
@@ -14,7 +14,6 @@ int atoiwi(const char *);
char *itoa(unsigned int);
char *itoa7(unsigned int);
int digits(int);
-char *strecpy(char *, const char *);
char **argparse(char *, int *);
long percentages(int, int *, long *, long *, long *);
char *format_time(long);