优化代码,修改 FALLTHROUGH 宏定义,增加递归互斥锁支持,改进调度器挂起和恢复逻辑,增强命令查找功能
This commit is contained in:
@@ -126,6 +126,18 @@ static const char *_skipwhite(const char *q);
|
||||
static double _strtod(const char *str, char **end); // https://gitee.com/mirrors_mattn/strtod/blob/master/strtod.c
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief 在所有命令列表中,查找注册的命令。
|
||||
* 函数会根据 save_depth 参数,保存当前命令的索引值,
|
||||
* 当下次调用时,函数会从上次保存的位置开始查找。
|
||||
*
|
||||
* @param sh_hdl 由 sh_init_vt100() 初始化的对象
|
||||
* @param new_list 允许临时插入的命令列表,这个列表在最后查找
|
||||
* @param save_depth 记录查找索引值 uint16_t save_depth[_MAX_SAVE_DEPTH] = {0};
|
||||
* @param argc 命令数量
|
||||
* @param argv 命令字符串指针
|
||||
* @return sh_cmd_info_t
|
||||
*/
|
||||
static sh_cmd_info_t _find_registered_command(sh_t *sh_hdl,
|
||||
sys_pslist_t *new_list,
|
||||
uint16_t save_depth[_MAX_SAVE_DEPTH],
|
||||
@@ -3297,6 +3309,7 @@ SH_CMD_FN(_cmd_print_which)
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint16_t last_depth[_MAX_SAVE_DEPTH] = {0};
|
||||
for (int i = 0; true; i++)
|
||||
{
|
||||
sh_cmd_info_t cp_info = _find_registered_command(sh_hdl, NULL, cp_param.save_depth, argc, argv);
|
||||
@@ -3332,6 +3345,7 @@ SH_CMD_FN(_cmd_print_which)
|
||||
uint16_t save_depth[_MAX_SAVE_DEPTH] = {0};
|
||||
for (int i = 1; i <= cp_info.cmd_count; i++)
|
||||
{
|
||||
memcpy(save_depth, last_depth, sizeof(save_depth));
|
||||
sh_cmd_info_t tmp = _find_registered_command(sh_hdl, NULL, save_depth, i, argv);
|
||||
|
||||
if (i == 1)
|
||||
@@ -3348,7 +3362,14 @@ SH_CMD_FN(_cmd_print_which)
|
||||
{
|
||||
sh_echo(sh_hdl, " ");
|
||||
}
|
||||
sh_echo(sh_hdl, "-- %s\r\n", tmp.match_cmd->help);
|
||||
if (tmp.match_cmd && tmp.match_cmd->help)
|
||||
{
|
||||
sh_echo(sh_hdl, "-- %s\r\n", tmp.match_cmd->help);
|
||||
}
|
||||
else
|
||||
{
|
||||
sh_echo(sh_hdl, "\r\n");
|
||||
}
|
||||
|
||||
if (i == cp_info.cmd_count)
|
||||
{
|
||||
@@ -3370,6 +3391,8 @@ SH_CMD_FN(_cmd_print_which)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
memcpy(last_depth, cp_param.save_depth, sizeof(last_depth));
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user