ack/lang/pc/comp/options.c

171 lines
3.2 KiB
C
Raw Normal View History

1988-10-26 15:21:11 +00:00
/* U S E R O P T I O N - H A N D L I N G */
#include <em_arith.h>
#include <em_label.h>
#include "class.h"
#include "const.h"
#include "idfsize.h"
#include "main.h"
#include "type.h"
1989-05-03 10:30:22 +00:00
#include "nocross.h"
1991-02-18 17:15:11 +00:00
#include "dbsymtab.h"
1988-10-26 15:21:11 +00:00
#define MINIDFSIZE 9
#if MINIDFSIZE < 9
You fouled up! MINIDFSIZE has to be at least 10 or the compiler will not
recognize some keywords!
#endif
extern int idfsize;
DoOption(text)
register char *text;
{
switch( *text++ ) {
default:
options[text[-1]]++; /* flags, debug options etc. */
break;
/* recognized flags:
-i: largest value of set of integer
1989-05-03 10:30:22 +00:00
-u, -U: allow underscore in identifier
1988-10-26 15:21:11 +00:00
-w: no warnings
1989-05-03 10:30:22 +00:00
-R: no range checks
-A: range checks for array references
1988-10-26 15:21:11 +00:00
and many more if DEBUG
*/
1991-02-18 17:15:11 +00:00
#ifdef DBSYMTAB
case 'g':
options['g'] = 1;
options['n'] = 1;
break;
#endif
1988-10-26 15:21:11 +00:00
case 'i': { /* largest value of set of integer */
char *t = text;
max_intset = txt2int(&t);
text = t;
if( max_intset <= (arith) 0 || *t ) {
error("bad -i flag : use -i<num>");
max_intset = 0;
}
break;
}
case 'M': { /* maximum identifier length */
char *t = text;
idfsize = txt2int(&t);
text = t;
1989-05-03 10:30:22 +00:00
if( idfsize <= 0 || *t ) {
1988-10-26 15:21:11 +00:00
fatal("malformed -M option");
/*NOTREACHED*/
1989-05-03 10:30:22 +00:00
}
1988-10-26 15:21:11 +00:00
if( idfsize > IDFSIZE ) {
idfsize = IDFSIZE;
warning("maximum identifier length is %d", IDFSIZE);
}
if( idfsize < MINIDFSIZE ) {
idfsize = MINIDFSIZE;
warning("minimum identifier length is %d", MINIDFSIZE);
}
break;
}
1989-05-03 10:30:22 +00:00
/* case 'u': /* underscore allowed in identifiers */
/* class('_') = STIDF;
/* inidf['_'] = 1;
/* break;
*/
1988-10-26 15:21:11 +00:00
case 'V' : { /* set object sizes and alignment requirements */
1989-05-03 10:30:22 +00:00
/* syntax : -V[ [w|i|l|f|p] size? [.alignment]? ]* */
#ifndef NOCROSS
1988-10-26 15:21:11 +00:00
register arith size;
register int align;
char c, *t;
while( c = *text++ ) {
char *strindex();
t = text;
size = txt2int(&t);
align = 0;
if( *(text = t) == '.' ) {
t = text + 1;
align = txt2int(&t);
text = t;
}
1989-05-03 10:30:22 +00:00
if( !strindex("wilfpS", c) )
1988-10-26 15:21:11 +00:00
error("-V: bad type indicator %c\n", c);
if( size )
switch( c ) {
case 'w': /* word */
word_size = size;
break;
case 'i': /* int */
int_size = size;
break;
1989-05-03 10:30:22 +00:00
case 'l': /* long */
long_size = size;
break;
1988-10-26 15:21:11 +00:00
case 'f': /* real */
real_size = size;
break;
case 'p': /* pointer */
pointer_size = size;
break;
case 'S': /* structure */
/* discard size */
break;
}
if( align )
switch( c ) {
case 'w': /* word */
word_align = align;
break;
case 'i': /* int */
int_align = align;
break;
1989-05-03 10:30:22 +00:00
case 'l': /* long */
long_align = align;
break;
1988-10-26 15:21:11 +00:00
case 'f': /* real */
real_align = align;
break;
case 'p': /* pointer */
pointer_align = align;
break;
case 'S': /* initial record alignment */
struct_align = align;
break;
}
}
break;
1989-05-03 10:30:22 +00:00
#endif NOCROSS
1988-10-26 15:21:11 +00:00
}
}
}
int
txt2int(tp)
register char **tp;
{
/* 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;
}