未验证 提交 c9dc670b 编写于 作者: wafwerar's avatar wafwerar 提交者: GitHub

[TS-711]<fix>: windows shell limit 254 char error. (#8827)

* [TS-711]<fix>: windows shell limit 254 char error.

* [TS-711]<fix>: windows shell limit 254 char error.
上级 87d794f4
......@@ -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]);
}
}
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册