From 55cb65be26635c6a3c727cb75f79fdccc82f28bb Mon Sep 17 00:00:00 2001 From: NishiOwO Date: Sat, 4 Apr 2026 00:35:01 +0900 Subject: [PATCH] be c89 --- src/abstract/directory.c | 16 +++++++--------- src/string.c | 2 +- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/src/abstract/directory.c b/src/abstract/directory.c index 3882f8e..068e566 100644 --- a/src/abstract/directory.c +++ b/src/abstract/directory.c @@ -4,7 +4,7 @@ typedef struct dir { HANDLE hFind; WIN32_FIND_DATA ffd; - int first; + int next; } dir_t; #else typedef struct dir { @@ -25,7 +25,7 @@ void* MwDirectoryOpen(const char* path) { return NULL; } free(p); - dir->first = 1; + dir->next = 1; #else if((dir->dir = opendir(path)) == NULL) { free(dir); @@ -54,14 +54,10 @@ MwDirectoryEntry* MwDirectoryRead(void* handle) { MwDirectoryEntry* entry = malloc(sizeof(*entry)); #ifdef _WIN32 ULARGE_INTEGER* l; - if(dir->first) { - dir->first = 0; - } else if(FindNextFile(dir->hFind, &dir->ffd) == 0) { - free(entry); - return NULL; - } - entry->name = MwStringDuplicate(dir->ffd.cFileName); + if(!dir->next) return NULL; + + entry->name = MwStringDuplicate(dir->ffd.cFileName); if(dir->ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { entry->type = MwDIRECTORY_DIRECTORY; } else { @@ -77,6 +73,8 @@ MwDirectoryEntry* MwDirectoryRead(void* handle) { l = (ULARGE_INTEGER*)&dir->ffd.ftLastWriteTime; entry->mtime = l->QuadPart / 10000000 - 11644473600; + + dir->next = FindNextFile(dir->hFind, &dir->ffd); #else struct dirent* d; struct stat s; diff --git a/src/string.c b/src/string.c index 8f960b1..fd87826 100644 --- a/src/string.c +++ b/src/string.c @@ -52,8 +52,8 @@ void MwStringPrintIntoBuffer(char* out, MwU32 size, const char* fmt, ...) { MWDECL MwBool MwStringIsKeyUTF8(MwU32 key) { unsigned char bytes[sizeof(MwU32)]; + int i; memcpy(bytes, &key, sizeof(MwU32)); - int i = 0; for(i = 0; i < sizeof(MwU32); i++) { if(( // ASCII