Просмотр исходного кода

【修复】输出信息多一个回车的问题

tangyuxin 7 лет назад
Родитель
Сommit
d4d3040975
1 измененных файлов с 9 добавлено и 0 удалено
  1. 9 0
      port/mpy_main.c

+ 9 - 0
port/mpy_main.c

@@ -68,6 +68,7 @@ static char *heap = RT_NULL;
 void mpy_main(const char *filename) {
     int stack_dummy;
     stack_top = (void *)&stack_dummy;
+    rt_uint16_t old_flag;
 
     rtt_getchar_init();
 
@@ -98,6 +99,11 @@ void mpy_main(const char *filename) {
     mp_obj_list_init(mp_sys_argv, 0);
     readline_init0();
 
+    /* Save the open flag */
+    old_flag = rt_console_get_device()->open_flag;
+    /* clean the stream flag. stream flag will automatically append '\r' */
+    rt_console_get_device()->open_flag &= ~RT_DEVICE_FLAG_STREAM;
+
     if (filename) {
 #ifndef MICROPYTHON_USING_UOS
         rt_kprintf("Please enable uos module in sys module option first.\n");
@@ -137,6 +143,9 @@ void mpy_main(const char *filename) {
         }
     }
 
+    /* restore the open flag */
+    rt_console_get_device()->open_flag = old_flag;
+
     gc_sweep_all();
 
     mp_deinit();