int allocInfo = 1;
symbol *mainf;
extern char *VersionString;
+set *pipeSet = NULL; /* set of pipes */
set *tmpfileSet = NULL; /* set of tmp file created by the compiler */
set *tmpfileNameSet = NULL; /* All are unlinked at close. */
+/*-----------------------------------------------------------------*/
+/* closePipes - closes all pipes created by the compiler */
+/*-----------------------------------------------------------------*/
+DEFSETFUNC (closePipes)
+{
+ FILE *pfile = item;
+ int ret;
+
+ if (pfile) {
+ ret = pclose (pfile);
+ assert(ret != -1);
+ }
+
+ return 0;
+}
+
/*-----------------------------------------------------------------*/
/* closeTmpFiles - closes all tmp files created by the compiler */
/* because of BRAIN DEAD MS/DOS & CYGNUS Libraries */
DEFSETFUNC (closeTmpFiles)
{
FILE *tfile = item;
+ int ret;
- if (tfile)
- fclose (tfile);
+ if (tfile) {
+ ret = fclose (tfile);
+ assert(ret == 0);
+ }
return 0;
}
DEFSETFUNC (rmTmpFiles)
{
char *name = item;
+ int ret;
- if (name)
- {
- unlink (name);
+ if (name) {
+ ret = unlink (name);
+ assert(ret == 0);
Safe_free (name);
- }
+ }
+
return 0;
}
rm_tmpfiles (void)
{
/* close temporary files */
+ applyToSet (pipeSet, closePipes);
+ /* close temporary files */
+ deleteSet (&pipeSet);
+
applyToSet (tmpfileSet, closeTmpFiles);
/* remove temporary files */
applyToSet (tmpfileNameSet, rmTmpFiles);
/* address of symbol */
if (IS_AST_SYM_VALUE (expr->left)) {
val = copyValue (AST_VALUE (expr->left));
- val->type = newLink ();
+ val->type = newLink (DECLARATOR);
if (SPEC_SCLS (expr->left->etype) == S_CODE) {
DCL_TYPE (val->type) = CPOINTER;
- DCL_PTR_CONST (val->type) = port->mem.code_ro;
+ DCL_TYPE (val->type) = port->mem.code_ro;
}
else if (SPEC_SCLS (expr->left->etype) == S_XDATA)
DCL_TYPE (val->type) = FPOINTER;
IS_ARRAY(expr->right->ftype)) {
val = copyValue (AST_VALUE (expr->right));
- val->type = newLink ();
+ val->type = newLink (DECLARATOR);
if (SPEC_SCLS (expr->right->etype) == S_CODE) {
DCL_TYPE (val->type) = CPOINTER;
DCL_PTR_CONST (val->type) = port->mem.code_ro;
iloop = ilist->init.deep;
lcnt = DCL_ELEM (type);
- for (last_type = type->next; last_type && DCL_ELEM (last_type); last_type = last_type->next)
+ for (last_type = type->next;
+ last_type && IS_DECL(last_type) && DCL_ELEM (last_type);
+ last_type = last_type->next) {
lcnt *= DCL_ELEM (last_type);
+ }
for (;;)
{
resolveIvalSym (sym->ival);
printIval (sym, sym->type, sym->ival, out);
noAlloc--;
- // if sym->ival is a string, WE don't need it anymore
- if (IS_AST_SYM_VALUE(list2expr(sym->ival)) &&
+ /* if sym is a simple string and sym->ival is a string,
+ WE don't need it anymore */
+ if (IS_ARRAY(sym->type) && IS_CHAR(sym->type->next) &&
+ IS_AST_SYM_VALUE(list2expr(sym->ival)) &&
list2val(sym->ival)->sym->isstrlit) {
freeStringSymbol(list2val(sym->ival)->sym);
}
char fnamebuf[PATH_MAX];
if ((fd = tempfileandname(fnamebuf, sizeof fnamebuf)) == -1) {
- fprintf(stderr, "Can't create temporary file name!");
+ fprintf(stderr, "Can't create temporary file!");
exit(1);
}
addSetHead(&tmpfileNameSet, tmp);
if ((fp = fdopen(fd, "w+b")) == NULL) {
- perror("Can't create temporary file name!");
+ perror("Can't create temporary file!");
exit(1);
}