File: findBadExternals.tcl

package info (click to toggle)
tcl9.0 9.0.1%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 35,828 kB
  • sloc: ansic: 216,761; tcl: 24,169; makefile: 3,524; sh: 2,553; ada: 1,681; pascal: 1,139; cpp: 1,001; cs: 879; yacc: 833; asm: 468; perl: 420; xml: 95
file content (53 lines) | stat: -rwxr-xr-x 1,244 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# 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
#
# 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.
#----------------------------------------------------------------------

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]