From 0bc9d3d4784735753dbe580c21b0b712a5114207 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=BA=90=E6=96=87=E9=9B=A8?= <41315874+fumiama@users.noreply.github.com> Date: Wed, 2 Mar 2022 17:36:24 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=98=BE=E7=A4=BA=E9=95=BF?= =?UTF-8?q?=E5=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cmoe.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/cmoe.c b/cmoe.c index c5e8c2f..4e55b94 100644 --- a/cmoe.c +++ b/cmoe.c @@ -85,14 +85,12 @@ static int add_user(char* name, uint32_t count, FILE* fp) { } static uint32_t get_content_len(int isbig, uint16_t* len_type, char* cntstr) { - int i = 0; uint32_t len = sizeof(svg_small) - 1 + 16 + isbig + sizeof(svg_tail) - 1; - for(; cntstr[i]; i++) { - len += len_type[cntstr[i] - '0']; + for(int i = 0; cntstr[i]; i++) { + len += len_type[cntstr[i] - '0'] + (sizeof(img_slot_front) + sizeof(img_slot_rear) - 1); } - len += (sizeof(img_slot_front) + sizeof(img_slot_rear) - 1) * i; return len; } @@ -119,9 +117,9 @@ static void return_count(char* name, char* theme) { char cntstrbuf[11]; sprintf(cntstrbuf, "%010u", d->count); free(spb); - char* cntstr = cntstrbuf+9; - while(cntstr > cntstrbuf && *cntstr != '0') cntstr--; - if(cntstr-cntstrbuf > 1) cntstr--; // 保留 2 位 0 + char* cntstr; + for(cntstr = cntstrbuf+9; cntstr > cntstrbuf; cntstr--) if(*cntstr == '0') break; + if(cntstr != cntstrbuf) cntstr--; // 保留 2 位 0 int isbig = 0; char** theme_type = mb; uint16_t* len_type = mbl;