Merge pull request #24291 from taosdata/fix/TD-27521-3.0
taos shell remove assert for check cursor position error
This commit is contained in:
commit
3d8fb17bfe
|
@ -66,6 +66,7 @@ typedef struct {
|
|||
char file[PATH_MAX];
|
||||
char password[TSDB_USET_PASSWORD_LEN];
|
||||
bool is_gen_auth;
|
||||
bool is_bi_mode;
|
||||
bool is_raw_time;
|
||||
bool is_version;
|
||||
bool is_dump_config;
|
||||
|
|
|
@ -44,6 +44,7 @@
|
|||
#define SHELL_NET_ROLE "Net role when network connectivity test, options: client|server."
|
||||
#define SHELL_PKT_LEN "Packet length used for net test, default is 1024 bytes."
|
||||
#define SHELL_PKT_NUM "Packet numbers used for net test, default is 100."
|
||||
#define SHELL_BI_MODE "Set BI mode"
|
||||
#define SHELL_VERSION "Print program version."
|
||||
|
||||
#ifdef WEBSOCKET
|
||||
|
@ -59,6 +60,7 @@ void shellPrintHelp() {
|
|||
printf("Usage: taos [OPTION...] \r\n\r\n");
|
||||
printf("%s%s%s%s\r\n", indent, "-a,", indent, SHELL_AUTH);
|
||||
printf("%s%s%s%s\r\n", indent, "-A,", indent, SHELL_GEN_AUTH);
|
||||
printf("%s%s%s%s\r\n", indent, "-B,", indent, SHELL_BI_MODE);
|
||||
printf("%s%s%s%s\r\n", indent, "-c,", indent, SHELL_CFG_DIR);
|
||||
printf("%s%s%s%s\r\n", indent, "-C,", indent, SHELL_DMP_CFG);
|
||||
printf("%s%s%s%s\r\n", indent, "-d,", indent, SHELL_DB);
|
||||
|
@ -127,6 +129,7 @@ static struct argp_option shellOptions[] = {
|
|||
{"timeout", 'T', "SECONDS", 0, SHELL_TIMEOUT},
|
||||
#endif
|
||||
{"pktnum", 'N', "PKTNUM", 0, SHELL_PKT_NUM},
|
||||
{"bimode", 'B', 0, 0, SHELL_BI_MODE},
|
||||
{0},
|
||||
};
|
||||
|
||||
|
@ -173,6 +176,9 @@ static int32_t shellParseSingleOpt(int32_t key, char *arg) {
|
|||
case 'A':
|
||||
pArgs->is_gen_auth = true;
|
||||
break;
|
||||
case 'B':
|
||||
pArgs->is_bi_mode = true;
|
||||
break;
|
||||
case 'c':
|
||||
#ifdef WEBSOCKET
|
||||
pArgs->cloud = false;
|
||||
|
|
|
@ -62,7 +62,6 @@ int32_t shellCountPrefixOnes(uint8_t c) {
|
|||
}
|
||||
|
||||
void shellGetPrevCharSize(const char *str, int32_t pos, int32_t *size, int32_t *width) {
|
||||
ASSERT(pos > 0);
|
||||
if (pos <= 0) return;
|
||||
|
||||
TdWchar wc;
|
||||
|
@ -82,7 +81,6 @@ void shellGetPrevCharSize(const char *str, int32_t pos, int32_t *size, int32_t *
|
|||
}
|
||||
|
||||
void shellGetNextCharSize(const char *str, int32_t pos, int32_t *size, int32_t *width) {
|
||||
ASSERT(pos >= 0);
|
||||
if(pos < 0) return;
|
||||
|
||||
TdWchar wc;
|
||||
|
@ -91,7 +89,6 @@ void shellGetNextCharSize(const char *str, int32_t pos, int32_t *size, int32_t *
|
|||
}
|
||||
|
||||
void shellInsertChar(SShellCmd *cmd, char *c, int32_t size) {
|
||||
ASSERT(cmd->cursorOffset <= cmd->commandSize && cmd->endOffset >= cmd->screenOffset);
|
||||
if(cmd->cursorOffset > cmd->commandSize || cmd->endOffset < cmd->screenOffset) return;
|
||||
|
||||
TdWchar wc;
|
||||
|
@ -138,7 +135,6 @@ void shellInsertStr(SShellCmd *cmd, char *str, int32_t size) {
|
|||
}
|
||||
|
||||
void shellBackspaceChar(SShellCmd *cmd) {
|
||||
ASSERT(cmd->cursorOffset <= cmd->commandSize && cmd->endOffset >= cmd->screenOffset);
|
||||
if(cmd->cursorOffset > cmd->commandSize || cmd->endOffset < cmd->screenOffset) return;
|
||||
|
||||
if (cmd->cursorOffset > 0) {
|
||||
|
@ -159,7 +155,6 @@ void shellBackspaceChar(SShellCmd *cmd) {
|
|||
}
|
||||
|
||||
void shellClearLineBefore(SShellCmd *cmd) {
|
||||
ASSERT(cmd->cursorOffset <= cmd->commandSize && cmd->endOffset >= cmd->screenOffset);
|
||||
if(cmd->cursorOffset > cmd->commandSize || cmd->endOffset < cmd->screenOffset) return;
|
||||
|
||||
shellClearScreen(cmd->endOffset + PSIZE, cmd->screenOffset + PSIZE);
|
||||
|
@ -174,7 +169,6 @@ void shellClearLineBefore(SShellCmd *cmd) {
|
|||
}
|
||||
|
||||
void shellClearLineAfter(SShellCmd *cmd) {
|
||||
ASSERT(cmd->cursorOffset <= cmd->commandSize && cmd->endOffset >= cmd->screenOffset);
|
||||
if(cmd->cursorOffset > cmd->commandSize || cmd->endOffset < cmd->screenOffset) return;
|
||||
|
||||
shellClearScreen(cmd->endOffset + PSIZE, cmd->screenOffset + PSIZE);
|
||||
|
@ -184,7 +178,6 @@ void shellClearLineAfter(SShellCmd *cmd) {
|
|||
}
|
||||
|
||||
void shellDeleteChar(SShellCmd *cmd) {
|
||||
ASSERT(cmd->cursorOffset <= cmd->commandSize && cmd->endOffset >= cmd->screenOffset);
|
||||
if(cmd->cursorOffset > cmd->commandSize || cmd->endOffset < cmd->screenOffset) return;
|
||||
|
||||
if (cmd->cursorOffset < cmd->commandSize) {
|
||||
|
@ -203,7 +196,6 @@ void shellDeleteChar(SShellCmd *cmd) {
|
|||
}
|
||||
|
||||
void shellMoveCursorLeft(SShellCmd *cmd) {
|
||||
ASSERT(cmd->cursorOffset <= cmd->commandSize && cmd->endOffset >= cmd->screenOffset);
|
||||
if(cmd->cursorOffset > cmd->commandSize || cmd->endOffset < cmd->screenOffset) return;
|
||||
|
||||
if (cmd->cursorOffset > 0) {
|
||||
|
@ -218,7 +210,6 @@ void shellMoveCursorLeft(SShellCmd *cmd) {
|
|||
}
|
||||
|
||||
void shellMoveCursorRight(SShellCmd *cmd) {
|
||||
ASSERT(cmd->cursorOffset <= cmd->commandSize && cmd->endOffset >= cmd->screenOffset);
|
||||
if(cmd->cursorOffset > cmd->commandSize || cmd->endOffset < cmd->screenOffset) return;
|
||||
|
||||
if (cmd->cursorOffset < cmd->commandSize) {
|
||||
|
@ -233,7 +224,6 @@ void shellMoveCursorRight(SShellCmd *cmd) {
|
|||
}
|
||||
|
||||
void shellPositionCursorHome(SShellCmd *cmd) {
|
||||
ASSERT(cmd->cursorOffset <= cmd->commandSize && cmd->endOffset >= cmd->screenOffset);
|
||||
if(cmd->cursorOffset > cmd->commandSize || cmd->endOffset < cmd->screenOffset) return;
|
||||
|
||||
if (cmd->cursorOffset > 0) {
|
||||
|
@ -254,7 +244,6 @@ void positionCursorMiddle(SShellCmd *cmd) {
|
|||
}
|
||||
|
||||
void shellPositionCursorEnd(SShellCmd *cmd) {
|
||||
ASSERT(cmd->cursorOffset <= cmd->commandSize && cmd->endOffset >= cmd->screenOffset);
|
||||
if(cmd->cursorOffset > cmd->commandSize || cmd->endOffset < cmd->screenOffset) return;
|
||||
|
||||
if (cmd->cursorOffset < cmd->commandSize) {
|
||||
|
@ -290,7 +279,6 @@ void shellPositionCursor(int32_t step, int32_t direction) {
|
|||
}
|
||||
|
||||
void shellUpdateBuffer(SShellCmd *cmd) {
|
||||
ASSERT(cmd->cursorOffset <= cmd->commandSize && cmd->endOffset >= cmd->screenOffset);
|
||||
if(cmd->cursorOffset > cmd->commandSize || cmd->endOffset < cmd->screenOffset) return;
|
||||
|
||||
if (shellRegexMatch(cmd->buffer, "(\\s+$)|(^$)", REG_EXTENDED)) strcat(cmd->command, " ");
|
||||
|
@ -306,7 +294,6 @@ void shellUpdateBuffer(SShellCmd *cmd) {
|
|||
}
|
||||
|
||||
bool shellIsReadyGo(SShellCmd *cmd) {
|
||||
ASSERT(cmd->cursorOffset <= cmd->commandSize && cmd->endOffset >= cmd->screenOffset);
|
||||
if(cmd->cursorOffset > cmd->commandSize || cmd->endOffset < cmd->screenOffset) return false;
|
||||
|
||||
char *total = (char *)taosMemoryCalloc(1, SHELL_MAX_COMMAND_SIZE);
|
||||
|
@ -334,7 +321,6 @@ void shellGetMbSizeInfo(const char *str, int32_t *size, int32_t *width) {
|
|||
}
|
||||
|
||||
void shellResetCommand(SShellCmd *cmd, const char s[]) {
|
||||
ASSERT(cmd->cursorOffset <= cmd->commandSize && cmd->endOffset >= cmd->screenOffset);
|
||||
if(cmd->cursorOffset > cmd->commandSize || cmd->endOffset < cmd->screenOffset) return;
|
||||
|
||||
shellClearScreen(cmd->endOffset + PSIZE, cmd->screenOffset + PSIZE);
|
||||
|
|
|
@ -1291,6 +1291,16 @@ int32_t shellExecute() {
|
|||
shellSetConn(shell.conn, runOnce);
|
||||
shellReadHistory();
|
||||
|
||||
if(shell.args.is_bi_mode) {
|
||||
// need set bi mode
|
||||
printf("Set BI mode is true.\n");
|
||||
#ifdef WEBSOCKET
|
||||
//ws_taos_set_conn_mode(shell.ws_conn, TAOS_CONN_MODE_BI, 1);
|
||||
#else
|
||||
taos_set_conn_mode(shell.conn, TAOS_CONN_MODE_BI, 1);
|
||||
#endif
|
||||
}
|
||||
|
||||
if (runOnce) {
|
||||
if (pArgs->commands != NULL) {
|
||||
printf("%s%s\r\n", shell.info.promptHeader, pArgs->commands);
|
||||
|
|
Loading…
Reference in New Issue