Skip to content

Commit 139b8b4

Browse files
committed
fix: normalize embedded file system files new-line to /n
1 parent b212dab commit 139b8b4

File tree

2 files changed

+30
-2
lines changed

2 files changed

+30
-2
lines changed

engine/embedded-file-system/generated/scripts.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ namespace {
1111
constexpr uint8_t luastg_io_lua[385]{0,28,23,6,0,83,0,6,14,31,17,71,81,83,6,2,29,6,29,21,9,91,86,19,13,17,24,2,78,90,126,11,3,16,21,11,76,31,7,19,11,83,73,71,30,22,5,18,5,1,17,79,78,31,7,19,11,81,93,109,102,31,27,4,13,31,84,43,35,52,43,43,41,37,49,43,51,58,58,33,35,83,73,71,94,121,126,1,25,29,23,19,5,28,26,71,0,0,0,0,66,32,13,20,24,22,25,43,3,20,92,19,9,11,0,78,102,83,84,71,76,31,7,19,11,93,56,8,11,91,56,40,43,44,56,34,58,54,56,56,37,61,50,40,64,83,0,2,20,7,93,109,9,29,16,109,102,21,1,9,15,7,29,8,2,83,24,20,24,20,90,55,30,26,26,19,68,93,90,73,69,121,84,71,76,83,24,8,15,18,24,71,13,1,19,20,76,78,84,28,66,93,90,26,102,83,84,71,76,31,27,4,13,31,84,6,30,20,23,71,81,83,7,2,0,22,23,19,68,84,87,64,64,83,90,73,66,90,126,71,76,83,84,1,3,1,84,14,76,78,84,86,64,83,21,21,11,16,84,3,3,121,84,71,76,83,84,71,76,83,21,21,11,0,47,14,49,83,73,71,24,28,7,19,30,26,26,0,68,18,6,0,31,40,29,58,69,121,84,71,76,83,17,9,8,121,84,71,76,83,24,20,24,20,90,43,3,20,92,43,35,52,43,43,41,37,49,43,51,58,58,33,35,95,84,19,13,17,24,2,66,16,27,9,15,18,0,79,13,1,19,20,64,83,83,59,24,84,93,78,102,22,26,3,102,121,4,21,5,29,0,71,81,83,24,20,24,20,90,55,30,26,26,19,102};
1212
constexpr uint8_t luastg_main_lua[329]{30,22,5,18,5,1,17,79,78,31,1,6,31,7,19,73,15,25,7,8,2,81,93,109,30,22,5,18,5,1,17,79,78,31,1,6,31,7,19,73,5,28,86,78,102,1,17,22,25,26,6,2,68,81,24,18,13,0,0,0,66,30,21,19,4,81,93,109,30,22,5,18,5,1,17,79,78,31,1,6,31,7,19,73,30,22,25,8,26,22,16,69,69,121,6,2,29,6,29,21,9,91,86,11,25,18,7,19,11,93,51,6,1,22,59,5,6,22,23,19,78,90,126,109,10,6,26,4,24,26,27,9,76,52,21,10,9,58,26,14,24,91,93,71,9,29,16,109,10,6,26,4,24,26,27,9,76,53,6,6,1,22,50,18,2,16,92,78,76,1,17,19,25,1,26,71,10,18,24,20,9,83,17,9,8,121,18,18,2,16,0,14,3,29,84,53,9,29,16,2,30,53,1,9,15,91,93,71,9,29,16,109,10,6,26,4,24,26,27,9,76,52,21,10,9,54,12,14,24,91,93,71,9,29,16,109,10,6,26,4,24,26,27,9,76,53,27,4,25,0,56,8,31,22,50,18,2,16,92,78,76,22,26,3,102,21,1,9,15,7,29,8,2,83,50,8,15,6,7,32,13,26,26,33,25,29,23,79,69,83,17,9,8,121,18,18,2,16,0,14,3,29,84,34,26,22,26,19,42,6,26,4,68,22,2,2,2,7,88,71,66,93,90,78,76,22,26,3,102};
1313
constexpr uint8_t luastg_math_lua[600]{0,28,23,6,0,83,25,6,24,27,84,90,76,1,17,22,25,26,6,2,68,81,25,6,24,27,86,78,102,31,27,4,13,31,84,11,31,7,19,71,81,83,6,2,29,6,29,21,9,91,86,11,31,7,19,69,69,121,126,11,3,16,21,11,76,1,21,3,76,78,84,10,13,7,28,73,30,18,16,109,0,28,23,6,0,83,16,2,11,83,73,71,1,18,0,15,66,23,17,0,102,31,27,4,13,31,84,20,5,29,84,90,76,30,21,19,4,93,7,14,2,121,24,8,15,18,24,71,15,28,7,71,81,83,25,6,24,27,90,4,3,0,126,11,3,16,21,11,76,7,21,9,76,78,84,10,13,7,28,73,24,18,26,109,0,28,23,6,0,83,21,20,5,29,84,90,76,30,21,19,4,93,21,20,5,29,126,11,3,16,21,11,76,18,23,8,31,83,73,71,1,18,0,15,66,18,23,8,31,121,24,8,15,18,24,71,13,7,21,9,76,78,84,10,13,7,28,73,13,7,21,9,102,31,27,4,13,31,84,6,24,18,26,85,76,78,84,10,13,7,28,73,13,7,21,9,94,83,27,21,76,30,21,19,4,93,21,19,13,29,126,109,10,6,26,4,24,26,27,9,76,31,7,19,11,93,7,14,2,91,12,78,76,1,17,19,25,1,26,71,31,26,26,79,30,18,16,79,20,90,93,71,9,29,16,109,10,6,26,4,24,26,27,9,76,31,7,19,11,93,23,8,31,91,12,78,76,1,17,19,25,1,26,71,15,28,7,79,30,18,16,79,20,90,93,71,9,29,16,109,10,6,26,4,24,26,27,9,76,31,7,19,11,93,0,6,2,91,12,78,76,1,17,19,25,1,26,71,24,18,26,79,30,18,16,79,20,90,93,71,9,29,16,109,10,6,26,4,24,26,27,9,76,31,7,19,11,93,21,20,5,29,92,31,69,83,6,2,24,6,6,9,76,23,17,0,68,18,7,14,2,91,12,78,69,83,17,9,8,121,18,18,2,16,0,14,3,29,84,11,31,7,19,73,13,16,27,20,68,11,93,71,30,22,0,18,30,29,84,3,9,20,92,6,15,28,7,79,20,90,93,71,9,29,16,109,10,6,26,4,24,26,27,9,76,31,7,19,11,93,21,19,13,29,92,73,66,93,93,71,30,22,0,18,30,29,84,3,9,20,92,6,24,18,26,79,66,93,90,78,69,83,17,9,8,121,18,18,2,16,0,14,3,29,84,11,31,7,19,73,13,7,21,9,94,91,13,75,76,11,93,71,30,22,0,18,30,29,84,3,9,20,92,6,24,18,26,85,68,10,88,71,20,90,93,71,9,29,16,109};
14-
constexpr uint8_t luastg_removed_lua[141]{0,28,23,6,0,83,24,20,24,20,84,90,76,1,17,22,25,26,6,2,68,81,24,20,24,20,86,78,102,121,18,18,2,16,0,14,3,29,84,11,31,7,19,73,63,27,27,16,63,3,24,6,31,27,35,14,2,23,27,16,68,90,84,2,2,23,126,1,25,29,23,19,5,28,26,71,0,0,0,0,66,35,27,20,24,54,18,1,9,16,0,36,13,3,0,18,30,22,92,78,76,22,26,3,102,21,1,9,15,7,29,8,2,83,24,20,24,20,90,55,3,0,0,34,10,21,17,4,24,50,4,23,0,10,92,78,76,22,26,3,102};
14+
constexpr uint8_t luastg_removed_lua[156]{65,94,89,39,15,31,21,20,31,83,24,20,24,20,126,11,3,16,21,11,76,31,7,19,11,83,73,71,30,22,5,18,5,1,17,79,78,31,7,19,11,81,93,109,102,21,1,9,15,7,29,8,2,83,24,20,24,20,90,52,4,28,3,52,28,31,21,20,4,36,29,9,8,28,3,79,69,83,17,9,8,121,18,18,2,16,0,14,3,29,84,11,31,7,19,73,60,28,7,19,41,21,18,2,15,7,55,6,28,7,1,21,9,91,93,71,9,29,16,109,10,6,26,4,24,26,27,9,76,31,7,19,11,93,36,8,31,7,49,1,10,22,23,19,45,3,4,11,21,91,93,71,9,29,16,109};
1515
constexpr std::array<Node const, 9> s_files{
1616
Node{"luastg/"sv, std::span<uint8_t, 0>()},
1717
Node{"luastg/cjson.lua"sv, std::span(luastg_cjson_lua, 72)},
@@ -21,7 +21,7 @@ namespace {
2121
Node{"luastg/io.lua"sv, std::span(luastg_io_lua, 385)},
2222
Node{"luastg/main.lua"sv, std::span(luastg_main_lua, 329)},
2323
Node{"luastg/math.lua"sv, std::span(luastg_math_lua, 600)},
24-
Node{"luastg/removed.lua"sv, std::span(luastg_removed_lua, 141)},
24+
Node{"luastg/removed.lua"sv, std::span(luastg_removed_lua, 156)},
2525
};
2626
}
2727

tool/embedded-file-system-builder/main.cpp

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,31 @@ namespace {
131131
return true;
132132
}
133133

134+
void normalizeNewLine(std::vector<uint8_t>& buffer) {
135+
size_t i{};
136+
size_t j{};
137+
while (i < buffer.size()) {
138+
if (buffer[i] == '\r') {
139+
if ((i + 1) < buffer.size() && buffer[i + 1] == '\n') {
140+
buffer[j] = '\n';
141+
i += 2;
142+
j += 1;
143+
continue;
144+
}
145+
if ((i + 1) <= buffer.size()) {
146+
buffer[j] = '\n';
147+
i += 1;
148+
j += 1;
149+
break;
150+
}
151+
}
152+
buffer[j] = buffer[i];
153+
i += 1;
154+
j += 1;
155+
}
156+
buffer.resize(j);
157+
}
158+
134159
class InternalLuaScriptsFileSystemBuilder {
135160
public:
136161
void addFile(std::string_view const& name, std::filesystem::path const& path) {
@@ -185,6 +210,9 @@ namespace {
185210
if (!readAllBytes(entry.path, buffer)) {
186211
return false;
187212
}
213+
if (entry.path.has_extension() && entry.path.extension() == ".lua"sv) {
214+
normalizeNewLine(buffer);
215+
}
188216
luastg::mask(buffer.data(), buffer.size());
189217
entry.size = buffer.size();
190218
if (buffer.empty()) {

0 commit comments

Comments
 (0)