summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeo Tenenbaum <pommicket@gmail.com>2021-01-29 10:44:46 -0500
committerLeo Tenenbaum <pommicket@gmail.com>2021-01-29 10:44:46 -0500
commit6f6ae8af3e3fdee60d38fa12f25ff83097522807 (patch)
tree353936408eb0329a9833db8d847e1e4a69ae18b8
parent31b5649b131695300f39563640c4af8f0d3032cb (diff)
got windows build to work again
-rw-r--r--filesystem-win.c2
-rw-r--r--main.c6
-rw-r--r--ui.c2
-rw-r--r--util.c19
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 <=
diff --git a/main.c b/main.c
index 686a515..44a612c 100644
--- a/main.c
+++ b/main.c
@@ -123,13 +123,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");
@@ -162,7 +162,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
diff --git a/ui.c b/ui.c
index f0cdb72..9c63fb4 100644
--- a/ui.c
+++ b/ui.c
@@ -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
diff --git a/util.c b/util.c
index d805830..4a5340b 100644
--- a/util.c
+++ b/util.c
@@ -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
}