1
0
mirror of https://github.com/fumiama/CMoe-Counter.git synced 2024-11-30 16:24:28 +01:00

fix(compile): 'for' loop initial declarations are only allowed in C99 mode

This commit is contained in:
源文雨 2024-04-12 23:04:33 +09:00
parent 538e120d45
commit d3385953db
2 changed files with 5 additions and 9 deletions

View File

@ -5,12 +5,6 @@ SET(CMAKE_BUILD_TYPE "Release")
include_directories("/usr/local/include") include_directories("/usr/local/include")
link_directories("/usr/local/lib") link_directories("/usr/local/lib")
if (NOT BUILD STREQUAL "docker")
#c99
add_compile_options(-std=c99)
message(STATUS "optional:-std=c99")
endif ()
add_executable(cmoe cmoe.c) add_executable(cmoe cmoe.c)
add_executable(cmoeditor editor.c) add_executable(cmoeditor editor.c)

8
cmoe.c
View File

@ -83,7 +83,8 @@ static inline int add_user(char* name, uint32_t count, FILE* fp) {
static inline uint32_t get_content_len(int isbig, uint16_t* len_type, char* cntstr) { static inline uint32_t get_content_len(int isbig, uint16_t* len_type, char* cntstr) {
uint32_t len = sizeof(svg_small) // small & big has the same len uint32_t len = sizeof(svg_small) // small & big has the same len
+ sizeof(svg_tail) - 1; + sizeof(svg_tail) - 1;
for (int i = 0; cntstr[i]; i++) { int i = 0;
for (; cntstr[i]; i++) {
len += len_type[cntstr[i] - '0'] + (sizeof(img_slot_front) + sizeof(img_slot_rear) - 2); len += len_type[cntstr[i] - '0'] + (sizeof(img_slot_front) + sizeof(img_slot_rear) - 2);
if (i > 0) len++; if (i > 0) len++;
if (i > 2-isbig) len++; if (i > 2-isbig) len++;
@ -111,7 +112,8 @@ static void return_count(FILE* fp, char* name, char* theme) {
char cntstrbuf[11]; char cntstrbuf[11];
sprintf(cntstrbuf, "%010u", d->count); sprintf(cntstrbuf, "%010u", d->count);
char* cntstr = cntstrbuf; char* cntstr = cntstrbuf;
for (int i = 0; i < 10; i++) if (cntstrbuf[i] != '0') { int i = 0;
for (; i < 10; i++) if (cntstrbuf[i] != '0') {
if (i > 2) cntstr = cntstrbuf+i-2; if (i > 2) cntstr = cntstrbuf+i-2;
break; break;
} }
@ -143,7 +145,7 @@ static void return_count(FILE* fp, char* name, char* theme) {
return; return;
} }
printf(head, w*(10+cntstrbuf-cntstr)); printf(head, w*(10+cntstrbuf-cntstr));
for (int i = 0; cntstr[i]; i++) { for (i = 0; cntstr[i]; i++) {
printf(img_slot_front, w * i, w, h); printf(img_slot_front, w * i, w, h);
int n = cntstr[i] - '0'; int n = cntstr[i] - '0';
fwrite(theme_type[n], len_type[n], 1, stdout); fwrite(theme_type[n], len_type[n], 1, stdout);