]> gitweb.ps.run Git - iftint/commitdiff
fix peekchar input
authorPatrick <patrick.schoenberger@posteo.de>
Wed, 2 Aug 2023 21:47:20 +0000 (23:47 +0200)
committerPatrick <patrick.schoenberger@posteo.de>
Wed, 2 Aug 2023 21:47:20 +0000 (23:47 +0200)
main2.c

diff --git a/main2.c b/main2.c
index 5ea32ef8788d035a48587bec17b1a37c6812bc76..104c2a47a021ad8b347aea2f563e184ac29f5804 100644 (file)
--- a/main2.c
+++ b/main2.c
@@ -14,7 +14,7 @@
 #define NEWARR(TYPE, NUM) ((TYPE *)calloc(NUM, sizeof(TYPE)))
 
 
-// getch()
+// getch
 
 #ifdef _WIN32
 #include <windows.h>
@@ -279,8 +279,8 @@ GetChar() {
 
 int
 PeekChar() {
-    int c = GetChar();
-    ungetch(c);
+    Draw();
+    int c = peekch();
     return c;
 }
 
@@ -354,20 +354,20 @@ GetNode(JSONNode * parent) {
     }
     case 'o': {
         result->kind = JSONNodeKind_Obj;
-        while ((c = peekch()), (c != '\r') && (c != '\n')) {
+        while ((c = PeekChar()), (c != '\r') && (c != '\n')) {
             JSONNodePush(result, JSONNodeNewStr(GetStr()));
 
             JSONNodePush(result, GetNode(result));
         }
-        getch();
+        GetChar();
         break;
     }
     case 'a': {
         result->kind = JSONNodeKind_Arr;
-        while ((c = peekch()), (c != '\r') && (c != '\n')) {
+        while ((c = PeekChar()), (c != '\r') && (c != '\n')) {
             JSONNodePush(result, GetNode(result));
         }
-        getch();
+        GetChar();
         break;
     }
     case 8: