Module Name:    othersrc
Committed By:   dyoung
Date:           Wed Sep 23 19:32:34 UTC 2015

Modified Files:
        othersrc/external/bsd/arfe/dt: README core.c core.h dt.c hex.c hex.h
            ipv4.c ipv4.h
        othersrc/external/bsd/arfe/it: README
        othersrc/external/bsd/arfe/tt: README tt.c

Log Message:
Extract a subroutine, clocc_score(), that uses the lengths of two
class-occurrences (cloccs) to assign their match a score.

Add $NetBSD$, $ARFE$, and BSD license to core.c.

Update $NetBSD$

Remove a dangling comment from tt/tt.c.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 othersrc/external/bsd/arfe/dt/README
cvs rdiff -u -r1.1 -r1.2 othersrc/external/bsd/arfe/dt/core.c \
    othersrc/external/bsd/arfe/dt/core.h
cvs rdiff -u -r1.13 -r1.14 othersrc/external/bsd/arfe/dt/dt.c
cvs rdiff -u -r1.5 -r1.6 othersrc/external/bsd/arfe/dt/hex.c \
    othersrc/external/bsd/arfe/dt/hex.h othersrc/external/bsd/arfe/dt/ipv4.c \
    othersrc/external/bsd/arfe/dt/ipv4.h
cvs rdiff -u -r1.7 -r1.8 othersrc/external/bsd/arfe/it/README
cvs rdiff -u -r1.4 -r1.5 othersrc/external/bsd/arfe/tt/README
cvs rdiff -u -r1.1 -r1.2 othersrc/external/bsd/arfe/tt/tt.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: othersrc/external/bsd/arfe/dt/README
diff -u othersrc/external/bsd/arfe/dt/README:1.9 othersrc/external/bsd/arfe/dt/README:1.10
--- othersrc/external/bsd/arfe/dt/README:1.9	Tue Sep 22 01:12:09 2015
+++ othersrc/external/bsd/arfe/dt/README	Wed Sep 23 19:32:34 2015
@@ -1,5 +1,5 @@
-$ARFE: README 251 2015-09-22 01:09:13Z dyoung $
-$NetBSD: README,v 1.9 2015/09/22 01:12:09 dyoung Exp $
+$ARFE: README 258 2015-09-23 19:31:17Z dyoung $
+$NetBSD: README,v 1.10 2015/09/23 19:32:34 dyoung Exp $
 
 DT---(d)ifferentiate (t)ext---finds a longest common subsequence (LCS)
 of two texts where the numbers and IPv4 addresses are "wild": a span

Index: othersrc/external/bsd/arfe/dt/core.c
diff -u othersrc/external/bsd/arfe/dt/core.c:1.1 othersrc/external/bsd/arfe/dt/core.c:1.2
--- othersrc/external/bsd/arfe/dt/core.c:1.1	Tue Sep 22 01:12:09 2015
+++ othersrc/external/bsd/arfe/dt/core.c	Wed Sep 23 19:32:34 2015
@@ -1,3 +1,30 @@
+/* $NetBSD: core.c,v 1.2 2015/09/23 19:32:34 dyoung Exp $ */
+/* $ARFE$ */
+
+/*-
+ * Copyright (c) 2014,2015 David Young <[email protected]>
+ * All rights reserved.
+ *
+ * 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 ``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 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.
+ */
 #include <err.h>
 #include <errno.h>
 #include <fcntl.h>
@@ -563,6 +590,12 @@ empty(void)
 	return newchain(strdup(""), 0);
 }
 
+static inline ssize_t
+clocc_score(ssize_t a, ssize_t b)
+{
+	return a * b + 1;
+}
+
 static void
 algb(const slice_t *A, const slice_t *B, scratch_t *scratch, size_t *LL,
     bool do_clocc)
