From 740e54be27af8df71fcbee86170c188825afbcd4 Mon Sep 17 00:00:00 2001 From: Archie Cobbs Date: Thu, 7 Jan 1999 19:28:57 +0000 Subject: [PATCH] Add the 'diffburst' tool, which does the following: Reads the output of 'diff -r' and splits it into separate patch files, one per file. The files are named 'patch-XX' where XX is aa, ab, ac, ... Useful when creating ports. --- tools/tools/README | 5 +++- tools/tools/diffburst/Makefile | 9 +++++++ tools/tools/diffburst/diffburst.1 | 19 +++++++++++++ tools/tools/diffburst/main.c | 44 +++++++++++++++++++++++++++++++ 4 files changed, 76 insertions(+), 1 deletion(-) create mode 100644 tools/tools/diffburst/Makefile create mode 100644 tools/tools/diffburst/diffburst.1 create mode 100644 tools/tools/diffburst/main.c diff --git a/tools/tools/README b/tools/tools/README index 2a7fca1a3aae..b305823f6169 100644 --- a/tools/tools/README +++ b/tools/tools/README @@ -1,4 +1,4 @@ -# $Id: README,v 1.13 1998/12/15 16:51:48 cracauer Exp $ +# $Id: README,v 1.14 1998/12/17 12:21:19 cracauer Exp $ This directory is for tools. @@ -22,3 +22,6 @@ tcl_bmake Generates a bmake Makefile for src/lib/libtcl. upgrade Scripts used for upgrading an installed system. vop_table Generates a HTML document that shows all the VOP's in the kernel. +diffburst Reads the output of 'diff -r' and splits it into separate + patch files, one per file. The files are named 'patch-XX' + where XX is aa, ab, ac, ... Useful when creating ports. diff --git a/tools/tools/diffburst/Makefile b/tools/tools/diffburst/Makefile new file mode 100644 index 000000000000..4e58e4cdd866 --- /dev/null +++ b/tools/tools/diffburst/Makefile @@ -0,0 +1,9 @@ +# $Id: Makefile,v 1.1 1997/12/06 00:44:04 archie Exp $ + +PROG= diffburst +SRCS= main.c +MAN1= diffburst.1 + +COPTS+= -g -Wall + +.include diff --git a/tools/tools/diffburst/diffburst.1 b/tools/tools/diffburst/diffburst.1 new file mode 100644 index 000000000000..91a33091ab52 --- /dev/null +++ b/tools/tools/diffburst/diffburst.1 @@ -0,0 +1,19 @@ +.Dd Jan 7, 1999 +.Dt DIFFBURST 1 +.Os BSD 4.4 +.Sh NAME +.Nm diffburst +.Nd split recursive diff output into separate files +.Sh SYNOPSIS +.Nm diffburst < input +.Sh DESCRIPTION +.Nm +reads the output of a recursive diff from standard input, +and writes it back out as a series of patchfiles, where each patchfile +contains the diff for a single file. The files are named +patch-aa, patch-ab, and so on. +.Pp +This program is intended to aid in developing FreeBSD ports, +where the 'one patchfile per file' rule applies. +.Sh AUTHOR +Archie Cobbs diff --git a/tools/tools/diffburst/main.c b/tools/tools/diffburst/main.c new file mode 100644 index 000000000000..a38e40c5e1f1 --- /dev/null +++ b/tools/tools/diffburst/main.c @@ -0,0 +1,44 @@ +#include +#include +#include +#include + +/* Split a recursive diff into sub-patches to satisfy the requirement + that each patch only patch a single file */ + +int +main(int ac, char *av[]) +{ + int ln; + char line[8192]; + char suf[2] = { 'a', 'a' }; + FILE *fp = NULL; + + memset(line, 0, sizeof(line)); + for (ln = 1; fgets(line, sizeof(line) - 1, stdin); ln++) + { + if (line[strlen(line) - 1] != '\n') + errx(1, "line %d is too long", ln); + if (!strncmp(line, "diff", 4) && fp != NULL) + { + fclose(fp); + fp = NULL; + } + if (fp == NULL) + { + char name[200]; + + snprintf(name, sizeof(name), "patch-%c%c", suf[0], suf[1]); + if (suf[1]++ == 'z') + { + suf[1] = 'a'; + suf[0]++; + } + if ((fp = fopen(name, "w")) == NULL) + err(1, "%s", name); + } + fprintf(fp, "%s", line); + } + return(0); +} +