disable the unrecognized nls flag
[AROS-Contrib.git] / regina / options.c
blob5f8f678ae9f095a462d0c9e7323daff2b2e615ff
1 /*
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.
20 #include "rexx.h"
22 #include <assert.h>
23 #include <string.h>
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" ),
32 METAOP( AREXX, "CALLS_AS_FUNCS AREXX_BIFS AREXX_SEMANTICS" ),
33 OPTION( AREXX_BIFS ),
34 OPTION( AREXX_SEMANTICS ),
35 OPTION( BROKEN_ADDRESS_COMMAND ),
36 METAOP( BUFFERS, "BUFTYPE_BIF DESBUF_BIF DROPBUF_BIF MAKEBUF_BIF" ),
37 OPTION( BUFTYPE_BIF ),
38 OPTION( CACHEEXT ),
39 OPTION( CALLS_AS_FUNCS ),
40 OPTION( DESBUF_BIF ),
41 OPTION( DROPBUF_BIF ),
42 OPTION( EXT_COMMANDS_AS_FUNCS ),
43 OPTION( FAST_LINES_BIF_DEFAULT ),
44 OPTION( FLUSHSTACK ),
45 OPTION( HALT_ON_EXT_CALL_FAIL ),
46 OPTION( INTERNAL_QUEUES ),
47 OPTION( LINEOUTTRUNC ),
48 OPTION( MAKEBUF_BIF ),
49 OPTION( PRUNE_TRACE ),
50 OPTION( QUEUES_301 ),
51 METAOP( REGINA, "NOCALLS_AS_FUNCS EXT_COMMANDS_AS_FUNCS FAST_LINES_BIF_DEFAULT, NOHALT_ON_EXT_CALL_FAIL " ),
52 OPTION( REGINA_BIFS ),
53 OPTION( RESULTS ), /* ARexx option */
54 METAOP( SAA, "NOCALLS_AS_FUNCS NOEXT_COMMANDS_AS_FUNCS" ),
55 OPTION( SINGLE_INTERPRETER ),
56 OPTION( STDOUT_FOR_STDERR ),
57 OPTION( STRICT_ANSI ),
58 OPTION( STRICT_WHITE_SPACE_COMPARISONS ),
59 OPTION( TRACE_HTML ),
60 METAOP( TRL1, "NOCALLS_AS_FUNCS NOEXT_COMMANDS_AS_FUNCS" ),
61 METAOP( TRL2, "NOCALLS_AS_FUNCS NOEXT_COMMANDS_AS_FUNCS" ),
62 { NULL, 0 }
63 } ;
66 void do_options( tsd_t *TSD, proclevel pl, streng *options, int toggle )
68 char *cptr,*eptr,*start;
69 int length,inverse=0,tmp;
70 const struct __regina_option *lower,*upper,*middle=NULL;
72 cptr = options->value;
73 eptr = cptr + options->len;
75 while ( cptr < eptr )
77 for ( ; cptr < eptr && rx_isspace( *cptr ); cptr++ )
79 for ( start = cptr; cptr < eptr && !rx_isspace( *cptr ); cptr++ )
80 *cptr = (char) rx_toupper( *cptr );
82 if ( cptr > start+2 )
84 if ( ( inverse = ( *start == 'N' && *( start + 1) == 'O') ) != 0 )
85 start += 2;
87 length = cptr - start;
89 lower = all_options;
90 upper = lower + sizeof( all_options ) / sizeof( all_options[0] ) - 2;
92 while ( upper >= lower )
94 middle = lower + ( upper - lower ) / 2;
95 tmp = strncmp( middle->name, start, length );
96 if ( tmp == 0 && middle->name[length] == '\0' )
97 break;
99 if ( tmp > 0 )
100 upper = middle - 1;
101 else
102 lower = middle + 1;
105 /* If option is unknown, don't care ... */
106 if ( upper >= lower )
108 assert ( middle->name );
109 if ( middle->offset == -1 )
111 do_options( TSD, pl, Str_creTSD( middle->contains ),
112 toggle ^ inverse );
114 else
116 if (inverse ^ toggle)
117 set_options_flag( pl, middle->offset, 0 );
118 else
119 set_options_flag( pl, middle->offset, 1 );
123 Free_stringTSD( options );
125 * Check if SINGLE_INTERPRTER option is set; save the current TSD globally
127 if ( get_options_flag( pl, EXT_SINGLE_INTERPRETER ) )
129 setGlobalTSD( TSD );
133 int get_options_flag( cproclevel pl, int offset )
135 return pl->options & ( 1ul << offset );
138 void set_options_flag( proclevel pl, int offset, int status )
140 if ( status )
141 pl->options |= ( 1ul << offset );
142 else
143 pl->options &= ~( 1ul << offset );