Skip to content
Tcl Source Code Artifact [ae141c7e1b]
Login

Artifact [ae141c7e1b]

Artifact ae141c7e1b3f87cd1bc183e89975c0b2cc7c7aa4284e368030cdd009b801886b:


# Copyright © 2005 George Peter Staplin and Kevin Kenny
#
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.

# You may distribute and/or modify this program under the terms of the GNU
# Affero General Public License as published by the Free Software Foundation,
# either version 3 of the License, or (at your option) any later version.
#
# See the file "COPYING" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.

# findBadExternals.tcl --
#
#	This script scans the Tcl load library for exported symbols
#	that do not begin with 'Tcl' or 'tcl'.  It reports them on the
#	standard output.  It is used to make sure that the library does
#	not inadvertently export externals that may be in conflict with
#	other code.
#
# Usage:
#
#	tclsh findBadExternals.tcl /path/to/tclXX.so-or-.dll

proc main {argc argv} {

    if {$argc != 1} {
	puts stderr "syntax is: [info script] libtcl"
	return 1
    }


    switch -exact -- $::tcl_platform(platform) {
	unix -
	macosx {
	    set status [catch {
		exec nm --extern-only --defined-only [lindex $argv 0]
	    } result]
	}
	windows {
	    set status [catch {
		exec dumpbin /exports [lindex $argv 0]
	    } result]
	}
    }
    if {$status != 0 && $::errorCode ne "NONE"} {
	puts $result
	return 1
    }

    foreach line [split $result \n] {
	if {! [string match {* [Tt]cl*} $line]} {
	    puts $line
	}
    }

    return 0
}
exit [main $::argc $::argv]