summaryrefslogtreecommitdiffstats
path: root/gnu
diff options
context:
space:
mode:
authored <ed@FreeBSD.org>2009-08-23 12:23:24 +0000
committered <ed@FreeBSD.org>2009-08-23 12:23:24 +0000
commit070a590e2dab584cfe1b087e3a4ff26742654ea9 (patch)
treee7b31036b8f57c49274dca0726a5a616ee554229 /gnu
parentb6fbbf626eb21066b710af86a0cd1fef7b98f66d (diff)
downloadFreeBSD-src-070a590e2dab584cfe1b087e3a4ff26742654ea9.zip
FreeBSD-src-070a590e2dab584cfe1b087e3a4ff26742654ea9.tar.gz
Add support for diffs generated by Perforce.
It basically picks the filenames from the "====" line and strips off the # revision number.
Diffstat (limited to 'gnu')
-rw-r--r--gnu/usr.bin/patch/pch.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/gnu/usr.bin/patch/pch.c b/gnu/usr.bin/patch/pch.c
index 1638241..d72f84f 100644
--- a/gnu/usr.bin/patch/pch.c
+++ b/gnu/usr.bin/patch/pch.c
@@ -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 &&
OpenPOWER on IntegriCloud