diff --git a/src/goxel.h b/src/goxel.h index e47fbde87..ecb2dafe1 100644 --- a/src/goxel.h +++ b/src/goxel.h @@ -242,11 +242,6 @@ static inline float smoothstep(float edge0, float edge1, float x) return x * x * (3.0f - 2.0f * x); } -// Fallback for strlcpy if it doesn't exists. -#ifndef strlcpy -#define strlcpy(dst, src, size) snprintf(dst, size, "%s", src) -#endif - /* * Function: mix * Linear blend of x and y. diff --git a/src/main.c b/src/main.c index 44d5791fc..cf8173411 100644 --- a/src/main.c +++ b/src/main.c @@ -302,12 +302,12 @@ static void split_path_and_file( sep = strrchr(path_and_file, '/'); if (!sep) { - strlcpy(path, path_and_file, path_size); - file[0] = '\0'; + snprintf(file, file_size, "%s", path_and_file); + path[0] = '\0'; } else { path_len = (int)(sep - path_and_file); snprintf(path, path_size, "%.*s", path_len, path_and_file); - strlcpy(file, sep + 1, file_size); + snprintf(file, file_size, "%s", sep + 1); } } @@ -315,9 +315,11 @@ static void filters_to_nfd_spec( const char *const *filters, char buf[], size_t buf_size) { int i; + size_t len = 0; + buf[0] = '\0'; for (i = 0; filters[i]; i++) { - strlcat(buf, filters[i] + 2, buf_size); + len += snprintf(buf + len, buf_size - len, "%s", filters[i] + 2); } } @@ -356,7 +358,7 @@ static bool open_dialog( &(nfdsavedialogu8args_t){ .filterList = &filter, .filterCount = 1, - .defaultPath = default_path, + .defaultPath = default_path[0] ? default_path : NULL, .defaultName = default_name, .parentWindow = nfd_window, });