mirror of
https://gitee.com/Lyon1998/pikapython.git
synced 2025-01-15 17:02:53 +08:00
fix 0x7F,'p','y','o' check err when backspace + p
This commit is contained in:
parent
d96c82076d
commit
79361f493b
@ -1064,9 +1064,18 @@ void _do_pikaScriptShell(PikaObj* self, ShellConfig* cfg) {
|
||||
|
||||
/* run xx.py.o */
|
||||
if (inputChar[0] == 'p' && inputChar[1] == 0x7f) {
|
||||
char yo[2] = {0};
|
||||
for (int i = 0; i < 2; i++) {
|
||||
/* eat 'yo' */
|
||||
cfg->fn_getchar();
|
||||
yo[i] = cfg->fn_getchar();
|
||||
}
|
||||
if (!(yo[0] == 'y' && yo[1] == 'o')) {
|
||||
/* not the magic code, abort */
|
||||
_do_obj_runChar(self, 0x7f, cfg);
|
||||
_do_obj_runChar(self, 'p', cfg);
|
||||
_do_obj_runChar(self, yo[0], cfg);
|
||||
_do_obj_runChar(self, yo[1], cfg);
|
||||
continue;
|
||||
}
|
||||
uint32_t size = 0;
|
||||
for (int i = 0; i < 4; i++) {
|
||||
|
@ -2755,3 +2755,21 @@ TEST(pikaMain, REPL_backspace_issue_1) {
|
||||
obj_deinit(pikaMain);
|
||||
EXPECT_EQ(pikaMemNow(), 0);
|
||||
}
|
||||
|
||||
TEST(pikaMain, REPL_backspace_issue_2) {
|
||||
char* lines =
|
||||
"loop\bp\n";
|
||||
/* init */
|
||||
pikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
/* run */
|
||||
__platform_printf("BEGIN\r\n");
|
||||
for (size_t i = 0; i < strGetSize(lines); i++) {
|
||||
obj_runChar(pikaMain, lines[i]);
|
||||
}
|
||||
/* collect */
|
||||
/* assert */
|
||||
/* deinit */
|
||||
obj_deinit(pikaMain);
|
||||
EXPECT_EQ(pikaMemNow(), 0);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user