From owner-svn-src-all@freebsd.org Tue Dec 17 09:13:49 2019 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 6168E1E14D0; Tue, 17 Dec 2019 09:13:49 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 47cXWK1zqjz43Lf; Tue, 17 Dec 2019 09:13:49 +0000 (UTC) (envelope-from bapt@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 3F738B96D; Tue, 17 Dec 2019 09:13:49 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id xBH9DnDP010893; Tue, 17 Dec 2019 09:13:49 GMT (envelope-from bapt@FreeBSD.org) Received: (from bapt@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xBH9DnTn010892; Tue, 17 Dec 2019 09:13:49 GMT (envelope-from bapt@FreeBSD.org) Message-Id: <201912170913.xBH9DnTn010892@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bapt set sender to bapt@FreeBSD.org using -f From: Baptiste Daroussin Date: Tue, 17 Dec 2019 09:13:49 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r355847 - head/usr.bin/diff3 X-SVN-Group: head X-SVN-Commit-Author: bapt X-SVN-Commit-Paths: head/usr.bin/diff3 X-SVN-Commit-Revision: 355847 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 17 Dec 2019 09:13:49 -0000 Author: bapt Date: Tue Dec 17 09:13:48 2019 New Revision: 355847 URL: https://svnweb.freebsd.org/changeset/base/355847 Log: Use strtoimax. Use existing strtoimax instead of reinventing it Modified: head/usr.bin/diff3/diff3.c Modified: head/usr.bin/diff3/diff3.c ============================================================================== --- head/usr.bin/diff3/diff3.c Tue Dec 17 08:57:01 2019 (r355846) +++ head/usr.bin/diff3/diff3.c Tue Dec 17 09:13:48 2019 (r355847) @@ -84,6 +84,8 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include +#include #include #include @@ -132,7 +134,6 @@ static bool duplicate(struct range *, struct range *); static int edit(struct diff *, bool, int); static char *getchange(FILE *); static char *get_line(FILE *, size_t *); -static int number(char **); static int readin(int fd, struct diff **); static int skip(int, int, const char *); static void change(int, struct range *, bool); @@ -188,16 +189,16 @@ readin(int fd, struct diff **dd) for (i=0; (p = getchange(f)); i++) { if (i >= szchanges - 1) increase(); - a = b = number(&p); + a = b = (int)strtoimax(p, &p, 10); if (*p == ',') { p++; - b = number(&p); + b = (int)strtoimax(p, &p, 10); } kind = *p++; - c = d = number(&p); + c = d = (int)strtoimax(p, &p, 10); if (*p==',') { p++; - d = number(&p); + d = (int)strtoimax(p, &p, 10); } if (kind == 'a') a++; @@ -238,17 +239,6 @@ diffexec(const char *diffprog, char **diffargv, int fd } close(fd[1]); return (pd); -} - -static int -number(char **lc) -{ - int nn; - - nn = 0; - while (isdigit((unsigned char)(**lc))) - nn = nn*10 + *(*lc)++ - '0'; - return (nn); } static char *