summaryrefslogtreecommitdiff
path: root/systems/mac/support/alpha/tcl/extensions
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
committerNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
commite0c6872cf40896c7be36b11dcc744620f10adf1d (patch)
tree60335e10d2f4354b0674ec22d7b53f0f8abee672 /systems/mac/support/alpha/tcl/extensions
Initial commit
Diffstat (limited to 'systems/mac/support/alpha/tcl/extensions')
-rw-r--r--systems/mac/support/alpha/tcl/extensions/bibAdditions.tcl193
-rw-r--r--systems/mac/support/alpha/tcl/extensions/bibConvert.tcl1634
-rw-r--r--systems/mac/support/alpha/tcl/extensions/collapsablewidget.tcl.gzbin0 -> 3021 bytes
-rw-r--r--systems/mac/support/alpha/tcl/extensions/plplot/Readme.txt54
-rw-r--r--systems/mac/support/alpha/tcl/extensions/plplotter.kitbin0 -> 431073 bytes
-rw-r--r--systems/mac/support/alpha/tcl/extensions/tktext.diff169
-rw-r--r--systems/mac/support/alpha/tcl/extensions/tktexttabs.patch147
-rw-r--r--systems/mac/support/alpha/tcl/extensions/trace.c282
-rw-r--r--systems/mac/support/alpha/tcl/extensions/trace.diff594
9 files changed, 3073 insertions, 0 deletions
diff --git a/systems/mac/support/alpha/tcl/extensions/bibAdditions.tcl b/systems/mac/support/alpha/tcl/extensions/bibAdditions.tcl
new file mode 100644
index 0000000000..fd39957133
--- /dev/null
+++ b/systems/mac/support/alpha/tcl/extensions/bibAdditions.tcl
@@ -0,0 +1,193 @@
+## -*-Tcl-*-
+ # ###################################################################
+ # Vince's Additions - an extension package for Alpha
+ #
+ # FILE: "bibAdditions.tcl"
+ # created: 6/8/95 {4:23:11 pm}
+ # last update: 31/1/1999 {2:34:46 pm}
+ # Author: Vince Darley
+ # E-mail: <darley@fas.harvard.edu>
+ # mail: Division of Applied Sciences, Harvard University
+ # Oxford Street, Cambridge MA 02138, USA
+ # www: <http://www.fas.harvard.edu/~darley/>
+ #
+ # This file is part of the package "Vince's Additions".
+ # See its documentation for more details.
+ #
+ # This file contains basic utility proedures used by
+ # the bibliography tools so they work both under Alpha
+ # and under more general (e.g. Unix) Tcl interpreters.
+ #
+ # Bug reports and feature requests to:
+ # <mailto:darley@fas.harvard.edu>
+ # ###################################################################
+ ##
+
+##
+ # in case we wish to use auto-loading: just call this procedure
+ # to ensure 'bibAdditions.tcl' is loaded.
+ ##
+
+proc dummyBibAdditions {} {}
+
+# check if we're using Alpha, and if so sort out the interface
+if {![catch {alpha::package exists Alpha}]} {
+ # only do this first time we're sourced
+ set vince_usingAlpha [alpha::package exists Alpha]
+} else {
+ set vince_usingAlpha 0
+}
+
+
+##
+ # Given an input file name, an output extension, a set of possible input
+ # extensions, a possible output file name, and a possible mapping from
+ # abbreviated input extensions to full extensions, this procedure will
+ # make sure the input file exists (either as given or with one of the
+ # extensions attached), will generate the output file name if necessary,
+ # and will return the full extension of the input file.
+ #
+ # See my 'proc bibConvert' for an example of using this procedure.
+ ##
+
+proc vince_parseFileNames { fin outextension extensionlist { fout default } { abbrev "" } } {
+ global bibconv::use_alpha bibconv::pr bibconv::types bibconv::extensions
+
+ set extension [file extension $fin]
+ if { $extension != "" } {
+ if { ![file exists $fin] } {
+ ${bibconv::pr} "Input file '$fin' does not exist"
+ return
+ } else {
+ # have an extension, and file exists.
+ # we don't care if it's in the extensionlist, but do care
+ # if it's in the abbreviation list.
+ if { $abbrev != "" } {
+ upvar $abbrev extarray
+ set e [string range $extension 1 end]
+ if {[info exists extarray($e)]} {
+ set extension .$extarray($e)
+ }
+ }
+ }
+ } else {
+ # No extension was supplied, we must generate our own
+ if { $abbrev != "" } {
+ set fe [vince_findFile $fin $abbrev 1]
+ } else {
+ set fe [vince_findFile $fin $extensionlist 0]
+ }
+ if { $fe == "" } {
+ vince_print "Couldn't find an appropriate existing extension for '$fin'"
+ return
+ }
+ set fin [lindex $fe 0]
+ set extension [lindex $fe 1]
+
+ }
+ # now we have both 'fin' and 'extension'
+ # just need 'fout'
+
+ if { $fout == "default" } {
+ set fout [string range ${fin} 0 \
+ [expr [string length ${fin}] - \
+ [string length [file extension ${fin}]] - 1]].${outextension}
+ }
+
+ return [list $fin $fout [string range $extension 1 end] ]
+}
+
+##
+ # Used by the above procedure.
+ #
+ # Given an input file name and a set of possible extensions or
+ # abbreviated extension mappings, this procedure will find the
+ # correct input file if it exists.
+ ##
+
+proc vince_findFile { fin extlist isarray } {
+ if {$isarray} {
+ upvar $extlist ext_abbreviations
+ # if we have an abbreviation list
+ foreach suf [array names ext_abbreviations] {
+ if {[file exists ${fin}.${suf} ]} {
+ return [list ${fin}.${suf} .$ext_abbreviations($suf) ]
+ }
+ }
+ } else {
+ # else use the full extensions
+ foreach suf $extlist {
+ if {[file exists ${fin}.${suf} ]} {
+ return [list ${fin}.${suf} .$suf ]
+ }
+ }
+ }
+
+ return ""
+}
+
+##
+ # The following procedures are here so that this code can be used
+ # without Alpha being present (perhaps under Tickle or on a unix
+ # workstation).
+ ##
+
+proc vince_print { str } {
+ global vince_usingAlpha
+
+ if { $vince_usingAlpha } {
+ message $str
+ } else {
+ puts $str
+ }
+}
+
+proc vince_edit { file } {
+ global vince_usingAlpha
+
+ if { $vince_usingAlpha } {
+ edit $file
+ }
+}
+
+proc vince_askyesno { text } {
+ global vince_usingAlpha
+
+ if { $vince_usingAlpha } {
+ return [askyesno $text]
+ } else {
+ puts $text
+ gets stdin yes
+ return $yes
+ }
+}
+
+proc vince_getFile { text { action "" } } {
+ global vince_usingAlpha
+
+ if { $vince_usingAlpha } {
+ # find window
+ set fname [win::Current]
+ if { $fname == "" } {
+ set fname [getfile $text ]
+ if { $fname == "" } {
+ return
+ }
+ if { $action == "edit" } {
+ edit $fname
+ }
+ }
+ # add a colon to workaround an Alpha bug
+ cd "[file dirname $fname]:"
+ } else {
+ puts $text
+ gets stdin fname
+ cd "[file dirname $fname]"
+ }
+
+ set fin [file tail $fname]
+
+ return $fin
+}
+
+
diff --git a/systems/mac/support/alpha/tcl/extensions/bibConvert.tcl b/systems/mac/support/alpha/tcl/extensions/bibConvert.tcl
new file mode 100644
index 0000000000..78d0170782
--- /dev/null
+++ b/systems/mac/support/alpha/tcl/extensions/bibConvert.tcl
@@ -0,0 +1,1634 @@
+## -*-Tcl-*-
+ # ###################################################################
+ # Vince's Additions - an extension package for Alpha
+ #
+ # FILE: "bibConvert.tcl"
+ # created: 6/8/95 {4:23:31 pm}
+ # last update: 21/3/1999 {3:24:37 pm}
+ # Author: Vince Darley
+ # E-mail: <darley@fas.harvard.edu>
+ # mail: Division of Applied Sciences, Harvard University
+ # Oxford Street, Cambridge MA 02138, USA
+ # www: <http://www.fas.harvard.edu/~darley/>
+ #
+ # Description:
+ #
+ # proc bibConvert {}
+ #
+ # First attempt at parsing various records into bibtex entries.
+ # It now copes with hollis records, the horrible form of inspec
+ # record our firstsearch interface gives us, and a nicer
+ # form of inspec record produced by another interface.
+ #
+ # Bibliography Formats Handled:
+ #
+ # Hollis: (Harvard University Library System)
+ #
+ # The basic idea is that records are outlined by "%START:" and
+ # "%END:" tags, each field label is of the form "%FIELDNAME:"
+ # so we can easily separate things out.
+ #
+ # Inspec: (File capture of 'FirstSearch' interface output)
+ #
+ # It's a bit harder here, and we have to remove a lot of
+ # garbage, however, we basically only accept lines beginning
+ # with '|', and parse the record names appropriately.
+ #
+ # Inspec2:
+ #
+ # This is much easier: each record starts with 'Document N' and
+ # ends with a long line of dashes.
+ #
+ # Inspec3:
+ #
+ # This is much easier: each record starts with 'Citation N'.
+ # Now copes with two variants of this record type (Aug'96)
+ #
+ # Inspec4:
+ #
+ # This is much easier: each record starts with ' Doc Type:'.
+ #
+ # Inspec5:
+ #
+ # I've forgotten what this one looks like (Record No. or so)
+ #
+ # Inspec6:
+ #
+ # Something from Berkeley: 'N. (Inspec Result)'
+ #
+ # ISI: (Institute of Scientific Information; Science Citation Index)
+ #
+ # The basic idea is that records are outlined by "PT" and
+ # "ER" tags, each field label is of the form "FF "
+ # so we can easily separate things out.
+ #
+ # Features:
+ #
+ # The only clever bits are as follows:
+ # 1) Automatically try and extract an author surname,
+ # concatenate it with the year and use it as the bibtex
+ # citation label.
+ # 2) Replace '\' in author lists by 'and' (hollis)
+ # 3) Replace ';' in author lists by 'and' (inspec)
+ # 4) Uses editor 'Alpha' on the mac for some interaction
+ # 5) Automatic bib type recognition via file extensions
+ # 6) Can automatically convert an Alpha window, and
+ # integrate with the bibtex mode.
+ # 7) Will extract and separate journal entries containing
+ # name, vol., number and pages together.
+ # 8) Plus lots more clever stuff now....
+ #
+ #########################################################################
+ #
+ # Please send any improvements: <mailto:darley@fas.harvard.edu>
+ #
+ # This code snippet is copyright (C) Vince Darley 1997,
+ # although you may freely copy and modify it provided this
+ # copyright notice remains intact. I will maintain and add to
+ # it over time, and will accomodate your improvements if you send
+ # them to me.
+ #
+ #########################################################################
+ #
+ # All procedures and global variables begin with 'bibconv::'
+ # except the main one, which is called 'bibConvert'.
+ #
+ # If you're interested in self-organisation, complex systems
+ # and stuff like that, check out the follwing URL for some
+ # bibliographies which are the results of this code: #
+ # <http://www.fas.harvard.edu/~darley/>
+ #
+ #########################################################################
+ #
+ # Usage:
+ # must be sourced into a Tcl interpreter, e.g.:
+ #
+ # >tclsh
+ # % source bibAdditions.tcl
+ # % source bibConvert.tcl
+ # % bibConvert myfile.inspec
+ # % bibConvert otherfile.inspec
+ # % exit
+ # > more myfile.bib
+ # > ...
+ #
+ # Detailed usage:
+ #
+ # 'bibConvert input-file [output-file] [hollis | inspec]'
+ #
+ # If the output file exists it will be overwritten, except on a
+ # Mac, running under Alpha, in which case the user is asked first
+ #
+ # Simple usage:
+ # 'bibConvert foo'
+ # will look for files "foo.[inspec|insp|hollis|hol]"
+ # If one exists, the appropriate conversion will take place, and
+ # the converted bibliography saved in file "foo.bib".
+ #
+ # Personalisation:
+ # There are a few variables whose values you can modify to tailor
+ # the output to your personal needs. See the start of the code
+ # section for details.
+ #
+ # Usage via a shell script: remove the leading '#' on each of the seven
+ # lines below and put the rest into a script file 'bibConvert'
+ #
+ # ---------------bibConvert---------------cut here ---------
+ # #!/bin/sh
+ # # the next line restarts using tclsh, as long as it's in the path \
+ # exec tclsh7.6 "$0" "$@"
+ #
+ # source ~/bin/bibAdditions.tcl
+ # source ~/bin/bibConvert.tcl
+ # eval bibConvert $argv
+ # --------------------------------------- cut here ---------
+ #
+ #########################################################################
+ #
+ # Usage under the editor 'Alpha':
+ #
+ # You may have got this file as part of "Vince's Additions", a
+ # set of Tcl files which I've built up to personalise Alpha for
+ # various purposes. Use the readme to install this package for Alpha.
+ #
+ # Now open a '.hollis' or '.inspec' file
+ # and Alpha automatically switches to bibtex mode, with a new item
+ # at the bottom of the bibtex menu 'bibConvert', also bound to the
+ # key combination '<ctrl>-b'. Select it and Alpha converts the open
+ # window, saving it in a new file (with extension '.bib'), which it
+ # then opens for you to examine!
+ #
+ #########################################################################
+ #
+ # To Do:
+ # Better handling of record types: currently all hollis records
+ # are 'book' and inspec records are 'article' or 'inproceedings'
+ #
+ # Add ability to append to a given bibliography.
+ #
+ # Add ability to convert a text selection under Alpha
+ #
+ #####################################################################
+ # History
+ #
+ # modified by rev reason
+ # -------- --- --- -----------
+ # May95 VMD 0.1 original, hollis->bibtex converter
+ # May95 VMD 0.2 added rudimentary inspec support
+ # May95 VMD 0.3 code more robust, and handles inspec well
+ # May95 VMD 0.4 looks at command line extensions to determine
+ # bib type.
+ # May95 VMD 0.5 Will convert windows of the Alpha editor
+ # May95 VMD 0.6 Integrates with bibtex mode under Alpha
+ # May95 VMD 0.7 Now dependent upon some utility code in
+ # 'bibAdditions.tcl'
+ # May95 VMD 0.8 Tries to generate correct record type, and
+ # splits journal entries into pieces.
+ # Jun95 VMD 0.9 Handles a new inspec format plus few extras
+ # Aug96 VMD 0.91 More formats
+ # 5/3/97 VMD 1.0 Prettier output, more user control over format
+ # 6/5/97 VMD 1.01 Fixed two minor bugs
+ # 17/2/98 VMD 1.05 Various improvements and new inspec type
+ # 4/16/98 JEG 1.06 Added ISI conversion
+ # 16/4/98 VMD 1.07 Modernised a few things.
+ # 21/2/99 fp 1.12 Added OVID support
+ # ###################################################################
+ ##
+
+# use a single tab to indent the body of an item.
+# change this if you prefer something else
+set _bibIndent "\t"
+# if an item covers multiple lines, indent lines 2-n by the amount
+set _bibMultiIndent "\t\t"
+# max line width
+set _bibMaxWidth 72
+
+# the types we recognise, with file extension mappings
+namespace eval bibconv {}
+set bibconv::types { hollis inspec isi ovid }
+set bibconv::extensions(insp) inspec
+set bibconv::extensions(inspec) inspec
+set bibconv::extensions(hol) hollis
+set bibconv::extensions(hollis) hollis
+set bibconv::extensions(isi) isi
+set bibconv::extensions(ovid) ovid
+
+# just so we can use this file without Alpha.
+namespace eval alpha {}
+if {[info commands alpha::feature] == ""} { proc alpha::feature {args} {} }
+
+# MODIFY BELOW AT YOUR OWN RISK.
+alpha::feature bibConvert 1.13 "Bib" {
+ alpha::package require Bib 3.1
+} {
+ menu::insert bibtexMenu items end "/B<BconvertToBib"
+} {
+} uninstall {this-directory} maintainer {
+ "Vince Darley" darley@fas.harvard.edu <http://www.fas.harvard.edu/~darley/>
+} help {
+ "bibConvert.tcl"
+
+This package will convert bibliography windows from 'hollis' and 'inspec'
+formats to bibtex, saving the result in a new file, and opening it in a new
+window for your perusal. This may not be of any use to you, but is very
+useful to me.
+
+Here 'hollis' is the format used by the Harvard University library system,
+and 'inspec' is a commercial scientific bibliography, interfaced either by
+the 'firstsearch' system or another standard inspec interface (whose output
+is handled by this Tcl code). This code currently handles no less than 7
+different inspec formats! Also, flip (flip@skidmore.edu) added ovid support.
+
+ "bibAdditions.tcl"
+
+Various common utility functions utilised by the rest of the code; also
+allows 'bibConvert' to work under a general Tcl interpreter (e.g. under
+Unix tclsh).
+}
+
+# make sure we've got my code loaded
+if {[catch {dummyBibAdditions}]} { puts "You must first source 'bibAdditions.tcl'" }
+
+namespace eval Bib {}
+proc Bib::convertToBib {args} {
+ eval bibConvert $args
+}
+
+proc bibConvert { { fin "" } { fout default } { bibtype unknown } } {
+ global vince_usingAlpha bibconv::using_window
+
+ if { $fin == "" } {
+ set fin [vince_getFile "Please select a bibliography to convert" ]
+ }
+
+ set args [bibconv::parse_args $fin $fout $bibtype]
+ set fin [lindex $args 0]
+ set fout [lindex $args 1]
+ set bibtype [lindex $args 2]
+
+ if { $bibtype == -1 } {
+ return
+ }
+
+ if {$vince_usingAlpha && ([info tclversion] < 8.0)} {
+ if {![catch {getWinInfo -w $fin alphawin}]} {
+ if {$alphawin(platform) != "mac"} {
+ alertnote "Windows to be converted must have MacOS eol's.\
+ I'll correct this for you."
+ setWinInfo -w $fin dirty 1
+ setWinInfo -w $fin platform mac
+ save
+ }
+ }
+ }
+
+ set fi [open $fin]
+ # make sure it's the correct type
+ set bibtype [bibconv::confirm_type $fi $bibtype]
+ if { $bibtype == "" } {
+ return
+ }
+
+ if {[file exists $fout]} {
+ if { [vince_askyesno \
+ "File '$fout' exists. Do you want to overwrite it?" ] \
+ != "yes" } {
+ return "bibliography conversion cancelled"
+ }
+ }
+
+ set fo [open $fout w]
+
+ set count 0
+ while {![eof $fi]} {
+ vince_print "converting: [incr count]"
+ bibconv::read_record $fi $fo $bibtype
+ }
+
+ close $fi
+ close $fo
+
+ vince_edit $fout
+}
+
+proc bibconv::confirm_type { fi bibtype } {
+ switch -- $bibtype {
+ "hollis" { return $bibtype }
+ "inspec" {
+ while { ![eof $fi] } {
+ gets $fi rline
+ if { [string range $rline 0 14] == "| RECORD NO.:" } {
+ set returnval "inspec"
+ break
+ } elseif { [string range $rline 0 7] == "Document" } {
+ set returnval "inspec2"
+ break
+ } elseif { [string range $rline 0 7] == "Citation" } {
+ set returnval "inspec3"
+ break
+ } elseif { [string range $rline 0 8] == " Doc Type" } {
+ set returnval "inspec4"
+ break
+ } elseif { [string range $rline 0 13] == " RECORD NO.:" } {
+ set returnval "inspec5"
+ break
+ } elseif { [string range $rline 0 20] == " COPYRIGHT:" } {
+ set returnval "inspec5"
+ break
+ } elseif { [string range $rline 0 17] == "1. (INSPEC result)" } {
+ set returnval "inspec6"
+ break
+ } elseif { [regexp {^<[0-9]+>} $rline]} {
+ set returnval "inspec7"
+ break
+ }
+ }
+ seek $fi 0 start
+ if { ![info exists returnval] } {
+ vince_print "Sorry I don't recognise this inspec format. Please contact darley@fas.harvard.edu"
+ return ""
+ }
+
+ return $returnval
+ }
+ "isi" { return $bibtype }
+ "ovid" {
+ # peel this off
+ gets $fi rline
+ seek $fi 0 start
+
+ if { [regexp {^<[0-9]+>} $rline]} {
+ return "ovid"
+ } else {
+ vince_print "Sorry I don't recognise this ovid format."
+ return ""
+ }
+ }
+
+ }
+
+}
+
+# called by the main bibConvert function
+
+proc bibconv::parse_args { fin fout bibtype } {
+ global vince_usingAlpha bibconv::types bibconv::extensions
+
+ if { $bibtype == "unknown" || [lsearch -exact ${bibconv::types} $bibtype ] == -1 } {
+ set bibtype ""
+ }
+
+ set f [vince_parseFileNames $fin "bib" ${bibconv::types} $fout bibconv::extensions ]
+
+ set bibtype [lindex $f 2]
+ if { [lsearch ${bibconv::types} $bibtype ] == -1 } {
+ # pick one from a list
+ set bibtype .[listpick \
+ -p "Please select a bibliography type to read from:" \
+ ${bibconv::types}]
+ set f [lreplace $f 2 2 $bibtype]
+ }
+ return $f
+}
+
+##
+ # Some fields extend over multiple lines, in which
+ # case we don't start a new field entry. This
+ # procedure returns '1' if we have a continuation.
+ ##
+
+proc bibconv::not_new_item { line bibtype } {
+ switch -- $bibtype {
+ "hollis"
+ { if { [string index $line 0] != "%" } {
+ return 1
+ } else {
+ return 0
+ }
+ }
+ "inspec"
+ { # is there a colon at position 14, and it starts with "|"
+ if { [string index $line 14] != ":" || [string index $line 0] != "|" } {
+ return 1
+ } else {
+ return 0
+ }
+ }
+ "ovid" -
+ "inspec7" -
+ "isi" {
+ # does the line start with whitespace
+ return [regexp {^[ \t]+[^ \t]} $line]
+ }
+ "inspec2" -
+ "inspec6"
+ { # is the first portion of the line blank?
+ if { [string range $line 0 14] == " " } {
+ return 1
+ } else {
+ return 0
+ }
+ }
+ "inspec3" -
+ "inspec4"
+ { # is the first portion of the line blank?
+ if { [string range $line 0 2] == " " } {
+ return 1
+ } else {
+ return 0
+ }
+ }
+ "inspec5"
+ { # is there a colon at position 13,
+ if { [string index $line 13] != ":" && [string index $line 20] != ":" } {
+ return 1
+ } else {
+ return 0
+ }
+ }
+ }
+}
+
+##
+ # Some interfaces intersperse records with garbage
+ # lines ("press 'f' for another page"). This procedure
+ # ignores them.
+ ##
+
+proc bibconv::throw_away { fi l1 bibtype } {
+ gets $fi rline2
+ switch -- $bibtype {
+ "hollis"
+ { return $rline2 }
+ "inspec" {
+ while { ![eof $fi] } {
+ # do away with identical lines
+ # (caused by paging through data)
+ if { $l1 != $rline2 \
+ && [string range $rline2 0 1] != "|_" \
+ && $rline2 != "|" \
+ && [string index $rline2 0] == "|" } {
+ return $rline2
+ } else {
+ gets $fi rline2
+ }
+
+ }
+ return ""
+ }
+ "ovid" -
+ "inspec2" -
+ "inspec7" -
+ "inspec3" -
+ "inspec4"
+ { return $rline2 }
+ "inspec6" {
+ set tr [string trim $rline2]
+ if {$tr == "CONFERENCE PAPER" || $tr == ""} {
+ gets $fi rline2
+ }
+ return $rline2
+ }
+ "inspec5" {
+ if { [string range $rline2 0 11] == " Next Record" } {
+ gets $fi rline2
+ }
+ return $rline2
+ }
+ "isi"
+ { return $rline2 }
+ }
+}
+
+##
+ # Parse a line and extract the
+ # category and actual item text:
+ ##
+
+proc bibconv::extract_item { rline bibtype } {
+ switch -- $bibtype {
+ "hollis"
+ {
+ set itempos [string first : $rline ]
+ set itemtype [string range $rline 1 [expr {$itempos - 1}] ]
+ set itemtype [string trimleft [string trimright $itemtype] ]
+ set itemtype [join $itemtype _]
+ set itemtext [string range $rline [expr {$itempos +1}] end]
+ set itemtext [string trimleft [string trimright $itemtext] ]
+ return [list $itemtype $itemtext]
+ }
+ "inspec"
+ {
+ set itemtype [string range $rline 1 13]
+ set itemtype [string trimleft [string trimright $itemtype] ]
+ set itemtype [join $itemtype _]
+ set itemtext [string range $rline 16 end]
+ return [list $itemtype $itemtext]
+
+ }
+ "inspec2"
+ {
+ set itemtype [string range $rline 0 14]
+ set itemtype [string trimright $itemtype " :" ]
+ set itemtype [join $itemtype _]
+ set itemtext [string range $rline 15 end]
+ return [list $itemtype $itemtext]
+ }
+ "inspec3" -
+ "inspec4" -
+ "inspec5" -
+ "inspec6" {
+ set itemtype [lindex [split "$rline" ":"] 0]
+ set itemtext [string range $rline [expr {1+[string length $itemtype]}] end]
+ set itemtype [join [string trim $itemtype] _]
+ return [list $itemtype $itemtext]
+ }
+ "inspec7" {
+ set itemtype [lindex [split "$rline" "\n"] 0]
+ set itemtext [string trim [string range $rline [expr {1+[string length $itemtype]}] end]]
+ set itemtype [join [string trim $itemtype] _]
+ return [list $itemtype $itemtext]
+ }
+ "isi" {
+ set itemtype [lindex [split "$rline" " "] 0]
+ set itemtext [string trim [string range $rline [expr {1+[string length $itemtype]}] end]]
+ set itemtype [join [string trim $itemtype] _]
+ return [list $itemtype $itemtext]
+ }
+ "ovid" {
+ set itemtype [lindex [split "$rline" "\n"] 0]
+ set itemtext [string trim [string range $rline [expr {1+[string length $itemtype]}] end]]
+ set itemtype [join [string trim $itemtype] _]
+ return [list $itemtype $itemtext]
+ }
+
+ }
+}
+
+##
+ # The main procedure which grabs a whole
+ # bibtex record
+ ##
+
+proc bibconv::read_record { fi fo bibtype } {
+ global bibconv::last_item
+
+ set rline [bibconv::find_start $fi ${bibconv::last_item} $bibtype]
+ if { $rline == 0 } { return }
+ catch {unset new_record}
+
+ while { [bibconv::not_at_end $rline $bibtype] && ![eof $fi] } {
+ #gets $fi rline2
+
+ set rline2 [bibconv::throw_away $fi $rline $bibtype]
+
+ # get all of a single item
+ while { [bibconv::not_new_item $rline2 $bibtype] && ![eof $fi] } {
+ append rline [bibconv::append_item $rline2 $bibtype]
+ set rline2 [bibconv::throw_away $fi $rline2 $bibtype]
+ }
+
+ set item [bibconv::extract_item $rline $bibtype]
+
+ eval bibconv::make_item new_record $item $bibtype
+
+ set rline $rline2
+ }
+ # all items are in the array 'new_record'
+
+ set bibconv::last_item $rline
+
+ set tag ""
+ if {[info exists new_record(author) ]} {
+ set author [bibconv::parse_author $new_record(author) $bibtype]
+ append tag [lindex $author 0]
+ set new_record(author) [lindex $author 1]
+ }
+
+ # parse year out (ignoring months) and append to the tag
+ if {[info exists new_record(year) ]} {
+ set y $new_record(year)
+ set year ""
+ regexp {[0-9][0-9][0-9][0-9]} $y year
+ set new_record(year) $year
+ }
+
+ # remove spaces to give the citation tag
+ set tag [join [split $tag " "] ""]
+
+ #set bibt [bibconv::citation_type [array names new_record] $bibtype ]
+
+ # returns the type of citation
+ set bibt [bibconv::reformat_records new_record $bibtype]
+ if {[info exists new_record(year) ]} {
+ # fp did this since I like this format better... though it might make it Y2K non-compliant
+ append tag [string range $new_record(year) 2 3]
+ }
+ puts $fo "@$bibt\{$tag,"
+ bibconv::clever_printing new_record $fo
+
+ foreach item [array names new_record] {
+ if { $new_record($item) != "" } {
+ bibconv::print new_record $item $fo
+ }
+ }
+ puts $fo "\}\n"
+}
+
+proc bibconv::make_item { rec itemtype itemtext bibtype } {
+ upvar $rec a
+ global bibconv::${bibtype}_map bibconv::${bibtype}_kill
+ set maps bibconv::${bibtype}_map
+ set kills bibconv::${bibtype}_kill
+
+ if {[info exists ${kills}($itemtype) ]} {
+ switch -- [set ${kills}($itemtype)] {
+ "always" {}
+ "remember" {lappend a(kill) $itemtype}
+ }
+ } elseif {[info exists ${maps}($itemtype) ]} {
+ if { $itemtext != "" } {
+ set a([set ${maps}($itemtype)]) $itemtext
+ }
+ } else {
+ vince_print "No such item $itemtype"
+ }
+}
+
+##
+ # print out author, title and year first, then the return
+ # for the rest in any order
+ ##
+
+proc bibconv::clever_printing { rec fo } {
+ upvar $rec a
+ global _bibIndent _bibMultiIndent
+ foreach item { author title year } {
+ bibconv::print a $item $fo
+ }
+}
+
+proc bibconv::print { rec item fo } {
+ upvar $rec a
+ global _bibIndent _bibMultiIndent
+ if {[info exists a($item) ]} {
+ set text [bibconv::convertfunnytcharstolatex $a($item)]
+ if { $text != "" } {
+ set pref [string range "$item = \{" 0 3]
+ set t [string range "$item = \{" 4 end]
+ set text "${t}$a($item)\},"
+ regsub -all "\[ \t\r\n]+" [string trim $text] " " text
+ regsub -all {(([^A-Z@]|\\@)[.?!]("|'|'')?([])])?) } $text {\1 } text
+ regsub -all {\&} $text {\\\&} text
+
+ bibconv::breakintolines text
+ puts $fo "${_bibIndent}${pref}$text"
+ }
+ unset a($item)
+ }
+
+}
+
+proc bibconv::convertfunnytcharstolatex {t} {
+ # convert formatting information.
+ regsub -all {/sub ([^/]+)/} $t "_\{\\1\}" t
+ regsub -all {/sup ([^/]+)/} $t "^\{\\1\}" t
+ return $t
+}
+
+proc bibconv::breakintolines {t} {
+ global vince_usingAlpha
+ global _bibIndent _bibMultiIndent _bibMaxWidth
+ set fc [expr {$_bibMaxWidth - 8}]
+ upvar $t text
+ # what if it's really big?
+ if {[string length $text] > $fc} {
+ if {$vince_usingAlpha} {
+ global leftFillColumn fillColumn
+ # temporarily adjust the fillColumns
+ set ol $leftFillColumn
+ set or $fillColumn
+ set leftFillColumn 0
+ set fillColumn $fc
+ # break and indent the paragraph
+ regsub -all "\[\n\r\]" "[string trimright [breakIntoLines $text]]" "\r${_bibMultiIndent}" text
+ set leftFillColumn $ol
+ set fillColumn $or
+ } else {
+ # do it by hand!
+ while {[string length $text] > $fc} {
+ set f [string last " " [string range $text 0 $fc]]
+ if {$f == -1} {
+ vince_print "Have a word > $fc letters long. It will be broken."
+ set f $fc
+ }
+ append a "[string range $text 0 $f]\n${_bibMultiIndent}"
+ set text [string range $text [incr f] end]
+ }
+ append a $text
+ set text $a
+ }
+ }
+}
+
+##
+ # We kill any records we don't want, and maybe split some which
+ # are given in sets.
+ ##
+
+proc bibconv::reformat_records { rec bibtype } {
+ upvar $rec a
+ # get rid of empty entries - but there shouldn't be any
+ ##
+ # foreach v [array names a] {
+ # if { $a($v) == "" } {
+ # unset a($v)
+ # }
+ # }
+ ##
+
+ switch -- $bibtype {
+ "hollis"
+ {
+ set a(kill) ""
+ unset a(kill)
+ return "book"
+ }
+ "inspec" -
+ "inspec2" -
+ "inspec3" -
+ "inspec5" -
+ "inspec6" -
+ "inspec7"
+ {
+ # if it's in a journal, we need to extract vol, number and pages
+ if {[info exists a(journal)]} {
+ regsub -all "\[ \t\r\n\]+" $a(journal) " " a(journal)
+ regsub -all {\([^0-9]+\)} $a(journal) "" a(journal)
+ # we split it with 'vol.' and 'p.' and grab the
+ # smaller start of the two
+ set p1 [string first " vol." $a(journal)]
+ if {$p1 < 0} {
+ set p1 [string first " vol " $a(journal)]
+ }
+ set p2 [string first " p." $a(journal)]
+ if {$p2 < 0} {
+ set p2 [string first " pp." $a(journal)]
+ }
+ if { $p2 < 0 } { set p2 1000 }
+
+ if { $p1 == $p2 } {
+ # both not found; currently do nothing
+ } else {
+ if {$p1 == -1} {
+ set p $p2
+ set j [string range $a(journal) [expr {$p +1}] end]
+ set a(journal) [string range $a(journal) 0 [expr $p -2]]
+ set j [split $j ,]
+ } else {
+ if { $p1 < $p2 } {
+ set p $p1
+ } else {
+ set p $p2
+ }
+ set j [string range $a(journal) [expr $p +1] end]
+ set a(journal) [string range $a(journal) 0 [expr $p -2]]
+ set j [split $j ,]
+ }
+
+ #alertnote $j
+
+ set l [llength $j]
+ # sometimes we aren't given a number so we insert a blank
+ if { $l == 2 } {
+ set j [linsert $j 1 "." ]
+ incr l
+ set p [lindex $j 2]
+ if { [string first "p." $p ] < 0 } {
+ set j [lreplace $j 2 2 p.${p} ]
+ }
+ }
+ # now extract vol, number and page from the last three
+ #set j [lrange $j [expr $l -2] $l]
+ if { ![info exists a(volume)] } {
+ set a(volume) [bibconv::extract_vnp [lindex $j 0] "."]
+ }
+ if { ![info exists a(number)] } {
+ set a(number) [bibconv::extract_vnp [lindex $j 1] "."]
+ }
+ if { ![info exists a(pages)] } {
+ set a(pages) [bibconv::extract_vnp [lindex $j 2] "p."]
+ }
+
+ #now journal may end in a month and year! (esp Inspec 3,6)
+ set a(journal) [string trim $a(journal)]
+ if { [set jj [string first "(" $a(journal)]] != -1 } {
+ set rest [string range $a(journal) $jj end]
+ set a(journal) [string range $a(journal) 0 [expr $jj -1]]
+ set rest [string trim $rest "() "]
+ if {[string match {*[1-9][0-9][0-9][0-9]} $rest]} {
+ set lrest [llength $rest]
+ set a(year) [lindex $rest [expr $lrest -1]]
+ set a(month) [lindex $rest [expr $lrest -2]]
+ }
+ } else {
+
+ set l [string length $a(journal)]
+ set e [string range $a(journal) [expr $l -4] end ]
+ if {[string match {[1-9][0-9][0-9][0-9]} $e ]} {
+ # it ends in a year
+ set a(year) $e
+ set p [string last "," $a(journal)]
+ set my [string range $a(journal) $p end]
+ set a(journal) [string range $a(journal) 0 [expr $p -1]]
+ set l [string length $my]
+ set a(month) [string trim [string range $my 1 [expr $l -5]]]
+ } else {
+ # 'j' above may end in a year
+ set j [string trim [lindex $j end] " ."]
+ regsub -all {[ .]+} $j " " j
+ regexp {(([1-9][0-9]* )?[A-Za-z]+) ([1-9][0-9][0-9][0-9])$} $j \
+ "" a(month) "" a(year)
+ }
+
+ }
+
+ }
+ }
+
+ # we're only interested if it's a conference proceedings or not
+ if {[info exists a(kill)]} {
+ unset a(kill)
+ return "inproceedings"
+ } else {
+ return "article"
+ }
+ }
+ "inspec4"
+ {
+ # if it's in a journal, we need to extract vol, number and pages
+ if {[info exists a(journal)]} {
+ # we split it with 'vol.' and 'p.' and grab the
+ # smaller start of the two
+ set s [split $a(journal) "\n"]
+ set a(journal) [lindex $s 0]
+ for { set i 1 } { $i <= [llength $s] } { incr i } {
+ set l [bibconv::extract_item [lindex $s $i] $bibtype]
+ eval bibconv::make_item a $l $bibtype
+ }
+ }
+
+ if {[info exists a(volume)]} {
+ set p [string first "Iss:" $a(volume)]
+ if { $p > 0 } {
+ set a(number) [string range $a(volume) [expr $p +4] end]
+ set a(volume) [string range $a(volume) 0 [expr $p -1]]
+ }
+ }
+
+ if {[info exists a(number)]} {
+ set p [string first "p." $a(number)]
+ if { $p > 0 } {
+ set a(pages) [string range $a(number) [expr $p +2] end]
+ set a(number) [string range $a(number) 0 [expr $p -1]]
+ }
+ }
+
+ # we're only interested if it's a conference proceedings or not
+ if {[info exists a(kill)]} {
+ unset a(kill)
+ return "inproceedings"
+ } else {
+ return "article"
+ }
+ }
+ "isi" {
+ if {[info exists a(EP)]} {
+ if {[info exists a(pages)]} {
+ set a(EP) [string trim $a(EP)]
+ set a(pages) [string trim $a(pages)]
+ if {$a(pages) != $a(EP)} {
+ set a(pages) "$a(pages)--$a(EP)"
+ }
+ } else {
+ # I know of no reason for this to ever happen, but...
+ set a(pages) $a(EP)
+ }
+ unset a(EP)
+ }
+ if {[info exists a(DE)]} {
+ if {[info exists a(key)]} {
+ append a(key) ";\n\t\t$a(DE)"
+ } else {
+ set a(key) $a(DE)
+ }
+ unset a(DE)
+ }
+ if {[info exists a(DT)]} {
+ set type [string tolower $a(DT)]
+ unset a(DT)
+ } else {
+ set type "article"
+ }
+ return $type
+ }
+ "ovid"
+ {
+ # if it's in a journal, we need to extract vol, number and pages
+ if {[info exists a(journal)]} {
+ regsub -all "\[ \t\r\n\]+" $a(journal) " " a(journal)
+ regsub -all {\([^0-9]+\)} $a(journal) "" a(journal)
+
+ # split into journal name and volume info
+ set js [split $a(journal) .]
+ #split volume info into chunks
+ set j [split [lindex $js 1] ,]
+
+ # Apa kindof looks like this:
+ # Name. Vol vol(num), month year, pages.
+ set a(journal) [string trim [lindex $js 0]]
+
+ #alertnote $j
+
+ # the chunks and how many of 'em.
+ set l [llength $j]
+ set v [string trim [lindex $j 0]]
+ set e [string trim [lindex $j 1]]
+ if {$l == 3} {set pp [string trim [lindex $j 2]]}
+
+ #first is the volume field, tends to be in one of three formats
+ # raw number: 62
+ # vol indica: Vol 32
+ # no indica: No 43
+ # vol no: Vol 43(2)
+ #
+ # yes, yes, i'm not entirely sure what is up here... ok, ok, yes
+ # stop tortureing me. i'm sorry, can't that just be enough for you?
+ #
+ if { ![info exists a(volume)] || ![info exists a(number)] } {
+ switch -regexp $v {
+ {([0-9]+)\(([0-9]+)\)} {regexp {([0-9]+)\(([0-9]+)\)} $v poo a(volume) a(number)}
+ {[Vv].*} {regexp {([0-9]+)} $v poo a(volume)}
+ {[Nn].*} {regexp {([0-9]+)} $v poo a(number)}
+ default {regexp {([0-9]+)} $v poo a(number)}
+ }
+ }
+ if { ![info exists a(pages)] && $l == 3} {
+ set a(pages) $pp
+ }
+
+ if {[string match {[1-9][0-9][0-9][0-9]} $e ]} {
+ # it ends in a year
+ set a(year) $e
+ } else {
+ # 'j' above may end in a year
+ regexp {(([1-9][0-9]* )?[A-Za-z]+) ([1-9][0-9][0-9][0-9])$} $e \
+ "" a(month) "" a(year)
+ }
+ }
+
+ # we're only interested if it's a conference proceedings or not
+ if {[info exists a(kill)]} {
+ unset a(kill)
+ return "inproceedings"
+ } else {
+ return "article"
+ }
+ }
+
+ }
+}
+
+##
+ # Utility procedure used by the above
+ ##
+
+proc bibconv::extract_vnp { str prefix } {
+ set p [string first $prefix $str]
+ if { $p == -1 } {
+ return ""
+ } else {
+ return [string range $str [expr $p + [string length $prefix]] end]
+ }
+}
+
+##
+ # Try and do something intelligent with lists
+ # of multiple authors. Returns a list containing
+ # the surname of the first author (for the bibtex tag)
+ # followed by the actual bibtex author entry.
+ ##
+
+proc bibconv::parse_author { author bibtype } {
+ switch -- $bibtype {
+ "hollis"
+ {
+ return [list [lindex [split $author ,] 0] \
+ [join [split $author \\ ] and] ]
+ }
+ "ovid" -
+ "inspec" -
+ "inspec3" -
+ "inspec4" -
+ "inspec5" -
+ "inspec6" -
+ "inspec7"
+ {
+ # remove anything in '()' (usually an address)
+ regsub -all {\([^\(\)]*\)} $author {} auth
+ return [list [lindex [split $auth ",;.:" ] 0] \
+ [join [split $auth ";" ] " and"] ]
+
+ }
+ "inspec2"
+ {
+ set first [lindex [split $author "-" ] 0]
+ set alist ""
+ foreach a [split $author "."] {
+ if { $a != "" } {
+ set l [split $a "-"]
+ append alist "[lindex $l 0], "
+ foreach i [lrange $l 1 end] {
+ append alist "$i."
+ }
+ append alist " and "
+ }
+ }
+ set l [string length $alist]
+ set alist [string range $alist 0 [expr $l -5 ] ]
+
+ return [list $first $alist]
+ }
+ "isi" {
+ regsub -all "\t\t" $author "" author
+ set first [lindex [split $author ",\n"] 0]
+ set alist ""
+ foreach a [split $author "\n"] {
+ if {$a != ""} {
+ set l [split $a ","]
+ append alist "[lindex $l 0]"
+
+ if {[llength $l] == 2} {
+ append alist ","
+ set ii [string trim [lindex $l 1]]
+ regsub -all {[A-Z]} $ii { \0.} ii
+ append alist $ii
+ }
+
+ append alist " and "
+ }
+ }
+
+ # clip last " and "
+ set l [string length $alist]
+ set alist [string range $alist 0 [expr $l -6 ] ]
+
+ return [list $first $alist]
+ }
+ }
+}
+
+##
+ # We had a multiple line field and wish
+ # to add the subsequent lines
+ ##
+
+proc bibconv::append_item { rline2 bibtype } {
+ switch -- $bibtype {
+ "hollis"
+ {
+ return "\n\t\t[string trimleft $rline2]"
+ }
+ "inspec"
+ {
+ if { $rline2 != "|" } {
+ if { [string index $rline2 0] == "|" } {
+ return "\n[string range $rline2 1 end]"
+ } else {
+ return "\n$rline2"
+ }
+ } else {
+ return ""
+ }
+ }
+ "ovid" -
+ "inspec2" -
+ "inspec3" -
+ "inspec4" -
+ "inspec5" -
+ "inspec6" -
+ "inspec7" -
+ "isi"
+ {
+ return "\n\t\t[string trimleft $rline2]"
+ }
+ }
+}
+
+##
+ # Find the start of a new bibtex record
+ ##
+
+proc bibconv::find_start { fi rline bibtype } {
+ if { $rline == "" } { gets $fi rline }
+ switch -- $bibtype {
+ "hollis"
+ { while {![eof $fi] } {
+ if { $rline == "%START:" } {
+ gets $fi rline
+ return $rline
+ }
+ gets $fi rline
+ }
+ return 0
+ }
+ "inspec"
+ { while {![eof $fi] } {
+ if { [string range $rline 0 14] == "| RECORD NO.:" } {
+ gets $fi rline
+ return $rline
+ }
+ gets $fi rline
+ }
+ return 0
+ }
+ "inspec2"
+ { while {![eof $fi] } {
+ if { [string range $rline 0 7] == "Document" } {
+ gets $fi rline
+ return $rline
+ }
+ gets $fi rline
+ }
+ return 0
+ }
+ "inspec3"
+ { while {![eof $fi] } {
+ if { [string range $rline 0 7] == "Citation" } {
+ gets $fi rline
+ return $rline
+ }
+ gets $fi rline
+ }
+ return 0
+ }
+ "inspec4"
+ { while {![eof $fi] } {
+ if { [string range $rline 0 8] == " Doc Type" } {
+ gets $fi rline
+ return $rline
+ }
+ #gets $fi rline
+ }
+ return 0
+ }
+ "inspec5"
+ { while {![eof $fi] } {
+ if { [string range $rline 0 13] == " RECORD NO.:" \
+ || [string range $rline 0 20] == " RECORD NO.:"} {
+ gets $fi rline
+ return $rline
+ }
+ gets $fi rline
+ }
+ return 0
+ }
+ "inspec6"
+ { while {![eof $fi] } {
+ if { [string trim [lindex [split $rline "."] 1]] == "(INSPEC result)" } {
+ gets $fi rline
+ if { [string trim $rline] == "CONFERENCE PAPER"} {
+ gets $fi rline
+ }
+ return $rline
+ }
+ gets $fi rline
+ }
+ return 0
+ }
+ "ovid" -
+ "inspec7"
+ { while {![eof $fi] } {
+ if { [regexp {^<[0-9]+>} $rline] } {
+ gets $fi rline
+ return $rline
+ }
+ gets $fi rline
+ }
+ return 0
+ }
+ "isi"
+ { while {![eof $fi] } {
+ if { [string range $rline 0 1] == "PT" } {
+ gets $fi rline
+ return $rline
+ }
+ gets $fi rline
+ }
+ return 0
+ }
+ }
+}
+
+##
+ # Have we reached the end of the last
+ # bibtex field?
+ ##
+
+proc bibconv::not_at_end { line bibtype } {
+ switch -- $bibtype {
+ "hollis"
+ { if { $line != "%END:" } { return 1 } else { return 0 }
+ }
+ "inspec"
+ {
+ set st [string range $line 0 14]
+ if { $st != "| CLASS CODES:" && $st != "| RECORD NO.:" } {
+ return 1
+ } else {
+ return 0
+ }
+
+ }
+ "inspec2"
+ {
+ set st [string range $line 0 7]
+ if { $st != "--------" && $st != "UW Load " } {
+ return 1
+ } else { return 0 }
+ }
+ "inspec3"
+ {
+ if { [string range $line 0 7] != "Citation" } {
+ return 1
+ } else { return 0 }
+ }
+ "inspec4"
+ {
+ if { [string range $line 0 8] != " Doc Type" } {
+ return 1
+ } else { return 0 }
+ }
+ "inspec5"
+ {
+ set st [string range $line 0 13]
+ if { $st != " CLASS CODES:" && $st != " RECORD NO.:" } {
+ return 1
+ } else {
+ set st [string range $line 0 20]
+ if { $st != " CLASS CODES:" && $st != " RECORD NO.:" } {
+ return 1
+ } else {
+ return 0
+ }
+ }
+
+ }
+ "inspec6"
+ {
+ set st [string trim [lindex [split $line "."] 1]]
+ if { $st != "(INSPEC result)" } {
+ return 1
+ } else {
+ return 0
+ }
+ }
+ "ovid" -
+ "inspec7"
+ {
+ if { [string trim $line] == "" } {
+ return 0
+ } else {
+ return 1
+ }
+ }
+ "isi" {
+ if { $line != "ER" } { return 1 } else { return 0 }
+ }
+ }
+}
+
+set bibconv::last_item ""
+set bibconv::using_window 0
+
+
+########################################################
+# #
+# Record field name mappings for different formats #
+# #
+########################################################
+
+# spaces are replaced by underscores in array entries
+
+########################
+# #
+# Hollis mappings: #
+# #
+########################
+
+set bibconv::hollis_map(AUTHORS) author
+set bibconv::hollis_map(YEAR) year
+set bibconv::hollis_map(TITLE) title
+set bibconv::hollis_map(PUB._INFO) publisher
+set bibconv::hollis_map(EDITION) edition
+set bibconv::hollis_map(SUMMARY) annote
+set bibconv::hollis_map(NOTES) note
+set bibconv::hollis_map(LOCATION) customField
+set bibconv::hollis_map(SERIES) series
+set bibconv::hollis_map(SUBJECTS) key
+set bibconv::hollis_map(PUBLISHED_IN) howPublished
+set bibconv::hollis_map(NUMBERS) isbn
+
+set bibconv::hollis_kill(HOLLIS#) always
+set bibconv::hollis_kill(DESCRIPTION) always
+set bibconv::hollis_kill(FORMAT) always
+set bibconv::hollis_kill(FREQUENCY) always
+set bibconv::hollis_kill(AUTHOR) always
+
+#######################
+# #
+# Inspec mappings #
+# #
+#######################
+
+set bibconv::inspec_map(AUTHOR) author
+set bibconv::inspec_map(TITLE) title
+set bibconv::inspec_map(YEAR) year
+set bibconv::inspec_map(LANGUAGE) language
+set bibconv::inspec_map(ABSTRACT) annote
+set bibconv::inspec_map(PLACE_OF_PUBL) howPublished
+set bibconv::inspec_map(DESCRIPTORS) key
+set bibconv::inspec_map(IDENTIFIERS) key
+set bibconv::inspec_map(CORP_SOURCE) institution
+set bibconv::inspec_map(ISSN) issn
+set bibconv::inspec_map(ISBN) isbn
+set bibconv::inspec_map(CONF_TITLE) organization
+set bibconv::inspec_map(SOURCE) journal
+set bibconv::inspec_map(PUBLISHER) publisher
+set bibconv::inspec_map(EDITOR) editor
+set bibconv::inspec_map(SPONSOR_ORG) organization
+set bibconv::inspec_kill(COPYRIGHT) always
+set bibconv::inspec_kill(COPYRIGHT_NO) always
+set bibconv::inspec_kill(COUNTRY) always
+set bibconv::inspec_kill(CLASS_CODES) always
+set bibconv::inspec_kill(RECORD_NO.) always
+set bibconv::inspec_kill(CODEN) always
+set bibconv::inspec_kill(CONF_LOCATION) remember
+set bibconv::inspec_kill(TREATMENT) always
+set bibconv::inspec_kill(TRANSLATED_IN) always
+set bibconv::inspec_kill(LIBRARIES) always
+
+##
+ # Inspec 2 mappings
+ # These are for inspec files started
+ # with 'Document ...' and 'Accession No.'
+ ##
+
+set bibconv::inspec2_map(Author) author
+set bibconv::inspec2_map(Title) title
+set bibconv::inspec2_map(Source) journal
+set bibconv::inspec2_kill(References) always
+set bibconv::inspec2_map(ISSN) issn
+set bibconv::inspec2_map(Subject) note
+set bibconv::inspec2_map(Identifiers) key
+set bibconv::inspec2_map(Abstract) annote
+set bibconv::inspec2_map(Language) language
+set bibconv::inspec2_map(Year) year
+set bibconv::inspec2_kill(Pub._Type) always
+set bibconv::inspec2_kill(CODEN) always
+set bibconv::inspec2_kill(Accession_No.) always
+set bibconv::inspec2_kill(Author_Affil.) always
+set bibconv::inspec2_kill(Treatment) always
+set bibconv::inspec2_kill(Num._Indexing) always
+set bibconv::inspec2_kill(Report_No.) always
+set bibconv::inspec2_kill(Pub._Country) always
+set bibconv::inspec2_kill(Class._Code) always
+set bibconv::inspec2_kill(Sub./Material) always
+set bibconv::inspec2_kill(UW_Load_Date) always
+
+##
+ # Inspec 3 mappings
+ # These are for inspec files started
+ # with 'Citation ...' and
+ ##
+
+set bibconv::inspec3_map(AUTHOR) author
+set bibconv::inspec3_map(TITLE) title
+set bibconv::inspec3_map(YEAR) year
+set bibconv::inspec3_kill(DOCUMENT_TYPE) always
+set bibconv::inspec3_map(LANGUAGE) language
+set bibconv::inspec3_map(LOCATION) location
+set bibconv::inspec3_map(ABSTRACT) annote
+set bibconv::inspec3_map(PLACE_OF_PUBL) howPublished
+set bibconv::inspec3_map(DESCRIPTORS) key
+set bibconv::inspec3_map(IDENTIFIERS) key
+set bibconv::inspec3_map(THESAURUS) key
+set bibconv::inspec3_map(CORP_SOURCE) institution
+set bibconv::inspec3_map(ISSN) issn
+set bibconv::inspec3_map(ISBN) isbn
+set bibconv::inspec3_map(CONF_TITLE) organization
+set bibconv::inspec3_map(PUBLICATION) journal
+set bibconv::inspec3_map(NOTES) note
+set bibconv::inspec3_map(OTHER_SUBJECTS) annote
+set bibconv::inspec3_map(PUBLISHER) publisher
+set bibconv::inspec3_map(EDITOR) editor
+set bibconv::inspec3_map(SPONSOR_ORG) organization
+set bibconv::inspec3_kill(COPYRIGHT) always
+set bibconv::inspec3_kill(COPYRIGHT_NO) always
+set bibconv::inspec3_kill(COUNTRY) always
+set bibconv::inspec3_kill(CLASS_CODES) always
+set bibconv::inspec3_kill(RECORD_NO.) always
+set bibconv::inspec3_kill(CODEN) always
+set bibconv::inspec3_kill(CONF_LOCATION) remember
+set bibconv::inspec3_kill(TREATMENT) always
+set bibconv::inspec3_kill(TRANSLATED_IN) always
+set bibconv::inspec3_kill(LIBRARIES) always
+set bibconv::inspec3_kill(CHEMICAL_INDEXING) always
+
+##
+ # Inspec 4 mappings
+ # These are for inspec files started
+ # with 'Doc Type: ...' and
+ ##
+
+set bibconv::inspec4_map(Language) language
+set bibconv::inspec4_map(Authors) author
+set bibconv::inspec4_map(Title) title
+set bibconv::inspec4_map(Vol) volume
+set bibconv::inspec4_map(Date) year
+set bibconv::inspec4_map(Country_of_Publication) howPublished
+set bibconv::inspec4_map(ISSN) issn
+set bibconv::inspec4_kill(CCC) always
+set bibconv::inspec4_map(Affiliation) organization
+set bibconv::inspec4_map(Journal) journal
+set bibconv::inspec4_map(Free_Terms) key
+set bibconv::inspec4_map(Abstract) annote
+set bibconv::inspec4_map(Classification) key
+set bibconv::inspec4_map(Thesaurus) key
+set bibconv::inspec4_kill(Treatment) always
+set bibconv::inspec4_kill(Doc_Type) always
+
+##
+ # Inspec 5 mappings
+ # These are for inspec files started
+ # with 'Record No: ...' and
+ ##
+
+set bibconv::inspec5_map(AUTHOR) author
+set bibconv::inspec5_map(TITLE) title
+set bibconv::inspec5_map(YEAR) year
+set bibconv::inspec5_map(LANGUAGE) language
+set bibconv::inspec5_map(ABSTRACT) annote
+set bibconv::inspec5_map(PLACE_OF_PUBL) howPublished
+set bibconv::inspec5_map(DESCRIPTORS) key
+set bibconv::inspec5_map(IDENTIFIERS) key
+set bibconv::inspec5_map(CORP_SOURCE) institution
+set bibconv::inspec5_map(ISSN) issn
+set bibconv::inspec5_map(ISBN) isbn
+set bibconv::inspec5_map(CONF_TITLE) organization
+set bibconv::inspec5_map(SOURCE) journal
+set bibconv::inspec5_map(PUBLISHER) publisher
+set bibconv::inspec5_map(EDITOR) editor
+set bibconv::inspec5_map(SPONSOR_ORG) organization
+set bibconv::inspec5_kill(COPYRIGHT) always
+set bibconv::inspec5_kill(RECORD_TYPE) always
+set bibconv::inspec5_kill(COPYRIGHT_NO) always
+set bibconv::inspec5_kill(COUNTRY) always
+set bibconv::inspec5_kill(CLASS_CODES) always
+set bibconv::inspec5_kill(RECORD_NO.) always
+set bibconv::inspec5_kill(CODEN) always
+set bibconv::inspec5_kill(CONF_LOCATION) remember
+set bibconv::inspec5_kill(TREATMENT) always
+set bibconv::inspec5_kill(TRANSLATED_IN) always
+set bibconv::inspec5_kill(LIBRARIES) always
+
+##
+ # Inspec 6 mappings
+ # These are for inspec files started
+ # with 'N. (INSPEC result)'
+ ##
+
+set bibconv::inspec6_map(Author) author
+set bibconv::inspec6_map(Title) title
+set bibconv::inspec6_map(Language) language
+set bibconv::inspec6_map(Text) annote
+set bibconv::inspec6_map(Subject) key
+set bibconv::inspec6_map(Affiliation) institution
+set bibconv::inspec6_map(Source) journal
+set bibconv::inspec6_map(Conference) organization
+set bibconv::inspec6_kill(Chem_Indexing) always
+set bibconv::inspec6_kill(Pub_type) always
+set bibconv::inspec6_kill(Subfile) always
+
+##
+ # Inspec 7 mappings
+ # These are for inspec files started
+ # with <N>, and each article with an accession number
+ ##
+
+set bibconv::inspec7_map(Author) author
+set bibconv::inspec7_map(Title) title
+set bibconv::inspec7_map(Source) journal
+set bibconv::inspec7_kill(References) always
+set bibconv::inspec7_map(ISSN,ISBN,SBN) issn
+set bibconv::inspec7_map(Subject) note
+set bibconv::inspec7_map(Identifiers) key
+set bibconv::inspec7_map(Descriptors) key
+set bibconv::inspec7_map(Abstract) annote
+set bibconv::inspec7_map(Language) language
+set bibconv::inspec7_map(Year) year
+set bibconv::inspec7_kill(Publication_Type) always
+set bibconv::inspec7_kill(CODEN) always
+set bibconv::inspec7_kill(Accession_Number) always
+set bibconv::inspec7_kill(Abstract_Number) always
+set bibconv::inspec7_kill(Conference_Title) always
+set bibconv::inspec7_kill(Author_Affiliation) always
+set bibconv::inspec7_kill(Treatment_Code) always
+set bibconv::inspec7_kill(Num._Indexing) always
+set bibconv::inspec7_kill(Report_Number) always
+set bibconv::inspec7_kill(Country_of_Publication) always
+set bibconv::inspec7_kill(Classification_Codes) always
+set bibconv::inspec7_kill(Substance_Material) always
+set bibconv::inspec7_kill(Update_Code) always
+set bibconv::inspec7_kill(Numeric_Indexing) always
+
+########################
+# #
+# ISI mappings: #
+# #
+########################
+
+set bibconv::isi_map(AU) author
+set bibconv::isi_map(TI) title
+set bibconv::isi_map(SO) journal
+set bibconv::isi_map(PU) publisher
+set bibconv::isi_map(C1) institution
+set bibconv::isi_map(ID) key
+# post-processed into key
+set bibconv::isi_map(DE) DE
+set bibconv::isi_map(AB) annote
+set bibconv::isi_map(BP) pages
+# post-processed into pages
+set bibconv::isi_map(EP) EP
+set bibconv::isi_map(PY) year
+set bibconv::isi_map(PD) month
+set bibconv::isi_map(VL) volume
+set bibconv::isi_map(IS) number
+set bibconv::isi_map(SE) series
+# post-processed into entry type
+set bibconv::isi_map(DT) DT
+
+set bibconv::isi_kill(PT) always
+set bibconv::isi_kill(SN) always
+set bibconv::isi_kill(PG) always
+set bibconv::isi_kill(JI) always
+set bibconv::isi_kill(GA) always
+set bibconv::isi_kill(PI) always
+set bibconv::isi_kill(RP) always
+set bibconv::isi_kill(J9) always
+set bibconv::isi_kill(PA) always
+set bibconv::isi_kill(PN) always
+
+##
+ # Ovid mappings
+ # These are for inspec files started
+ # with <N>, and each article with an accession number
+ ##
+
+set bibconv::ovid_map(Author) author
+set bibconv::ovid_map(Title) title
+set bibconv::ovid_map(Source) journal
+set bibconv::ovid_kill(References) always
+set bibconv::ovid_map(ISSN) issn
+set bibconv::ovid_map(ISBN) issn
+set bibconv::ovid_map(SBN) issn
+set bibconv::ovid_map(Subject_Headings) note
+set bibconv::ovid_map(Key_Phrase_Identifiers) key
+set bibconv::ovid_map(Descriptors) key
+set bibconv::ovid_map(Abstract) annote
+set bibconv::ovid_map(Language) language
+set bibconv::ovid_map(Publication_Year) year
+set bibconv::ovid_map(Institution) institution
+set bibconv::ovid_map(Conference_Information) conference
+set bibconv::ovid_map(Chapter_Title) chapter
+set bibconv::ovid_kill(Publication_Type) always
+set bibconv::ovid_kill(CODEN) always
+set bibconv::ovid_kill(Accession_Number) always
+set bibconv::ovid_kill(Abstract_Number) always
+set bibconv::ovid_kill(Conference_Title) always
+set bibconv::ovid_kill(Author_Affiliation) always
+set bibconv::ovid_kill(Treatment_Code) always
+set bibconv::ovid_kill(Num._Indexing) always
+set bibconv::ovid_kill(Report_Number) always
+set bibconv::ovid_kill(Country_of_Publication) always
+set bibconv::ovid_kill(Classification_Codes) always
+set bibconv::ovid_kill(Classification_Code) always
+set bibconv::ovid_kill(Substance_Material) always
+set bibconv::ovid_kill(Update_Code) always
+set bibconv::ovid_kill(Numeric_Indexing) always
+set bibconv::ovid_kill(Local_Messages) always
+set bibconv::ovid_kill(Population_Group) always
+set bibconv::ovid_kill(Form/Content_Type) always
+set bibconv::ovid_kill(Special_Feature) always
+set bibconv::ovid_kill(Population_Location) always
+
diff --git a/systems/mac/support/alpha/tcl/extensions/collapsablewidget.tcl.gz b/systems/mac/support/alpha/tcl/extensions/collapsablewidget.tcl.gz
new file mode 100644
index 0000000000..b8fb11b653
--- /dev/null
+++ b/systems/mac/support/alpha/tcl/extensions/collapsablewidget.tcl.gz
Binary files differ
diff --git a/systems/mac/support/alpha/tcl/extensions/plplot/Readme.txt b/systems/mac/support/alpha/tcl/extensions/plplot/Readme.txt
new file mode 100644
index 0000000000..52a9ddb9a7
--- /dev/null
+++ b/systems/mac/support/alpha/tcl/extensions/plplot/Readme.txt
@@ -0,0 +1,54 @@
+This directory contains 'TEA-complaint' configuration and makefiles
+to compile Plplot as a set of extensions to Tcl. 'TEA' stands for
+'Tcl Extension Architecture' and is the modern way to build extensions
+for Tcl so that they can be easily recompiled on any Tcl platform.
+
+On windows (using cygwin --- see www.scriptics.com for more
+instructions), the following sort of thing should suffice:
+
+(in the bash shell):
+
+% autoconf
+% ../configure --with-tcl=//d/tcl-source/tcl8.3.1/win/Release
+--with-tclinclude=//d/tcl-source/tcl8.3.1/generic
+--prefix=//d/progra~1/tcl
+
+% make
+% make install
+
+'with-tcl' is the location of tclConfig.sh (this requirement may be
+lifted in a future version of TEA).
+'with-tclinclude' is the location of tcl.h
+'prefix' is the install location
+
+You may also wish to add 'exec-prefix' for a platform specific
+installation location (otherwise prefix/bin will be used).
+
+For 'Pltk' you'll need to add --with-tk etc.
+
+----------------------
+
+State as of May 2000:
+
+I've now made three separate compilation directories 'tcltk',
+'pltcltk' and 'pltk'. These compile respectively a 'Matrix'
+extension, a 'Pltcl' extension, and a 'Pltk' extension. However each
+subsumes the previous items (e.g. Pltcl has the Matrix stuff embedded
+in it, rather than simply using the Matrix shared library).
+
+The first two compile and run on windows. The third one appears to
+manage all of the compilation except for xwin.c, so there is a good
+chance it will compile/run on Unix.
+
+You may need to edit your tkDevs.h to turn off devices which won't compile.
+
+To Do:
+
+Add targets for proper support of 'Matrix', 'Pltcl' and 'Pltk' as
+interdependent shared libraries.
+
+I suggest that 'Plplot' be a Tcl-only package, which, when requested,
+loads up Matrix, Pltcl and Pltk. The actual shared libraries should
+be platform specific variants of 'Matrix, Pltcl and Pltk' (i.e. with
+.so, .dll, version numbers, 'lib' prefix or whatever is defined by the
+TEA standard). But I'm open to suggestions on that.
diff --git a/systems/mac/support/alpha/tcl/extensions/plplotter.kit b/systems/mac/support/alpha/tcl/extensions/plplotter.kit
new file mode 100644
index 0000000000..85d63a08df
--- /dev/null
+++ b/systems/mac/support/alpha/tcl/extensions/plplotter.kit
Binary files differ
diff --git a/systems/mac/support/alpha/tcl/extensions/tktext.diff b/systems/mac/support/alpha/tcl/extensions/tktext.diff
new file mode 100644
index 0000000000..03ceaddbe3
--- /dev/null
+++ b/systems/mac/support/alpha/tcl/extensions/tktext.diff
@@ -0,0 +1,169 @@
+diff -r -C 3 -X tktext-ignore tk8.2/generic/tkText.c tk8.2orig/generic/tkText.c
+*** tk8.2/generic/tkText.c Tue Sep 14 18:32:43 1999
+--- tk8.2orig/generic/tkText.c Sun Sep 05 15:11:10 1999
+***************
+*** 40,49 ****
+ {TK_CONFIG_SYNONYM, "-bd", "borderWidth", (char *) NULL,
+ (char *) NULL, 0, 0},
+ {TK_CONFIG_SYNONYM, "-bg", "background", (char *) NULL,
+! (char *) NULL, 0, 0},
+! {TK_CONFIG_BOOLEAN, "-blockcursor", "blockCursor",
+! "BlockCursor", DEF_TEXT_BLOCK_CURSOR,
+! Tk_Offset(TkText, insertCursorType), 0},
+ {TK_CONFIG_PIXELS, "-borderwidth", "borderWidth", "BorderWidth",
+ DEF_TEXT_BORDER_WIDTH, Tk_Offset(TkText, borderWidth), 0},
+ {TK_CONFIG_ACTIVE_CURSOR, "-cursor", "cursor", "Cursor",
+--- 40,46 ----
+ {TK_CONFIG_SYNONYM, "-bd", "borderWidth", (char *) NULL,
+ (char *) NULL, 0, 0},
+ {TK_CONFIG_SYNONYM, "-bg", "background", (char *) NULL,
+! (char *) NULL, 0, 0},
+ {TK_CONFIG_PIXELS, "-borderwidth", "borderWidth", "BorderWidth",
+ DEF_TEXT_BORDER_WIDTH, Tk_Offset(TkText, borderWidth), 0},
+ {TK_CONFIG_ACTIVE_CURSOR, "-cursor", "cursor", "Cursor",
+***************
+*** 283,289 ****
+ textPtr->insertMarkPtr = NULL;
+ textPtr->insertBorder = NULL;
+ textPtr->insertWidth = 0;
+- textPtr->insertCursorType = 0;
+ textPtr->insertBorderWidth = 0;
+ textPtr->insertOnTime = 0;
+ textPtr->insertOffTime = 0;
+--- 280,285 ----
+***************
+*** 1519,1531 ****
+ }
+ TkTextMarkSegToIndex(textPtr, textPtr->insertMarkPtr, &index);
+ TkTextCharBbox(textPtr, &index, &x, &y, &w, &h);
+! if (textPtr->insertCursorType) {
+! TkTextRedrawRegion(textPtr, x - textPtr->width / 2, y,
+! w + textPtr->insertWidth / 2, h);
+! } else {
+! TkTextRedrawRegion(textPtr, x - textPtr->insertWidth / 2, y,
+! textPtr->insertWidth, h);
+! }
+ }
+
+ /*
+--- 1515,1522 ----
+ }
+ TkTextMarkSegToIndex(textPtr, textPtr->insertMarkPtr, &index);
+ TkTextCharBbox(textPtr, &index, &x, &y, &w, &h);
+! TkTextRedrawRegion(textPtr, x - textPtr->insertWidth / 2, y,
+! textPtr->insertWidth, h);
+ }
+
+ /*
+diff -r -C 3 -X tktext-ignore tk8.2/generic/tkText.h tk8.2orig/generic/tkText.h
+*** tk8.2/generic/tkText.h Tue Sep 14 18:13:21 1999
+--- tk8.2orig/generic/tkText.h Thu Jun 17 13:58:00 1999
+***************
+*** 575,582 ****
+ * in "on" state for each blink. */
+ int insertOffTime; /* Number of milliseconds cursor should spend
+ * in "off" state for each blink. */
+- int insertCursorType; /* Zero by default, which means to use a line-cursor.
+- * If one we use a block cursor. */
+ Tcl_TimerToken insertBlinkHandler;
+ /* Timer handler used to blink cursor on and
+ * off. */
+--- 575,580 ----
+diff -r -C 3 -X tktext-ignore tk8.2/generic/tkTextMark.c tk8.2orig/generic/tkTextMark.c
+*** tk8.2/generic/tkTextMark.c Tue Sep 14 18:43:14 1999
+--- tk8.2orig/generic/tkTextMark.c Thu Apr 15 19:51:24 1999
+***************
+*** 522,540 ****
+ * corresponds to y. */
+ {
+ TkText *textPtr = (TkText *) chunkPtr->clientData;
+! TkTextIndex index;
+! int rightSideWidth;
+! int ix = 0, iy = 0, iw = 0, ih = 0;
+
+! if(textPtr->insertCursorType) {
+! TkTextMarkSegToIndex(textPtr, textPtr->insertMarkPtr, &index);
+! TkTextCharBbox(textPtr, &index, &ix, &iy, &iw, &ih);
+! rightSideWidth = iw + textPtr->insertWidth/2;
+! } else {
+! rightSideWidth = textPtr->insertWidth/2;
+! }
+!
+! if ((x + rightSideWidth) < 0) {
+ /*
+ * The insertion cursor is off-screen. Just return.
+ */
+--- 522,530 ----
+ * corresponds to y. */
+ {
+ TkText *textPtr = (TkText *) chunkPtr->clientData;
+! int halfWidth = textPtr->insertWidth/2;
+
+! if ((x + halfWidth) < 0) {
+ /*
+ * The insertion cursor is off-screen. Just return.
+ */
+***************
+*** 552,562 ****
+
+ if (textPtr->flags & INSERT_ON) {
+ Tk_Fill3DRectangle(textPtr->tkwin, dst, textPtr->insertBorder,
+! x - textPtr->insertWidth/2, y, iw + textPtr->insertWidth,
+ height, textPtr->insertBorderWidth, TK_RELIEF_RAISED);
+ } else if (textPtr->selBorder == textPtr->insertBorder) {
+ Tk_Fill3DRectangle(textPtr->tkwin, dst, textPtr->border,
+! x - textPtr->insertWidth/2, y, iw + textPtr->insertWidth,
+ height, 0, TK_RELIEF_FLAT);
+ }
+ }
+--- 542,552 ----
+
+ if (textPtr->flags & INSERT_ON) {
+ Tk_Fill3DRectangle(textPtr->tkwin, dst, textPtr->insertBorder,
+! x - textPtr->insertWidth/2, y, textPtr->insertWidth,
+ height, textPtr->insertBorderWidth, TK_RELIEF_RAISED);
+ } else if (textPtr->selBorder == textPtr->insertBorder) {
+ Tk_Fill3DRectangle(textPtr->tkwin, dst, textPtr->border,
+! x - textPtr->insertWidth/2, y, textPtr->insertWidth,
+ height, 0, TK_RELIEF_FLAT);
+ }
+ }
+diff -r -C 3 -X tktext-ignore tk8.2/mac/tkMacDefault.h tk8.2orig/mac/tkMacDefault.h
+*** tk8.2/mac/tkMacDefault.h Tue Sep 14 18:36:57 1999
+--- tk8.2orig/mac/tkMacDefault.h Thu Apr 15 19:51:30 1999
+***************
+*** 409,415 ****
+
+ #define DEF_TEXT_BG_COLOR NORMAL_BG
+ #define DEF_TEXT_BG_MONO WHITE
+- #define DEF_TEXT_BLOCK_CURSOR "0"
+ #define DEF_TEXT_BORDER_WIDTH "0"
+ #define DEF_TEXT_CURSOR "xterm"
+ #define DEF_TEXT_FG BLACK
+--- 409,414 ----
+diff -r -C 3 -X tktext-ignore tk8.2/unix/tkUnixDefault.h tk8.2orig/unix/tkUnixDefault.h
+*** tk8.2/unix/tkUnixDefault.h Tue Sep 14 18:37:19 1999
+--- tk8.2orig/unix/tkUnixDefault.h Thu Apr 15 19:51:45 1999
+***************
+*** 398,404 ****
+
+ #define DEF_TEXT_BG_COLOR NORMAL_BG
+ #define DEF_TEXT_BG_MONO WHITE
+- #define DEF_TEXT_BLOCK_CURSOR "0"
+ #define DEF_TEXT_BORDER_WIDTH "2"
+ #define DEF_TEXT_CURSOR "xterm"
+ #define DEF_TEXT_FG BLACK
+--- 398,403 ----
+diff -r -C 3 -X tktext-ignore tk8.2/win/tkWinDefault.h tk8.2orig/win/tkWinDefault.h
+*** tk8.2/win/tkWinDefault.h Tue Sep 14 18:36:36 1999
+--- tk8.2orig/win/tkWinDefault.h Thu Apr 15 19:51:50 1999
+***************
+*** 404,410 ****
+
+ #define DEF_TEXT_BG_COLOR "SystemWindow"
+ #define DEF_TEXT_BG_MONO WHITE
+- #define DEF_TEXT_BLOCK_CURSOR "0"
+ #define DEF_TEXT_BORDER_WIDTH "2"
+ #define DEF_TEXT_CURSOR "xterm"
+ #define DEF_TEXT_FG TEXT_FG
+--- 404,409 ----
diff --git a/systems/mac/support/alpha/tcl/extensions/tktexttabs.patch b/systems/mac/support/alpha/tcl/extensions/tktexttabs.patch
new file mode 100644
index 0000000000..1fc1280d25
--- /dev/null
+++ b/systems/mac/support/alpha/tcl/extensions/tktexttabs.patch
@@ -0,0 +1,147 @@
+diff -c3 -r -X patchtext tk8.1orig/generic/tkText.c tk8.1/generic/tkText.c
+*** tk8.1orig/generic/tkText.c Wed Apr 21 15:53:28 1999
+--- tk8.1/generic/tkText.c Sat Jun 05 18:32:16 1999
+***************
+*** 48,53 ****
+--- 48,55 ----
+ {TK_CONFIG_BOOLEAN, "-exportselection", "exportSelection",
+ "ExportSelection", DEF_TEXT_EXPORT_SELECTION,
+ Tk_Offset(TkText, exportSelection), 0},
++ {TK_CONFIG_INT, "-fixedtabs", "fixedTabs", "FixedTabs",
++ "8", Tk_Offset(TkText, fixedTabOption), 0},
+ {TK_CONFIG_SYNONYM, "-fg", "foreground", (char *) NULL,
+ (char *) NULL, 0, 0},
+ {TK_CONFIG_FONT, "-font", "font", "Font",
+***************
+*** 260,265 ****
+--- 262,268 ----
+ textPtr->spacing1 = 0;
+ textPtr->spacing2 = 0;
+ textPtr->spacing3 = 0;
++ textPtr->fixedTabOption = 8;
+ textPtr->tabOptionString = NULL;
+ textPtr->tabArrayPtr = NULL;
+ textPtr->wrapMode = Tk_GetUid("char");
+***************
+*** 795,800 ****
+--- 798,806 ----
+ }
+ if (textPtr->spacing3 < 0) {
+ textPtr->spacing3 = 0;
++ }
++ if (textPtr->fixedTabOption <= 0) {
++ textPtr->fixedTabOption = 8;
+ }
+
+ /*
+diff -c3 -r -X patchtext tk8.1orig/generic/tkText.h tk8.1/generic/tkText.h
+*** tk8.1orig/generic/tkText.h Thu Apr 15 19:51:23 1999
+--- tk8.1/generic/tkText.h Sat Jun 05 18:27:56 1999
+***************
+*** 609,614 ****
+--- 609,617 ----
+ * vertical scrollbar when view changes. */
+ int flags; /* Miscellaneous flags; see below for
+ * definitions. */
++ int fixedTabOption; /* Used to set the number of char widths for tabs
++ * when the -tabs option is unset. */
++
+ } TkText;
+
+ /*
+diff -c3 -r -X patchtext tk8.1orig/generic/tkTextDisp.c tk8.1/generic/tkTextDisp.c
+*** tk8.1orig/generic/tkTextDisp.c Wed Apr 21 15:53:28 1999
+--- tk8.1/generic/tkTextDisp.c Sat Jun 05 18:33:02 1999
+***************
+*** 341,347 ****
+ TkTextIndex *srcPtr, int distance,
+ TkTextIndex *dstPtr));
+ static int NextTabStop _ANSI_ARGS_((Tk_Font tkfont, int x,
+! int tabOrigin));
+ static void UpdateDisplayInfo _ANSI_ARGS_((TkText *textPtr));
+ static void ScrollByLines _ANSI_ARGS_((TkText *textPtr,
+ int offset));
+--- 341,347 ----
+ TkTextIndex *srcPtr, int distance,
+ TkTextIndex *dstPtr));
+ static int NextTabStop _ANSI_ARGS_((Tk_Font tkfont, int x,
+! int tabOrigin, TkText *textPtr));
+ static void UpdateDisplayInfo _ANSI_ARGS_((TkText *textPtr));
+ static void ScrollByLines _ANSI_ARGS_((TkText *textPtr,
+ int offset));
+***************
+*** 4664,4670 ****
+ * interpretation of tabs.
+ */
+
+! desired = NextTabStop(textPtr->tkfont, x, 0);
+ goto update;
+ }
+
+--- 4664,4670 ----
+ * interpretation of tabs.
+ */
+
+! desired = NextTabStop(textPtr->tkfont, x, 0, textPtr);
+ goto update;
+ }
+
+***************
+*** 4822,4828 ****
+ TkTextTabAlign alignment;
+
+ if ((tabArrayPtr == NULL) || (tabArrayPtr->numTabs == 0)) {
+! tabX = NextTabStop(textPtr->tkfont, x, 0);
+ return tabX - x;
+ }
+ if (index < tabArrayPtr->numTabs) {
+--- 4822,4828 ----
+ TkTextTabAlign alignment;
+
+ if ((tabArrayPtr == NULL) || (tabArrayPtr->numTabs == 0)) {
+! tabX = NextTabStop(textPtr->tkfont, x, 0, textPtr);
+ return tabX - x;
+ }
+ if (index < tabArrayPtr->numTabs) {
+***************
+*** 4904,4910 ****
+ */
+
+ static int
+! NextTabStop(tkfont, x, tabOrigin)
+ Tk_Font tkfont; /* Font in which chunk that contains tab
+ * stop will be drawn. */
+ int x; /* X-position in pixels where last
+--- 4904,4910 ----
+ */
+
+ static int
+! NextTabStop(tkfont, x, tabOrigin, textPtr)
+ Tk_Font tkfont; /* Font in which chunk that contains tab
+ * stop will be drawn. */
+ int x; /* X-position in pixels where last
+***************
+*** 4912,4921 ****
+ * occurs somewhere after this location. */
+ int tabOrigin; /* The origin for tab stops. May be
+ * non-zero if text has been scrolled. */
+ {
+ int tabWidth, rem;
+
+! tabWidth = Tk_TextWidth(tkfont, "0", 1) * 8;
+ if (tabWidth == 0) {
+ tabWidth = 1;
+ }
+--- 4912,4923 ----
+ * occurs somewhere after this location. */
+ int tabOrigin; /* The origin for tab stops. May be
+ * non-zero if text has been scrolled. */
++ TkText *textPtr; /* Information about the text widget as
++ * a whole. */
+ {
+ int tabWidth, rem;
+
+! tabWidth = Tk_TextWidth(tkfont, "0", 1) * textPtr->fixedTabOption;
+ if (tabWidth == 0) {
+ tabWidth = 1;
+ }
diff --git a/systems/mac/support/alpha/tcl/extensions/trace.c b/systems/mac/support/alpha/tcl/extensions/trace.c
new file mode 100644
index 0000000000..f66c51a908
--- /dev/null
+++ b/systems/mac/support/alpha/tcl/extensions/trace.c
@@ -0,0 +1,282 @@
+/*
+ * trace.c --
+ *
+ * Copyright (c) 1999 Vince Darley
+ *
+ * This file is distributed under the same license as Tcl.
+ *
+ * See the file "license.terms" for information on usage and redistribution
+ * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
+ *
+ * Note: It would be relatively easy to take this code and use it
+ * to extend Tcl's current 'trace' command to perform both variable
+ * and command tracing. It would make a nice addition to the Tcl core.
+ *
+ * Notice that I didn't think it sensible to implement the idea of
+ * calling a Tcl proc with each traced command (as is done with
+ * variable traces). This seemed likely to (i) lead to nasty
+ * recursions which would have to be worked around, and (ii) be
+ * unnecessary, since the primary use of this code would seem to be
+ * debugging -- 'my proc foo doesn't do what I think it should, give me
+ * a dump of everything that's happening inside it'.
+ *
+ * Basic use is:
+ *
+ * # register trace
+ * tracecommand on foo
+ * # now call some code which uses 'foo'
+ * foo arg1 arg2 arg3
+ * # now see what happened inside foo
+ * tracecommand dump foo
+ * # now get rid of the trace and free associated memory
+ * tracecommand off foo
+ *
+ */
+
+#define TCL_USE_STUBS
+#include <tcl.h>
+
+/* For Tcl_GetCommandFromObj, Tcl_GetCommandFullName */
+#include <tclInt.h>
+#include <string.h>
+
+extern Tcl_ObjCmdProc Trace_ObjCmd;
+DLLEXPORT int Trace_Init(Tcl_Interp* interp);
+
+static Tcl_CmdTraceObjProc traceCmd;
+static Tcl_InterpDeleteProc traceCleanup;
+static void addIndentTruncate(Tcl_DString *ds, int indent, int truncate, Tcl_DString *add);
+
+typedef struct traceInfo {
+ Tcl_DString traceDetails;
+ Tcl_Trace tracePtr;
+ Tcl_Command cmdPtr;
+ int truncationLength;
+ int relativeDepth;
+ struct traceInfo* nextPtr;
+} traceInfo;
+
+typedef struct interpTraceInfo {
+ traceInfo* traces;
+} interpTraceInfo;
+
+int Trace_Init(Tcl_Interp* interp) {
+ interpTraceInfo* traceInfoPtr;
+ Tcl_InitStubs(interp,TCL_VERSION,0);
+
+ traceInfoPtr = (interpTraceInfo*) ckalloc(sizeof(interpTraceInfo));
+ traceInfoPtr->traces = NULL;
+
+ Tcl_CallWhenDeleted(interp, traceCleanup, (ClientData) traceInfoPtr);
+ Tcl_CreateObjCommand(interp, "tracecommand", Trace_ObjCmd,
+ (ClientData)traceInfoPtr, (Tcl_CmdDeleteProc*) NULL);
+ return TCL_OK;
+}
+
+int Trace_ObjCmd(clientData, interp, objc, objv)
+ ClientData clientData; /* Trace info */
+ Tcl_Interp *interp; /* Current interpreter. */
+ int objc; /* Number of arguments. */
+ Tcl_Obj *CONST objv[]; /* Argument objects. */
+{
+ int index;
+ int flags, min, max, truncate, relativeDepth, c;
+ traceInfo *loopPtr, *prevPtr;
+ interpTraceInfo *traceInfoPtr = (interpTraceInfo*)clientData;
+ Tcl_Command cmdPtr;
+
+ static char *optionStrings[] = {
+ "dump", "list", "off", "on", NULL
+ };
+ enum options {
+ TRACE_DUMP, TRACE_LIST, TRACE_OFF, TRACE_ON
+ };
+ if (objc < 2) {
+ Tcl_WrongNumArgs(interp, 1, objv, "option ?arg ...?");
+ return TCL_ERROR;
+ }
+ if (Tcl_GetIndexFromObj(interp, objv[1], optionStrings, "option", 0,
+ &index) != TCL_OK) {
+ return TCL_ERROR;
+ }
+ if ((enum options) index == TRACE_LIST) {
+ Tcl_Obj *resObj = Tcl_NewListObj(0,NULL);
+ for(loopPtr = traceInfoPtr->traces; loopPtr != NULL; loopPtr = loopPtr->nextPtr) {
+ Tcl_Obj *objPtr = Tcl_NewObj();
+ Tcl_GetCommandFullName(interp, loopPtr->cmdPtr, objPtr);
+ Tcl_ListObjAppendElement(interp,resObj,objPtr);
+ }
+ Tcl_SetObjResult(interp,resObj);
+ return TCL_OK;
+ }
+
+ if(objc < 3) {
+ Tcl_WrongNumArgs(interp, 2, objv, "command");
+ return TCL_ERROR;
+ }
+ cmdPtr = Tcl_GetCommandFromObj(interp, objv[2]);
+ if(cmdPtr == NULL) {
+ Tcl_AppendResult(interp, "Bad argument \"", Tcl_GetString(objv[2]),
+ "\": must be the name of an existing command or procedure",
+ (char *) NULL);
+ return TCL_ERROR;
+ }
+
+ switch ((enum options) index) {
+ case TRACE_DUMP:
+ for(loopPtr = traceInfoPtr->traces; loopPtr != NULL; loopPtr = loopPtr->nextPtr) {
+ if(loopPtr->cmdPtr == cmdPtr) {
+ Tcl_DStringResult(interp,&loopPtr->traceDetails);
+ return TCL_OK;
+ }
+ }
+ Tcl_AppendResult(interp, "There is no existing trace on \"", Tcl_GetString(objv[2]),
+ "\"", (char *) NULL);
+ return TCL_ERROR;
+ break;
+ case TRACE_ON:
+ flags = min = max = truncate = relativeDepth = 0;
+ c = 3;
+ while(c < objc) {
+ int len;
+ char* str = Tcl_GetStringFromObj(objv[c],&len);
+ if(str[0] == '-' && c != objc-1) {
+ if (len == 9 && !strncmp(str,"-minlevel",9)) {
+ if (Tcl_GetIntFromObj(interp,objv[c+1],&min) == TCL_ERROR) {
+ return TCL_ERROR;
+ }
+ c++;
+ } else if (len == 9 && !strncmp(str,"-maxlevel",9)) {
+ if (Tcl_GetIntFromObj(interp,objv[c+1],&max) == TCL_ERROR) {
+ return TCL_ERROR;
+ }
+ c++;
+ } else if (len == 9 && !strncmp(str,"-truncate",9)) {
+ if (Tcl_GetIntFromObj(interp,objv[c+1],&truncate) == TCL_ERROR) {
+ return TCL_ERROR;
+ }
+ c++;
+ } else if (len == 6 && !strncmp(str,"-depth",6)) {
+ if (Tcl_GetIntFromObj(interp,objv[c+1],&relativeDepth) == TCL_ERROR) {
+ return TCL_ERROR;
+ }
+ c++;
+ } else {
+ goto bad_args;
+ }
+ } else if (len == 6 && !strncmp(str,"before",6)) {
+ flags |= TCL_CMD_TRACE_BEFORE;
+ } else if (len == 5 && !strncmp(str,"after",5)) {
+ flags |= TCL_CMD_TRACE_AFTER;
+ } else {
+ bad_args:
+ Tcl_AppendResult(interp, "Bad argument \"", Tcl_GetString(objv[c]),
+ "\": should be before, after -minlevel n, -maxlevel n, -depth n or -truncate n",
+ (char *) NULL);
+ return TCL_ERROR;
+ }
+ c++;
+ }
+ loopPtr = (traceInfo*) ckalloc(sizeof(traceInfo));
+ loopPtr->cmdPtr = cmdPtr;
+ Tcl_DStringInit(&loopPtr->traceDetails);
+ loopPtr->tracePtr = Tcl_CreateTraceObj(interp,objv[2],flags,max,min,traceCmd,(ClientData)loopPtr);
+ loopPtr->truncationLength = truncate;
+ loopPtr->relativeDepth = relativeDepth;
+ loopPtr->nextPtr = traceInfoPtr->traces;
+ traceInfoPtr->traces = loopPtr;
+ break;
+ case TRACE_OFF:
+ prevPtr = NULL;
+ for(loopPtr = traceInfoPtr->traces; loopPtr != NULL; loopPtr = loopPtr->nextPtr) {
+ if(loopPtr->cmdPtr == cmdPtr) {
+ Tcl_DeleteTrace(interp,loopPtr->tracePtr);
+ Tcl_DStringFree(&loopPtr->traceDetails);
+ if(prevPtr != NULL) {
+ prevPtr->nextPtr = loopPtr->nextPtr;
+ } else {
+ traceInfoPtr->traces = NULL;
+ }
+ ckfree((char*)loopPtr);
+ return TCL_OK;
+ }
+ prevPtr = loopPtr;
+ }
+ Tcl_AppendResult(interp, "There is no existing trace on \"", Tcl_GetString(objv[2]),
+ "\"", (char *) NULL);
+ return TCL_ERROR;
+ break;
+ }
+ return TCL_OK;
+}
+
+void traceCleanup(ClientData clientData, Tcl_Interp *interp) {
+ traceInfo *loopPtr, *prevPtr;
+ interpTraceInfo *traceInfoPtr = (interpTraceInfo*)clientData;
+ for(loopPtr = traceInfoPtr->traces; loopPtr != NULL; loopPtr = loopPtr->nextPtr) {
+ Tcl_DStringFree(&loopPtr->traceDetails);
+ Tcl_DeleteTrace(interp,loopPtr->tracePtr);
+ prevPtr= loopPtr;
+ loopPtr = loopPtr->nextPtr;
+ ckfree((char*)prevPtr);
+ }
+ ckfree((char*)traceInfoPtr);
+}
+
+void traceCmd(ClientData clientData, Tcl_Interp *interp,
+ int level, int startLevel, int flags, int code,
+ char* command, int length, Tcl_Command cmdInfo,
+ int objc, struct Tcl_Obj *CONST objv[]) {
+ Tcl_DString ds;
+ traceInfo* traceInfoPtr = (traceInfo*)clientData;
+ /* Cut-off anything deeper than this */
+ if (traceInfoPtr->relativeDepth > 0 && (level-startLevel > traceInfoPtr->relativeDepth)) {
+ return;
+ }
+ if (flags & TCL_CMD_TRACE_BEFORE) {
+ Tcl_DStringInit(&ds);
+ Tcl_DStringAppend(&ds, "'", 1);
+ Tcl_DStringAppend(&ds, command, length);
+ Tcl_DStringAppend(&ds, "'", 1);
+ Tcl_DStringAppend(&ds, "\n", 1);
+ addIndentTruncate(&traceInfoPtr->traceDetails,level-startLevel,traceInfoPtr->truncationLength,&ds);
+ Tcl_DStringFree(&ds);
+ }
+ if (flags & TCL_CMD_TRACE_AFTER) {
+ int i;
+ Tcl_DStringInit(&ds);
+ for (i = 0; i < objc; i++) {
+ char* str;
+ int len;
+ str = Tcl_GetStringFromObj(objv[i],&len);
+ Tcl_DStringAppend(&ds, str, len);
+ Tcl_DStringAppend(&ds, " ", 1);
+ }
+ Tcl_DStringAppend(&ds, "\n", 1);
+ addIndentTruncate(&traceInfoPtr->traceDetails,level-startLevel,traceInfoPtr->truncationLength,&ds);
+ Tcl_DStringFree(&ds);
+ }
+ if (flags & TCL_CMD_TRACE_AFTER) {
+ Tcl_DStringInit(&ds);
+ Tcl_DStringAppend(&ds, code == TCL_ERROR ? "ERROR: " : "OK: ", -1);
+ Tcl_DStringAppend(&ds, Tcl_GetStringResult(interp), -1);
+ Tcl_DStringAppend(&ds, "\n", 1);
+ addIndentTruncate(&traceInfoPtr->traceDetails,level-startLevel,traceInfoPtr->truncationLength,&ds);
+ Tcl_DStringFree(&ds);
+ }
+}
+
+void addIndentTruncate(Tcl_DString *ds, int indent, int truncate, Tcl_DString *add) {
+ int i;
+ for (i = 1; i < indent; i++) {
+ Tcl_DStringAppend(ds, " ", 1);
+ }
+ if(truncate > 0 && (truncate - indent < Tcl_DStringLength(add))) {
+ Tcl_DStringAppend(ds, Tcl_DStringValue(add), truncate - indent);
+ Tcl_DStringAppend(ds,"...\n",4);
+ } else {
+ Tcl_DStringAppend(ds, Tcl_DStringValue(add), Tcl_DStringLength(add));
+ }
+}
+
+
diff --git a/systems/mac/support/alpha/tcl/extensions/trace.diff b/systems/mac/support/alpha/tcl/extensions/trace.diff
new file mode 100644
index 0000000000..679b12527e
--- /dev/null
+++ b/systems/mac/support/alpha/tcl/extensions/trace.diff
@@ -0,0 +1,594 @@
+diff -C 3 -r -X traceignore.txt tcl8.2/generic/tcl.decls tcl8.2orig/generic/tcl.decls
+*** tcl8.2/generic/tcl.decls Sat Sep 18 19:52:50 1999
+--- tcl8.2orig/generic/tcl.decls Wed Aug 18 20:59:08 1999
+***************
+*** 1343,1353 ****
+ declare 389 generic {
+ int Tcl_GetChannelNamesEx(Tcl_Interp *interp, char *pattern)
+ }
+! declare 390 generic {
+! Tcl_Trace Tcl_CreateTraceObj(Tcl_Interp* interp, Tcl_Obj* insideCmd, \
+! int traceFlags, int maxLevel, int minLevel, \
+! Tcl_CmdTraceObjProc *proc, ClientData clientData)
+! }
+
+
+ ##############################################################################
+--- 1343,1349 ----
+ declare 389 generic {
+ int Tcl_GetChannelNamesEx(Tcl_Interp *interp, char *pattern)
+ }
+!
+
+
+ ##############################################################################
+diff -C 3 -r -X traceignore.txt tcl8.2/generic/tcl.h tcl8.2orig/generic/tcl.h
+*** tcl8.2/generic/tcl.h Tue Sep 21 09:03:50 1999
+--- tcl8.2orig/generic/tcl.h Tue Aug 10 17:16:25 1999
+***************
+*** 503,512 ****
+ typedef void (Tcl_CmdTraceProc) _ANSI_ARGS_((ClientData clientData,
+ Tcl_Interp *interp, int level, char *command, Tcl_CmdProc *proc,
+ ClientData cmdClientData, int argc, char *argv[]));
+- typedef void (Tcl_CmdTraceObjProc) _ANSI_ARGS_((ClientData clientData,
+- Tcl_Interp *interp, int level, int startLevel, int flags, int code,
+- char* command, int length, Tcl_Command currentCmd,
+- int objc, struct Tcl_Obj *CONST objv[]));
+ typedef void (Tcl_DupInternalRepProc) _ANSI_ARGS_((struct Tcl_Obj *srcPtr,
+ struct Tcl_Obj *dupPtr));
+ typedef int (Tcl_EncodingConvertProc)_ANSI_ARGS_((ClientData clientData,
+--- 503,508 ----
+***************
+*** 867,878 ****
+ #define TCL_INTERP_DESTROYED 0x100
+ #define TCL_LEAVE_ERR_MSG 0x200
+ #define TCL_TRACE_ARRAY 0x800
+-
+- /*
+- * Flag values passed to Tcl_CreateTraceObj
+- */
+- #define TCL_CMD_TRACE_BEFORE 1
+- #define TCL_CMD_TRACE_AFTER 2
+
+ /*
+ * The TCL_PARSE_PART1 flag is deprecated and has no effect.
+--- 863,868 ----
+diff -C 3 -r -X traceignore.txt tcl8.2/generic/tclBasic.c tcl8.2orig/generic/tclBasic.c
+*** tcl8.2/generic/tclBasic.c Tue Sep 21 12:28:02 1999
+--- tcl8.2orig/generic/tclBasic.c Fri May 14 17:16:54 1999
+***************
+*** 3837,3964 ****
+ tracePtr = (Trace *) ckalloc(sizeof(Trace));
+ tracePtr->level = level;
+ tracePtr->proc = proc;
+- tracePtr->traceFlags = 0;
+ tracePtr->clientData = clientData;
+- tracePtr->nextPtr = iPtr->tracePtr;
+- iPtr->tracePtr = tracePtr;
+-
+- return (Tcl_Trace) tracePtr;
+- }
+-
+- /*
+- *----------------------------------------------------------------------
+- *
+- * Tcl_CreateTraceObj --
+- *
+- * Arrange for a procedure to be called to trace command execution.
+- *
+- * Results:
+- * The return value is a token for the trace, which may be passed
+- * to Tcl_DeleteTrace to eliminate the trace.
+- *
+- * Side effects:
+- * From now on, proc will be called just before a command procedure
+- * is called to execute a Tcl command, provided certain conditions
+- * are met. These conditions may include: current execution
+- * level is at least 'minLevel'; current execution level is at
+- * most 'maxLevel'; execution is currently inside the command/proc
+- * 'insideCmd'. For any given occasion on which those conditions
+- * are met, there are two times at which this procedure may
+- * be called: before the command is executed, and after the
+- * command is executed. Depending on the value to 'traceFlags'
+- * the procedure will be called in one or both of those situations.
+- *
+- * Calls to proc will have the following form:
+- *
+- * void
+- * proc(clientData, interp, level, startLevel, flags, code,
+- * command, length, currentCmd, objc, objv)
+- * ClientData clientData;
+- * Tcl_Interp *interp;
+- * int level;
+- * int startLevel;
+- * int flags;
+- * int code;
+- * char *command;
+- * int length;
+- * Tcl_Command currentCmd;
+- * int objc;
+- * struct Tcl_Obj *CONST objv[];
+- * {
+- * }
+- *
+- * The clientData, interp and flags arguments to proc will be the
+- * same as the corresponding arguments to this procedure. Level
+- * gives the nesting level of command interpretation for this
+- * interpreter (0 corresponds to top level). StartLevel gives the
+- * level at which the first command trace was triggered (so
+- * Level-StartLevel gives a relative level). The first 'length'
+- * characters of Command gives the ASCII text of the raw command,
+- * and currentCmd is the Tcl_Command structure referring to the
+- * current command. will receive, and objc and objv give the
+- * arguments to the command, after any argument parsing and
+- * substitution. Proc does not return a value.
+- *
+- *----------------------------------------------------------------------
+- */
+-
+- Tcl_Trace
+- Tcl_CreateTraceObj(interp, insideCmd, traceFlags, maxLevel, minLevel,
+- proc, clientData)
+- Tcl_Interp *interp; /* Interpreter in which to create trace. */
+- Tcl_Obj* insideCmd; /* Only activate this trace when execution
+- * is inside a call to this command, and
+- * after it is inside, later deactivate the
+- * trace when execution of this command is
+- * complete. */
+- int traceFlags; /* Or'd combination of TCL_CMD_TRACE_ flags,
+- * to indicate whether to call the given
+- * procedure before command execution,
+- * or after command execution (with the
+- * result of the command execution). If
+- * zero, then equivalent to the default
+- * of tracing before and after. */
+- int maxLevel; /* Only call proc for commands at nesting
+- * level<=argument level (1=>top level).
+- * If zero, then ignore minimum level. */
+- int minLevel; /* Only call proc for commands at nesting
+- * level>=argument level (1=>top level).
+- * If zero then ignore maximum level. */
+- Tcl_CmdTraceObjProc *proc; /* Procedure to call before executing each
+- * command. */
+- ClientData clientData; /* Arbitrary value word to pass to proc. */
+- {
+- register Trace *tracePtr;
+- register Interp *iPtr = (Interp *) interp;
+-
+- /*
+- * Invalidate existing compiled code for this interpreter and arrange
+- * (by setting the DONT_COMPILE_CMDS_INLINE flag) that when compiling
+- * new code, no commands will be compiled inline (i.e., into an inline
+- * sequence of instructions). We do this because commands that were
+- * compiled inline will never result in a command trace being called.
+- */
+-
+- iPtr->compileEpoch++;
+- iPtr->flags |= DONT_COMPILE_CMDS_INLINE;
+-
+- tracePtr = (Trace *) ckalloc(sizeof(Trace));
+- tracePtr->level = minLevel;
+- tracePtr->objProc = proc;
+- if((traceFlags & 3) == 0) {
+- tracePtr->traceFlags = TCL_CMD_TRACE_BEFORE | TCL_CMD_TRACE_AFTER;
+- } else {
+- tracePtr->traceFlags = traceFlags & 3;
+- }
+- tracePtr->clientData = clientData;
+- tracePtr->minLevel = minLevel;
+- tracePtr->cmdPtr = NULL;
+- if(insideCmd != NULL) {
+- tracePtr->cmdPtr = Tcl_FindCommand(interp,
+- Tcl_GetString(insideCmd), (Tcl_Namespace *) NULL, /*flags*/ 0);
+- }
+- tracePtr->tracingCmdDepth = 0;
+- tracePtr->tracingInitialDepth = 0;
+ tracePtr->nextPtr = iPtr->tracePtr;
+ iPtr->tracePtr = tracePtr;
+
+--- 3837,3843 ----
+diff -C 3 -r -X traceignore.txt tcl8.2/generic/tclExecute.c tcl8.2orig/generic/tclExecute.c
+*** tcl8.2/generic/tclExecute.c Wed Sep 22 18:55:43 1999
+--- tcl8.2orig/generic/tclExecute.c Wed Jun 16 15:56:33 1999
+***************
+*** 208,214 ****
+ static void CallTraceProcedure _ANSI_ARGS_((Tcl_Interp *interp,
+ Trace *tracePtr, Command *cmdPtr,
+ char *command, int numChars,
+! int objc, Tcl_Obj *CONST objv[]));
+ static void DupCmdNameInternalRep _ANSI_ARGS_((Tcl_Obj *objPtr,
+ Tcl_Obj *copyPtr));
+ static int ExprAbsFunc _ANSI_ARGS_((Tcl_Interp *interp,
+--- 208,214 ----
+ static void CallTraceProcedure _ANSI_ARGS_((Tcl_Interp *interp,
+ Trace *tracePtr, Command *cmdPtr,
+ char *command, int numChars,
+! int objc, Tcl_Obj *objv[]));
+ static void DupCmdNameInternalRep _ANSI_ARGS_((Tcl_Obj *objPtr,
+ Tcl_Obj *copyPtr));
+ static int ExprAbsFunc _ANSI_ARGS_((Tcl_Interp *interp,
+***************
+*** 726,737 ****
+
+ doInvocation:
+ {
+! int objc = opnd; /* The number of arguments. */
+! Tcl_Obj **objv; /* The array of argument objects. */
+! Command *cmdPtr; /* Points to command's Command struct. */
+! int newPcOffset; /* New inst offset for break, continue. */
+! char *command; /* String starting with actual command */
+! int numChars; /* Number of chars of command to use */
+ #ifdef TCL_COMPILE_DEBUG
+ int isUnknownCmd = 0;
+ char cmdNameBuf[21];
+--- 726,735 ----
+
+ doInvocation:
+ {
+! int objc = opnd; /* The number of arguments. */
+! Tcl_Obj **objv; /* The array of argument objects. */
+! Command *cmdPtr; /* Points to command's Command struct. */
+! int newPcOffset; /* New inst offset for break, continue. */
+ #ifdef TCL_COMPILE_DEBUG
+ int isUnknownCmd = 0;
+ char cmdNameBuf[21];
+***************
+*** 789,799 ****
+ */
+
+ if (iPtr->tracePtr != NULL) {
+! command = GetSrcInfoForPc(pc, codePtr, &numChars);
+! DECACHE_STACK_INFO();
+! TclCheckTraces(interp,command,numChars,cmdPtr,TCL_OK,
+! TCL_CMD_TRACE_BEFORE,objc,objv);
+! CACHE_STACK_INFO();
+ }
+
+ /*
+--- 787,809 ----
+ */
+
+ if (iPtr->tracePtr != NULL) {
+! Trace *tracePtr, *nextTracePtr;
+!
+! for (tracePtr = iPtr->tracePtr; tracePtr != NULL;
+! tracePtr = nextTracePtr) {
+! nextTracePtr = tracePtr->nextPtr;
+! if (iPtr->numLevels <= tracePtr->level) {
+! int numChars;
+! char *cmd = GetSrcInfoForPc(pc, codePtr,
+! &numChars);
+! if (cmd != NULL) {
+! DECACHE_STACK_INFO();
+! CallTraceProcedure(interp, tracePtr, cmdPtr,
+! cmd, numChars, objc, objv);
+! CACHE_STACK_INFO();
+! }
+! }
+! }
+ }
+
+ /*
+***************
+*** 849,861 ****
+ (void) Tcl_GetObjResult(interp);
+ }
+
+- if (iPtr->tracePtr != NULL) {
+- DECACHE_STACK_INFO();
+- TclCheckTraces(interp,command,numChars,cmdPtr,result,
+- TCL_CMD_TRACE_AFTER,objc,objv);
+- CACHE_STACK_INFO();
+- }
+-
+ /*
+ * Pop the objc top stack elements and decrement their ref
+ * counts.
+--- 859,864 ----
+***************
+*** 3083,3185 ****
+ /*
+ *----------------------------------------------------------------------
+ *
+- * TclCheckTraces --
+- *
+- * Checks on all current traces, and invokes procedures which
+- * have been registered. This procedure can be used by other
+- * code which performs execution to unify the tracing system.
+- * For instance extensions like [incr Tcl] which use their
+- * own execution technique can make use of Tcl's tracing.
+- *
+- * This procedure is used by 'EvalObjv' and 'TclExecuteByteCode'
+- *
+- * Results:
+- * None.
+- *
+- * Side effects:
+- * Those side effects made by any trace procedures called.
+- *
+- *----------------------------------------------------------------------
+- */
+- void
+- TclCheckTraces(interp, command, numChars, cmdPtr, result, traceFlags, objc, objv)
+- Tcl_Interp *interp; /* The current interpreter. */
+- char *command; /* Pointer to beginning of the current
+- * command string. */
+- int numChars; /* The number of characters in 'command'
+- * which are part of the command string. */
+- Command *cmdPtr; /* Points to command's Command struct. */
+- int result; /* The current result code. */
+- int traceFlags; /* Current tracing situation. */
+- int objc; /* Number of arguments for the command. */
+- Tcl_Obj *CONST objv[]; /* Pointers to Tcl_Obj of each argument. */
+- {
+- Interp *iPtr = (Interp *) interp;
+- Trace *tracePtr;
+-
+- if (command == NULL) {
+- return;
+- }
+-
+- for (tracePtr = iPtr->tracePtr;tracePtr != NULL;tracePtr = tracePtr->nextPtr) {
+- if (tracePtr->level != 0 && iPtr->numLevels > tracePtr->level) {
+- continue;
+- }
+- if (tracePtr->traceFlags != 0) {
+- /* The trace was created with Tcl_CreateTraceObj */
+- if (iPtr->numLevels < tracePtr->minLevel) {
+- continue;
+- }
+-
+- if (traceFlags & TCL_CMD_TRACE_BEFORE) {
+- if (tracePtr->cmdPtr != NULL) {
+- if (tracePtr->tracingCmdDepth == 0) {
+- if (cmdPtr == (Command*)tracePtr->cmdPtr) {
+- tracePtr->tracingInitialDepth = iPtr->numLevels;
+- } else {
+- continue;
+- }
+- }
+- /* If we reach here, we are inside the command
+- * we wish to trace. */
+- tracePtr->tracingCmdDepth++;
+- }
+- if (tracePtr->traceFlags & TCL_CMD_TRACE_BEFORE) {
+- (*tracePtr->objProc)(tracePtr->clientData, interp,
+- iPtr->numLevels, tracePtr->tracingInitialDepth,
+- TCL_CMD_TRACE_BEFORE, 0,
+- command, numChars, (Tcl_Command)cmdPtr,
+- objc, objv);
+- }
+- } else {
+- if (tracePtr->cmdPtr != NULL) {
+- if (tracePtr->tracingCmdDepth == 0) {
+- continue;
+- }
+- /* If we reach here, we are inside the command
+- * we wish to trace. */
+- tracePtr->tracingCmdDepth--;
+- }
+- if (tracePtr->traceFlags & TCL_CMD_TRACE_AFTER) {
+- (*tracePtr->objProc)(tracePtr->clientData, interp,
+- iPtr->numLevels, tracePtr->tracingInitialDepth,
+- tracePtr->traceFlags & TCL_CMD_TRACE_AFTER,
+- result, command, numChars, (Tcl_Command)cmdPtr,
+- objc, objv);
+- }
+- }
+- } else {
+- /* The trace was created with Tcl_CreateTrace */
+- CallTraceProcedure(interp, tracePtr, cmdPtr,
+- command, numChars, objc, objv);
+- }
+- }
+- }
+-
+-
+- /*
+- *----------------------------------------------------------------------
+- *
+ * CallTraceProcedure --
+ *
+ * Invokes a trace procedure registered with an interpreter. These
+--- 3086,3091 ----
+***************
+*** 3206,3212 ****
+ int numChars; /* The number of characters in the
+ * command's source. */
+ register int objc; /* Number of arguments for the command. */
+! Tcl_Obj *CONST objv[]; /* Pointers to Tcl_Obj of each argument. */
+ {
+ Interp *iPtr = (Interp *) interp;
+ register char **argv;
+--- 3112,3118 ----
+ int numChars; /* The number of characters in the
+ * command's source. */
+ register int objc; /* Number of arguments for the command. */
+! Tcl_Obj *objv[]; /* Pointers to Tcl_Obj of each argument. */
+ {
+ Interp *iPtr = (Interp *) interp;
+ register char **argv;
+diff -C 3 -r -X traceignore.txt tcl8.2/generic/tclInt.decls tcl8.2orig/generic/tclInt.decls
+*** tcl8.2/generic/tclInt.decls Wed Sep 22 18:49:37 1999
+--- tcl8.2orig/generic/tclInt.decls Mon Aug 09 20:42:14 1999
+***************
+*** 543,548 ****
+--- 543,549 ----
+ declare 145 generic {
+ struct AuxDataType *TclGetAuxDataType(char *typeName)
+ }
++
+ declare 146 generic {
+ TclHandle TclHandleCreate(VOID *ptr)
+ }
+***************
+*** 590,606 ****
+ }
+ declare 157 generic {
+ Var * TclVarTraceExists (Tcl_Interp *interp, char *varName)
+- }
+-
+- declare 159 generic {
+- void TclCheckTraces (Tcl_Interp *interp, char *command, int numChars, \
+- Command *cmdPtr, int result, int traceFlags, int objc, \
+- Tcl_Obj *CONST objv[])
+ }
+
+ ##############################################################################
+--- 591,596 ----
+diff -C 3 -r -X traceignore.txt tcl8.2/generic/tclInt.h tcl8.2orig/generic/tclInt.h
+*** tcl8.2/generic/tclInt.h Sun Sep 19 03:13:53 1999
+--- tcl8.2orig/generic/tclInt.h Mon Aug 02 11:45:37 1999
+***************
+*** 612,637 ****
+ */
+
+ typedef struct Trace {
+! int level; /* Only trace commands at nesting level
+! * less than or equal to this. */
+! union {
+! Tcl_CmdTraceProc *proc; /* Procedure to call to trace command. */
+! Tcl_CmdTraceObjProc *objProc; /* Procedure to call to trace command. */
+! };
+! ClientData clientData; /* Arbitrary value to pass to proc. */
+! struct Trace *nextPtr; /* Next in list of traces for this
+! * interp. */
+! int traceFlags; /* If zero, then this is an old trace
+! * strcture, and the following fields are
+! * ignored. Otherwise it is an or'd
+! * combination of TCL_CMD_TRACE_ flags.
+! * Old trace structures use the 'proc'
+! * above, new ones use 'objProc'. */
+! int minLevel; /* Only trace commands at nesting level
+! * greater than or equal to this. */
+! Tcl_Command cmdPtr; /* Only trace inside this command */
+! int tracingCmdDepth; /* Used to keep track of depth. */
+! int tracingInitialDepth; /* Used to keep track of depth. */
+ } Trace;
+
+ /*
+--- 612,622 ----
+ */
+
+ typedef struct Trace {
+! int level; /* Only trace commands at nesting level
+! * less than or equal to this. */
+! Tcl_CmdTraceProc *proc; /* Procedure to call to trace command. */
+! ClientData clientData; /* Arbitrary value to pass to proc. */
+! struct Trace *nextPtr; /* Next in list of traces for this interp. */
+ } Trace;
+
+ /*
+***************
+*** 1495,1518 ****
+
+ typedef struct TclpTime_t_ *TclpTime_t;
+
+ /*
+ *----------------------------------------------------------------
+ * Variables shared among Tcl modules but not used by the outside world.
+diff -C 3 -r -X traceignore.txt tcl8.2/generic/tclParse.c tcl8.2orig/generic/tclParse.c
+*** tcl8.2/generic/tclParse.c Wed Sep 22 18:51:37 1999
+--- tcl8.2orig/generic/tclParse.c Thu Aug 12 17:14:42 1999
+***************
+*** 799,804 ****
+--- 799,806 ----
+ Interp *iPtr = (Interp *) interp;
+ Tcl_Obj **newObjv;
+ int i, code;
++ Trace *tracePtr, *nextPtr;
++ char **argv, *commandCopy;
+ CallFrame *savedVarFramePtr; /* Saves old copy of iPtr->varFramePtr
+ * in case TCL_EVAL_GLOBAL was set. */
+
+***************
+*** 878,886 ****
+ * Call trace procedures if needed.
+ */
+
+! if (iPtr->tracePtr != NULL) {
+! TclCheckTraces(interp, command, length, cmdPtr, TCL_OK,
+! TCL_CMD_TRACE_BEFORE, objc, objv);
+ }
+
+ /*
+--- 880,923 ----
+ * Call trace procedures if needed.
+ */
+
+! argv = NULL;
+! commandCopy = command;
+!
+! for (tracePtr = iPtr->tracePtr; tracePtr != NULL; tracePtr = nextPtr) {
+! nextPtr = tracePtr->nextPtr;
+! if (iPtr->numLevels > tracePtr->level) {
+! continue;
+! }
+!
+! /*
+! * This is a bit messy because we have to emulate the old trace
+! * interface, which uses strings for everything.
+! */
+!
+! if (argv == NULL) {
+! argv = (char **) ckalloc((unsigned) (objc + 1) * sizeof(char *));
+! for (i = 0; i < objc; i++) {
+! argv[i] = Tcl_GetString(objv[i]);
+! }
+! argv[objc] = 0;
+!
+! if (length < 0) {
+! length = strlen(command);
+! } else if ((size_t)length < strlen(command)) {
+! commandCopy = (char *) ckalloc((unsigned) (length + 1));
+! strncpy(commandCopy, command, (size_t) length);
+! commandCopy[length] = 0;
+! }
+! }
+! (*tracePtr->proc)(tracePtr->clientData, interp, iPtr->numLevels,
+! commandCopy, cmdPtr->proc, cmdPtr->clientData,
+! objc, argv);
+! }
+! if (argv != NULL) {
+! ckfree((char *) argv);
+! }
+! if (commandCopy != command) {
+! ckfree((char *) commandCopy);
+ }
+
+ /*
+***************
+*** 909,919 ****
+ (void) Tcl_GetObjResult(interp);
+ }
+
+- if (iPtr->tracePtr != NULL) {
+- TclCheckTraces(interp,command, length, cmdPtr, code,
+- TCL_CMD_TRACE_AFTER, objc, objv);
+- }
+-
+ done:
+ iPtr->numLevels--;
+ return code;
+--- 946,951 ----
+***************
+*** 962,972 ****
+ /*
+ * EvalObjv will increment numLevels so use "<" rather than "<="
+ */
+! if ((tracePtr->level == 0 || (iPtr->numLevels < tracePtr->level))
+! && !(tracePtr->traceFlags != 0
+! && (iPtr->numLevels < (tracePtr->minLevel - 1)))) {
+! /* It's either an old-style trace, or a new-style trace
+! * whose level is acceptable. */
+ int i;
+ /*
+ * The command will be needed for an execution trace or stack trace
+--- 994,1000 ----
+ /*
+ * EvalObjv will increment numLevels so use "<" rather than "<="
+ */
+! if (iPtr->numLevels < tracePtr->level) {
+ int i;
+ /*
+ * The command will be needed for an execution trace or stack trace