pkgsrc-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[pkgsrc/trunk]: pkgsrc/devel/cvsdiff2patch Add devel/cvsdiff2patch, a simple ...
details: https://anonhg.NetBSD.org/pkgsrc/rev/7eaf47a0f98e
branches: trunk
changeset: 535794:7eaf47a0f98e
user: bjs <bjs%pkgsrc.org@localhost>
date: Thu Nov 29 10:11:13 2007 +0000
description:
Add devel/cvsdiff2patch, a simple utility which, in the words of the
author, "Converts crappy CVS diffs into something that patch(1)
understands."
diffstat:
devel/cvsdiff2patch/DESCR | 1 +
devel/cvsdiff2patch/Makefile | 33 +++++++
devel/cvsdiff2patch/PLIST | 2 +
devel/cvsdiff2patch/files/cvsdiff2patch.c | 124 ++++++++++++++++++++++++++++++
4 files changed, 160 insertions(+), 0 deletions(-)
diffs (176 lines):
diff -r 711b9fe17332 -r 7eaf47a0f98e devel/cvsdiff2patch/DESCR
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/devel/cvsdiff2patch/DESCR Thu Nov 29 10:11:13 2007 +0000
@@ -0,0 +1,1 @@
+Convert CVS diffs into something that patch(1) understands.
diff -r 711b9fe17332 -r 7eaf47a0f98e devel/cvsdiff2patch/Makefile
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/devel/cvsdiff2patch/Makefile Thu Nov 29 10:11:13 2007 +0000
@@ -0,0 +1,33 @@
+# $NetBSD: Makefile,v 1.1.1.1 2007/11/29 10:11:13 bjs Exp $
+#
+
+DISTNAME= cvsdiff2patch-1.0.1
+CATEGORIES= devel
+MASTER_SITES= # empty
+DISTFILES= # empty
+
+MAINTAINER= bjs%NetBSD.org@localhost
+HOMEPAGE= http://people.freebsd.org/~alfred/sources/cvsdiff2patch/
+COMMENT= Convert CVS diffs into something that patch(1) understands
+
+PKG_DESTDIR_SUPPORT= user-destdir
+
+NO_CHECKSUM= yes
+NO_CONFIGURE= yes
+USE_LIBTOOL= yes
+
+INSTALLATION_DIRS+= bin
+
+do-extract:
+ ${RUN} ${CP} -R ${FILESDIR} ${WRKSRC}
+
+do-build:
+ ${RUN} cd ${WRKSRC} && \
+ ${LIBTOOL} --mode=link ${CC} -o ${PKGBASE} ${PKGBASE}.c
+
+do-install:
+ ${RUN} cd ${WRKSRC} && \
+ ${LIBTOOL} --mode=install ${INSTALL_PROGRAM} ${PKGBASE} \
+ ${DESTDIR}${PREFIX}/bin
+
+.include "../../mk/bsd.pkg.mk"
diff -r 711b9fe17332 -r 7eaf47a0f98e devel/cvsdiff2patch/PLIST
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/devel/cvsdiff2patch/PLIST Thu Nov 29 10:11:13 2007 +0000
@@ -0,0 +1,2 @@
+@comment $NetBSD: PLIST,v 1.1.1.1 2007/11/29 10:11:13 bjs Exp $
+bin/cvsdiff2patch
diff -r 711b9fe17332 -r 7eaf47a0f98e devel/cvsdiff2patch/files/cvsdiff2patch.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/devel/cvsdiff2patch/files/cvsdiff2patch.c Thu Nov 29 10:11:13 2007 +0000
@@ -0,0 +1,124 @@
+/* $NetBSD: cvsdiff2patch.c,v 1.1.1.1 2007/11/29 10:11:13 bjs Exp $ */
+
+/*
+ * Copyright (c) 2003 Research Engineering Development Inc.
+ * All rights reserved.
+ * Author: Alfred Perlstein <alfred%FreeBSD.org@localhost>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $Id: cvsdiff2patch.c,v 1.1.1.1 2007/11/29 10:11:13 bjs Exp $
+ */
+
+/*
+ * Convert crappy CVS diffs into something that patch(1) understands.
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <err.h>
+
+char * xstrdup(const char *str);
+int fileline(const char *line, int ch);
+
+char *
+xstrdup(const char *str)
+{
+ char *ret;
+
+ ret = strdup(str);
+ if (str == NULL)
+ err(1, "strdup");
+ return (ret);
+}
+
+int
+fileline(const char *line, int ch)
+{
+ int i;
+
+ for (i = 0; i < 3; i++) {
+ if (line[i] != ch)
+ return (0);
+ }
+ if (line[strlen(line) - 1] == ch) {
+ return (0);
+ }
+ return (1);
+}
+
+int
+main(void)
+{
+ char *line, *filepath;
+ size_t len;
+ const char *indexstr = "Index:";
+ size_t indexlen;
+
+ fprintf(stderr,
+ "Cvsdiff2patch (c) 2003 Research Engineering Development\n");
+
+ filepath = NULL;
+ indexlen = strlen(indexstr);
+
+ while ((line = fgetln(stdin, &len)) != NULL) {
+ line[len - 1] = '\0';
+ if (len > indexlen && strncmp(line, indexstr, indexlen) == 0) {
+ char *p;
+
+ p = memchr(line, ' ', len);
+ if (p != NULL) {
+ p++;
+ free(filepath);
+ filepath = xstrdup(p);
+ }
+ continue;
+ }
+ if (len > 4 &&
+ (fileline(line, '-') ||
+ fileline(line, '+') ||
+ fileline(line, '*'))) {
+ line[3] = '\0';
+ printf("%s %s\n", line, filepath);
+ continue;
+ }
+ line[len - 1] = '\n';
+ switch (*line) {
+ case ' ':
+ case '+':
+ case '-':
+ case '!':
+ case '@':
+ case '*':
+ fwrite(line, 1, len, stdout);
+ break;
+ default:
+#if 0
+ printf("blah! ");
+ fwrite(line, 1, len, stdout);
+#endif
+ break;
+ }
+ }
+ return (0);
+}
Home |
Main Index |
Thread Index |
Old Index