                         Tadzio's File Compare
                         =====================

                               Version 3.1

         Original (c) 1997-2000 Daniel Schroeder (tadzio@tadzio.com)
		    Enhancements (c) 2007 Ian Binnie

For a list of changes since the last version see "10. Version History"
at the end of this document!


0. Contents
___________

 1. What is it?
 2. It's free!
 3. Legal stuff
 4. Command line options
 5. Interactive usage
 6. Unicode
 7. What does 'Tadzio' stand for?
 8. How TFC Works
 9. Getting the latest version
10. Version history
11. Contacting the author


1. What is it?
______________

Tadzio's File Compare (or TFC) is a small and fast side-by-side file compare
utility for Windows 9x and NT. It takes two file names from the command line
(or one file name and one directory, or some wildcards - see below) and
displays them side-by-side in a console window, highlighting differing
lines. TFC employs a sophisticated resync mechanism to find matching portions
of the two files. It will allow you to scroll through the two files, modify
comparison criteria like case sensitivity or ignoring empty lines, and jump
directly to the next or previous difference.

TFC was modelled after "Jeff's file compare" which was included in later
versions of XTree, but has an improved resync mechanism and a better user
interface. It was designed to be used both as a stand-alone program and a
plug-in for Kim Henkel's great XTree clone ZTreeWin (available at
www.ztree.com; starting with version 1.30, ZTreeWin distribution archives
include TFC).

Note: TFC treats any single Carriage Return (CR), single Line Feed (LF), and
CR/LF combination as end-of-line character. It does not differentiate between
them which means that TFC treats files that differ only in their end-of-line
character as identical.


2. It's free!
_____________
That's right - it will cost you nothing!


3. Legal stuff
______________
New: TFC is now covered by the GNU General Public License,
see http://www.gnu.org.


Warranty:

Basically, "you get what you pay for." So there's no warranty at all. We will
not be liable for any damage, loss of profit or other consequences arising out
of the use of Tadzio's File Compare utility.

