From 5e0268f519c0388e493791fb8fe4ff848752b803 Mon Sep 17 00:00:00 2001 From: Ratstail91 Date: Thu, 23 Feb 2023 03:26:51 +1100 Subject: [PATCH] Fixed misplaced prebuild step --- Airport.vcxproj | 6 ++++-- Box.vcxproj | 8 ++++++++ box/repl_tools.c | 10 +++++----- box/repl_tools.h | 2 +- 4 files changed, 18 insertions(+), 8 deletions(-) diff --git a/Airport.vcxproj b/Airport.vcxproj index 217581b..f7e824b 100644 --- a/Airport.vcxproj +++ b/Airport.vcxproj @@ -122,7 +122,8 @@ - xcopy "$(SolutionDir)Toy\repl\lib*.*" "$(SolutionDir)box" /Y /I /E + + @@ -137,7 +138,8 @@ SDL2main.lib;SDL2.lib;SDL2_image.lib;Toy.lib;Box.lib;%(AdditionalDependencies) - xcopy "$(SolutionDir)Toy\repl\lib*.*" "$(SolutionDir)box" /Y /I /E + + diff --git a/Box.vcxproj b/Box.vcxproj index d740cd7..7edb6ee 100644 --- a/Box.vcxproj +++ b/Box.vcxproj @@ -116,6 +116,10 @@ $(SDL2Dir)\lib\x64;$(SDL2ImageDir)\lib\x64;$(SolutionDir)out\$(Configuration)\;%(AdditionalLibraryDirectories) SDL2.lib;SDL2_image.lib;Toy.lib;%(AdditionalDependencies) + + xcopy "$(SolutionDir)Toy\repl\lib*.*" "$(SolutionDir)box" /Y /I /E +xcopy "$(SolutionDir)Toy\repl\repl_tools.*" "$(SolutionDir)box" /Y /I /E + @@ -127,6 +131,10 @@ $(SDL2Dir)\lib\x64;$(SDL2ImageDir)\lib\x64;$(SolutionDir)out\$(Configuration)\;%(AdditionalLibraryDirectories) SDL2.lib;SDL2_image.lib;Toy.lib;%(AdditionalDependencies) + + xcopy "$(SolutionDir)Toy\repl\lib*.*" "$(SolutionDir)box" /Y /I /E +xcopy "$(SolutionDir)Toy\repl\repl_tools.*" "$(SolutionDir)box" /Y /I /E + diff --git a/box/repl_tools.c b/box/repl_tools.c index 2d13715..0b46080 100644 --- a/box/repl_tools.c +++ b/box/repl_tools.c @@ -14,7 +14,7 @@ #include //IO functions -const char* Toy_readFile(const char* path, size_t* fileSize) { +const unsigned char* Toy_readFile(const char* path, size_t* fileSize) { FILE* file = fopen(path, "rb"); if (file == NULL) { @@ -26,14 +26,14 @@ const char* Toy_readFile(const char* path, size_t* fileSize) { *fileSize = ftell(file); rewind(file); - char* buffer = (char*)malloc(*fileSize + 1); + unsigned char* buffer = (unsigned char*)malloc(*fileSize + 1); if (buffer == NULL) { fprintf(stderr, TOY_CC_ERROR "Not enough memory to read \"%s\"\n" TOY_CC_RESET, path); return NULL; } - size_t bytesRead = fread(buffer, sizeof(char), *fileSize, file); + size_t bytesRead = fread(buffer, sizeof(unsigned char), *fileSize, file); buffer[*fileSize] = '\0'; //NOTE: fread doesn't append this @@ -120,7 +120,7 @@ void Toy_runBinary(const unsigned char* tb, size_t size) { void Toy_runBinaryFile(const char* fname) { size_t size = 0; //not used - const unsigned char* tb = (const unsigned char*)Toy_readFile(fname, &size); + const unsigned char* tb = Toy_readFile(fname, &size); if (!tb) { return; } @@ -140,7 +140,7 @@ void Toy_runSource(const char* source) { void Toy_runSourceFile(const char* fname) { size_t size = 0; //not used - const char* source = Toy_readFile(fname, &size); + const char* source = (const char*)Toy_readFile(fname, &size); if (!source) { return; } diff --git a/box/repl_tools.h b/box/repl_tools.h index 819f752..235cef8 100644 --- a/box/repl_tools.h +++ b/box/repl_tools.h @@ -2,7 +2,7 @@ #include "toy_common.h" -const char* Toy_readFile(const char* path, size_t* fileSize); +const unsigned char* Toy_readFile(const char* path, size_t* fileSize); int Toy_writeFile(const char* path, const unsigned char* bytes, size_t size); const unsigned char* Toy_compileString(const char* source, size_t* size);