Annotation For lib/minirivet/minirivet.tcl

Origin for each line in lib/minirivet/minirivet.tcl from check-in 5dc4de14de:

47dcf5fc27 2019-05-01        rkeene: #! /usr/bin/env tclsh
47dcf5fc27 2019-05-01        rkeene: 
47dcf5fc27 2019-05-01        rkeene: namespace eval ::minirivet {}
47dcf5fc27 2019-05-01        rkeene: 
b07616bee9 2019-09-20        rkeene: if {![info exists ::minirivet::_outputChannel] && ![info exists ::minirivet::_outputVariable]} {
b07616bee9 2019-09-20        rkeene: 	set ::minirivet::_outputChannel stdout
b07616bee9 2019-09-20        rkeene: }
b07616bee9 2019-09-20        rkeene: 
b07616bee9 2019-09-20        rkeene: proc ::minirivet::setOutputChannel {channel} {
b07616bee9 2019-09-20        rkeene: 	unset -nocomplain ::minirivet::_outputVariable
b07616bee9 2019-09-20        rkeene: 	set ::minirivet::_outputChannel $channel
b07616bee9 2019-09-20        rkeene: }
b07616bee9 2019-09-20        rkeene: 
b07616bee9 2019-09-20        rkeene: proc ::minirivet::setOutputVar {variable} {
b07616bee9 2019-09-20        rkeene: 	unset -nocomplain ::minirivet::_outputChannel
b07616bee9 2019-09-20        rkeene: 	set ::minirivet::_outputVariable $variable
b07616bee9 2019-09-20        rkeene: }
b07616bee9 2019-09-20        rkeene: 
b07616bee9 2019-09-20        rkeene: proc ::minirivet::_emitOutput {string} {
b07616bee9 2019-09-20        rkeene: 	if {[info exists ::minirivet::_outputChannel]} {
b07616bee9 2019-09-20        rkeene: 		puts -nonewline $::minirivet::_outputChannel $string
b07616bee9 2019-09-20        rkeene: 	}
b07616bee9 2019-09-20        rkeene: 	if {[info exists ::minirivet::_outputVariable]} {
b07616bee9 2019-09-20        rkeene: 		append $::minirivet::_outputVariable $string
b07616bee9 2019-09-20        rkeene: 	}
b07616bee9 2019-09-20        rkeene: 	return
b07616bee9 2019-09-20        rkeene: }
b07616bee9 2019-09-20        rkeene: 
5dc4de14de 2019-09-20        rkeene: proc ::minirivet::parseStringToCode {string {outputCommand ""}} {
5dc4de14de 2019-09-20        rkeene: 	if {$outputCommand eq ""} {
5dc4de14de 2019-09-20        rkeene: 		set outputCommand [list ::minirivet::_emitOutput]
5dc4de14de 2019-09-20        rkeene: 	}
5dc4de14de 2019-09-20        rkeene: 
47dcf5fc27 2019-05-01        rkeene: 	set code ""
47dcf5fc27 2019-05-01        rkeene: 	while {$string ne ""} {
47dcf5fc27 2019-05-01        rkeene: 		set endIndex [string first "<?" $string]
47dcf5fc27 2019-05-01        rkeene: 		if {$endIndex == -1} {
47dcf5fc27 2019-05-01        rkeene: 			set endIndex [expr {[string length $string] + 1}]
47dcf5fc27 2019-05-01        rkeene: 		}
47dcf5fc27 2019-05-01        rkeene: 
5dc4de14de 2019-09-20        rkeene: 		append code [list {*}$outputCommand [string range $string 0 $endIndex-1]] "; "
47dcf5fc27 2019-05-01        rkeene: 		set string [string range $string $endIndex end]
47dcf5fc27 2019-05-01        rkeene: 		set endIndex [string first "?>" $string]
47dcf5fc27 2019-05-01        rkeene: 		if {$endIndex == -1} {
47dcf5fc27 2019-05-01        rkeene: 			set endIndex [expr {[string length $string] + 1}]
47dcf5fc27 2019-05-01        rkeene: 		}
47dcf5fc27 2019-05-01        rkeene: 
47dcf5fc27 2019-05-01        rkeene: 		set work [string range $string 0 2]
47dcf5fc27 2019-05-01        rkeene: 		if {$work eq "<?="} {
47dcf5fc27 2019-05-01        rkeene: 			set startIndex 3
5dc4de14de 2019-09-20        rkeene: 			append code "$outputCommand [string trim [string range $string 3 $endIndex-1]]; "
47dcf5fc27 2019-05-01        rkeene: 		} else {
47dcf5fc27 2019-05-01        rkeene: 			append code [string range $string 2 $endIndex-1] "\n"
47dcf5fc27 2019-05-01        rkeene: 		}
47dcf5fc27 2019-05-01        rkeene: 
47dcf5fc27 2019-05-01        rkeene: 		set string [string range $string $endIndex+2 end]
47dcf5fc27 2019-05-01        rkeene: 
47dcf5fc27 2019-05-01        rkeene: 
47dcf5fc27 2019-05-01        rkeene: 	}
47dcf5fc27 2019-05-01        rkeene: 
f09ab16ca1 2019-05-08        rkeene: 	return $code
f09ab16ca1 2019-05-08        rkeene: }
f09ab16ca1 2019-05-08        rkeene: 
f09ab16ca1 2019-05-08        rkeene: proc ::minirivet::parseString {string} {
f09ab16ca1 2019-05-08        rkeene: 	set code [parseStringToCode $string]
47dcf5fc27 2019-05-01        rkeene: 	tailcall namespace eval ::request $code
47dcf5fc27 2019-05-01        rkeene: }
47dcf5fc27 2019-05-01        rkeene: 
47dcf5fc27 2019-05-01        rkeene: proc ::minirivet::parse {file} {
47dcf5fc27 2019-05-01        rkeene: 	set fd [open $file]
47dcf5fc27 2019-05-01        rkeene: 	set data [read $fd]
47dcf5fc27 2019-05-01        rkeene: 	close $fd
47dcf5fc27 2019-05-01        rkeene: 	tailcall parseString $data
47dcf5fc27 2019-05-01        rkeene: }
47dcf5fc27 2019-05-01        rkeene: 
47dcf5fc27 2019-05-01        rkeene: package provide minirivet 1