1986-04-17 09:28:09 +00:00
|
|
|
/* U S E R O P T I O N - H A N D L I N G */
|
|
|
|
|
|
|
|
#include "idfsize.h"
|
1986-04-25 10:14:08 +00:00
|
|
|
#include "ndir.h"
|
1986-04-17 09:28:09 +00:00
|
|
|
|
1986-05-01 19:06:53 +00:00
|
|
|
#include <em_arith.h>
|
|
|
|
#include <em_label.h>
|
|
|
|
|
1986-04-17 09:28:09 +00:00
|
|
|
#include "type.h"
|
1986-04-25 10:14:08 +00:00
|
|
|
#include "main.h"
|
1986-04-17 09:28:09 +00:00
|
|
|
|
|
|
|
extern int idfsize;
|
1986-04-25 10:14:08 +00:00
|
|
|
static int ndirs;
|
|
|
|
|
1986-05-01 19:06:53 +00:00
|
|
|
DoOption(text)
|
1986-10-06 20:36:30 +00:00
|
|
|
register char *text;
|
1986-04-17 09:28:09 +00:00
|
|
|
{
|
|
|
|
switch(*text++) {
|
|
|
|
|
|
|
|
default:
|
1986-06-10 13:18:52 +00:00
|
|
|
options[text[-1]]++; /* flags, debug options etc. */
|
1986-04-17 09:28:09 +00:00
|
|
|
break;
|
1986-09-25 19:39:06 +00:00
|
|
|
/* recognized flags:
|
|
|
|
-L: don't generate fil/lin
|
|
|
|
-p: generate procentry/procexit
|
|
|
|
-w: no warnings
|
|
|
|
-n: no register messages
|
|
|
|
and many more if DEBUG
|
|
|
|
*/
|
1986-04-17 09:28:09 +00:00
|
|
|
|
|
|
|
|
1986-10-06 20:36:30 +00:00
|
|
|
case 'M': { /* maximum identifier length */
|
|
|
|
char *t = text; /* because &text is illegal */
|
|
|
|
|
|
|
|
idfsize = txt2int(&t);
|
|
|
|
if (*t || idfsize <= 0)
|
1986-04-17 09:28:09 +00:00
|
|
|
fatal("malformed -M option");
|
|
|
|
if (idfsize > IDFSIZE)
|
|
|
|
fatal("maximum identifier length is %d", IDFSIZE);
|
1986-10-06 20:36:30 +00:00
|
|
|
}
|
1986-04-17 09:28:09 +00:00
|
|
|
break;
|
|
|
|
|
1986-04-25 10:14:08 +00:00
|
|
|
case 'I' :
|
|
|
|
if (++ndirs >= NDIRS) {
|
|
|
|
fatal("Too many -I options");
|
|
|
|
}
|
|
|
|
DEFPATH[ndirs] = text;
|
|
|
|
break;
|
|
|
|
|
1986-04-17 09:28:09 +00:00
|
|
|
case 'V' : /* set object sizes and alignment requirements */
|
|
|
|
{
|
|
|
|
arith size;
|
|
|
|
int align;
|
|
|
|
char c;
|
1986-10-06 20:36:30 +00:00
|
|
|
char *t;
|
1986-04-17 09:28:09 +00:00
|
|
|
|
|
|
|
while (c = *text++) {
|
1986-10-06 20:36:30 +00:00
|
|
|
t = text;
|
|
|
|
size = txt2int(&t);
|
1986-04-17 09:28:09 +00:00
|
|
|
align = 0;
|
1986-10-06 20:36:30 +00:00
|
|
|
if (*(text = t) == '.') {
|
|
|
|
t = text + 1;
|
|
|
|
align = txt2int(&t);
|
|
|
|
text = t;
|
1986-04-17 09:28:09 +00:00
|
|
|
}
|
|
|
|
switch (c) {
|
|
|
|
|
|
|
|
case 'w': /* word */
|
1986-05-16 17:15:36 +00:00
|
|
|
if (size != (arith)0) {
|
|
|
|
word_size = size;
|
|
|
|
dword_size = 2 * size;
|
|
|
|
}
|
1986-04-17 09:28:09 +00:00
|
|
|
if (align != 0) word_align = align;
|
|
|
|
break;
|
|
|
|
case 'i': /* int */
|
|
|
|
if (size != (arith)0) int_size = size;
|
|
|
|
if (align != 0) int_align = align;
|
|
|
|
break;
|
|
|
|
case 'l': /* longint */
|
|
|
|
if (size != (arith)0) long_size = size;
|
|
|
|
if (align != 0) long_align = align;
|
|
|
|
break;
|
|
|
|
case 'f': /* real */
|
|
|
|
if (size != (arith)0) float_size = size;
|
|
|
|
if (align != 0) float_align = align;
|
|
|
|
break;
|
|
|
|
case 'd': /* longreal */
|
|
|
|
if (size != (arith)0) double_size = size;
|
|
|
|
if (align != 0) double_align = align;
|
|
|
|
break;
|
|
|
|
case 'p': /* pointer */
|
|
|
|
if (size != (arith)0) pointer_size = size;
|
|
|
|
if (align != 0) pointer_align = align;
|
|
|
|
break;
|
|
|
|
case 'S': /* initial record alignment */
|
|
|
|
if (align != (arith)0) struct_align = align;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
error("-V: bad type indicator %c\n", c);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
txt2int(tp)
|
1986-10-06 20:36:30 +00:00
|
|
|
register char **tp;
|
1986-04-17 09:28:09 +00:00
|
|
|
{
|
|
|
|
/* the integer pointed to by *tp is read, while increasing
|
|
|
|
*tp; the resulting value is yielded.
|
|
|
|
*/
|
|
|
|
register int val = 0;
|
|
|
|
register int ch;
|
|
|
|
|
|
|
|
while (ch = **tp, ch >= '0' && ch <= '9') {
|
|
|
|
val = val * 10 + ch - '0';
|
|
|
|
(*tp)++;
|
|
|
|
}
|
|
|
|
return val;
|
|
|
|
}
|