Skip to content

Commit 053bf6e

Browse files
committed
Fix backslashes in STORE QUOTE
1 parent e216876 commit 053bf6e

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

src/aux/aux_format.cpp

+12
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,18 @@ string &escape_c_quotes(string &str) {
6767
return str;
6868
}
6969

70+
string &escape_c_backslashes(string &str) {
71+
// -- Replaces all " in the passed string for \" --
72+
for (unsigned int i = 0; i < str.size(); ++i) {
73+
if (str[i] == '\\') {
74+
str.erase(i, 1);
75+
str.insert(i, "\\\\");
76+
++i;
77+
}
78+
}
79+
return str;
80+
}
81+
7082
string expandHomeDirectory(string &filename) {
7183
// -- Expands a home directory (normaly when the character ~ is used) --
7284
#if defined(_WIN32)

src/ldpl.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ void compile(vector<string> &lines, compiler_state &state)
121121
}
122122

123123
// No END QUOTE, emit the line as C++
124-
state.add_code("\"\" \"" + escape_c_quotes(line) + "\\n\"", state.where);
124+
state.add_code("\"\" \"" + escape_c_quotes(escape_c_backslashes(line)) + "\\n\"", state.where);
125125
continue;
126126
}
127127

src/ldpl.h

+1
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ string get_c_number(compiler_state &state, string &expression);
8686
string get_c_condition(compiler_state &state, vector<string> tokens);
8787
string get_c_condition(compiler_state &state, vector<string> tokens, unsigned int &ct);
8888
string &escape_c_quotes(string &str);
89+
string &escape_c_backslashes(string &str);
8990
void load_and_compile(string &filename, compiler_state &state);
9091
void accept_and_compile(compiler_state &state);
9192
void replace_whitespace(string &code);

0 commit comments

Comments
 (0)