Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 08 Aug 2012 16:07:26 +0000
From:      jhagewood@FreeBSD.org
To:        svn-soc-all@FreeBSD.org
Subject:   socsvn commit: r240196 - in soc2012/jhagewood: . diff diff3 mdocml mdocml/ports-textproc-patches mdocml/tests sdiff
Message-ID:  <20120808160726.99307106564A@hub.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jhagewood
Date: Wed Aug  8 16:07:26 2012
New Revision: 240196
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=240196

Log:
  Reorganized subtree

Added:
  soc2012/jhagewood/Milestones
  soc2012/jhagewood/diff/
  soc2012/jhagewood/diff/Makefile
  soc2012/jhagewood/diff/TODO
  soc2012/jhagewood/diff/decompress.c
  soc2012/jhagewood/diff/diff   (contents, props changed)
  soc2012/jhagewood/diff/diff-test.sh
  soc2012/jhagewood/diff/diff.1
  soc2012/jhagewood/diff/diff.1.gz   (contents, props changed)
  soc2012/jhagewood/diff/diff.c
  soc2012/jhagewood/diff/diff.h
  soc2012/jhagewood/diff/diffdir.c
  soc2012/jhagewood/diff/diffreg.c
  soc2012/jhagewood/diff/pathnames.h
  soc2012/jhagewood/diff3/
  soc2012/jhagewood/diff3/Makefile
  soc2012/jhagewood/diff3/TODO
  soc2012/jhagewood/diff3/diff3-test.sh
  soc2012/jhagewood/diff3/diff3.1
  soc2012/jhagewood/diff3/diff3.ksh
  soc2012/jhagewood/diff3/diff3.sh
  soc2012/jhagewood/diff3/diff3prog.c
  soc2012/jhagewood/mdocml/
  soc2012/jhagewood/mdocml/Makefile
  soc2012/jhagewood/mdocml/TODO
  soc2012/jhagewood/mdocml/apropos.1
  soc2012/jhagewood/mdocml/apropos.c
  soc2012/jhagewood/mdocml/apropos_db.c
  soc2012/jhagewood/mdocml/apropos_db.h
  soc2012/jhagewood/mdocml/arch.c
  soc2012/jhagewood/mdocml/arch.in
  soc2012/jhagewood/mdocml/att.c
  soc2012/jhagewood/mdocml/att.in
  soc2012/jhagewood/mdocml/catman.8
  soc2012/jhagewood/mdocml/catman.c
  soc2012/jhagewood/mdocml/cgi.c
  soc2012/jhagewood/mdocml/chars.c
  soc2012/jhagewood/mdocml/chars.in
  soc2012/jhagewood/mdocml/compat_fgetln.c
  soc2012/jhagewood/mdocml/compat_getsubopt.c
  soc2012/jhagewood/mdocml/compat_strlcat.c
  soc2012/jhagewood/mdocml/compat_strlcpy.c
  soc2012/jhagewood/mdocml/config.h.post
  soc2012/jhagewood/mdocml/config.h.pre
  soc2012/jhagewood/mdocml/demandoc.1
  soc2012/jhagewood/mdocml/demandoc.c
  soc2012/jhagewood/mdocml/eqn.7
  soc2012/jhagewood/mdocml/eqn.c
  soc2012/jhagewood/mdocml/eqn_html.c
  soc2012/jhagewood/mdocml/eqn_term.c
  soc2012/jhagewood/mdocml/example.style.css
  soc2012/jhagewood/mdocml/external.png   (contents, props changed)
  soc2012/jhagewood/mdocml/html.c
  soc2012/jhagewood/mdocml/html.h
  soc2012/jhagewood/mdocml/index.css
  soc2012/jhagewood/mdocml/index.sgml
  soc2012/jhagewood/mdocml/lib.c
  soc2012/jhagewood/mdocml/lib.in
  soc2012/jhagewood/mdocml/libman.h
  soc2012/jhagewood/mdocml/libmandoc.h
  soc2012/jhagewood/mdocml/libmdoc.h
  soc2012/jhagewood/mdocml/libroff.h
  soc2012/jhagewood/mdocml/main.c
  soc2012/jhagewood/mdocml/main.h
  soc2012/jhagewood/mdocml/man-cgi.css
  soc2012/jhagewood/mdocml/man.7
  soc2012/jhagewood/mdocml/man.c
  soc2012/jhagewood/mdocml/man.cgi.7
  soc2012/jhagewood/mdocml/man.h
  soc2012/jhagewood/mdocml/man.h.orig
  soc2012/jhagewood/mdocml/man_hash.c
  soc2012/jhagewood/mdocml/man_html.c
  soc2012/jhagewood/mdocml/man_macro.c
  soc2012/jhagewood/mdocml/man_term.c
  soc2012/jhagewood/mdocml/man_term.c.orig
  soc2012/jhagewood/mdocml/man_validate.c
  soc2012/jhagewood/mdocml/mandoc.1
  soc2012/jhagewood/mdocml/mandoc.3
  soc2012/jhagewood/mdocml/mandoc.c
  soc2012/jhagewood/mdocml/mandoc.h
  soc2012/jhagewood/mdocml/mandoc_char.7
  soc2012/jhagewood/mdocml/mandocdb.8
  soc2012/jhagewood/mdocml/mandocdb.c
  soc2012/jhagewood/mdocml/mandocdb.h
  soc2012/jhagewood/mdocml/manpath.c
  soc2012/jhagewood/mdocml/manpath.h
  soc2012/jhagewood/mdocml/manpaths.txt
  soc2012/jhagewood/mdocml/mdoc.7
  soc2012/jhagewood/mdocml/mdoc.c
  soc2012/jhagewood/mdocml/mdoc.h
  soc2012/jhagewood/mdocml/mdoc_argv.c
  soc2012/jhagewood/mdocml/mdoc_hash.c
  soc2012/jhagewood/mdocml/mdoc_html.c
  soc2012/jhagewood/mdocml/mdoc_macro.c
  soc2012/jhagewood/mdocml/mdoc_man.c
  soc2012/jhagewood/mdocml/mdoc_term.c
  soc2012/jhagewood/mdocml/mdoc_validate.c
  soc2012/jhagewood/mdocml/mdocml-manpage-errors.txt
  soc2012/jhagewood/mdocml/msec.c
  soc2012/jhagewood/mdocml/msec.in
  soc2012/jhagewood/mdocml/out.c
  soc2012/jhagewood/mdocml/out.h
  soc2012/jhagewood/mdocml/ports-textproc-patches/
  soc2012/jhagewood/mdocml/ports-textproc-patches/patch-config.txt
  soc2012/jhagewood/mdocml/ports-textproc-patches/patch-lib.in.txt
  soc2012/jhagewood/mdocml/ports-textproc-patches/patch-mdoc_validate.c
  soc2012/jhagewood/mdocml/ports-textproc-patches/patch-msec.in.txt
  soc2012/jhagewood/mdocml/preconv.1
  soc2012/jhagewood/mdocml/preconv.c
  soc2012/jhagewood/mdocml/predefs.in
  soc2012/jhagewood/mdocml/read.c
  soc2012/jhagewood/mdocml/roff.7
  soc2012/jhagewood/mdocml/roff.c
  soc2012/jhagewood/mdocml/st.c
  soc2012/jhagewood/mdocml/st.in
  soc2012/jhagewood/mdocml/style.css
  soc2012/jhagewood/mdocml/tbl.7
  soc2012/jhagewood/mdocml/tbl.c
  soc2012/jhagewood/mdocml/tbl_data.c
  soc2012/jhagewood/mdocml/tbl_html.c
  soc2012/jhagewood/mdocml/tbl_layout.c
  soc2012/jhagewood/mdocml/tbl_opts.c
  soc2012/jhagewood/mdocml/tbl_term.c
  soc2012/jhagewood/mdocml/term.c
  soc2012/jhagewood/mdocml/term.h
  soc2012/jhagewood/mdocml/term_ascii.c
  soc2012/jhagewood/mdocml/term_ps.c
  soc2012/jhagewood/mdocml/test-fgetln.c
  soc2012/jhagewood/mdocml/test-getsubopt.c
  soc2012/jhagewood/mdocml/test-mmap.c
  soc2012/jhagewood/mdocml/test-strlcat.c
  soc2012/jhagewood/mdocml/test-strlcpy.c
  soc2012/jhagewood/mdocml/test-strptime.c
  soc2012/jhagewood/mdocml/tests/
  soc2012/jhagewood/mdocml/tests/compile-man-pages.sh   (contents, props changed)
  soc2012/jhagewood/mdocml/tests/mdocml-test.sh   (contents, props changed)
  soc2012/jhagewood/mdocml/tree.c
  soc2012/jhagewood/mdocml/vol.c
  soc2012/jhagewood/mdocml/vol.in
  soc2012/jhagewood/mdocml/whatis.1
  soc2012/jhagewood/sdiff/
  soc2012/jhagewood/sdiff/Makefile
  soc2012/jhagewood/sdiff/TODO
  soc2012/jhagewood/sdiff/benchmarks
  soc2012/jhagewood/sdiff/common.c
  soc2012/jhagewood/sdiff/common.h
  soc2012/jhagewood/sdiff/edit.c
  soc2012/jhagewood/sdiff/extern.h
  soc2012/jhagewood/sdiff/sdiff-test.sh
  soc2012/jhagewood/sdiff/sdiff.1
  soc2012/jhagewood/sdiff/sdiff.c

