Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions cpp1.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ int PREFIX fppPreProcess(REG(a0) struct fppTag *tags)
{
int i=0;
ReturnCode ret; /* cpp return code */
int retVal; /* fppPreProcess return code */
struct Global *global;

global=(struct Global *)malloc(sizeof(struct Global));
Expand Down Expand Up @@ -143,10 +144,16 @@ int PREFIX fppPreProcess(REG(a0) struct fppTag *tags)
}
fflush(stdout);
fclose(stdout);
delalldefines(global);

retVal = IO_NORMAL;
if (global->errors > 0 && !global->eflag)
return(IO_ERROR);
return(IO_NORMAL); /* No errors or -E option set */
retVal = IO_ERROR;
free(global->tokenbuf);
free(global->functionname);
free(global->spacebuf);
free(global);
return retVal; /* No errors or -E option set */
}

INLINE FILE_LOCAL
Expand Down
2 changes: 1 addition & 1 deletion cpp3.c
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ ReturnCode initdefines(struct Global *global)
return(FPP_OK);
}

void deldefines(struct Global *global)
void delbuiltindefines(struct Global *global)
{
/*
* Delete the built-in #define's.
Expand Down
25 changes: 24 additions & 1 deletion cpp6.c
Original file line number Diff line number Diff line change
Expand Up @@ -618,12 +618,35 @@ DEFBUF *defendel(struct Global *global,
}


void delalldefines(struct Global *global)
{
/*
* Delete all the defines in the tables and free memory
*/

DEFBUF *dp;
DEFBUF *prevp;
int i;

for (i = 0; i < SBSIZE; ++i)
{
prevp = global->symtab[i];
while ((dp = prevp) != (DEFBUF *)NULL) {
prevp = dp->link;
free(dp->repl); /* Free the replacement */
free((char *)dp); /* Free the symbol */
}
global->symtab[i] = NULL;
}
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please adapt this code to use the same code style as elsewhere?



void outdefines(struct Global *global)
{
DEFBUF *dp;
DEFBUF **syp;

deldefines(global); /* Delete built-in #defines */
delbuiltindefines(global); /* Delete built-in #defines */
for (syp = global->symtab; syp < &global->symtab[SBSIZE]; syp++) {
if ((dp = *syp) != (DEFBUF *) NULL) {
do {
Expand Down
3 changes: 2 additions & 1 deletion cppadd.h
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,8 @@ void dumpadef(char *, register DEFBUF *);
#endif
ReturnCode openfile(struct Global *,char *);
int cget(struct Global *);
void deldefines(struct Global *);
void delbuiltindefines(struct Global *);
void delalldefines(struct Global *);
char *Getmem(struct Global *, int);
ReturnCode openinclude(struct Global *, char *, int);
ReturnCode expstuff(struct Global *, char *, char *);