Annotation For lib/minirivet/minirivet.tcl

Lines of lib/minirivet/minirivet.tcl from check-in b07616bee9 that are changed by the sequence of edits moving toward check-in 5dc4de14de:

                         1: #! /usr/bin/env tclsh
                         2: 
                         3: namespace eval ::minirivet {}
                         4: 
                         5: if {![info exists ::minirivet::_outputChannel] && ![info exists ::minirivet::_outputVariable]} {
                         6: 	set ::minirivet::_outputChannel stdout
                         7: }
                         8: 
                         9: proc ::minirivet::setOutputChannel {channel} {
                        10: 	unset -nocomplain ::minirivet::_outputVariable
                        11: 	set ::minirivet::_outputChannel $channel
                        12: }
                        13: 
                        14: proc ::minirivet::setOutputVar {variable} {
                        15: 	unset -nocomplain ::minirivet::_outputChannel
                        16: 	set ::minirivet::_outputVariable $variable
                        17: }
                        18: 
                        19: proc ::minirivet::_emitOutput {string} {
                        20: 	if {[info exists ::minirivet::_outputChannel]} {
                        21: 		puts -nonewline $::minirivet::_outputChannel $string
                        22: 	}
                        23: 	if {[info exists ::minirivet::_outputVariable]} {
                        24: 		append $::minirivet::_outputVariable $string
                        25: 	}
                        26: 	return
                        27: }
                        28: 
b07616bee9 2019-09-20   29: proc ::minirivet::parseStringToCode {string} {
                        30: 	set code ""
                        31: 	while {$string ne ""} {
                        32: 		set endIndex [string first "<?" $string]
                        33: 		if {$endIndex == -1} {
                        34: 			set endIndex [expr {[string length $string] + 1}]
                        35: 		}
                        36: 
b07616bee9 2019-09-20   37: 		append code [list ::minirivet::_emitOutput [string range $string 0 $endIndex-1]] "; "
                        38: 		set string [string range $string $endIndex end]
                        39: 		set endIndex [string first "?>" $string]
                        40: 		if {$endIndex == -1} {
                        41: 			set endIndex [expr {[string length $string] + 1}]
                        42: 		}
                        43: 
                        44: 		set work [string range $string 0 2]
                        45: 		if {$work eq "<?="} {
                        46: 			set startIndex 3
b07616bee9 2019-09-20   47: 			append code "::minirivet::_emitOutput [string trim [string range $string 3 $endIndex-1]]; "
                        48: 		} else {
                        49: 			append code [string range $string 2 $endIndex-1] "\n"
                        50: 		}
                        51: 
                        52: 		set string [string range $string $endIndex+2 end]
                        53: 
                        54: 
                        55: 	}
                        56: 
                        57: 	return $code
                        58: }
                        59: 
                        60: proc ::minirivet::parseString {string} {
                        61: 	set code [parseStringToCode $string]
                        62: 	tailcall namespace eval ::request $code
                        63: }
                        64: 
                        65: proc ::minirivet::parse {file} {
                        66: 	set fd [open $file]
                        67: 	set data [read $fd]
                        68: 	close $fd
                        69: 	tailcall parseString $data
                        70: }
                        71: 
                        72: package provide minirivet 1