Added: soc2012/jhagewood/Milestones
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ soc2012/jhagewood/Milestones	Wed Aug  8 16:07:26 2012	(r240196)
@@ -0,0 +1,30 @@
+May 21 - June 17
+
+    Implement missing features of mdocml, including legacy features.
+    Testing of mdocml. 
+
+June 18 - July 1
+
+    Complete diff
+    Debugging and testing of diff 
+
+July 2 - July 18
+
+    Mid-term evaluations.
+    Complete sdiff
+    Debugging and testing of sdiff 
+
+July 19 - August 5
+
+    Complete diff3
+    Debugging and testing of diff3 
+
+August 6 – August 12
+
+    Thouroughly test and benchmark all utilities. 
+
+August 13 - August 20
+
+    "Pencils down" period.
+    Finish cleaning up code and do any testing that might be left.
+    Write documentation. 

Added: soc2012/jhagewood/diff/Makefile
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ soc2012/jhagewood/diff/Makefile	Wed Aug  8 16:07:26 2012	(r240196)
@@ -0,0 +1,10 @@
+#	$FreeBSD$
+#	$OpenBSD: Makefile,v 1.2 2003/06/25 02:42:50 deraadt Exp $
+
+DEBUG_FLAGS+= -g
+
+PROG=	diff zdiff
+SRCS=	diff.c diffdir.c diffreg.c
+CFLAGS+=	-std=c99 -Wall -pedantic -lz
+
+.include <bsd.prog.mk>

