Browse Source

fix a bug

blueloveTH 3 years ago
parent
commit
c75cf86270
2 changed files with 3 additions and 4 deletions
  1. 2 3
      src/main.cpp
  2. 1 1
      src/vm.h

+ 2 - 3
src/main.cpp

@@ -20,13 +20,12 @@ struct Timer{
 };
 };
 
 
 VM* newVM(){
 VM* newVM(){
-    // disable buff of std::cout and std::cerr
-    std::cout.setf(std::ios::unitbuf);
-    std::cerr.setf(std::ios::unitbuf);
     VM* vm = createVM([](const char* str) { 
     VM* vm = createVM([](const char* str) { 
         std::cout << str;
         std::cout << str;
+        std::cout.flush();
     }, [](const char* str) { 
     }, [](const char* str) { 
         std::cerr << str;
         std::cerr << str;
+        std::cerr.flush();
     });
     });
     return vm;
     return vm;
 }
 }

+ 1 - 1
src/vm.h

@@ -668,7 +668,7 @@ private:
     std::stack<_Str> _cleanErrorAndGetSnapshots(){
     std::stack<_Str> _cleanErrorAndGetSnapshots(){
         std::stack<_Str> snapshots;
         std::stack<_Str> snapshots;
         while (!callstack.empty()){
         while (!callstack.empty()){
-            if(snapshots.size() < 10){
+            if(snapshots.size() < 8){
                 snapshots.push(callstack.top()->errorSnapshot());
                 snapshots.push(callstack.top()->errorSnapshot());
             }
             }
             callstack.pop();
             callstack.pop();