2019-05-10 17:17:40 +00:00
|
|
|
/*
|
|
|
|
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
|
|
|
|
* See the copyright notice in the ACK home directory, in the file "Copyright".
|
|
|
|
*
|
|
|
|
* Author: Hans van Staveren
|
|
|
|
*/
|
2017-11-10 03:22:13 +00:00
|
|
|
#include <assert.h>
|
1984-05-17 13:42:36 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include "param.h"
|
|
|
|
#include "types.h"
|
1988-09-12 09:13:49 +00:00
|
|
|
#include <em_pseu.h>
|
|
|
|
#include <em_spec.h>
|
|
|
|
#include <em_mes.h>
|
1984-05-17 13:42:36 +00:00
|
|
|
#include "lookup.h"
|
2019-05-10 17:17:40 +00:00
|
|
|
#include "putline.h"
|
|
|
|
#include "util.h"
|
1984-05-17 13:42:36 +00:00
|
|
|
#include "ext.h"
|
|
|
|
|
2019-05-10 17:17:40 +00:00
|
|
|
void cleanup(void)
|
|
|
|
{
|
1984-05-17 13:42:36 +00:00
|
|
|
FILE *infile;
|
2019-05-10 17:17:40 +00:00
|
|
|
register int c;
|
|
|
|
register sym_p *spp, sp;
|
1984-05-17 13:42:36 +00:00
|
|
|
|
2019-05-10 17:17:40 +00:00
|
|
|
for (spp = symhash; spp < &symhash[NSYMHASH]; spp++)
|
|
|
|
for (sp = *spp; sp != (sym_p) 0; sp = sp->s_next)
|
|
|
|
if ((sp->s_flags & SYMOUT) == 0)
|
|
|
|
outdef(sp);
|
|
|
|
if (!Lflag)
|
1984-05-17 13:42:36 +00:00
|
|
|
return;
|
2019-05-10 17:17:40 +00:00
|
|
|
c = fclose(outfile);
|
1984-05-17 13:42:36 +00:00
|
|
|
assert(c != EOF);
|
|
|
|
outfile = stdout;
|
2019-05-10 17:17:40 +00:00
|
|
|
infile = fopen(tempname, "r");
|
1984-05-17 13:42:36 +00:00
|
|
|
if (infile == NULL)
|
|
|
|
error("temp file disappeared");
|
|
|
|
outshort(sp_magic);
|
1987-05-20 13:56:26 +00:00
|
|
|
/* Attempt to first output the word_size message */
|
2019-05-10 17:17:40 +00:00
|
|
|
while ((c = getc(infile)) != sp_cend && c != EOF)
|
|
|
|
{
|
1987-05-20 13:56:26 +00:00
|
|
|
putc(c, outfile);
|
|
|
|
}
|
2019-05-10 17:17:40 +00:00
|
|
|
if (c == sp_cend)
|
|
|
|
putc(c, outfile);
|
1984-05-17 13:42:36 +00:00
|
|
|
outinst(ps_mes);
|
|
|
|
outint(ms_ext);
|
2019-05-10 17:17:40 +00:00
|
|
|
for (spp = symhash; spp < &symhash[NSYMHASH]; spp++)
|
1984-05-17 13:42:36 +00:00
|
|
|
for (sp = *spp; sp != (sym_p) 0; sp = sp->s_next)
|
2019-05-10 17:17:40 +00:00
|
|
|
if ((sp->s_flags & (SYMDEF | SYMGLOBAL)) == (SYMDEF | SYMGLOBAL))
|
1984-05-17 13:42:36 +00:00
|
|
|
outsym(sp);
|
2019-05-10 17:17:40 +00:00
|
|
|
putc(sp_cend, outfile);
|
|
|
|
while ((c = getc(infile)) != EOF)
|
|
|
|
putc(c, outfile);
|
|
|
|
c = fclose(infile);
|
1984-05-17 13:42:36 +00:00
|
|
|
assert(c != EOF);
|
2019-05-10 17:17:40 +00:00
|
|
|
c = remove(tempname);
|
1984-05-17 13:42:36 +00:00
|
|
|
assert(c == 0);
|
|
|
|
}
|