Annotation For xvfs-create

Lines of xvfs-create from check-in d36db7c01b that are changed by the sequence of edits moving toward check-in 3cb72a0d20:

                         1: #! /usr/bin/env tclsh
                         2: 
                         3: set sourceDirectory [file dirname [file normalize [info script]]]
                         4: 
                         5: lappend auto_path [file join $sourceDirectory lib]
                         6: 
                         7: set template [file join $sourceDirectory lib xvfs xvfs.c.rvt]
                         8: 
                         9: package require minirivet
                        10: 
                        11: set mode "run"
                        12: if {[lindex $argv 0] == "--dump-tcl"} {
                        13: 	set mode "dump-tcl"
                        14: }
                        15: 
                        16: foreach {arg val} $argv {
                        17: 	switch -exact -- $arg {
                        18: 		"--output" {
                        19: 			set outputFile $val
                        20: 		}
                        21: 	}
                        22: }
                        23: 
                        24: proc remove_debug {input} {
                        25: 	set output [list]
                        26: 
                        27: 	set lastLine -
                        28: 	foreach line [split $input "\n"] {
                        29: 		if {[string match -nocase "*XVFS_DEBUG*" $line]} {
                        30: 			continue
                        31: 		}
                        32: 
                        33: 		if {$lastLine eq "" && $line eq ""} {
                        34: 			continue
                        35: 		}
                        36: 
                        37: 		set lastLine $line
                        38: 		lappend output $line
                        39: 	}
                        40: 
                        41: 	return [join $output "\n"]
                        42: }
                        43: 
                        44: switch -- $mode {
                        45: 	"run" {
                        46: 		package require xvfs
                        47: 
                        48: 		if {[info exists outputFile]} {
                        49: 			set fd [open $outputFile w]
                        50: 			::xvfs::setOutputChannel $fd
                        51: 		}
                        52: 
d36db7c01b 2019-09-20   53: 		set ::xvfs::argv $argv
d36db7c01b 2019-09-20   54: 		::xvfs::run
                        55: 
                        56: 		if {[info exists fd]} {
                        57: 			close $fd
                        58: 		}
                        59: 	}
                        60: 	"dump-tcl" {
                        61: 		set xvfs_tcl [file join $sourceDirectory lib xvfs xvfs.tcl]
                        62: 		set xvfs_core_h [file join $sourceDirectory xvfs-core.h]
                        63: 		set xvfs_core_c [file join $sourceDirectory xvfs-core.c]
                        64: 
                        65: 		set cleanup {
                        66: 			"#include <xvfs-core.h>" ""
                        67: 			"#include <xvfs-core.c>" ""
                        68: 		}
                        69: 
                        70: 		set core_header_data ""
                        71: 		append core_header_data [string map $cleanup [read [open $xvfs_core_h]]] "\n"
                        72: 		append core_header_data [string map $cleanup [read [open $xvfs_core_c]]] "\n"
                        73: 
                        74: 		if {[lsearch -exact $argv "--remove-debug"] != -1} {
                        75: 			set core_header_data [remove_debug $core_header_data]
                        76: 		}
                        77: 
                        78: 		puts "#! /usr/bin/env tclsh"
                        79: 		puts ""
                        80: 		puts [list namespace eval ::minirivet {}]
                        81: 		puts [list set ::minirivet::_outputChannel stdout]
                        82: 		puts [list proc ::minirivet::_emitOutput [info args ::minirivet::_emitOutput] [info body ::minirivet::_emitOutput]]
                        83: 		puts ""
                        84: 		puts [read [open $xvfs_tcl]]
                        85: 		puts ""
                        86: 		puts {set ::xvfs::argv $::argv}
                        87: 		puts {
                        88: 			foreach {arg val} $argv {
                        89: 				switch -exact -- $arg {
                        90: 					"--output" {
                        91: 						set ::minirivet::_outputChannel [open $val w]
                        92: 					}
                        93: 				}
                        94: 			}
                        95: 		}
                        96: 		puts ""
                        97: 		puts [list ::minirivet::_emitOutput $core_header_data]
                        98: 		puts ""
                        99: 
                       100: 		puts ""
                       101: 		puts [string map $cleanup [::minirivet::parseStringToCode [read [open $template]]]]
                       102: 	}
                       103: 	default {
                       104: 		puts stderr "error: Invalid mode: $mode"
                       105: 		exit 1
                       106: 	}
                       107: }