From f025daaae4743d055983f9cfd639f90449a72c4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=B1=E8=BF=99=E6=A0=B7=2E=2E=2E?= Date: Fri, 21 Feb 2025 18:01:32 +0800 Subject: [PATCH] =?UTF-8?q?1.=E8=A7=A3=E5=86=B3=E6=8C=89F2~F4=EF=BC=8C?= =?UTF-8?q?=E8=AE=BE=E5=A4=87=E9=87=8D=E5=90=AF=E7=9A=84=E9=97=AE=E9=A2=98?= =?UTF-8?q?=EF=BC=9B2.=E8=A7=A3=E5=86=B3=E4=BD=BF=E7=94=A8NR=5FSHELL=5FUSI?= =?UTF-8?q?NG=5FEXPORT=5FCMD=E6=97=B6=EF=BC=8Ctab=E6=8C=89=E9=94=AE?= =?UTF-8?q?=E5=8C=B9=E9=85=8D=E4=B8=8D=E5=88=B0=EF=BC=8C=E8=AE=BE=E5=A4=87?= =?UTF-8?q?=E6=8C=82=E6=AD=BB=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/ansi.c | 19 +++++++++++-------- src/ansi_port.c | 6 +++--- src/nr_micro_shell.c | 10 +++++----- 3 files changed, 19 insertions(+), 16 deletions(-) diff --git a/src/ansi.c b/src/ansi.c index 99a9e81..52d605c 100644 --- a/src/ansi.c +++ b/src/ansi.c @@ -67,7 +67,8 @@ void (*const nr_ansi_in_special_symbol_fun[])(ansi_st *) = nr_ansi_in_bsb_function, nr_ansi_in_bsn_function, nr_ansi_in_bsr_function, - nr_ansi_in_bst_function}; + nr_ansi_in_bst_function + }; int ansi_search_char(char x, const char *buf) { @@ -87,7 +88,7 @@ int ansi_search_char(char x, const char *buf) enum { ANSI_NO_CTRL_CHAR, - ANSI_MAYBE_CTRL_CHAR, + ANSI_MAYBE_CTRL_CHAR, ANSI_WAIT_CTRL_CHAR_END, }; @@ -128,11 +129,11 @@ char ansi_get_char(char x, ansi_st *ansi) { ansi->combine_state = ANSI_WAIT_CTRL_CHAR_END; ansi->combine_buf[ansi->cmd_num] = x; - ansi->cmd_num++; + ansi->cmd_num++; } else { - nr_ansi_common_char_slover(ansi,x); + nr_ansi_common_char_slover(ansi, x); } } else if (ansi->combine_state == ANSI_WAIT_CTRL_CHAR_END) @@ -142,10 +143,12 @@ char ansi_get_char(char x, ansi_st *ansi) if (('a' <= x && 'z' >= x) || ('A' <= x && 'Z' >= x) || x== '~') { cmd_id = ansi_search_char(x, nr_ansi_in_cmd); - nr_ansi_in_cmd_fun[cmd_id](ansi); - - ansi->cmd_num = 0; - ansi->combine_state = ANSI_NO_CTRL_CHAR; + if (-1 != cmd_id) + { + nr_ansi_in_cmd_fun[cmd_id](ansi); + ansi->cmd_num = 0; + ansi->combine_state = ANSI_NO_CTRL_CHAR; + } } else if (ansi->cmd_num > 18) { diff --git a/src/ansi_port.c b/src/ansi_port.c index 0941ed3..dd31ad2 100644 --- a/src/ansi_port.c +++ b/src/ansi_port.c @@ -92,7 +92,7 @@ void nr_ansi_ctrl_common_slover(ansi_st *ansi) unsigned int i; for (i = 0; i < ansi->cmd_num; i++) { - ansi_show_char((*(ansi->combine_buf + i))); + ansi_show_char(ansi->combine_buf[i]); } } @@ -100,7 +100,7 @@ void nr_ansi_ctrl_common_slover(ansi_st *ansi) void nr_ansi_in_enter(ansi_st *ansi) { #if NR_SHELL_END_OF_LINE == 1 - ansi->p = -1; + ansi->p = -1; ansi->counter = 0; nr_shell.cmd_his.index = nr_shell.cmd_his.len; @@ -114,7 +114,7 @@ void nr_ansi_in_enter(ansi_st *ansi) // line break '\n' processing void nr_ansi_in_newline(ansi_st *ansi) { - ansi->p = -1; + ansi->p = -1; ansi->counter = 0; nr_shell.cmd_his.index = nr_shell.cmd_his.len; diff --git a/src/nr_micro_shell.c b/src/nr_micro_shell.c index 4cee3fc..1625b5e 100644 --- a/src/nr_micro_shell.c +++ b/src/nr_micro_shell.c @@ -40,9 +40,9 @@ NR_SHELL_CMD_EXPORT_START(0,NULL); NR_SHELL_CMD_EXPORT_END(n,NULL); shell_st nr_shell = - { - .user_name = NR_SHELL_USER_NAME, - .static_cmd = nr_cmd_start_add, +{ + .user_name = NR_SHELL_USER_NAME, + .static_cmd = nr_cmd_start_add, }; static char *nr_shell_strtok(char *string_org, const char *demial) @@ -89,7 +89,7 @@ static char *nr_shell_strtok(char *string_org, const char *demial) } else { - return string_org; + return string_org; } } @@ -189,7 +189,7 @@ char *shell_cmd_complete(shell_st *shell, char *str) char *best_matched = NULL; unsigned char min_position = 255; - for (i = 0; shell->static_cmd[i].cmd[0] != '\0'; i++) + for (i = 0; shell->static_cmd[i].fp != NULL; i++) { temp = NULL; temp = strstr(shell->static_cmd[i].cmd, str); -- Gitee