From 2316e3144cf7fea891df57d101403457b497c499 Mon Sep 17 00:00:00 2001 From: Yerolling <2911328695@qq.com> Date: Tue, 24 May 2022 21:16:51 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BA=86PrintState?= =?UTF-8?q?=E5=87=BD=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/bus_io.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/bus_io.c b/src/bus_io.c index e46aa08..364c1f2 100644 --- a/src/bus_io.c +++ b/src/bus_io.c @@ -151,12 +151,13 @@ void PrintState(char *str) { memset(str, 0, 150); - int count; + int count, flag=1; //flag用于标记,为使下面第一个循环能够进入 rail_node_t *p = NULL; char target[20], clockwise[20], counterclockwise[20]; - for (count = 0, p = rails; p != NULL; p = p->next_node, count++) + for (count = 0, p = rails; flag==1 || p != NULL; p = p->next_node, count++) { + flag=0; target[count] = '0'; clockwise[count] = '0'; counterclockwise[count] = '0'; From 30c7d92bfd9c30af761f02b707664af37dcce983 Mon Sep 17 00:00:00 2001 From: Yerolling <2911328695@qq.com> Date: Tue, 24 May 2022 21:18:19 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BA=86PrintState?= =?UTF-8?q?=E5=87=BD=E6=95=B0=E4=B8=AD=E8=AE=A1=E6=95=B0=E6=95=B0=E7=BB=84?= =?UTF-8?q?=E7=9A=84=E5=A4=A7=E5=B0=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/bus_io.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bus_io.c b/src/bus_io.c index 364c1f2..d17ffcc 100644 --- a/src/bus_io.c +++ b/src/bus_io.c @@ -153,7 +153,7 @@ void PrintState(char *str) int count, flag=1; //flag用于标记,为使下面第一个循环能够进入 rail_node_t *p = NULL; - char target[20], clockwise[20], counterclockwise[20]; + char target[25], clockwise[25], counterclockwise[25]; for (count = 0, p = rails; flag==1 || p != NULL; p = p->next_node, count++) { From 9e6faf16bfb749c15738e112d78df1b73d55d27f Mon Sep 17 00:00:00 2001 From: Yerolling <2911328695@qq.com> Date: Tue, 24 May 2022 21:20:33 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BA=86PrintState?= =?UTF-8?q?=E5=87=BD=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/bus_io.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bus_io.c b/src/bus_io.c index d17ffcc..ab623a8 100644 --- a/src/bus_io.c +++ b/src/bus_io.c @@ -155,7 +155,7 @@ void PrintState(char *str) rail_node_t *p = NULL; char target[25], clockwise[25], counterclockwise[25]; - for (count = 0, p = rails; flag==1 || p != NULL; p = p->next_node, count++) + for (count = 0, p = rails; flag==1 || p != rails; p = p->next_node, count++) { flag=0; target[count] = '0'; From d96c1747035a90e077eae905ed5838a388cac68c Mon Sep 17 00:00:00 2001 From: Yerolling <2911328695@qq.com> Date: Tue, 24 May 2022 21:22:57 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BA=86PrintState?= =?UTF-8?q?=E5=87=BD=E6=95=B0=E4=B8=AD=E7=9A=84=E9=83=A8=E5=88=86=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E9=A3=8E=E6=A0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/bus_io.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/bus_io.c b/src/bus_io.c index ab623a8..c6126fd 100644 --- a/src/bus_io.c +++ b/src/bus_io.c @@ -151,11 +151,11 @@ void PrintState(char *str) { memset(str, 0, 150); - int count, flag=1; //flag用于标记,为使下面第一个循环能够进入 + int count, flag = 1; //flag用于标记,为使下面第一个循环能够进入 rail_node_t *p = NULL; char target[25], clockwise[25], counterclockwise[25]; - for (count = 0, p = rails; flag==1 || p != rails; p = p->next_node, count++) + for (count = 0, p = rails; flag == 1 || p != rails; p = p->next_node, count++) { flag=0; target[count] = '0'; From 8485eef361b0fee988c4207cc3d81b5a58933f50 Mon Sep 17 00:00:00 2001 From: Yerolling <2911328695@qq.com> Date: Tue, 24 May 2022 21:37:30 +0800 Subject: [PATCH 5/5] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BA=86PrintState?= =?UTF-8?q?=E5=87=BD=E6=95=B0=E4=B8=AD=E5=AD=97=E7=AC=A6=E4=B8=B2=E6=95=B0?= =?UTF-8?q?=E7=BB=84=E6=9C=AA=E5=8A=A0=E7=BB=88=E6=AD=A2=E7=AC=A6=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/bus_io.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/bus_io.c b/src/bus_io.c index c6126fd..a491f6a 100644 --- a/src/bus_io.c +++ b/src/bus_io.c @@ -162,7 +162,10 @@ void PrintState(char *str) clockwise[count] = '0'; counterclockwise[count] = '0'; } //遍历轨道链表,将所有站点初始化为0,即:无任何请求; - + target[count] = '\0'; + clockwise[count] = '\0'; + counterclockwise[count] = '\0'; + bus_query_t *t = NULL; int i; for (t = queries; t != NULL; t = t->next_node)