Archived
1
0

today I learned MSVC still doesn't have stdbool.h

This commit is contained in:
Marrub 2015-07-29 07:59:25 -04:00
parent f104dcbdfc
commit 58319b43a1
2 changed files with 21 additions and 17 deletions

View File

@ -70,7 +70,7 @@ static LT_Config cfg;
static iconv_t icDesc; static iconv_t icDesc;
#endif #endif
static bool assertError = false; static LT_BOOL assertError = LT_FALSE;
static char *assertString; static char *assertString;
static char *stringChars = (char *)"\"", *charChars = (char *)"'"; static char *stringChars = (char *)"\"", *charChars = (char *)"'";
@ -235,17 +235,17 @@ void LT_Init(LT_Config initCfg)
if(icDesc == (iconv_t) -1) if(icDesc == (iconv_t) -1)
{ {
LT_Assert(true, "LT_Init: Failure opening iconv"); LT_Assert(LT_TRUE, "LT_Init: Failure opening iconv");
} }
} }
else else
{ {
cfg.doConvert = false; cfg.doConvert = LT_FALSE;
} }
if(cfg.stripInvalid && cfg.doConvert) if(cfg.stripInvalid && cfg.doConvert)
{ {
cfg.stripInvalid = false; cfg.stripInvalid = LT_FALSE;
} }
#endif #endif
@ -316,7 +316,7 @@ void LT_SetConfig(LT_Config newCfg)
if(icDesc == (iconv_t) -1) if(icDesc == (iconv_t) -1)
{ {
LT_Assert(true, "LT_Init: Failure opening iconv"); LT_Assert(LT_TRUE, "LT_Init: Failure opening iconv");
} }
} }
else else
@ -327,12 +327,12 @@ void LT_SetConfig(LT_Config newCfg)
icDesc = NULL; icDesc = NULL;
} }
cfg.doConvert = false; cfg.doConvert = LT_FALSE;
} }
if(cfg.stripInvalid && cfg.doConvert) if(cfg.stripInvalid && cfg.doConvert)
{ {
cfg.stripInvalid = false; cfg.stripInvalid = LT_FALSE;
} }
#endif #endif
@ -419,7 +419,7 @@ void LT_Quit()
#endif #endif
} }
bool LT_Assert(bool assertion, const char *fmt, ...) LT_BOOL LT_Assert(LT_BOOL assertion, const char *fmt, ...)
{ {
if(assertion) if(assertion)
{ {
@ -427,7 +427,7 @@ bool LT_Assert(bool assertion, const char *fmt, ...)
char asBuffer[512]; char asBuffer[512];
va_list va; va_list va;
assertError = true; assertError = LT_TRUE;
assertString = malloc(512); assertString = malloc(512);
snprintf(ftString, 16, ":%ld:", ftell(parseFile)); snprintf(ftString, 16, ":%ld:", ftell(parseFile));
@ -459,20 +459,20 @@ LT_AssertInfo LT_CheckAssert()
} }
#ifndef __GDCC__ #ifndef __GDCC__
bool LT_OpenFile(const char *filePath) LT_BOOL LT_OpenFile(const char *filePath)
#else #else
bool LT_OpenFile(__str filePath) LT_BOOL LT_OpenFile(__str filePath)
#endif #endif
{ {
parseFile = fopen(filePath, "r"); parseFile = fopen(filePath, "r");
if(parseFile == NULL) if(parseFile == NULL)
{ {
LT_Assert(true, "LT_OpenFile: %s", strerror(errno)); LT_Assert(LT_TRUE, "LT_OpenFile: %s", strerror(errno));
return false; return LT_FALSE;
} }
return true; return LT_TRUE;
} }
void LT_SetPos(int newPos) void LT_SetPos(int newPos)
@ -542,7 +542,7 @@ char *LT_ReadString(char term)
char *str = LT_Alloc(TOKEN_STR_BLOCK_LENGTH); char *str = LT_Alloc(TOKEN_STR_BLOCK_LENGTH);
int c; int c;
while(true) while(LT_TRUE)
{ {
c = fgetc(parseFile); c = fgetc(parseFile);
@ -682,7 +682,7 @@ char *LT_Escaper(char *str, size_t pos, char escape)
break; break;
default: default:
LT_Assert(true, "LT_Escaper: Unknown escape character '%c'", escape); LT_Assert(LT_TRUE, "LT_Escaper: Unknown escape character '%c'", escape);
break; break;
} }

View File

@ -29,7 +29,6 @@ THE SOFTWARE.
*/ */
#include <stdlib.h> #include <stdlib.h>
#include <stdbool.h>
/* /*
* Definitions * Definitions
@ -54,6 +53,9 @@ THE SOFTWARE.
#define LT_NO_ICONV #define LT_NO_ICONV
#endif #endif
#define LT_TRUE 1
#define LT_FALSE 0
enum enum
{ {
TOK_Colon, TOK_Comma, TOK_Div, TOK_Mod, TOK_Mul, TOK_Colon, TOK_Comma, TOK_Div, TOK_Mod, TOK_Mul,
@ -111,6 +113,8 @@ typedef struct LT_GarbageList_s
void *ptr; void *ptr;
} LT_GarbageList; // [marrub] Don't include this into FFI declarations. } LT_GarbageList; // [marrub] Don't include this into FFI declarations.
typedef int LT_BOOL;
/* /*
* Functions * Functions
*/ */