File: T016.tcl

package info (click to toggle)
vera%2B%2B 1.3.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,184 kB
  • sloc: cpp: 10,361; tcl: 921; python: 32; makefile: 5
file content (19 lines) | stat: -rwxr-xr-x 747 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#!/usr/bin/tclsh
# Calls to min/max should be protected against accidental macro substitution

foreach file [getSourceFileNames] {
    set prev "none"
    foreach identifier [getTokens $file 1 0 -1 -1 {}] {
        set value [lindex $identifier 0]
        if {($value == "min" || $value == "max") && $prev != "::"} {
            set lineNumber [lindex $identifier 1]
            set columnNumber [expr [lindex $identifier 2] + [string length $value]]
            set restOfLine [string range [getLine $file $lineNumber] $columnNumber end]

            if {[regexp {^[[:space:]]*\(} $restOfLine] == 1} {
                report $file $lineNumber "min/max potential macro substitution problem"
            }
        }
        set prev $value
    }
}