未验证 提交 e3ac2572 编写于 作者: M Minglei Jin 提交者: GitHub

Merge pull request #8828 from taosdata/fix/ZhiqiangWang/TS-711-windows-shell-limit-254-char-err

[TS-711]<fix>: windows shell limit 254 char error.
...@@ -17,6 +17,8 @@ ...@@ -17,6 +17,8 @@
#include "taos.h" #include "taos.h"
#include "shellCommand.h" #include "shellCommand.h"
#define SHELL_INPUT_MAX_COMMAND_SIZE 500000
extern char configDir[]; extern char configDir[];
char WINCLIENT_VERSION[] = "Welcome to the TDengine shell from %s, Client Version:%s\n" char WINCLIENT_VERSION[] = "Welcome to the TDengine shell from %s, Client Version:%s\n"
...@@ -258,13 +260,14 @@ int32_t shellReadCommand(TAOS *con, char command[]) { ...@@ -258,13 +260,14 @@ int32_t shellReadCommand(TAOS *con, char command[]) {
// Read input. // Read input.
void *console = GetStdHandle(STD_INPUT_HANDLE); void *console = GetStdHandle(STD_INPUT_HANDLE);
unsigned long read; unsigned long read;
wchar_t c; wchar_t *c= (wchar_t *)calloc(SHELL_INPUT_MAX_COMMAND_SIZE, sizeof(wchar_t));
char mbStr[16]; char mbStr[16];
while (1) { while (1) {
int ret = ReadConsole(console, &c, 1, &read, NULL); int ret = ReadConsole(console, c, SHELL_INPUT_MAX_COMMAND_SIZE, &read, NULL);
int size = WideCharToMultiByte(CP_UTF8, 0, &c, read, mbStr, sizeof(mbStr), NULL, 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; mbStr[size] = 0;
switch (c) { switch (c[input_index]) {
case '\n': case '\n':
if (isReadyGo(&cmd)) { if (isReadyGo(&cmd)) {
sprintf(command, "%s%s", cmd.buffer, cmd.command); sprintf(command, "%s%s", cmd.buffer, cmd.command);
...@@ -272,6 +275,7 @@ int32_t shellReadCommand(TAOS *con, char command[]) { ...@@ -272,6 +275,7 @@ int32_t shellReadCommand(TAOS *con, char command[]) {
cmd.buffer = NULL; cmd.buffer = NULL;
free(cmd.command); free(cmd.command);
cmd.command = NULL; cmd.command = NULL;
free(c);
return 0; return 0;
} else { } else {
shellPrintContinuePrompt(); shellPrintContinuePrompt();
...@@ -286,6 +290,7 @@ int32_t shellReadCommand(TAOS *con, char command[]) { ...@@ -286,6 +290,7 @@ int32_t shellReadCommand(TAOS *con, char command[]) {
} }
} }
} }
}
return 0; return 0;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册