From: Jon Trulson Date: Wed, 19 Sep 2018 01:02:49 +0000 (-0600) Subject: docbook.tcl: fix up some problems using a modern Tcl X-Git-Tag: 2.3.0a~26^2~7 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=776e031b60ccf7fc78a3343587624e2fe1e34657;p=oweals%2Fcde.git docbook.tcl: fix up some problems using a modern Tcl One issue that came up was attempting to read array values indexed by a key that didn't exist when generating indexes and glossaries. I am not sure why this hasn't been a problem before, but for now, we simply won't try to emit array values for non-existant array indexes. --- diff --git a/cde/programs/dtdocbook/doc2sdl/docbook.tcl b/cde/programs/dtdocbook/doc2sdl/docbook.tcl index 08b42282..01578f8f 100755 --- a/cde/programs/dtdocbook/doc2sdl/docbook.tcl +++ b/cde/programs/dtdocbook/doc2sdl/docbook.tcl @@ -2195,6 +2195,7 @@ proc SortAndEmitGlossary {popForm} { set names [array names currentGlossArray] foreach name $names { + # puts stderr "JET0: name: $name" upvar 0 currentGlossArray($name) glossEntryList # skip this array entry if we've already emitted it; mark as @@ -2215,7 +2216,10 @@ proc SortAndEmitGlossary {popForm} { set names [lsort -command CompareI18NStrings [array names sortArray]] foreach name $names { - Emit $sortArray($name) + # puts stderr "JET1: name: $name" + if {[info exists sortArray($name)]} { + Emit $sortArray($name) + } } if {[string toupper $popForm] == "POPFORM"} { @@ -2481,24 +2485,26 @@ proc WriteIndex {} { set oldLevel 0 puts $file "" foreach name $names { - set thisEntry $indexArray($name) - switch [lindex $thisEntry 0] { - 1 { switch $oldLevel { - 1 { puts $file "" } - 2 { puts $file "\n" } - 3 { puts $file "\n\n" } + if {[info exists indexArray($name)]} { + set thisEntry $indexArray($name) + switch [lindex $thisEntry 0] { + 1 { switch $oldLevel { + 1 { puts $file "" } + 2 { puts $file "\n" } + 3 { puts $file "\n\n" } } - } - 2 { switch $oldLevel { - 2 { puts $file "" } - 3 { puts $file "\n" } + } + 2 { switch $oldLevel { + 2 { puts $file "" } + 3 { puts $file "\n" } } - } - 3 { if {$oldLevel == 3} { puts $file "" } } - } - puts -nonewline $file "" - puts -nonewline $file [lindex $thisEntry 3] - set oldLevel [lindex $thisEntry 0] + } + 3 { if {$oldLevel == 3} { puts $file "" } } + } + puts -nonewline $file "" + puts -nonewline $file [lindex $thisEntry 3] + set oldLevel [lindex $thisEntry 0] + } } switch $oldLevel { @@ -2547,10 +2553,10 @@ proc FootnoteRef {idref} { # add an element to the current SNB - try to reuse an entry if # possible -proc AddToSNB {type data} { +proc AddToSNB {stype data} { global currentSNB nextId - set index "$type::$data" + set index "${stype}::${data}" if {[info exists currentSNB($index)]} { set snbId $currentSNB($index)