fix: escape backslashes in embedded Wren source strings for C compilation
Add `line.replace("\\", "\\\\")` to the `wren_to_c_string.py` script so that backslashes in Wren source code (e.g., `\n`, `\r`, `\x1b`) are properly escaped when embedded as C string literals. This fixes incorrect escape sequences in `io.wren.inc` and `repl.wren.inc` that caused runtime failures when reading line separators and rendering REPL output.
This commit is contained in:
@@ -24,6 +24,7 @@ static const char* {1}ModuleSource =
|
||||
def wren_to_c_string(input_path, wren_source_lines, module):
|
||||
wren_source = ""
|
||||
for line in wren_source_lines:
|
||||
line = line.replace("\\", "\\\\")
|
||||
line = line.replace('"', "\\\"")
|
||||
line = line.replace("\n", "\\n\"")
|
||||
if wren_source: wren_source += "\n"
|
||||
|
||||
Reference in New Issue
Block a user