diff --git a/dependencies/tlibc b/dependencies/tlibc index a0affaa..75c94e8 160000 --- a/dependencies/tlibc +++ b/dependencies/tlibc @@ -1 +1 @@ -Subproject commit a0affaa6d0e4764c9a906bba516c1f7d1ded5405 +Subproject commit 75c94e88d9a7e12839d343bf4c7978cb7ecf91e1 diff --git a/project.config b/project.config index a0b4ad8..a1c32fb 100644 --- a/project.config +++ b/project.config @@ -34,13 +34,13 @@ case "$OS" in EXEC_FILE="$PROJECT.exe" SHARED_LIB_FILE="$PROJECT.dll" INCLUDE="$INCLUDE " - LINKER_LIBS="-lpthread -lws2_32 -lreadline" + LINKER_LIBS="-lpthread -lws2_32" ;; LINUX) EXEC_FILE="$PROJECT" SHARED_LIB_FILE="$PROJECT.so" INCLUDE="$INCLUDE " - LINKER_LIBS="-lreadline" + LINKER_LIBS="" ;; *) error "operating system $OS has no configuration variants" diff --git a/src/client/client.c b/src/client/client.c index beed1a6..cb58c7c 100644 --- a/src/client/client.c +++ b/src/client/client.c @@ -1,9 +1,4 @@ -// readline.h doesn't include stdio.h -// This bug is older than me))) #include "client.h" -#include -#include -#include #include "term.h" static const str greeting_art = STR( @@ -46,25 +41,23 @@ Result(void) client_run() { if(!term_init()){ Return RESULT_ERROR("can't init terminal", false); } - using_history(); fputs(greeting_art.data, stdout); try_void(askUserNameAndPassword(&_client_credential)); - char* command_input_prev = NULL; - char* command_input_raw = NULL; - Defer(rl_free(command_input_prev)); + Array(char) input_buf = Array_alloc(char, 10000); str command_input = str_null; bool stop = false; - while(!stop && (command_input_raw = readline("> "))){ - rl_free(command_input_prev); - command_input_prev = command_input_raw; - command_input = str_from_cstr(command_input_raw); + while(!stop){ + fputs("> ", stdout); + if(fgets(input_buf.data, input_buf.size, stdin) == NULL) + continue; + + command_input = str_from_cstr(input_buf.data); str_trim(&command_input, true); if(command_input.size == 0) continue; - add_history(command_input.data); Result(void) com_result = commandExec(command_input, &stop); if(com_result.error){ str e_str = Error_toStr(com_result.error); @@ -74,6 +67,7 @@ Result(void) client_run() { } } + free(input_buf.data); ClientCredential_free(_client_credential); ServerConnection_close(_server_connection); Return RESULT_VOID; @@ -123,7 +117,7 @@ static Result(void) commandExec(str command, bool* stop){ } else { Return RESULT_ERROR_FMT("unknown kommand: '%s'\n" - "Use 'h' to see list of avaliable commands\n", + "Use 'h' to see list of avaliable commands", command.data); }