From 39916071a5ce9da58ac346d280a11dbeba33c906 Mon Sep 17 00:00:00 2001 From: Thomas Debesse Date: Fri, 28 Jun 2024 17:04:51 +0200 Subject: [PATCH] example3: make strncpy multiplatform --- example3/example3.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/example3/example3.cpp b/example3/example3.cpp index c6fae24b..346941b7 100644 --- a/example3/example3.cpp +++ b/example3/example3.cpp @@ -89,7 +89,11 @@ int main(int argc, char* argv[]) { if (++i >= argc) return error("Expected output filename!"); +#if defined(_WIN32) strcpy_s(out_filename, sizeof(out_filename), argv[i]); +#else + strncpy(out_filename, argv[i], sizeof(out_filename)); +#endif } else if (!crnlib_stricmp(argv[i], "-nonsrgb")) srgb_colorspace = false; else if (!crnlib_stricmp(argv[i], "-pixelformat")) { @@ -224,7 +228,11 @@ int main(int argc, char* argv[]) { char dst_filename[FILENAME_MAX]; crnlib_snprintf(dst_filename, sizeof(dst_filename), "%s%s%s.dds", drive_buf, dir_buf, fname_buf); if (out_filename[0]) - strcpy(dst_filename, out_filename); +#if defined(_WIN32) + strcpy_s(dst_filename, sizeof(dst_filename), out_filename); +#else + strncpy(dst_filename, out_filename, sizeof(dst_filename)); +#endif printf("Writing DDS file: %s\n", dst_filename);