@@ -623,7 +656,7 @@ algb(const slice_t *A, const slice_t *B,
 						  &wlen.B, &kind.B) &&
 			    kind.A == kind.B && /* match kind */
 			    wlen.B <= j + 1 /* must not begin outside of B */) {
-				const size_t step = wlen.A * wlen.B + 1,
+				const size_t step = clocc_score(wlen.A, wlen.B),
 				             nscore = Kclocc[j - wlen.B] + step;
 				dbg_printf("%s visits clocc boundary at A[%d] "
 				    "and B[%d] step %zu\n", __func__,
@@ -859,9 +892,9 @@ algc(const slice_t *A, const slice_t *B,
 
 		if (ivlidx.B != -1) {
 			dbg_assert(expected_lcs == no_expected_lcs ||
-			    (size_t)(end - start + 1) * m + 1 == expected_lcs);
+			    (size_t)clocc_score(end - start + 1, m) == expected_lcs);
 			return algc_return(m, n, origin, lcsp,
-			    (size_t)(end - start + 1) * m + 1,
+			    clocc_score(end - start + 1, m),
 			    clocc(scratch, ivlidx.A, ivlidx.B));
 		}
 	}
Index: othersrc/external/bsd/arfe/dt/core.h
diff -u othersrc/external/bsd/arfe/dt/core.h:1.1 othersrc/external/bsd/arfe/dt/core.h:1.2
--- othersrc/external/bsd/arfe/dt/core.h:1.1	Tue Sep 22 01:12:09 2015
+++ othersrc/external/bsd/arfe/dt/core.h	Wed Sep 23 19:32:34 2015
@@ -1,5 +1,5 @@
-/* $NetBSD: core.h,v 1.1 2015/09/22 01:12:09 dyoung Exp $ */
-/* $ARFE: core.h 250 2015-09-22 01:04:13Z dyoung $ */
+/* $NetBSD: core.h,v 1.2 2015/09/23 19:32:34 dyoung Exp $ */
+/* $ARFE: core.h 258 2015-09-23 19:31:17Z dyoung $ */
 
 /*-
  * Copyright (c) 2014,2015 David Young <[email protected]>

Index: othersrc/external/bsd/arfe/dt/dt.c
diff -u othersrc/external/bsd/arfe/dt/dt.c:1.13 othersrc/external/bsd/arfe/dt/dt.c:1.14
--- othersrc/external/bsd/arfe/dt/dt.c:1.13	Tue Sep 22 01:12:09 2015
+++ othersrc/external/bsd/arfe/dt/dt.c	Wed Sep 23 19:32:34 2015
@@ -1,5 +1,5 @@
-/* $NetBSD: dt.c,v 1.13 2015/09/22 01:12:09 dyoung Exp $ */
-/* $ARFE: dt.c 251 2015-09-22 01:09:13Z dyoung $ */
+/* $NetBSD: dt.c,v 1.14 2015/09/23 19:32:34 dyoung Exp $ */
+/* $ARFE: dt.c 258 2015-09-23 19:31:17Z dyoung $ */
 
 /*-
  * Copyright (c) 2014,2015 David Young <[email protected]>

Index: othersrc/external/bsd/arfe/dt/hex.c
diff -u othersrc/external/bsd/arfe/dt/hex.c:1.5 othersrc/external/bsd/arfe/dt/hex.c:1.6
--- othersrc/external/bsd/arfe/dt/hex.c:1.5	Tue Sep 22 01:12:09 2015
+++ othersrc/external/bsd/arfe/dt/hex.c	Wed Sep 23 19:32:34 2015
@@ -1,5 +1,5 @@
-/* $NetBSD: hex.c,v 1.5 2015/09/22 01:12:09 dyoung Exp $ */
-/* $ARFE: hex.c 251 2015-09-22 01:09:13Z dyoung $ */
+/* $NetBSD: hex.c,v 1.6 2015/09/23 19:32:34 dyoung Exp $ */
+/* $ARFE: hex.c 258 2015-09-23 19:31:17Z dyoung $ */
 
 /*-
  * Copyright (c) 2014,2015 David Young <[email protected]>
Index: othersrc/external/bsd/arfe/dt/hex.h
diff -u othersrc/external/bsd/arfe/dt/hex.h:1.5 othersrc/external/bsd/arfe/dt/hex.h:1.6
--- othersrc/external/bsd/arfe/dt/hex.h:1.5	Tue Sep 22 01:12:09 2015
+++ othersrc/external/bsd/arfe/dt/hex.h	Wed Sep 23 19:32:34 2015
@@ -1,5 +1,5 @@
-/* $NetBSD: hex.h,v 1.5 2015/09/22 01:12:09 dyoung Exp $ */
-/* $ARFE: hex.h 251 2015-09-22 01:09:13Z dyoung $ */
+/* $NetBSD: hex.h,v 1.6 2015/09/23 19:32:34 dyoung Exp $ */
+/* $ARFE: hex.h 258 2015-09-23 19:31:17Z dyoung $ */
 
 /*-
  * Copyright (c) 2014,2015 David Young <[email protected]>
Index: othersrc/external/bsd/arfe/dt/ipv4.c
diff -u othersrc/external/bsd/arfe/dt/ipv4.c:1.5 othersrc/external/bsd/arfe/dt/ipv4.c:1.6
--- othersrc/external/bsd/arfe/dt/ipv4.c:1.5	Tue Sep 22 01:12:09 2015
+++ othersrc/external/bsd/arfe/dt/ipv4.c	Wed Sep 23 19:32:34 2015
@@ -1,5 +1,5 @@
-/* $NetBSD: ipv4.c,v 1.5 2015/09/22 01:12:09 dyoung Exp $ */
-/* $ARFE: ipv4.c 251 2015-09-22 01:09:13Z dyoung $ */
+/* $NetBSD: ipv4.c,v 1.6 2015/09/23 19:32:34 dyoung Exp $ */
+/* $ARFE: ipv4.c 258 2015-09-23 19:31:17Z dyoung $ */
 
 /*-
  * Copyright (c) 2014,2015 David Young <[email protected]>
Index: othersrc/external/bsd/arfe/dt/ipv4.h
diff -u othersrc/external/bsd/arfe/dt/ipv4.h:1.5 othersrc/external/bsd/arfe/dt/ipv4.h:1.6
--- othersrc/external/bsd/arfe/dt/ipv4.h:1.5	Tue Sep 22 01:12:09 2015
+++ othersrc/external/bsd/arfe/dt/ipv4.h	Wed Sep 23 19:32:34 2015
@@ -1,5 +1,5 @@
-/* $NetBSD: ipv4.h,v 1.5 2015/09/22 01:12:09 dyoung Exp $ */
-/* $ARFE: ipv4.h 251 2015-09-22 01:09:13Z dyoung $ */
+/* $NetBSD: ipv4.h,v 1.6 2015/09/23 19:32:34 dyoung Exp $ */
+/* $ARFE: ipv4.h 258 2015-09-23 19:31:17Z dyoung $ */
 
 /*-
  * Copyright (c) 2014,2015 David Young <[email protected]>

Index: othersrc/external/bsd/arfe/it/README
diff -u othersrc/external/bsd/arfe/it/README:1.7 othersrc/external/bsd/arfe/it/README:1.8
--- othersrc/external/bsd/arfe/it/README:1.7	Tue Sep 22 01:12:09 2015
+++ othersrc/external/bsd/arfe/it/README	Wed Sep 23 19:32:34 2015
@@ -1,5 +1,5 @@
-$ARFE: README 252 2015-09-22 01:10:07Z dyoung $
-$NetBSD: README,v 1.7 2015/09/22 01:12:09 dyoung Exp $
+$ARFE: README 258 2015-09-23 19:31:17Z dyoung $
+$NetBSD: README,v 1.8 2015/09/23 19:32:34 dyoung Exp $
 
 IT---(i)ntegrate (t)ext---is a variation on DT that adds decimal numbers
 instead of subtracts, and bitwise-ORs hexadecimal numbers instead of

Index: othersrc/external/bsd/arfe/tt/README
diff -u othersrc/external/bsd/arfe/tt/README:1.4 othersrc/external/bsd/arfe/tt/README:1.5
--- othersrc/external/bsd/arfe/tt/README:1.4	Tue Sep 22 01:12:09 2015
+++ othersrc/external/bsd/arfe/tt/README	Wed Sep 23 19:32:34 2015
@@ -1,5 +1,5 @@
-$ARFE: README 253 2015-09-22 01:10:15Z dyoung $
-$NetBSD: README,v 1.4 2015/09/22 01:12:09 dyoung Exp $
+$ARFE: README 258 2015-09-23 19:31:17Z dyoung $
+$NetBSD: README,v 1.5 2015/09/23 19:32:34 dyoung Exp $
 
 TT---(t)ransform (t)ext---transforms its input based on a
 match/transform-template pair that exemplifies the changes that should

Index: othersrc/external/bsd/arfe/tt/tt.c
diff -u othersrc/external/bsd/arfe/tt/tt.c:1.1 othersrc/external/bsd/arfe/tt/tt.c:1.2
--- othersrc/external/bsd/arfe/tt/tt.c:1.1	Tue Sep 22 01:12:09 2015
+++ othersrc/external/bsd/arfe/tt/tt.c	Wed Sep 23 19:32:34 2015
@@ -1,4 +1,4 @@
-/* $NetBSD: tt.c,v 1.1 2015/09/22 01:12:09 dyoung Exp $ */
+/* $NetBSD: tt.c,v 1.2 2015/09/23 19:32:34 dyoung Exp $ */
 /* $ARFE$ */
 
 /*-
@@ -65,7 +65,6 @@ main(int argc, char **argv)
 
 	if (argc != 4)
 		usage();
-		/*FALLTHROUGH*/
 
 	left = file_to_slice(argv[1]);
 	match = file_to_slice(argv[2]);

Reply via email to