Skip to content

Commit

Permalink
Fixed error messages
Browse files Browse the repository at this point in the history
- Removed error_message_line and done everything properly ;)
- Added code tests to make test. CI IMPROVAL :D
  • Loading branch information
Fubukimaru committed Nov 1, 2020
1 parent 98f65a6 commit 2341872
Show file tree
Hide file tree
Showing 7 changed files with 210 additions and 217 deletions.
12 changes: 3 additions & 9 deletions src/asmsx.c
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ int d_rand(void)


// Function for errors
void error_message_line(int n, unsigned int show_line, char* fname_src, int lines)
void error_message(int n, char* fname_src, int lines)
{
fflush(stdout); // Flush output so error is in the end.
switch (n)
Expand Down Expand Up @@ -590,7 +590,7 @@ void error_message_line(int n, unsigned int show_line, char* fname_src, int line
default:
sprintf(error_buffer, "Unexpected error code %d\n", n);
}
if (show_line) {
if (lines >= 0) {
fprintf(stderr, "%s, line %d: %s", strtok(fname_src, "\042"), lines, error_buffer);
} else {
fprintf(stderr, "%s", error_buffer);
Expand All @@ -599,12 +599,6 @@ void error_message_line(int n, unsigned int show_line, char* fname_src, int line
exit(n + 1);
}


void error_message(int n)
{
error_message_line(n, 1, 0, 0);
}

void warning_message(int n, char* fname_src, int lines, int pass, int* warnings)
{
if (pass != 2)
Expand Down Expand Up @@ -647,7 +641,7 @@ void warning_message(int n, char* fname_src, int lines, int pass, int* warnings)
char* safe_strcat(char* dest, char* orig, unsigned int max_size, char* fname_src, int lines)
{
if ((strlen(dest) + strlen(orig)) > max_size) {
error_message_line(47, 0, fname_src, lines);
error_message(47, fname_src, lines);
}
strcat(dest, orig);
return(dest);
Expand Down
3 changes: 1 addition & 2 deletions src/asmsx.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,5 @@ extern char error_buffer[124];
extern void write_tape(const int, const char *, const char *, const int, const int, const int, const int, const char *);
int d_rand(void);
extern char* safe_strcat(char* dest, char* orig, unsigned int max_size, char* fname_src, int lines);
extern void error_message_line(int n, unsigned int show_line, char* fname_src, int lines);
extern void error_message(int);
extern void error_message(int n, char* fname_src, int lines);
extern void warning_message(int n, char* fname_src, int lines, int pass, int* warnings);
Loading

0 comments on commit 2341872

Please sign in to comment.