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
|
|
|
|
*/
|
2006-07-20 23:04:15 +00:00
|
|
|
#include <stdlib.h>
|
1984-05-17 13:42:36 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include "param.h"
|
|
|
|
#include "types.h"
|
1990-09-04 16:42:43 +00:00
|
|
|
#include "tes.h"
|
1984-05-17 13:42:36 +00:00
|
|
|
#include "alloc.h"
|
2019-05-10 17:17:40 +00:00
|
|
|
#include "system.h"
|
1988-09-12 09:13:49 +00:00
|
|
|
#include <em_spec.h>
|
1984-05-17 13:42:36 +00:00
|
|
|
#include "ext.h"
|
2019-05-10 17:17:40 +00:00
|
|
|
#include "util.h"
|
|
|
|
#include "getline.h"
|
|
|
|
#include "putline.h"
|
|
|
|
|
|
|
|
/* Other external definitions */
|
|
|
|
extern void cleanup(void);
|
|
|
|
|
|
|
|
void flags(register char *s)
|
|
|
|
{
|
|
|
|
for (s++; *s; s++)
|
|
|
|
switch (*s)
|
|
|
|
{
|
|
|
|
case 'L':
|
|
|
|
Lflag = TRUE;
|
|
|
|
break;
|
|
|
|
case 'n':
|
|
|
|
nflag = TRUE;
|
|
|
|
break;
|
|
|
|
case 'm':
|
|
|
|
if (*(s + 1) == 'l')
|
|
|
|
{
|
|
|
|
s++;
|
|
|
|
repl_longmuls = TRUE;
|
|
|
|
}
|
|
|
|
repl_muls = atoi(s + 1);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void fileinit(void)
|
|
|
|
{
|
|
|
|
if (readshort() != (short) sp_magic)
|
|
|
|
error("wrong input file");
|
|
|
|
if (Lflag)
|
|
|
|
{
|
2022-07-18 19:42:52 +00:00
|
|
|
tempname = sys_maketempfile("opt", "dat");
|
2019-05-10 17:17:40 +00:00
|
|
|
outfile = fopen(tempname, "wb");
|
|
|
|
if (outfile == NULL)
|
|
|
|
error("can't create %s", tempname);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-07-17 18:47:53 +00:00
|
|
|
sys_setbinarymode(stdout);
|
2019-05-10 17:17:40 +00:00
|
|
|
outfile = stdout;
|
|
|
|
outshort(sp_magic);
|
|
|
|
}
|
|
|
|
}
|
1984-05-17 13:42:36 +00:00
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Main program for EM optimizer
|
|
|
|
*/
|
|
|
|
|
2019-05-10 17:17:40 +00:00
|
|
|
int main(int argc, char* argv[])
|
|
|
|
{
|
|
|
|
#ifndef USEMALLOC
|
1988-04-19 19:46:28 +00:00
|
|
|
int somespace[STACKROOM];
|
2019-05-10 17:17:40 +00:00
|
|
|
#endif
|
1984-05-17 13:42:36 +00:00
|
|
|
|
|
|
|
progname = argv[0];
|
2019-05-10 17:17:40 +00:00
|
|
|
while (argc-- > 1 && **++argv == '-')
|
1984-05-17 13:42:36 +00:00
|
|
|
flags(*argv);
|
2019-05-10 17:17:40 +00:00
|
|
|
if (argc > 1)
|
|
|
|
{
|
|
|
|
fprintf(stderr, "Usage: %s [-Ln] [-m<num>] [name]\n", progname);
|
|
|
|
exit(EXIT_FAILURE);
|
1984-05-17 13:42:36 +00:00
|
|
|
}
|
|
|
|
if (argc)
|
2022-07-17 18:47:53 +00:00
|
|
|
{
|
2022-07-17 18:11:21 +00:00
|
|
|
if (freopen(*argv, "rb", stdin) == NULL)
|
2019-05-10 17:17:40 +00:00
|
|
|
error("Cannot open %s", *argv);
|
2022-07-17 18:47:53 +00:00
|
|
|
}
|
2022-07-17 18:11:21 +00:00
|
|
|
else
|
2022-07-17 18:47:53 +00:00
|
|
|
sys_setbinarymode(stdin);
|
2022-07-17 18:11:21 +00:00
|
|
|
|
1984-05-17 13:42:36 +00:00
|
|
|
fileinit();
|
2019-05-10 17:17:40 +00:00
|
|
|
#ifdef USEMALLOC
|
|
|
|
coreinit();
|
|
|
|
#else
|
|
|
|
coreinit((short *) somespace, (short *) (somespace + STACKROOM));
|
|
|
|
#endif
|
1984-05-17 13:42:36 +00:00
|
|
|
getlines();
|
|
|
|
cleanup();
|
2019-05-10 17:17:40 +00:00
|
|
|
return (EXIT_SUCCESS);
|
1984-05-17 13:42:36 +00:00
|
|
|
}
|
|
|
|
|