Added: soc2012/jhagewood/diff/TODO
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ soc2012/jhagewood/diff/TODO	Wed Aug  8 16:07:26 2012	(r240196)
@@ -0,0 +1,77 @@
+TASK					STATUS			NOTE
+
+--unified GNU compatibility		COMPLETE		Fixed timestamp.		
+--context GNU compatibility		COMPLETE		Fixed timestamp, will test more.
+--ignore-blank-lines			IN PROGRESS		Was already implemented in check(), but has weird outputs.
+--left-column				COMPLETE		Because side-by-side mode is executed by sdiff, option is simply passed to sdiff.
+--show-function-line			INCOMPLETE
+--unidirectional-new-file		INCOMPLETE
+--normal				COMPLETE		Sets format to D_NORMAL in getopt_long().
+--suppress-common-lines			COMPLETE		Because side-by-side mode is executed by sdiff, option is simply passed to sdiff.
+--GTYPE-group-format			IN PROGRESS		Added options for various GTYPEs.
+--line-format				IN PROGRESS		Added new-line-format, old-line-format, and unchanged-line-format for compatibility
+--LTYPE-line-format			INCOMPLETE
+--from-file				COMPLETE		Checks for flag then calls diffreg() with input files diff'd against optarg. 
+--to-file				COMPLETE		Checks for flag then calls diffreg() with optarg diff'd against input files.
+--horizon-lines				INCOMPLETE
+--speed-large-file			INCOMPLETE
+--ignore-tab-expansion			IN PROGRESS		Functionality implemented in check(), needs debugging. (Same problem as --ignore-blank-lines?)  
+--width					INCOMPLETE
+--help					COMPLETE
+Fix non-ascii character diffs		COMPLETE		Changed name of asciifile() to istextfile() and detects if file is binary.
+Test script				COMPLETE 
+Support for zdiff			IN PROGRESS		Needs testing.
+
+
+Notes: 
+
+- When using text files with non-ascii characters, diff will interpret them as binary files and output "Files [file1] and [file2] differ."
+  Very important compatibility problem with GNU diff, which will diff files that aren't strictly ascii.
+	- Error is associated with asciifile() in diffreg.c
+	- FIX: Changed name of asciifile() to istextfile() (more appropriate), and instead of checking if every character is ASCII, it checks the first 32kb of data in the file for a null character. If a null character is found, diff assumes that the file is a text file.
+- With some files, modification times displayed in the timestamp for file1 are different than the time outputted by GNU diff. 
+- The -ignore-*-* options need some work.
+- BUG: BSD diff seg faults when another longopt is used with '--side-by-side'. FIX: When passing args to sdiff for side-by-side mode, only the 
+	short option '-y' was excluded. Added '--side-by-side' as an exception also.
+- --ignore-*-* options
+	-WORKING
+		--ignore-all-space
+		--ignore-case
+		--ignore-file-name-case
+		--ignore-matching-lines
+		--ignore-space-change
+	-NOT WORKING
+		--ignore-blank-lines
+		--ignore-tab-expansion
+
+- line formats:
+
+	%l	Only includes contents of a line, excluding trailing new line.
+	%L	Only includes contents of a line, including trailing new line.
+	%%	Stand for '%'
+	%c'C'	Where C is a character.
+	%c'\O'	where O is a string of 1, 2, or 3 octal digits, stands for the character with octal code O.
+	Fn	Where n is:
+		-'e'
+		-'f'
+		-'l'
+		-'m'
+		-'n'
+		-'E, F, L, M, N'
+
+- group formats: 
+
+	%<	Stands for the lines from the first file, including trailing new lines.
+	%>	Stands for the lines from the second file, including trailing new lines.
+	%=	Stands for lines common to both files, including trailing new lines.
+	%%	Stands for '%'
+	%c'C'	Where C is a character.
+	%c'\O'	where O is a string of 1, 2, or 3 octal digits, stands for the character with octal code O.
+	Fn	Where n is:
+		-'e'
+		-'f'
+		-'l'
+		-'m'
+		-'n'
+		-'E, F, L, M, N'
+	

Added: soc2012/jhagewood/diff/decompress.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ soc2012/jhagewood/diff/decompress.c	Wed Aug  8 16:07:26 2012	(r240196)
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2012 Jesse Hagewood <jhagewood@freebsd.org>
+ * 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 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.
+ */
+
+#if 0
+#ifndef lint
+static char sccsid[] = "@(#)decompress.c 6/6/93";
+#endif
+#endif /* not lint */
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <sys/param.h>
+#include <sys/stat.h>
+#include <sys/wait.h>
+
+#include <ctype.h>
+#include <err.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <stddef.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <zlib.h>
+
+#ifndef WITHOUT_BZIP2
+#include <bzlib.h>
+#endif
+
+#include "diff.h"
+#include "pathnames.h"
+
+#define MAXBUFSIZE (32 * 1024)
+
+/* Decompresses a gzip file and returns a regular FILE. */
+FILE *
+decompressfile(char *filename, char *mode) {
+
+	FILE *file;
+	char *buf;
+	gzFile comprfile; 
+	
+	if (comprfile = gzopen(filename, mode) == Z_NULL)
+		err(1, "Could not open compressed file %s.", filename);
+	gzread(comprfile, buf, MAXBUFSIZE);
+	file = fdopen(buf, mode);
+	 
+	return file;
+}