That said, TFC is safe. Both files to be compared are opened in read-only mode
and closed again as soon as they are read into memory. TFC never attempts to
write to your hard disk (except for its configuration file, TFC.ini, and maybe
triggering Windows' memory swapping mechanism if you compare very large files),
so it's highly unlikely that anything on your hard disk gets corrupted.
Also, TFC knows nothing about MAPI or TCP/IP, so it will never send any
information to anyone over a network.


4. Command line options
_______________________

                 TFC [-options] file1 [file2]

[] denote optional parts.

file1: Any valid file name, with or without path. Long file names are
  supported. If it contains blanks, surround it with double quotes.
  You can not use wildcards ('*' and '?') here.

file2: Either a file name or a directory or nothing. If you do not specify
  file2, TFC assumes the same name as file1, with the extension '.bak'.
  If you specify a directory, TFC will append the name and extension portion
  (omitting the drive and directory parts, if any) of file1 to it. You may
  specify the directory with or without a trailing backslash.
  You may replace the name and/or extension portion of file2 with an asterisk.
  In that case, the corresponding part of file1 is used in place of that
  wild card. The question mark wild card '?' is not supported.

Examples: this command line      |  compares file     |     to file
_____________________________________________________________________________
 TFC c:\config.sys               |  c:\config.sys     | c:\config.bak
 TFC c:\config.sys  c:\backup    |  c:\config.sys     | c:\backup  (see Note)
                                 |                    | c:\backup\config.sys
 TFC c:\config.sys  *.old        |  c:\config.sys     | c:\config.old
 TFC c:\config.sys  d:\aaa\*.old |  c:\config.sys     | d:\aaa\config.old
 TFC autoexec.bat   4start.*     |  autoexec.bat      | 4start.bat
 TFC "Letter to Diane"           |  "Letter to Diane" | "Letter to Rosie"
             "Letter to Rosie"   |                    |

Note: If c:\backup exists; if not, TFC tries c:\backup\config.sys instead.
______________________________________________________________________________


Options:

-aYY[,XX]: Set window height to YY lines [, width to XX columns]. Either
  can be omitted,  -aYY -aYY,XX and -A,XX are all valid. The upper limit
  depends on the operating system and actual screen size. This is not
  necessary if TFC is started by ZTreeWin.

-b: Batch mode. The two files are compared, a one-line-info is printed ("The
  file are identical" or "The files are not identical"), and TFC exits with
  one of the following error levels:
  0: files are identical (or similar)
  1: files are not identical
  2: one of the files could not be found or opened
  3: out of memory (though I'm not sure if this will ever happen under Win32)
  This option is meant for using TFC in batch files, e.g. for synchronising
  directories or automatically checking if a file has changed before backing it
  up.

-c: Case insensitive compare. By default, TFC treats upper case and lower case
  characters as different.

-d: Toggles highlighting of differing characters within a line on or off.
  Turning this on may slow down TFC a bit, and may make for a confusing display
  if lines are totally different, so that characters will only randomly match.

-e: Suppress empty lines. All lines that contain only whitespace
  characters (blanks, tabs) are ignored during compare and display.

-h: Toggles between hex and character mode. The toggle affects the compare
  routines as well as the display routines. In hex mode, every line contains
  8, 12, 16, 24, 32, 40 ... characters up to the window width.
  Note that as of version 2.20, TFC will *not* try to resync files in hex
  mode, as most users seem to use it for files where some bytes were *changed*,
  but not inserted or deleted.

-l: No line numbers are displayed.

-m  Don't display menu

-n: Same as -l, for compatibility with JFC

-o: Toggles between OEM and ANSI character sets. OEM (or ASCII) is used by
  DOS-based programs, whereas Windows-based programs use ANSI.

-s: Sync scan many lines (see 8b. Sync scan). If TFC finds two lines to be
  different, it assumes some lines were inserted in one of the files, and the
  matching line is somewhere further down in the file. So by default it scans
  the next 200 lines to find it ("resync"). If you compare files of which you
  know that more than 200 lines were inserted somewhere, you may want to use
  this option. However, this may slow down TFC considerably.

-s+: Sync scan whole file.

-v: Start with a vertically split display. The default is a horizontally split
  display

-w: Compress white space. All sequences of one or more whitespace characters
  are treated as one single blank character during compare and display. This
  makes it possible to compare two versions of a file where one version has
  tabs, and some editor changed those tabs to a series of blanks in the second
  version.

-1: ... -9: sets the size of the block of lines to match against the target
  (default 4). Larger blocks may improve matching, but may also make it worse
  where there are many changes. (See 8a. Choice of 'block' size)


5. Interactive usage
____________________

By default, TFC displays the two file on a horizontally split
screen. The colours are taken from TFC.ini, if it can be found in the
directory where TFC.exe lives; otherwise, TFC tries to read the colours
from ZTW.INI. If that also fails, default colours are used. There is a
colour setup utility built into TFC (try pressing Alt-F10) that creates
TFC.ini.

If the files to compare are identical, TFC tells you so, waits for a key
stroke (not in batch mode) and exits.

If the files to compare are similar (ignoring end-of-line characters and,
depending on options, Case insensitive compare, Compress white space, Suppress
empty lines), TFC tells you so, but continues - allowing options to be changed,
or exit with Esc.

The usual cursor keys can be used to navigate through the two files. They work
like in any other program, with one additional feature: If you scrolled the
display to the right, Pos1 (Home) does not jump to the beginning of the files,
but rather to the beginning of the line. If you press it again, TFC then
will jump to the beginning of the files.

'+' and '-' jump to the next and previous block of different lines,
respectively. If there is no such block, they jump to the end resp. beginning
of the files. The space bar functions identically to '+'.

's' toggles between horizontal and vertical splitting of the screen.

'h' toggles between hex and character mode. The toggle affects the compare
routines as well as the display routines. In hex mode, every line contains
8, 12, 16, 24, 32, 40 ... characters up to the window width.
The line number display changes to a file-offset display, using hexadecimal
numbers. When entering hex mode TFC tries to position the hex display at the
current line (this does not apply when returning to character mode).

'l' (thats an ell) toggles line numbers on and off - for those of you who want
to see more of the files and are not interested in line numbers. For
compatibility with jfc, 'n' is also accepted. In hex mode, the line number
display changes to a file offset hex display that cannot be switched off.

't' toggles between 25 lines and x lines display, where x is either 50 (if TFC
was started in 25-lines-mode) or the number of lines of the active mode when
TFC was started (otherwise). Regardless of the state of this toggle, when
exiting TFC always switches back to the mode that was active when TFC was
started. (This option is obsolete, and retained for backward compatibiliy.)

'1'...'9' sets the display width of tab characters. Note that this does NOT
have any impact on the compare operation, only on the display!
Tabs are relative to the display window, so if you have scrolled source to the
right, tab display may change.

'c' toggles between case sensitive compare (the default) and case-insensitive
compare. The case-insensitive setting handles characters depending on your
Locale - e.g. German umlauts are handled correctly!

'o' toggles between OEM and ANSI character sets. OEM (or ASCII) is used by
DOS-based programs, whereas Windows-based programs use ANSI.

'w' toggles white space compression on and off. If on, all sequences of
whitespace characters (blanks, tabs) in the two files are replaced by one
single blank. This affects the compare operation as well as the display.

'e' toggles empty line suppression on and off. If on, all lines that contain
nothing but blanks and/or tabs are ignored.

'm' toggles the menu display on/off, after all if you have seen it thousands of
times it is not necessary, which frees up more screen real estate.

F1 gives you access to the online help, although I feel TFC is so easy and
intuitive to use that the online help shouldn't be really necessary.

Alt-1 ... Alt-9 sets the size of the block of lines to match. (See 8a. Choice of
'block' size)

Alt-s toggles Sync scan lines between default (200) and maximum.

Alt-F7 toggles to maximum size and back to previous size.

Alt-F8 cycles width between 80,100,120, ... screen width columns.

Alt-F9 cycles height between 25, 50, 60, 70, ... screen height lines.

Alt-F10 invokes the colour setup facility, see below.

ESC and ENTER both exit TFC.


5a. Colour Setup
________________

There is a built-in colour setup facility that can be invoked by
pressing Alt-F10.

The colour setup facility allows you to customize TFC's colour scheme.
The colours are stored in a file named TFC.ini in the same directory as
TFC.exe (which may be different from the current directory!)

The colour setup screen shows two sample files which contain elements of all
possible colours. Note that during 'real' usage you need to toggle 'Diff chars'
on to see the 'Differing chars in differing line' colour.

To change a foreground colour, use uppercase letters, e.g. Shift-f or Shift-i.
To change background colours, just use the indicated letters, e.g. 'f' or 'i'.
The meaning of 'f', 'i', and 'l' should be rather self-explanatory.
'm' and 'd' are for characters in lines that differ between the two files.
'r' restores a built-in default colour scheme - in case you got totally
lost. 'k' deletes the file 'TFC.ini' from disk. If you called TFC from
within ZTree, TFC reverts back to ZTree's colour scheme. Otherwise, TFC uses
its default scheme. By pressing ESC, all changes (except deleting TFC.ini)
will be discarded. ENTER on the other hand writes the current colour scheme to
TFC.ini, regardless of how the colour scheme was created (inherited by ZTree,
'R'estored, etc).
Note that if you want TFC to inherit ZTree's colour scheme each time you use
it, you'll have to first 'k'ill TFC.ini, then press ESC - do NOT press ENTER,
as this would write a new TFC.ini, overriding ZTree's settings.


6. Unicode
__________
TFC is now Unicode enabled and can compare Unicode files (technically UTF-16LE
with or without BOM - these are the most common in Windows).

UTF-8 files can be compared (with UTF-8 or UTF-16LE). These are first converted
to Unicode internally.

It can also compare 8 bit files (i.e. ANSI or OEM), but the result is displayed
as Unicode. The most noticable difference is that all ANSI characters can be
displayed, not just those which map to OEM.

TFC can now compare ANSI files with Unicode. These are first converted to
Unicode internally. (OEM is not supported for mixed comparisons).

For all internal conversions the Hex display shows the original content.

NOTE - the ability to display Unicode (or ANSI) depends on the font. The
default Windows raster fonts do not even display ANSI well; e.g. characters
0xD2-0xD8, 0xD8 all display as 'O'. Lucida Console and Andale Mono are
mono-spaced fonts which display most 652 WGL4 characters, even if they
are not the most attractive. Consolas looks better, but misses many OEM
characters e.g box drawing.

Windows 9x uses ANSI for file and directory names. Windows 2K and later use
Unicode. ZtreeWin translates these to OEM for display purposes. When file or
directory names contain special characters, such as the copyright sign, that
cannot be translated to OEM a substitute is used, but these cause errors,
because the file can not be found.

TFC attempts to find the original Unicode/ANSI name of the file, to enable it
to open the files, and correctly display names. This only happens if called
from ZtreeWin.

When used as a stand-alone program, TFC accepts Unicode file names.

An ANSI version is available for Win9x, but can be used on all Windows systems.

The download contains TFC.exe (Unicode) and TFC8.exe (ANSI)

Win9x systems should use the ANSI version, by renaming TFC8.exe to TFC.exe
Alternatively, change the ZTreeWin configuration (see help file
3.7.1 Configuration Page 1)

%#ZThome%\TFC8.EXE %1 %4 %5

Alternatively edit TFC.BAT to contain:-
@TFC8.EXE %1 %6 %4 %5


7. What does 'Tadzio' stand for?
________________________________

Tadzio is a nick name for 'Tadaeusz', a common Eastern European name.
Daniel Schroeder used it as a handle/nickname.


8. How TFC Works
________________

TFC steps through the 2 files comparing lines.

Firstly, TFC compares the current line in each file for equality.

If not equal:-

For each starting point it compares a 'block' of lines and calculates the number
which match, this will be 0..block. The pointer steps through the other file
repeating the comparison, and finds the best match i.e. maximum number of
matching lines. If the result is 'block' an exact match is found.

The step is repeated using the other file as the starting point.

The search is limited to the next 'sync scan' lines (default 200).

8a. Choice of 'block' size
__________________________
The size of the block of lines to match against the target has a significant
impact on how TFC works.

1 is a good value for files which are unlikely to contain repeated lines e.g.
log files, lists of files.

4 (default) is suitable for most files, and is good for identifying underlying
changes within lines, as it will find a good match for the surrounding lines.

Larger values (up to 9) may improve matching where many lines have been edited,
but may be worse if lines have been added/deleted.

Source code files, where small blocks of code are repeated may match better with
larger values.

8b. Sync scan
_____________

The default Sync scan is 200 lines (increased from 100 because of faster CPU).
This detects inserted blocks of up to 200 lines.

The -s option increases this to 2400, and -s+ will scan to the end of the file.

NOTE TFC only works for files where lines have been inserted/deleted, or which
are in a defined order.

8c. Know bugs and problems
_________________________

If a tab character is scrolled out of the left side of an window, the
remainder of that line jumps left to the window border. Fixing this would make
TFC much slower, so I hope you can live with it...


9. Getting the latest version
_____________________________

Version 2.21a is available at http://www.tadzio.com (this site is in German,
but you don't have to speak German. Just click on 'Home of TFC', then on
'Download', and there you go!).

Enhanced versions by Ian Binnie @ http://binnie.id.au/Downloads/TFC.zip

The download contains TFC.exe and TFC8.exe.

The source will of course be available.
http://binnie.id.au/Downloads/TFCforWindowsSource.zip


10. Version history
__________________

3.1   2008-03-29
		Added - check for "similar" files
		Added - Alt-F7 toggle to maximum size and back
		Added - SuperSync scan (-s+)
		Changed - Sync scan defaults changed
		Fixed - Sync scan (-s) reversed (wrong since 2.21a)

3.00k 2007-12-29
		Fixed - GPF on windows wider than 256

3.00j 2007-12-17
		Added - Unicode version warns if not NT4+
		Added - Alt+1..9, Alt+s commands

3.00h 2007-09-14      
		Added - Unicode file comparison
		Added - Unicode file names on command line
		Added - ZtreeWin specific file handling
			(Attempt to find the original Unicode/ANSI name)
		Added - Visual feedback of Toggle settings C, W, E, O, D
		Fixed - Tab expansion
		Added - large screen support
		Added - Alt-F8 screen width
		Changed - Alt-F9 screen height
		Changed - Command line switch now -aYY[,XX]
		Changed - no longer wastes one line of each window
		Added - option to hide menu (-m, M toggle)
		Changed - Hex file-offset display now minimum length 
		Changed - hex mode 8, 12, 16, 24, 32, 40 ...  characters

2.21a 1999-12-13 - Change: When window height is specified using -aXX,
                   the previous state is *not* restored on exit. This
                   should help ZTree users.
                 - Change: back to old window height (more correctly:
                   screen buffer height) detection method
                 - Change: better error handling if a WinAPI call to
                   change the screen buffer height fails.
2.21  1999-12-03 - Bugfix: When used stand-alone, TFC hides the cursor
                   and would not re-enable it when exiting - fixed.
2.20  1999-11-28 - Bugfix: file names that included non-ASCII characters
                   were inproperly parsed.
                 - Change: In hex mode, TFC no longer tries to re-sync.
                 - Change: In hex mode, the number of characters on one line
                   is now set to 8 (vertical-split) or 16 (horizontal-split)
                 - Change: In hex mode, a file offset is displayed instead of
                   the line number.
                 - Change: Changed the logic that determines the initial
                   window height.
                 - Change: TFC is now compiled with MS Visual C++ 6.0,
                   resulting in a smaller executable file.
                 - Change: Version history now uses standardized date
                   format ;-)

2.13  1999-06-06 - New: Command line switch -aXX to set window height to XX
                   lines.

2.12  1999-4-27  - Bugfix: Command line switch -n was not documented
                   at all, -v was missing in internal documentation.

2.11  1999-4-26  - Bugfix: TFC incorrectly stated that two files were
                   identical when the first n characters were identical,
                   where n is the length of the first file, and the
                   second file was longer than the first.

2.10  1999-4-23  - Bugfix: Cursor keys didn't work in Windows 9x when a
                   keyboard driver was loaded in CONFIG.SYS. This is the
                   case for all non-english versions of Windows. NT was
                   not affected.
                 - Change: The display is now split horizontally by default.
                 - Added: New command line switch '/s' to start with a
                   vertically split display, as pre-2.1 versions did.
                 - Added: The colour setup is now better documented.
                 - Change: The restriction for usage in a military
                   environment was removed.

2.02  1999-2-21  - Bugfix: Command line parameters ending in \" caused a
                   "can't open file" error.
                 - Documentation updates: New email address, own home page,
                   changed TFC.doc to TFC.txt
                 This version was never really released, because literally
                 minutes before I wanted to upload it, someone discovered a
                 serious bug. That's life!

2.01  1997-8-9   - Bugfix: file names that contained special characters (um_
                   lauts etc) weren't treated correctly
                 - New: ANSI/OEM toggle

2.0   1997-8-2   First Windows 95/NT version, based on the old OS/2 code,
                 but many new features.

1.0   1996-9-2   First public OS/2 version.


11. Contacting the author
_________________________

Daniel Schroeder author of Version 2.21a e-mail tadzio@tadzio.com

Ian Binnie author of enhanced versions 3.00 via ZTreeWin Forum
    http://ztw3.com/forum/forum.cgi
(Unfortunately due to spam, I no longer include email addresses on web pages.)
