From: Patrick Date: Wed, 2 Aug 2023 21:47:20 +0000 (+0200) Subject: fix peekchar input X-Git-Url: https://gitweb.ps.run/iftint/commitdiff_plain/4732c7322c4af189232d5faee94e43fe71b175d2?hp=b836e0a4630c9cf8c098b18bca83a3323e181b7f fix peekchar input --- diff --git a/main2.c b/main2.c index 5ea32ef..104c2a4 100644 --- a/main2.c +++ b/main2.c @@ -14,7 +14,7 @@ #define NEWARR(TYPE, NUM) ((TYPE *)calloc(NUM, sizeof(TYPE))) -// getch() +// getch #ifdef _WIN32 #include @@ -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: