cleanup.c 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #ifndef NORCSID
  2. static char rcsid[] = "$Id$";
  3. #endif
  4. #include <stdio.h>
  5. #include "param.h"
  6. #include "types.h"
  7. #include "assert.h"
  8. #include <em_pseu.h>
  9. #include <em_spec.h>
  10. #include <em_mes.h>
  11. #include "lookup.h"
  12. #include "ext.h"
  13. /*
  14. * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
  15. * See the copyright notice in the ACK home directory, in the file "Copyright".
  16. *
  17. * Author: Hans van Staveren
  18. */
  19. cleanup() {
  20. FILE *infile;
  21. register c;
  22. register sym_p *spp,sp;
  23. for (spp=symhash;spp< &symhash[NSYMHASH];spp++)
  24. for (sp = *spp; sp != (sym_p) 0; sp = sp->s_next)
  25. if ((sp->s_flags & SYMOUT) == 0)
  26. outdef(sp);
  27. if(!Lflag)
  28. return;
  29. c=fclose(outfile);
  30. assert(c != EOF);
  31. outfile = stdout;
  32. infile = fopen(template,"r");
  33. if (infile == NULL)
  34. error("temp file disappeared");
  35. outshort(sp_magic);
  36. /* Attempt to first output the word_size message */
  37. while ((c = getc(infile)) != sp_cend && c != EOF) {
  38. putc(c, outfile);
  39. }
  40. if (c == sp_cend) putc(c, outfile);
  41. outinst(ps_mes);
  42. outint(ms_ext);
  43. for (spp=symhash;spp< &symhash[NSYMHASH];spp++)
  44. for (sp = *spp; sp != (sym_p) 0; sp = sp->s_next)
  45. if ((sp->s_flags&(SYMDEF|SYMGLOBAL)) == (SYMDEF|SYMGLOBAL))
  46. outsym(sp);
  47. putc(sp_cend,outfile);
  48. while ( (c=getc(infile)) != EOF)
  49. putc(c,outfile);
  50. c=fclose(infile);
  51. assert(c != EOF);
  52. c=unlink(template);
  53. assert(c == 0);
  54. }