UtilCode/CoreAssertion.c

#include "CoreAssertion.h"
 
 
 
strcatnum(char *str, short num)
{
    Str31   lineStr;
    
    NumToString((long)num,lineStr); // convert number to pascal string
    lineStr[lineStr[0]+1] = 0x00;   // null terminate the string
    lineStr[0] = ' ';               // make first byte a space
    strcat(str,lineStr);            // append number text to string
}
 
void CoreAssert(short expEval, char *expr, char *file, short linenum)
/* This routine will build an error message from the information passed */
/* and drop into the debugger */
{
    char    str[256];
    char    *header = "ASSERTION FAILURE: '";
    char    *filePfx = "' IN FILE ";
    char    *linePfx = " LINE #";
    char    *postFix = "; SC6";
    char    *evalPfx = " EXP =";
    
    strcpy(&str[1],header);         // put the asssertion failure message first
    strcat(&str[1], (void*)expr);           // copy the expression that evaluated to false
    strcat(&str[1], (void*)filePfx);        // display file prefix
    strcat(&str[1], (void*)file);           // append file name to error message
    strcat(&str[1],(void*)linePfx);     // display line number prefix
    strcatnum(&str[1],linenum);     // display the line number
    strcat(&str[1],(void*)evalPfx);     // display the evaluation prefix
    strcatnum(&str[1],expEval);     // display the evaluation result
 
    /* Display the error message in the debugger */
    strcat(&str[1],(void*)postFix);     // add macsbug commands to end of error message
    str[0] = strlen(&str[1]);       // set the length byte for pascal string
    DebugStr(str);
}