.NAME Line length

.DESCRIPTION
A line in a source shall not exceed a maximum number of characters.

The maximum number of characters is the value of the parameter of the rule.

.SEVERITY Advisory

.COMMAND tcl

.CODE

::logiscope::include -once common utilities.tcl

proc compute {standardName tree} {
	variable CurrentParameterList
	global violations

	set violations ""
	set chan [open "[::logiscope::fileName]"]
	set line 0
	while {[gets $chan content] >= 0} {
		incr line
		if { "[string length $content]" > "$CurrentParameterList" } {
			lappend violations $line
		}
	}
	close $chan
	if { "$violations" != "" } {
		::utilities::filterTree $tree [list [namespace current]::displayViolations]
	}
}

proc displayViolations { tree } {
	global violations

	if { "[llength $violations]" == 0 } {
		return 0
	}
	if { "[::logiscope::treeGetStartLine $tree]" >= "[lindex $violations 0]" } {
		::logiscope::addViolation $tree
		set violations [lreplace $violations 0 0]
	}
	return 1
}

