From 65abcabe94b79545e06733454dfb2246758252e5 Mon Sep 17 00:00:00 2001 From: hqm <13720409820@163.com> Date: Mon, 3 Jul 2023 21:05:59 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=89=A9=E5=B1=95=E4=B8=AD?= =?UTF-8?q?=E7=9A=84=E4=B8=80=E4=BA=9Bbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- extensions/ex_list/ex_list.c | 26 ++++----- extensions/test/test.c | 107 ++++++++++++++++++----------------- 2 files changed, 67 insertions(+), 66 deletions(-) diff --git a/extensions/ex_list/ex_list.c b/extensions/ex_list/ex_list.c index f6ca57d..8318856 100644 --- a/extensions/ex_list/ex_list.c +++ b/extensions/ex_list/ex_list.c @@ -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; diff --git a/extensions/test/test.c b/extensions/test/test.c index a57d30e..f5f1aba 100644 --- a/extensions/test/test.c +++ b/extensions/test/test.c @@ -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; ihistory); - for(int i=0; ihistory, 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; ihistory); + for(int i=0; ihistory, 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[] =