From owner-svn-src-stable@freebsd.org Fri Mar 16 05:29:32 2018 Return-Path: Delivered-To: svn-src-stable@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 D9754F521BD; Fri, 16 Mar 2018 05:29:31 +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 877536C7EB; Fri, 16 Mar 2018 05:29:31 +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 7D75C1FF0F; Fri, 16 Mar 2018 05:29:31 +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 w2G5TVPA066711; Fri, 16 Mar 2018 05:29:31 GMT (envelope-from eadler@FreeBSD.org) Received: (from eadler@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w2G5TVgh066709; Fri, 16 Mar 2018 05:29:31 GMT (envelope-from eadler@FreeBSD.org) Message-Id: <201803160529.w2G5TVgh066709@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: eadler set sender to eadler@FreeBSD.org using -f From: Eitan Adler Date: Fri, 16 Mar 2018 05:29:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r331047 - stable/11/usr.bin/patch X-SVN-Group: stable-11 X-SVN-Commit-Author: eadler X-SVN-Commit-Paths: stable/11/usr.bin/patch X-SVN-Commit-Revision: 331047 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 16 Mar 2018 05:29:32 -0000 Author: eadler Date: Fri Mar 16 05:29:30 2018 New Revision: 331047 URL: https://svnweb.freebsd.org/changeset/base/331047 Log: MFC r311106,r311109,r311110,r320579,r327063,r327064,: patch(1): replace strnlen() with a simpler strlen(). patch(1): add support for git generated diffs. patch: rejname[] is also -r option buffer, and should be PATH_MAX. patch: further cleanup to git-style diffs. Modified: stable/11/usr.bin/patch/patch.c stable/11/usr.bin/patch/pch.c Directory Properties: stable/11/ (props changed) Modified: stable/11/usr.bin/patch/patch.c ============================================================================== --- stable/11/usr.bin/patch/patch.c Fri Mar 16 05:23:48 2018 (r331046) +++ stable/11/usr.bin/patch/patch.c Fri Mar 16 05:29:30 2018 (r331047) @@ -112,7 +112,7 @@ static bool reverse_flag_specified = false; static bool Vflag = false; /* buffer holding the name of the rejected patch file. */ -static char rejname[NAME_MAX + 1]; +static char rejname[PATH_MAX]; /* how many input lines have been irretractibly output */ static LINENUM last_frozen_line = 0; @@ -749,10 +749,10 @@ rej_line(int ch, LINENUM i) size_t len; const char *line = pfetch(i); - len = strnlen(line, USHRT_MAX); + len = strlen(line); fprintf(rejfp, "%c%s", ch, line); - if (len == 0 || line[len-1] != '\n') { + if (len == 0 || line[len - 1] != '\n') { if (len >= USHRT_MAX) fprintf(rejfp, "\n\\ Line too long\n"); else Modified: stable/11/usr.bin/patch/pch.c ============================================================================== --- stable/11/usr.bin/patch/pch.c Fri Mar 16 05:23:48 2018 (r331046) +++ stable/11/usr.bin/patch/pch.c Fri Mar 16 05:29:30 2018 (r331047) @@ -264,6 +264,7 @@ intuit_diff_type(void) char *s, *t; int indent, retval; struct file_name names[MAX_FILE]; + int piece_of_git = 0; memset(names, 0, sizeof(names)); ok_to_create_file = false; @@ -308,14 +309,22 @@ intuit_diff_type(void) if (!stars_last_line && strnEQ(s, "*** ", 4)) names[OLD_FILE].path = fetchname(s + 4, &names[OLD_FILE].exists, strippath); - else if (strnEQ(s, "--- ", 4)) - names[NEW_FILE].path = fetchname(s + 4, + else if (strnEQ(s, "--- ", 4)) { + size_t off = 4; + if (piece_of_git && strippath == 957 && + strnEQ(s, "--- a/", 6)) + off = 6; + names[NEW_FILE].path = fetchname(s + off, &names[NEW_FILE].exists, strippath); - else if (strnEQ(s, "+++ ", 4)) + } else if (strnEQ(s, "+++ ", 4)) { /* pretend it is the old name */ - names[OLD_FILE].path = fetchname(s + 4, + size_t off = 4; + if (piece_of_git && strippath == 957 && + strnEQ(s, "+++ b/", 6)) + off = 6; + names[OLD_FILE].path = fetchname(s + off, &names[OLD_FILE].exists, strippath); - else if (strnEQ(s, "Index:", 6)) + } else if (strnEQ(s, "Index:", 6)) names[INDEX_FILE].path = fetchname(s + 6, &names[INDEX_FILE].exists, strippath); else if (strnEQ(s, "Prereq:", 7)) { @@ -330,6 +339,9 @@ intuit_diff_type(void) free(revision); revision = NULL; } + } else if (strnEQ(s, "diff --git a/", 13)) { + /* Git-style diffs. */ + piece_of_git = 1; } else if (strnEQ(s, "==== ", 5)) { /* Perforce-style diffs. */ if ((t = strstr(s + 5, " - ")) != NULL)