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 switch (cur_inobj->in_type)
97 sprintf(buf1, "%s %d: Error: %s\n", curfname, curlineno, buf);
100 sprintf(buf1, "%s %d: Error: %s\n", curfname, cur_inobj->inobj.imacro->im_macro->lineList->lineno, buf);
103 sprintf(buf1, "%s %d: Error: %s\n", curfname, cur_inobj->inobj.irept->lineno, buf);
108 unused = write(err_fd, buf1, (LONG)strlen(buf1));
120 // Display warning message (uses printf() style variable arguments)
122 int warn(const char * text, ...)
130 vsprintf(buf, text, arg);
136 sprintf(buf1, "%s %d: Warning: %s\n", curfname, curlineno, buf);
139 unused = write(err_fd, buf1, (LONG)strlen(buf1));
149 int fatal(const char * s)
158 sprintf(buf, "%s %d: Fatal: %s\n", curfname, curlineno, s);
161 unused = write(err_fd, buf, (LONG)strlen(buf));
174 sprintf(buf, "%s %d: Internal error #%d\n", curfname, curlineno, n);
180 unused = write(err_fd, buf, (LONG)strlen(buf));