1
0
This repository has been archived on 2024-07-22. You can view files and clone it, but cannot push or open issues or pull requests.
TP-Link_Archer-XR500v/EN7526G_3.18Kernel_SDK/apps/public/usb-modeswitch-1.2.3/make_string.tcl
2024-07-22 01:58:46 -03:00

32 lines
738 B
Tcl
Executable File

#!/usr/bin/env tclsh
# (c) Josua Dietze 2012
#
# Usage: mk_script_string.tcl source.tcl >jim-source.c
# Converts a Tcl source file into C source suitable
# for using as an embedded script.
set source [lindex $argv 0]
if {![string match *.tcl $source]} {
error "Source $source is not a .tcl file"
}
# Read the Tcl source and convert to C macro
set sourcelines {}
set f [open $source]
while {[gets $f buf] >= 0} {
# Remove comment lines
regsub {^[ \t]*#.*$} $buf "" buf
# Remove leading whitespaces
set buf [string trimleft $buf]
# Escape quotes and backlashes
set buf [string map [list \\ \\\\ \" \\"] $buf]
if [string length $buf] {
lappend sourcelines "$buf\\n"
}
}
close $f
puts "#define RAW \"[join $sourcelines ""]\""