diff options
Diffstat (limited to 'tools')
-rwxr-xr-x | tools/fix_tommath_h.tcl | 103 | ||||
-rw-r--r-- | tools/genStubs.tcl | 14 | ||||
-rw-r--r-- | tools/man2help2.tcl | 2 | ||||
-rw-r--r-- | tools/man2html2.tcl | 22 | ||||
-rw-r--r-- | tools/regexpTestLib.tcl | 6 | ||||
-rw-r--r-- | tools/str2c | 2 | ||||
-rw-r--r-- | tools/tclOOScript.tcl | 456 | ||||
-rw-r--r-- | tools/tcltk-man2html-utils.tcl | 8 | ||||
-rwxr-xr-x | tools/tcltk-man2html.tcl | 87 |
9 files changed, 552 insertions, 148 deletions
diff --git a/tools/fix_tommath_h.tcl b/tools/fix_tommath_h.tcl deleted file mode 100755 index cee29fa..0000000 --- a/tools/fix_tommath_h.tcl +++ /dev/null @@ -1,103 +0,0 @@ -# fixtommath.tcl -- -# -# Changes to 'tommath.h' to make it conform with Tcl's linking -# conventions. -# -# Copyright (c) 2005 by Kevin B. Kenny. All rights reserved. -# -# See the file "license.terms" for information on usage and redistribution -# of this file, and for a DISCLAIMER OF ALL WARRANTIES. -#---------------------------------------------------------------------- - -set f [open [lindex $argv 0] r] -set data [read $f] -close $f - -set eat_endif 0 -set eat_semi 0 -set def_count 0 -foreach line [split $data \n] { - if {!$eat_semi && !$eat_endif} { - switch -regexp -- $line { - {#define BN_H_} { - puts $line - puts {} - puts "\#include \"tclTomMathDecls.h\"" - puts "\#ifndef MODULE_SCOPE" - puts "\#define MODULE_SCOPE extern" - puts "\#endif" - } - {typedef\s+unsigned long\s+mp_digit;} { - # change the second 'typedef unsigned long mp - incr def_count - puts "\#ifndef MP_DIGIT_DECLARED" - if {$def_count == 2} { - puts [string map {long int} $line] - } else { - puts $line - } - puts "\#define MP_DIGIT_DECLARED" - puts "\#endif" - } - {typedef.*mp_digit;} { - puts "\#ifndef MP_DIGIT_DECLARED" - puts $line - puts "\#define MP_DIGIT_DECLARED" - puts "\#endif" - } - {typedef.*mp_word;} { - puts "\#ifndef MP_WORD_DECLARED" - puts $line - puts "\#define MP_WORD_DECLARED" - puts "\#endif" - } - {typedef struct} { - puts "\#ifndef MP_INT_DECLARED" - puts "\#define MP_INT_DECLARED" - puts "typedef struct mp_int mp_int;" - puts "\#endif" - puts "struct mp_int \{" - } - \}\ mp_int\; { - puts "\};" - } - {^(char|int|void)} { - puts "/*" - puts $line - set eat_semi 1 - set after_semi "*/" - } - {^extern (int|const)} { - puts "\#if defined(BUILD_tcl) || !defined(_WIN32)" - puts [regsub {^extern} $line "MODULE_SCOPE"] - set eat_semi 1 - set after_semi "\#endif" - } - {define heap macros} { - puts $line - puts "\#if 0 /* these are macros in tclTomMathDecls.h */" - set eat_endif 1 - } - {#include} { - # remove all includes - } - default { - puts $line - } - } - } else { - puts $line - } - if {$eat_semi} { - if {[regexp {; *$} $line]} { - puts $after_semi - set eat_semi 0 - } - } - if {$eat_endif} { - if {[regexp {^\#endif} $line]} { - puts "\#endif" - set eat_endif 0 - } - } -} diff --git a/tools/genStubs.tcl b/tools/genStubs.tcl index f2f410f..7c9ee03 100644 --- a/tools/genStubs.tcl +++ b/tools/genStubs.tcl @@ -479,6 +479,8 @@ proc genStubs::makeDecl {name decl index} { if {[info exists stubs($name,deprecated,$index)]} { append text "[string toupper $libraryName]_DEPRECATED(\"$stubs($name,deprecated,$index)\")\n" set line "$rtype" + } elseif {[string range $rtype end-5 end] eq "MP_WUR"} { + set line "$scspec [string trim [string range $rtype 0 end-6]]" } else { set line "$scspec $rtype" } @@ -523,7 +525,7 @@ proc genStubs::makeDecl {name decl index} { } append line ", ...)" if {[lindex $args end] eq "{const char *} format"} { - append line " TCL_FORMAT_PRINTF(" [expr [llength $args] - 1] ", " [llength $args] ")" + append line " TCL_FORMAT_PRINTF(" [expr {[llength $args] - 1}] ", " [llength $args] ")" } } default { @@ -548,6 +550,9 @@ proc genStubs::makeDecl {name decl index} { append line ")" } } + if {[string range $rtype end-5 end] eq "MP_WUR"} { + append line " MP_WUR" + } return "$text$line;\n" } @@ -611,6 +616,8 @@ proc genStubs::makeSlot {name decl index} { append text [string trim [string range $rtype 0 end-9]] " (__stdcall *" $lfname ") " } elseif {[string range $rtype 0 11] eq "TCL_NORETURN"} { append text "TCL_NORETURN1 " [string trim [string range $rtype 12 end]] " (*" $lfname ") " + } elseif {[string range $rtype end-5 end] eq "MP_WUR"} { + append text [string trim [string range $rtype 0 end-6]] " (*" $lfname ") " } else { append text $rtype " (*" $lfname ") " } @@ -631,7 +638,7 @@ proc genStubs::makeSlot {name decl index} { } append text ", ...)" if {[lindex $args end] eq "{const char *} format"} { - append text " TCL_FORMAT_PRINTF(" [expr [llength $args] - 1] ", " [llength $args] ")" + append text " TCL_FORMAT_PRINTF(" [expr {[llength $args] - 1}] ", " [llength $args] ")" } } default { @@ -648,6 +655,9 @@ proc genStubs::makeSlot {name decl index} { } } + if {[string range $rtype end-5 end] eq "MP_WUR"} { + append text " MP_WUR" + } append text "; /* $index */\n" return $text } diff --git a/tools/man2help2.tcl b/tools/man2help2.tcl index 9c8f503..4f3b7e5 100644 --- a/tools/man2help2.tcl +++ b/tools/man2help2.tcl @@ -827,7 +827,7 @@ proc IPmacro {argList} { set text "\u00b7" } - set tab [expr $indent * 0.1]i + set tab [expr {$indent * 0.1}]i newPara $tab -$tab set state(sb) 80 setTabs $tab diff --git a/tools/man2html2.tcl b/tools/man2html2.tcl index e4ccedf..8483204 100644 --- a/tools/man2html2.tcl +++ b/tools/man2html2.tcl @@ -114,9 +114,9 @@ proc text string { set pos [string first "\t" $string] if {$pos >= 0} { - text [string range $string 0 [expr $pos-1]] + text [string range $string 0 [expr {$pos-1}]] tab - text [string range $string [expr $pos+1] end] + text [string range $string [expr {$pos+1}] end] return } if {$inTable} { @@ -471,27 +471,27 @@ proc formattedText text { text $text return } - text [string range $text 0 [expr $index-1]] - set c [string index $text [expr $index+1]] + text [string range $text 0 [expr {$index-1}]] + set c [string index $text [expr {$index+1}]] switch -- $c { f { - font [string index $text [expr $index+2]] - set text [string range $text [expr $index+3] end] + font [string index $text [expr {$index+2}]] + set text [string range $text [expr {$index+3}] end] } e { text \\ - set text [string range $text [expr $index+2] end] + set text [string range $text [expr {$index+2}] end] } - { dash - set text [string range $text [expr $index+2] end] + set text [string range $text [expr {$index+2}] end] } | { - set text [string range $text [expr $index+2] end] + set text [string range $text [expr {$index+2}] end] } default { puts stderr "Unknown sequence: \\$c" - set text [string range $text [expr $index+2] end] + set text [string range $text [expr {$index+2}] end] } } } @@ -527,7 +527,7 @@ proc tab {} { global inPRE charCnt tabString file # ? charCnt if {$inPRE == 1} { - set pos [expr $charCnt % [string length $tabString] ] + set pos [expr {$charCnt % [string length $tabString]}] set spaces [string first "1" [string range $tabString $pos end] ] text [format "%*s" [incr spaces] " "] } else { diff --git a/tools/regexpTestLib.tcl b/tools/regexpTestLib.tcl index d84a012..8379159 100644 --- a/tools/regexpTestLib.tcl +++ b/tools/regexpTestLib.tcl @@ -17,13 +17,13 @@ proc readInputFile {} { set len [string length $line] - if {($len > 0) && ([string index $line [expr $len - 1]] == "\\")} { + if {($len > 0) && ([string index $line [expr {$len - 1}]] == "\\")} { if {[info exists lineArray(c$i)] == 0} { set lineArray(c$i) 1 } else { incr lineArray(c$i) } - set line [string range $line 0 [expr $len - 2]] + set line [string range $line 0 [expr {$len - 2}]] append lineArray($i) $line continue } @@ -204,7 +204,7 @@ proc convertTestLine {currentLine len lineNum srcLineNum} { # find the test result - set numVars [expr $len - 3] + set numVars [expr {$len - 3}] set vars {} set vals {} set result 0 diff --git a/tools/str2c b/tools/str2c index cff7ba2..588abdf 100644 --- a/tools/str2c +++ b/tools/str2c @@ -39,7 +39,7 @@ static char data\[\]=\"[translate $r]\";" static const char * const data\[\]= {" set n 1 for {set i 0} {$i<$lg} {incr i $MAX} { - set part [string range $r $i [expr $i+$MAX-1]] + set part [string range $r $i [expr {$i+$MAX-1}]] set len [string length $part]; puts "\t/* Start of part $n ($len characters) */" puts "\t\"[translate $part]\"," diff --git a/tools/tclOOScript.tcl b/tools/tclOOScript.tcl new file mode 100644 index 0000000..5e0145f --- /dev/null +++ b/tools/tclOOScript.tcl @@ -0,0 +1,456 @@ +# tclOOScript.h -- +# +# This file contains support scripts for TclOO. They are defined here so +# that the code can be definitely run even in safe interpreters; TclOO's +# core setup is safe. +# +# Copyright (c) 2012-2018 Donal K. Fellows +# Copyright (c) 2013 Andreas Kupries +# Copyright (c) 2017 Gerald Lester +# +# See the file "license.terms" for information on usage and redistribution of +# this file, and for a DISCLAIMER OF ALL WARRANTIES. + +::namespace eval ::oo { + ::namespace path {} + + # + # Commands that are made available to objects by default. + # + namespace eval Helpers { + ::namespace path {} + + # ------------------------------------------------------------------ + # + # callback, mymethod -- + # + # Create a script prefix that calls a method on the current + # object. Same operation, two names. + # + # ------------------------------------------------------------------ + + proc callback {method args} { + list [uplevel 1 {::namespace which my}] $method {*}$args + } + + # Make the [callback] command appear as [mymethod] too. + namespace export callback + namespace eval tmp {namespace import ::oo::Helpers::callback} + namespace export -clear + rename tmp::callback mymethod + namespace delete tmp + + # ------------------------------------------------------------------ + # + # classvariable -- + # + # Link to a variable in the class of the current object. + # + # ------------------------------------------------------------------ + + proc classvariable {name args} { + # Get a reference to the class's namespace + set ns [info object namespace [uplevel 1 {self class}]] + # Double up the list of variable names + foreach v [list $name {*}$args] { + if {[string match *(*) $v]} { + set reason "can't create a scalar variable that looks like an array element" + return -code error -errorcode {TCL UPVAR LOCAL_ELEMENT} \ + [format {bad variable name "%s": %s} $v $reason] + } + if {[string match *::* $v]} { + set reason "can't create a local variable with a namespace separator in it" + return -code error -errorcode {TCL UPVAR INVERTED} \ + [format {bad variable name "%s": %s} $v $reason] + } + lappend vs $v $v + } + # Lastly, link the caller's local variables to the class's variables + tailcall namespace upvar $ns {*}$vs + } + + # ------------------------------------------------------------------ + # + # link -- + # + # Make a command that invokes a method on the current object. + # The name of the command and the name of the method match by + # default. + # + # ------------------------------------------------------------------ + + proc link {args} { + set ns [uplevel 1 {::namespace current}] + foreach link $args { + if {[llength $link] == 2} { + lassign $link src dst + } elseif {[llength $link] == 1} { + lassign $link src + set dst $src + } else { + return -code error -errorcode {TCLOO CMDLINK FORMAT} \ + "bad link description; must only have one or two elements" + } + if {![string match ::* $src]} { + set src [string cat $ns :: $src] + } + interp alias {} $src {} ${ns}::my $dst + trace add command ${ns}::my delete [list \ + ::oo::UnlinkLinkedCommand $src] + } + return + } + } + + # ---------------------------------------------------------------------- + # + # UnlinkLinkedCommand -- + # + # Callback used to remove linked command when the underlying mechanism + # that supports it is deleted. + # + # ---------------------------------------------------------------------- + + proc UnlinkLinkedCommand {cmd args} { + if {[namespace which $cmd] ne {}} { + rename $cmd {} + } + } + + # ---------------------------------------------------------------------- + # + # DelegateName -- + # + # Utility that gets the name of the class delegate for a class. It's + # trivial, but makes working with them much easier as delegate names are + # intentionally hard to create by accident. + # + # ---------------------------------------------------------------------- + + proc DelegateName {class} { + string cat [info object namespace $class] {:: oo ::delegate} + } + + # ---------------------------------------------------------------------- + # + # MixinClassDelegates -- + # + # Support code called *after* [oo::define] inside the constructor of a + # class that patches in the appropriate class delegates. + # + # ---------------------------------------------------------------------- + + proc MixinClassDelegates {class} { + if {![info object isa class $class]} { + return + } + set delegate [DelegateName $class] + if {![info object isa class $delegate]} { + return + } + foreach c [info class superclass $class] { + set d [DelegateName $c] + if {![info object isa class $d]} { + continue + } + define $delegate ::oo::define::superclass -append $d + } + objdefine $class ::oo::objdefine::mixin -append $delegate + } + + # ---------------------------------------------------------------------- + # + # UpdateClassDelegatesAfterClone -- + # + # Support code that is like [MixinClassDelegates] except for when a + # class is cloned. + # + # ---------------------------------------------------------------------- + + proc UpdateClassDelegatesAfterClone {originObject targetObject} { + # Rebuild the class inheritance delegation class + set originDelegate [DelegateName $originObject] + set targetDelegate [DelegateName $targetObject] + if { + [info object isa class $originDelegate] + && ![info object isa class $targetDelegate] + } then { + copy $originDelegate $targetDelegate + objdefine $targetObject ::oo::objdefine::mixin -set \ + {*}[lmap c [info object mixin $targetObject] { + if {$c eq $originDelegate} {set targetDelegate} {set c} + }] + } + } + + # ---------------------------------------------------------------------- + # + # oo::define::classmethod -- + # + # Defines a class method. See define(n) for details. + # + # Note that the ::oo::define namespace is semi-public and a bit weird + # anyway, so we don't regard the namespace path as being under control: + # fully qualified names are used for everything. + # + # ---------------------------------------------------------------------- + + proc define::classmethod {name {args {}} {body {}}} { + # Create the method on the class if the caller gave arguments and body + ::set argc [::llength [::info level 0]] + ::if {$argc == 3} { + ::return -code error -errorcode {TCL WRONGARGS} [::format \ + {wrong # args: should be "%s name ?args body?"} \ + [::lindex [::info level 0] 0]] + } + ::set cls [::uplevel 1 self] + ::if {$argc == 4} { + ::oo::define [::oo::DelegateName $cls] method $name $args $body + } + # Make the connection by forwarding + ::tailcall forward $name myclass $name + } + + # ---------------------------------------------------------------------- + # + # oo::define::initialise, oo::define::initialize -- + # + # Do specific initialisation for a class. See define(n) for details. + # + # Note that the ::oo::define namespace is semi-public and a bit weird + # anyway, so we don't regard the namespace path as being under control: + # fully qualified names are used for everything. + # + # ---------------------------------------------------------------------- + + proc define::initialise {body} { + ::set clsns [::info object namespace [::uplevel 1 self]] + ::tailcall apply [::list {} $body $clsns] + } + + # Make the [initialise] definition appear as [initialize] too + namespace eval define { + ::namespace export initialise + ::namespace eval tmp {::namespace import ::oo::define::initialise} + ::namespace export -clear + ::rename tmp::initialise initialize + ::namespace delete tmp + } + + # ---------------------------------------------------------------------- + # + # Slot -- + # + # The class of slot operations, which are basically lists at the low + # level of TclOO; this provides a more consistent interface to them. + # + # ---------------------------------------------------------------------- + + define Slot { + # ------------------------------------------------------------------ + # + # Slot Get -- + # + # Basic slot getter. Retrieves the contents of the slot. + # Particular slots must provide concrete non-erroring + # implementation. + # + # ------------------------------------------------------------------ + + method Get {} { + return -code error -errorcode {TCLOO ABSTRACT_SLOT} "unimplemented" + } + + # ------------------------------------------------------------------ + # + # Slot Set -- + # + # Basic slot setter. Sets the contents of the slot. Particular + # slots must provide concrete non-erroring implementation. + # + # ------------------------------------------------------------------ + + method Set list { + return -code error -errorcode {TCLOO ABSTRACT_SLOT} "unimplemented" + } + + # ------------------------------------------------------------------ + # + # Slot Resolve -- + # + # Helper that lets a slot convert a list of arguments of a + # particular type to their canonical forms. Defaults to doing + # nothing (suitable for simple strings). + # + # ------------------------------------------------------------------ + + method Resolve list { + return $list + } + + # ------------------------------------------------------------------ + # + # Slot -set, -append, -clear, --default-operation -- + # + # Standard public slot operations. If a slot can't figure out + # what method to call directly, it uses --default-operation. + # + # ------------------------------------------------------------------ + + method -set args { + set my [namespace which my] + set args [lmap a $args {uplevel 1 [list $my Resolve $a]}] + tailcall my Set $args + } + method -append args { + set my [namespace which my] + set args [lmap a $args {uplevel 1 [list $my Resolve $a]}] + set current [uplevel 1 [list $my Get]] + tailcall my Set [list {*}$current {*}$args] + } + method -clear {} {tailcall my Set {}} + method -prepend args { + set my [namespace which my] + set args [lmap a $args {uplevel 1 [list $my Resolve $a]}] + set current [uplevel 1 [list $my Get]] + tailcall my Set [list {*}$args {*}$current] + } + method -remove args { + set my [namespace which my] + set args [lmap a $args {uplevel 1 [list $my Resolve $a]}] + set current [uplevel 1 [list $my Get]] + tailcall my Set [lmap val $current { + if {$val in $args} continue else {set val} + }] + } + + # Default handling + forward --default-operation my -append + method unknown {args} { + set def --default-operation + if {[llength $args] == 0} { + tailcall my $def + } elseif {![string match -* [lindex $args 0]]} { + tailcall my $def {*}$args + } + next {*}$args + } + + # Set up what is exported and what isn't + export -set -append -clear -prepend -remove + unexport unknown destroy + } + + # Set the default operation differently for these slots + objdefine define::superclass forward --default-operation my -set + objdefine define::mixin forward --default-operation my -set + objdefine objdefine::mixin forward --default-operation my -set + + # ---------------------------------------------------------------------- + # + # oo::object <cloned> -- + # + # Handler for cloning objects that clones basic bits (only!) of the + # object's namespace. Non-procedures, traces, sub-namespaces, etc. need + # more complex (and class-specific) handling. + # + # ---------------------------------------------------------------------- + + define object method <cloned> {originObject} { + # Copy over the procedures from the original namespace + foreach p [info procs [info object namespace $originObject]::*] { + set args [info args $p] + set idx -1 + foreach a $args { + if {[info default $p $a d]} { + lset args [incr idx] [list $a $d] + } else { + lset args [incr idx] [list $a] + } + } + set b [info body $p] + set p [namespace tail $p] + proc $p $args $b + } + # Copy over the variables from the original namespace + foreach v [info vars [info object namespace $originObject]::*] { + upvar 0 $v vOrigin + namespace upvar [namespace current] [namespace tail $v] vNew + if {[info exists vOrigin]} { + if {[array exists vOrigin]} { + array set vNew [array get vOrigin] + } else { + set vNew $vOrigin + } + } + } + # General commands, sub-namespaces and advancd variable config (traces, + # etc) are *not* copied over. Classes that want that should do it + # themselves. + } + + # ---------------------------------------------------------------------- + # + # oo::class <cloned> -- + # + # Handler for cloning classes, which fixes up the delegates. + # + # ---------------------------------------------------------------------- + + define class method <cloned> {originObject} { + next $originObject + # Rebuild the class inheritance delegation class + ::oo::UpdateClassDelegatesAfterClone $originObject [self] + } + + # ---------------------------------------------------------------------- + # + # oo::singleton -- + # + # A metaclass that is used to make classes that only permit one instance + # of them to exist. See singleton(n). + # + # ---------------------------------------------------------------------- + + class create singleton { + superclass class + variable object + unexport create createWithNamespace + method new args { + if {![info exists object] || ![info object isa object $object]} { + set object [next {*}$args] + ::oo::objdefine $object { + method destroy {} { + ::return -code error -errorcode {TCLOO SINGLETON} \ + "may not destroy a singleton object" + } + method <cloned> {originObject} { + ::return -code error -errorcode {TCLOO SINGLETON} \ + "may not clone a singleton object" + } + } + } + return $object + } + } + + # ---------------------------------------------------------------------- + # + # oo::abstract -- + # + # A metaclass that is used to make classes that can't be directly + # instantiated. See abstract(n). + # + # ---------------------------------------------------------------------- + + class create abstract { + superclass class + unexport create createWithNamespace new + } +} + +# Local Variables: +# mode: tcl +# c-basic-offset: 4 +# fill-column: 78 +# End: diff --git a/tools/tcltk-man2html-utils.tcl b/tools/tcltk-man2html-utils.tcl index 5a4550b..b38f0b5 100644 --- a/tools/tcltk-man2html-utils.tcl +++ b/tools/tcltk-man2html-utils.tcl @@ -876,7 +876,7 @@ proc insert-cross-references {text} { [expr {$offset(end-bold)-1}]] set text [string range $text[set text ""] \ [expr {$offset(end-bold)+4}] end] - regsub {http://[\w/.]+} $body {<A HREF="&">&</A>} body + regsub {http://[\w/.-]+} $body {<A HREF="&">&</A>} body append result <B> [cross-reference $body] </B> continue } @@ -912,7 +912,7 @@ proc insert-cross-references {text} { url { set off [lindex $offsets 0] append result [string range $text 0 [expr {$off-1}]] - regexp -indices -start $off {http://[\w/.]+} $text range + regexp -indices -start $off {http://[\w/.-]+} $text range set url [string range $text {*}$range] append result "<A HREF=\"[string trimright $url .]\">$url</A>" set text [string range $text[set text ""] \ @@ -1566,6 +1566,10 @@ proc make-manpage-section {outputDir sectionDescriptor} { puts stderr "" } + if {![llength $manual(wing-toc)]} { + fatal "not table of contents." + } + # # make the wing table of contents for the section # diff --git a/tools/tcltk-man2html.tcl b/tools/tcltk-man2html.tcl index bd17b13..117ba73 100755 --- a/tools/tcltk-man2html.tcl +++ b/tools/tcltk-man2html.tcl @@ -31,36 +31,50 @@ set ::CSSFILE "docs.css" ## source [file join [file dirname [info script]] tcltk-man2html-utils.tcl] +proc getversion {tclh {name {}}} { + if {[file exists $tclh]} { + set chan [open $tclh] + set data [read $chan] + close $chan + if {$name eq ""} { + set name [string toupper [file root [file tail $tclh]]] + } + # backslash isn't required in front of quote, but it keeps syntax + # highlighting straight in some editors + if {[regexp -lineanchor \ + [string map [list @name@ $name] \ + {^#define\s+@name@_VERSION\s+\"([^.])+\.([^.\"]+)}] \ + $data -> major minor]} { + return [list $major $minor] + } + } +} proc findversion {top name useversion} { + # Default search version is a glob pattern, switch it for string match: + if {$useversion eq {{,[8-9].[0-9]{,[.ab][0-9]{,[0-9]}}}}} { + set useversion {[8-9].[0-9]} + } + # Search: set upper [string toupper $name] foreach top1 [list $top $top/..] sub {{} generic} { foreach dirname [ glob -nocomplain -tails -type d -directory $top1 *] { - set tclh [join [list $top1 $dirname {*}$sub $name.h] /] - if {[file exists $tclh]} { - set chan [open $tclh] - set data [read $chan] - close $chan - # backslash isn't required in front of quote, but it keeps syntax - # highlighting straight in some editors - if {[regexp -lineanchor \ - [string map [list @name@ $upper] \ - {^#define\s+@name@_VERSION\s+\"([^.])+\.([^.\"]+)}] \ - $data -> major minor]} { - # to do - # use glob matching instead of string matching or add - # brace handling to [string matcch] - if {$useversion eq {} || [string match $useversion $major.$minor]} { - set top [file dirname [file dirname $tclh]] - set prefix [file dirname $top] - return [list $prefix [file tail $top] $major $minor] - } + set tclh [join [list $top1 $dirname {*}$sub ${name}.h] /] + set v [getversion $tclh $upper] + if {[llength $v]} { + lassign $v major minor + # to do + # use glob matching instead of string matching or add + # brace handling to [string matcch] + if {$useversion eq {} || [string match $useversion $major.$minor]} { + set top [file dirname [file dirname $tclh]] + set prefix [file dirname $top] + return [list $prefix [file tail $top] $major $minor] } } } } - return } proc parse_command_line {} { @@ -151,9 +165,19 @@ proc parse_command_line {} { set build_tk 1 } + set major "" + set minor "" + if {$build_tcl} { - # Find Tcl. - lassign [findversion $tcltkdir tcl $useversion] tcltkdir tcldir major minor + # Find Tcl (firstly using glob pattern / backwards compatible way) + set tcldir [lindex [lsort [glob -nocomplain -tails -type d \ + -directory $tcltkdir tcl$useversion]] end] + if {$tcldir ne {}} { + # obtain version from generic header if we can: + lassign [getversion [file join $tcltkdir $tcldir generic tcl.h]] major minor + } else { + lassign [findversion $tcltkdir tcl $useversion] tcltkdir tcldir major minor + } if {$tcldir eq {} && $opt_build_tcl} { puts stderr "tcltk-man-html: couldn't find Tcl below $tcltkdir" exit 1 @@ -163,8 +187,17 @@ proc parse_command_line {} { if {$build_tk} { - # Find Tk. - lassign [findversion $tcltkdir tk $useversion] tcltkdir tkdir major minor + # Find Tk (firstly using glob pattern / backwards compatible way) + set tkdir [lindex [lsort [glob -nocomplain -tails -type d \ + -directory $tcltkdir tk$useversion]] end] + if {$tkdir ne {}} { + if {$major eq ""} { + # obtain version from generic header if we can: + lassign [getversion [file join $tcltkdir $tcldir generic tk.h]] major minor + } + } else { + lassign [findversion $tcltkdir tk $useversion] tcltkdir tkdir major minor + } if {$tkdir eq {} && $opt_build_tk} { puts stderr "tcltk-man-html: couldn't find Tk below $tcltkdir" exit 1 @@ -178,7 +211,11 @@ proc parse_command_line {} { global overall_title set overall_title "" if {$build_tcl} { - append overall_title "Tcl $major.$minor" + if {$major ne ""} { + append overall_title "Tcl $major.$minor" + } else { + append overall_title "Tcl [capitalize $tcldir]" + } } if {$build_tcl && $build_tk} { append overall_title "/" |