Check-in [bf2b430faa]
Overview
SHA1:bf2b430faa6d6f0a7c0f27481783c85e90bcc937
Date: 2017-10-17 04:03:09
User: rkeene
Comment:Started work on a stringify that does not use as much RAM
Timelines: family | ancestors | less-memory-stringify
Downloads: Tarball | ZIP archive
Other Links: files | file ages | folders | manifest
Tags And Properties
Context
2017-10-17
04:03
[bf2b430faa] Leaf: Started work on a stringify that does not use as much RAM (user: rkeene, tags: less-memory-stringify)
04:01
[3d037ffb60] Removed obsolete files from initialization (user: rkeene, tags: trunk)
Changes

Modified kitsh/buildsrc/kitsh-0.0/dir2c.tcl from [990f9a7e47] to [2f404d8acb].

59
60
61
62
63
64
65








66
67


68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
	}

	return $ret
}

# Convert a string into a C-style binary string
## XXX: This function needs to be optimized








proc stringify {data} {
	set ret "\""


	for {set idx 0} {$idx < [string length $data]} {incr idx} {
		binary scan [string index $data $idx] H* char

		append ret "\\x${char}"

		if {($idx % 20) == 0 && $idx != 0} {
			append ret "\"\n\""
		}
	}

	set ret [string trim $ret "\n\""]

	set ret "\"$ret\""

	return $ret
}

# Encrypt the data
proc random_byte {} {
	set value [expr {int(256 * rand())}]







>
>
>
>
>
>
>
>
|
<
>
>



|


|



|
<
<







59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74

75
76
77
78
79
80
81
82
83
84
85
86
87


88
89
90
91
92
93
94
	}

	return $ret
}

# Convert a string into a C-style binary string
## XXX: This function needs to be optimized
proc stringify_putsOrAppend {var fd data} {
	if {$fd eq ""} {
		uplevel 1 [list append $var $data]
	} else {
		puts -nonewline $fd $data
	}
}

proc stringify {data {outfd ""}} {

	stringify_putsOrAppend ret $outfd "\""

	for {set idx 0} {$idx < [string length $data]} {incr idx} {
		binary scan [string index $data $idx] H* char

		stringify_putsOrAppend ret $outfd "\\x${char}"

		if {($idx % 20) == 0 && $idx != 0} {
			stringify_putsOrAppend ret $outfd "\"\n\""
		}
	}

	stringify_putsOrAppend ret $outfd "\""



	return $ret
}

# Encrypt the data
proc random_byte {} {
	set value [expr {int(256 * rand())}]