X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?p=rmac;a=blobdiff_plain;f=error.c;h=81f0633f771d0175237756e684129cff5fb4292a;hp=fa4ceb54a7ee8c64346f70ffaa53660eb2090df3;hb=03dd34951a331e0b8971195ccef1600fffaea2e6;hpb=44301fed8a6d94673afa3aae3a8a0a76aebac6f7 diff --git a/error.c b/error.c index fa4ceb5..81f0633 100644 --- a/error.c +++ b/error.c @@ -1,19 +1,20 @@ // -// RMAC - Reboot's Macro Assembler for the Atari Jaguar Console System +// RMAC - Reboot's Macro Assembler for all Atari computers // ERROR.C - Error Handling -// Copyright (C) 199x Landon Dyer, 2011 Reboot and Friends +// Copyright (C) 199x Landon Dyer, 2011-2017 Reboot and Friends // RMAC derived from MADMAC v1.07 Written by Landon Dyer, 1986 -// Source Utilised with the Kind Permission of Landon Dyer +// Source utilised with the kind permission of Landon Dyer // #include "error.h" #include "token.h" #include "listing.h" -int errcnt; // Error count -char * err_fname; // Name of error message file +int errcnt; // Error count +char * err_fname; // Name of error message file -static char nl[] = "\n"; +static const char nl[] = "\n"; +static long unused; // For supressing 'write' warnings // @@ -21,25 +22,30 @@ static char nl[] = "\n"; // int at_eol(void) { - if (*tok != EOL) - error("syntax error"); + char msg[256]; - return 0; + if (*tok != EOL) + { + sprintf(msg, "syntax error. expected EOL, found $%X ('%c')", *tok, *tok); + error(msg); + } + + return 0; } // -// Cannot Create a File +// Cannot create a file // -void cantcreat(char * fn) +void cantcreat(const char * fn) { - printf("cannot create: '%s'\n", fn); - exit(1); + printf("cannot create: '%s'\n", fn); + exit(1); } // -// Setup for Error Message +// Setup for error message // o Create error listing file (if necessary) // o Set current filename // @@ -69,7 +75,7 @@ void err_setup(void) // -// Display Error Message +// Display error message // int error(const char * s) { @@ -85,7 +91,7 @@ int error(const char * s) length = strlen(buf); if (err_flag) - write(err_fd, buf, length); + unused = write(err_fd, buf, length); else printf("%s", buf); @@ -96,7 +102,7 @@ int error(const char * s) } -int errors(char * s, char * s1) +int errors(const char * s, char * s1) { char buf[EBUFSIZ]; char buf1[EBUFSIZ]; @@ -110,7 +116,7 @@ int errors(char * s, char * s1) sprintf(buf1, "%s %d: Error: %s%s", curfname, curlineno, buf, nl); if (err_flag) - write(err_fd, buf1, (LONG)strlen(buf1)); + unused = write(err_fd, buf1, (LONG)strlen(buf1)); else printf("%s", buf1); @@ -121,7 +127,7 @@ int errors(char * s, char * s1) } -int warn(char * s) +int warn(const char * s) { char buf[EBUFSIZ]; @@ -133,7 +139,7 @@ int warn(char * s) sprintf(buf, "%s %d: Warning: %s%s", curfname, curlineno, s, nl); if (err_flag) - write(err_fd, buf, (LONG)strlen(buf)); + unused = write(err_fd, buf, (LONG)strlen(buf)); else printf("%s", buf); @@ -143,7 +149,7 @@ int warn(char * s) } -int warns(char * s, char * s1) +int warns(const char * s, char * s1) { char buf[EBUFSIZ]; char buf1[EBUFSIZ]; @@ -157,7 +163,7 @@ int warns(char * s, char * s1) sprintf(buf1, "%s %d: Warning: %s%s", curfname, curlineno, buf, nl); if (err_flag) - write(err_fd, buf1, (LONG)strlen(buf1)); + unused = write(err_fd, buf1, (LONG)strlen(buf1)); else printf("%s", buf1); @@ -167,7 +173,7 @@ int warns(char * s, char * s1) } -int warni(char * s, unsigned i) +int warni(const char * s, unsigned i) { char buf[EBUFSIZ]; char buf1[EBUFSIZ]; @@ -181,7 +187,7 @@ int warni(char * s, unsigned i) sprintf(buf1, "%s %d: Warning: %s%s", curfname, curlineno, buf, nl); if (err_flag) - write(err_fd, buf1, (LONG)strlen(buf1)); + unused = write(err_fd, buf1, (LONG)strlen(buf1)); else printf("%s", buf1); @@ -191,7 +197,7 @@ int warni(char * s, unsigned i) } -int fatal(char * s) +int fatal(const char * s) { char buf[EBUFSIZ]; @@ -203,7 +209,7 @@ int fatal(char * s) sprintf(buf, "%s %d: Fatal: %s%s", curfname, curlineno, s, nl); if (err_flag) - write(err_fd, buf, (LONG)strlen(buf)); + unused = write(err_fd, buf, (LONG)strlen(buf)); else printf("%s", buf); @@ -222,9 +228,10 @@ int interror(int n) ship_ln(buf); if (err_flag) - write(err_fd, buf, (LONG)strlen(buf)); + unused = write(err_fd, buf, (LONG)strlen(buf)); else printf("%s", buf); exit(1); } +