diff options
-rw-r--r-- | filesystem-win.c | 2 | ||||
-rw-r--r-- | main.c | 6 | ||||
-rw-r--r-- | ui.c | 2 | ||||
-rw-r--r-- | util.c | 19 |
4 files changed, 11 insertions, 18 deletions
diff --git a/filesystem-win.c b/filesystem-win.c index d35597f..d9ff143 100644 --- a/filesystem-win.c +++ b/filesystem-win.c @@ -68,7 +68,7 @@ int fs_mkdir(char const *path) { int fs_get_cwd(char *buf, size_t buflen) { assert(buf && buflen); - DWORD pathlen = GetCurrentDirectory(buflen, buf); + DWORD pathlen = GetCurrentDirectory((DWORD)buflen, buf); if (pathlen == 0) { return -1; } else if (pathlen < buflen) { // it's confusing, but this is < and not <= @@ -190,13 +190,13 @@ int main(int argc, char **argv) { wchar_t *appdata = NULL; KNOWNFOLDERID id = FOLDERID_LocalAppData; if (SHGetKnownFolderPath(&id, 0, NULL, &appdata) == S_OK) { - strbuf_printf(ted_local_data_dir, "%ls" PATH_SEPARATOR_STR "ted", appdata); + strbuf_printf(ted->local_data_dir, "%ls" PATH_SEPARATOR_STR "ted", appdata); CoTaskMemFree(appdata); } id = FOLDERID_Profile; wchar_t *home = NULL; if (SHGetKnownFolderPath(&id, 0, NULL, &home) == S_OK) { - strbuf_printf(ted_home, "%ls", home); + strbuf_printf(ted->home, "%ls", home); CoTaskMemFree(home); } strbuf_printf(ted->global_data_dir, "C:\\Program Files\\ted"); @@ -229,7 +229,7 @@ int main(int argc, char **argv) { char *last_backslash = strrchr(executable_path, '\\'); if (last_backslash) { *last_backslash = '\0'; - ted_search_cwd = streq(cwd, executable_path); + ted->search_cwd = streq(cwd, executable_path); } } #else @@ -85,7 +85,7 @@ static void file_selector_down(Ted const *ted, FileSelector *fs, i64 n) { file_selector_up(ted, fs, -n); } -static int qsort_file_entry_cmp(void const *av, void const *bv, void *search_termv) { +static int qsort_file_entry_cmp(void *search_termv, void const *av, void const *bv) { char const *search_term = search_termv; FileEntry const *a = av, *b = bv; // put directories first @@ -191,23 +191,16 @@ static int str_qsort_case_insensitive_cmp(const void *av, const void *bv) { return strcmp_case_insensitive(*a, *b); } -static void *qsort_ctx_data; -static int (*qsort_ctx_cmp)(const void *, const void *, void *data); +static void *qsort_ctx_arg; +static int (*qsort_ctx_cmp)(void *, const void *, const void *); static int qsort_with_context_cmp(const void *a, const void *b) { - return qsort_ctx_cmp(a, b, qsort_ctx_data); + return qsort_ctx_cmp(qsort_ctx_arg, a, b); } -// qsort but with a user void* -static void qsort_with_context(void *base, size_t nmemb, size_t size, int (*compar)(const void *, const void *, void *), void *arg) { -#if _WIN32 - qsort_s(base, nmemb, size, compar, arg); -#elif __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 8) - // GNU doesn't have qsort_s ): - qsort_r(base, nmemb, size, compar, arg); -#else +static void qsort_with_context(void *base, size_t nmemb, size_t size, int (*compar)(void *, const void *, const void *), void *arg) { + // @TODO(eventually): write this yourself // just use global variables. hopefully we don't try to run this in something multithreaded! - qsort_ctx_data = arg; + qsort_ctx_arg = arg; qsort_ctx_cmp = compar; qsort(base, nmemb, size, qsort_with_context_cmp); -#endif } |