source: git/doc/doc2idx.pl @ 71e7014

spielwiese
Last change on this file since 71e7014 was 71e7014, checked in by Olaf Bachmann <obachman@…>, 25 years ago
*** empty log message *** git-svn-id: file:///usr/local/Singular/svn/trunk@3328 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 1.9 KB
Line 
1#!/usr/local/bin/perl
2# $Id: doc2idx.pl,v 1.1 1999-07-22 13:54:21 obachman Exp $
3###################################################################
4#  Computer Algebra System SINGULAR
5#
6#  doc2idx.pl: utility to index file for singular manual
7#
8#  Prints to stdout lines of the following form
9#
10#  $indexentry\t$nodename\t$url\t$chksum
11#
12#  where $indexentry: entries of index (all lower case)
13#        $nodename  : name of node where index entry occured
14#        $url       : url of node
15#        $chksum    : checksum of help text, if library proc node
16# lines are sorted alphabetically w.r.t. $indexentry
17
18####
19$Usage = <<EOT;
20Usage: 
21$0 singular-index-file html-index-file chksum-db
22Outputs sorted lines of the form $indexentry\t$nodename\t$url\t$chksum
23EOT
24
25###################################################################
26# parse command line options
27#
28die "Need 3 arguments:\n $Usage" unless (scalar(@ARGV) == 3);
29
30# open files
31open (HLP, "<$ARGV[0]") || die "Can't open $ARGV[0]: $!\n";
32open (URL, "<$ARGV[1]") || die "Can't open $ARGV[1]: $!\n";
33$db_file = $ARGV[2];
34$db_file = $1 if ($db_file =~ /(.*)\..*$/);
35dbmopen (%CHK, $db_file, 0666) ||
36      die "Error: can't open chksum data base $db_file";
37
38# fill hashes
39# first: HLP
40while (<HLP>)
41{
42  if (/Node: Index/)
43  {
44    while (<HLP>)
45    {
46      last if /\* Menu:/;
47    }
48    <HLP>;
49    while (<HLP>)
50    {
51      last if /^\s*$/;
52      if (/^\* (.*?): (.*)\.$/)
53      {
54        $entry = $1;
55        $node = $2;
56      }
57      $entry =~ s/\s*(.*) <\d+>\s*$/$1/;
58      $node =~ s/^\s*(.*)\s*$/$1/;
59      $index->{$entry}->{Node} = $node unless $entry eq $prev;
60      $prev = $entry;
61    }
62    last;
63  }
64}
65close(HLP);
66
67while (<URL>)
68{
69  ($entry, $url) = split(/\t/);
70  $url =~ s/^\s*(.*)\s*$/$1/;
71  $index->{$entry}->{Url} = $url;
72}
73close(URL);
74
75for $entry (sort keys %$index)
76{
77  print "$entry\t$index->{$entry}->{Node}\t$index->{$entry}->{Url}\t$CHK{$entry}\n";
78}
79
80close(%CHK);
81
Note: See TracBrowser for help on using the repository browser.