Мале стилске промене

This commit is contained in:
kappa 2019-11-30 20:18:21 +01:00
parent bd36290735
commit fa931c0d33
2 changed files with 44 additions and 30 deletions

16
print.c
View file

@ -6,19 +6,21 @@ void printValue(object input);
int Print(object input)
{
if (TYPE(input) == errorObject)
switch (TYPE(input))
{
case errorObject:
fprintf(stderr, "\nГРЕШКА: %s\n\n", ERR(input));
}
else if (TYPE(input) == EOFObject)
{
break;
case EOFObject:
return 0;
}
else if (TYPE(input) != unspecifiedObject)
{
break;
case unspecifiedObject:
break;
default:
printf("\n");
printValue(input);
printf("\n\n");
break;
}
return 1;

56
util.c
View file

@ -179,23 +179,15 @@ int improperListLength(object list)
void deleteObject(object input)
{
if (TYPE(input) == symbolObject && SYM(input) != NULL)
{
free(SYM(input));
SYM(input) = NULL;
}
else if (TYPE(input) == stringObject && STR(input) != NULL)
{
free(STR(input));
STR(input) = NULL;
}
else if (TYPE(input) == errorObject && ERR(input) != NULL)
{
free(ERR(input));
ERR(input) = NULL;
}
else if (TYPE(input) == procedureObject)
switch (TYPE(input))
{
case consObject:
deleteObject(CAR(input));
deleteObject(CDR(input));
free(CONS(input));
CONS(input) = NULL;
break;
case procedureObject:
if (PROC_TYPE(input) == compoundProc)
{
deleteObject(PROC_COMP_ARGS(input));
@ -203,13 +195,33 @@ void deleteObject(object input)
}
free(PROC(input));
PROC(input) = NULL;
}
else if (TYPE(input) == consObject)
break;
case symbolObject:
if (SYM(input) == NULL)
{
deleteObject(CAR(input));
deleteObject(CDR(input));
free(CONS(input));
CONS(input) = NULL;
break;
}
free(SYM(input));
SYM(input) = NULL;
break;
case stringObject:
if (STR(input) == NULL)
{
break;
}
free(STR(input));
STR(input) = NULL;
break;
case errorObject:
if (ERR(input) == NULL)
{
break;
}
free(ERR(input));
ERR(input) = NULL;
break;
default:
break;
}
TYPE(input) = nilObject;