diff --git a/src/kit/shell/src/shellWindows.c b/src/kit/shell/src/shellWindows.c index 223149126330524b89378ecb60effb05d5adf795..0babd88333c846c1f0b5dbe4baede4a6d38cbcdd 100644 --- a/src/kit/shell/src/shellWindows.c +++ b/src/kit/shell/src/shellWindows.c @@ -17,6 +17,8 @@ #include "taos.h" #include "shellCommand.h" +#define SHELL_INPUT_MAX_COMMAND_SIZE 500000 + extern char configDir[]; char WINCLIENT_VERSION[] = "Welcome to the TDengine shell from %s, Client Version:%s\n" @@ -274,32 +276,35 @@ int32_t shellReadCommand(TAOS *con, char command[]) { // Read input. void *console = GetStdHandle(STD_INPUT_HANDLE); unsigned long read; - wchar_t c; + wchar_t *c= (wchar_t *)calloc(SHELL_INPUT_MAX_COMMAND_SIZE, sizeof(wchar_t)); char mbStr[16]; while (1) { - int ret = ReadConsole(console, &c, 1, &read, NULL); - int size = WideCharToMultiByte(CP_UTF8, 0, &c, read, mbStr, sizeof(mbStr), NULL, NULL); - mbStr[size] = 0; - switch (c) { - case '\n': - if (isReadyGo(&cmd)) { - sprintf(command, "%s%s", cmd.buffer, cmd.command); - free(cmd.buffer); - cmd.buffer = NULL; - free(cmd.command); - cmd.command = NULL; - return 0; - } else { - shellPrintContinuePrompt(); - updateBuffer(&cmd); - } - break; - case '\r': - break; - default: - for (int i = 0; i < size; ++i) { - insertChar(&cmd, mbStr[i]); - } + int ret = ReadConsole(console, c, SHELL_INPUT_MAX_COMMAND_SIZE, &read, NULL); + for (int input_index = 0; input_index < read; input_index++) { + int size = WideCharToMultiByte(CP_UTF8, 0, &c[input_index], 1, mbStr, sizeof(mbStr), NULL, NULL); + mbStr[size] = 0; + switch (c[input_index]) { + case '\n': + if (isReadyGo(&cmd)) { + sprintf(command, "%s%s", cmd.buffer, cmd.command); + free(cmd.buffer); + cmd.buffer = NULL; + free(cmd.command); + cmd.command = NULL; + free(c); + return 0; + } else { + shellPrintContinuePrompt(); + updateBuffer(&cmd); + } + break; + case '\r': + break; + default: + for (int i = 0; i < size; ++i) { + insertChar(&cmd, mbStr[i]); + } + } } }