2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
6 * These libraries and programs are free software; you can
7 * redistribute them and/or modify them under the terms of the GNU
8 * Lesser General Public License as published by the Free Software
9 * Foundation; either version 2 of the License, or (at your option)
12 * These libraries and programs are distributed in the hope that
13 * they will be useful, but WITHOUT ANY WARRANTY; without even the
14 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU Lesser General Public License for more
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with these libraries and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
23 /* A lexical scanner generated by flex */
25 /* scanner skeleton version:
26 * $XConsortium: token.cc /main/4 1996/07/05 15:20:12 rws $
34 /* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */
46 #if defined(linux) || defined(CSRG_BASED) || defined(sun)
52 /* use prototypes in function declarations */
53 #define schema_USE_PROTOS
55 /* the "const" storage-class-modifier is valid */
56 #define schema_USE_CONST
58 #else /* ! __cplusplus */
64 void *malloc( size_t );
70 #define schema_USE_PROTOS
71 #define schema_USE_CONST
74 #endif /* ! __cplusplus */
78 #define schema_USE_CONST
82 #ifndef schema_USE_CONST
87 #ifdef schema_USE_PROTOS
88 #define schema_PROTO(proto) proto
90 #define schema_PROTO(proto) ()
91 /* we can't get here if it's an ANSI C compiler, or a C++ compiler,
92 * so it's got to be a K&R compiler, and therefore there's no standard
93 * place from which to include these definitions
101 /* amount of stuff to slurp up with each read */
102 #ifndef schema_READ_BUF_SIZE
103 #define schema_READ_BUF_SIZE 8192
106 /* returned upon end-of-file */
107 #define schema_END_TOK 0
109 /* copy whatever the last rule matched to the standard output */
111 /* cast to (char *) is because for 8-bit chars, schematext is (unsigned char *) */
112 /* this used to be an fputs(), but since the string might contain NUL's,
113 * we now use fwrite()
115 #define ECHO (void) fwrite( (char *) schematext, schemaleng, 1, schemaout )
117 /* gets input and stuffs it into "buf". number of characters read, or schema_NULL,
118 * is returned in "result".
120 #define schema_INPUT(buf,result,max_size) \
121 if ( (result = read( fileno( schemain), (char *) buf, max_size )) < 0 ) \
122 schema_FATAL_ERROR( "read() in flex scanner failed" );
123 #define schema_NULL 0
125 /* no semi-colon after return; correct usage is to write " schematerminate();" -
126 * we don't want an extra ';' after the "return" because that will cause
127 * some compilers to complain about unreachable statements.
129 #define schematerminate() return ( schema_NULL )
131 /* report a fatal error */
133 /* The funky do-while is used to turn this macro definition into
134 * a single C statement (which needs a semi-colon terminator).
135 * This avoids problems with code like:
137 * if ( something_happens )
138 * schema_FATAL_ERROR( "oops, the something happened" );
142 * Prior to using the do-while the compiler would get upset at the
143 * "else" because it interpreted the "if" statement as being all
144 * done when it reached the ';' after the schema_FATAL_ERROR() call.
147 #define schema_FATAL_ERROR(msg) \
150 (void) fputs( msg, stderr ); \
151 (void) putc( '\n', stderr ); \
156 /* default schemawrap function - always treat EOF as an EOF */
157 #define schemawrap() 1
159 /* enter a start condition. This macro really ought to take a parameter,
160 * but we do it the disgusting crufty way forced on us by the ()-less
161 * definition of BEGIN
163 #define BEGIN schema_start = 1 + 2 *
165 /* action number for EOF rule of a given start state */
166 #define schema_STATE_EOF(state) ( schema_END_OF_BUFFER + state + 1)
168 /* special action meaning "start processing a new file" */
169 #define schema_NEW_FILE \
172 schema_init_buffer( schema_current_buffer, schemain ); \
173 schema_load_buffer_state(); \
177 /* default declaration of generated scanner - a define so the user can
178 * easily add parameters
180 #define schema_DECL int schemalex schema_PROTO(( void ))
182 /* code executed at the end of each rule */
183 #define schema_BREAK break;
185 #define schema_END_OF_BUFFER_CHAR 0
187 #ifndef schema_BUF_SIZE
188 #define schema_BUF_SIZE ( schema_READ_BUF_SIZE * 2) /* size of default input buffer */
191 typedef struct schema_buffer_state * schema_BUFFER_STATE;
193 #define schema_CHAR unsigned char
196 * $XConsortium: token.cc /main/4 1996/07/05 15:20:12 rws $
198 * Copyright (c) 1993 HAL Computer Systems International, Ltd.
199 * All rights reserved. Unpublished -- rights reserved under
200 * the Copyright Laws of the United States. USE OF A COPYRIGHT
201 * NOTICE IS PRECAUTIONARY ONLY AND DOES NOT IMPLY PUBLICATION
204 * THIS SOFTWARE CONTAINS CONFIDENTIAL INFORMATION AND TRADE
205 * SECRETS OF HAL COMPUTER SYSTEMS INTERNATIONAL, LTD. USE,
206 * DISCLOSURE, OR REPRODUCTION IS PROHIBITED WITHOUT THE
207 * PRIOR EXPRESS WRITTEN PERMISSION OF HAL COMPUTER SYSTEMS
208 * INTERNATIONAL, LTD.
210 * RESTRICTED RIGHTS LEGEND
211 * Use, duplication, or disclosure by the Government is subject
212 * to the restrictions as set forth in subparagraph (c)(l)(ii)
213 * of the Rights in Technical Data and Computer Software clause
214 * at DFARS 252.227-7013.
216 * HAL COMPUTER SYSTEMS INTERNATIONAL, LTD.
221 #include "store_desc.h"
222 #include "sheet.tab.h"
223 extern char replace_string[PATHSIZ];
224 extern int replace_string_len;
228 /* done after the current pattern has been matched and before the
229 * corresponding action - sets up schematext
231 #define schema_DO_BEFORE_ACTION \
232 schematext = schema_bp; \
233 schemaleng = schema_cp - schema_bp; \
234 schema_hold_char = * schema_cp; \
235 * schema_cp = '\0'; \
236 schema_c_buf_p = schema_cp;
238 #define EOB_ACT_CONTINUE_SCAN 0
239 #define EOB_ACT_END_OF_FILE 1
240 #define EOB_ACT_LAST_MATCH 2
242 /* return all but the first 'n' matched characters back to the input stream */
243 #define schemaless(n) \
246 /* undo effects of setting up schematext */ \
247 * schema_cp = schema_hold_char; \
248 schema_c_buf_p = schema_cp = schema_bp + n; \
249 schema_DO_BEFORE_ACTION; /* set up schematext again */ \
253 #define unput(c) schemaunput( c, schematext )
256 struct schema_buffer_state
258 FILE * schema_input_file;
260 schema_CHAR * schema_ch_buf; /* input buffer */
261 schema_CHAR * schema_buf_pos; /* current position in input buffer */
263 /* size of input buffer in bytes, not including room for EOB characters*/
266 /* number of characters read into schema_ch_buf, not including EOB characters */
269 int schema_eof_status; /* whether we've seen an EOF on this buffer */
270 #define EOF_NOT_SEEN 0
271 /* "pending" happens when the EOF has been seen but there's still
274 #define EOF_PENDING 1
278 static schema_BUFFER_STATE schema_current_buffer;
280 /* we provide macros for accessing buffer states in case in the
281 * future we want to put the buffer states in a more general
284 #define schema_CURRENT_BUFFER schema_current_buffer
287 /* schema_hold_char holds the character lost when schematext is formed */
288 static schema_CHAR schema_hold_char;
290 static int schema_n_chars; /* number of characters read into schema_ch_buf */
294 #ifndef schema_USER_ACTION
295 #define schema_USER_ACTION
298 #ifndef schema_USER_INIT
299 #define schema_USER_INIT
302 extern schema_CHAR * schematext;
303 extern int schemaleng;
304 extern FILE * schemain, * schemaout;
306 schema_CHAR * schematext;
309 FILE * schemain = (FILE *) 0, * schemaout = (FILE *) 0;
311 #define schema_END_OF_BUFFER 37
312 typedef int schema_state_type;
313 static const short int schema_accept[164] =
315 0, 0, 37, 36, 32, 31, 35, 34, 30, 29,
316 35, 35, 35, 35, 35, 35, 35, 35, 35, 35,
317 35, 35, 33, 32, 31, 35, 34, 30, 30, 35,
318 35, 35, 35, 35, 35, 35, 35, 35, 35, 35,
319 23, 35, 35, 35, 35, 35, 35, 33, 35, 35,
320 35, 35, 35, 35, 35, 35, 35, 5, 35, 35,
321 35, 35, 35, 2, 35, 35, 35, 35, 35, 35,
322 35, 35, 35, 8, 35, 35, 35, 3, 25, 10,
323 35, 35, 35, 35, 35, 35, 11, 35, 35, 35,
324 35, 35, 13, 35, 35, 35, 35, 12, 21, 24,
326 35, 35, 35, 35, 35, 35, 35, 35, 17, 35,
327 35, 35, 35, 35, 35, 35, 35, 35, 35, 35,
328 7, 35, 35, 35, 35, 26, 35, 35, 35, 18,
329 35, 35, 35, 6, 35, 35, 4, 35, 35, 20,
330 35, 19, 35, 35, 35, 1, 35, 35, 35, 35,
331 35, 27, 35, 35, 14, 22, 35, 16, 35, 9,
335 static const schema_CHAR schema_ec[256] =
337 1, 1, 1, 1, 1, 1, 1, 1, 2, 3,
338 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
339 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
340 1, 2, 1, 1, 4, 5, 1, 1, 1, 1,
341 1, 1, 1, 1, 5, 5, 1, 6, 6, 6,
342 6, 6, 6, 6, 6, 6, 6, 7, 1, 1,
343 8, 1, 1, 1, 5, 5, 5, 5, 5, 5,
344 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
345 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
346 1, 9, 1, 1, 10, 1, 11, 12, 13, 14,
348 15, 16, 17, 18, 19, 5, 5, 20, 21, 22,
349 23, 24, 5, 25, 26, 27, 28, 29, 5, 30,
350 31, 32, 1, 1, 1, 1, 1, 1, 1, 1,
351 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
352 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
353 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
354 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
355 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
356 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
357 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
359 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
360 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
361 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
362 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
363 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
367 static const schema_CHAR schema_meta[33] =
369 1, 1, 2, 1, 3, 3, 1, 1, 1, 3,
370 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
371 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
375 static const short int schema_base[166] =
377 0, 174, 177, 179, 174, 172, 0, 168, 30, 179,
378 156, 7, 24, 153, 143, 148, 150, 13, 147, 29,
379 27, 157, 0, 164, 162, 0, 158, 179, 160, 147,
380 136, 133, 146, 22, 145, 141, 27, 130, 141, 136,
381 0, 136, 126, 124, 126, 126, 125, 0, 125, 131,
382 130, 126, 119, 115, 114, 124, 124, 128, 110, 121,
383 119, 119, 114, 0, 114, 106, 111, 102, 113, 117,
384 111, 100, 113, 0, 102, 92, 99, 0, 0, 110,
385 109, 91, 101, 101, 101, 104, 103, 89, 97, 95,
386 90, 97, 97, 85, 86, 78, 84, 92, 91, 0,
388 78, 80, 73, 87, 70, 73, 72, 35, 0, 71,
389 18, 69, 72, 68, 68, 66, 73, 62, 59, 69,
390 0, 66, 61, 67, 57, 0, 57, 56, 56, 0,
391 62, 60, 63, 0, 48, 57, 0, 56, 45, 0,
392 55, 0, 53, 42, 49, 0, 43, 34, 48, 47,
393 31, 0, 44, 28, 0, 0, 23, 0, 25, 0,
397 static const short int schema_def[166] =
399 163, 1, 163, 163, 163, 163, 164, 164, 163, 163,
400 164, 164, 164, 164, 164, 164, 164, 164, 164, 164,
401 164, 164, 165, 163, 163, 164, 164, 163, 163, 164,
402 164, 164, 164, 164, 164, 164, 164, 164, 164, 164,
403 164, 164, 164, 164, 164, 164, 164, 165, 164, 164,
404 164, 164, 164, 164, 164, 164, 164, 164, 164, 164,
405 164, 164, 164, 164, 164, 164, 164, 164, 164, 164,
406 164, 164, 164, 164, 164, 164, 164, 164, 164, 164,
407 164, 164, 164, 164, 164, 164, 164, 164, 164, 164,
408 164, 164, 164, 164, 164, 164, 164, 164, 164, 164,
410 164, 164, 164, 164, 164, 164, 164, 164, 164, 164,
411 164, 164, 164, 164, 164, 164, 164, 164, 164, 164,
412 164, 164, 164, 164, 164, 164, 164, 164, 164, 164,
413 164, 164, 164, 164, 164, 164, 164, 164, 164, 164,
414 164, 164, 164, 164, 164, 164, 164, 164, 164, 164,
415 164, 164, 164, 164, 164, 164, 164, 164, 164, 164,
416 164, 164, 0, 163, 163
419 static const short int schema_nxt[212] =
421 4, 5, 6, 4, 7, 8, 9, 10, 4, 7,
422 11, 12, 13, 14, 7, 7, 7, 15, 16, 17,
423 18, 19, 7, 20, 7, 21, 7, 7, 22, 7,
424 7, 7, 28, 31, 33, 39, 40, 32, 29, 42,
425 57, 44, 53, 54, 125, 122, 34, 45, 26, 126,
426 162, 43, 161, 46, 160, 58, 123, 48, 159, 48,
427 158, 157, 156, 155, 154, 153, 152, 151, 150, 149,
428 148, 147, 146, 145, 144, 143, 142, 141, 140, 139,
429 138, 137, 136, 135, 134, 133, 132, 131, 130, 129,
430 128, 127, 124, 121, 120, 119, 118, 117, 116, 115,
432 114, 113, 112, 111, 110, 109, 108, 107, 106, 105,
433 104, 103, 102, 101, 100, 99, 98, 97, 96, 95,
434 94, 93, 92, 91, 90, 89, 88, 87, 86, 85,
435 84, 83, 82, 81, 80, 79, 78, 77, 76, 75,
436 74, 73, 72, 71, 70, 69, 68, 67, 66, 65,
437 64, 63, 62, 61, 60, 59, 56, 55, 52, 51,
438 50, 49, 28, 27, 25, 24, 47, 41, 38, 37,
439 36, 35, 30, 27, 25, 24, 163, 23, 3, 163,
440 163, 163, 163, 163, 163, 163, 163, 163, 163, 163,
441 163, 163, 163, 163, 163, 163, 163, 163, 163, 163,
443 163, 163, 163, 163, 163, 163, 163, 163, 163, 163,
447 static const short int schema_chk[212] =
449 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
450 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
451 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
452 1, 1, 9, 12, 13, 18, 18, 12, 9, 20,
453 37, 21, 34, 34, 111, 108, 13, 21, 164, 111,
454 159, 20, 157, 21, 154, 37, 108, 165, 153, 165,
455 151, 150, 149, 148, 147, 145, 144, 143, 141, 139,
456 138, 136, 135, 133, 132, 131, 129, 128, 127, 125,
457 124, 123, 122, 120, 119, 118, 117, 116, 115, 114,
458 113, 112, 110, 107, 106, 105, 104, 103, 102, 101,
460 99, 98, 97, 96, 95, 94, 93, 92, 91, 90,
461 89, 88, 87, 86, 85, 84, 83, 82, 81, 80,
462 77, 76, 75, 73, 72, 71, 70, 69, 68, 67,
463 66, 65, 63, 62, 61, 60, 59, 58, 57, 56,
464 55, 54, 53, 52, 51, 50, 49, 47, 46, 45,
465 44, 43, 42, 40, 39, 38, 36, 35, 33, 32,
466 31, 30, 29, 27, 25, 24, 22, 19, 17, 16,
467 15, 14, 11, 8, 6, 5, 3, 2, 163, 163,
468 163, 163, 163, 163, 163, 163, 163, 163, 163, 163,
469 163, 163, 163, 163, 163, 163, 163, 163, 163, 163,
471 163, 163, 163, 163, 163, 163, 163, 163, 163, 163,
475 static schema_state_type schema_last_accepting_state;
476 static schema_CHAR * schema_last_accepting_cpos;
478 /* the intent behind this definition is that it'll catch
479 * any uses of REJECT which flex missed
481 #define REJECT reject_used_but_not_detected
482 #define schemamore() schemamore_used_but_not_detected
483 #define schema_MORE_ADJ 0
485 /* these variables are all declared out here so that section 3 code can
488 /* points to current character in buffer */
489 static schema_CHAR * schema_c_buf_p = ( schema_CHAR *) 0;
490 static int schema_init = 1; /* whether we need to initialize */
491 static int schema_start = 0; /* start state number */
493 /* flag which is used to allow schemawrap()'s to do buffer switches
494 * instead of setting up a fresh schemain. A bit of a hack ...
496 static int schema_did_buffer_switch_on_eof;
498 static schema_state_type schema_get_previous_state schema_PROTO(( void ));
499 static schema_state_type schema_try_NUL_trans schema_PROTO(( schema_state_type current_state ));
500 static int schema_get_next_buffer schema_PROTO(( void ));
502 static void schemaunput schema_PROTO(( schema_CHAR c, schema_CHAR *buf_ptr ));
504 void schemarestart schema_PROTO(( FILE *input_file ));
505 void schema_switch_to_buffer schema_PROTO(( schema_BUFFER_STATE new_buffer ));
506 void schema_load_buffer_state schema_PROTO(( void ));
507 schema_BUFFER_STATE schema_create_buffer schema_PROTO(( FILE *file, int size ));
508 void schema_delete_buffer schema_PROTO(( schema_BUFFER_STATE b ));
509 void schema_init_buffer schema_PROTO(( schema_BUFFER_STATE b, FILE *file ));
511 #define schema_new_buffer schema_create_buffer
515 static int schemainput schema_PROTO(( void ));
517 static int input schema_PROTO(( void ));
523 register schema_state_type schema_current_state;
524 register schema_CHAR * schema_cp, * schema_bp;
525 register int schema_act;
534 if ( ! schema_start )
535 schema_start = 1; /* first start state */
543 if ( schema_current_buffer )
544 schema_init_buffer( schema_current_buffer, schemain );
546 schema_current_buffer = schema_create_buffer( schemain, schema_BUF_SIZE );
548 schema_load_buffer_state();
553 while ( 1 ) /* loops until end-of-file is reached */
555 schema_cp = schema_c_buf_p;
557 /* support of schematext */
558 * schema_cp = schema_hold_char;
560 /* schema_bp points to the position in schema_ch_buf of the start of the
563 schema_bp = schema_cp;
565 schema_current_state = schema_start;
566 if ( schema_bp[-1] == '\n' )
567 ++ schema_current_state;
571 register schema_CHAR schema_c = schema_ec[* schema_cp];
572 if ( schema_accept[ schema_current_state] )
574 schema_last_accepting_state = schema_current_state;
575 schema_last_accepting_cpos = schema_cp;
577 while ( schema_chk[ schema_base[ schema_current_state] + schema_c] != schema_current_state )
579 schema_current_state = schema_def[ schema_current_state];
580 if ( schema_current_state >= 164 )
581 schema_c = schema_meta[ schema_c];
583 schema_current_state = schema_nxt[ schema_base[ schema_current_state] + schema_c];
586 while ( schema_current_state != 163 );
587 schema_cp = schema_last_accepting_cpos;
588 schema_current_state = schema_last_accepting_state;
591 schema_act = schema_accept[ schema_current_state];
593 schema_DO_BEFORE_ACTION;
596 do_action: /* this label is used only to access EOF actions */
599 switch ( schema_act )
601 case 0: /* must backtrack */
602 /* undo the effects of schema_DO_BEFORE_ACTION */
603 * schema_cp = schema_hold_char;
604 schema_cp = schema_last_accepting_cpos;
605 schema_current_state = schema_last_accepting_state;
606 goto schema_find_action;
745 return(CACHED_PAGES);
773 schemalval.integer = atoi((char*) schematext);
779 if ( replace_string[0] != 0 && schematext[0] == '$' ) {
780 int len = MIN(strlen((char*) schematext+1),
781 (unsigned int)(PATHSIZ - replace_string_len - 1));
782 *((char *) memcpy(replace_string + replace_string_len,
783 (char*) schematext+1, len) + len) = '\0';
784 schemalval.string = replace_string;
786 schemalval.string = (char*) schematext;
791 schema_FATAL_ERROR( "flex scanner jammed" );
793 case schema_STATE_EOF(INITIAL):
796 case schema_END_OF_BUFFER:
798 /* amount of text matched not including the EOB char */
799 int schema_amount_of_matched_text = schema_cp - schematext - 1;
801 /* undo the effects of schema_DO_BEFORE_ACTION */
802 * schema_cp = schema_hold_char;
804 /* note that here we test for schema_c_buf_p "<=" to the position
805 * of the first EOB in the buffer, since schema_c_buf_p will
806 * already have been incremented past the NUL character
807 * (since all states make transitions on EOB to the end-
808 * of-buffer state). Contrast this with the test in schemainput().
810 if ( schema_c_buf_p <= & schema_current_buffer-> schema_ch_buf[ schema_n_chars] )
811 /* this was really a NUL */
813 schema_state_type schema_next_state;
815 schema_c_buf_p = schematext + schema_amount_of_matched_text;
817 schema_current_state = schema_get_previous_state();
819 /* okay, we're now positioned to make the
820 * NUL transition. We couldn't have
821 * schema_get_previous_state() go ahead and do it
822 * for us because it doesn't know how to deal
823 * with the possibility of jamming (and we
824 * don't want to build jamming into it because
825 * then it will run more slowly)
828 schema_next_state = schema_try_NUL_trans( schema_current_state );
830 schema_bp = schematext + schema_MORE_ADJ;
832 if ( schema_next_state )
834 /* consume the NUL */
835 schema_cp = ++ schema_c_buf_p;
836 schema_current_state = schema_next_state;
842 schema_cp = schema_last_accepting_cpos;
843 schema_current_state = schema_last_accepting_state;
844 goto schema_find_action;
848 else switch ( schema_get_next_buffer() )
850 case EOB_ACT_END_OF_FILE:
852 schema_did_buffer_switch_on_eof = 0;
856 /* note: because we've taken care in
857 * schema_get_next_buffer() to have set up schematext,
858 * we can now set up schema_c_buf_p so that if some
859 * total hoser (like flex itself) wants
860 * to call the scanner after we return the
861 * schema_NULL, it'll still work - another schema_NULL
864 schema_c_buf_p = schematext + schema_MORE_ADJ;
866 schema_act = schema_STATE_EOF(( schema_start - 1) / 2);
872 if ( ! schema_did_buffer_switch_on_eof )
878 case EOB_ACT_CONTINUE_SCAN:
879 schema_c_buf_p = schematext + schema_amount_of_matched_text;
881 schema_current_state = schema_get_previous_state();
883 schema_cp = schema_c_buf_p;
884 schema_bp = schematext + schema_MORE_ADJ;
887 case EOB_ACT_LAST_MATCH:
889 & schema_current_buffer-> schema_ch_buf[ schema_n_chars];
891 schema_current_state = schema_get_previous_state();
893 schema_cp = schema_c_buf_p;
894 schema_bp = schematext + schema_MORE_ADJ;
895 goto schema_find_action;
902 printf( "action # %d\n", schema_act );
905 "fatal flex scanner internal error--no action found" );
911 /* schema_get_next_buffer - try to read in a new buffer
914 * int schema_get_next_buffer();
916 * returns a code representing an action
917 * EOB_ACT_LAST_MATCH -
918 * EOB_ACT_CONTINUE_SCAN - continue scanning from current position
919 * EOB_ACT_END_OF_FILE - end of file
922 static int schema_get_next_buffer()
925 register schema_CHAR *dest = schema_current_buffer-> schema_ch_buf;
926 register schema_CHAR *source = schematext - 1; /* copy prev. char, too */
927 register int number_to_move, i;
930 if ( schema_c_buf_p > & schema_current_buffer-> schema_ch_buf[ schema_n_chars + 1] )
932 "fatal flex scanner internal error--end of buffer missed" );
934 /* try to read more data */
936 /* first move last chars to start of buffer */
937 number_to_move = schema_c_buf_p - schematext;
939 for ( i = 0; i < number_to_move; ++i )
940 *(dest++) = *(source++);
942 if ( schema_current_buffer-> schema_eof_status != EOF_NOT_SEEN )
943 /* don't do the read, it's not guaranteed to return an EOF,
950 int num_to_read = schema_current_buffer-> schema_buf_size - number_to_move - 1;
952 if ( num_to_read > schema_READ_BUF_SIZE )
953 num_to_read = schema_READ_BUF_SIZE;
955 else if ( num_to_read <= 0 )
956 schema_FATAL_ERROR( "fatal error - scanner input buffer overflow" );
958 /* read in more data */
959 schema_INPUT( (& schema_current_buffer-> schema_ch_buf[number_to_move]),
960 schema_n_chars, num_to_read );
963 if ( schema_n_chars == 0 )
965 if ( number_to_move == 1 )
967 ret_val = EOB_ACT_END_OF_FILE;
968 schema_current_buffer-> schema_eof_status = EOF_DONE;
973 ret_val = EOB_ACT_LAST_MATCH;
974 schema_current_buffer-> schema_eof_status = EOF_PENDING;
979 ret_val = EOB_ACT_CONTINUE_SCAN;
981 schema_n_chars += number_to_move;
982 schema_current_buffer-> schema_ch_buf[ schema_n_chars] = schema_END_OF_BUFFER_CHAR;
983 schema_current_buffer-> schema_ch_buf[ schema_n_chars + 1] = schema_END_OF_BUFFER_CHAR;
985 /* schematext begins at the second character in schema_ch_buf; the first
986 * character is the one which preceded it before reading in the latest
987 * buffer; it needs to be kept around in case it's a newline, so
988 * schema_get_previous_state() will have with '^' rules active
991 schematext = & schema_current_buffer-> schema_ch_buf[1];
997 /* schema_get_previous_state - get the state just before the EOB char was reached
1000 * schema_state_type schema_get_previous_state();
1003 static schema_state_type schema_get_previous_state()
1006 register schema_state_type schema_current_state;
1007 register schema_CHAR * schema_cp;
1009 register schema_CHAR * schema_bp = schematext;
1011 schema_current_state = schema_start;
1012 if ( schema_bp[-1] == '\n' )
1013 ++ schema_current_state;
1015 for ( schema_cp = schematext + schema_MORE_ADJ; schema_cp < schema_c_buf_p; ++ schema_cp )
1017 register schema_CHAR schema_c = (* schema_cp ? schema_ec[* schema_cp] : 1);
1018 if ( schema_accept[ schema_current_state] )
1020 schema_last_accepting_state = schema_current_state;
1021 schema_last_accepting_cpos = schema_cp;
1023 while ( schema_chk[ schema_base[ schema_current_state] + schema_c] != schema_current_state )
1025 schema_current_state = schema_def[ schema_current_state];
1026 if ( schema_current_state >= 164 )
1027 schema_c = schema_meta[ schema_c];
1029 schema_current_state = schema_nxt[ schema_base[ schema_current_state] + schema_c];
1032 return ( schema_current_state );
1036 /* schema_try_NUL_trans - try to make a transition on the NUL character
1039 * next_state = schema_try_NUL_trans( current_state );
1042 #ifdef schema_USE_PROTOS
1043 static schema_state_type schema_try_NUL_trans( register schema_state_type schema_current_state )
1045 static schema_state_type schema_try_NUL_trans( schema_current_state )
1046 register schema_state_type schema_current_state;
1050 register int schema_is_jam;
1051 register schema_CHAR * schema_cp = schema_c_buf_p;
1053 register schema_CHAR schema_c = 1;
1054 if ( schema_accept[ schema_current_state] )
1056 schema_last_accepting_state = schema_current_state;
1057 schema_last_accepting_cpos = schema_cp;
1059 while ( schema_chk[ schema_base[ schema_current_state] + schema_c] != schema_current_state )
1061 schema_current_state = schema_def[ schema_current_state];
1062 if ( schema_current_state >= 164 )
1063 schema_c = schema_meta[ schema_c];
1065 schema_current_state = schema_nxt[ schema_base[ schema_current_state] + schema_c];
1066 schema_is_jam = ( schema_current_state == 163);
1068 return ( schema_is_jam ? 0 : schema_current_state );
1073 #ifdef schema_USE_PROTOS
1074 static void schemaunput( schema_CHAR c, register schema_CHAR * schema_bp )
1076 static void schemaunput( c, schema_bp )
1078 register schema_CHAR * schema_bp;
1082 register schema_CHAR * schema_cp = schema_c_buf_p;
1084 /* undo effects of setting up schematext */
1085 * schema_cp = schema_hold_char;
1087 if ( schema_cp < schema_current_buffer-> schema_ch_buf + 2 )
1088 { /* need to shift things up to make room */
1089 register int number_to_move = schema_n_chars + 2; /* +2 for EOB chars */
1090 register schema_CHAR *dest =
1091 & schema_current_buffer-> schema_ch_buf[ schema_current_buffer-> schema_buf_size + 2];
1092 register schema_CHAR *source =
1093 & schema_current_buffer-> schema_ch_buf[number_to_move];
1095 while ( source > schema_current_buffer-> schema_ch_buf )
1096 *--dest = *--source;
1098 schema_cp += dest - source;
1099 schema_bp += dest - source;
1100 schema_n_chars = schema_current_buffer-> schema_buf_size;
1102 if ( schema_cp < schema_current_buffer-> schema_ch_buf + 2 )
1103 schema_FATAL_ERROR( "flex scanner push-back overflow" );
1106 if ( schema_cp > schema_bp && schema_cp[-1] == '\n' )
1107 schema_cp[-2] = '\n';
1111 /* note: the formal parameter *must* be called " schema_bp" for this
1112 * macro to now work correctly
1114 schema_DO_BEFORE_ACTION; /* set up schematext again */
1121 static int schemainput()
1128 schema_CHAR * schema_cp = schema_c_buf_p;
1130 * schema_cp = schema_hold_char;
1132 if ( * schema_c_buf_p == schema_END_OF_BUFFER_CHAR )
1134 /* schema_c_buf_p now points to the character we want to return.
1135 * If this occurs *before* the EOB characters, then it's a
1136 * valid NUL; if not, then we've hit the end of the buffer.
1138 if ( schema_c_buf_p < & schema_current_buffer-> schema_ch_buf[ schema_n_chars] )
1139 /* this was really a NUL */
1140 * schema_c_buf_p = '\0';
1143 { /* need more input */
1144 schematext = schema_c_buf_p;
1147 switch ( schema_get_next_buffer() )
1149 case EOB_ACT_END_OF_FILE:
1153 schema_c_buf_p = schematext + schema_MORE_ADJ;
1160 return ( schemainput() );
1167 case EOB_ACT_CONTINUE_SCAN:
1168 schema_c_buf_p = schematext + schema_MORE_ADJ;
1171 case EOB_ACT_LAST_MATCH:
1173 schema_FATAL_ERROR( "unexpected last match in schemainput()" );
1175 schema_FATAL_ERROR( "unexpected last match in input()" );
1181 c = * schema_c_buf_p;
1182 schema_hold_char = *++ schema_c_buf_p;
1189 #ifdef schema_USE_PROTOS
1190 void schemarestart( FILE *input_file )
1192 void schemarestart( input_file )
1197 schema_init_buffer( schema_current_buffer, input_file );
1198 schema_load_buffer_state();
1202 #ifdef schema_USE_PROTOS
1203 void schema_switch_to_buffer( schema_BUFFER_STATE new_buffer )
1205 void schema_switch_to_buffer( new_buffer )
1206 schema_BUFFER_STATE new_buffer;
1210 if ( schema_current_buffer == new_buffer )
1213 if ( schema_current_buffer )
1215 /* flush out information for old buffer */
1216 * schema_c_buf_p = schema_hold_char;
1217 schema_current_buffer-> schema_buf_pos = schema_c_buf_p;
1218 schema_current_buffer-> schema_n_chars = schema_n_chars;
1221 schema_current_buffer = new_buffer;
1222 schema_load_buffer_state();
1224 /* we don't actually know whether we did this switch during
1225 * EOF ( schemawrap()) processing, but the only time this flag
1226 * is looked at is after schemawrap() is called, so it's safe
1227 * to go ahead and always set it.
1229 schema_did_buffer_switch_on_eof = 1;
1233 #ifdef schema_USE_PROTOS
1234 void schema_load_buffer_state( void )
1236 void schema_load_buffer_state()
1240 schema_n_chars = schema_current_buffer-> schema_n_chars;
1241 schematext = schema_c_buf_p = schema_current_buffer-> schema_buf_pos;
1242 schemain = schema_current_buffer-> schema_input_file;
1243 schema_hold_char = * schema_c_buf_p;
1247 #ifdef schema_USE_PROTOS
1248 schema_BUFFER_STATE schema_create_buffer( FILE *file, int size )
1250 schema_BUFFER_STATE schema_create_buffer( file, size )
1256 schema_BUFFER_STATE b;
1258 b = ( schema_BUFFER_STATE) malloc( sizeof( struct schema_buffer_state ) );
1261 schema_FATAL_ERROR( "out of dynamic memory in schema_create_buffer()" );
1263 b-> schema_buf_size = size;
1265 /* schema_ch_buf has to be 2 characters longer than the size given because
1266 * we need to put in 2 end-of-buffer characters.
1268 b-> schema_ch_buf = ( schema_CHAR *) malloc( (unsigned) (b-> schema_buf_size + 2) );
1270 if ( ! b-> schema_ch_buf )
1271 schema_FATAL_ERROR( "out of dynamic memory in schema_create_buffer()" );
1273 schema_init_buffer( b, file );
1279 #ifdef schema_USE_PROTOS
1280 void schema_delete_buffer( schema_BUFFER_STATE b )
1282 void schema_delete_buffer( b )
1283 schema_BUFFER_STATE b;
1287 if ( b == schema_current_buffer )
1288 schema_current_buffer = ( schema_BUFFER_STATE) 0;
1290 free( (char *) b-> schema_ch_buf );
1295 #ifdef schema_USE_PROTOS
1296 void schema_init_buffer( schema_BUFFER_STATE b, FILE *file )
1298 void schema_init_buffer( b, file )
1299 schema_BUFFER_STATE b;
1304 b-> schema_input_file = file;
1306 /* we put in the '\n' and start reading from [1] so that an
1307 * initial match-at-newline will be true.
1310 b-> schema_ch_buf[0] = '\n';
1311 b-> schema_n_chars = 1;
1313 /* we always need two end-of-buffer characters. The first causes
1314 * a transition to the end-of-buffer state. The second causes
1315 * a jam in that state.
1317 b-> schema_ch_buf[1] = schema_END_OF_BUFFER_CHAR;
1318 b-> schema_ch_buf[2] = schema_END_OF_BUFFER_CHAR;
1320 b-> schema_buf_pos = &b-> schema_ch_buf[1];
1322 b-> schema_eof_status = EOF_NOT_SEEN;