Updated the way string symbols are handled, allowing the programmer to terminate a string with any byte or none at all.
This commit is contained in:
@@ -40,6 +40,23 @@ Symbol* CreateSymbol(char* name, SymbolType type) {
|
||||
return symbol;
|
||||
}
|
||||
|
||||
SymbolString* CreateSymbolString(char* string, int terminated) {
|
||||
if (!string) return NULL;
|
||||
|
||||
SymbolString* s = calloc(1, sizeof(SymbolString));
|
||||
|
||||
if (!s) {
|
||||
fprintf(stderr, "Failed to calloc string for symbol. %s.\n", strerror(errno));
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
s->String = string;
|
||||
s->Terminated = terminated;
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
Symbol* TryGetSymbol(char* name, SymbolTable* table) {
|
||||
if (!name || !table) return NULL;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user