Archived
1
0

fuck this

This commit is contained in:
Marrub 2015-06-06 10:08:55 -04:00
parent 214a3a7517
commit 5c8f7ede03
3 changed files with 11 additions and 94 deletions

View File

@ -35,8 +35,6 @@ typedef struct
bool doConvert; bool doConvert;
const char *fromCode; const char *fromCode;
const char *toCode; const char *toCode;
const char *stringChars;
const char *charChars; // [marrub] heh
} LT_InitInfo; } LT_InitInfo;
typedef struct typedef struct

101
src/lt.c
View File

@ -40,7 +40,6 @@ static LT_InitInfo info;
static iconv_t icDesc; static iconv_t icDesc;
static bool assertError = false; static bool assertError = false;
static const char *assertString; static const char *assertString;
static char *stringChars, *charChars;
static const char *errors[] = { static const char *errors[] = {
"LT_Error: Syntax error", "LT_Error: Syntax error",
@ -80,6 +79,12 @@ static void LT_DoConvert(char **str)
void LT_Init(LT_InitInfo initInfo) void LT_Init(LT_InitInfo initInfo)
{ {
gbHead = malloc(sizeof(LT_GarbageList));
gbHead->next = NULL;
gbHead->ptr = NULL;
gbRover = gbHead;
info = initInfo; info = initInfo;
if(info.doConvert && info.fromCode != NULL && info.toCode != NULL) if(info.doConvert && info.fromCode != NULL && info.toCode != NULL)
@ -100,68 +105,6 @@ void LT_Init(LT_InitInfo initInfo)
{ {
info.stripInvalid = false; info.stripInvalid = false;
} }
if(info.stringChars != NULL)
{
int i;
stringChars = malloc(6);
for(i = 0; i < 6; i++)
{
char c = info.stringChars[i];
if(c != '\0')
{
stringChars[i] = c;
}
else
{
break;
}
}
stringChars[i] = '\0';
info.stringChars = NULL; // [marrub] don't use this after init
}
else
{
stringChars = "\"";
}
if(info.charChars != NULL)
{
int i;
charChars = malloc(6);
for(i = 0; i < 6; i++)
{
char c = info.charChars[i];
if(c != '\0')
{
charChars[i] = c;
}
else
{
break;
}
}
charChars[i] = '\0';
info.charChars = NULL; // [marrub] don't use this after init
}
else
{
charChars = "'";
}
gbHead = malloc(sizeof(LT_GarbageList));
gbHead->next = NULL;
gbHead->ptr = NULL;
gbRover = gbHead;
} }
void LT_Quit() void LT_Quit()
@ -171,8 +114,6 @@ void LT_Quit()
iconv_close(icDesc); iconv_close(icDesc);
} }
free(stringChars);
gbRover = gbHead; gbRover = gbHead;
while(gbRover != NULL) while(gbRover != NULL)
@ -587,38 +528,18 @@ LT_Token LT_GetToken()
} }
return tk; return tk;
} case '"': case '\'':
tk.string = LT_ReadString(c);
for(size_t i = 0; i < 6;) if(c == '"')
{
char cc = stringChars[i++];
if(cc == '\0')
{ {
break;
}
else if(c == cc)
{
tk.string = LT_ReadString(c);
tk.token = LT_TkNames[TOK_String]; tk.token = LT_TkNames[TOK_String];
return tk;
} }
} else
for(size_t i = 0; i < 6;)
{
char cc = charChars[i++];
if(cc == '\0')
{ {
break;
}
else if(c == cc)
{
tk.string = LT_ReadString(c);
tk.token = LT_TkNames[TOK_Charac]; tk.token = LT_TkNames[TOK_Charac];
return tk;
} }
return tk;
} }
if(isdigit(c)) if(isdigit(c))

View File

@ -72,8 +72,6 @@ typedef struct
bool doConvert; bool doConvert;
const char *fromCode; const char *fromCode;
const char *toCode; const char *toCode;
const char *stringChars;
const char *charChars; // [marrub] heh
} LT_InitInfo; } LT_InitInfo;
typedef struct typedef struct