2 * The Regina Rexx Interpreter
3 * Copyright (C) 1992-1994 Anders Christensen <anders@pvv.unit.no>
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
15 * You should have received a copy of the GNU Library General Public
16 * License along with this library; if not, write to the Free
17 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26 #define OPTION(opt) { #opt, EXT_##opt, NULL }
27 #define METAOP(name,value) { #name, -1, value }
30 static const struct __regina_option all_options
[] = { /* Must be alphabetically sorted! */
31 METAOP( ANSI
, "NOCALLS_AS_FUNCS NOEXT_COMMANDS_AS_FUNCS FAST_LINES_BIF_DEFAULT STRICT_ANSI STRICT_WHITE_SPACE_COMPARISONS" ),
33 OPTION( AREXX_SEMANTICS
),
34 OPTION( BROKEN_ADDRESS_COMMAND
),
35 METAOP( BUFFERS
, "BUFTYPE_BIF DESBUF_BIF DROPBUF_BIF MAKEBUF_BIF" ),
36 OPTION( BUFTYPE_BIF
),
38 OPTION( CALLS_AS_FUNCS
),
40 OPTION( DROPBUF_BIF
),
41 OPTION( EXT_COMMANDS_AS_FUNCS
),
42 OPTION( FAST_LINES_BIF_DEFAULT
),
44 OPTION( HALT_ON_EXT_CALL_FAIL
),
45 OPTION( INTERNAL_QUEUES
),
46 OPTION( LINEOUTTRUNC
),
47 OPTION( MAKEBUF_BIF
),
48 OPTION( PRUNE_TRACE
),
50 METAOP( REGINA
, "NOCALLS_AS_FUNCS EXT_COMMANDS_AS_FUNCS FAST_LINES_BIF_DEFAULT, NOHALT_ON_EXT_CALL_FAIL " ),
51 OPTION( REGINA_BIFS
),
52 OPTION( RESULTS
), /* ARexx option */
53 METAOP( SAA
, "NOCALLS_AS_FUNCS NOEXT_COMMANDS_AS_FUNCS" ),
54 OPTION( SINGLE_INTERPRETER
),
55 OPTION( STDOUT_FOR_STDERR
),
56 OPTION( STRICT_ANSI
),
57 OPTION( STRICT_WHITE_SPACE_COMPARISONS
),
59 METAOP( TRL1
, "NOCALLS_AS_FUNCS NOEXT_COMMANDS_AS_FUNCS" ),
60 METAOP( TRL2
, "NOCALLS_AS_FUNCS NOEXT_COMMANDS_AS_FUNCS" ),
65 void do_options( tsd_t
*TSD
, proclevel pl
, streng
*options
, int toggle
)
67 char *cptr
,*eptr
,*start
;
68 int length
,inverse
=0,tmp
;
69 const struct __regina_option
*lower
,*upper
,*middle
=NULL
;
71 cptr
= options
->value
;
72 eptr
= cptr
+ options
->len
;
76 for ( ; cptr
< eptr
&& rx_isspace( *cptr
); cptr
++ )
78 for ( start
= cptr
; cptr
< eptr
&& !rx_isspace( *cptr
); cptr
++ )
79 *cptr
= (char) rx_toupper( *cptr
);
83 if ( ( inverse
= ( *start
== 'N' && *( start
+ 1) == 'O') ) != 0 )
86 length
= cptr
- start
;
89 upper
= lower
+ sizeof( all_options
) / sizeof( all_options
[0] ) - 2;
91 while ( upper
>= lower
)
93 middle
= lower
+ ( upper
- lower
) / 2;
94 tmp
= strncmp( middle
->name
, start
, length
);
95 if ( tmp
== 0 && middle
->name
[length
] == '\0' )
104 /* If option is unknown, don't care ... */
105 if ( upper
>= lower
)
107 assert ( middle
->name
);
108 if ( middle
->offset
== -1 )
110 do_options( TSD
, pl
, Str_creTSD( middle
->contains
),
115 if (inverse
^ toggle
)
116 set_options_flag( pl
, middle
->offset
, 0 );
118 set_options_flag( pl
, middle
->offset
, 1 );
122 Free_stringTSD( options
);
124 * Check if SINGLE_INTERPRTER option is set; save the current TSD globally
126 if ( get_options_flag( pl
, EXT_SINGLE_INTERPRETER
) )
132 int get_options_flag( cproclevel pl
, int offset
)
134 return pl
->options
& ( 1ul << offset
);
137 void set_options_flag( proclevel pl
, int offset
, int status
)
140 pl
->options
|= ( 1ul << offset
);
142 pl
->options
&= ~( 1ul << offset
);