Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/windirstat/premake-4.x-stable.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOliver Schneider <oliver@assarbad.net>2014-01-10 06:57:05 +0400
committerOliver Schneider <oliver@assarbad.net>2014-01-10 06:57:05 +0400
commit2f442bebcdfdda02f37af11b870dfe1beef12401 (patch)
treea61bc29af88b85cbd6c73b4a5ad13d75dd6f7077 /scripts
parentfde372c6d3935334ffe3596821ed2ef5dda6b2b9 (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')
-rw-r--r--scripts/embed.lua17
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