style(core): for loops stylization
This commit is contained in:
parent
d90570962b
commit
0db444b65c
@ -65,7 +65,7 @@ int sappyou_load(Sappyou *sappyou) {
|
|||||||
temp.holes = calloc(temp.hole_cnt, sizeof(Tanzaku *));
|
temp.holes = calloc(temp.hole_cnt, sizeof(Tanzaku *));
|
||||||
size_t max_string_len = SIZE_MAX;
|
size_t max_string_len = SIZE_MAX;
|
||||||
Tanzaku *current_tanzaku = temp.database;
|
Tanzaku *current_tanzaku = temp.database;
|
||||||
for (uint64_t i = 0, r = temp.hole_cnt; i < temp.size; i++) {
|
for (uint64_t i = 0, r = temp.hole_cnt; i < temp.size; i++, current_tanzaku++) {
|
||||||
if (fgetc(temp.file) != 0) {
|
if (fgetc(temp.file) != 0) {
|
||||||
current_tanzaku->id = i;
|
current_tanzaku->id = i;
|
||||||
if (fread(¤t_tanzaku->created_ts, 8, 1, temp.file) != 1 ||
|
if (fread(¤t_tanzaku->created_ts, 8, 1, temp.file) != 1 ||
|
||||||
@ -86,7 +86,6 @@ int sappyou_load(Sappyou *sappyou) {
|
|||||||
r--;
|
r--;
|
||||||
temp.holes[r] = current_tanzaku;
|
temp.holes[r] = current_tanzaku;
|
||||||
}
|
}
|
||||||
current_tanzaku++;
|
|
||||||
}
|
}
|
||||||
if (fflush(temp.file) == 0) {
|
if (fflush(temp.file) == 0) {
|
||||||
sappyou->file = NULL;
|
sappyou->file = NULL;
|
||||||
@ -111,7 +110,7 @@ int sappyou_save(Sappyou *sappyou) {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
Tanzaku *current_tanzaku = sappyou->database;
|
Tanzaku *current_tanzaku = sappyou->database;
|
||||||
for (uint64_t i = 0; i < sappyou->size; i++) {
|
for (uint64_t i = 0; i < sappyou->size; i++, current_tanzaku++) {
|
||||||
if (current_tanzaku->id != HOLE_ID) {
|
if (current_tanzaku->id != HOLE_ID) {
|
||||||
if (fputc(0xff, sappyou->file) == EOF ||
|
if (fputc(0xff, sappyou->file) == EOF ||
|
||||||
fwrite(¤t_tanzaku->created_ts, 8, 1, sappyou->file) != 1 ||
|
fwrite(¤t_tanzaku->created_ts, 8, 1, sappyou->file) != 1 ||
|
||||||
@ -125,7 +124,6 @@ int sappyou_save(Sappyou *sappyou) {
|
|||||||
} else if (fputc(0, sappyou->file) == EOF) {
|
} else if (fputc(0, sappyou->file) == EOF) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
current_tanzaku++;
|
|
||||||
}
|
}
|
||||||
return fflush(sappyou->file);
|
return fflush(sappyou->file);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -64,7 +64,7 @@ int sasahyou_load(Sasahyou *sasahyou) {
|
|||||||
temp.holes = calloc(temp.hole_cnt, sizeof(Sasa *));
|
temp.holes = calloc(temp.hole_cnt, sizeof(Sasa *));
|
||||||
size_t max_path_len = SIZE_MAX;
|
size_t max_path_len = SIZE_MAX;
|
||||||
Sasa *current_sasa = temp.database;
|
Sasa *current_sasa = temp.database;
|
||||||
for (uint64_t i = 0, r = temp.hole_cnt; i < temp.size; i++) {
|
for (uint64_t i = 0, r = temp.hole_cnt; i < temp.size; i++, current_sasa++) {
|
||||||
if (fgetc(temp.file) != 0) {
|
if (fgetc(temp.file) != 0) {
|
||||||
current_sasa->id = i;
|
current_sasa->id = i;
|
||||||
if (fread(¤t_sasa->created_ts, 8, 1, temp.file) != 1 ||
|
if (fread(¤t_sasa->created_ts, 8, 1, temp.file) != 1 ||
|
||||||
@ -83,7 +83,6 @@ int sasahyou_load(Sasahyou *sasahyou) {
|
|||||||
r--;
|
r--;
|
||||||
temp.holes[r] = current_sasa;
|
temp.holes[r] = current_sasa;
|
||||||
}
|
}
|
||||||
current_sasa++;
|
|
||||||
}
|
}
|
||||||
if (fflush(temp.file) == 0) {
|
if (fflush(temp.file) == 0) {
|
||||||
sasahyou->file = NULL;
|
sasahyou->file = NULL;
|
||||||
@ -108,7 +107,7 @@ int sasahyou_save(Sasahyou *sasahyou) {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
Sasa *current_sasa = sasahyou->database;
|
Sasa *current_sasa = sasahyou->database;
|
||||||
for (uint64_t i = 0; i < sasahyou->size; i++) {
|
for (uint64_t i = 0; i < sasahyou->size; i++, current_sasa++) {
|
||||||
if (current_sasa->id != HOLE_ID) {
|
if (current_sasa->id != HOLE_ID) {
|
||||||
if (fputc(0xff, sasahyou->file) == EOF ||
|
if (fputc(0xff, sasahyou->file) == EOF ||
|
||||||
fwrite(¤t_sasa->created_ts, 8, 1, sasahyou->file) != 1 ||
|
fwrite(¤t_sasa->created_ts, 8, 1, sasahyou->file) != 1 ||
|
||||||
@ -119,7 +118,6 @@ int sasahyou_save(Sasahyou *sasahyou) {
|
|||||||
} else if (fputc(0, sasahyou->file) == EOF) {
|
} else if (fputc(0, sasahyou->file) == EOF) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
current_sasa++;
|
|
||||||
}
|
}
|
||||||
return fflush(sasahyou->file);
|
return fflush(sasahyou->file);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -55,7 +55,7 @@ int shoppyou_load(Shoppyou *shoppyou) {
|
|||||||
}
|
}
|
||||||
temp.database = calloc(temp.size, sizeof(Kazari));
|
temp.database = calloc(temp.size, sizeof(Kazari));
|
||||||
Kazari *current_kazari = temp.database;
|
Kazari *current_kazari = temp.database;
|
||||||
for (uint64_t i = 0; i < temp.size; i++) {
|
for (uint64_t i = 0; i < temp.size; i++, current_kazari++) {
|
||||||
if (fread(¤t_kazari->created_ts, 8, 1, temp.file) != 1 ||
|
if (fread(¤t_kazari->created_ts, 8, 1, temp.file) != 1 ||
|
||||||
fread(¤t_kazari->sasa_id, 8, 1, temp.file) != 1 ||
|
fread(¤t_kazari->sasa_id, 8, 1, temp.file) != 1 ||
|
||||||
fread(¤t_kazari->tanzaku_id, 8, 1, temp.file) != 1) {
|
fread(¤t_kazari->tanzaku_id, 8, 1, temp.file) != 1) {
|
||||||
@ -63,7 +63,6 @@ int shoppyou_load(Shoppyou *shoppyou) {
|
|||||||
shoppyou_free(&temp);
|
shoppyou_free(&temp);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
current_kazari++;
|
|
||||||
}
|
}
|
||||||
if (fflush(temp.file) == 0) {
|
if (fflush(temp.file) == 0) {
|
||||||
shoppyou->file = NULL;
|
shoppyou->file = NULL;
|
||||||
@ -90,7 +89,7 @@ int shoppyou_save(Shoppyou *shoppyou) {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
Kazari *current_kazari = shoppyou->database;
|
Kazari *current_kazari = shoppyou->database;
|
||||||
for (uint64_t i = 0; i < shoppyou->size; i++) {
|
for (uint64_t i = 0; i < shoppyou->size; i++, current_kazari++) {
|
||||||
if (shoppyou->database[i].sasa_id != HOLE_ID && shoppyou->database[i].tanzaku_id != HOLE_ID) {
|
if (shoppyou->database[i].sasa_id != HOLE_ID && shoppyou->database[i].tanzaku_id != HOLE_ID) {
|
||||||
if (fwrite(¤t_kazari->created_ts, 8, 1, shoppyou->file) != 1 ||
|
if (fwrite(¤t_kazari->created_ts, 8, 1, shoppyou->file) != 1 ||
|
||||||
fwrite(¤t_kazari->sasa_id, 8, 1, shoppyou->file) != 1 ||
|
fwrite(¤t_kazari->sasa_id, 8, 1, shoppyou->file) != 1 ||
|
||||||
@ -98,7 +97,6 @@ int shoppyou_save(Shoppyou *shoppyou) {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
current_kazari++;
|
|
||||||
}
|
}
|
||||||
return fflush(shoppyou->file);
|
return fflush(shoppyou->file);
|
||||||
}
|
}
|
||||||
@ -151,7 +149,7 @@ int kazari_rem(Shoppyou *shoppyou, uint64_t sasa_id, uint64_t tanzaku_id) {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
Kazari *current_kazari = shoppyou->database;
|
Kazari *current_kazari = shoppyou->database;
|
||||||
for (uint64_t i = 0; i < shoppyou->size; i++) {
|
for (uint64_t i = 0; i < shoppyou->size; i++, current_kazari++) {
|
||||||
if (current_kazari->sasa_id == sasa_id && current_kazari->tanzaku_id == tanzaku_id) {
|
if (current_kazari->sasa_id == sasa_id && current_kazari->tanzaku_id == tanzaku_id) {
|
||||||
current_kazari->sasa_id = HOLE_ID;
|
current_kazari->sasa_id = HOLE_ID;
|
||||||
current_kazari->tanzaku_id = HOLE_ID;
|
current_kazari->tanzaku_id = HOLE_ID;
|
||||||
@ -161,7 +159,6 @@ int kazari_rem(Shoppyou *shoppyou, uint64_t sasa_id, uint64_t tanzaku_id) {
|
|||||||
shoppyou->modified_ts = time(NULL);
|
shoppyou->modified_ts = time(NULL);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
current_kazari++;
|
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -172,7 +169,7 @@ int kazari_rem_by_sasa(Shoppyou *shoppyou, uint64_t sasa_id) {
|
|||||||
}
|
}
|
||||||
Kazari *current_kazari = shoppyou->database;
|
Kazari *current_kazari = shoppyou->database;
|
||||||
_Bool changed = 0;
|
_Bool changed = 0;
|
||||||
for (uint64_t i = 0; i < shoppyou->size; i++) {
|
for (uint64_t i = 0; i < shoppyou->size; i++, current_kazari++) {
|
||||||
if (current_kazari->sasa_id == sasa_id) {
|
if (current_kazari->sasa_id == sasa_id) {
|
||||||
current_kazari->sasa_id = HOLE_ID;
|
current_kazari->sasa_id = HOLE_ID;
|
||||||
current_kazari->tanzaku_id = HOLE_ID;
|
current_kazari->tanzaku_id = HOLE_ID;
|
||||||
@ -181,7 +178,6 @@ int kazari_rem_by_sasa(Shoppyou *shoppyou, uint64_t sasa_id) {
|
|||||||
shoppyou->holes[shoppyou->hole_cnt - 1] = current_kazari;
|
shoppyou->holes[shoppyou->hole_cnt - 1] = current_kazari;
|
||||||
changed = 1;
|
changed = 1;
|
||||||
}
|
}
|
||||||
current_kazari++;
|
|
||||||
}
|
}
|
||||||
if (changed) {
|
if (changed) {
|
||||||
shoppyou->modified_ts = time(NULL);
|
shoppyou->modified_ts = time(NULL);
|
||||||
@ -196,7 +192,7 @@ int kazari_rem_by_tanzaku(Shoppyou *shoppyou, uint64_t tanzaku_id) {
|
|||||||
}
|
}
|
||||||
Kazari *current_kazari = shoppyou->database;
|
Kazari *current_kazari = shoppyou->database;
|
||||||
_Bool changed = 0;
|
_Bool changed = 0;
|
||||||
for (uint64_t i = 0; i < shoppyou->size; i++) {
|
for (uint64_t i = 0; i < shoppyou->size; i++, current_kazari++) {
|
||||||
if (current_kazari->tanzaku_id == tanzaku_id) {
|
if (current_kazari->tanzaku_id == tanzaku_id) {
|
||||||
current_kazari->sasa_id = HOLE_ID;
|
current_kazari->sasa_id = HOLE_ID;
|
||||||
current_kazari->tanzaku_id = HOLE_ID;
|
current_kazari->tanzaku_id = HOLE_ID;
|
||||||
@ -205,7 +201,6 @@ int kazari_rem_by_tanzaku(Shoppyou *shoppyou, uint64_t tanzaku_id) {
|
|||||||
shoppyou->holes[shoppyou->hole_cnt - 1] = current_kazari;
|
shoppyou->holes[shoppyou->hole_cnt - 1] = current_kazari;
|
||||||
changed = 1;
|
changed = 1;
|
||||||
}
|
}
|
||||||
current_kazari++;
|
|
||||||
}
|
}
|
||||||
if (changed) {
|
if (changed) {
|
||||||
shoppyou->modified_ts = time(NULL);
|
shoppyou->modified_ts = time(NULL);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user