mirror of
https://gitee.com/Lyon1998/pikapython.git
synced 2025-01-29 17:22:56 +08:00
solve '\r\n' in PikaVM_runFile()
This commit is contained in:
parent
70f40df524
commit
21cf379456
@ -428,7 +428,7 @@ TEST(cJSON, test7) {
|
|||||||
/* collect */
|
/* collect */
|
||||||
/* assert */
|
/* assert */
|
||||||
|
|
||||||
EXPECT_STREQ(log_buff[0], "Android\r\n");
|
EXPECT_STREQ(log_buff[0], "shopping\r\n");
|
||||||
/* deinit */
|
/* deinit */
|
||||||
obj_deinit(pikaMain);
|
obj_deinit(pikaMain);
|
||||||
EXPECT_EQ(pikaMemNow(), 0);
|
EXPECT_EQ(pikaMemNow(), 0);
|
||||||
|
12
src/PikaVM.c
12
src/PikaVM.c
@ -1091,9 +1091,17 @@ exit:
|
|||||||
|
|
||||||
VMParameters* pikaVM_runFile(PikaObj* self, char* filename) {
|
VMParameters* pikaVM_runFile(PikaObj* self, char* filename) {
|
||||||
Arg* file_arg = arg_loadFile(NULL, filename);
|
Arg* file_arg = arg_loadFile(NULL, filename);
|
||||||
char* py_lines = (char*)arg_getBytes(file_arg);
|
char* lines = (char*)arg_getBytes(file_arg);
|
||||||
VMParameters* res = pikaVM_run(self, py_lines);
|
Args buffs = {0};
|
||||||
|
/* replace the "\r\n" to "\n" */
|
||||||
|
lines = strsReplace(&buffs, lines, "\r\n", "\n");
|
||||||
|
/* clear the void line */
|
||||||
|
lines = strsReplace(&buffs, lines, "\n\n", "\n");
|
||||||
|
/* add '\n' at the end */
|
||||||
|
lines = strsAppend(&buffs, lines, "\n\n");
|
||||||
|
VMParameters* res = pikaVM_run(self, lines);
|
||||||
arg_deinit(file_arg);
|
arg_deinit(file_arg);
|
||||||
|
strsDeinit(&buffs);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user