diff --git a/repl/lib_fileio.c b/repl/lib_fileio.c index de62980..08ed83b 100644 --- a/repl/lib_fileio.c +++ b/repl/lib_fileio.c @@ -235,10 +235,10 @@ static int nativeRead(Toy_Interpreter* interpreter, Toy_LiteralArray* arguments) break; } - case TOY_LITERAL_STRING: { + case TOY_LITERAL_STRING: { //BUG: needs a terminator to show how much to read char value[TOY_MAX_STRING_LENGTH] = {0}; - fread(value, sizeof(char), TOY_MAX_STRING_LENGTH - 1, file->fp); - value[TOY_MAX_STRING_LENGTH - 1] = '\0'; + size_t size = fread(value, sizeof(char), TOY_MAX_STRING_LENGTH - 1, file->fp); + value[size] = '\0'; resultLiteral = TOY_TO_STRING_LITERAL(Toy_createRefString(value)); diff --git a/source/toy_lexer.c b/source/toy_lexer.c index a8e0d4d..25eb78b 100644 --- a/source/toy_lexer.c +++ b/source/toy_lexer.c @@ -178,7 +178,6 @@ static Toy_Token makeIntegerOrFloat(Toy_Lexer* lexer) { static bool isEscapableCharacter(char c) { switch (c) { case 'n': - case 'r': case 't': case '\\': case '"': diff --git a/source/toy_parser.c b/source/toy_parser.c index fed9756..1b4f5af 100644 --- a/source/toy_parser.c +++ b/source/toy_parser.c @@ -281,9 +281,6 @@ static Toy_Opcode string(Toy_Parser* parser, Toy_ASTNode** nodeHandle) { case 'n': buffer[strLength++] = '\n'; break; - case 'r': - buffer[strLength++] = '\r'; - break; case 't': buffer[strLength++] = '\t'; break; diff --git a/test/scripts/lib/fileio.toy b/test/scripts/lib/fileio.toy index 896716d..0f33212 100644 --- a/test/scripts/lib/fileio.toy +++ b/test/scripts/lib/fileio.toy @@ -121,12 +121,13 @@ fn reset() { assert reader.seek("end", -2) == true, "seek from end failed"; contents = reader.read(string); - assert (contents == "!\n" || contents == "\r\n"), "seek failed to move file position (2nd)"; + print ">>>(" + contents + ")" + string( contents.length() ); + assert contents == "\n", "seek failed to move file position (2nd)"; assert reader.seek("cur", -2) == true, "seek from cur failed"; contents = reader.read(string); - assert (contents == "!\n" || contents == "\r\n"), "seek failed to move file position (3rd)"; + assert contents == "\n", "seek failed to move file position (3rd)"; assert reader.seek("CUR", 0) == false, "seek origin failed (1st)"; assert reader.seek("End", 0) == false, "seek origin failed (2nd)"; diff --git a/test/test_libraries.c b/test/test_libraries.c index 3957449..4181639 100644 --- a/test/test_libraries.c +++ b/test/test_libraries.c @@ -44,7 +44,7 @@ void runBinaryWithLibrary(const unsigned char* tb, size_t size, const char* libr Toy_initInterpreter(&interpreter); //NOTE: supress print output for testing - Toy_setInterpreterPrint(&interpreter, noPrintFn); + // Toy_setInterpreterPrint(&interpreter, noPrintFn); Toy_setInterpreterAssert(&interpreter, assertWrapper); Toy_setInterpreterError(&interpreter, errorWrapper);