.NAME Commented out sections of code using C-style comments

.DESCRIPTION
Sections of code shall not be "commented out" using 
C-style comments. 

.COMMENT V7.0

.SEVERITY Required

.COMMENT
Please refer to the MISRA C++:2008 document for further details (www.misra-cpp.com)

.COMMAND r_tcl_checker

.CODE
variable possibleCharsForStatements
set possibleCharsForStatements  [list + - * / = \%]

proc howManyLines { str } {
	set l [string length $str]
	set nb 1
	for { set i 0 } { $i < $l } { incr i } {
		if { "[string range $str $i $i]" == "\n" } {
			incr nb
		}
	}
	return $nb
}

# reading all file and looking for comments
proc compute {standardName filename} {
	variable possibleCharsForStatements
	variable CurrentParameterList

	if { "$CurrentParameterList" == "" } {
		set CurrentParameterList 1
	}
	set chan [open $filename]
	set content [read $chan]
	close $chan
	set idx 0
	set cont 1
	while { $cont } {
		set idx [string first "/*" $content $idx]
		if { $idx < 0 } {
			set cont 0
		} else {
			incr idx 2
			set idx2 [string first "*/" $content $idx]
			if { $idx2 < 0 } {
				set idx2 [string length $content]
				if { [expr $idx2 - 2] < $idx } {
					set idx2 [$idx + 2]
				}
			}
			set str [string range $content $idx [expr $idx2 - 2]]
			set vio 0
			set nb 0
			set nbLines 0
			set virg 0
			set nbInLine 0
			for { set i 0 } { $i < [string length $str] } { incr i } {
				set char [string range $str $i $i]
				switch -- $char {
					; {
						incr virg;
						incr nbInLine
					}
					\n {
						if { $nbInLine > 0 } {
							incr nbLines
						}
						set nbInLine 0
					}
					default {
						if { [lsearch $possibleCharsForStatements $char] >= 0 } {
							incr nb
						}
						if { "$char" != "\t" && "$char" != " " } {
							incr nbInLine
						}
					}
				}
			}
			if { $nbInLine > 0 } {
				incr nbLines
			}
			if { $nbLines > 0 } {
				if { [expr $virg * 2] >= $nbLines && [expr $nb * 2 / $nbLines] >= $CurrentParameterList } {
					set vio 1
				} else {
					if { [regexp {(for|while|switch|if)\s*\(} $str] } {
						set vio 1
					}
				}
				if { $vio } {
					set numLine [howManyLines [string range $content 0 $idx]]
					Violation $filename $idx [expr $idx2 - 2] $numLine $standardName "Code in comments not allowed"
				}
			}
			set idx [expr $idx2 + 3]
		}
	}
}
