修复扩展中的一些bug
This commit is contained in:
parent
579b3b92d0
commit
65abcabe94
|
@ -33,7 +33,7 @@ static int list_test(int argc, char* argv[])
|
|||
|
||||
xcmd_print(xcmder, "list_add: \r\n");
|
||||
list_for_each(pos, &stu1.stu_list) {
|
||||
xcmd_print(xcmder, "ID = %d,math = %d\n",((struct student*)pos)->ID,((struct student*)pos)->math);
|
||||
xcmd_print(xcmder, "ID = %d,math = %d\r\n",((struct student*)pos)->ID,((struct student*)pos)->math);
|
||||
}
|
||||
|
||||
//尾插法创建stu stu1链表
|
||||
|
@ -49,7 +49,7 @@ static int list_test(int argc, char* argv[])
|
|||
|
||||
xcmd_print(xcmder, "list_add_tail: \r\n");
|
||||
list_for_each(pos, &stu2.stu_list) {
|
||||
xcmd_print(xcmder, "ID = %d,math = %d\n",((struct student*)pos)->ID,((struct student*)pos)->math);
|
||||
xcmd_print(xcmder, "ID = %d,math = %d\r\n",((struct student*)pos)->ID,((struct student*)pos)->math);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -81,7 +81,7 @@ static int list_note_del(int argc, char* argv[])
|
|||
|
||||
xcmd_print(xcmder, "list_add: \r\n");
|
||||
list_for_each(pos1, &stu1.stu_list) {
|
||||
xcmd_print(xcmder, "ID = %d,math = %d\n",((struct student*)pos1)->ID,((struct student*)pos1)->math);
|
||||
xcmd_print(xcmder, "ID = %d,math = %d\r\n",((struct student*)pos1)->ID,((struct student*)pos1)->math);
|
||||
}
|
||||
|
||||
//删除
|
||||
|
@ -94,7 +94,7 @@ static int list_note_del(int argc, char* argv[])
|
|||
|
||||
xcmd_print(xcmder, "list_del\r\n");
|
||||
list_for_each_entry(pos2,&stu1.stu_list,stu_list) {
|
||||
xcmd_print(xcmder, "ID = %d,math = %d\n",pos2->ID,pos2->math);
|
||||
xcmd_print(xcmder, "ID = %d,math = %d\r\n",pos2->ID,pos2->math);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -125,7 +125,7 @@ static int list_note_rep(int argc, char* argv[])
|
|||
}
|
||||
xcmd_print(xcmder, "list_add: \r\n");
|
||||
list_for_each(pos1, &stu1.stu_list) {
|
||||
xcmd_print(xcmder, "ID = %d,math = %d\n",((struct student*)pos1)->ID,((struct student*)pos1)->math);
|
||||
xcmd_print(xcmder, "ID = %d,math = %d\r\n",((struct student*)pos1)->ID,((struct student*)pos1)->math);
|
||||
}
|
||||
|
||||
//替换
|
||||
|
@ -137,7 +137,7 @@ static int list_note_rep(int argc, char* argv[])
|
|||
}
|
||||
xcmd_print(xcmder, "list_replace\r\n");
|
||||
list_for_each_entry(pos2,&stu1.stu_list,stu_list) {
|
||||
xcmd_print(xcmder, "ID = %d,math = %d\n",pos2->ID,pos2->math);
|
||||
xcmd_print(xcmder, "ID = %d,math = %d\r\n",pos2->ID,pos2->math);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -168,7 +168,7 @@ static int list_note_del_insert(int argc, char* argv[])
|
|||
}
|
||||
xcmd_print(xcmder, "list_add: \r\n");
|
||||
list_for_each(pos1, &stu1.stu_list) {
|
||||
xcmd_print(xcmder, "ID = %d,math = %d\n",((struct student*)pos1)->ID,((struct student*)pos1)->math);
|
||||
xcmd_print(xcmder, "ID = %d,math = %d\r\n",((struct student*)pos1)->ID,((struct student*)pos1)->math);
|
||||
}
|
||||
|
||||
//移位替换
|
||||
|
@ -180,7 +180,7 @@ static int list_note_del_insert(int argc, char* argv[])
|
|||
}
|
||||
xcmd_print(xcmder, "list_move\r\n");
|
||||
list_for_each_entry(pos2,&stu1.stu_list,stu_list) {
|
||||
xcmd_print(xcmder, "ID = %d,math = %d\n",pos2->ID,pos2->math);
|
||||
xcmd_print(xcmder, "ID = %d,math = %d\r\n",pos2->ID,pos2->math);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -210,7 +210,7 @@ static int List_to_merge(int argc, char* argv[])
|
|||
}
|
||||
xcmd_print(xcmder, "stu1: \r\n");
|
||||
list_for_each(pos1, &stu1.stu_list) {
|
||||
xcmd_print(xcmder, "ID = %d,math = %d\n",((struct student*)pos1)->ID,((struct student*)pos1)->math);
|
||||
xcmd_print(xcmder, "ID = %d,math = %d\r\n",((struct student*)pos1)->ID,((struct student*)pos1)->math);
|
||||
}
|
||||
//头插法创建stu2 list 链表
|
||||
for (int i = 0;i < 3;i++) {
|
||||
|
@ -224,14 +224,14 @@ static int List_to_merge(int argc, char* argv[])
|
|||
}
|
||||
xcmd_print(xcmder, "stu2: \r\n");
|
||||
list_for_each(pos1, &stu2.stu_list) {
|
||||
xcmd_print(xcmder, "ID = %d,math = %d\n",((struct student*)pos1)->ID,((struct student*)pos1)->math);
|
||||
xcmd_print(xcmder, "ID = %d,math = %d\r\n",((struct student*)pos1)->ID,((struct student*)pos1)->math);
|
||||
}
|
||||
|
||||
//合并
|
||||
list_splice(&stu1.stu_list,&stu2.stu_list);
|
||||
xcmd_print(xcmder, "list_splice\r\n");
|
||||
list_for_each(pos1, &stu2.stu_list) {
|
||||
xcmd_print(xcmder, "stu2 ID = %d,math = %d\n",((struct student*)pos1)->ID,((struct student*)pos1)->math);
|
||||
xcmd_print(xcmder, "stu2 ID = %d,math = %d\r\n",((struct student*)pos1)->ID,((struct student*)pos1)->math);
|
||||
}
|
||||
|
||||
|
||||
|
@ -262,12 +262,12 @@ static int List_traverse(int argc, char* argv[])
|
|||
}
|
||||
xcmd_print(xcmder, "stu1: \r\n");
|
||||
list_for_each(pos1, &stu1.stu_list) {
|
||||
xcmd_print(xcmder, "ID = %d,math = %d\n",((struct student*)pos1)->ID,((struct student*)pos1)->math);
|
||||
xcmd_print(xcmder, "ID = %d,math = %d\r\n",((struct student*)pos1)->ID,((struct student*)pos1)->math);
|
||||
}
|
||||
|
||||
xcmd_print(xcmder, "list_for_each_prev\r\n");
|
||||
list_for_each_prev(pos1, &stu1.stu_list){
|
||||
xcmd_print(xcmder, "stu2 ID = %d,math = %d\n",((struct student*)pos1)->ID,((struct student*)pos1)->math);
|
||||
xcmd_print(xcmder, "stu2 ID = %d,math = %d\r\n",((struct student*)pos1)->ID,((struct student*)pos1)->math);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -46,56 +46,7 @@ static uint8_t param_check(int need, int argc, char*argv[])
|
|||
return ret;
|
||||
}
|
||||
|
||||
static int cmd_example(int argc, char* argv[])
|
||||
{
|
||||
xcmder_t *xcmder = XCMD_CURRENT();
|
||||
uint8_t i;
|
||||
if(param_check(1, argc, argv))
|
||||
{
|
||||
if(strcmp(argv[1], "-s") == 0)
|
||||
{
|
||||
for(i=2; i<argc; i++)
|
||||
{
|
||||
xcmd_print(xcmder, "%s\r\n", argv[i]);
|
||||
}
|
||||
}
|
||||
if(strcmp(argv[1], "-i") == 0)
|
||||
{
|
||||
for(i=2; i<argc; i++)
|
||||
{
|
||||
xcmd_print(xcmder, "%d\r\n", atoi(argv[i]));
|
||||
}
|
||||
}
|
||||
if(strcmp(argv[1], "-f") == 0)
|
||||
{
|
||||
for(i=2; i<argc; i++)
|
||||
{
|
||||
xcmd_print(xcmder, "%f\r\n", atof(argv[i]));
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int cmd_history(int argc, char* argv[])
|
||||
{
|
||||
xcmder_t *xcmder = XCMD_CURRENT();
|
||||
char out_line[XNR_LINE_MAX_LENGTH] = {0};
|
||||
int len = xnr_history_length(&xcmder->history);
|
||||
for(int i=0; i<len; i++)
|
||||
{
|
||||
if(xnr_history_get(&xcmder->history, i, out_line, XNR_LINE_MAX_LENGTH) > 0)
|
||||
{
|
||||
xcmd_print(xcmder, "%s\r\n", out_line);
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifndef ENABLE_XCMD_EXPORT
|
||||
static int cmd_delete_cmd(int argc, char* argv[])
|
||||
{
|
||||
xcmder_t *xcmder = XCMD_CURRENT();
|
||||
|
@ -131,7 +82,59 @@ error:
|
|||
xcmd_print(xcmder, "Too many parameters are entered or there is no command\r\n");
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
static int cmd_example(int argc, char* argv[])
|
||||
{
|
||||
xcmder_t *xcmder = XCMD_CURRENT();
|
||||
uint8_t i;
|
||||
if(param_check(1, argc, argv))
|
||||
{
|
||||
if(strcmp(argv[1], "-s") == 0)
|
||||
{
|
||||
for(i=2; i<argc; i++)
|
||||
{
|
||||
xcmd_print(xcmder, "%s\r\n", argv[i]);
|
||||
}
|
||||
}
|
||||
if(strcmp(argv[1], "-i") == 0)
|
||||
{
|
||||
for(i=2; i<argc; i++)
|
||||
{
|
||||
xcmd_print(xcmder, "%d\r\n", atoi(argv[i]));
|
||||
}
|
||||
}
|
||||
if(strcmp(argv[1], "-f") == 0)
|
||||
{
|
||||
for(i=2; i<argc; i++)
|
||||
{
|
||||
xcmd_print(xcmder, "%f\r\n", atof(argv[i]));
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
XCMD_EXPORT_CMD(example, cmd_example, "example [-f|-i|-s] [val]")
|
||||
|
||||
static int cmd_history(int argc, char* argv[])
|
||||
{
|
||||
xcmder_t *xcmder = XCMD_CURRENT();
|
||||
char out_line[XNR_LINE_MAX_LENGTH] = {0};
|
||||
int len = xnr_history_length(&xcmder->history);
|
||||
for(int i=0; i<len; i++)
|
||||
{
|
||||
if(xnr_history_get(&xcmder->history, i, out_line, XNR_LINE_MAX_LENGTH) > 0)
|
||||
{
|
||||
xcmd_print(xcmder, "%s\r\n", out_line);
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
XCMD_EXPORT_CMD(history, cmd_history, "show history list")
|
||||
|
||||
static int cmd_ctr_q(int argc, char* argv[])
|
||||
{
|
||||
|
@ -139,6 +142,7 @@ static int cmd_ctr_q(int argc, char* argv[])
|
|||
xcmd_print(xcmder, "this is ctr+q\n");
|
||||
return 0;
|
||||
}
|
||||
XCMD_EXPORT_KEY(KEY_CTR_Q, cmd_ctr_q, "ctr+q")
|
||||
|
||||
static int cmd_print_color(int argc, char* argv[])
|
||||
{
|
||||
|
@ -160,9 +164,6 @@ static int cmd_print_color(int argc, char* argv[])
|
|||
xcmd_print(xcmder, "%s\r\n", ANSI_BG_TXT(ANSI_BG_WHITE, "background_color = BK_WHITE"));
|
||||
return 0;
|
||||
}
|
||||
|
||||
XCMD_EXPORT_CMD(history, cmd_history, "show history list")
|
||||
XCMD_EXPORT_CMD(example, cmd_example, "example [-f|-i|-s] [val]")
|
||||
XCMD_EXPORT_CMD(color, cmd_print_color, "printf color text")
|
||||
|
||||
static xcmd_t cmds[] =
|
||||
|
|
Loading…
Reference in New Issue