From 5bff5c5514eece60a8de91d9effcf139a5f7c4ab Mon Sep 17 00:00:00 2001 From: Liang Chang Date: Sat, 11 Dec 2021 00:26:01 +0800 Subject: [PATCH] DtMmdb: repair lex source in compression dir. --- .../dtinfo/DtMmdb/compression/Makefile.am | 10 + cde/programs/dtinfo/DtMmdb/compression/ps.C | 1073 ---------------- .../DtMmdb/compression/{ps.lex => ps.ll} | 3 - cde/programs/dtinfo/DtMmdb/compression/sgml.C | 1083 ----------------- .../DtMmdb/compression/{sgml.lex => sgml.ll} | 4 - 5 files changed, 10 insertions(+), 2163 deletions(-) delete mode 100644 cde/programs/dtinfo/DtMmdb/compression/ps.C rename cde/programs/dtinfo/DtMmdb/compression/{ps.lex => ps.ll} (97%) delete mode 100644 cde/programs/dtinfo/DtMmdb/compression/sgml.C rename cde/programs/dtinfo/DtMmdb/compression/{sgml.lex => sgml.ll} (97%) diff --git a/cde/programs/dtinfo/DtMmdb/compression/Makefile.am b/cde/programs/dtinfo/DtMmdb/compression/Makefile.am index f6e276356..05754ca79 100644 --- a/cde/programs/dtinfo/DtMmdb/compression/Makefile.am +++ b/cde/programs/dtinfo/DtMmdb/compression/Makefile.am @@ -6,3 +6,13 @@ libcompression_la_CXXFLAGS = -I.. libcompression_la_SOURCES = abs_agent.C zip.C huffman.C trie.C code.C lzss.C \ sgml.C ps.C + +AM_LFLAGS = -8 -s + +CLEANFILES = sgml.C ps.C + +sgml.C: sgml.ll + $(LEX) $(AM_LFLAGS) -P sgml -o $@ $< + +ps.C: ps.ll + $(LEX) $(AM_LFLAGS) -P ps -o $@ $< diff --git a/cde/programs/dtinfo/DtMmdb/compression/ps.C b/cde/programs/dtinfo/DtMmdb/compression/ps.C deleted file mode 100644 index 747f73141..000000000 --- a/cde/programs/dtinfo/DtMmdb/compression/ps.C +++ /dev/null @@ -1,1073 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* A lexical scanner generated by flex */ - -/* scanner skeleton version: - * $XConsortium: ps.cc /main/5 1996/08/05 17:05:45 drk $ - */ - -#define FLEX_SCANNER - -#include - - -/* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */ -#ifdef c_plusplus -#ifndef __cplusplus -#define __cplusplus -#endif -#endif - - -#ifdef __cplusplus - -#include - -#if defined(__linux__) || defined(CSRG_BASED) || defined(sun) -#include -#else -#include -#endif - -/* use prototypes in function declarations */ -#define ps_USE_PROTOS - -/* the "const" storage-class-modifier is valid */ -#define ps_USE_CONST - -#else /* ! __cplusplus */ - -#ifdef __STDC__ - -#ifdef __GNUC__ -#include -void *malloc( size_t ); -void free( void* ); -#else -#include -#endif /* __GNUC__ */ - -#define ps_USE_PROTOS -#define ps_USE_CONST - -#endif /* __STDC__ */ -#endif /* ! __cplusplus */ - - -#ifdef __TURBOC__ -#define ps_USE_CONST -#endif - - -#ifndef ps_USE_CONST -#define const -#endif - - -#ifdef ps_USE_PROTOS -#define ps_PROTO(proto) proto -#else -#define ps_PROTO(proto) () -/* we can't get here if it's an ANSI C compiler, or a C++ compiler, - * so it's got to be a K&R compiler, and therefore there's no standard - * place from which to include these definitions - */ -char *malloc(); -int free(); -int read(); -#endif - - -/* amount of stuff to slurp up with each read */ -#ifndef ps_READ_BUF_SIZE -#define ps_READ_BUF_SIZE 8192 -#endif - -/* returned upon end-of-file */ -#define ps_END_TOK 0 - -/* copy whatever the last rule matched to the standard output */ - -/* cast to (char *) is because for 8-bit chars, pstext is (unsigned char *) */ -/* this used to be an fputs(), but since the string might contain NUL's, - * we now use fwrite() - */ -#define ECHO (void) fwrite( (char *) pstext, psleng, 1, psout ) - -/* gets input and stuffs it into "buf". number of characters read, or ps_NULL, - * is returned in "result". - */ -#define ps_INPUT(buf,result,max_size) \ - if ( (result = read( fileno(psin), (char *) buf, max_size )) < 0 ) \ - ps_FATAL_ERROR( "read() in flex scanner failed" ); -#define ps_NULL 0 - -/* no semi-colon after return; correct usage is to write "psterminate();" - - * we don't want an extra ';' after the "return" because that will cause - * some compilers to complain about unreachable statements. - */ -#define psterminate() return ( ps_NULL ) - -/* report a fatal error */ - -/* The funky do-while is used to turn this macro definition into - * a single C statement (which needs a semi-colon terminator). - * This avoids problems with code like: - * - * if ( something_happens ) - * ps_FATAL_ERROR( "oops, the something happened" ); - * else - * everything_okay(); - * - * Prior to using the do-while the compiler would get upset at the - * "else" because it interpreted the "if" statement as being all - * done when it reached the ';' after the ps_FATAL_ERROR() call. - */ - -#define ps_FATAL_ERROR(msg) \ - do \ - { \ - (void) fputs( msg, stderr ); \ - (void) putc( '\n', stderr ); \ - exit( 1 ); \ - } \ - while ( 0 ) - -/* default pswrap function - always treat EOF as an EOF */ -#define pswrap() 1 - -/* enter a start condition. This macro really ought to take a parameter, - * but we do it the disgusting crufty way forced on us by the ()-less - * definition of BEGIN - */ -#define BEGIN ps_start = 1 + 2 * - -/* action number for EOF rule of a given start state */ -#define ps_STATE_EOF(state) (ps_END_OF_BUFFER + state + 1) - -/* special action meaning "start processing a new file" */ -#define ps_NEW_FILE \ - do \ - { \ - ps_init_buffer( ps_current_buffer, psin ); \ - ps_load_buffer_state(); \ - } \ - while ( 0 ) - -/* default declaration of generated scanner - a define so the user can - * easily add parameters - */ -#define ps_DECL int pslex ps_PROTO(( void )) - -/* code executed at the end of each rule */ -#define ps_BREAK break; - -#define ps_END_OF_BUFFER_CHAR 0 - -#ifndef ps_BUF_SIZE -#define ps_BUF_SIZE (ps_READ_BUF_SIZE * 2) /* size of default input buffer */ -#endif - -typedef struct ps_buffer_state *ps_BUFFER_STATE; - -#define ps_CHAR unsigned char -# line 1 "ps.l" -#define INITIAL 0 -/* -* $XConsortium: ps.cc /main/5 1996/08/05 17:05:45 drk $ -* -* Copyright (c) 1993 HAL Computer Systems International, Ltd. -* All rights reserved. Unpublished -- rights reserved under -* the Copyright Laws of the United States. USE OF A COPYRIGHT -* NOTICE IS PRECAUTIONARY ONLY AND DOES NOT IMPLY PUBLICATION -* OR DISCLOSURE. -* -* THIS SOFTWARE CONTAINS CONFIDENTIAL INFORMATION AND TRADE -* SECRETS OF HAL COMPUTER SYSTEMS INTERNATIONAL, LTD. USE, -* DISCLOSURE, OR REPRODUCTION IS PROHIBITED WITHOUT THE -* PRIOR EXPRESS WRITTEN PERMISSION OF HAL COMPUTER SYSTEMS -* INTERNATIONAL, LTD. -* -* RESTRICTED RIGHTS LEGEND -* Use, duplication, or disclosure by the Government is subject -* to the restrictions as set forth in subparagraph (c)(l)(ii) -* of the Rights in Technical Data and Computer Software clause -* at DFARS 252.227-7013. -* -* HAL COMPUTER SYSTEMS INTERNATIONAL, LTD. -* 1315 Dell Avenue -* Campbell, CA 95008 -* -*/ -# line 37 "ps.l" - -#include "compression/trie.h" -#include "compression/abs_agent.h" - -static unsigned char psbuf[LBUFSIZ]; -static int psbuf_sz = LBUFSIZ; -static int psbuffed = 0; - -#undef pswrap -int pswrap(); - -#undef ps_INPUT -#define ps_INPUT(buf,result,max_size) \ - { \ - result = (*fill_buf_func)((unsigned char*)buf,max_size); \ - } - - -# line 57 "ps.l" - -/* done after the current pattern has been matched and before the - * corresponding action - sets up pstext - */ -#define ps_DO_BEFORE_ACTION \ - pstext = ps_bp; \ - psleng = ps_cp - ps_bp; \ - ps_hold_char = *ps_cp; \ - *ps_cp = '\0'; \ - ps_c_buf_p = ps_cp; - -#define EOB_ACT_CONTINUE_SCAN 0 -#define EOB_ACT_END_OF_FILE 1 -#define EOB_ACT_LAST_MATCH 2 - -/* return all but the first 'n' matched characters back to the input stream */ -#define psless(n) \ - do \ - { \ - /* undo effects of setting up pstext */ \ - *ps_cp = ps_hold_char; \ - ps_c_buf_p = ps_cp = ps_bp + n; \ - ps_DO_BEFORE_ACTION; /* set up pstext again */ \ - } \ - while ( 0 ) - -#define unput(c) psunput( c, pstext ) - - -struct ps_buffer_state - { - FILE *ps_input_file; - - ps_CHAR *ps_ch_buf; /* input buffer */ - ps_CHAR *ps_buf_pos; /* current position in input buffer */ - - /* size of input buffer in bytes, not including room for EOB characters*/ - int ps_buf_size; - - /* number of characters read into ps_ch_buf, not including EOB characters */ - int ps_n_chars; - - int ps_eof_status; /* whether we've seen an EOF on this buffer */ -#define EOF_NOT_SEEN 0 - /* "pending" happens when the EOF has been seen but there's still - * some text process - */ -#define EOF_PENDING 1 -#define EOF_DONE 2 - }; - -static ps_BUFFER_STATE ps_current_buffer; - -/* we provide macros for accessing buffer states in case in the - * future we want to put the buffer states in a more general - * "scanner state" - */ -#define ps_CURRENT_BUFFER ps_current_buffer - - -/* ps_hold_char holds the character lost when pstext is formed */ -static ps_CHAR ps_hold_char; - -static int ps_n_chars; /* number of characters read into ps_ch_buf */ - - - -#ifndef ps_USER_ACTION -#define ps_USER_ACTION -#endif - -#ifndef ps_USER_INIT -#define ps_USER_INIT -#endif - -extern ps_CHAR *pstext; -extern int psleng; -extern FILE *psin, *psout; - -ps_CHAR *pstext; -int psleng; - -FILE *psin = (FILE *) 0, *psout = (FILE *) 0; - -#define ps_END_OF_BUFFER 3 -typedef int ps_state_type; -static const short int ps_accept[6] = - { 0, - 0, 0, 3, 1, 0 - } ; - -static const ps_CHAR ps_ec[256] = - { 0, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1 - } ; - -static const ps_CHAR ps_meta[3] = - { 0, - 1, 1 - } ; - -static const short int ps_base[6] = - { 0, - 0, 0, 3, 4, 4 - } ; - -static const short int ps_def[6] = - { 0, - 5, 1, 5, 5, 0 - } ; - -static const short int ps_nxt[7] = - { 0, - 4, 4, 5, 3, 5, 5 - } ; - -static const short int ps_chk[7] = - { 0, - 1, 1, 3, 5, 5, 5 - } ; - -static ps_state_type ps_last_accepting_state; -static ps_CHAR *ps_last_accepting_cpos; - -/* the intent behind this definition is that it'll catch - * any uses of REJECT which flex missed - */ -#define REJECT reject_used_but_not_detected -#define psmore() psmore_used_but_not_detected -#define ps_MORE_ADJ 0 - -/* these variables are all declared out here so that section 3 code can - * manipulate them - */ -/* points to current character in buffer */ -static ps_CHAR *ps_c_buf_p = (ps_CHAR *) 0; -static int ps_init = 1; /* whether we need to initialize */ -static int ps_start = 0; /* start state number */ - -/* flag which is used to allow pswrap()'s to do buffer switches - * instead of setting up a fresh psin. A bit of a hack ... - */ -static int ps_did_buffer_switch_on_eof; - -static ps_state_type ps_get_previous_state ps_PROTO(( void )); -static ps_state_type ps_try_NUL_trans ps_PROTO(( ps_state_type current_state )); -static int ps_get_next_buffer ps_PROTO(( void )); -#if 0 -static void psunput ps_PROTO(( ps_CHAR c, ps_CHAR *buf_ptr )); -#endif -void psrestart ps_PROTO(( FILE *input_file )); -void ps_switch_to_buffer ps_PROTO(( ps_BUFFER_STATE new_buffer )); -void ps_load_buffer_state ps_PROTO(( void )); -ps_BUFFER_STATE ps_create_buffer ps_PROTO(( FILE *file, int size )); -void ps_delete_buffer ps_PROTO(( ps_BUFFER_STATE b )); -void ps_init_buffer ps_PROTO(( ps_BUFFER_STATE b, FILE *file )); - -#define ps_new_buffer ps_create_buffer - -#if 0 -#ifdef __cplusplus -static int psinput ps_PROTO(( void )); -#else -static int input ps_PROTO(( void )); -#endif -#endif - -ps_DECL - { - ps_state_type ps_current_state; - ps_CHAR *ps_cp, *ps_bp; - int ps_act; - - - - - if ( ps_init ) - { - ps_USER_INIT; - - if ( ! ps_start ) - ps_start = 1; /* first start state */ - - if ( ! psin ) - psin = stdin; - - if ( ! psout ) - psout = stdout; - - if ( ps_current_buffer ) - ps_init_buffer( ps_current_buffer, psin ); - else - ps_current_buffer = ps_create_buffer( psin, ps_BUF_SIZE ); - - ps_load_buffer_state(); - - ps_init = 0; - } - - while ( 1 ) /* loops until end-of-file is reached */ - { - ps_cp = ps_c_buf_p; - - /* support of pstext */ - *ps_cp = ps_hold_char; - - /* ps_bp points to the position in ps_ch_buf of the start of the - * current run. - */ - ps_bp = ps_cp; - - ps_current_state = ps_start; -ps_match: - do - { - ps_CHAR ps_c = ps_ec[*ps_cp]; - if ( ps_accept[ps_current_state] ) - { - ps_last_accepting_state = ps_current_state; - ps_last_accepting_cpos = ps_cp; - } - while ( ps_chk[ps_base[ps_current_state] + ps_c] != ps_current_state ) - { - ps_current_state = ps_def[ps_current_state]; - if ( ps_current_state >= 6 ) - ps_c = ps_meta[ps_c]; - } - ps_current_state = ps_nxt[ps_base[ps_current_state] + ps_c]; - ++ps_cp; - } - while ( ps_current_state != 5 ); - ps_cp = ps_last_accepting_cpos; - ps_current_state = ps_last_accepting_state; - -ps_find_action: - ps_act = ps_accept[ps_current_state]; - - ps_DO_BEFORE_ACTION; - ps_USER_ACTION; - -do_action: /* this label is used only to access EOF actions */ - - - switch ( ps_act ) - { - case 0: /* must backtrack */ - /* undo the effects of ps_DO_BEFORE_ACTION */ - *ps_cp = ps_hold_char; - ps_cp = ps_last_accepting_cpos; - ps_current_state = ps_last_accepting_state; - goto ps_find_action; - -case 1: -# line 59 "ps.l" -{ - if ( psbuffed >= psbuf_sz ) { - //alphabet -> add_letters( psbuf, psbuf_sz ); - (*lex_action_func)(psbuf, psbuf_sz, 2); - psbuffed = 0; - } - - psbuf[psbuffed++] = pstext[0]; - } - ps_BREAK -case 2: -# line 70 "ps.l" -ps_FATAL_ERROR( "flex scanner jammed" ); - ps_BREAK -case ps_STATE_EOF(INITIAL): - psterminate(); - - case ps_END_OF_BUFFER: - { - /* amount of text matched not including the EOB char */ - int ps_amount_of_matched_text = ps_cp - pstext - 1; - - /* undo the effects of ps_DO_BEFORE_ACTION */ - *ps_cp = ps_hold_char; - - /* note that here we test for ps_c_buf_p "<=" to the position - * of the first EOB in the buffer, since ps_c_buf_p will - * already have been incremented past the NUL character - * (since all states make transitions on EOB to the end- - * of-buffer state). Contrast this with the test in psinput(). - */ - if ( ps_c_buf_p <= &ps_current_buffer->ps_ch_buf[ps_n_chars] ) - /* this was really a NUL */ - { - ps_state_type ps_next_state; - - ps_c_buf_p = pstext + ps_amount_of_matched_text; - - ps_current_state = ps_get_previous_state(); - - /* okay, we're now positioned to make the - * NUL transition. We couldn't have - * ps_get_previous_state() go ahead and do it - * for us because it doesn't know how to deal - * with the possibility of jamming (and we - * don't want to build jamming into it because - * then it will run more slowly) - */ - - ps_next_state = ps_try_NUL_trans( ps_current_state ); - - ps_bp = pstext + ps_MORE_ADJ; - - if ( ps_next_state ) - { - /* consume the NUL */ - ps_cp = ++ps_c_buf_p; - ps_current_state = ps_next_state; - goto ps_match; - } - - else - { - ps_cp = ps_last_accepting_cpos; - ps_current_state = ps_last_accepting_state; - goto ps_find_action; - } - } - - else switch ( ps_get_next_buffer() ) - { - case EOB_ACT_END_OF_FILE: - { - ps_did_buffer_switch_on_eof = 0; - - if ( pswrap() ) - { - /* note: because we've taken care in - * ps_get_next_buffer() to have set up pstext, - * we can now set up ps_c_buf_p so that if some - * total hoser (like flex itself) wants - * to call the scanner after we return the - * ps_NULL, it'll still work - another ps_NULL - * will get returned. - */ - ps_c_buf_p = pstext + ps_MORE_ADJ; - - ps_act = ps_STATE_EOF((ps_start - 1) / 2); - goto do_action; - } - - else - { - if ( ! ps_did_buffer_switch_on_eof ) - ps_NEW_FILE; - } - } - break; - - case EOB_ACT_CONTINUE_SCAN: - ps_c_buf_p = pstext + ps_amount_of_matched_text; - - ps_current_state = ps_get_previous_state(); - - ps_cp = ps_c_buf_p; - ps_bp = pstext + ps_MORE_ADJ; - goto ps_match; - - case EOB_ACT_LAST_MATCH: - ps_c_buf_p = - &ps_current_buffer->ps_ch_buf[ps_n_chars]; - - ps_current_state = ps_get_previous_state(); - - ps_cp = ps_c_buf_p; - ps_bp = pstext + ps_MORE_ADJ; - goto ps_find_action; - } - break; - } - - default: -#ifdef FLEX_DEBUG - printf( "action # %d\n", ps_act ); -#endif - ps_FATAL_ERROR( - "fatal flex scanner internal error--no action found" ); - } - } - } - - -/* ps_get_next_buffer - try to read in a new buffer - * - * synopsis - * int ps_get_next_buffer(); - * - * returns a code representing an action - * EOB_ACT_LAST_MATCH - - * EOB_ACT_CONTINUE_SCAN - continue scanning from current position - * EOB_ACT_END_OF_FILE - end of file - */ - -static int ps_get_next_buffer() - - { - ps_CHAR *dest = ps_current_buffer->ps_ch_buf; - ps_CHAR *source = pstext - 1; /* copy prev. char, too */ - int number_to_move, i; - int ret_val; - - if ( ps_c_buf_p > &ps_current_buffer->ps_ch_buf[ps_n_chars + 1] ) - ps_FATAL_ERROR( - "fatal flex scanner internal error--end of buffer missed" ); - - /* try to read more data */ - - /* first move last chars to start of buffer */ - number_to_move = ps_c_buf_p - pstext; - - for ( i = 0; i < number_to_move; ++i ) - *(dest++) = *(source++); - - if ( ps_current_buffer->ps_eof_status != EOF_NOT_SEEN ) - /* don't do the read, it's not guaranteed to return an EOF, - * just force an EOF - */ - ps_n_chars = 0; - - else - { - int num_to_read = ps_current_buffer->ps_buf_size - number_to_move - 1; - - if ( num_to_read > ps_READ_BUF_SIZE ) - num_to_read = ps_READ_BUF_SIZE; - - else if ( num_to_read <= 0 ) - ps_FATAL_ERROR( "fatal error - scanner input buffer overflow" ); - - /* read in more data */ - ps_INPUT( (&ps_current_buffer->ps_ch_buf[number_to_move]), - ps_n_chars, num_to_read ); - } - - if ( ps_n_chars == 0 ) - { - if ( number_to_move == 1 ) - { - ret_val = EOB_ACT_END_OF_FILE; - ps_current_buffer->ps_eof_status = EOF_DONE; - } - - else - { - ret_val = EOB_ACT_LAST_MATCH; - ps_current_buffer->ps_eof_status = EOF_PENDING; - } - } - - else - ret_val = EOB_ACT_CONTINUE_SCAN; - - ps_n_chars += number_to_move; - ps_current_buffer->ps_ch_buf[ps_n_chars] = ps_END_OF_BUFFER_CHAR; - ps_current_buffer->ps_ch_buf[ps_n_chars + 1] = ps_END_OF_BUFFER_CHAR; - - /* pstext begins at the second character in ps_ch_buf; the first - * character is the one which preceded it before reading in the latest - * buffer; it needs to be kept around in case it's a newline, so - * ps_get_previous_state() will have with '^' rules active - */ - - pstext = &ps_current_buffer->ps_ch_buf[1]; - - return ( ret_val ); - } - - -/* ps_get_previous_state - get the state just before the EOB char was reached - * - * synopsis - * ps_state_type ps_get_previous_state(); - */ - -static ps_state_type ps_get_previous_state() - - { - ps_state_type ps_current_state; - ps_CHAR *ps_cp; - - ps_current_state = ps_start; - - for ( ps_cp = pstext + ps_MORE_ADJ; ps_cp < ps_c_buf_p; ++ps_cp ) - { - ps_CHAR ps_c = (*ps_cp ? ps_ec[*ps_cp] : 1); - if ( ps_accept[ps_current_state] ) - { - ps_last_accepting_state = ps_current_state; - ps_last_accepting_cpos = ps_cp; - } - while ( ps_chk[ps_base[ps_current_state] + ps_c] != ps_current_state ) - { - ps_current_state = ps_def[ps_current_state]; - if ( ps_current_state >= 6 ) - ps_c = ps_meta[ps_c]; - } - ps_current_state = ps_nxt[ps_base[ps_current_state] + ps_c]; - } - - return ( ps_current_state ); - } - - -/* ps_try_NUL_trans - try to make a transition on the NUL character - * - * synopsis - * next_state = ps_try_NUL_trans( current_state ); - */ - -#ifdef ps_USE_PROTOS -static ps_state_type ps_try_NUL_trans( ps_state_type ps_current_state ) -#else -static ps_state_type ps_try_NUL_trans( ps_current_state ) -ps_state_type ps_current_state; -#endif - - { - int ps_is_jam; - ps_CHAR *ps_cp = ps_c_buf_p; - - ps_CHAR ps_c = 1; - if ( ps_accept[ps_current_state] ) - { - ps_last_accepting_state = ps_current_state; - ps_last_accepting_cpos = ps_cp; - } - while ( ps_chk[ps_base[ps_current_state] + ps_c] != ps_current_state ) - { - ps_current_state = ps_def[ps_current_state]; - if ( ps_current_state >= 6 ) - ps_c = ps_meta[ps_c]; - } - ps_current_state = ps_nxt[ps_base[ps_current_state] + ps_c]; - ps_is_jam = (ps_current_state == 5); - - return ( ps_is_jam ? 0 : ps_current_state ); - } - - -#if 0 -#ifdef ps_USE_PROTOS -static void psunput( ps_CHAR c, ps_CHAR *ps_bp ) -#else -static void psunput( c, ps_bp ) -ps_CHAR c; -ps_CHAR *ps_bp; -#endif - - { - ps_CHAR *ps_cp = ps_c_buf_p; - - /* undo effects of setting up pstext */ - *ps_cp = ps_hold_char; - - if ( ps_cp < ps_current_buffer->ps_ch_buf + 2 ) - { /* need to shift things up to make room */ - int number_to_move = ps_n_chars + 2; /* +2 for EOB chars */ - ps_CHAR *dest = - &ps_current_buffer->ps_ch_buf[ps_current_buffer->ps_buf_size + 2]; - ps_CHAR *source = - &ps_current_buffer->ps_ch_buf[number_to_move]; - - while ( source > ps_current_buffer->ps_ch_buf ) - *--dest = *--source; - - ps_cp += dest - source; - ps_bp += dest - source; - ps_n_chars = ps_current_buffer->ps_buf_size; - - if ( ps_cp < ps_current_buffer->ps_ch_buf + 2 ) - ps_FATAL_ERROR( "flex scanner push-back overflow" ); - } - - if ( ps_cp > ps_bp && ps_cp[-1] == '\n' ) - ps_cp[-2] = '\n'; - - *--ps_cp = c; - - /* note: the formal parameter *must* be called "ps_bp" for this - * macro to now work correctly - */ - ps_DO_BEFORE_ACTION; /* set up pstext again */ - } -#endif - - -#if 0 -#ifdef __cplusplus -static int psinput() -#else -static int input() -#endif - - { - int c; - ps_CHAR *ps_cp = ps_c_buf_p; - - *ps_cp = ps_hold_char; - - if ( *ps_c_buf_p == ps_END_OF_BUFFER_CHAR ) - { - /* ps_c_buf_p now points to the character we want to return. - * If this occurs *before* the EOB characters, then it's a - * valid NUL; if not, then we've hit the end of the buffer. - */ - if ( ps_c_buf_p < &ps_current_buffer->ps_ch_buf[ps_n_chars] ) - /* this was really a NUL */ - *ps_c_buf_p = '\0'; - - else - { /* need more input */ - pstext = ps_c_buf_p; - ++ps_c_buf_p; - - switch ( ps_get_next_buffer() ) - { - case EOB_ACT_END_OF_FILE: - { - if ( pswrap() ) - { - ps_c_buf_p = pstext + ps_MORE_ADJ; - return ( EOF ); - } - - ps_NEW_FILE; - -#ifdef __cplusplus - return ( psinput() ); -#else - return ( input() ); -#endif - } - break; - - case EOB_ACT_CONTINUE_SCAN: - ps_c_buf_p = pstext + ps_MORE_ADJ; - break; - - case EOB_ACT_LAST_MATCH: -#ifdef __cplusplus - ps_FATAL_ERROR( "unexpected last match in psinput()" ); -#else - ps_FATAL_ERROR( "unexpected last match in input()" ); -#endif - } - } - } - - c = *ps_c_buf_p; - ps_hold_char = *++ps_c_buf_p; - - return ( c ); - } -#endif - - -#ifdef ps_USE_PROTOS -void psrestart( FILE *input_file ) -#else -void psrestart( input_file ) -FILE *input_file; -#endif - - { - ps_init_buffer( ps_current_buffer, input_file ); - ps_load_buffer_state(); - } - - -#ifdef ps_USE_PROTOS -void ps_switch_to_buffer( ps_BUFFER_STATE new_buffer ) -#else -void ps_switch_to_buffer( new_buffer ) -ps_BUFFER_STATE new_buffer; -#endif - - { - if ( ps_current_buffer == new_buffer ) - return; - - if ( ps_current_buffer ) - { - /* flush out information for old buffer */ - *ps_c_buf_p = ps_hold_char; - ps_current_buffer->ps_buf_pos = ps_c_buf_p; - ps_current_buffer->ps_n_chars = ps_n_chars; - } - - ps_current_buffer = new_buffer; - ps_load_buffer_state(); - - /* we don't actually know whether we did this switch during - * EOF (pswrap()) processing, but the only time this flag - * is looked at is after pswrap() is called, so it's safe - * to go ahead and always set it. - */ - ps_did_buffer_switch_on_eof = 1; - } - - -#ifdef ps_USE_PROTOS -void ps_load_buffer_state( void ) -#else -void ps_load_buffer_state() -#endif - - { - ps_n_chars = ps_current_buffer->ps_n_chars; - pstext = ps_c_buf_p = ps_current_buffer->ps_buf_pos; - psin = ps_current_buffer->ps_input_file; - ps_hold_char = *ps_c_buf_p; - } - - -#ifdef ps_USE_PROTOS -ps_BUFFER_STATE ps_create_buffer( FILE *file, int size ) -#else -ps_BUFFER_STATE ps_create_buffer( file, size ) -FILE *file; -int size; -#endif - - { - ps_BUFFER_STATE b; - - b = (ps_BUFFER_STATE) malloc( sizeof( struct ps_buffer_state ) ); - - if ( ! b ) - ps_FATAL_ERROR( "out of dynamic memory in ps_create_buffer()" ); - - b->ps_buf_size = size; - - /* ps_ch_buf has to be 2 characters longer than the size given because - * we need to put in 2 end-of-buffer characters. - */ - b->ps_ch_buf = (ps_CHAR *) malloc( (unsigned) (b->ps_buf_size + 2) ); - - if ( ! b->ps_ch_buf ) - ps_FATAL_ERROR( "out of dynamic memory in ps_create_buffer()" ); - - ps_init_buffer( b, file ); - - return ( b ); - } - - -#ifdef ps_USE_PROTOS -void ps_delete_buffer( ps_BUFFER_STATE b ) -#else -void ps_delete_buffer( b ) -ps_BUFFER_STATE b; -#endif - - { - if ( b == ps_current_buffer ) - ps_current_buffer = (ps_BUFFER_STATE) 0; - - free( (char *) b->ps_ch_buf ); - free( (char *) b ); - } - - -#ifdef ps_USE_PROTOS -void ps_init_buffer( ps_BUFFER_STATE b, FILE *file ) -#else -void ps_init_buffer( b, file ) -ps_BUFFER_STATE b; -FILE *file; -#endif - - { - b->ps_input_file = file; - - /* we put in the '\n' and start reading from [1] so that an - * initial match-at-newline will be true. - */ - - b->ps_ch_buf[0] = '\n'; - b->ps_n_chars = 1; - - /* we always need two end-of-buffer characters. The first causes - * a transition to the end-of-buffer state. The second causes - * a jam in that state. - */ - b->ps_ch_buf[1] = ps_END_OF_BUFFER_CHAR; - b->ps_ch_buf[2] = ps_END_OF_BUFFER_CHAR; - - b->ps_buf_pos = &b->ps_ch_buf[1]; - - b->ps_eof_status = EOF_NOT_SEEN; - } -# line 70 "ps.l" - - -int pswrap() -{ - //alphabet -> add_letters( psbuf, psbuffed ); - (*lex_action_func)(psbuf, psbuffed, 2); - return 1; -} - diff --git a/cde/programs/dtinfo/DtMmdb/compression/ps.lex b/cde/programs/dtinfo/DtMmdb/compression/ps.ll similarity index 97% rename from cde/programs/dtinfo/DtMmdb/compression/ps.lex rename to cde/programs/dtinfo/DtMmdb/compression/ps.ll index 5561b7dfd..f66a5113d 100644 --- a/cde/programs/dtinfo/DtMmdb/compression/ps.lex +++ b/cde/programs/dtinfo/DtMmdb/compression/ps.ll @@ -41,9 +41,6 @@ static unsigned char yybuf[LBUFSIZ]; static int yybuf_sz = LBUFSIZ; static int yybuffed = 0; - -#undef yywrap -int yywrap(); #undef YY_INPUT #define YY_INPUT(buf,result,max_size) \ diff --git a/cde/programs/dtinfo/DtMmdb/compression/sgml.C b/cde/programs/dtinfo/DtMmdb/compression/sgml.C deleted file mode 100644 index bcfd4cea8..000000000 --- a/cde/programs/dtinfo/DtMmdb/compression/sgml.C +++ /dev/null @@ -1,1083 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* A lexical scanner generated by flex */ - -/* scanner skeleton version: - * $XConsortium: sgml.cc /main/5 1996/08/05 17:05:53 drk $ - */ - -#define FLEX_SCANNER - -#include - - -/* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */ -#ifdef c_plusplus -#ifndef __cplusplus -#define __cplusplus -#endif -#endif - - -#ifdef __cplusplus - -#include - -#if defined(__linux__) || defined(CSRG_BASED) || defined(sun) -#include -#else -#include -#endif - -/* use prototypes in function declarations */ -#define sgml_USE_PROTOS - -/* the "const" storage-class-modifier is valid */ -#define sgml_USE_CONST - -#else /* ! __cplusplus */ - -#ifdef __STDC__ - -#ifdef __GNUC__ -#include -void *malloc( size_t ); -void free( void* ); -#else -#include -#endif /* __GNUC__ */ - -#define sgml_USE_PROTOS -#define sgml_USE_CONST - -#endif /* __STDC__ */ -#endif /* ! __cplusplus */ - - -#ifdef __TURBOC__ -#define sgml_USE_CONST -#endif - - -#ifndef sgml_USE_CONST -#define const -#endif - - -#ifdef sgml_USE_PROTOS -#define sgml_PROTO(proto) proto -#else -#define sgml_PROTO(proto) () -/* we can't get here if it's an ANSI C compiler, or a C++ compiler, - * so it's got to be a K&R compiler, and therefore there's no standard - * place from which to include these definitions - */ -char *malloc(); -int free(); -int read(); -#endif - - -/* amount of stuff to slurp up with each read */ -#ifndef sgml_READ_BUF_SIZE -#define sgml_READ_BUF_SIZE 8192 -#endif - -/* returned upon end-of-file */ -#define sgml_END_TOK 0 - -/* copy whatever the last rule matched to the standard output */ - -/* cast to (char *) is because for 8-bit chars, sgmltext is (unsigned char *) */ -/* this used to be an fputs(), but since the string might contain NUL's, - * we now use fwrite() - */ -#define ECHO (void) fwrite( (char *) sgmltext, sgmlleng, 1, sgmlout ) - -/* gets input and stuffs it into "buf". number of characters read, or sgml_NULL, - * is returned in "result". - */ -#define sgml_INPUT(buf,result,max_size) \ - if ( (result = read( fileno(sgmlin), (char *) buf, max_size )) < 0 ) \ - sgml_FATAL_ERROR( "read() in flex scanner failed" ); -#define sgml_NULL 0 - -/* no semi-colon after return; correct usage is to write "sgmlterminate();" - - * we don't want an extra ';' after the "return" because that will cause - * some compilers to complain about unreachable statements. - */ -#define sgmlterminate() return ( sgml_NULL ) - -/* report a fatal error */ - -/* The funky do-while is used to turn this macro definition into - * a single C statement (which needs a semi-colon terminator). - * This avoids problems with code like: - * - * if ( something_happens ) - * sgml_FATAL_ERROR( "oops, the something happened" ); - * else - * everything_okay(); - * - * Prior to using the do-while the compiler would get upset at the - * "else" because it interpreted the "if" statement as being all - * done when it reached the ';' after the sgml_FATAL_ERROR() call. - */ - -#define sgml_FATAL_ERROR(msg) \ - do \ - { \ - (void) fputs( msg, stderr ); \ - (void) putc( '\n', stderr ); \ - exit( 1 ); \ - } \ - while ( 0 ) - -/* default sgmlwrap function - always treat EOF as an EOF */ -#define sgmlwrap() 1 - -/* enter a start condition. This macro really ought to take a parameter, - * but we do it the disgusting crufty way forced on us by the ()-less - * definition of BEGIN - */ -#define BEGIN sgml_start = 1 + 2 * - -/* action number for EOF rule of a given start state */ -#define sgml_STATE_EOF(state) (sgml_END_OF_BUFFER + state + 1) - -/* special action meaning "start processing a new file" */ -#define sgml_NEW_FILE \ - do \ - { \ - sgml_init_buffer( sgml_current_buffer, sgmlin ); \ - sgml_load_buffer_state(); \ - } \ - while ( 0 ) - -/* default declaration of generated scanner - a define so the user can - * easily add parameters - */ -#define sgml_DECL int sgmllex sgml_PROTO(( void )) - -/* code executed at the end of each rule */ -#define sgml_BREAK break; - -#define sgml_END_OF_BUFFER_CHAR 0 - -#ifndef sgml_BUF_SIZE -#define sgml_BUF_SIZE (sgml_READ_BUF_SIZE * 2) /* size of default input buffer */ -#endif - -typedef struct sgml_buffer_state *sgml_BUFFER_STATE; - -#define sgml_CHAR unsigned char -# line 1 "sgml.l" -#define INITIAL 0 -/* -* $XConsortium: sgml.cc /main/5 1996/08/05 17:05:53 drk $ -* -* Copyright (c) 1993 HAL Computer Systems International, Ltd. -* All rights reserved. Unpublished -- rights reserved under -* the Copyright Laws of the United States. USE OF A COPYRIGHT -* NOTICE IS PRECAUTIONARY ONLY AND DOES NOT IMPLY PUBLICATION -* OR DISCLOSURE. -* -* THIS SOFTWARE CONTAINS CONFIDENTIAL INFORMATION AND TRADE -* SECRETS OF HAL COMPUTER SYSTEMS INTERNATIONAL, LTD. USE, -* DISCLOSURE, OR REPRODUCTION IS PROHIBITED WITHOUT THE -* PRIOR EXPRESS WRITTEN PERMISSION OF HAL COMPUTER SYSTEMS -* INTERNATIONAL, LTD. -* -* RESTRICTED RIGHTS LEGEND -* Use, duplication, or disclosure by the Government is subject -* to the restrictions as set forth in subparagraph (c)(l)(ii) -* of the Rights in Technical Data and Computer Software clause -* at DFARS 252.227-7013. -* -* HAL COMPUTER SYSTEMS INTERNATIONAL, LTD. -* 1315 Dell Avenue -* Campbell, CA 95008 -* -*/ -# line 37 "sgml.l" - -#include "compression/trie.h" -#include "compression/abs_agent.h" - - -static unsigned char sgmlbuf[LBUFSIZ]; -static int sgmlbuf_sz = LBUFSIZ; -static int sgmlbuffed = 0; - - -#undef sgmlwrap -int sgmlwrap(); - -#undef sgml_INPUT -#define sgml_INPUT(buf,result,max_size) \ - { \ - result = (*fill_buf_func)((unsigned char*)buf,max_size); \ - } - - -# line 59 "sgml.l" - -/* done after the current pattern has been matched and before the - * corresponding action - sets up sgmltext - */ -#define sgml_DO_BEFORE_ACTION \ - sgmltext = sgml_bp; \ - sgmlleng = sgml_cp - sgml_bp; \ - sgml_hold_char = *sgml_cp; \ - *sgml_cp = '\0'; \ - sgml_c_buf_p = sgml_cp; - -#define EOB_ACT_CONTINUE_SCAN 0 -#define EOB_ACT_END_OF_FILE 1 -#define EOB_ACT_LAST_MATCH 2 - -/* return all but the first 'n' matched characters back to the input stream */ -#define sgmlless(n) \ - do \ - { \ - /* undo effects of setting up sgmltext */ \ - *sgml_cp = sgml_hold_char; \ - sgml_c_buf_p = sgml_cp = sgml_bp + n; \ - sgml_DO_BEFORE_ACTION; /* set up sgmltext again */ \ - } \ - while ( 0 ) - -#define unput(c) sgmlunput( c, sgmltext ) - - -struct sgml_buffer_state - { - FILE *sgml_input_file; - - sgml_CHAR *sgml_ch_buf; /* input buffer */ - sgml_CHAR *sgml_buf_pos; /* current position in input buffer */ - - /* size of input buffer in bytes, not including room for EOB characters*/ - int sgml_buf_size; - - /* number of characters read into sgml_ch_buf, not including EOB characters */ - int sgml_n_chars; - - int sgml_eof_status; /* whether we've seen an EOF on this buffer */ -#define EOF_NOT_SEEN 0 - /* "pending" happens when the EOF has been seen but there's still - * some text process - */ -#define EOF_PENDING 1 -#define EOF_DONE 2 - }; - -static sgml_BUFFER_STATE sgml_current_buffer; - -/* we provide macros for accessing buffer states in case in the - * future we want to put the buffer states in a more general - * "scanner state" - */ -#define sgml_CURRENT_BUFFER sgml_current_buffer - - -/* sgml_hold_char holds the character lost when sgmltext is formed */ -static sgml_CHAR sgml_hold_char; - -static int sgml_n_chars; /* number of characters read into sgml_ch_buf */ - - - -#ifndef sgml_USER_ACTION -#define sgml_USER_ACTION -#endif - -#ifndef sgml_USER_INIT -#define sgml_USER_INIT -#endif - -extern sgml_CHAR *sgmltext; -extern int sgmlleng; -extern FILE *sgmlin, *sgmlout; - -sgml_CHAR *sgmltext; -int sgmlleng; - -FILE *sgmlin = (FILE *) 0, *sgmlout = (FILE *) 0; - -#define sgml_END_OF_BUFFER 4 -typedef int sgml_state_type; -static const short int sgml_accept[11] = - { 0, - 0, 0, 4, 2, 2, 0, 0, 1, 0, 0 - } ; - -static const sgml_CHAR sgml_ec[256] = - { 0, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 3, 4, 3, 3, 3, - 3, 3, 3, 3, 3, 3, 3, 1, 1, 5, - 1, 6, 1, 1, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 1, 1, 1, 1, 3, 1, 3, 3, 3, 3, - - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1 - } ; - -static const sgml_CHAR sgml_meta[7] = - { 0, - 1, 1, 2, 1, 1, 1 - } ; - -static const short int sgml_base[13] = - { 0, - 7, 6, 7, 13, 0, 2, 0, 13, 0, 13, - 8, 0 - } ; - -static const short int sgml_def[13] = - { 0, - 11, 11, 10, 10, 10, 10, 12, 10, 12, 0, - 10, 10 - } ; - -static const short int sgml_nxt[20] = - { 0, - 10, 9, 6, 7, 6, 8, 10, 8, 4, 4, - 5, 5, 3, 10, 10, 10, 10, 10, 10 - } ; - -static const short int sgml_chk[20] = - { 0, - 0, 12, 5, 5, 6, 9, 3, 6, 11, 11, - 2, 1, 10, 10, 10, 10, 10, 10, 10 - } ; - -static sgml_state_type sgml_last_accepting_state; -static sgml_CHAR *sgml_last_accepting_cpos; - -/* the intent behind this definition is that it'll catch - * any uses of REJECT which flex missed - */ -#define REJECT reject_used_but_not_detected -#define sgmlmore() sgmlmore_used_but_not_detected -#define sgml_MORE_ADJ 0 - -/* these variables are all declared out here so that section 3 code can - * manipulate them - */ -/* points to current character in buffer */ -static sgml_CHAR *sgml_c_buf_p = (sgml_CHAR *) 0; -static int sgml_init = 1; /* whether we need to initialize */ -static int sgml_start = 0; /* start state number */ - -/* flag which is used to allow sgmlwrap()'s to do buffer switches - * instead of setting up a fresh sgmlin. A bit of a hack ... - */ -static int sgml_did_buffer_switch_on_eof; - -static sgml_state_type sgml_get_previous_state sgml_PROTO(( void )); -static sgml_state_type sgml_try_NUL_trans sgml_PROTO(( sgml_state_type current_state )); -static int sgml_get_next_buffer sgml_PROTO(( void )); -#if 0 -static void sgmlunput sgml_PROTO(( sgml_CHAR c, sgml_CHAR *buf_ptr )); -#endif -void sgmlrestart sgml_PROTO(( FILE *input_file )); -void sgml_switch_to_buffer sgml_PROTO(( sgml_BUFFER_STATE new_buffer )); -void sgml_load_buffer_state sgml_PROTO(( void )); -sgml_BUFFER_STATE sgml_create_buffer sgml_PROTO(( FILE *file, int size )); -void sgml_delete_buffer sgml_PROTO(( sgml_BUFFER_STATE b )); -void sgml_init_buffer sgml_PROTO(( sgml_BUFFER_STATE b, FILE *file )); - -#define sgml_new_buffer sgml_create_buffer - -#if 0 -#ifdef __cplusplus -static int sgmlinput sgml_PROTO(( void )); -#else -static int input sgml_PROTO(( void )); -#endif -#endif - -sgml_DECL - { - sgml_state_type sgml_current_state; - sgml_CHAR *sgml_cp, *sgml_bp; - int sgml_act; - - - - - if ( sgml_init ) - { - sgml_USER_INIT; - - if ( ! sgml_start ) - sgml_start = 1; /* first start state */ - - if ( ! sgmlin ) - sgmlin = stdin; - - if ( ! sgmlout ) - sgmlout = stdout; - - if ( sgml_current_buffer ) - sgml_init_buffer( sgml_current_buffer, sgmlin ); - else - sgml_current_buffer = sgml_create_buffer( sgmlin, sgml_BUF_SIZE ); - - sgml_load_buffer_state(); - - sgml_init = 0; - } - - while ( 1 ) /* loops until end-of-file is reached */ - { - sgml_cp = sgml_c_buf_p; - - /* support of sgmltext */ - *sgml_cp = sgml_hold_char; - - /* sgml_bp points to the position in sgml_ch_buf of the start of the - * current run. - */ - sgml_bp = sgml_cp; - - sgml_current_state = sgml_start; -sgml_match: - do - { - sgml_CHAR sgml_c = sgml_ec[*sgml_cp]; - if ( sgml_accept[sgml_current_state] ) - { - sgml_last_accepting_state = sgml_current_state; - sgml_last_accepting_cpos = sgml_cp; - } - while ( sgml_chk[sgml_base[sgml_current_state] + sgml_c] != sgml_current_state ) - { - sgml_current_state = sgml_def[sgml_current_state]; - if ( sgml_current_state >= 11 ) - sgml_c = sgml_meta[sgml_c]; - } - sgml_current_state = sgml_nxt[sgml_base[sgml_current_state] + sgml_c]; - ++sgml_cp; - } - while ( sgml_current_state != 10 ); - sgml_cp = sgml_last_accepting_cpos; - sgml_current_state = sgml_last_accepting_state; - -sgml_find_action: - sgml_act = sgml_accept[sgml_current_state]; - - sgml_DO_BEFORE_ACTION; - sgml_USER_ACTION; - -do_action: /* this label is used only to access EOF actions */ - - - switch ( sgml_act ) - { - case 0: /* must backtrack */ - /* undo the effects of sgml_DO_BEFORE_ACTION */ - *sgml_cp = sgml_hold_char; - sgml_cp = sgml_last_accepting_cpos; - sgml_current_state = sgml_last_accepting_state; - goto sgml_find_action; - -case 1: -# line 61 "sgml.l" -{ - (*lex_action_func)((unsigned char*)(sgmltext), sgmlleng, 1); - } - sgml_BREAK -case 2: -# line 65 "sgml.l" -{ - if ( sgmlbuffed >= sgmlbuf_sz ) { - (*lex_action_func)(sgmlbuf, sgmlbuf_sz, 2); - sgmlbuffed = 0; - } - - sgmlbuf[sgmlbuffed++] = sgmltext[0]; - } - sgml_BREAK -case 3: -# line 75 "sgml.l" -sgml_FATAL_ERROR( "flex scanner jammed" ); - sgml_BREAK -case sgml_STATE_EOF(INITIAL): - sgmlterminate(); - - case sgml_END_OF_BUFFER: - { - /* amount of text matched not including the EOB char */ - int sgml_amount_of_matched_text = sgml_cp - sgmltext - 1; - - /* undo the effects of sgml_DO_BEFORE_ACTION */ - *sgml_cp = sgml_hold_char; - - /* note that here we test for sgml_c_buf_p "<=" to the position - * of the first EOB in the buffer, since sgml_c_buf_p will - * already have been incremented past the NUL character - * (since all states make transitions on EOB to the end- - * of-buffer state). Contrast this with the test in sgmlinput(). - */ - if ( sgml_c_buf_p <= &sgml_current_buffer->sgml_ch_buf[sgml_n_chars] ) - /* this was really a NUL */ - { - sgml_state_type sgml_next_state; - - sgml_c_buf_p = sgmltext + sgml_amount_of_matched_text; - - sgml_current_state = sgml_get_previous_state(); - - /* okay, we're now positioned to make the - * NUL transition. We couldn't have - * sgml_get_previous_state() go ahead and do it - * for us because it doesn't know how to deal - * with the possibility of jamming (and we - * don't want to build jamming into it because - * then it will run more slowly) - */ - - sgml_next_state = sgml_try_NUL_trans( sgml_current_state ); - - sgml_bp = sgmltext + sgml_MORE_ADJ; - - if ( sgml_next_state ) - { - /* consume the NUL */ - sgml_cp = ++sgml_c_buf_p; - sgml_current_state = sgml_next_state; - goto sgml_match; - } - - else - { - sgml_cp = sgml_last_accepting_cpos; - sgml_current_state = sgml_last_accepting_state; - goto sgml_find_action; - } - } - - else switch ( sgml_get_next_buffer() ) - { - case EOB_ACT_END_OF_FILE: - { - sgml_did_buffer_switch_on_eof = 0; - - if ( sgmlwrap() ) - { - /* note: because we've taken care in - * sgml_get_next_buffer() to have set up sgmltext, - * we can now set up sgml_c_buf_p so that if some - * total hoser (like flex itself) wants - * to call the scanner after we return the - * sgml_NULL, it'll still work - another sgml_NULL - * will get returned. - */ - sgml_c_buf_p = sgmltext + sgml_MORE_ADJ; - - sgml_act = sgml_STATE_EOF((sgml_start - 1) / 2); - goto do_action; - } - - else - { - if ( ! sgml_did_buffer_switch_on_eof ) - sgml_NEW_FILE; - } - } - break; - - case EOB_ACT_CONTINUE_SCAN: - sgml_c_buf_p = sgmltext + sgml_amount_of_matched_text; - - sgml_current_state = sgml_get_previous_state(); - - sgml_cp = sgml_c_buf_p; - sgml_bp = sgmltext + sgml_MORE_ADJ; - goto sgml_match; - - case EOB_ACT_LAST_MATCH: - sgml_c_buf_p = - &sgml_current_buffer->sgml_ch_buf[sgml_n_chars]; - - sgml_current_state = sgml_get_previous_state(); - - sgml_cp = sgml_c_buf_p; - sgml_bp = sgmltext + sgml_MORE_ADJ; - goto sgml_find_action; - } - break; - } - - default: -#ifdef FLEX_DEBUG - printf( "action # %d\n", sgml_act ); -#endif - sgml_FATAL_ERROR( - "fatal flex scanner internal error--no action found" ); - } - } - } - - -/* sgml_get_next_buffer - try to read in a new buffer - * - * synopsis - * int sgml_get_next_buffer(); - * - * returns a code representing an action - * EOB_ACT_LAST_MATCH - - * EOB_ACT_CONTINUE_SCAN - continue scanning from current position - * EOB_ACT_END_OF_FILE - end of file - */ - -static int sgml_get_next_buffer() - - { - sgml_CHAR *dest = sgml_current_buffer->sgml_ch_buf; - sgml_CHAR *source = sgmltext - 1; /* copy prev. char, too */ - int number_to_move, i; - int ret_val; - - if ( sgml_c_buf_p > &sgml_current_buffer->sgml_ch_buf[sgml_n_chars + 1] ) - sgml_FATAL_ERROR( - "fatal flex scanner internal error--end of buffer missed" ); - - /* try to read more data */ - - /* first move last chars to start of buffer */ - number_to_move = sgml_c_buf_p - sgmltext; - - for ( i = 0; i < number_to_move; ++i ) - *(dest++) = *(source++); - - if ( sgml_current_buffer->sgml_eof_status != EOF_NOT_SEEN ) - /* don't do the read, it's not guaranteed to return an EOF, - * just force an EOF - */ - sgml_n_chars = 0; - - else - { - int num_to_read = sgml_current_buffer->sgml_buf_size - number_to_move - 1; - - if ( num_to_read > sgml_READ_BUF_SIZE ) - num_to_read = sgml_READ_BUF_SIZE; - - else if ( num_to_read <= 0 ) - sgml_FATAL_ERROR( "fatal error - scanner input buffer overflow" ); - - /* read in more data */ - sgml_INPUT( (&sgml_current_buffer->sgml_ch_buf[number_to_move]), - sgml_n_chars, num_to_read ); - } - - if ( sgml_n_chars == 0 ) - { - if ( number_to_move == 1 ) - { - ret_val = EOB_ACT_END_OF_FILE; - sgml_current_buffer->sgml_eof_status = EOF_DONE; - } - - else - { - ret_val = EOB_ACT_LAST_MATCH; - sgml_current_buffer->sgml_eof_status = EOF_PENDING; - } - } - - else - ret_val = EOB_ACT_CONTINUE_SCAN; - - sgml_n_chars += number_to_move; - sgml_current_buffer->sgml_ch_buf[sgml_n_chars] = sgml_END_OF_BUFFER_CHAR; - sgml_current_buffer->sgml_ch_buf[sgml_n_chars + 1] = sgml_END_OF_BUFFER_CHAR; - - /* sgmltext begins at the second character in sgml_ch_buf; the first - * character is the one which preceded it before reading in the latest - * buffer; it needs to be kept around in case it's a newline, so - * sgml_get_previous_state() will have with '^' rules active - */ - - sgmltext = &sgml_current_buffer->sgml_ch_buf[1]; - - return ( ret_val ); - } - - -/* sgml_get_previous_state - get the state just before the EOB char was reached - * - * synopsis - * sgml_state_type sgml_get_previous_state(); - */ - -static sgml_state_type sgml_get_previous_state() - - { - sgml_state_type sgml_current_state; - sgml_CHAR *sgml_cp; - - sgml_current_state = sgml_start; - - for ( sgml_cp = sgmltext + sgml_MORE_ADJ; sgml_cp < sgml_c_buf_p; ++sgml_cp ) - { - sgml_CHAR sgml_c = (*sgml_cp ? sgml_ec[*sgml_cp] : 1); - if ( sgml_accept[sgml_current_state] ) - { - sgml_last_accepting_state = sgml_current_state; - sgml_last_accepting_cpos = sgml_cp; - } - while ( sgml_chk[sgml_base[sgml_current_state] + sgml_c] != sgml_current_state ) - { - sgml_current_state = sgml_def[sgml_current_state]; - if ( sgml_current_state >= 11 ) - sgml_c = sgml_meta[sgml_c]; - } - sgml_current_state = sgml_nxt[sgml_base[sgml_current_state] + sgml_c]; - } - - return ( sgml_current_state ); - } - - -/* sgml_try_NUL_trans - try to make a transition on the NUL character - * - * synopsis - * next_state = sgml_try_NUL_trans( current_state ); - */ - -#ifdef sgml_USE_PROTOS -static sgml_state_type sgml_try_NUL_trans( sgml_state_type sgml_current_state ) -#else -static sgml_state_type sgml_try_NUL_trans( sgml_current_state ) -sgml_state_type sgml_current_state; -#endif - - { - int sgml_is_jam; - sgml_CHAR *sgml_cp = sgml_c_buf_p; - - sgml_CHAR sgml_c = 1; - if ( sgml_accept[sgml_current_state] ) - { - sgml_last_accepting_state = sgml_current_state; - sgml_last_accepting_cpos = sgml_cp; - } - while ( sgml_chk[sgml_base[sgml_current_state] + sgml_c] != sgml_current_state ) - { - sgml_current_state = sgml_def[sgml_current_state]; - if ( sgml_current_state >= 11 ) - sgml_c = sgml_meta[sgml_c]; - } - sgml_current_state = sgml_nxt[sgml_base[sgml_current_state] + sgml_c]; - sgml_is_jam = (sgml_current_state == 10); - - return ( sgml_is_jam ? 0 : sgml_current_state ); - } - - -#if 0 -#ifdef sgml_USE_PROTOS -static void sgmlunput( sgml_CHAR c, sgml_CHAR *sgml_bp ) -#else -static void sgmlunput( c, sgml_bp ) -sgml_CHAR c; -sgml_CHAR *sgml_bp; -#endif - - { - sgml_CHAR *sgml_cp = sgml_c_buf_p; - - /* undo effects of setting up sgmltext */ - *sgml_cp = sgml_hold_char; - - if ( sgml_cp < sgml_current_buffer->sgml_ch_buf + 2 ) - { /* need to shift things up to make room */ - int number_to_move = sgml_n_chars + 2; /* +2 for EOB chars */ - sgml_CHAR *dest = - &sgml_current_buffer->sgml_ch_buf[sgml_current_buffer->sgml_buf_size + 2]; - sgml_CHAR *source = - &sgml_current_buffer->sgml_ch_buf[number_to_move]; - - while ( source > sgml_current_buffer->sgml_ch_buf ) - *--dest = *--source; - - sgml_cp += dest - source; - sgml_bp += dest - source; - sgml_n_chars = sgml_current_buffer->sgml_buf_size; - - if ( sgml_cp < sgml_current_buffer->sgml_ch_buf + 2 ) - sgml_FATAL_ERROR( "flex scanner push-back overflow" ); - } - - if ( sgml_cp > sgml_bp && sgml_cp[-1] == '\n' ) - sgml_cp[-2] = '\n'; - - *--sgml_cp = c; - - /* note: the formal parameter *must* be called "sgml_bp" for this - * macro to now work correctly - */ - sgml_DO_BEFORE_ACTION; /* set up sgmltext again */ - } -#endif - - -#if 0 -#ifdef __cplusplus -static int sgmlinput() -#else -static int input() -#endif - - { - int c; - sgml_CHAR *sgml_cp = sgml_c_buf_p; - - *sgml_cp = sgml_hold_char; - - if ( *sgml_c_buf_p == sgml_END_OF_BUFFER_CHAR ) - { - /* sgml_c_buf_p now points to the character we want to return. - * If this occurs *before* the EOB characters, then it's a - * valid NUL; if not, then we've hit the end of the buffer. - */ - if ( sgml_c_buf_p < &sgml_current_buffer->sgml_ch_buf[sgml_n_chars] ) - /* this was really a NUL */ - *sgml_c_buf_p = '\0'; - - else - { /* need more input */ - sgmltext = sgml_c_buf_p; - ++sgml_c_buf_p; - - switch ( sgml_get_next_buffer() ) - { - case EOB_ACT_END_OF_FILE: - { - if ( sgmlwrap() ) - { - sgml_c_buf_p = sgmltext + sgml_MORE_ADJ; - return ( EOF ); - } - - sgml_NEW_FILE; - -#ifdef __cplusplus - return ( sgmlinput() ); -#else - return ( input() ); -#endif - } - break; - - case EOB_ACT_CONTINUE_SCAN: - sgml_c_buf_p = sgmltext + sgml_MORE_ADJ; - break; - - case EOB_ACT_LAST_MATCH: -#ifdef __cplusplus - sgml_FATAL_ERROR( "unexpected last match in sgmlinput()" ); -#else - sgml_FATAL_ERROR( "unexpected last match in input()" ); -#endif - } - } - } - - c = *sgml_c_buf_p; - sgml_hold_char = *++sgml_c_buf_p; - - return ( c ); - } -#endif - - -#ifdef sgml_USE_PROTOS -void sgmlrestart( FILE *input_file ) -#else -void sgmlrestart( input_file ) -FILE *input_file; -#endif - - { - sgml_init_buffer( sgml_current_buffer, input_file ); - sgml_load_buffer_state(); - } - - -#ifdef sgml_USE_PROTOS -void sgml_switch_to_buffer( sgml_BUFFER_STATE new_buffer ) -#else -void sgml_switch_to_buffer( new_buffer ) -sgml_BUFFER_STATE new_buffer; -#endif - - { - if ( sgml_current_buffer == new_buffer ) - return; - - if ( sgml_current_buffer ) - { - /* flush out information for old buffer */ - *sgml_c_buf_p = sgml_hold_char; - sgml_current_buffer->sgml_buf_pos = sgml_c_buf_p; - sgml_current_buffer->sgml_n_chars = sgml_n_chars; - } - - sgml_current_buffer = new_buffer; - sgml_load_buffer_state(); - - /* we don't actually know whether we did this switch during - * EOF (sgmlwrap()) processing, but the only time this flag - * is looked at is after sgmlwrap() is called, so it's safe - * to go ahead and always set it. - */ - sgml_did_buffer_switch_on_eof = 1; - } - - -#ifdef sgml_USE_PROTOS -void sgml_load_buffer_state( void ) -#else -void sgml_load_buffer_state() -#endif - - { - sgml_n_chars = sgml_current_buffer->sgml_n_chars; - sgmltext = sgml_c_buf_p = sgml_current_buffer->sgml_buf_pos; - sgmlin = sgml_current_buffer->sgml_input_file; - sgml_hold_char = *sgml_c_buf_p; - } - - -#ifdef sgml_USE_PROTOS -sgml_BUFFER_STATE sgml_create_buffer( FILE *file, int size ) -#else -sgml_BUFFER_STATE sgml_create_buffer( file, size ) -FILE *file; -int size; -#endif - - { - sgml_BUFFER_STATE b; - - b = (sgml_BUFFER_STATE) malloc( sizeof( struct sgml_buffer_state ) ); - - if ( ! b ) - sgml_FATAL_ERROR( "out of dynamic memory in sgml_create_buffer()" ); - - b->sgml_buf_size = size; - - /* sgml_ch_buf has to be 2 characters longer than the size given because - * we need to put in 2 end-of-buffer characters. - */ - b->sgml_ch_buf = (sgml_CHAR *) malloc( (unsigned) (b->sgml_buf_size + 2) ); - - if ( ! b->sgml_ch_buf ) - sgml_FATAL_ERROR( "out of dynamic memory in sgml_create_buffer()" ); - - sgml_init_buffer( b, file ); - - return ( b ); - } - - -#ifdef sgml_USE_PROTOS -void sgml_delete_buffer( sgml_BUFFER_STATE b ) -#else -void sgml_delete_buffer( b ) -sgml_BUFFER_STATE b; -#endif - - { - if ( b == sgml_current_buffer ) - sgml_current_buffer = (sgml_BUFFER_STATE) 0; - - free( (char *) b->sgml_ch_buf ); - free( (char *) b ); - } - - -#ifdef sgml_USE_PROTOS -void sgml_init_buffer( sgml_BUFFER_STATE b, FILE *file ) -#else -void sgml_init_buffer( b, file ) -sgml_BUFFER_STATE b; -FILE *file; -#endif - - { - b->sgml_input_file = file; - - /* we put in the '\n' and start reading from [1] so that an - * initial match-at-newline will be true. - */ - - b->sgml_ch_buf[0] = '\n'; - b->sgml_n_chars = 1; - - /* we always need two end-of-buffer characters. The first causes - * a transition to the end-of-buffer state. The second causes - * a jam in that state. - */ - b->sgml_ch_buf[1] = sgml_END_OF_BUFFER_CHAR; - b->sgml_ch_buf[2] = sgml_END_OF_BUFFER_CHAR; - - b->sgml_buf_pos = &b->sgml_ch_buf[1]; - - b->sgml_eof_status = EOF_NOT_SEEN; - } -# line 75 "sgml.l" - - -int sgmlwrap() -{ - (*lex_action_func)(sgmlbuf, sgmlbuffed, 2); - return 1; -} - diff --git a/cde/programs/dtinfo/DtMmdb/compression/sgml.lex b/cde/programs/dtinfo/DtMmdb/compression/sgml.ll similarity index 97% rename from cde/programs/dtinfo/DtMmdb/compression/sgml.lex rename to cde/programs/dtinfo/DtMmdb/compression/sgml.ll index ab9b23062..50756e422 100644 --- a/cde/programs/dtinfo/DtMmdb/compression/sgml.lex +++ b/cde/programs/dtinfo/DtMmdb/compression/sgml.ll @@ -43,10 +43,6 @@ static unsigned char yybuf[LBUFSIZ]; static int yybuf_sz = LBUFSIZ; static int yybuffed = 0; - -#undef yywrap -int yywrap(); - #undef YY_INPUT #define YY_INPUT(buf,result,max_size) \ { \