Skip to content

Commit

Permalink
fix: deactivate code from stdin on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
jaromil committed Nov 25, 2024
1 parent 3ea2a27 commit 2a5e425
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ There are various build targets, just type `make` to have a list:
apple-osx 🍎 Build cjit.command for Apple/OSX using clang static
_
------ __ Debugging targets
linux-asan 🔬 Build using the address sanitizer to detect memory leaks
debug-asan 🔬 Build using the address sanitizer to detect memory leaks
_
------ __ Testing targets
check 🧪 Run all tests using the currently built binary ./cjit
Expand Down
10 changes: 9 additions & 1 deletion src/cjit.c
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,11 @@ int main(int argc, char **argv) {

char *stdin_code = NULL;
if(opt.ind >= argc) {
_err("No files specified on commandline, reading code from stdin\n");
#ifdef LIBC_MINGW32
_err("No files specified on commandline");
goto endgame;
#endif
_err("No files specified on commandline, reading code from stdin");
stdin_code = load_stdin(); // allocated returned buffer, needs free
if(!stdin_code) {
_err("Error reading from standard input");
Expand All @@ -244,6 +248,10 @@ int main(int argc, char **argv) {
_err("%c %s",(*code_path=='-'?'|':'+'),
(*code_path=='-'?"standard input":code_path));
if(*code_path=='-') { // stdin explicit
#ifdef LIBC_MINGW32
_err("Code from standard input not supported on Windows");
goto endgame;
#endif
stdin_code = load_stdin(); // allocated returned buffer, needs free
if(!stdin_code) {
_err("Error reading from standard input");
Expand Down
4 changes: 4 additions & 0 deletions src/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ char* file_load(const char *filename) {
}

char *load_stdin() {
#ifdef LIBC_MINGW32
return NULL;
#else
char *code = NULL;
char *line = NULL;
size_t len = 0;
Expand All @@ -104,6 +107,7 @@ char *load_stdin() {
line = NULL;
}
return(code);
#endif
}

bool write_to_file(char *path, char *filename, char *buf, unsigned int len) {
Expand Down

0 comments on commit 2a5e425

Please sign in to comment.