view vera/rules/F001.tcl @ 71:26304c6e4b69

mstch: import 1.0.2
author David Demelier <markand@malikania.fr>
date Wed, 18 Jul 2018 12:31:28 +0200
parents 82b832e1875d
children
line wrap: on
line source

#!/usr/bin/tclsh
# Source files should not use the '\r' (CR) character

foreach fileName [getSourceFileNames] {
    if { $fileName == "-" } {
      # can't check the content from stdin
      continue
    }
    set file [open $fileName "r"]
    fconfigure $file -translation lf
    set line [gets $file]
    set lineCounter 1
    while {![eof $file]} {
        set pos [string first "\r" $line]
        if {$pos != -1 && $pos != [expr [string length $line] - 1]} {
            report $fileName $lineCounter "\\r (CR) detected in isolation at position ${pos}"
        }
        set line [gets $file]
        incr lineCounter
    }
    close $file
}