Beispiel #1
0
myerror *addError(myerror *in, const char *message, char *text, int location, int line) {
	myerror *sNew = NULL;
	if(detectDupError(in, location, line) != NULL) {
		return in;
	} /* if */
	sNew = (myerror*)malloc(sizeof(myerror));
	memset(sNew->message, '\0', 256);
	memset(sNew->text, '\0', 4096);
	if(message != NULL) {
		strcpy(sNew->message, message);
	} else {
		return NULL;
	} /*if*/
	if(text != NULL) {
		strcpy(sNew->text, text);
	} /*if*/
	sNew->line = line;
	sNew->location = location;
	sNew->next = NULL;
	sNew->last = sNew;
	if(in == NULL) {
		in = sNew;
	} else {
		in->last->next = sNew;
		in->last = sNew;
	} /*if*/
	return in;
} /*addError*/
Beispiel #2
0
myerror *addError(myerror *in, const char *message, int location, int line, error_type errType) {
    if (errType == ET_ERROR) {
        numErrors += 1;
    } else {
        numWarnings += 1;
    }
	myerror *sNew = NULL;
	int errorTextLength = 0;
    line++;
	if(detectDupError(in, location, line) != NULL) {
		return in;
	} /* if */
	sNew = (myerror*)malloc(sizeof(myerror));
	memset(sNew->message, '\0', 256);
    if (illegalChar != 0) {
        char illegalCharMsg[21];
        sprintf(illegalCharMsg, "illegal character, %c", illegalChar);
        strcpy(sNew->message, illegalCharMsg);
        illegalChar = 0;
    } else if(message != NULL) {
		strcpy(sNew->message, message);
	} else {
		return NULL;
	} /*if*/
	sNew->text = NULL;
	sNew->errorTextLength = 0;
	sNew->line = line - 1;
	sNew->location = location;
	sNew->next = NULL;
	sNew->last = sNew;
    sNew->errType = errType;
	if(in == NULL) {
		in = sNew;
	} else {
		in->last->next = sNew;
		in->last = sNew;
	} /*if*/
	return in;
} /*addError*/