Check-in [b07616bee9]
Overview
Comment:Updated minirivet to support outputting to a variable or a different channel
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: b07616bee91689deb1e6cf63a7c6c001e3d13de0e2276748c2a4490dec3149db
User & Date: rkeene on 2019-09-20 14:53:39
Other Links: manifest | tags
Context
2019-09-20
15:00
Add support for writing output to a file rather than stdout check-in: 0bdbe4333e user: rkeene tags: trunk
14:53
Updated minirivet to support outputting to a variable or a different channel check-in: b07616bee9 user: rkeene tags: trunk
2019-09-18
05:30
Updated to allow user to specify mountpoint at compile-time check-in: 2139fe19a8 user: rkeene tags: trunk
Changes

Modified lib/minirivet/minirivet.tcl from [0d1a3257b6] to [1bcbec411f].

1
2
3
























4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#! /usr/bin/env tclsh

namespace eval ::minirivet {}

























proc ::minirivet::parseStringToCode {string} {
	set code ""
	while {$string ne ""} {
		set endIndex [string first "<?" $string]
		if {$endIndex == -1} {
			set endIndex [expr {[string length $string] + 1}]
		}

		append code [list puts -nonewline [string range $string 0 $endIndex-1]] "; "
		set string [string range $string $endIndex end]
		set endIndex [string first "?>" $string]
		if {$endIndex == -1} {
			set endIndex [expr {[string length $string] + 1}]
		}

		set work [string range $string 0 2]
		if {$work eq "<?="} {
			set startIndex 3
			append code "puts -nonewline [string trim [string range $string 3 $endIndex-1]]; "
		} else {
			append code [string range $string 2 $endIndex-1] "\n"
		}

		set string [string range $string $endIndex+2 end]





>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>









|









|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#! /usr/bin/env tclsh

namespace eval ::minirivet {}

if {![info exists ::minirivet::_outputChannel] && ![info exists ::minirivet::_outputVariable]} {
	set ::minirivet::_outputChannel stdout
}

proc ::minirivet::setOutputChannel {channel} {
	unset -nocomplain ::minirivet::_outputVariable
	set ::minirivet::_outputChannel $channel
}

proc ::minirivet::setOutputVar {variable} {
	unset -nocomplain ::minirivet::_outputChannel
	set ::minirivet::_outputVariable $variable
}

proc ::minirivet::_emitOutput {string} {
	if {[info exists ::minirivet::_outputChannel]} {
		puts -nonewline $::minirivet::_outputChannel $string
	}
	if {[info exists ::minirivet::_outputVariable]} {
		append $::minirivet::_outputVariable $string
	}
	return
}

proc ::minirivet::parseStringToCode {string} {
	set code ""
	while {$string ne ""} {
		set endIndex [string first "<?" $string]
		if {$endIndex == -1} {
			set endIndex [expr {[string length $string] + 1}]
		}

		append code [list ::minirivet::_emitOutput [string range $string 0 $endIndex-1]] "; "
		set string [string range $string $endIndex end]
		set endIndex [string first "?>" $string]
		if {$endIndex == -1} {
			set endIndex [expr {[string length $string] + 1}]
		}

		set work [string range $string 0 2]
		if {$work eq "<?="} {
			set startIndex 3
			append code "::minirivet::_emitOutput [string trim [string range $string 3 $endIndex-1]]; "
		} else {
			append code [string range $string 2 $endIndex-1] "\n"
		}

		set string [string range $string $endIndex+2 end]