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 librararies 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: ps.cc /main/5 1996/08/05 17:05:45 drk $
34 /* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */
46 #if defined(__osf__) || defined(linux) || defined(CSRG_BASED) || defined(sun)
49 #if !defined(__uxp__) && !defined(USL)
54 /* use prototypes in function declarations */
57 /* the "const" storage-class-modifier is valid */
60 #else /* ! __cplusplus */
66 void *malloc( size_t );
76 #endif /* ! __cplusplus */
90 #define ps_PROTO(proto) proto
92 #define ps_PROTO(proto) ()
93 /* we can't get here if it's an ANSI C compiler, or a C++ compiler,
94 * so it's got to be a K&R compiler, and therefore there's no standard
95 * place from which to include these definitions
103 /* amount of stuff to slurp up with each read */
104 #ifndef ps_READ_BUF_SIZE
105 #define ps_READ_BUF_SIZE 8192
108 /* returned upon end-of-file */
111 /* copy whatever the last rule matched to the standard output */
113 /* cast to (char *) is because for 8-bit chars, pstext is (unsigned char *) */
114 /* this used to be an fputs(), but since the string might contain NUL's,
115 * we now use fwrite()
117 #define ECHO (void) fwrite( (char *) pstext, psleng, 1, psout )
119 /* gets input and stuffs it into "buf". number of characters read, or ps_NULL,
120 * is returned in "result".
122 #define ps_INPUT(buf,result,max_size) \
123 if ( (result = read( fileno(psin), (char *) buf, max_size )) < 0 ) \
124 ps_FATAL_ERROR( "read() in flex scanner failed" );
127 /* no semi-colon after return; correct usage is to write "psterminate();" -
128 * we don't want an extra ';' after the "return" because that will cause
129 * some compilers to complain about unreachable statements.
131 #define psterminate() return ( ps_NULL )
133 /* report a fatal error */
135 /* The funky do-while is used to turn this macro definition into
136 * a single C statement (which needs a semi-colon terminator).
137 * This avoids problems with code like:
139 * if ( something_happens )
140 * ps_FATAL_ERROR( "oops, the something happened" );
144 * Prior to using the do-while the compiler would get upset at the
145 * "else" because it interpreted the "if" statement as being all
146 * done when it reached the ';' after the ps_FATAL_ERROR() call.
149 #define ps_FATAL_ERROR(msg) \
152 (void) fputs( msg, stderr ); \
153 (void) putc( '\n', stderr ); \
158 /* default pswrap function - always treat EOF as an EOF */
161 /* enter a start condition. This macro really ought to take a parameter,
162 * but we do it the disgusting crufty way forced on us by the ()-less
163 * definition of BEGIN
165 #define BEGIN ps_start = 1 + 2 *
167 /* action number for EOF rule of a given start state */
168 #define ps_STATE_EOF(state) (ps_END_OF_BUFFER + state + 1)
170 /* special action meaning "start processing a new file" */
171 #define ps_NEW_FILE \
174 ps_init_buffer( ps_current_buffer, psin ); \
175 ps_load_buffer_state(); \
179 /* default declaration of generated scanner - a define so the user can
180 * easily add parameters
182 #define ps_DECL int pslex ps_PROTO(( void ))
184 /* code executed at the end of each rule */
185 #define ps_BREAK break;
187 #define ps_END_OF_BUFFER_CHAR 0
190 #define ps_BUF_SIZE (ps_READ_BUF_SIZE * 2) /* size of default input buffer */
193 typedef struct ps_buffer_state *ps_BUFFER_STATE;
195 #define ps_CHAR unsigned char
199 * $XConsortium: ps.cc /main/5 1996/08/05 17:05:45 drk $
201 * Copyright (c) 1993 HAL Computer Systems International, Ltd.
202 * All rights reserved. Unpublished -- rights reserved under
203 * the Copyright Laws of the United States. USE OF A COPYRIGHT
204 * NOTICE IS PRECAUTIONARY ONLY AND DOES NOT IMPLY PUBLICATION
207 * THIS SOFTWARE CONTAINS CONFIDENTIAL INFORMATION AND TRADE
208 * SECRETS OF HAL COMPUTER SYSTEMS INTERNATIONAL, LTD. USE,
209 * DISCLOSURE, OR REPRODUCTION IS PROHIBITED WITHOUT THE
210 * PRIOR EXPRESS WRITTEN PERMISSION OF HAL COMPUTER SYSTEMS
211 * INTERNATIONAL, LTD.
213 * RESTRICTED RIGHTS LEGEND
214 * Use, duplication, or disclosure by the Government is subject
215 * to the restrictions as set forth in subparagraph (c)(l)(ii)
216 * of the Rights in Technical Data and Computer Software clause
217 * at DFARS 252.227-7013.
219 * HAL COMPUTER SYSTEMS INTERNATIONAL, LTD.
226 #include "compression/trie.h"
227 #include "compression/abs_agent.h"
229 static unsigned char psbuf[LBUFSIZ];
230 static int psbuf_sz = LBUFSIZ;
231 static int psbuffed = 0;
237 #define ps_INPUT(buf,result,max_size) \
239 result = (*fill_buf_func)((unsigned char*)buf,max_size); \
245 /* done after the current pattern has been matched and before the
246 * corresponding action - sets up pstext
248 #define ps_DO_BEFORE_ACTION \
250 psleng = ps_cp - ps_bp; \
251 ps_hold_char = *ps_cp; \
255 #define EOB_ACT_CONTINUE_SCAN 0
256 #define EOB_ACT_END_OF_FILE 1
257 #define EOB_ACT_LAST_MATCH 2
259 /* return all but the first 'n' matched characters back to the input stream */
263 /* undo effects of setting up pstext */ \
264 *ps_cp = ps_hold_char; \
265 ps_c_buf_p = ps_cp = ps_bp + n; \
266 ps_DO_BEFORE_ACTION; /* set up pstext again */ \
270 #define unput(c) psunput( c, pstext )
273 struct ps_buffer_state
277 ps_CHAR *ps_ch_buf; /* input buffer */
278 ps_CHAR *ps_buf_pos; /* current position in input buffer */
280 /* size of input buffer in bytes, not including room for EOB characters*/
283 /* number of characters read into ps_ch_buf, not including EOB characters */
286 int ps_eof_status; /* whether we've seen an EOF on this buffer */
287 #define EOF_NOT_SEEN 0
288 /* "pending" happens when the EOF has been seen but there's still
291 #define EOF_PENDING 1
295 static ps_BUFFER_STATE ps_current_buffer;
297 /* we provide macros for accessing buffer states in case in the
298 * future we want to put the buffer states in a more general
301 #define ps_CURRENT_BUFFER ps_current_buffer
304 /* ps_hold_char holds the character lost when pstext is formed */
305 static ps_CHAR ps_hold_char;
307 static int ps_n_chars; /* number of characters read into ps_ch_buf */
311 #ifndef ps_USER_ACTION
312 #define ps_USER_ACTION
319 extern ps_CHAR *pstext;
321 extern FILE *psin, *psout;
326 FILE *psin = (FILE *) 0, *psout = (FILE *) 0;
328 #define ps_END_OF_BUFFER 3
329 typedef int ps_state_type;
330 static const short int ps_accept[6] =
335 static const ps_CHAR ps_ec[256] =
337 1, 1, 1, 1, 1, 1, 1, 1, 1, 2,
338 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
339 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
340 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
341 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
342 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
343 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
344 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
345 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
346 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
348 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
349 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
350 1, 1, 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 ps_CHAR ps_meta[3] =
372 static const short int ps_base[6] =
377 static const short int ps_def[6] =
382 static const short int ps_nxt[7] =
387 static const short int ps_chk[7] =
392 static ps_state_type ps_last_accepting_state;
393 static ps_CHAR *ps_last_accepting_cpos;
395 /* the intent behind this definition is that it'll catch
396 * any uses of REJECT which flex missed
398 #define REJECT reject_used_but_not_detected
399 #define psmore() psmore_used_but_not_detected
400 #define ps_MORE_ADJ 0
402 /* these variables are all declared out here so that section 3 code can
405 /* points to current character in buffer */
406 static ps_CHAR *ps_c_buf_p = (ps_CHAR *) 0;
407 static int ps_init = 1; /* whether we need to initialize */
408 static int ps_start = 0; /* start state number */
410 /* flag which is used to allow pswrap()'s to do buffer switches
411 * instead of setting up a fresh psin. A bit of a hack ...
413 static int ps_did_buffer_switch_on_eof;
415 static ps_state_type ps_get_previous_state ps_PROTO(( void ));
416 static ps_state_type ps_try_NUL_trans ps_PROTO(( ps_state_type current_state ));
417 static int ps_get_next_buffer ps_PROTO(( void ));
419 static void psunput ps_PROTO(( ps_CHAR c, ps_CHAR *buf_ptr ));
421 void psrestart ps_PROTO(( FILE *input_file ));
422 void ps_switch_to_buffer ps_PROTO(( ps_BUFFER_STATE new_buffer ));
423 void ps_load_buffer_state ps_PROTO(( void ));
424 ps_BUFFER_STATE ps_create_buffer ps_PROTO(( FILE *file, int size ));
425 void ps_delete_buffer ps_PROTO(( ps_BUFFER_STATE b ));
426 void ps_init_buffer ps_PROTO(( ps_BUFFER_STATE b, FILE *file ));
428 #define ps_new_buffer ps_create_buffer
432 static int psinput ps_PROTO(( void ));
434 static int input ps_PROTO(( void ));
440 register ps_state_type ps_current_state;
441 register ps_CHAR *ps_cp, *ps_bp;
452 ps_start = 1; /* first start state */
460 if ( ps_current_buffer )
461 ps_init_buffer( ps_current_buffer, psin );
463 ps_current_buffer = ps_create_buffer( psin, ps_BUF_SIZE );
465 ps_load_buffer_state();
470 while ( 1 ) /* loops until end-of-file is reached */
474 /* support of pstext */
475 *ps_cp = ps_hold_char;
477 /* ps_bp points to the position in ps_ch_buf of the start of the
482 ps_current_state = ps_start;
486 register ps_CHAR ps_c = ps_ec[*ps_cp];
487 if ( ps_accept[ps_current_state] )
489 ps_last_accepting_state = ps_current_state;
490 ps_last_accepting_cpos = ps_cp;
492 while ( ps_chk[ps_base[ps_current_state] + ps_c] != ps_current_state )
494 ps_current_state = ps_def[ps_current_state];
495 if ( ps_current_state >= 6 )
496 ps_c = ps_meta[ps_c];
498 ps_current_state = ps_nxt[ps_base[ps_current_state] + ps_c];
501 while ( ps_current_state != 5 );
502 ps_cp = ps_last_accepting_cpos;
503 ps_current_state = ps_last_accepting_state;
506 ps_act = ps_accept[ps_current_state];
511 do_action: /* this label is used only to access EOF actions */
516 case 0: /* must backtrack */
517 /* undo the effects of ps_DO_BEFORE_ACTION */
518 *ps_cp = ps_hold_char;
519 ps_cp = ps_last_accepting_cpos;
520 ps_current_state = ps_last_accepting_state;
526 if ( psbuffed >= psbuf_sz ) {
527 //alphabet -> add_letters( psbuf, psbuf_sz );
528 (*lex_action_func)(psbuf, psbuf_sz, 2);
532 psbuf[psbuffed++] = pstext[0];
537 ps_FATAL_ERROR( "flex scanner jammed" );
539 case ps_STATE_EOF(INITIAL):
542 case ps_END_OF_BUFFER:
544 /* amount of text matched not including the EOB char */
545 int ps_amount_of_matched_text = ps_cp - pstext - 1;
547 /* undo the effects of ps_DO_BEFORE_ACTION */
548 *ps_cp = ps_hold_char;
550 /* note that here we test for ps_c_buf_p "<=" to the position
551 * of the first EOB in the buffer, since ps_c_buf_p will
552 * already have been incremented past the NUL character
553 * (since all states make transitions on EOB to the end-
554 * of-buffer state). Contrast this with the test in psinput().
556 if ( ps_c_buf_p <= &ps_current_buffer->ps_ch_buf[ps_n_chars] )
557 /* this was really a NUL */
559 ps_state_type ps_next_state;
561 ps_c_buf_p = pstext + ps_amount_of_matched_text;
563 ps_current_state = ps_get_previous_state();
565 /* okay, we're now positioned to make the
566 * NUL transition. We couldn't have
567 * ps_get_previous_state() go ahead and do it
568 * for us because it doesn't know how to deal
569 * with the possibility of jamming (and we
570 * don't want to build jamming into it because
571 * then it will run more slowly)
574 ps_next_state = ps_try_NUL_trans( ps_current_state );
576 ps_bp = pstext + ps_MORE_ADJ;
580 /* consume the NUL */
581 ps_cp = ++ps_c_buf_p;
582 ps_current_state = ps_next_state;
588 ps_cp = ps_last_accepting_cpos;
589 ps_current_state = ps_last_accepting_state;
594 else switch ( ps_get_next_buffer() )
596 case EOB_ACT_END_OF_FILE:
598 ps_did_buffer_switch_on_eof = 0;
602 /* note: because we've taken care in
603 * ps_get_next_buffer() to have set up pstext,
604 * we can now set up ps_c_buf_p so that if some
605 * total hoser (like flex itself) wants
606 * to call the scanner after we return the
607 * ps_NULL, it'll still work - another ps_NULL
610 ps_c_buf_p = pstext + ps_MORE_ADJ;
612 ps_act = ps_STATE_EOF((ps_start - 1) / 2);
618 if ( ! ps_did_buffer_switch_on_eof )
624 case EOB_ACT_CONTINUE_SCAN:
625 ps_c_buf_p = pstext + ps_amount_of_matched_text;
627 ps_current_state = ps_get_previous_state();
630 ps_bp = pstext + ps_MORE_ADJ;
633 case EOB_ACT_LAST_MATCH:
635 &ps_current_buffer->ps_ch_buf[ps_n_chars];
637 ps_current_state = ps_get_previous_state();
640 ps_bp = pstext + ps_MORE_ADJ;
648 printf( "action # %d\n", ps_act );
651 "fatal flex scanner internal error--no action found" );
657 /* ps_get_next_buffer - try to read in a new buffer
660 * int ps_get_next_buffer();
662 * returns a code representing an action
663 * EOB_ACT_LAST_MATCH -
664 * EOB_ACT_CONTINUE_SCAN - continue scanning from current position
665 * EOB_ACT_END_OF_FILE - end of file
668 static int ps_get_next_buffer()
671 register ps_CHAR *dest = ps_current_buffer->ps_ch_buf;
672 register ps_CHAR *source = pstext - 1; /* copy prev. char, too */
673 register int number_to_move, i;
676 if ( ps_c_buf_p > &ps_current_buffer->ps_ch_buf[ps_n_chars + 1] )
678 "fatal flex scanner internal error--end of buffer missed" );
680 /* try to read more data */
682 /* first move last chars to start of buffer */
683 number_to_move = ps_c_buf_p - pstext;
685 for ( i = 0; i < number_to_move; ++i )
686 *(dest++) = *(source++);
688 if ( ps_current_buffer->ps_eof_status != EOF_NOT_SEEN )
689 /* don't do the read, it's not guaranteed to return an EOF,
696 int num_to_read = ps_current_buffer->ps_buf_size - number_to_move - 1;
698 if ( num_to_read > ps_READ_BUF_SIZE )
699 num_to_read = ps_READ_BUF_SIZE;
701 else if ( num_to_read <= 0 )
702 ps_FATAL_ERROR( "fatal error - scanner input buffer overflow" );
704 /* read in more data */
705 ps_INPUT( (&ps_current_buffer->ps_ch_buf[number_to_move]),
706 ps_n_chars, num_to_read );
709 if ( ps_n_chars == 0 )
711 if ( number_to_move == 1 )
713 ret_val = EOB_ACT_END_OF_FILE;
714 ps_current_buffer->ps_eof_status = EOF_DONE;
719 ret_val = EOB_ACT_LAST_MATCH;
720 ps_current_buffer->ps_eof_status = EOF_PENDING;
725 ret_val = EOB_ACT_CONTINUE_SCAN;
727 ps_n_chars += number_to_move;
728 ps_current_buffer->ps_ch_buf[ps_n_chars] = ps_END_OF_BUFFER_CHAR;
729 ps_current_buffer->ps_ch_buf[ps_n_chars + 1] = ps_END_OF_BUFFER_CHAR;
731 /* pstext begins at the second character in ps_ch_buf; the first
732 * character is the one which preceded it before reading in the latest
733 * buffer; it needs to be kept around in case it's a newline, so
734 * ps_get_previous_state() will have with '^' rules active
737 pstext = &ps_current_buffer->ps_ch_buf[1];
743 /* ps_get_previous_state - get the state just before the EOB char was reached
746 * ps_state_type ps_get_previous_state();
749 static ps_state_type ps_get_previous_state()
752 register ps_state_type ps_current_state;
753 register ps_CHAR *ps_cp;
755 ps_current_state = ps_start;
757 for ( ps_cp = pstext + ps_MORE_ADJ; ps_cp < ps_c_buf_p; ++ps_cp )
759 register ps_CHAR ps_c = (*ps_cp ? ps_ec[*ps_cp] : 1);
760 if ( ps_accept[ps_current_state] )
762 ps_last_accepting_state = ps_current_state;
763 ps_last_accepting_cpos = ps_cp;
765 while ( ps_chk[ps_base[ps_current_state] + ps_c] != ps_current_state )
767 ps_current_state = ps_def[ps_current_state];
768 if ( ps_current_state >= 6 )
769 ps_c = ps_meta[ps_c];
771 ps_current_state = ps_nxt[ps_base[ps_current_state] + ps_c];
774 return ( ps_current_state );
778 /* ps_try_NUL_trans - try to make a transition on the NUL character
781 * next_state = ps_try_NUL_trans( current_state );
785 static ps_state_type ps_try_NUL_trans( register ps_state_type ps_current_state )
787 static ps_state_type ps_try_NUL_trans( ps_current_state )
788 register ps_state_type ps_current_state;
792 register int ps_is_jam;
793 register ps_CHAR *ps_cp = ps_c_buf_p;
795 register ps_CHAR ps_c = 1;
796 if ( ps_accept[ps_current_state] )
798 ps_last_accepting_state = ps_current_state;
799 ps_last_accepting_cpos = ps_cp;
801 while ( ps_chk[ps_base[ps_current_state] + ps_c] != ps_current_state )
803 ps_current_state = ps_def[ps_current_state];
804 if ( ps_current_state >= 6 )
805 ps_c = ps_meta[ps_c];
807 ps_current_state = ps_nxt[ps_base[ps_current_state] + ps_c];
808 ps_is_jam = (ps_current_state == 5);
810 return ( ps_is_jam ? 0 : ps_current_state );
816 static void psunput( ps_CHAR c, register ps_CHAR *ps_bp )
818 static void psunput( c, ps_bp )
820 register ps_CHAR *ps_bp;
824 register ps_CHAR *ps_cp = ps_c_buf_p;
826 /* undo effects of setting up pstext */
827 *ps_cp = ps_hold_char;
829 if ( ps_cp < ps_current_buffer->ps_ch_buf + 2 )
830 { /* need to shift things up to make room */
831 register int number_to_move = ps_n_chars + 2; /* +2 for EOB chars */
832 register ps_CHAR *dest =
833 &ps_current_buffer->ps_ch_buf[ps_current_buffer->ps_buf_size + 2];
834 register ps_CHAR *source =
835 &ps_current_buffer->ps_ch_buf[number_to_move];
837 while ( source > ps_current_buffer->ps_ch_buf )
840 ps_cp += dest - source;
841 ps_bp += dest - source;
842 ps_n_chars = ps_current_buffer->ps_buf_size;
844 if ( ps_cp < ps_current_buffer->ps_ch_buf + 2 )
845 ps_FATAL_ERROR( "flex scanner push-back overflow" );
848 if ( ps_cp > ps_bp && ps_cp[-1] == '\n' )
853 /* note: the formal parameter *must* be called "ps_bp" for this
854 * macro to now work correctly
856 ps_DO_BEFORE_ACTION; /* set up pstext again */
870 ps_CHAR *ps_cp = ps_c_buf_p;
872 *ps_cp = ps_hold_char;
874 if ( *ps_c_buf_p == ps_END_OF_BUFFER_CHAR )
876 /* ps_c_buf_p now points to the character we want to return.
877 * If this occurs *before* the EOB characters, then it's a
878 * valid NUL; if not, then we've hit the end of the buffer.
880 if ( ps_c_buf_p < &ps_current_buffer->ps_ch_buf[ps_n_chars] )
881 /* this was really a NUL */
885 { /* need more input */
889 switch ( ps_get_next_buffer() )
891 case EOB_ACT_END_OF_FILE:
895 ps_c_buf_p = pstext + ps_MORE_ADJ;
902 return ( psinput() );
909 case EOB_ACT_CONTINUE_SCAN:
910 ps_c_buf_p = pstext + ps_MORE_ADJ;
913 case EOB_ACT_LAST_MATCH:
915 ps_FATAL_ERROR( "unexpected last match in psinput()" );
917 ps_FATAL_ERROR( "unexpected last match in input()" );
924 ps_hold_char = *++ps_c_buf_p;
932 void psrestart( FILE *input_file )
934 void psrestart( input_file )
939 ps_init_buffer( ps_current_buffer, input_file );
940 ps_load_buffer_state();
945 void ps_switch_to_buffer( ps_BUFFER_STATE new_buffer )
947 void ps_switch_to_buffer( new_buffer )
948 ps_BUFFER_STATE new_buffer;
952 if ( ps_current_buffer == new_buffer )
955 if ( ps_current_buffer )
957 /* flush out information for old buffer */
958 *ps_c_buf_p = ps_hold_char;
959 ps_current_buffer->ps_buf_pos = ps_c_buf_p;
960 ps_current_buffer->ps_n_chars = ps_n_chars;
963 ps_current_buffer = new_buffer;
964 ps_load_buffer_state();
966 /* we don't actually know whether we did this switch during
967 * EOF (pswrap()) processing, but the only time this flag
968 * is looked at is after pswrap() is called, so it's safe
969 * to go ahead and always set it.
971 ps_did_buffer_switch_on_eof = 1;
976 void ps_load_buffer_state( void )
978 void ps_load_buffer_state()
982 ps_n_chars = ps_current_buffer->ps_n_chars;
983 pstext = ps_c_buf_p = ps_current_buffer->ps_buf_pos;
984 psin = ps_current_buffer->ps_input_file;
985 ps_hold_char = *ps_c_buf_p;
990 ps_BUFFER_STATE ps_create_buffer( FILE *file, int size )
992 ps_BUFFER_STATE ps_create_buffer( file, size )
1000 b = (ps_BUFFER_STATE) malloc( sizeof( struct ps_buffer_state ) );
1003 ps_FATAL_ERROR( "out of dynamic memory in ps_create_buffer()" );
1005 b->ps_buf_size = size;
1007 /* ps_ch_buf has to be 2 characters longer than the size given because
1008 * we need to put in 2 end-of-buffer characters.
1010 b->ps_ch_buf = (ps_CHAR *) malloc( (unsigned) (b->ps_buf_size + 2) );
1012 if ( ! b->ps_ch_buf )
1013 ps_FATAL_ERROR( "out of dynamic memory in ps_create_buffer()" );
1015 ps_init_buffer( b, file );
1021 #ifdef ps_USE_PROTOS
1022 void ps_delete_buffer( ps_BUFFER_STATE b )
1024 void ps_delete_buffer( b )
1029 if ( b == ps_current_buffer )
1030 ps_current_buffer = (ps_BUFFER_STATE) 0;
1032 free( (char *) b->ps_ch_buf );
1037 #ifdef ps_USE_PROTOS
1038 void ps_init_buffer( ps_BUFFER_STATE b, FILE *file )
1040 void ps_init_buffer( b, file )
1046 b->ps_input_file = file;
1048 /* we put in the '\n' and start reading from [1] so that an
1049 * initial match-at-newline will be true.
1052 b->ps_ch_buf[0] = '\n';
1055 /* we always need two end-of-buffer characters. The first causes
1056 * a transition to the end-of-buffer state. The second causes
1057 * a jam in that state.
1059 b->ps_ch_buf[1] = ps_END_OF_BUFFER_CHAR;
1060 b->ps_ch_buf[2] = ps_END_OF_BUFFER_CHAR;
1062 b->ps_buf_pos = &b->ps_ch_buf[1];
1064 b->ps_eof_status = EOF_NOT_SEEN;
1071 //alphabet -> add_letters( psbuf, psbuffed );
1072 (*lex_action_func)(psbuf, psbuffed, 2);