| 1 |
# findBadExternals.tcl -- |
| 2 |
# |
| 3 |
# This script scans the Tcl load library for exported symbols |
| 4 |
# that do not begin with 'Tcl' or 'tcl'. It reports them on the |
| 5 |
# standard output. It is used to make sure that the library does |
| 6 |
# not inadvertently export externals that may be in conflict with |
| 7 |
# other code. |
| 8 |
# |
| 9 |
# Usage: |
| 10 |
# |
| 11 |
# tclsh findBadExternals.tcl /path/to/tclXX.so-or-.dll |
| 12 |
# |
| 13 |
# Copyright (c) 2005 George Peter Staplin and Kevin Kenny |
| 14 |
# |
| 15 |
# See the file "license.terms" for information on usage and redistribution |
| 16 |
# of this file, and for a DISCLAIMER OF ALL WARRANTIES. |
| 17 |
#---------------------------------------------------------------------- |
| 18 |
|
| 19 |
proc main {argc argv} { |
| 20 |
|
| 21 |
if {$argc != 1} { |
| 22 |
puts stderr "syntax is: [info script] libtcl" |
| 23 |
return 1 |
| 24 |
} |
| 25 |
|
| 26 |
|
| 27 |
switch -exact -- $::tcl_platform(platform) { |
| 28 |
unix - |
| 29 |
macosx { |
| 30 |
set status [catch { |
| 31 |
exec nm --extern-only --defined-only [lindex $argv 0] |
| 32 |
} result] |
| 33 |
} |
| 34 |
windows { |
| 35 |
set status [catch { |
| 36 |
exec dumpbin /exports [lindex $argv 0] |
| 37 |
} result] |
| 38 |
} |
| 39 |
} |
| 40 |
if {$status != 0 && $::errorCode ne "NONE"} { |
| 41 |
puts $result |
| 42 |
return 1 |
| 43 |
} |
| 44 |
|
| 45 |
foreach line [split $result \n] { |
| 46 |
if {! [string match {* [Tt]cl*} $line]} { |
| 47 |
puts $line |
| 48 |
} |
| 49 |
} |
| 50 |
|
| 51 |
return 0 |
| 52 |
} |
| 53 |
exit [main $::argc $::argv] |