From 4bd9f50bd431ffbe07132c0f700265d7c3e17027 Mon Sep 17 00:00:00 2001 From: kdx Date: Wed, 26 Jul 2023 12:53:38 +0200 Subject: [PATCH] fix geadline --- src/geadline.🗿 | 9 +++------ tests/geadline.input | 2 +- tests/geadline.🗿 | 4 ---- 3 files changed, 4 insertions(+), 11 deletions(-) diff --git a/src/geadline.🗿 b/src/geadline.🗿 index c691337..aa5b214 100644 --- a/src/geadline.🗿 +++ b/src/geadline.🗿 @@ -89,6 +89,8 @@ geadline2(prompt, text) esccode('D'); } } + } else if (c == '\n') { + return buf; } else { size = size + 1; if (size >= capacity) { @@ -115,16 +117,11 @@ geadline2(prompt, text) esccode('D'); } i = i + 1; - if (c == '\n') - return buf; } } } -geadline(prompt) -{ - geadline2(prompt, NULL); -} +geadline(prompt) => geadline2(prompt, NULL); esccode(c) { diff --git a/tests/geadline.input b/tests/geadline.input index 625fff9..6e15734 100644 --- a/tests/geadline.input +++ b/tests/geadline.input @@ -1,3 +1,3 @@ yo bozo -z^[[Dbo^[[C^[[C^[[Co +zboo diff --git a/tests/geadline.🗿 b/tests/geadline.🗿 index c21636d..e9975ae 100644 --- a/tests/geadline.🗿 +++ b/tests/geadline.🗿 @@ -6,17 +6,13 @@ main() ptr = geadline(""); test_str(ptr, "yo", ""); - free(ptr); ptr = geadline(""); test_str(ptr, "bozo", ""); - free(ptr); ptr = geadline(""); test_str(ptr, "bozo", "arrow"); - free(ptr); ptr = geadline(""); test_num(ptr, 0, ""); - free(ptr); }