mirror of
https://github.com/Qsgs-Fans/FreeKill.git
synced 2024-11-16 11:42:45 +08:00
Fix windows build problem: use std::getline
This commit is contained in:
parent
60fc264285
commit
76c9b02623
|
@ -14,6 +14,7 @@
|
|||
#else
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
#endif
|
||||
#include <QJsonDocument>
|
||||
|
||||
|
@ -691,16 +692,15 @@ void Shell::run() {
|
|||
#ifdef FK_USE_READLINE
|
||||
char *bytes = readline(prompt);
|
||||
#else
|
||||
char *bytes = NULL;
|
||||
size_t bufsize = 512;
|
||||
char *bytes;
|
||||
printf("\rfk> ");
|
||||
fflush(stdin);
|
||||
int ret = getline(&bytes, &bufsize, stdin);
|
||||
if (ret == -1 || ret == 0) {
|
||||
free(bytes);
|
||||
std::string str;
|
||||
std::getline(std::cin, str);
|
||||
if (std::cin.fail()) {
|
||||
bytes = NULL;
|
||||
} else {
|
||||
bytes[strlen(bytes) - 1] = '\0'; // remove \n
|
||||
bytes = strdup(str.c_str());
|
||||
}
|
||||
#endif
|
||||
handleLine(bytes);
|
||||
|
|
Loading…
Reference in New Issue
Block a user