Added: soc2012/jhagewood/diff/diff
==============================================================================
Binary file. No diff available.

Added: soc2012/jhagewood/diff/diff-test.sh
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ soc2012/jhagewood/diff/diff-test.sh	Wed Aug  8 16:07:26 2012	(r240196)
@@ -0,0 +1,101 @@
+# Script for testing BSD diff outputs against GNU diff outputs.
+# Jesse Hagewood
+# jhagewood@freebsd.org
+
+#!/bin/sh
+
+rm -rf ./test_outputs
+mkdir ./test_outputs
+mkdir ./test_outputs/gnu
+mkdir ./test_outputs/bsd
+
+run () {
+
+	# Default diff
+	$1 1.txt 2.txt >> $2/diff.txt
+
+	# --unified output
+	$1 -u 1.txt 2.txt >> $2/unified.txt
+	$1 --unified 1.txt 2.txt >> $2/unified.txt
+	$1 --unified="3" 1.txt 2.txt >> $2/unified.txt
+
+	# --context output
+	$1 -c 1.txt 2.txt >> $2/context.txt
+	$1 --context	1.txt 2.txt >> $2/context.txt
+	$1 --context="3" 1.txt 2.txt >> $2/context.txt
+
+	# --normal format output
+	$1 --normal 1.txt 2.txt >> $2/normal.txt
+	$1 -c --normal 1.txt 2.txt >> $2/normal.txt
+	$1 -u --normal 1.txt 2.txt >> $2/normal.txt
+
+	# --brief
+	$1 -b 1.txt 2.txt >> $2/brief.txt
+	$1 --brief 1.txt 2.txt >> $2/brief.txt
+
+	# --ed 
+	$1 -ed 1.txt 2.txt >> $2/ed.txt
+	$1 -e 1.txt 2.txt >> $2/ed.txt
+
+	# --expand-tabs
+	$1 --expand-tabs 1.txt 2.txt >> $2/expand-tabs.txt
+	$1 -t 1.txt 2.txt >> $2/expand-tabs.txt
+
+	# --forward-ed
+	$1 --forward-ed 1.txt 2.txt >> $2/forward-ed.txt
+	$1 -f 1.txt 2.txt >> $2/forward-ed.txt
+	
+	# --to-file
+	# XXX Currently hangs on BSD diff.
+	#$1 --to-file="3.txt" 1.txt 2.txt >> $2/tofile.txt
+	
+	# --from-file
+	# XXX Currently hangs on BSD diff.
+	#$1 --from-file="3.txt" 1.txt 2.txt >> $2/fromfile.txt
+	
+	# --text
+	$1 --text 1.txt 2.txt >> $2/text.txt
+	$1 -a 1.txt 2.txt >> $2/text.txt
+	
+	# --strip-trailing-cr
+	$1 --strip-trailing-cr 1.txt 2.txt >> $2 stripcr.txt
+	
+	# --rcs
+	$1 --rcs 1.txt 2.txt >> $2/rcs.txt
+	$1 -n 1.txt 2.txt >> $2/rcs.txt
+	
+	# --width
+	$1 --width="10" 1.txt 2.txt >> $2/width.txt
+	$1 -W "10" 1.txt 2.txt >> $2/width.txt
+	
+	# --side-by-side
+	$1 --side-by-side 1.txt 2.txt >> $2/sbs.txt
+	$1 -y 1.txt 2.txt >> $2/sbs.txt
+	
+	# --left-column
+	$1 -y --left-column 1.txt 2.txt >> $2/lc.txt
+	$1 --side-by-side --left-column 1.txt 2.txt >> $2/lc.txt 
+	
+	# --suppress-common-lines
+	$1 -y --suppress-common-lines 1.txt 2.txt >> $2/scl.txt
+	$1 --side-by-side --suppress-common-lines 1.txt 2.txt >> $2/scl.txt
+
+	# --line-format
+	$1 --line-format="%l %% %c'T'" 1.txt 2.txt >> $2/lf.txt
+	
+	# --help
+	$1 --help 1.txt 2.txt >> $2/help.txt
+}
+
+DIR_PATH="./test_outputs/gnu"
+DIFF_PATH="/usr/bin/diff"
+run "$DIFF_PATH" "$DIR_PATH"
+DIR_PATH="./test_outputs/bsd"
+DIFF_PATH="./diff"
+run "$DIFF_PATH" "$DIR_PATH"
+
+#
+# Get the diff between the GNU and BSD outputs.
+#
+
+diff -rupN ./test_outputs/gnu/ ./test_outputs/bsd/ >> ./test_outputs/gnu-bsd-diff.txt

