Skip to content

Commit

Permalink
Fixed multiple bugs in file and io.
Browse files Browse the repository at this point in the history
  • Loading branch information
ax-6 committed Jul 31, 2024
1 parent eed4720 commit 9958620
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion aqvm/base/file/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ int AqvmBaseFile_feof(struct AqvmBaseFile_File* stream) {
}

int AqvmBaseFile_ferror(struct AqvmBaseFile_File* stream) {
if (stream == NULL || stream->file == NULL || AqvmBaseFile_ferror(stream)) {
if (stream == NULL || stream->file == NULL || ferror(stream->file)) {
// TODO
return -1;
}
Expand Down
14 changes: 7 additions & 7 deletions aqvm/base/io/io.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
AqvmBaseThreadingMutex_Mutex AqvmBaseIo_printMutex;

struct AqvmBaseFile_File AqvmBaseIo_stdoutStream;
extern struct AqvmBaseFile_File* AqvmBaseIo_stdout = &AqvmBaseIo_stdoutStream;
struct AqvmBaseFile_File* AqvmBaseIo_stdout = &AqvmBaseIo_stdoutStream;

struct AqvmBaseFile_File AqvmBaseIo_stdinStream;
extern struct AqvmBaseFile_File* AqvmBaseIo_stdin = &AqvmBaseIo_stdinStream;
struct AqvmBaseFile_File* AqvmBaseIo_stdin = &AqvmBaseIo_stdinStream;

struct AqvmBaseFile_File AqvmBaseIo_stderrStream;
extern struct AqvmBaseFile_File* AqvmBaseIo_stderr = &AqvmBaseIo_stderrStream;
struct AqvmBaseFile_File* AqvmBaseIo_stderr = &AqvmBaseIo_stderrStream;

int AqvmBaseIo_InitializeIo() {
AqvmBaseIo_stdoutStream.file = stdout;
Expand Down Expand Up @@ -88,7 +88,7 @@ int AqvmBaseIo_fgetc(struct AqvmBaseFile_File* stream) {
}

if (result == EOF) {
if (AQvmBaseFile_feof(stream)) {
if (AqvmBaseFile_feof(stream)) {
return EOF;
}
// TODO
Expand Down Expand Up @@ -417,7 +417,7 @@ int AqvmBaseIo_getc(struct AqvmBaseFile_File* stream) {
}

if (result == EOF) {
if (AQvmBaseFile_feof(stream)) {
if (AqvmBaseFile_feof(stream)) {
return EOF;
} else {
// TODO
Expand All @@ -429,7 +429,7 @@ int AqvmBaseIo_getc(struct AqvmBaseFile_File* stream) {
}

int AqvmBaseIo_getchar(void) {
if (AqvmBaseFile_ferror(stdin)) {
if (AqvmBaseFile_ferror(AqvmBaseIo_stdin)) {
// TODO
return -2;
}
Expand Down Expand Up @@ -556,7 +556,7 @@ int AqvmBaseIo_putc(int character, struct AqvmBaseFile_File* stream) {
}

int AqvmBaseIo_putchar(int character) {
if (AqvmBaseFile_ferror(stdout)) {
if (AqvmBaseFile_ferror(AqvmBaseIo_stdout)) {
// TODO
return -2;
}
Expand Down

0 comments on commit 9958620

Please sign in to comment.