edge
  8   ˆl—Ým_Jõ!®Å2 ¸ÛWmLZ7ÿ�þeßY¹^+LÊì…e ?Î„p/8ßÍÀË ?÷     #!/usr/bin/perl
# Debian required shebang above
# Original shebang below
# #! /usr/bin/env perl
###############################################################################
# texdoctk - GUI for TeX documentation access
# Copyright (C) 2000-2004  Thomas Ruedas
# Updated in 2010 by Manuel Pegourie-Gonnard
# Trivial non-code updates in 2012 by Karl Berry
# Patch from Debian for "texdoctk-warn-missing-perltk" installed in 2019
#   by Karl Berry.
# (This program is looking for a maintainer, email tex-live@tug.org.)
# 
# This program is provided under the GNU Public License; see the texdoctk
# README for details about requirements, installation, configuration,
# and the full disclaimer.
###############################################################################
my ($version, $date) = ("0.6.1", "2012-12-23");
use strict;
use Getopt::Long;
Getopt::Long::config('bundling');
use File::Basename;

BEGIN {
    Win32::SetChildShowWindow(0) if defined &Win32::SetChildShowWindow;
}

my $IsWin32 = ($^O =~ /MSWin32/i);

if ($IsWin32) {
  require Win32::API;
#  Win32::API->import( qw(
#    &something
#  ));
}

eval { require Tk; };
if ($@) {
  if (-x "/usr/bin/xmessage") {
    `xmessage -center -buttons Quit "The program texdoctk needs the package perl-tk, please install it!"`;
  } else {
    printf STDERR "The program texdoctk needs the package perl-tk, please install it!\n";
  }
  exit(1);
  # that didn't work out, so warn the user and continue with text mode
} else {
  Tk->import;
}


# initialization of some internal variables
$|=1;
my $quiet=1;
my $autoview;
my $xfmt_viewer=1,
my @tdcolors;
my %butcol;
my $srchentry;
my $srchflag=0;
my $srchtype; # 0 = database, 1 = texdoc
my $tmpfno;
# system variables
my ($texmfmain,$texmfdist,$texmfdoc,$texmflocal,$texmfhome,
    $texdocpath,$distdocpath,$docdocpath,$localdocpath,$homedocpath,
    $datadir,
    $dvi_viewer,$dvips_conv,$ps_viewer,$pdf_viewer,
    $pdfps_conv,$html_viewer,$htmlps_conv,$htmlps_redir,
    $txt_viewer,$txtps_conv,$txtps_redir,$print_cmd);

# defaults: unix values
my $qq="'";
my $HomeEnv=$ENV{HOME};
my $TeXDocRcDefaults="texdocrc.defaults";
my $TempDir; $TempDir=$ENV{TMPDIR} or $TempDir="/tmp";
my $CmdConsole="xterm -e ";

if ($IsWin32) {
  $qq = "\"";
  $HomeEnv = $ENV{'USERPROFILE'};
  chomp $HomeEnv;
  $TeXDocRcDefaults = "texdocrc-win32.defaults";
  $TempDir = &GetTempPath;
  $CmdConsole = "cmd /c ";
}

my $myrc="${HomeEnv}/.texdocrc"; # optional personal settings file

my ($line,@dummy);
my @tmpfiles;
# read system-wide defaults from texdocrc.defaults
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`;
my $homedatabase=`kpsewhich --progname=texdoctk --format=${qq}other text files${qq} texdoctk-pers.dat`;
chomp $locdatabase;
chomp $homedatabase;
chomp $sysrc;
&readrc($sysrc,1);
@dummy=split("/",$sysrc);
pop @dummy;
$datadir=join('/',@dummy);
# possibly use personal settings instead of defaults
if (-e $myrc) { &readrc($myrc,2); }
# command line options
GetOptions('v'=>\$quiet,'a'=>\$autoview);
my $special=0;
my @button;
$button[17]="Miscellaneous";
my (@packname,@topic,@doc,@keywords,@maxind,%stydoc);
# read database file
my $i=-1;
my $j;
open(DATABASE,"$database") || &fatalmsg("Couldn't open database $database.\n");
while ($line = <DATABASE>) {
  LINETYPE: {
      ($line =~ /^\@/) && do { # category
	  ++$i;
	  if ($i == $#button) {
	      pop @button;
	      push @button,(substr($line,1,-1));
	      $special=1;
	  } else {
	      $button[$i]=substr($line,1,-1);
	  }
	  $j=0;
	  last LINETYPE;
      };
      ($line =~ /^(#|$)/) && do { # comment or empty line
	  last LINETYPE;
      };
#     list item
       @dummy=split(";",$line);
       $packname[$i][$j]=$dummy[0];
       $topic[$i][$j]=$dummy[1];
       $doc[$i][$j]=$dummy[2];
       $ke