File: T008.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 (24 lines) | stat: -rwxr-xr-x 1,016 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/usr/bin/tclsh
# Keywords catch, for, if and while should be followed by a single space

foreach f [getSourceFileNames] {
    set pp_pragma_line -1
    foreach t [getTokens $f 1 0 -1 -1 {catch for if switch while pp_pragma}] {
        set keyword [lindex $t 0]
        set line [lindex $t 1]
        set column [lindex $t 2]
        set type [lindex $t 3]
        if {$type == "pp_pragma"} {
          set pp_pragma_line $line
        } elseif {$pp_pragma_line != $line} {
            set followingTokens [getTokens $f $line [expr $column + [string length $keyword]] [expr $line + 1] -1 {}]
            if {[llength $followingTokens] < 2} {
                report $f $line "keyword '${keyword}' not followed by a single space"
            } else {
                if {[list [lindex [lindex $followingTokens 0] 0] [lindex [lindex $followingTokens 1] 0]] != [list " " "("]} {
                    report $f $line "keyword '${keyword}' not followed by a single space"
                }
            }
        }
    }
}