py/frozenmod: Make frozen module content be 0-terminated.

To allow simple zero-terminated lexers.
This commit is contained in:
Paul Sokolovsky 2016-01-01 07:51:07 +02:00
parent ed584e2ffd
commit 0992588811
2 changed files with 2 additions and 2 deletions

View File

@ -46,7 +46,7 @@ mp_lexer_t *mp_find_frozen_module(const char *str, int len) {
mp_lexer_t *lex = mp_lexer_new_from_str_len(MP_QSTR_, s, *sz_ptr, 0); mp_lexer_t *lex = mp_lexer_new_from_str_len(MP_QSTR_, s, *sz_ptr, 0);
return lex; return lex;
} }
s += l + 1 + *sz_ptr++; s += (l + 1) + (*sz_ptr++ + 1);
} }
return NULL; return NULL;
} }

View File

@ -55,5 +55,5 @@ for f, st in modules:
data = data[1:] data = data[1:]
data = data[1:-1] data = data[1:-1]
data = data.replace('"', '\\"') data = data.replace('"', '\\"')
print('"%s"' % data) print('"%s\\0"' % data)
print("};") print("};")