diff --git a/src/ansi.c b/src/ansi.c index 99a9e81768cd86a9940cb479478a2808a141415d..52d605c7a6ce33167d482ffd1b6316a7bf6c388a 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 0941ed3d3bfd1960d0f15d5a6c400401d0e6c401..dd31ad20800fce92e8f37f9a72b6b2bc7b74fac8 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 4cee3fc13cc2005f1d177c1aa6b0d4872699ec35..1625b5e8418d69b15b033cb21eaf0358994eaaea 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);