summaryrefslogtreecommitdiffstats
path: root/tools/checkLibraryDoc.tcl
diff options
context:
space:
mode:
authorandreask <andreask>2013-01-22 19:24:25 (GMT)
committerandreask <andreask>2013-01-22 19:24:25 (GMT)
commit6d8a36d84d2843681302604a082e2f787c3c3674 (patch)
tree9d3b4ee05189203cf7ce94b4b2a6d2d911aaa18d /tools/checkLibraryDoc.tcl
parent296aebbd6ee092a25741684fa37ee31ef5a3e222 (diff)
downloadtcl-6d8a36d84d2843681302604a082e2f787c3c3674.zip
tcl-6d8a36d84d2843681302604a082e2f787c3c3674.tar.gz
tcl-6d8a36d84d2843681302604a082e2f787c3c3674.tar.bz2
Contribution by Patrick Fradin <patrick.fradin@planar.com>
Quoting his mail: <pre> ========================================================== Hi Jeff, I spent some of my time to contribute to the TclTk community ! I'm in late for Christmas gift but like we said in French : "Mieux vaut tard que jamais". ;-) I've use TclDevKit 5.3.0 tclchecker to analyse TclTk code in Tcl and Tk library directories (library, tools and tests) to correct a lot of warnings and few errors. (encapsulate some expr, use 'chan xxx' instead of fconfigure, fileevent...) I've made some improvements too : Examples : - Use 'lassign' instead of many 'lindex' of 'foreach/break' loop. - Use 'in' or 'ni' operators instead of 'lsearch -exact' or to factorise some eq/ne && / || tests. - Use 'eq' or 'ne' to tests strings instead of '==' or '!='. - Use 'unset -nocomplain' to avoid 'catch {unset...}'. - Remove some useless catch around 'destroy' calls. - Use expand {*} instead of 'eval'. Don't touch a lot of code because I don't know all structs and lists. I think it could be a greater improvement to reduce 'eval' calls. Due to previous experience, I dot not change any indentation ! ;-) ========================================================== </pre>
Diffstat (limited to 'tools/checkLibraryDoc.tcl')
-rwxr-xr-xtools/checkLibraryDoc.tcl39
1 files changed, 20 insertions, 19 deletions
diff --git a/tools/checkLibraryDoc.tcl b/tools/checkLibraryDoc.tcl
index 6d147ac..4af6eb9 100755
--- a/tools/checkLibraryDoc.tcl
+++ b/tools/checkLibraryDoc.tcl
@@ -139,17 +139,17 @@ proc compare {list1 list2} {
# the results to the file.
proc filter {code docs dir pkg {outFile stdout}} {
- set apis {}
+ set apis [list]
# A list of Tcl command APIs. These are not documented.
# This list should just be verified for accuracy.
- set cmds {}
+ set cmds [list]
# A list of proc pointer structs. These are not documented.
# This list should just be verified for accuracy.
- set procs {}
+ set procs [list]
# A list of internal declarations. These are not documented.
# This list should just be verified for accuracy.
@@ -161,23 +161,23 @@ proc filter {code docs dir pkg {outFile stdout}} {
set misc [grepMisc $dir $pkg]
- set pat1 ".*(${pkg}_\[A-z0-9]+).*$"
+ set pat1 ".*\(${pkg}_\[A-z0-9\]+\).*$"
# A list of APIs in the source, not in the docs.
# This list should just be verified for accuracy.
foreach x $code {
- if {[string match *Cmd $x]} {
- if {[string match ${pkg}* $x]} {
+ if {[string match "*Cmd" $x]} {
+ if {[string match "${pkg}*" $x]} {
lappend cmds $x
}
- } elseif {[string match *Proc $x]} {
- if {[string match ${pkg}* $x]} {
+ } elseif {[string match "*Proc" $x]} {
+ if {[string match "${pkg}*" $x]} {
lappend procs $x
}
- } elseif {[lsearch -exact $decls $x] >= 0} {
+ } elseif {$x in $decls} {
# No Op.
- } elseif {[lsearch -exact $misc $x] >= 0} {
+ } elseif {$x in $misc} {
# No Op.
} else {
lappend apis $x
@@ -211,7 +211,7 @@ proc dump {list title file} {
proc grepCode {dir pkg} {
set apis [myGrep "${pkg}_\.\*" "${dir}/\*/\*\.\[ch\]"]
- set pat1 ".*(${pkg}_\[A-z0-9]+).*$"
+ set pat1 ".*\(${pkg}_\[A-z0-9\]+\).*$"
foreach a $apis {
if {[regexp -- $pat1 $a main n1]} {
@@ -226,7 +226,7 @@ proc grepCode {dir pkg} {
proc grepDocs {dir pkg} {
set apis [myGrep "\\fB${pkg}_\.\*\\fR" "${dir}/doc/\*\.3"]
- set pat1 ".*(${pkg}_\[A-z0-9]+)\\\\fR.*$"
+ set pat1 ".*\(${pkg}_\[A-z0-9\]+\)\\\\fR.*$"
foreach a $apis {
if {[regexp -- $pat1 $a main n1]} {
@@ -242,7 +242,7 @@ proc grepDocs {dir pkg} {
proc grepDecl {dir pkg} {
set file [file join $dir generic "[string tolower $pkg]IntDecls.h"]
set apis [myGrep "^EXTERN.*\[ \t\]${pkg}_.*" $file]
- set pat1 ".*(${pkg}_\[A-z0-9]+).*$"
+ set pat1 ".*\(${pkg}_\[A-z0-9\]+\).*$"
foreach a $apis {
if {[regexp -- $pat1 $a main n1]} {
@@ -260,7 +260,7 @@ proc grepMisc {dir pkg} {
global StructList
set apis [myGrep "^EXTERN.*\[ \t\]${pkg}_Db.*" "${dir}/\*/\*\.\[ch\]"]
- set pat1 ".*(${pkg}_\[A-z0-9]+).*$"
+ set pat1 ".*\(${pkg}_\[A-z0-9\]+\).*$"
foreach a $apis {
if {[regexp -- $pat1 $a main n1]} {
@@ -268,7 +268,8 @@ proc grepMisc {dir pkg} {
}
}
- set result {}
+ set result [list]
+ # Question: Use {*} instead of eval ?
eval {lappend result} $StructList
eval {lappend result} [lsort [array names dbg]]
eval {lappend result} $CommentList
@@ -276,11 +277,11 @@ proc grepMisc {dir pkg} {
}
proc myGrep {searchPat globPat} {
- set result {}
- foreach file [glob -nocomplain $globPat] {
+ set result [list]
+ foreach file [glob -nocomplain -- $globPat] {
set file [open $file r]
- set data [read $file]
- close $file
+ set data [chan read $file]
+ chan close $file
foreach line [split $data "\n"] {
if {[regexp "^.*${searchPat}.*\$" $line]} {
lappend result $line