diff options
author | Oliver Schneider <oliver@assarbad.net> | 2014-01-10 06:57:05 +0400 |
---|---|---|
committer | Oliver Schneider <oliver@assarbad.net> | 2014-01-10 06:57:05 +0400 |
commit | 2f442bebcdfdda02f37af11b870dfe1beef12401 (patch) | |
tree | a61bc29af88b85cbd6c73b4a5ad13d75dd6f7077 /scripts/embed.lua | |
parent | fde372c6d3935334ffe3596821ed2ef5dda6b2b9 (diff) |
The post-processing after LuaSrcDiet processing is required so that the string becomes a valid C string
--HG--
branch : WDS-build
Diffstat (limited to 'scripts/embed.lua')
-rw-r--r-- | scripts/embed.lua | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/scripts/embed.lua b/scripts/embed.lua index f80a3cb..57f1034 100644 --- a/scripts/embed.lua +++ b/scripts/embed.lua @@ -7,9 +7,22 @@ local function stripfile(fname) dofile("scripts/luasrcdiet/LuaSrcDiet.lua") - -- Now simply return the file contents after LuaSrcDiet did its job + -- Let LuaSrcDiet do its job local s,l = get_slim_luasrc(fname) - print("\ttrimmed size: ", s:len(), " down from: ", l:len()) + -- Now do some cleanup so we can write these out as C strings + -- strip any CRs + s = s:gsub("[\r]", "") + + print("\ttrimmed size: ", s:len(), " down from: ", l:len()) -- we report the "raw" length + + -- escape backslashes + s = s:gsub("\\", "\\\\") + + -- escape line feeds + s = s:gsub("\n", "\\n") + + -- escape double quote marks + s = s:gsub("\"", "\\\"") return s end |