2 // RMAC - Reboot's Macro Assembler for all Atari computers
3 // ERROR.C - Error Handling
4 // Copyright (C) 199x Landon Dyer, 2011-2017 Reboot and Friends
5 // RMAC derived from MADMAC v1.07 Written by Landon Dyer, 1986
6 // Source utilised with the kind permission of Landon Dyer
14 int errcnt; // Error count
15 char * err_fname; // Name of error message file
17 static long unused; // For supressing 'write' warnings
21 // Report error if not at EOL
22 // N.B.: Since this should *never* happen, we can feel free to add whatever
23 // diagnostics that will help in tracking down a problem to this function.
29 error("syntax error. expected EOL, found $%X ('%c')", *tok, *tok);
41 // Cannot create a file
43 void cantcreat(const char * fn)
45 printf("cannot create: '%s'\n", fn);
51 // Setup for error message
52 // o Create error listing file (if necessary)
53 // o Set current filename
59 if (err_fname != NULL)
61 strcpy(fnbuf, err_fname);
64 strcpy(fnbuf, firstfname);
68 if ((err_fd = open(fnbuf, _OPEN_FLAGS, _PERM_MODE)) < 0)
77 // Display error message (uses printf() style variable arguments)
79 int error(const char * text, ...)
88 vsprintf(buf, text, arg);
94 sprintf(buf1, "%s %d: Error: %s\n", curfname, curlineno, buf);
97 unused = write(err_fd, buf1, (LONG)strlen(buf1));
109 // Display warning message (uses printf() style variable arguments)
111 int warn(const char * text, ...)
119 vsprintf(buf, text, arg);
125 sprintf(buf1, "%s %d: Warning: %s\n", curfname, curlineno, buf);
128 unused = write(err_fd, buf1, (LONG)strlen(buf1));
138 int fatal(const char * s)
147 sprintf(buf, "%s %d: Fatal: %s\n", curfname, curlineno, s);
150 unused = write(err_fd, buf, (LONG)strlen(buf));
163 sprintf(buf, "%s %d: Internal error #%d\n", curfname, curlineno, n);
169 unused = write(err_fd, buf, (LONG)strlen(buf));