#include <assert.h>\r
#include <limits.h>\r
\r
+#if defined(_WIN32)\r
+// NOTE: Don't include unwanted files to speed up compilation\r
+#define WIN32_LEAN_AND_MEAN\r
+#define NOCOMM\r
+#include <windows.h>\r
+#undef C_ASSERT // Bruh\r
+#endif\r
+\r
// Remove Prefix\r
#ifdef COMMONLIB_REMOVE_PREFIX\r
#define ASSERT C_ASSERT\r
\r
\r
// Macros\r
+#if defined(_MSC_VER) && !defined(__clang__) && !defined(__INTEL_COMPILER)\r
+#define C_ASSERT(condition, msg) do {\\r
+ if (!(condition)) {\\r
+ fprintf(stderr, "%s:%d:0 [ASSERTION FAILED] %s: %s", __FILE__, __LINE__, #condition, msg);\\r
+ DebugBreak();\\r
+ }\\r
+ } while (0)\r
+#else\r
#define C_ASSERT(condition, msg) do {\\r
if (!(condition)) {\\r
fprintf(stderr, "%s:%d:0 [ASSERTION FAILED] %s: %s", __FILE__, __LINE__, #condition, msg);\\r
exit(1);\\r
}\\r
} while (0)\r
+#endif // defined(_MSC_VER) && !defined(__clang__) && !defined(__INTEL_COMPILER)\r
\r
#define C_ARRAY_LEN(arr) (sizeof(arr) / sizeof(arr[0]))\r
\r
\r
size_t read = fread((char*)result, sizeof(char), fsize, f);\r
\r
- *file_size = (int)read;\r
+ // Process the result to remove '\r' characters\r
+ char* cleaned_result = malloc(read + 1); // Allocate memory for cleaned result\r
+ if (cleaned_result == NULL) {\r
+ fprintf(stderr, "Memory allocation failed\n");\r
+ free(result);\r
+ return NULL;\r
+ }\r
\r
- // set null-terminator\r
- result[read] = '\0';\r
+ size_t j = 0; // Index for cleaned_result\r
+ for (size_t i = 0; i < read; i++) {\r
+ if (result[i] != '\r') { // Skip '\r' characters\r
+ cleaned_result[j++] = result[i];\r
+ }\r
+ }\r
+ cleaned_result[j] = '\0'; // Null-terminate the cleaned result\r
+\r
+ free(result); // Free the original result\r
+ *file_size = (int)j; // Update the file size without '\r'\r
+ return cleaned_result; // Return the cleaned result\r
+\r
+ *file_size = (int)read;\r
\r
defer:\r
if (f) fclose(f);\r
from = clampi(from, 0, sv.count);\r
to = clampi(to, from, sv.count);\r
\r
- String_view range = {\r
+ c_String_view range = {\r
.data = (char*)(sv.data + from),\r
.count = (size_t)(to - from),\r
};\r