diff --git a/repl/lib_standard.c b/repl/lib_standard.c index 786cbd3..3c160b9 100644 --- a/repl/lib_standard.c +++ b/repl/lib_standard.c @@ -661,7 +661,7 @@ static int nativeConcat(Toy_Interpreter* interpreter, Toy_LiteralArray* argument } //get the combined length for the new string - size_t length = TOY_AS_STRING(selfLiteral)->length + TOY_AS_STRING(otherLiteral)->length + 1; + size_t length = TOY_AS_STRING(selfLiteral)->length + TOY_AS_STRING(otherLiteral)->length; if (length > TOY_MAX_STRING_LENGTH) { interpreter->errorOutput("Can't concatenate these strings, result is too long (error found in concat)\n"); @@ -671,8 +671,8 @@ static int nativeConcat(Toy_Interpreter* interpreter, Toy_LiteralArray* argument } //allocate the space and generate - char* buffer = TOY_ALLOCATE(char, length); - snprintf(buffer, length, "%s%s", Toy_toCString(TOY_AS_STRING(selfLiteral)), Toy_toCString(TOY_AS_STRING(otherLiteral))); + char* buffer = TOY_ALLOCATE(char, length + 1); + snprintf(buffer, length + 1, "%s%s", Toy_toCString(TOY_AS_STRING(selfLiteral)), Toy_toCString(TOY_AS_STRING(otherLiteral))); Toy_Literal result = TOY_TO_STRING_LITERAL(Toy_createRefString(buffer)); diff --git a/source/toy_ast_node.c b/source/toy_ast_node.c index 1397846..336c88b 100644 --- a/source/toy_ast_node.c +++ b/source/toy_ast_node.c @@ -362,8 +362,8 @@ void Toy_emitASTNodeAnd(Toy_ASTNode** nodeHandle, Toy_ASTNode* rhs) { Toy_ASTNode* tmp = TOY_ALLOCATE(Toy_ASTNode, 1); tmp->type = TOY_AST_NODE_AND; - tmp->binary.left = *nodeHandle; - tmp->binary.right = rhs; + tmp->pathAnd.left = *nodeHandle; + tmp->pathAnd.right = rhs; *nodeHandle = tmp; } @@ -372,8 +372,8 @@ void Toy_emitASTNodeOr(Toy_ASTNode** nodeHandle, Toy_ASTNode* rhs) { Toy_ASTNode* tmp = TOY_ALLOCATE(Toy_ASTNode, 1); tmp->type = TOY_AST_NODE_OR; - tmp->binary.left = *nodeHandle; - tmp->binary.right = rhs; + tmp->pathOr.left = *nodeHandle; + tmp->pathOr.right = rhs; *nodeHandle = tmp; } diff --git a/source/toy_literal.c b/source/toy_literal.c index dac2ea3..ecc298f 100644 --- a/source/toy_literal.c +++ b/source/toy_literal.c @@ -455,8 +455,8 @@ static void printToBuffer(const char* str) { globalPrintBuffer = TOY_GROW_ARRAY(char, globalPrintBuffer, oldCapacity, globalPrintCapacity); } - snprintf(globalPrintBuffer + globalPrintCount, strlen(str) + 1, "%s", str ? str : "\0"); - globalPrintCount += strlen(str); + size_t total = snprintf(globalPrintBuffer + globalPrintCount, strlen(str) + 1, "%s", str ? str : ""); + globalPrintCount += total; } //exposed functions