diff vera/rules/F001.tcl @ 57:82b832e1875d

vera: import 1.3.0, closes #728
author David Demelier <markand@malikania.fr>
date Tue, 21 Nov 2017 12:19:28 +0100
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/vera/rules/F001.tcl	Tue Nov 21 12:19:28 2017 +0100
@@ -0,0 +1,22 @@
+#!/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
+}