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