Skip to content

Commit a5185f4

Browse files
committed
Abstract out back-end stream functionality from lexer.
1 parent 68f59a9 commit a5185f4

9 files changed

Lines changed: 186 additions & 153 deletions

File tree

py/emitcpy.c

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,6 @@ static void emit_cpy_load_const_verbatim_strn(emit_t *emit, const char *str, int
211211
}
212212

213213
static void emit_cpy_load_const_verbatim_quoted_str(emit_t *emit, qstr qstr, bool bytes) {
214-
// TODO strings should be escaped before we get here
215214
if (emit->pass == PASS_3) {
216215
const char *str = qstr_str(qstr);
217216
int len = strlen(str);
@@ -237,13 +236,8 @@ static void emit_cpy_load_const_verbatim_quoted_str(emit_t *emit, qstr qstr, boo
237236
for (int i = 0; i < len; i++) {
238237
if (str[i] == '\n') {
239238
printf("\\n");
240-
} else if (str[i] == '\\' && str[i + 1] == '\'') {
241-
i += 1;
242-
if (quote_single) {
243-
printf("\\'");
244-
} else {
245-
printf("'");
246-
}
239+
} else if (str[i] == '\\') {
240+
printf("\\\\");
247241
} else if (str[i] == '\'' && quote_single) {
248242
printf("\\'");
249243
} else {

0 commit comments

Comments
 (0)