From owner-svn-src-head@freebsd.org Sat Jun 2 08:46:10 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 679E5FDFFDE; Sat, 2 Jun 2018 08:46:10 +0000 (UTC) (envelope-from eadler@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 19A7C75806; Sat, 2 Jun 2018 08:46:10 +0000 (UTC) (envelope-from eadler@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id F0094587C; Sat, 2 Jun 2018 08:46:09 +0000 (UTC) (envelope-from eadler@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w528k9D2010238; Sat, 2 Jun 2018 08:46:09 GMT (envelope-from eadler@FreeBSD.org) Received: (from eadler@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w528k9bm010235; Sat, 2 Jun 2018 08:46:09 GMT (envelope-from eadler@FreeBSD.org) Message-Id: <201806020846.w528k9bm010235@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: eadler set sender to eadler@FreeBSD.org using -f From: Eitan Adler Date: Sat, 2 Jun 2018 08:46:09 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r334527 - head/usr.bin/top X-SVN-Group: head X-SVN-Commit-Author: eadler X-SVN-Commit-Paths: head/usr.bin/top X-SVN-Commit-Revision: 334527 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 02 Jun 2018 08:46:10 -0000 Author: eadler Date: Sat Jun 2 08:46:09 2018 New Revision: 334527 URL: https://svnweb.freebsd.org/changeset/base/334527 Log: Use stpcpy instead of home grown solution Modified: head/usr.bin/top/display.c head/usr.bin/top/utils.c head/usr.bin/top/utils.h Modified: head/usr.bin/top/display.c ============================================================================== --- head/usr.bin/top/display.c Sat Jun 2 08:38:59 2018 (r334526) +++ head/usr.bin/top/display.c Sat Jun 2 08:46:09 2018 (r334527) @@ -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, ch 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); } } Modified: head/usr.bin/top/utils.c ============================================================================== --- head/usr.bin/top/utils.c Sat Jun 2 08:38:59 2018 (r334526) +++ head/usr.bin/top/utils.c Sat Jun 2 08:46:09 2018 (r334527) @@ -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'; Modified: head/usr.bin/top/utils.h ============================================================================== --- head/usr.bin/top/utils.h Sat Jun 2 08:38:59 2018 (r334526) +++ head/usr.bin/top/utils.h Sat Jun 2 08:46:09 2018 (r334527) @@ -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);