Added: soc2012/jhagewood/diff/diff.1
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ soc2012/jhagewood/diff/diff.1	Wed Aug  8 16:07:26 2012	(r240196)
@@ -0,0 +1,511 @@
+.\"	$FreeBSD$
+.\"	$OpenBSD: diff.1,v 1.33 2007/05/31 19:20:09 jmc Exp $
+.\"
+.\" Copyright (c) 1980, 1990, 1993
+.\"	The Regents of the University of California.  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.
+.\" 3. Neither the name of the University nor the names of its contributors
+.\"    may be used to endorse or promote products derived from this software
+.\"    without specific prior written permission.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
+.\"
+.\"     @(#)diff.1	8.1 (Berkeley) 6/30/93
+.\"
+.Dd Apr 7, 2008
+.Dt DIFF 1
+.Os
+.Sh NAME
+.Nm diff
+.Nd differential file and directory comparator
+.Sh SYNOPSIS
+.Nm diff
+.Op Fl abdilpqTtw
+.Op Fl I Ar pattern
+.Oo
+.Fl c | e | f |
+.Fl n | u
+.Oc
+.Op Fl L Ar label
+.Ar file1 file2
+.Nm diff
+.Op Fl abdilpqTtw
+.Op Fl I Ar pattern
+.Op Fl L Ar label
+.Fl C Op Ar number
+.Ar file1 file2
+.Nm diff
+.Op Fl abdilqtw
+.Op Fl I Ar pattern
+.Fl D Ar string
+.Ar file1 file2
+.Nm diff
+.Op Fl abdilpqTtw
+.Op Fl I Ar pattern
+.Op Fl L Ar label
+.Fl U Ar number
+.Ar file1 file2
+.Nm diff
+.Op Fl abdilNPpqrsTtw
+.Op Fl I Ar pattern
+.Oo
+.Fl c | e | f |
+.Fl n | u
+.Oc
+.Bk -words
+.Op Fl L Ar label
+.Op Fl S Ar name
+.Op Fl X Ar file
+.Op Fl x Ar pattern
+.Ek
+.Ar dir1 dir2
+.Nm diff
+.Op Fl v
+.Sh DESCRIPTION
+The
+.Nm
+utility compares the contents of
+.Ar file1
+and
+.Ar file2
+and writes to the standard output the list of changes necessary to
+convert one file into the other.
+No output is produced if the files are identical.
+.Pp
+Output options (mutually exclusive):
+.Bl -tag -width Ds
+.It Fl C Op Ar number , Fl Fl context Ns = Ns Op Ar number
+Like
+.Fl c
+but produces a diff with
+.Ar number
+lines of context.
+.It Fl c
+Produces a diff with 3 lines of context.
+With
+.Fl c
+the output format is modified slightly:
+the output begins with identification of the files involved and
+their creation dates and then each change is separated
+by a line with fifteen
+.Li * Ns 's .
+The lines removed from
+.Ar file1
+are marked with
+.Sq \&-\ \& ;
+those added to
+.Ar file2
+are marked
+.Sq \+\ \& .
+Lines which are changed from one file to the other are marked in
+both files with
+.Sq !\ \& .
+Changes which lie within 3 lines of each other are grouped together on
+output.
+.It Fl D Ar string , Fl Fl ifdef Ns = Ns Ar string
+Creates a merged version of
+.Ar file1
+and
+.Ar file2
+on the standard output, with C preprocessor controls included so that
+a compilation of the result without defining
+.Ar string
+is equivalent to compiling
+.Ar file1 ,
+while defining
+.Ar string
+will yield
+.Ar file2 .
+.It Fl e , Fl Fl ed
+Produces output in a form suitable as input for the editor utility,
+.Xr ed 1 ,
+which can then be used to convert file1 into file2.
+.Pp
+Extra commands are added to the output when comparing directories with
+.Fl e ,
+so that the result is a
+.Xr sh 1
+script for converting text files which are common to the two directories
+from their state in
+.Ar dir1
+to their state in
+.Ar dir2 .
+.It Fl f
+Identical output to that of the
+.Fl e
+flag, but in reverse order.
+It cannot be digested by
+.Xr ed 1 .
+.It Fl n , Fl Fl rcs
+Produces a script similar to that of
+.Fl e ,
+but in the opposite order and with a count of changed lines on each
+insert or delete command.
+This is the form used by
+.Xr rcsdiff 1 .
+.It Fl q , Fl Fl brief
+Just print a line when the files differ.
+Does not output a list of changes.
+.It Fl U Op Ar number , Fl Fl unified Ns = Ns Op Ar number
+Like
+.Fl u
+but produces a diff with
+.Ar number
+lines of context.
+.It Fl u
+Produces a
+.Em unified
+diff with 3 lines of context.
+A unified diff is similar to the context diff produced by the
+.Fl c
+option.
+However, unlike with
+.Fl c ,
+all lines to be changed (added and/or removed) are present in
+a single section.
+.El
+.Pp
+Comparison options:
+.Bl -tag -width Ds
+.It Fl a ,  Fl Fl text
+Treat all files as
+.Tn ASCII
+text.
+Normally
+.Nm
+will simply print
+.Dq Binary files ... differ
+if files contain binary characters.
+Use of this option forces
+.Nm
+to produce a diff.
+.It Fl b , Fl Fl ignore-space-change
+Causes trailing blanks (spaces and tabs) to be ignored, and other
+strings of blanks to compare equal.
+.It Fl d , Fl Fl minimal
+Try very hard to produce a diff as small as possible.
+This may consume a lot of processing power and memory when processing
+large files with many changes.
+.It Fl I Ar pattern , Fl Fl ignore-matching-lines Ns = Ns Ar pattern
+Ignores changes, insertions, and deletions whose lines match the
+extended regular expression
+.Ar pattern .
+Multiple
+.Fl I
+patterns may be specified.
+All lines in the change must match some pattern for the change to be
+ignored.
+See
+.Xr re_format 7
+for more information on regular expression patterns.
+.It Fl i , Fl Fl ignore-case
+Ignores the case of letters.
+E.g.,
+.Dq A
+will compare equal to
+.Dq a .
+.It Fl L Ar label
+Print
+.Ar label
+instead of the first (and second, if this option is specified twice)
+file name and time in the context or unified diff header.
+.It Fl l , Fl Fl paginate
+Long output format; each text file
+.Nm diff Ns \'d
+is piped through
+.Xr pr 1
+to paginate it;
+other differences are remembered and summarized
+after all text file differences are reported.
+.It Fl p , Fl Fl show-c-function
+With unified and context diffs, show with each change
+the first 40 characters of the last line before the context beginning
+with a letter, an underscore or a dollar sign.
+For C source code following standard layout conventions, this will
+show the prototype of the function the change applies to.
+.It Fl T , Fl Fl initial-tab
+Print a tab rather than a space before the rest of the line for the
+normal, context or unified output formats.
+This makes the alignment of tabs in the line consistent.
+.It Fl t , Fl Fl expand-tabs
+Will expand tabs in output lines.
+Normal or
+.Fl c
+output adds character(s) to the front of each line which may screw up
+the indentation of the original source lines and make the output listing
+difficult to interpret.
+This option will preserve the original source's indentation.
+.It Fl w , Fl Fl ignore-all-space
+Is similar to
+.Fl b
+but causes whitespace (blanks and tabs) to be totally ignored.
+E.g.,
+.Dq if (\ \&a == b \&)
+will compare equal to
+.Dq if(a==b) .
+.El
+.Pp
+Directory comparison options:
+.Bl -tag -width Ds
+.It Fl N , Fl Fl new-file
+If a file is found in only one directory, act as if it was found in the
+other directory too but was of zero size.
+.It Fl P
+If a file is found only in
+.Ar dir2 ,
+act as if it was found in
+.Ar dir1
+too but was of zero size.
+.It Fl r , Fl Fl recursive
+Causes application of
+.Nm
+recursively to common sub7 directories encountered.
+.It Fl S Ar name , Fl starting-file Ns = Ns Ar name
+Re-starts a directory
+.Nm
+in the middle, beginning with file
+.Ar name .
+.It Fl s , Fl Fl report-identical-files
+Causes
+.Nm
+to report files which are the same, which are otherwise not mentioned.
+.It Fl X Ar file , Fl Fl exclude-from Ns = Ns Ar file
+Exclude files and subdirectories from comparison whose basenames match
+lines in
+.Ar file .
+Multiple
+.Fl X
+options may be specified.
+.It Fl x Ar pattern , Fl Fl exclude Ns = Ns Ar pattern
+Exclude files and subdirectories from comparison whose basenames match
+.Ar pattern .
+Patterns are matched using shell-style globbing via
+.Xr fnmatch 3 .
+Multiple
+.Fl x
+options may be specified.
+.It Fl v , Fl Fl version
+Print version ino.
+.El
+.Pp
+If both arguments are directories,
+.Nm
+sorts the contents of the directories by name, and then runs the
+regular file
+.Nm
+algorithm, producing a change list,
+on text files which are different.
+Binary files which differ,
+common subdirectories, and files which appear in only one directory
+are described as such.
+In directory mode only regular files and directories are compared.
+If a non-regular file such as a device special file or
+.Tn FIFO
+is encountered, a diagnostic message is printed.
+.Pp
+If only one of
+.Ar file1
+and
+.Ar file2
+is a directory,
+.Nm
+is applied to the non-directory file and the file contained in
+the directory file with a filename that is the same as the
+last component of the non-directory file.
+.Pp
+If either
+.Ar file1
+or
+.Ar file2
+is
+.Sq Fl ,
+the standard input is
+used in its place.
+.Ss Output Style
+The default (without
+.Fl e ,
+.Fl c ,
+or
+.Fl n
+.\" -C
+options)
+output contains lines of these forms, where
+.Va XX , YY , ZZ , QQ
+are line numbers respective of file order.
+.Pp
+.Bl -tag -width "XX,YYcZZ,QQ" -compact
+.It Li XX Ns Ic a Ns Li YY
+At (the end of) line
+.Va XX
+of
+.Ar file1 ,
+append the contents
+of line
+.Va YY
+of
+.Ar file2
+to make them equal.
+.It Li XX Ns Ic a Ns Li YY,ZZ
+Same as above, but append the range of lines,
+.Va YY
+through
+.Va ZZ
+of
+.Ar file2
+to line
+.Va XX
+of file1.
+.It Li XX Ns Ic d Ns Li YY
+At line
+.Va XX
+delete
+the line.
+The value
+.Va YY
+tells to which line the change would bring
+.Ar file1
+in line with
+.Ar file1 .
+.It Li XX,YY Ns Ic d Ns Li ZZ
+Delete the range of lines
+.Va XX
+through
+.Va YY
+in
+.Ar file1 .
+.It Li XX Ns Ic c Ns Li YY
+Change the line
+.Va XX
+in
+.Ar file1
+to the line
+.Va YY
+in
+.Ar file2 .
+.It Li XX,YY Ns Ic c Ns Li ZZ
+Replace the range of specified lines with the line
+.Va ZZ .
+.It Li XX,YY Ns Ic c Ns Li ZZ,QQ
+Replace the range
+.Va XX , Ns Va YY
+from
+.Ar file1
+with the range
+.Va ZZ , Ns Va QQ
+from
+.Ar file2 .
+.El
+.Pp
+These lines resemble
+.Xr ed 1
+subcommands to convert
+.Ar file1
+into
+.Ar file2 .
+The line numbers before the action letters pertain to
+.Ar file1 ;
+those after pertain to
+.Ar file2 .
+Thus, by exchanging
+.Ic a
+for
+.Ic d
+and reading the line in reverse order, one can also
+determine how to convert
+.Ar file2
+into
+.Ar file1 .
+As in
+.Xr ed 1 ,
+identical
+pairs (where num1 = num2) are abbreviated as a single
+number.
+.Sh ENVIRONMENT
+.Bl -tag -width TMPDIR
+.It Ev TMPDIR
+If the environment variable
+.Ev TMPDIR
+exists,
+.Nm
+will use the directory specified by
+.Ev TMPDIR
+as the temporary directory.
+.El
+.Sh FILES
+.Bl -tag -width /tmp/diff.XXXXXXXX -compact
+.It Pa /tmp/diff. Ns Ar XXXXXXXX
+Temporary file used when comparing a device or the standard input.
+Note that the temporary file is unlinked as soon as it is created
+so it will not show up in a directory listing.
+.El
+.Sh DIAGNOSTICS
+The
+.Nm
+utility exits with one of the following values:
+.Pp
+.Bl -tag -width Ds -compact -offset indent
+.It 0
+No differences were found.
+.It 1
+Differences were found.
+.It \*(Gt1
+An error occurred.
+.El
+.Sh SEE ALSO
+.Xr cmp 1 ,
+.Xr comm 1 ,
+.Xr diff3 1 ,
+.Xr ed 1 ,
+.Xr pr 1 ,
+.Xr sdiff 1 ,
+.Xr fnmatch 3 ,
+.Xr re_format 7
+.Sh STANDARDS
+The
+.Nm
+utility is compliant with the
+St -p1003.1-2004
+specification.
+.Pp
+The flags
+.Op Fl aDdIiLlNnPpqSsTtUuwXx
+are extensions to that specification.
+.Sh HISTORY
+A
+.Nm
+command appeared in
+.At v6 .
+.Sh BUGS
+When comparing directories with the
+.Fl b ,
+.Fl w
+or
+.Fl i
+options specified,
+.Nm
+first compares the files ala
+.Xr cmp 1 ,
+and then decides to run the
+.Nm
+algorithm if they are not equal.
+This may cause a small amount of spurious output if the files
+then turn out to be identical because the only differences are
+insignificant whitespace or case differences.

Added: soc2012/jhagewood/diff/diff.1.gz
==============================================================================
Binary file. No diff available.

Added: soc2012/jhagewood/diff/diff.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ soc2012/jhagewood/diff/diff.c	Wed Aug  8 16:07:26 2012	(r240196)
@@ -0,0 +1,711 @@
+/*
+ * Copyright (c) 2003 Todd C. Miller <Todd.Miller@courtesan.com>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Sponsored in part by the Defense Advanced Research Projects
+ * Agency (DARPA) and Air Force Research Laboratory, Air Force
+ * Materiel Command, USAF, under agreement number F39502-99-1-0512.
+ */
+
+#if 0
+#ifndef lint
+static char sccsid[] = "@(#)diff.c	8.1 (Berkeley) 6/6/93";
+#endif
+#endif /* not lint */
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <sys/param.h>
+#include <sys/stat.h>
+
+#include <ctype.h>
+#include <err.h>
+#include <errno.h>
+#include <getopt.h>
+#include <signal.h>
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#include "diff.h"
+#include "pathnames.h"
+
+int	aflag, bflag, cflag, dflag, Eflag, iflag, lflag, Nflag, Pflag, pflag, rflag;
+int	sflag, tflag, Tflag, wflag, Toflag, Fromflag;
+int	Bflag, yflag;
+int filebehave;
+int strip_cr, suppress_cl, tabsize = 8;
+char ignore_file_case = 0;
+int	format, context, status;
+char *start, *ifdefname, *diffargs, *label[2], *ignore_pats, *line_format, *group_format;
+struct stat stb1, stb2;
+struct excludes *excludes_list;
+regex_t	 ignore_re;
+
+int flag_opts = 0;
+
+#define	OPTIONS	"0123456789aBbC:cdD:EefhI:iL:lnNPpqrS:sTtU:uvwXy:x"
+
+
+/* Options which exceed manageable alphanumeric assignments */ 
+enum 
+{
+  OPT_IGN_FN_CASE = CHAR_MAX + 1,
+  OPT_NIGN_FN_CASE,
+  OPT_STRIPCR,
+  OPT_NORMAL,
+  OPT_LEFTC,
+  OPT_SUPCL,
+  OPT_CHGD_GF,
+  OPT_NEW_GF,
+  OPT_OLD_GF,
+  OPT_UNCHGD_GF,
+  OPT_LF,
+  OPT_LLF,
+  OPT_TSIZE,
+  OPT_FFILE,
+  OPT_TOFILE,
+  OPT_HLINES,
+  OPT_LFILES,
+  OPT_HELP,
+  OPT_NEW_LF,
+  OPT_OLD_LF,
+  OPT_UNCHGD_LF,
+};
+
+
+static struct option longopts[] = {
+	
+	/*
+	 * Commented-out options are unimplemented.
+	 */
+
+	{ "brief",			no_argument,		NULL,	'q' },
+	{ "changed-group-format",		required_argument,	NULL,	OPT_CHGD_GF},
+	{ "context",			optional_argument,	NULL,	'C' },
+	{ "ed",				no_argument,		NULL,	'e' },
+	{ "exclude",			required_argument,	NULL,	'x' },
+	{ "exclude-from",		required_argument,	NULL,	'X' },
+	{ "expand-tabs",		no_argument,		NULL,	't' },
+	{ "from-file",			required_argument,	NULL,	OPT_FFILE },
+	{ "forward-ed",			no_argument,		NULL,	'f' },
+	{ "help",			no_argument,		NULL,	OPT_HELP },
+	/*{ "horizon-lines",		required_argument,	NULL,	OPT_HLINES },*/
+	{ "ifdef",			required_argument,	NULL,	'D' },
+	{ "ignore-all-space",		no_argument,		NULL,	'W' },
+	{ "ignore-blank-lines",		no_argument,		NULL,	'B' },
+ 	{ "ignore-case",		no_argument,		NULL,	'i' },
+	{ "ignore-file-name-case",	no_argument,		NULL,	OPT_IGN_FN_CASE },
+	{ "ignore-matching-lines",	required_argument,	NULL,	'I' },
+	{ "ignore-space-change",	no_argument,		NULL,	'b' },
+	{ "ignore-tab-expansion",	no_argument,		NULL,	'E' },
+	{ "initial-tab",		no_argument,		NULL,	'T' },
+	{ "label",			required_argument,	NULL,	'L' },
+	{ "left-column",		no_argument,		NULL,	OPT_LEFTC },
+	{ "line-format",		required_argument,	NULL,	OPT_LF },
+	{ "minimal",			no_argument,		NULL,	'd' },
+	{ "new-file",			no_argument,		NULL,	'N' },
+	{ "new-line-format",		required_argument,		NULL,	OPT_NEW_LF},
+	{ "new-group-format",		required_argument,		NULL, 	OPT_NEW_GF},
+	{ "no-ignore-file-name-case",	no_argument,		NULL,	OPT_NIGN_FN_CASE },
+	{ "normal",			no_argument,		NULL,	OPT_NORMAL },
+	{ "old-line-format",		required_argument,		NULL,	OPT_OLD_LF},
+	{ "old-group-format",		required_argument,		NULL,	OPT_OLD_GF},
+	{ "paginate",			no_argument,		NULL,	'l' },
+	{ "recursive",			no_argument,		NULL,	'r' },
+	{ "report-identical-files",	no_argument,		NULL,	's' },
+	{ "rcs",			no_argument,		NULL,	'n' },
+	{ "show-c-function",		no_argument,		NULL,	'p' },
+	{ "show-function-line",		required_argument,	NULL,	'F' },
+	{ "side-by-side",		no_argument,		NULL,	'y' },
+	/*{ "speed-large-files",		no_argument,		NULL,	OPT_LFILES }, */
+	{ "starting-file",		required_argument,	NULL,	'S' },	
+	{ "strip-trailing-cr",		no_argument,		NULL,	OPT_STRIPCR },
+	{ "suppress-common-lines",	no_argument,		NULL,	OPT_SUPCL },
+	{ "tabsize",			optional_argument,	NULL,	OPT_TSIZE },
+	{ "text",			no_argument,		NULL,	'a' },
+	{ "to-file",			required_argument,	NULL,	OPT_TOFILE },
+	{ "unchanged-group-format",		required_argument,			NULL,	OPT_UNCHGD_GF},
+	{ "unchanged-line-format",		required_argument,			NULL,	OPT_UNCHGD_LF},
+	{ "unidirectional-new-file",	no_argument,		NULL,	'P' },
+	{ "unified",			optional_argument,	NULL,	'U' },
+	{ "version",			no_argument,		NULL,	'v' },
+	/*{ "width",			optional_argument,	NULL,	'w' }, */
+	{ NULL,				0,			NULL,	'\0'}
+};
+
+static const char *help_msg[] = { 
+"\t-a --text  treat files as ASCII text",
+"\t-B --ignore-blank-lines  Ignore blank newlines in the comparison",
+"\t-b --ignore-space-change  Ignore all changes due to whitespace",
+"\t-C -c NUM --context=NUM  Show NUM lines before and after change (default 3)",
+"\t-D --ifdef=NAME  Output merged file with `#ifdef NAME' diffs",
+"\t-E --ignore-tab-expansion  Ignore tab expansion in the comparison",
+"\t-e --ed  Output an ed script",
+"\t-F --show-function-line=RE	 Show the most recent line matching RE",
+"\t-f --forward-ed  Output a forward ed script",
+"\t-I --ignore-matching-lines=RE  Ignore changes whose lines all match RE",
+"\t-i --ignore-case  Ignore case differences in file contents",
+"\t-L --label=NAME  Label file header",
+"\t-l --paginate  Paginates output through pr",
+"\t-N --new-file  Treat new files as empty",
+"\t-n --rcs  Output an RCS format diff",
+"\t-P --unidirectional-new-file  Treat absent-first files as empty",
+"\t-p --show-c-function  Show which C function each change is in",
+"\t-q --brief  report only when files differ",
+"\t-r --recursive Recursively compare any sub-directories found",
+"\t-S --starting-file=FILE  Start with FILE when comparing directories",
+"\t-s --report-identical-files Report when two files are the same",
+"\t-T --initial-tab  Make tabs line up by prepending a tab",
+"\t-t --expand-tabs  Expand tabs to spaces in output",
+"\t-U -u NUM --unified=NUM  Show NUM lines of unified context",
+"\t-v --version  Show diff version",
+"\t-W --ignore-all-space Ignore all space",

*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20120808160726.99307106564A>