 texk/tetex/texdoctk |   51 ++++++++++++++++++++++++++++++++++++++-------------
 1 files changed, 38 insertions(+), 13 deletions(-)

Index: trunk/texk/tetex/texdoctk
===================================================================
--- trunk.orig/texk/tetex/texdoctk	2006-12-06 19:01:11.000000000 +0100
+++ trunk/texk/tetex/texdoctk	2006-12-06 21:38:41.000000000 +0100
@@ -9,11 +9,30 @@
 # and the full disclaimer.
 ###############################################################################
 use strict;
-use Tk;
 use Getopt::Long;
 Getopt::Long::config('bundling');
 use File::Basename;
 
+BEGIN {
+    eval { require Tk; import Tk; };
+    if ($@) {
+	my $progname = basename($0);
+	my $message;
+	if ($@ =~ /^Can\'t locate Tk\.pm/) {
+	    $message = "$progname: you must have the perl-tk package installed\nto use this script\n";
+	} else {
+	    $message = "$progname: problem loading the Tk module:\n  $@\nHave you installed the perl-tk package?\n";
+	}
+
+	if (! -t STDOUT and exists $ENV{DISPLAY})
+	{
+	    exec("tetex-xwarn", $message);
+	} else {
+	    die $message;
+	}
+    }
+}
+
 my $IsWin32 = ($^O =~ /MSWin32/i);
 
 #if ($IsWin32) {
@@ -32,8 +51,8 @@
 my $srchflag=0;
 my $tmpfno;
 # system variables
-my ($texmfmain,$texmfdist,$texmfdoc,$texmflocal,$texmfhome,
-    $texdocpath,$distdocpath,$docdocpath,$localdocpath,$homedocpath,
+my ($texmfmain,$texmfdist_tetex,$texmfdist_texlive,$texmfdoc,$texmflocal,$texmfhome,
+    $texdocpath,$distdocpath_tetex,$distdocpath_texlive,$docdocpath,$localdocpath,$homedocpath,
     $datadir,
     $dvi_viewer,$dvips_conv,$ps_viewer,$pdf_viewer,
     $pdfps_conv,$html_viewer,$htmlps_conv,$htmlps_redir,
@@ -42,7 +61,7 @@
 # defaults: unix values
 my $qq="'";
 my $HomeEnv=$ENV{HOME};
-my $TeXDocRcDefaults="texdocrc.defaults";
+my $TeXDocRcDefaults="texdocrc";
 my $TempDir; $TempDir=$ENV{TMPDIR} or $TempDir="/tmp";
 my $CmdConsole="xterm -e ";
 
@@ -59,7 +78,7 @@
 
 my ($line,@dummy);
 my @tmpfiles;
-# read system-wide defaults from texdocrc.defaults
+# read system-wide defaults from texdocrc
 my $sysrc=`kpsewhich --progname=texdoctk --format=${qq}other text files${qq} ${TeXDocRcDefaults}`;
 my $database=`kpsewhich --progname=texdoctk --format=${qq}other text files${qq} texdoctk.dat`;
 my $locdatabase=`kpsewhich --progname=texdoctk --format=${qq}other text files${qq} texdoctk-local.dat`;
@@ -637,7 +656,7 @@
 sub finddoc {
     my($slcdoc,$slc,$parframe)=@_;
     my ($dummy,$status);
-  SLCDOCFIND: foreach ($texdocpath,$distdocpath,$docdocpath) {
+  SLCDOCFIND: foreach ($texdocpath,$distdocpath_tetex,$distdocpath_texlive,$docdocpath) {
       $slcdoc="$_/$slc";
       if (-e $slcdoc) {
 #       found where it should be
@@ -692,6 +711,7 @@
 			$slcdoc="";
 			return $slcdoc;
 		    }
+		    return $slcdoc;
 		    last CMPREND;
 		}
 	    }
@@ -720,7 +740,8 @@
     my $found=0;
     if ($docselect =~ /\.sty$/) {
     STYPATH: foreach my $fullpath ("$texmfmain/tex/$docselect",
-				   "$texmfdist/tex/$docselect",
+				   "$texmfdist_tetex/tex/$docselect",
+				   "$texmfdist_texlive/tex/$docselect",
 				   "$texmflocal/tex/$docselect",
 				   "$texmfhome/tex/$docselect") {
 	if (-e $fullpath) {
@@ -733,7 +754,8 @@
 	&popmsg(2,"Selected file:\n$docselect\ndoes not exist.",$tpbframe) }
     } else {
     DOCPATH: foreach my $fullpath ("$texdocpath/$docselect",
-				   "$distdocpath/$docselect",
+				   "$distdocpath_tetex/$docselect",
+				   "$distdocpath_texlive/$docselect",
 				   "$docdocpath/$docselect",
 				   "$localdocpath/$docselect",
 				   "$homedocpath/$docselect") {
@@ -949,7 +971,8 @@
 							-fill=>'x',
 							-expand=>1);
     my $docframestring="\nDistribution documentation root path(s):\n$texdocpath";
-    $docframestring.=", $distdocpath" if (-e $distdocpath);
+    $docframestring.=", $distdocpath_tetex" if (-e $distdocpath_tetex);
+    $docframestring.=", $distdocpath_texlive" if (-e $distdocpath_texlive);
     $docframestring.=", $docdocpath" if (length $docdocpath);
     if ($localdocpath && $localdocpath ne $texdocpath) {
 	$docframestring.="\nLocal documentation root path: $localdocpath\n";
@@ -1535,10 +1558,12 @@
 	$texmfmain=`kpsewhich --expand-path=${qq}\$TEXMFMAIN${qq}`;
 	chomp $texmfmain;
 	$texdocpath="$texmfmain/$texdocpath";
-	$texmfdist=`kpsewhich --expand-path=${qq}\$TEXMFDIST${qq}`;
-	chomp $texmfdist;
-	$distdocpath=join('/',"$texmfdist",basename($texdocpath,""))
-			  if (length $texmfdist);
+# 	$texmfdist=`kpsewhich --expand-path=${qq}\$TEXMFDIST${qq}`;
+# 	chomp $texmfdist;
+	$distdocpath_tetex=join('/',"$texmfdist_tetex",basename($texdocpath,""))
+			  if (length $texmfdist_tetex);
+	$distdocpath_texlive=join('/',"$texmfdist_texlive",basename($texdocpath,""))
+			  if (length $texmfdist_texlive);
 	# TeXLive has this texmf-doc
 	$texmfdoc=join('/',"$texmfmain-doc",basename($texdocpath,""));
 	if (-e $texmfdoc) {
