/* Standard debugging and error tracking functions for the MacOS */ /* **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** */ /* **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** */ /* Preprocessor Includes */ #include "stdtypes.h" #include "stddebug.h" /* **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** */ /* **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** */ /* Preprocessor Declarations */ #define EOL "\r\n" #define MSG ((fatal) ? "Assert" : ((thrown) ? "Throw" : "Trace")) /* **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** */ /* **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** */ static StringPtr pcstrcat(StringPtr pstr, char *cstr) { while(*cstr) pstr[++(pstr[0])] = *cstr++; return(pstr); } /* **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** */ /* **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** */ static StringPtr pnumcat(StringPtr str, long num) { register long i, j, nonzero = 0; if (num < 0) str[++(str[0])]='-', num=0-num; for(i=8, j=100000000; i>=0; i--, j/=10) if (nonzero || (num/j)%10 || !i) { str[++(str[0])] = '0' + (num/j)%10; nonzero = 1; /* Our first digit */ } return(str); } /* **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** */ /* **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** */ PASCAL void Debug(char *msg, long err, char *file, char *line, int thrown, int fatal) { Str255 debugstr = "\p"; if (!msg || !*msg) msg = MSG; pcstrcat(debugstr, msg); pcstrcat(debugstr, " : "); pnumcat(debugstr, err); pcstrcat(debugstr, " @ "); pcstrcat(debugstr, file); pcstrcat(debugstr, ":"); pcstrcat(debugstr, line); if (!fatal && !thrown) pcstrcat(debugstr, ";g"); DebugStr(debugstr); if (fatal) ExitToShell(); }