Skip to content

Commit

Permalink
Added invalid file name errors
Browse files Browse the repository at this point in the history
  • Loading branch information
OJddJO committed Nov 6, 2024
1 parent 6882330 commit 2ba2f8d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
3 changes: 0 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@
> [!IMPORTANT]
> Word is still in development, some functionalities may not work as expected or may be missing. Please report any issues you encounter.
> [!WARNING]
> There are currently many memory leaks, high memory usage is expected. I'm currently working on them.
WordLanguage is a programming language designed to minimize the use of symbols, making it easy to read and write. Its syntax is simple and closely resembles natural language, aiming to be both easy to learn and powerful enough for complex programming tasks.

**Key Features**:
Expand Down
Binary file modified bin/word.exe
Binary file not shown.
9 changes: 9 additions & 0 deletions src/interpreter.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,15 @@ int main(int argc, char *argv[]) {
return 1;
}

if (strlen(argv[1]) < 3) {
fprintf(stderr, "Error: Invalid file name\n");
return 1;
}
if (strcmp(argv[1] + strlen(argv[1]) - 2, ".w") != 0) {
fprintf(stderr, "Error: Invalid file extension\n");
return 1;
}

FILE *file;
if (DEBUG) file = fopen("test.w", "r"); //DEBUG
else file = fopen(argv[1], "r");
Expand Down

0 comments on commit 2ba2f8d

Please sign in to comment.