diff --git a/standalone_libraries/io.c b/standalone_libraries/io.c index 935c00b..6f194ab 100644 --- a/standalone_libraries/io.c +++ b/standalone_libraries/io.c @@ -36,14 +36,14 @@ IO_THREAD_LOCAL void (*IO_User_OutputMessage)(int kind, const char *file, int li IO_API bool IO__FatalErrorf(const char *file, int line, const char *msg, ...) { va_list args1; va_list args2; - char buff[2048]; + char buff[2048]; va_start(args1, msg); va_copy(args2, args1); int size = IO_VSNPRINTF(buff, sizeof(buff), msg, args2); va_end(args2); - char *new_buffer = 0; + char *new_buffer = 0; char *user_message = buff; if (size >= sizeof(buff)) { size += 4; @@ -55,14 +55,14 @@ IO_API bool IO__FatalErrorf(const char *file, int line, const char *msg, ...) { IO_ErrorResult ret = IO_ErrorResult_Continue; { - char buff2[2048]; + char buff2[2048]; char *result = buff2; - char *b = 0; - int size2 = IO_SNPRINTF(buff2, sizeof(buff2), "%s(%d): error: %s \n", file, line, user_message); + char *b = 0; + int size2 = IO_SNPRINTF(buff2, sizeof(buff2), "%s(%d): error: %s \n", file, line, user_message); if (size2 >= sizeof(buff2)) { size2 += 4; - b = (char *)IO_ALLOCATE(size2); - size2 = IO_SNPRINTF(b, size2, "%s(%d): error: %s \n", file, line, user_message); + b = (char *)IO_ALLOCATE(size2); + size2 = IO_SNPRINTF(b, size2, "%s(%d): error: %s \n", file, line, user_message); result = b; } @@ -89,7 +89,7 @@ IO_API void IO__Printf(int kind, const char *file, int line, const char *msg, .. // case. va_list args1; va_list args2; - char buff[2048]; + char buff[2048]; va_start(args1, msg); va_copy(args2, args1); @@ -97,7 +97,7 @@ IO_API void IO__Printf(int kind, const char *file, int line, const char *msg, .. va_end(args2); char *new_buffer = 0; - char *result = buff; + char *result = buff; if (size >= sizeof(buff)) { size += 4; new_buffer = (char *)IO_ALLOCATE(size); @@ -108,8 +108,7 @@ IO_API void IO__Printf(int kind, const char *file, int line, const char *msg, .. if (IO_User_OutputMessage) { IO_User_OutputMessage(kind, file, line, result, size); - } - else { + } else { IO_OutputMessage(result, size); } @@ -118,9 +117,9 @@ IO_API void IO__Printf(int kind, const char *file, int line, const char *msg, .. } } -IO_API bool IO__FatalError(char *msg) { - int len = IO_Strlen(msg); - IO_ErrorResult result = IO_OutputError(msg, len); +IO_API bool IO__FatalError(const char *msg) { + int len = IO_Strlen((char *)msg); + IO_ErrorResult result = IO_OutputError((char *)msg, len); if (result == IO_ErrorResult_Exit) { IO_Exit(1); } @@ -130,8 +129,7 @@ IO_API bool IO__FatalError(char *msg) { IO_API void IO_Print(int kind, const char *file, int line, char *msg, int len) { if (IO_User_OutputMessage) { IO_User_OutputMessage(kind, file, line, msg, len); - } - else { + } else { IO_OutputMessage(msg, len); } } @@ -177,7 +175,7 @@ IO_API IO_ErrorResult IO_OutputError(char *str, int len) { // Limit size of error output message char tmp = 0; if (len > 4096) { - tmp = str[4096]; + tmp = str[4096]; str[4096] = 0; } @@ -188,8 +186,7 @@ IO_API IO_ErrorResult IO_OutputError(char *str, int len) { } result = IO_ErrorResult_Exit; - } - else { + } else { result = IO_ErrorResult_Break; } diff --git a/standalone_libraries/io.h b/standalone_libraries/io.h index 6c325d5..70f8bb8 100644 --- a/standalone_libraries/io.h +++ b/standalone_libraries/io.h @@ -55,8 +55,8 @@ extern IO_THREAD_LOCAL void (*IO_User_OutputMessage)(int kind, const char *file, #define IO__TOSTRING(x) IO__STRINGIFY(x) #define IO_LINE IO__TOSTRING(__LINE__) -#define IO_Assert(x) !(x) && IO__FatalError((char *)(__FILE__ "(" IO_LINE "): " \ - "error: " #x "\n")) && \ +#define IO_Assert(x) !(x) && IO__FatalError((__FILE__ "(" IO_LINE "): " \ + "error: " #x "\n")) && \ IO_DebugBreak() #define IO_FatalErrorf(...) \ do { \ @@ -85,22 +85,22 @@ extern IO_THREAD_LOCAL void (*IO_User_OutputMessage)(int kind, const char *file, IO_InvalidCodepath(); \ } #define IO_InvalidCodepath() IO_FatalError("This codepath is invalid") -#define IO_InvalidDefaultCase() \ - default: { \ - IO_FatalError("Entered invalid switch statement case"); \ - } +#define IO_InvalidDefaultCase() \ +default: { \ + IO_FatalError("Entered invalid switch statement case"); \ +} #define IO_Todo() IO_FatalError("This codepath is not implemented yet") -IO_API bool IO__FatalErrorf(const char *file, int line, const char *msg, ...) IO__PrintfFormat(3, 4); -IO_API void IO__Printf(int kind, const char *file, int line, const char *msg, ...) IO__PrintfFormat(4, 5); -IO_API bool IO__FatalError(char *msg); -IO_API void IO_Print(int kind, const char *file, int line, char *msg, int len); -IO_API void IO_OutputMessage(char *str, int len); +IO_API bool IO__FatalErrorf(const char *file, int line, const char *msg, ...) IO__PrintfFormat(3, 4); +IO_API void IO__Printf(int kind, const char *file, int line, const char *msg, ...) IO__PrintfFormat(4, 5); +IO_API bool IO__FatalError(const char *msg); +IO_API void IO_Print(int kind, const char *file, int line, char *msg, int len); +IO_API void IO_OutputMessage(char *str, int len); IO_API IO_ErrorResult IO_OutputError(char *str, int len); -IO_API void IO_Exit(int error_code); -IO_API bool IO_IsDebuggerPresent(void); +IO_API void IO_Exit(int error_code); +IO_API bool IO_IsDebuggerPresent(void); -static const int IO_KindPrintf = 1; +static const int IO_KindPrintf = 1; static const int IO_KindWarningf = 2; #define IO_Printf(...) IO__Printf(IO_KindPrintf, __FILE__, __LINE__, __VA_ARGS__)