diff -uNr catdoc-0.94.2.orig/src/catppt.c catdoc-0.94.2/src/catppt.c
--- catdoc-0.94.2.orig/src/catppt.c	2006-02-24 12:44:06.000000000 -0500
+++ catdoc-0.94.2/src/catppt.c	2006-08-28 23:23:24.000000000 -0400
@@ -109,13 +109,13 @@
 	} 
 	spec_chars=read_substmap(stradd("ascii",SPEC_EXT));
 	if (!spec_chars) {
-		fprintf(stderr,"Cannod read substitution map ascii%s\n",
+		fprintf(stderr,"Cannot read substitution map ascii%s\n",
 						SPEC_EXT);
 		exit(1);
 	}  
 	replacements=read_substmap(stradd("ascii",REPL_EXT));
 	if (!replacements) {
-		fprintf(stderr,"Cannod read substitution map ascii%s\n",
+		fprintf(stderr,"Cannot read substitution map ascii%s\n",
 						REPL_EXT);
 		exit(1);
 	}  
diff -uNr catdoc-0.94.2.orig/src/charsets.c catdoc-0.94.2/src/charsets.c
--- catdoc-0.94.2.orig/src/charsets.c	2006-02-24 12:44:06.000000000 -0500
+++ catdoc-0.94.2/src/charsets.c	2006-08-28 23:22:22.000000000 -0400
@@ -75,7 +75,7 @@
 	short int *new=calloc(sizeof(short int),256);
 	int c;
 	long int uc;
-	path= find_file(stradd(filename,CHARSET_EXT),charset_path);
+	path=find_file(stradd(filename,CHARSET_EXT),charset_path);
 	if (!path) {
 		fprintf(stderr,"Cannot load charset %s - file not found\n",filename);
 		return NULL;
diff -uNr catdoc-0.94.2.orig/src/config.h catdoc-0.94.2/src/config.h
--- catdoc-0.94.2.orig/src/config.h	1969-12-31 19:00:00.000000000 -0500
+++ catdoc-0.94.2/src/config.h	2006-08-28 23:25:04.000000000 -0400
@@ -0,0 +1,51 @@
+/* src/config.h.  Generated automatically by configure.  */
+/* src/config.h.in.  Generated automatically from configure.in by autoheader 2.13.  */
+
+/* Define to empty if the keyword does not work.  */
+/* #undef const */
+
+/* Define if the setvbuf function takes the buffering type as its second
+   argument and the buffer pointer as the third, as on System V
+   before release 3.  */
+/* #undef SETVBUF_REVERSED */
+
+/* Define if you have the ANSI C header files.  */
+#define STDC_HEADERS 1
+
+/* Define if your processor stores words with the most significant
+   byte first (like Motorola and SPARC, unlike Intel and VAX).  */
+/* #undef WORDS_BIGENDIAN */
+
+/* Define if you have the strdup function.  */
+#define HAVE_STRDUP 1
+
+/* Define if you have the strftime function.  */
+#define HAVE_STRFTIME 1
+
+/* Define if you have the strtol function.  */
+#define HAVE_STRTOL 1
+
+/* Define if you have the <unistd.h> header file.  */
+#define HAVE_UNISTD_H 1
+
+/* Define if you have the <windows.h> header file  */
+#define HAVE_WINDOWS_H 1
+
+/* Define this if you have XPG4 comliant nl_langinfo, which accepts CODESET argument */
+#define HAVE_LANGINFO 0
+
+/* Character encoding used by default for 8-bit source files */
+#define SOURCE_CHARSET "us-ascii"
+
+/* Output character encoding used by default, if impossible to determine encoding from locale */
+#define TARGET_CHARSET "8859-15"
+
+/* Suffix for files with special symbols map (ones to be replaced regardless of availability in target encoding) */
+#define SPEC_EXT ".spc"
+
+/* Suffix for symbols replacement map (what to do with symbols, which are not available in the target encoding) */
+#define REPL_EXT ".rpl"
+
+/* Symbol to represent character which is not available either in target encoding or in replacement map */
+#define UNKNOWN_CHAR "?"
+
diff -uNr catdoc-0.94.2.orig/src/config.h.in catdoc-0.94.2/src/config.h.in
--- catdoc-0.94.2.orig/src/config.h.in	2006-02-24 12:44:06.000000000 -0500
+++ catdoc-0.94.2/src/config.h.in	2006-08-28 21:29:18.000000000 -0400
@@ -27,6 +27,9 @@
 /* Define if you have the <unistd.h> header file.  */
 #undef HAVE_UNISTD_H
 
+/* Define if you have the <windows.h> header file.  */
+#undef HAVE_WINDOWS_H
+
 /* Define this if you have XPG4 comliant nl_langinfo, which accepts CODESET argument */
 #undef HAVE_LANGINFO
 
diff -uNr catdoc-0.94.2.orig/src/confutil.c catdoc-0.94.2/src/confutil.c
--- catdoc-0.94.2.orig/src/confutil.c	2006-02-24 12:44:06.000000000 -0500
+++ catdoc-0.94.2/src/confutil.c	2006-08-28 21:47:16.000000000 -0400
@@ -7,7 +7,12 @@
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
+#ifdef HAVE_UNISTD_H
 #include <unistd.h>
+#endif
+#ifdef HAVE_WINDOWS_H
+#include <windows.h>
+#endif
 #include <ctype.h>
 #include <string.h>
 #include <stdlib.h>
@@ -103,7 +108,14 @@
 #ifndef __TURBOC__	
 	if (!setlocale(LC_CTYPE,"")) return;
 #endif
+#ifndef _WIN32
 	codeset = nl_langinfo(CODESET);
+#else
+    /* Get ANSI Code Page, Windows equivalent of nl_langinfo */
+    static char buf[2 + 10 + 1];
+    sprintf (buf, "CP%u", GetACP ());
+    codeset = buf;
+#endif
 	if (!strncmp(codeset,"ISO",3)||!strncmp(codeset,"iso",3)) {
 		codeset+=3;
 		if (*codeset=='-') codeset++;
diff -uNr catdoc-0.94.2.orig/src/fileutil.c catdoc-0.94.2/src/fileutil.c
--- catdoc-0.94.2.orig/src/fileutil.c	2006-02-24 12:44:06.000000000 -0500
+++ catdoc-0.94.2/src/fileutil.c	2006-08-28 23:18:51.000000000 -0400
@@ -7,7 +7,15 @@
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
+#ifdef HAVE_UNISTD_H
 #include <unistd.h>
+#endif
+#ifdef HAVE_IO_H
+#include <io.h>
+#endif
+#ifdef HAVE_WINDOWS_H
+#include <windows.h>
+#endif
 #include <stdio.h>
 #include <string.h>
 #include <sys/stat.h>
@@ -22,7 +30,14 @@
 #else
 #include <glob.h>
 #endif
-
+#ifdef _WIN32
+#include <winbase.h>
+#define MAX_FNAME _MAX_FNAME
+#define findfirst(a,b) _findfirst(a,b)
+#define findnext(a,b) _findnext(a,b)
+#define findclose(a) _findclose(a)
+#define finddata_t _finddata_t
+#endif
 
 /************************************************************************/
 /*  Copies component of string starting with p and ending one char      */
@@ -52,7 +67,7 @@
 	if (!*path_buf) {
 		path_buf[0]='.';
 		path_buf[1]=0;
-#ifdef __MSDOS__
+#if defined(__MSDOS__) || defined(_WIN32)
 	} else {
 		strcpy(path_buf,add_exe_path(path_buf)); /* safe, becouse
 													add_exe_path knows about PATH_BUF_SIZE */
@@ -134,8 +149,39 @@
 /*
  * In DOS, argv[0] contain full path to the program, and it is a custom
  * to keep configuration files in same directory as program itself
- */
-#ifdef __MSDOS__
+ */
+#if defined(_WIN32)
+/* Win32 hack to get libexecdir at runtime */
+/* Caller should free memory returned */
+char * exe_dir(void){
+	char *fn;
+	char *tr;
+	int pos;
+
+	fn = malloc(MAX_PATH+1);
+	/* get the full name of the executable */
+	if(!GetModuleFileNameA(NULL,fn,MAX_PATH))
+	{
+		free( fn );
+		return(".");
+	}
+	
+	/* get the base directory */
+	tr = strrchr(fn, '\\');
+	pos = tr - fn;
+	fn[pos]='\0';
+	
+	/* get the prefix directory */
+	tr = strrchr(fn, '\\');
+	pos = tr - fn;
+
+	/* if we're in bin we'll assume prefix is up one level */
+    if(!strncasecmp(&fn[pos+1], "bin\0", 4))
+		fn[pos]='\0';
+	
+	return(fn);
+}
+#elif defined(__MSDOS__)
 char *exe_dir(void) {
 	static char pathbuf[PATH_BUF_SIZE];
 	char *q;
@@ -149,6 +195,9 @@
 	}
 	return pathbuf;
 }
+#endif
+
+#if defined(__MSDOS__) || defined(_WIN32)
 char *add_exe_path(const char *name) {
 	static char path[PATH_BUF_SIZE];
 	char *mypath=exe_dir();
@@ -178,14 +227,18 @@
 	char *q;
 	char path_buf[PATH_BUF_SIZE];
 	char dir_sep[2]={DIR_SEP,0};
-#ifdef __MSDOS__
+#if defined(__MSDOS__)
 	struct ffblk ffblock;
 	int res,col;
+	char **ptr;
+#elif defined(_WIN32)
+    struct _finddata_t ffblock;
+    long ffhandle;
 #else
 	glob_t glob_buf;
 	int count,glob_flags=GLOB_ERR;
-#endif
 	char **ptr;
+#endif
 	for (p=charset_path;p;p=q+1) {
 		q=strchr(p,LIST_SEP);
 
@@ -205,7 +258,7 @@
 		if (!*path_buf) {
 			path_buf[0]='.';
 			path_buf[1]=0;
-#ifdef __MSDOS__
+#if defined(__MSDOS__) || defined(_WIN32)
 		} else {
 			strcpy(path_buf,add_exe_path(path_buf)); /* safe, becouse
 														add_exe_path knows about PATH_BUF_SIZE */
@@ -215,7 +268,18 @@
 		if (strlen(path_buf)+6>=PATH_BUF_SIZE)
 			continue; /* Ignore too deeply nested directories */
 		strcat(path_buf,"*.txt");
-#ifdef __MSDOS__
+#if defined(__MSDOS__) || defined(_WIN32)
+#ifdef _WIN32
+      if( !(( ffhandle = findfirst(path_buf,&ffblock)) == -1L ) ){
+	      while ( _findnext( ffhandle, &ffblock ) == 0 ) {
+		 char name[MAX_FNAME],*src,*dest;
+		 dest=name;
+		 src=ffblock.name;
+		 for (dest=name,src=ffblock.name;*src && *src !='.';dest++,src++)
+		     *dest=tolower(*src);
+	      }
+      }
+#else
 		res=findfirst(path_buf,&ffblock,FA_RDONLY | FA_HIDDEN | FA_ARCH);
 		col=1;
 		printf("Available charsets:\n"); 
@@ -231,6 +295,7 @@
 			printf("%10s",name);
 			res=findnext(&ffblock);
 		}
+#endif
 #else
 		switch (glob(path_buf,glob_flags,NULL,&glob_buf)) {
 			case 0:
@@ -245,7 +310,7 @@
 		glob_flags|=GLOB_APPEND;
 #endif
 	}
-#ifdef __MSDOS__
+#if defined(__MSDOS__) || defined(_WIN32)
 	fputs("utf-8\n",stdout);
 #else
 	count=0;printf("Available charsets:"); 
diff -uNr catdoc-0.94.2.orig/src/Makefile catdoc-0.94.2/src/Makefile
--- catdoc-0.94.2.orig/src/Makefile	1969-12-31 19:00:00.000000000 -0500
+++ catdoc-0.94.2/src/Makefile	2006-08-28 23:26:07.000000000 -0400
@@ -0,0 +1,103 @@
+# Generated automatically from Makefile.in by configure.
+# Your C compilier and flags
+SHELL = /bin/sh
+
+srcdir = .
+top_srcdir = ..
+prefix = /usr/local
+exec_prefix = ${prefix}
+installroot = 
+
+bindir = ${exec_prefix}/bin
+libdir = ${exec_prefix}/lib
+confdir = ${prefix}/etc
+datadir = ${prefix}/share
+mandir = ${prefix}/man
+INSTALL = /usr/bin/install -c
+WISH = /usr/bin/wish
+CC = -i586-mingw32msvc-gcc
+COMPAT_OBJ=
+build_targets = catdoc xls2csv catppt wordview
+install_targets = install-catdoc install-wordview
+CHARSETPATH=
+# Flags to pass to your C compilier
+# remove -O2 on HP/UX 9. It is known to cause problems
+FLAGS=-I. -g -O2 -Wall  -DHAVE_CONFIG_H -DCATDOC_VERSION=\"0.94.2\"
+
+#Compile-time configuration of catdoc itself. Edit according to taste
+
+#Directory, where all system-wide stuff resides
+DATA_DIR=$(datadir)/catdoc
+#directory, where catdoc binary would be placed
+#directory where to put man page
+
+#System-wide configuration file
+SYSTEMRC=
+
+#Per-user configration file (in user's home directory
+USERRC=
+
+# path where to search for charsets. may be colon-separated list of dirs
+
+# Extension for map of special character
+SPEC_EXT=.spc
+
+# Extension for map of substitutes (chars which are missing from target
+# charset)
+REPL_EXT=.rpl
+
+# Target charset - one used on your system console or xterm
+TARGET_CHARSET=8859-15
+
+# Source charset - one which your Word files are usially in unless they
+# are UNICODE
+SOURCE_CHARSET=us-ascii
+
+# Character which would be printed instead of ones, not found in charset
+# or replacement map
+UNKNOWN_CHAR=?
+
+# END OF COMPILE-TIME CONFIGURATION
+
+DEFINES=
+
+CFLAGS=$(FLAGS) $(DEFINES) -I../compat -DHAVE_CONFIG_H
+
+COMMONOBJ=charsets.o substmap.o fileutil.o confutil.o numutils.o ole.o 
+
+OBJ=catdoc.o reader.o writer.o analyze.o rtfread.o $(COMMONOBJ)
+
+OBJXLS=xls2csv.o sheet.o xlsparse.o $(COMMONOBJ)
+
+OBJPPT=catppt.o pptparse.o $(COMMONOBJ)
+#.c.o:
+#	$(CC) -c $(CFLAGS) $*
+all: catdoc xls2csv catppt wordview
+catdoc: $(OBJ)
+	$(CC)  -o catdoc  $(OBJ)
+xls2csv: $(OBJXLS)
+	$(CC) -o xls2csv $(OBJXLS) -lm
+
+catppt: $(OBJPPT)
+	$(CC) -o catppt $(OBJPPT) -lm
+
+install: install-catdoc install-wordview
+install-catdoc:catdoc xls2csv catppt 
+	../mkinstalldirs $(installroot)$(bindir)
+	$(INSTALL) -m 755 catdoc $(installroot)$(bindir)/catdoc
+	$(INSTALL) -m 755 xls2csv $(installroot)$(bindir)/xls2csv
+	$(INSTALL) -m 755 catppt $(installroot)$(bindir)/catppt
+install-wordview: wordview 
+	../mkinstalldirs $(installroot)$(bindir)
+	$(INSTALL) -m 755 wordview $(installroot)$(bindir)/wordview
+wordview: wordview.tcl
+	echo "#! $(WISH)" >wordview
+	echo set charset_lib "\"$(CHARSETPATH)\"">>wordview
+	cat wordview.tcl >>wordview
+	chmod 0755 wordview
+strftime.o: ../compat/strftime.c
+	$(CC) -c $(FLAGS) -o $@ $*
+clean:
+	rm -f *.o catdoc wordview xls2csv catppt
+distclean: clean
+	rm Makefile
diff -uNr catdoc-0.94.2.orig/src/Makefile.in catdoc-0.94.2/src/Makefile.in
--- catdoc-0.94.2.orig/src/Makefile.in	2006-02-24 12:44:06.000000000 -0500
+++ catdoc-0.94.2/src/Makefile.in	2006-08-28 21:31:42.000000000 -0400
@@ -97,6 +97,8 @@
 	chmod 0755 wordview
 strftime.o: ../compat/strftime.c
 	$(CC) -c $(FLAGS) -o $@ $*
+langinfo.o: ../compat/langinfo.c
+	$(CC) -C $(FLAGS) -o $@ $*
 clean:
 	rm -f *.o catdoc wordview xls2csv catppt
 distclean: clean
diff -uNr catdoc-0.94.2.orig/src/wordview catdoc-0.94.2/src/wordview
--- catdoc-0.94.2.orig/src/wordview	1969-12-31 19:00:00.000000000 -0500
+++ catdoc-0.94.2/src/wordview	2006-08-28 23:26:17.000000000 -0400
@@ -0,0 +1,284 @@
+#! /usr/bin/wish
+set charset_lib ""
+# -* wish *-
+# fallback which allows me to run wordview.tcl without doing make
+package require Tcl 8.3
+
+if ![info exist charset_lib] {
+  set charset_lib /usr/local/lib/catdoc
+}
+option add *Text.Font {Courier 11} widgetDefault
+option add *Text.Background white widgetDefault
+option add *Text.Foreground black widgetDefault
+option add *Text.selectBackground black widgetDefault
+option add *Text.selectForeground white widgetDefault
+option add *Text.findMode exact widgetDefault
+option add *Text.findCase no widgetDefault
+option add *Menu.highlightBackground MidnightBlue widgetDefault
+option add *Menu.highlightThickness 0 widgetDefault
+option add *Menu.activeBackground MidnightBlue widgetDefault
+option add *Menu.activeForeground white widgetDefault
+option add *Menu.activeBorderWidth 0 widgetDefault
+menu .mainmenu
+. configure -menu .mainmenu
+.mainmenu add cascade  -label File -menu [set m [menu .mainmenu.file]] -underline 0
+$m add command -label Open... -command load_file -accelerator Ctrl-O
+$m add command -label "Save As..." -command write_file -accelerator Ctrl-S -state disabled
+$m add separator
+$m add command -label Quit -command exit -accelerator Alt-F4
+set m [menu .mainmenu.edit -postcommand EditEnable]
+.mainmenu add cascade -label Edit -menu $m -underline 0 -state disabled
+$m add command -label Copy -command CopySel -accelerator Ctrl-C
+$m add separator
+$m add command -label "Select All" -accelerator Ctrl-A -command \
+ {.text tag add sel 0.0 end}
+.mainmenu add cascade -label Find -menu .mainmenu.search -underline 1 -state disabled
+set m [menu .mainmenu.search -postcommand EnableSearch]
+$m add command -label "Find..." -command FindDialog -accelerator Ctrl-F
+$m add command -label "Find Again" -accelerator F3 -command DoFind
+#  
+# build charset menu
+# 
+
+.mainmenu add cascade -state disabled -label Encoding -menu [set m [menu .mainmenu.encoding]]
+$m add radio -label Default -value Default -var in_charset 
+$m add radio -label unicode -value unicode -var in_charset 
+foreach l [glob [file join $charset_lib *.txt]] {
+    set n [file rootname [file tail $l]]
+    $m add radio -label $n -value $n -var in_charset
+}
+
+set in_charset Default 
+
+trace var in_charset w reread
+set m [menu .mainmenu.help]
+.mainmenu  add cascade -label Help -menu $m -underline 0
+$m add command -label "Manual page" -command [list  show_help [file tail $argv0]]
+$m add command -label "Regular expressions" -command {show_help re_syntax}
+$m add separator
+$m add command -label "About..." -command AboutDialog
+
+
+
+text .text -width 80 -height 25  -xscrollcommand ".xs set" \
+    -yscrollcommand ".ys set"   -wrap word \
+     -spacing3 2m 
+.text tag configure sel -relief flat -borderwidth 0
+.text tag configure doc -lmargin1 0.2i -lmargin2 0
+scrollbar .ys -orient vert -command ".text yview"
+scrollbar .xs -orient horiz -command ".text xview"
+bind .text <F3> { if [info exists FindPattern] DoFind}
+bind .text <Control-O> load_file
+bind .text <Control-o> load_file
+bind .text <Control-S> {write_file}
+bind .text <Control-s> {write_file}
+bind .text <Control-F> FindDialog
+bind .text <Control-f> FindDialog
+grid .text .ys
+grid .xs x  
+grid .text -sticky news
+grid .xs -sticky we
+grid .ys -sticky ns
+grid columnconfigure . 0 -weight 1 
+grid columnconfigure . 1 -weight 0
+grid rowconfigure . 0 -weight 1 
+grid rowconfigure . 1 -weight 0
+
+# Find options (All this can be tuned from dialog)
+set FindMode -[option get .text findMode FindMode] ;# no -regexp for novices
+set FindDir -forwards ;# Why not -backwards
+set FindCase -nocase ;# Leave it empty if you want to be case sensitive
+if {[option get .text findCase FindCase]} {
+	set FindCase ""
+}	
+
+
+proc show_help {page} {
+	global argv0
+	if [winfo exists .man] {
+		wm deiconify .man
+		raise .man
+		.man.text delete 0.0 end
+	} else {	
+		toplevel .man -class Man
+		wm title .man "[file tail $argv0] help: $page"
+		menu .man.menu 
+		.man.menu add cascade -label File -menu [set m [menu .man.menu.file]]
+		.man configure -menu .man.menu
+		$m add command -label Close -command {destroy .man}
+		text .man.text -yscrollcommand {.man.y set}
+		scrollbar .man.y -command {.man.text yview} -orient vert
+		grid .man.text .man.y -sticky news
+		grid columnconfigure .man 0 -weight 1
+		grid columnconfigure .man 1 -weight 0
+	}
+	.man.text insert end [exec man $page 2>/dev/null | col -b ]
+}	
+
+proc load_file {{name {}}} {
+global filename
+if ![string length $name] {set name [tk_getOpenFile -filetypes {
+{{Msword files} .doc}
+{{RTF files} .rtf}
+{{MS Write files} .wri}
+{{All files} *}} ]}
+if ![string length $name] return
+if ![file readable $name] {
+  return -code error "Cannot open file $name"
+}
+set filename $name
+.mainmenu entryconfigure Encoding -state normal
+.mainmenu.file entryconfigure "Save As..." -state normal
+.mainmenu  entryconfigure "Edit" -state normal
+.mainmenu entryconfigure "Find"  -state normal
+reread
+}
+
+proc make_opt {var flag} {
+  upvar #0 $var charset
+  switch $charset {
+	"Default" {return ""}
+	"unicode" {return "-u"}
+        default {return "$flag $charset"}
+  }
+}	
+proc reread {args} {
+global filename in_charset out_charset
+
+set inopt [make_opt in_charset -s]
+set f [open "|catdoc -w $inopt -d utf-8 \"$filename\"" r]
+fconfigure $f -encoding utf-8
+.text configure -state normal
+.text delete 0.0 end
+.text insert 0.0 [read $f] doc
+.text mark set insert 1.0
+.text configure -state disabled
+.text see 1.0
+if [catch {close $f} msg] {
+ tk_messageBox -icon error -title error -message $msg -type ok
+ return
+}
+}
+proc write_file {{name {}}} {
+    global filename 
+    if ![string length $name] {
+       set name [tk_getSaveFile -filetypes {
+      {{Text files} .txt}
+      {{LaTeX files} .tex}}]
+    }
+    if ![string length $name] return
+    if {[file extension $name]==".tex"} {
+       eval exec catdoc -t [make_opt in_charset -s] [make_opt out_charset -d]\
+		[list $filename] > [list $name]
+    } else {
+       eval exec catdoc [make_opt in_charset -s] [make_opt out_charset -d]\
+		[list $filename]  > [list $name]
+    }
+}
+# -postcommand for Edit menu
+proc EditEnable {} {
+if [llength [.text tag ranges sel]] {
+  .mainmenu.edit entryconfigure Copy -state normal
+} else {
+  .mainmenu.edit entryconfigure Copy -state disabled
+}
+}
+proc CopySel {} {
+clipboard clear
+clipboard append -- [.text get sel.first sel.last]
+}
+proc FindDialog {} {
+make_transient .find "Find" 
+frame .find.top
+label .find.top.l -text "Find"
+entry .find.top.e -width 30 -textvar FindPattern
+bind .find.top.e <Key-Return> ".find.b.find invoke"
+pack .find.top.l .find.top.e -side left
+FindOptionFrame
+frame .find.b
+button .find.b.find -text "Search" -command DoFind
+button .find.b.close -text "Close" -command "destroy .find"
+pack .find.b.find .find.b.close -side left -padx 20
+pack .find.top -pady 5 -anchor w -padx 10
+pack .find.opt -pady 10
+pack .find.b
+focus .find.top.e
+}
+proc EnableSearch {} {
+global FindPattern ReplaceString
+if ![info exists FindPattern] {
+  .mainmenu.search entryconfigure "Find Again" -state disabled
+} else {
+  .mainmenu.search entryconfigure "Find Again" -state normal
+}
+}
+proc make_transient {wpath title} {
+set x [expr [winfo rootx .]+[winfo width .]/3]
+set y [expr [winfo rooty .]+[winfo height .]/3]
+catch {destroy $wpath}
+toplevel $wpath
+wm transient $wpath .
+wm positionfrom $wpath program
+wm geometry $wpath +$x+$y
+wm title  $wpath $title
+}
+proc FindOptionFrame {} {
+frame .find.opt
+checkbutton .find.opt.dir -variable FindDir -onvalue -backwards\
+   -offvalue -forwards  -text Backward
+checkbutton .find.opt.regex -variable FindMode -onvalue\
+      -regex -offvalue -exact  -text RegExp
+checkbutton .find.opt.case -variable FindCase -onvalue -nocase -offvalue {}\
+  -text "Ignore case"
+pack .find.opt.dir .find.opt.regex .find.opt.case -side left
+}
+proc DoFind {{quiet 0}} {
+global FindPattern FindMode FindDir FindCase
+if ![string length $FindPattern] {return 0}
+if {$FindMode=="-backwords"} {  
+    set stopindex 0.0
+} else {
+  set stopindex end
+} 
+set index [eval ".text search $FindCase $FindMode $FindDir -- \
+  [list $FindPattern] insert $stopindex"] 
+if ![string length $index] {
+  if !$quiet {
+   tk_messageBox -type ok -title "Not found" -message "Pattern not found"
+  }
+ return 0
+} else {
+.text tag remove sel 0.0 end
+if {$FindMode=="-exact"} {
+.text tag add sel $index "$index + [string length $FindPattern] chars"
+} else {
+eval "regexp $FindCase --" [list $FindPattern [.text get "$index linestart"\
+   "$index lineend"] match]
+.text tag add sel $index "$index + [string length $match] chars"
+}
+.text mark set insert sel.last 
+.text see $index
+.text see insert
+focus .text
+return 1
+}
+}
+proc AboutDialog {} {
+make_transient .about "About WordView"
+message .about.m -aspect 250 -text "MS-Word viewer for UNIX
+Copyright (c) by Victor B. Wagner 1997-98
+This program is distributed under
+GNU General Public License Version 2 or above
+Check http://www.gnu.org/copyleft/gpl.html for copying
+and warranty conditions" -justify center
+button .about.ok -text Ok -command {destroy .about}
+pack .about.m .about.ok
+}
+if [llength $argv] {
+ if {![file exist [lindex $argv 0]]} {
+    puts stderr "No such file: [lindex $argv 0]"
+    exit 1
+ }   
+load_file [lindex $argv 0]
+}
+focus .text
