From owner-svn-src-all@FreeBSD.ORG Sun Aug 23 12:23:25 2009 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4076D106568E; Sun, 23 Aug 2009 12:23:25 +0000 (UTC) (envelope-from ed@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 2F66F8FC18; Sun, 23 Aug 2009 12:23:25 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n7NCNPab060681; Sun, 23 Aug 2009 12:23:25 GMT (envelope-from ed@svn.freebsd.org) Received: (from ed@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n7NCNPqd060679; Sun, 23 Aug 2009 12:23:25 GMT (envelope-from ed@svn.freebsd.org) Message-Id: <200908231223.n7NCNPqd060679@svn.freebsd.org> From: Ed Schouten Date: Sun, 23 Aug 2009 12:23:25 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r196459 - head/gnu/usr.bin/patch X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 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: Sun, 23 Aug 2009 12:23:25 -0000 Author: ed Date: Sun Aug 23 12:23:24 2009 New Revision: 196459 URL: http://svn.freebsd.org/changeset/base/196459 Log: Add support for diffs generated by Perforce. It basically picks the filenames from the "====" line and strips off the # revision number. Modified: head/gnu/usr.bin/patch/pch.c Modified: head/gnu/usr.bin/patch/pch.c ============================================================================== --- head/gnu/usr.bin/patch/pch.c Sun Aug 23 11:33:46 2009 (r196458) +++ head/gnu/usr.bin/patch/pch.c Sun Aug 23 12:23:24 2009 (r196459) @@ -211,6 +211,25 @@ there_is_another_patch(void) return TRUE; } +static char * +p4_savestr(char *str) +{ + char *t, *h; + + /* Leading whitespace. */ + while (isspace((unsigned char)*str)) + str++; + + /* Remove the file revision number. */ + for (t = str, h = NULL; *t != '\0' && !isspace((unsigned char)*t); t++) + if (*t == '#') + h = t; + if (h != NULL) + *h = '\0'; + + return savestr(str); +} + /* * Determine what kind of diff is in the remaining part of the patch file. */ @@ -298,6 +317,11 @@ intuit_diff_type(void) free(revision); revision = Nullch; } + } else if (strnEQ(s, "==== ", 5)) { + /* Perforce-style diffs. */ + if ((t = strstr(s + 5, " - ")) != NULL) + newtmp = p4_savestr(t + 3); + oldtmp = p4_savestr(s + 5); } if ((!diff_type || diff_type == ED_DIFF) && first_command_line >= 0L &&