Archived
1
0

added new init option

This commit is contained in:
Marrub 2015-06-05 07:47:39 -04:00
parent a1718ebf47
commit e28a3f89ce
3 changed files with 8 additions and 6 deletions

12
lt.c
View File

@ -31,7 +31,7 @@ FILE *LT_ParseFile;
bool LT_AssertError = false; bool LT_AssertError = false;
LT_GarbageList *gbHead, *gbRover; LT_GarbageList *gbHead, *gbRover;
static bool escapeChars = true; static LT_InitInfo info;
static char *tokenTypes[] = { static char *tokenTypes[] = {
// [marrub] So, this was an interesting bug. This was completely misordered from the enum. // [marrub] So, this was an interesting bug. This was completely misordered from the enum.
@ -47,7 +47,7 @@ static char *tokenTypes[] = {
void LT_Init(LT_InitInfo initInfo) void LT_Init(LT_InitInfo initInfo)
{ {
escapeChars = initInfo.escapeChars; info = initInfo;
gbHead = malloc(sizeof(LT_GarbageList)); gbHead = malloc(sizeof(LT_GarbageList));
gbHead->next = NULL; gbHead->next = NULL;
@ -131,7 +131,7 @@ char *LT_ReadNumber()
realloc(str, TOKEN_STR_BLOCK_LENGTH * str_blocks++); realloc(str, TOKEN_STR_BLOCK_LENGTH * str_blocks++);
} }
str[i++] = c; str[i++] = ((info.stripInvalid && (isspace(c) || isprint(c))) || !info.stripInvalid) ? c : ' ';
} }
str[i++] = '\0'; str[i++] = '\0';
@ -164,7 +164,7 @@ char *LT_ReadString(char term)
return emptyString; return emptyString;
} }
if(c == '\\' && escapeChars) if(c == '\\' && info.escapeChars)
{ {
fread(&c, 1, 1, LT_ParseFile); fread(&c, 1, 1, LT_ParseFile);
@ -188,7 +188,7 @@ char *LT_ReadString(char term)
realloc(str, TOKEN_STR_BLOCK_LENGTH * str_blocks++); realloc(str, TOKEN_STR_BLOCK_LENGTH * str_blocks++);
} }
str[i++] = c; str[i++] = ((info.stripInvalid && (isspace(c) || isprint(c))) || !info.stripInvalid) ? c : ' ';
} }
} }
@ -465,7 +465,7 @@ LT_Token LT_GetToken()
realloc(str, TOKEN_STR_BLOCK_LENGTH * str_blocks++); realloc(str, TOKEN_STR_BLOCK_LENGTH * str_blocks++);
} }
str[i++] = c; str[i++] = ((info.stripInvalid && (isspace(c) || isprint(c))) || !info.stripInvalid) ? c : ' ';
fread(&c, 1, 1, LT_ParseFile); fread(&c, 1, 1, LT_ParseFile);
} }

1
lt.h
View File

@ -37,6 +37,7 @@ THE SOFTWARE.
typedef struct typedef struct
{ {
bool escapeChars; bool escapeChars;
bool stripInvalid;
} LT_InitInfo; } LT_InitInfo;
typedef struct typedef struct

View File

@ -31,6 +31,7 @@ ffi.cdef([[
typedef struct typedef struct
{ {
bool escapeChars; bool escapeChars;
bool stripInvalid;
} LT_InitInfo; } LT_InitInfo;
typedef struct typedef struct