summaryrefslogtreecommitdiff
path: root/support/xtexshell/help/convhelp
blob: a0432980068fa1db5aaed73a2f7f3d53b78144ef (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/usr/bin/tclsh 

#*** Main Program

    if {$argc != 2} {   
        puts stdout "\nConvHelp \nGenerate Index File for Help System\nUsage: conv infile outfile\n"
        return; 
    }

    set inname  [lindex $argv 0]
    set outname [lindex $argv 1]        

    set infile  [open $inname  "r"] 
    set outfile [open $outname "w"]

#*** Skip file Header and read the x- and y-length

    puts stdout "Converting..."

#*** Write Header for new file

    set rowcount 0      
    set entry    0

    while {[eof $infile] == 0} {
        set filepos [tell $infile]
        gets $infile inbuf 
        if {$entry == 0} {                      # *** Start of entry was not found so far..
           if {[string first ":entry" $inbuf] >= 0} {
              set entry 1                       
              set commandlist {}
              if {![expr $rowcount%10]} {       # *** Inform User
                 puts -nonewline stdout "\[$rowcount\] "
                 flush stdout
              }
              incr rowcount
           }
        } else {                                # *** Ok, we are processing an entry
           if {[string first ":" $inbuf] < 0} { # *** Another entry
               foreach word "$inbuf" {
                   lappend commandlist "$word"  
               }
           } else {
               foreach command "$commandlist" { # *** End of entries reached
                   puts $outfile "$command $inname $filepos" 
               }
               set entry 0
           } 
        }               
    }                   

    close $outfile
    close $infile
    puts stdout "\[$rowcount\] "