Disable all code related to libXp
[oweals/cde.git] / cde / programs / dtinfo / DtMmdb / StyleSheet / tokenStyle.C
1 /*
2  * CDE - Common Desktop Environment
3  *
4  * Copyright (c) 1993-2012, The Open Group. All rights reserved.
5  *
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)
10  * any later version.
11  *
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
16  * details.
17  *
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
22  */
23 /* A lexical scanner generated by flex */
24
25 /* scanner skeleton version:
26  * $TOG: tokenStyle.C /main/6 1998/04/17 11:52:06 mgreess $
27  */
28
29 #define FLEX_SCANNER
30
31 #include <stdio.h>
32
33
34 /* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */
35 #ifdef c_plusplus
36 #ifndef __cplusplus
37 #define __cplusplus
38 #endif
39 #endif
40
41
42 #ifdef __cplusplus
43
44 #include <stdlib.h>
45
46 #if !defined(__osf__) && !defined(USL) && !defined(linux) && \
47     !defined(CSRG_BASED) && !defined(sun)
48 #include <osfcn.h>
49 #endif
50
51 /* use prototypes in function declarations */
52 #define style_USE_PROTOS
53
54 /* the "const" storage-class-modifier is valid */
55 #define style_USE_CONST
56
57 #else   /* ! __cplusplus */
58
59 #ifdef __STDC__
60
61 #ifdef __GNUC__
62 #include <stddef.h>
63 void *malloc( size_t );
64 void free( void* );
65 #else
66 #include <stdlib.h>
67 #endif  /* __GNUC__ */
68
69 #define style_USE_PROTOS
70 #define style_USE_CONST
71
72 #endif  /* __STDC__ */
73 #endif  /* ! __cplusplus */
74
75
76 #ifdef __TURBOC__
77 #define style_USE_CONST
78 #endif
79
80
81 #ifndef style_USE_CONST
82 #define const
83 #endif
84
85
86 #ifdef style_USE_PROTOS
87 #define style_PROTO(proto) proto
88 #else
89 #define style_PROTO(proto) ()
90 /* we can't get here if it's an ANSI C compiler, or a C++ compiler,
91  * so it's got to be a K&R compiler, and therefore there's no standard
92  * place from which to include these definitions
93  */
94 char *malloc();
95 int free();
96 int read();
97 #endif
98
99
100 /* amount of stuff to slurp up with each read */
101 #ifndef style_READ_BUF_SIZE
102 #define style_READ_BUF_SIZE 8192
103 #endif
104
105 /* returned upon end-of-file */
106 #define style_END_TOK 0
107
108 /* copy whatever the last rule matched to the standard output */
109
110 /* cast to (char *) is because for 8-bit chars, styletext is (unsigned char *) */
111 /* this used to be an fputs(), but since the string might contain NUL's,
112  * we now use fwrite()
113  */
114 #define ECHO (void) fwrite( (char *) styletext, styleleng, 1, styleout )
115
116 /* gets input and stuffs it into "buf".  number of characters read, or style_NULL,
117  * is returned in "result".
118  */
119 #define style_INPUT(buf,result,max_size) \
120         if ( (result = read( fileno(stylein), (char *) buf, max_size )) < 0 ) \
121             style_FATAL_ERROR( "read() in flex scanner failed" );
122 #define style_NULL 0
123
124 /* no semi-colon after return; correct usage is to write "styleterminate();" -
125  * we don't want an extra ';' after the "return" because that will cause
126  * some compilers to complain about unreachable statements.
127  */
128 #define styleterminate() return ( style_NULL )
129
130 /* report a fatal error */
131
132 /* The funky do-while is used to turn this macro definition into
133  * a single C statement (which needs a semi-colon terminator).
134  * This avoids problems with code like:
135  *
136  *      if ( something_happens )
137  *              style_FATAL_ERROR( "oops, the something happened" );
138  *      else
139  *              everything_okay();
140  *
141  * Prior to using the do-while the compiler would get upset at the
142  * "else" because it interpreted the "if" statement as being all
143  * done when it reached the ';' after the style_FATAL_ERROR() call.
144  */
145
146 #define style_FATAL_ERROR(msg) \
147         do \
148                 { \
149                 (void) fputs( msg, stderr ); \
150                 (void) putc( '\n', stderr ); \
151                 exit( 1 ); \
152                 } \
153         while ( 0 )
154
155 /* default stylewrap function - always treat EOF as an EOF */
156 #define stylewrap() 1
157
158 /* enter a start condition.  This macro really ought to take a parameter,
159  * but we do it the disgusting crufty way forced on us by the ()-less
160  * definition of BEGIN
161  */
162 #define BEGIN style_start = 1 + 2 *
163
164 /* action number for EOF rule of a given start state */
165 #define style_STATE_EOF(state) (style_END_OF_BUFFER + state + 1)
166
167 /* special action meaning "start processing a new file" */
168 #define style_NEW_FILE \
169         do \
170                 { \
171                 style_init_buffer( style_current_buffer, stylein ); \
172                 style_load_buffer_state(); \
173                 } \
174         while ( 0 )
175
176 /* default declaration of generated scanner - a define so the user can
177  * easily add parameters
178  */
179 #define style_DECL int stylelex style_PROTO(( void )) 
180
181 /* code executed at the end of each rule */
182 #define style_BREAK break;
183
184 #define style_END_OF_BUFFER_CHAR 0
185
186 #ifndef style_BUF_SIZE
187 #define style_BUF_SIZE (style_READ_BUF_SIZE * 2) /* size of default input buffer */
188 #endif
189
190 typedef struct style_buffer_state *style_BUFFER_STATE;
191
192 #define style_CHAR unsigned char
193 # line 1 "tokenStyle.l"
194 #define INITIAL 0
195 /*
196 * $TOG: tokenStyle.C /main/6 1998/04/17 11:52:06 mgreess $
197 *
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
202 * OR DISCLOSURE.
203
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.
209
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.
215 *
216 *          HAL COMPUTER SYSTEMS INTERNATIONAL, LTD.
217 *                  1315 Dell Avenue
218 *                  Campbell, CA  95008
219
220 */
221 # line 37 "tokenStyle.l"
222 #include <string.h>
223 #include "ParserConst.h"
224 #include "Expression.h"
225 #include "FeatureValue.h"
226 #include "PathTable.h"
227 #include "SSPath.h"
228 #include "PathQualifier.h"
229 #include "StyleSheetExceptions.h"
230 #include "style.tab.h"
231 #include "Debug.h"
232 #include <iostream>
233 using namespace std;
234
235 istream *g_stylein = 0;
236
237 #undef style_INPUT
238 #define style_INPUT(buf,result,max_size)\
239   {\
240      if (g_stylein -> eof()) {\
241         result=0;\
242      } else {\
243         g_stylein -> read((char*)buf, max_size-1); \
244         result = g_stylein -> gcount(); \
245         buf[result] = 0; \
246      }\
247   }
248
249 unsigned char* qstring_buf = new unsigned char[1024];
250 int qstring_buf_size = 1024;
251 int qstring_buf_content_size = 0;
252
253 char* commentBuffer = new char [1024];
254 int commentBufferSize = 1024;
255 int commentBufferContentSize = 0;
256
257 int stylelineno=1;
258                 
259 void addToQstringBuf(const unsigned char* str, int size)
260 {
261    if ( size <= 0 ) return;
262
263    if ( qstring_buf_size - qstring_buf_content_size < size ) {
264       qstring_buf_size = 2*(size+qstring_buf_content_size);
265       unsigned char* x = new unsigned char[qstring_buf_size];
266       memcpy(x, qstring_buf, qstring_buf_content_size);
267       delete qstring_buf;
268       qstring_buf = x;
269    }
270
271    memcpy(qstring_buf + qstring_buf_content_size, str, size);
272    qstring_buf_content_size += size;
273    qstring_buf[qstring_buf_content_size] = 0;
274 }
275
276
277 #define block 1
278 #define sgmlgimode 2
279 #define quoted_string 3
280 # line 95 "tokenStyle.l"
281
282 /* done after the current pattern has been matched and before the
283  * corresponding action - sets up styletext
284  */
285 #define style_DO_BEFORE_ACTION \
286         styletext = style_bp; \
287         styleleng = style_cp - style_bp; \
288         style_hold_char = *style_cp; \
289         *style_cp = '\0'; \
290         style_c_buf_p = style_cp;
291
292 #define EOB_ACT_CONTINUE_SCAN 0
293 #define EOB_ACT_END_OF_FILE 1
294 #define EOB_ACT_LAST_MATCH 2
295
296 /* return all but the first 'n' matched characters back to the input stream */
297 #define styleless(n) \
298         do \
299                 { \
300                 /* undo effects of setting up styletext */ \
301                 *style_cp = style_hold_char; \
302                 style_c_buf_p = style_cp = style_bp + n; \
303                 style_DO_BEFORE_ACTION; /* set up styletext again */ \
304                 } \
305         while ( 0 )
306
307 #define unput(c) styleunput( c, styletext )
308
309
310 struct style_buffer_state
311     {
312     FILE *style_input_file;
313
314     style_CHAR *style_ch_buf;           /* input buffer */
315     style_CHAR *style_buf_pos;  /* current position in input buffer */
316
317     /* size of input buffer in bytes, not including room for EOB characters*/
318     int style_buf_size; 
319
320     /* number of characters read into style_ch_buf, not including EOB characters */
321     int style_n_chars;
322
323     int style_eof_status;               /* whether we've seen an EOF on this buffer */
324 #define EOF_NOT_SEEN 0
325     /* "pending" happens when the EOF has been seen but there's still
326      * some text process
327      */
328 #define EOF_PENDING 1
329 #define EOF_DONE 2
330     };
331
332 static style_BUFFER_STATE style_current_buffer;
333
334 /* we provide macros for accessing buffer states in case in the
335  * future we want to put the buffer states in a more general
336  * "scanner state"
337  */
338 #define style_CURRENT_BUFFER style_current_buffer
339
340
341 /* style_hold_char holds the character lost when styletext is formed */
342 static style_CHAR style_hold_char;
343
344 static int style_n_chars;               /* number of characters read into style_ch_buf */
345
346
347
348 #ifndef style_USER_ACTION
349 #define style_USER_ACTION
350 #endif
351
352 #ifndef style_USER_INIT
353 #define style_USER_INIT
354 #endif
355
356 extern style_CHAR *styletext;
357 extern int styleleng;
358 extern FILE *stylein, *styleout;
359
360 style_CHAR *styletext;
361 int styleleng;
362
363 FILE *stylein = (FILE *) 0, *styleout = (FILE *) 0;
364
365 #define style_END_OF_BUFFER 48
366 typedef int style_state_type;
367 static const short int style_accept[134] =
368     {   0,
369         0,    0,    0,    0,    0,    0,   36,   36,   48,   39,
370        41,   42,   43,   23,   33,   39,   39,   18,   19,    9,
371         5,   13,    6,    8,    7,   31,   10,   24,    3,   24,
372        11,    4,   39,   39,   39,   39,   39,   39,   39,   16,
373        17,   12,   39,   39,   14,   39,   15,    2,   45,   46,
374        45,   47,   40,   36,   36,   34,   35,   39,   22,    1,
375        21,    0,   31,   39,   39,   39,   24,   38,   39,   39,
376        38,   39,   28,   39,   39,   39,   20,    2,    2,    1,
377        44,   40,   36,   32,   30,   30,   39,   39,   39,   39,
378        39,   29,   39,   39,   39,   39,    0,    0,    0,   39,
379
380        39,   39,   39,   39,   39,   39,   39,   26,   30,   30,
381         0,    0,   39,   39,   27,   39,    0,    0,    0,    0,
382        39,    0,    0,   39,   39,   39,   39,   39,   39,   39,
383        39,   25,    0
384     } ;
385
386 static const style_CHAR style_ec[256] =
387     {   0,
388         1,    1,    1,    1,    1,    1,    1,    1,    2,    3,
389         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
390         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
391         1,    4,    5,    6,    7,    1,    1,    8,    1,    9,
392        10,   11,   12,   13,   14,   15,   16,   17,   17,   17,
393        17,   17,   17,   17,   17,   17,   17,   18,    1,   19,
394        20,   21,   22,   23,   24,   25,   26,   25,   27,   28,
395        29,   30,   31,   25,   25,   32,   33,   34,   35,   36,
396        25,   37,   38,   39,   40,   25,   25,   41,   25,   25,
397        42,   43,   44,   45,    1,    1,   46,   25,   47,   25,
398
399        48,   28,   25,   30,   49,   25,   25,   32,   33,   50,
400        51,   36,   25,   37,   52,   53,   40,   54,   25,   41,
401        25,   25,   55,   56,   57,    1,    1,    1,    1,    1,
402         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
403         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
404         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
405         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
406         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
407         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
408         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
409
410         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
411         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
412         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
413         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
414         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
415         1,    1,    1,    1,    1
416     } ;
417
418 static const style_CHAR style_meta[58] =
419     {   0,
420         1,    2,    3,    2,    2,    4,    1,    1,    2,    2,
421         2,    2,    2,    5,    6,    2,    5,    2,    1,    2,
422         1,    2,    2,    5,    5,    5,    5,    5,    5,    5,
423         5,    5,    5,    5,    5,    5,    5,    5,    5,    5,
424         5,    2,    7,    2,    2,    5,    5,    5,    5,    5,
425         5,    5,    5,    5,    2,    1,    2
426     } ;
427
428 static const short int style_base[141] =
429     {   0,
430         0,  341,   55,   56,  112,    0,   57,   58,  347,    0,
431       349,  349,  349,  326,  349,  289,  336,  349,  349,  349,
432       349,  349,    0,  349,  349,   50,  349,  323,  322,  321,
433       349,  349,  303,   38,  300,   32,   40,   57,  284,  349,
434       349,  349,   35,  289,  349,  259,  349,  168,  349,  349,
435       307,  349,    0,    0,    0,  349,  349,    0,  349,    0,
436         0,  296,  170,  262,   37,  169,  349,    0,  262,  267,
437        44,  264,    0,  156,   44,  251,    0,  224,    0,    0,
438       349,    0,    0,  224,    0,   47,  168,   46,   51,  244,
439       259,    0,   56,  144,  155,  166,  255,  177,  223,  257,
440
441       152,  204,  198,  211,  234,  253,  168,    0,  349,  217,
442       237,  226,  250,  212,    0,  213,  223,  221,  229,  246,
443       164,  167,  244,  127,   59,   55,   56,   45,   30,   24,
444        24,    0,  349,  297,  304,  311,  318,  321,  327,  333
445     } ;
446
447 static const short int style_def[141] =
448     {   0,
449       133,    1,  134,  134,  133,    5,  135,  135,  133,  136,
450       133,  133,  133,  133,  133,  136,  136,  133,  133,  133,
451       133,  133,  136,  133,  133,  136,  133,  136,  133,  136,
452       133,  133,  136,  136,  136,  136,  136,  136,  136,  133,
453       133,  133,  136,  136,  133,  136,  133,  137,  133,  133,
454       133,  133,  138,  139,  139,  133,  133,  136,  133,  136,
455       136,  133,  136,  136,  136,  136,  133,  136,  136,  136,
456       136,  136,  136,  136,  136,  136,  136,  137,  140,   78,
457       133,  138,  139,  133,  136,  136,  136,  136,  136,  136,
458       136,  136,  136,  136,  136,  136,  133,  133,  133,  136,
459
460       136,  136,  136,  136,  136,  136,  136,  136,  133,  133,
461       133,  133,  136,  136,  136,  136,  133,  133,  133,  133,
462       136,  133,  133,  136,  136,  136,  136,  136,  136,  136,
463       136,  136,    0,  133,  133,  133,  133,  133,  133,  133
464     } ;
465
466 static const short int style_nxt[407] =
467     {   0,
468        10,   11,   12,   13,   14,   15,   16,   17,   18,   19,
469        20,   21,   22,   23,   24,   25,   26,   27,   28,   29,
470        30,   31,   32,   10,   10,   33,   10,   34,   35,   10,
471        36,   10,   10,   10,   37,   38,   10,   10,   39,   10,
472        10,   40,   10,   41,   42,   10,   33,   10,   36,   43,
473        44,   10,   39,   10,   45,   46,   47,   50,   50,   55,
474        55,   69,   56,   56,   62,   71,   63,   72,   73,   91,
475        86,  132,  100,   73,   95,   64,  103,  131,  130,   68,
476        65,   71,   68,   69,   73,   66,   86,   74,  104,   73,
477        91,   75,   95,  100,  103,   68,   64,  129,   65,   57,
478
479        57,   68,  104,   68,  128,   74,  127,   75,  126,   68,
480        51,   51,   52,   52,   52,   52,   52,   52,   52,   52,
481        52,   52,   52,   52,   52,   53,   53,   52,   53,   52,
482        52,   52,   52,   52,   52,   53,   53,   53,   53,   53,
483        53,   53,   53,   53,   53,   53,   53,   53,   53,   53,
484        53,   53,   53,   52,   52,   52,   52,   53,   53,   53,
485        53,   53,   53,   53,   53,   53,   52,   52,   52,   79,
486       106,   79,   79,   79,  125,   85,   79,   79,   79,   79,
487        79,   93,   79,   79,   62,   79,   63,   79,  107,   79,
488        79,  106,  108,  101,   85,   64,   94,   85,  109,   87,
489
490        65,  124,   93,   88,  107,   66,   68,   85,  102,   79,
491       110,   79,   79,  108,  101,   85,   64,   87,   65,   88,
492        68,   85,   79,   80,   79,   79,  110,   79,   79,   79,
493       113,  114,   79,   79,   79,   79,   79,  115,   79,   79,
494        84,   79,  117,   79,  109,   79,   79,  114,  109,   97,
495        85,  113,  109,  111,   98,  122,  120,  112,  115,   99,
496       121,  109,  118,  117,   85,   79,  109,   79,   79,  109,
497        97,  111,   98,  112,  120,  109,  122,  119,   79,  123,
498        79,   85,  109,  118,   68,  116,   85,  109,   68,  105,
499        96,   92,   90,   89,   85,  123,  109,   49,   49,   49,
500
501        49,   49,   49,   49,   54,   54,   54,   54,   54,   54,
502        54,   58,   84,   81,   77,   58,   72,   58,   78,   78,
503        76,   78,   78,   78,   78,   82,   82,   83,   83,   83,
504        70,   83,   83,   79,   79,   68,   79,   79,   79,   79,
505        67,   59,   67,   61,   60,   59,  133,   48,    9,  133,
506       133,  133,  133,  133,  133,  133,  133,  133,  133,  133,
507       133,  133,  133,  133,  133,  133,  133,  133,  133,  133,
508       133,  133,  133,  133,  133,  133,  133,  133,  133,  133,
509       133,  133,  133,  133,  133,  133,  133,  133,  133,  133,
510       133,  133,  133,  133,  133,  133,  133,  133,  133,  133,
511
512       133,  133,  133,  133,  133,  133
513     } ;
514
515 static const short int style_chk[407] =
516     {   0,
517         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
518         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
519         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
520         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
521         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
522         1,    1,    1,    1,    1,    1,    1,    3,    4,    7,
523         8,   34,    7,    8,   26,   36,   26,   37,   43,   71,
524        65,  131,   86,   37,   75,   26,   88,  130,  129,   93,
525        26,   36,   38,   34,   43,   26,   65,   38,   89,   37,
526        71,   38,   75,   86,   88,   38,   26,  128,   26,    7,
527
528         8,   93,   89,   38,  127,   38,  126,   38,  125,   38,
529         3,    4,    5,    5,    5,    5,    5,    5,    5,    5,
530         5,    5,    5,    5,    5,    5,    5,    5,    5,    5,
531         5,    5,    5,    5,    5,    5,    5,    5,    5,    5,
532         5,    5,    5,    5,    5,    5,    5,    5,    5,    5,
533         5,    5,    5,    5,    5,    5,    5,    5,    5,    5,
534         5,    5,    5,    5,    5,    5,    5,    5,    5,   48,
535        94,   48,   48,   48,  124,  101,   48,   48,   48,   48,
536        48,   74,   48,   48,   63,   48,   63,   48,   95,   48,
537        48,   94,   96,   87,   66,   63,   74,  101,  122,   66,
538
539        63,  121,   74,   66,   95,   63,  107,   66,   87,   48,
540        98,   48,   48,   96,   87,   66,   63,   66,   63,   66,
541       107,   66,   48,   48,   48,   78,   98,   78,   78,   78,
542       102,  103,   78,   78,   78,   78,   78,  104,   78,   78,
543        84,   78,  110,   78,  118,   78,   78,  103,   99,   84,
544       114,  102,  117,   99,   84,  119,  112,   99,  104,   84,
545       116,   99,  111,  110,  114,   78,  118,   78,   78,   99,
546        84,   99,   84,   99,  112,   99,  119,  111,   78,  120,
547        78,  113,  123,  111,  106,  105,  100,   97,   91,   90,
548        76,   72,   70,   69,   64,  120,  123,  134,  134,  134,
549
550       134,  134,  134,  134,  135,  135,  135,  135,  135,  135,
551       135,  136,   62,   51,   46,  136,   44,  136,  137,  137,
552        39,  137,  137,  137,  137,  138,  138,  139,  139,  139,
553        35,  139,  139,  140,  140,   33,  140,  140,  140,  140,
554        30,   29,   28,   17,   16,   14,    9,    2,  133,  133,
555       133,  133,  133,  133,  133,  133,  133,  133,  133,  133,
556       133,  133,  133,  133,  133,  133,  133,  133,  133,  133,
557       133,  133,  133,  133,  133,  133,  133,  133,  133,  133,
558       133,  133,  133,  133,  133,  133,  133,  133,  133,  133,
559       133,  133,  133,  133,  133,  133,  133,  133,  133,  133,
560
561       133,  133,  133,  133,  133,  133
562     } ;
563
564 static style_state_type style_last_accepting_state;
565 static style_CHAR *style_last_accepting_cpos;
566
567 /* the intent behind this definition is that it'll catch
568  * any uses of REJECT which flex missed
569  */
570 #define REJECT reject_used_but_not_detected
571 #define stylemore() stylemore_used_but_not_detected
572 #define style_MORE_ADJ 0
573
574 /* these variables are all declared out here so that section 3 code can
575  * manipulate them
576  */
577 /* points to current character in buffer */
578 static style_CHAR *style_c_buf_p = (style_CHAR *) 0;
579 static int style_init = 1;              /* whether we need to initialize */
580 static int style_start = 0;     /* start state number */
581
582 /* flag which is used to allow stylewrap()'s to do buffer switches
583  * instead of setting up a fresh stylein.  A bit of a hack ...
584  */
585 static int style_did_buffer_switch_on_eof;
586
587 static style_state_type style_get_previous_state style_PROTO(( void ));
588 static style_state_type style_try_NUL_trans style_PROTO(( style_state_type current_state ));
589 static int style_get_next_buffer style_PROTO(( void ));
590 #if 0
591 static void styleunput style_PROTO(( style_CHAR c, style_CHAR *buf_ptr ));
592 #endif
593 void stylerestart style_PROTO(( FILE *input_file ));
594 void style_switch_to_buffer style_PROTO(( style_BUFFER_STATE new_buffer ));
595 void style_load_buffer_state style_PROTO(( void ));
596 style_BUFFER_STATE style_create_buffer style_PROTO(( FILE *file, int size ));
597 void style_delete_buffer style_PROTO(( style_BUFFER_STATE b ));
598 void style_init_buffer style_PROTO(( style_BUFFER_STATE b, FILE *file ));
599
600 #define style_new_buffer style_create_buffer
601
602 #ifdef __cplusplus
603 static int styleinput style_PROTO(( void ));
604 #else
605 static int input style_PROTO(( void ));
606 #endif
607
608 style_DECL
609     {
610     register style_state_type style_current_state;
611     register style_CHAR *style_cp, *style_bp;
612     register int style_act;
613
614
615
616
617     if ( style_init )
618         {
619         style_USER_INIT;
620
621         if ( ! style_start )
622             style_start = 1;    /* first start state */
623
624         if ( ! stylein )
625             stylein = stdin;
626
627         if ( ! styleout )
628             styleout = stdout;
629
630         if ( style_current_buffer )
631             style_init_buffer( style_current_buffer, stylein );
632         else
633             style_current_buffer = style_create_buffer( stylein, style_BUF_SIZE );
634
635         style_load_buffer_state();
636
637         style_init = 0;
638         }
639
640     while ( 1 )         /* loops until end-of-file is reached */
641         {
642         style_cp = style_c_buf_p;
643
644         /* support of styletext */
645         *style_cp = style_hold_char;
646
647         /* style_bp points to the position in style_ch_buf of the start of the
648          * current run.
649          */
650         style_bp = style_cp;
651
652         style_current_state = style_start;
653         if ( style_bp[-1] == '\n' )
654             ++style_current_state;
655 style_match:
656         do
657             {
658             register style_CHAR style_c = style_ec[*style_cp];
659             if ( style_accept[style_current_state] )
660                 {
661                 style_last_accepting_state = style_current_state;
662                 style_last_accepting_cpos = style_cp;
663                 }
664             while ( style_chk[style_base[style_current_state] + style_c] != style_current_state )
665                 {
666                 style_current_state = style_def[style_current_state];
667                 if ( style_current_state >= 134 )
668                     style_c = style_meta[style_c];
669                 }
670             style_current_state = style_nxt[style_base[style_current_state] + style_c];
671             ++style_cp;
672             }
673         while ( style_current_state != 133 );
674         style_cp = style_last_accepting_cpos;
675         style_current_state = style_last_accepting_state;
676
677 style_find_action:
678         style_act = style_accept[style_current_state];
679
680         style_DO_BEFORE_ACTION;
681         style_USER_ACTION;
682
683 do_action:      /* this label is used only to access EOF actions */
684
685
686         switch ( style_act )
687             {
688             case 0: /* must backtrack */
689             /* undo the effects of style_DO_BEFORE_ACTION */
690             *style_cp = style_hold_char;
691             style_cp = style_last_accepting_cpos;
692             style_current_state = style_last_accepting_state;
693             goto style_find_action;
694
695 case 1:
696 # line 97 "tokenStyle.l"
697 BEGIN(block);
698         style_BREAK
699 case 2:
700 # line 99 "tokenStyle.l"
701 {
702            if ( commentBufferSize < styleleng ) {
703               delete commentBuffer;
704               commentBufferSize = 2 * styleleng ;
705               commentBuffer = new char [commentBufferSize];
706            } 
707
708            commentBufferContentSize = styleleng-1;
709            memcpy(commentBuffer, styletext+1, commentBufferContentSize); // copy everything except the #
710            commentBuffer[commentBufferContentSize] = 0;
711         }
712         style_BREAK
713 case 3:
714 # line 111 "tokenStyle.l"
715 {
716            return(OPER_assign);
717         }
718         style_BREAK
719 case 4:
720 # line 115 "tokenStyle.l"
721 {
722            return(OPER_attr);
723         }
724         style_BREAK
725 case 5:
726 # line 119 "tokenStyle.l"
727 {
728            stylelval.charData = styletext[0];
729            return(OPER_plus);
730         }
731         style_BREAK
732 case 6:
733 # line 124 "tokenStyle.l"
734 {
735            stylelval.charData = styletext[0];
736            return(OPER_minus);
737         }
738         style_BREAK
739 case 7:
740 # line 129 "tokenStyle.l"
741 {
742            stylelval.charData = styletext[0];
743            return(OPER_div);
744         }
745         style_BREAK
746 case 8:
747 # line 134 "tokenStyle.l"
748 {
749            return(OPER_period);
750         }
751         style_BREAK
752 case 9:
753 # line 138 "tokenStyle.l"
754 {
755            stylelval.charData = styletext[0];
756            return(OPER_star);
757         }
758         style_BREAK
759 case 10:
760 # line 143 "tokenStyle.l"
761 {
762            return(OPER_modify);
763         }
764         style_BREAK
765 case 11:
766 # line 147 "tokenStyle.l"
767 {
768            return(OPER_oneof);
769         }
770         style_BREAK
771 case 12:
772 # line 151 "tokenStyle.l"
773 {
774            return(OPER_parent);
775         }
776         style_BREAK
777 case 13:
778 # line 155 "tokenStyle.l"
779 {
780            return(SEPARATOR);
781         }
782         style_BREAK
783 case 14:
784 # line 159 "tokenStyle.l"
785 {
786            return(FSOPEN);
787         }
788         style_BREAK
789 case 15:
790 # line 163 "tokenStyle.l"
791 {
792            return(FSCLOSE);
793         }
794         style_BREAK
795 case 16:
796 # line 167 "tokenStyle.l"
797 {
798            return(ARRAYOPEN);
799         }
800         style_BREAK
801 case 17:
802 # line 171 "tokenStyle.l"
803 {
804            return(ARRAYCLOSE);
805         }
806         style_BREAK
807 case 18:
808 # line 175 "tokenStyle.l"
809 {
810            return(OPER_parenopen);
811         }
812         style_BREAK
813 case 19:
814 # line 179 "tokenStyle.l"
815 {
816            return(OPER_parenclose);
817         }
818         style_BREAK
819 case 20:
820 # line 183 "tokenStyle.l"
821 {
822            return(OPER_or);
823         }
824         style_BREAK
825 case 21:
826 # line 187 "tokenStyle.l"
827 {
828            return(OPER_and);
829         }
830         style_BREAK
831 case 22:
832 # line 191 "tokenStyle.l"
833 {
834            if ( strcmp((const char*)styletext, "==") == 0 )
835               stylelval.intData = EQUAL;
836            else
837               stylelval.intData = NOT_EQUAL;
838
839            return(OPER_equality);
840         }
841         style_BREAK
842 case 23:
843 # line 200 "tokenStyle.l"
844 {
845            return(OPER_logicalnegate);
846         }
847         style_BREAK
848 case 24:
849 # line 204 "tokenStyle.l"
850 {
851            if ( strcmp((const char*)styletext, "<=") == 0 )
852               stylelval.intData = LESS_OR_EQUAL;
853            else
854            if ( strcmp((const char*)styletext, "<") == 0 )
855               stylelval.intData = LESS;
856            else
857            if ( strcmp((const char*)styletext, ">=") == 0 )
858               stylelval.intData = GREATER_OR_EQUAL;
859            else
860               stylelval.intData = GREATER;
861
862            return(OPER_relational);
863         }
864         style_BREAK
865 case 25:
866 # line 219 "tokenStyle.l"
867 {
868                 return(GI_CASE_SENSITIVE);
869                         }
870         style_BREAK
871 case 26:
872 # line 223 "tokenStyle.l"
873 {
874                 stylelval.boolData = true;
875                 return(BOOLVAL);
876                         }
877         style_BREAK
878 case 27:
879 # line 228 "tokenStyle.l"
880 {
881                 stylelval.boolData = false;
882                 return(BOOLVAL);
883                         }
884         style_BREAK
885 case 28:
886 # line 233 "tokenStyle.l"
887 {
888                 stylelval.boolData = true;
889                 return(BOOLVAL);
890                 }
891         style_BREAK
892 case 29:
893 # line 238 "tokenStyle.l"
894 {
895                 stylelval.boolData = false;
896                 return(BOOLVAL);
897                 }
898         style_BREAK
899 case 30:
900 # line 243 "tokenStyle.l"
901 {
902                 stylelval.charPtrData = 
903                   (unsigned char*)strdup((const char*)styletext);
904                 return(DIMENSION);
905                 }
906         style_BREAK
907 case 31:
908 # line 249 "tokenStyle.l"
909 {
910                 stylelval.intData = atoi((char*)styletext);
911                 return(INTEGER);
912                 }
913         style_BREAK
914 case 32:
915 # line 254 "tokenStyle.l"
916 {
917                 stylelval.realData = atof((char*)styletext);
918                 return(REAL);
919                 }
920         style_BREAK
921 case 33:
922 # line 259 "tokenStyle.l"
923 {
924                 BEGIN quoted_string;
925                 }
926         style_BREAK
927 case 34:
928 # line 263 "tokenStyle.l"
929 {
930
931                 stylelval.charPtrData = 
932                         new unsigned char[qstring_buf_content_size+1];
933                 memcpy( stylelval.charPtrData, 
934                         qstring_buf, 
935                         qstring_buf_content_size+1
936                       );
937
938                 qstring_buf_content_size = 0;
939                 BEGIN 0;
940
941                 return(QUOTED_STRING);
942                 }
943         style_BREAK
944 case 35:
945 # line 278 "tokenStyle.l"
946 {
947                 int c = styleinput();
948                 switch (c) {
949                    case '"':
950                      addToQstringBuf((unsigned char*)"\"", 1);
951                      break;
952                    case '\\':
953                      addToQstringBuf((unsigned char*)"\\", 1);
954                      break;
955                    default:
956                      throw(CASTSSEXCEPT StyleSheetException());
957                 }
958                 }
959         style_BREAK
960 case 36:
961 # line 292 "tokenStyle.l"
962 {
963                 addToQstringBuf((const unsigned char *)styletext, styleleng);
964                 }
965         style_BREAK
966 case 37:
967 # line 296 "tokenStyle.l"
968 {
969                 addToQstringBuf((const unsigned char *)styletext, styleleng);
970                 }
971         style_BREAK
972 case 38:
973 # line 300 "tokenStyle.l"
974 {
975                 stylelval.charPtrData = 
976                   (unsigned char*)strdup((const char*)styletext);
977                   return(UNIT_STRING);
978                 }
979         style_BREAK
980 case 39:
981 # line 306 "tokenStyle.l"
982 {
983                 stylelval.charPtrData = 
984                   (unsigned char*)strdup((const char*)styletext);
985                 return(NORMAL_STRING);
986                 }
987         style_BREAK
988 case 40:
989 # line 312 "tokenStyle.l"
990 {
991                 stylelval.charPtrData = 
992                   (unsigned char*)strdup((const char*)styletext);
993                 BEGIN 0;
994                 return(SGMLGI_STRING);
995         }
996         style_BREAK
997 case 41:
998 # line 319 "tokenStyle.l"
999 {
1000         }
1001         style_BREAK
1002 case 42:
1003 # line 322 "tokenStyle.l"
1004 {
1005            stylelineno++;
1006         }
1007         style_BREAK
1008 case 43:
1009 # line 326 "tokenStyle.l"
1010 {
1011         }
1012         style_BREAK
1013 case 44:
1014 # line 331 "tokenStyle.l"
1015 { BEGIN(0); }
1016         style_BREAK
1017 case 45:
1018 # line 332 "tokenStyle.l"
1019 ;
1020         style_BREAK
1021 case 46:
1022 # line 333 "tokenStyle.l"
1023 ;
1024         style_BREAK
1025 case 47:
1026 # line 334 "tokenStyle.l"
1027 style_FATAL_ERROR( "flex scanner jammed" );
1028         style_BREAK
1029 case style_STATE_EOF(INITIAL):
1030 case style_STATE_EOF(block):
1031 case style_STATE_EOF(sgmlgimode):
1032 case style_STATE_EOF(quoted_string):
1033     styleterminate();
1034
1035             case style_END_OF_BUFFER:
1036                 {
1037                 /* amount of text matched not including the EOB char */
1038                 int style_amount_of_matched_text = style_cp - styletext - 1;
1039
1040                 /* undo the effects of style_DO_BEFORE_ACTION */
1041                 *style_cp = style_hold_char;
1042
1043                 /* note that here we test for style_c_buf_p "<=" to the position
1044                  * of the first EOB in the buffer, since style_c_buf_p will
1045                  * already have been incremented past the NUL character
1046                  * (since all states make transitions on EOB to the end-
1047                  * of-buffer state).  Contrast this with the test in styleinput().
1048                  */
1049                 if ( style_c_buf_p <= &style_current_buffer->style_ch_buf[style_n_chars] )
1050                     /* this was really a NUL */
1051                     {
1052                     style_state_type style_next_state;
1053
1054                     style_c_buf_p = styletext + style_amount_of_matched_text;
1055
1056                     style_current_state = style_get_previous_state();
1057
1058                     /* okay, we're now positioned to make the
1059                      * NUL transition.  We couldn't have
1060                      * style_get_previous_state() go ahead and do it
1061                      * for us because it doesn't know how to deal
1062                      * with the possibility of jamming (and we
1063                      * don't want to build jamming into it because
1064                      * then it will run more slowly)
1065                      */
1066
1067                     style_next_state = style_try_NUL_trans( style_current_state );
1068
1069                     style_bp = styletext + style_MORE_ADJ;
1070
1071                     if ( style_next_state )
1072                         {
1073                         /* consume the NUL */
1074                         style_cp = ++style_c_buf_p;
1075                         style_current_state = style_next_state;
1076                         goto style_match;
1077                         }
1078
1079                     else
1080                         {
1081                             style_cp = style_last_accepting_cpos;
1082                             style_current_state = style_last_accepting_state;
1083                         goto style_find_action;
1084                         }
1085                     }
1086
1087                 else switch ( style_get_next_buffer() )
1088                     {
1089                     case EOB_ACT_END_OF_FILE:
1090                         {
1091                         style_did_buffer_switch_on_eof = 0;
1092
1093                         if ( stylewrap() )
1094                             {
1095                             /* note: because we've taken care in
1096                              * style_get_next_buffer() to have set up styletext,
1097                              * we can now set up style_c_buf_p so that if some
1098                              * total hoser (like flex itself) wants
1099                              * to call the scanner after we return the
1100                              * style_NULL, it'll still work - another style_NULL
1101                              * will get returned.
1102                              */
1103                             style_c_buf_p = styletext + style_MORE_ADJ;
1104
1105                             style_act = style_STATE_EOF((style_start - 1) / 2);
1106                             goto do_action;
1107                             }
1108
1109                         else
1110                             {
1111                             if ( ! style_did_buffer_switch_on_eof )
1112                                 style_NEW_FILE;
1113                             }
1114                         }
1115                         break;
1116
1117                     case EOB_ACT_CONTINUE_SCAN:
1118                         style_c_buf_p = styletext + style_amount_of_matched_text;
1119
1120                         style_current_state = style_get_previous_state();
1121
1122                         style_cp = style_c_buf_p;
1123                         style_bp = styletext + style_MORE_ADJ;
1124                         goto style_match;
1125
1126                     case EOB_ACT_LAST_MATCH:
1127                         style_c_buf_p =
1128                             &style_current_buffer->style_ch_buf[style_n_chars];
1129
1130                         style_current_state = style_get_previous_state();
1131
1132                         style_cp = style_c_buf_p;
1133                         style_bp = styletext + style_MORE_ADJ;
1134                         goto style_find_action;
1135                     }
1136                 break;
1137                 }
1138
1139             default:
1140 #ifdef FLEX_DEBUG
1141                 printf( "action # %d\n", style_act );
1142 #endif
1143                 style_FATAL_ERROR(
1144                         "fatal flex scanner internal error--no action found" );
1145             }
1146         }
1147     }
1148
1149
1150 /* style_get_next_buffer - try to read in a new buffer
1151  *
1152  * synopsis
1153  *     int style_get_next_buffer();
1154  *     
1155  * returns a code representing an action
1156  *     EOB_ACT_LAST_MATCH - 
1157  *     EOB_ACT_CONTINUE_SCAN - continue scanning from current position
1158  *     EOB_ACT_END_OF_FILE - end of file
1159  */
1160
1161 static int style_get_next_buffer()
1162
1163     {
1164     register style_CHAR *dest = style_current_buffer->style_ch_buf;
1165     register style_CHAR *source = styletext - 1; /* copy prev. char, too */
1166     register int number_to_move, i;
1167     int ret_val;
1168
1169     if ( style_c_buf_p > &style_current_buffer->style_ch_buf[style_n_chars + 1] )
1170         style_FATAL_ERROR(
1171                 "fatal flex scanner internal error--end of buffer missed" );
1172
1173     /* try to read more data */
1174
1175     /* first move last chars to start of buffer */
1176     number_to_move = style_c_buf_p - styletext;
1177
1178     for ( i = 0; i < number_to_move; ++i )
1179         *(dest++) = *(source++);
1180
1181     if ( style_current_buffer->style_eof_status != EOF_NOT_SEEN )
1182         /* don't do the read, it's not guaranteed to return an EOF,
1183          * just force an EOF
1184          */
1185         style_n_chars = 0;
1186
1187     else
1188         {
1189         int num_to_read = style_current_buffer->style_buf_size - number_to_move - 1;
1190
1191         if ( num_to_read > style_READ_BUF_SIZE )
1192             num_to_read = style_READ_BUF_SIZE;
1193
1194         else if ( num_to_read <= 0 )
1195             style_FATAL_ERROR( "fatal error - scanner input buffer overflow" );
1196
1197         /* read in more data */
1198         style_INPUT( (&style_current_buffer->style_ch_buf[number_to_move]),
1199                   style_n_chars, num_to_read );
1200         }
1201
1202     if ( style_n_chars == 0 )
1203         {
1204         if ( number_to_move == 1 )
1205             {
1206             ret_val = EOB_ACT_END_OF_FILE;
1207             style_current_buffer->style_eof_status = EOF_DONE;
1208             }
1209
1210         else
1211             {
1212             ret_val = EOB_ACT_LAST_MATCH;
1213             style_current_buffer->style_eof_status = EOF_PENDING;
1214             }
1215         }
1216
1217     else
1218         ret_val = EOB_ACT_CONTINUE_SCAN;
1219
1220     style_n_chars += number_to_move;
1221     style_current_buffer->style_ch_buf[style_n_chars] = style_END_OF_BUFFER_CHAR;
1222     style_current_buffer->style_ch_buf[style_n_chars + 1] = style_END_OF_BUFFER_CHAR;
1223
1224     /* styletext begins at the second character in style_ch_buf; the first
1225      * character is the one which preceded it before reading in the latest
1226      * buffer; it needs to be kept around in case it's a newline, so
1227      * style_get_previous_state() will have with '^' rules active
1228      */
1229
1230     styletext = &style_current_buffer->style_ch_buf[1];
1231
1232     return ( ret_val );
1233     }
1234
1235
1236 /* style_get_previous_state - get the state just before the EOB char was reached
1237  *
1238  * synopsis
1239  *     style_state_type style_get_previous_state();
1240  */
1241
1242 static style_state_type style_get_previous_state()
1243
1244     {
1245     register style_state_type style_current_state;
1246     register style_CHAR *style_cp;
1247
1248     register style_CHAR *style_bp = styletext;
1249
1250     style_current_state = style_start;
1251     if ( style_bp[-1] == '\n' )
1252         ++style_current_state;
1253
1254     for ( style_cp = styletext + style_MORE_ADJ; style_cp < style_c_buf_p; ++style_cp )
1255         {
1256         register style_CHAR style_c = (*style_cp ? style_ec[*style_cp] : 1);
1257         if ( style_accept[style_current_state] )
1258             {
1259             style_last_accepting_state = style_current_state;
1260             style_last_accepting_cpos = style_cp;
1261             }
1262         while ( style_chk[style_base[style_current_state] + style_c] != style_current_state )
1263             {
1264             style_current_state = style_def[style_current_state];
1265             if ( style_current_state >= 134 )
1266                 style_c = style_meta[style_c];
1267             }
1268         style_current_state = style_nxt[style_base[style_current_state] + style_c];
1269         }
1270
1271     return ( style_current_state );
1272     }
1273
1274
1275 /* style_try_NUL_trans - try to make a transition on the NUL character
1276  *
1277  * synopsis
1278  *     next_state = style_try_NUL_trans( current_state );
1279  */
1280
1281 #ifdef style_USE_PROTOS
1282 static style_state_type style_try_NUL_trans( register style_state_type style_current_state )
1283 #else
1284 static style_state_type style_try_NUL_trans( style_current_state )
1285 register style_state_type style_current_state;
1286 #endif
1287
1288     {
1289     register int style_is_jam;
1290     register style_CHAR *style_cp = style_c_buf_p;
1291
1292     register style_CHAR style_c = 1;
1293     if ( style_accept[style_current_state] )
1294         {
1295         style_last_accepting_state = style_current_state;
1296         style_last_accepting_cpos = style_cp;
1297         }
1298     while ( style_chk[style_base[style_current_state] + style_c] != style_current_state )
1299         {
1300         style_current_state = style_def[style_current_state];
1301         if ( style_current_state >= 134 )
1302             style_c = style_meta[style_c];
1303         }
1304     style_current_state = style_nxt[style_base[style_current_state] + style_c];
1305     style_is_jam = (style_current_state == 133);
1306
1307     return ( style_is_jam ? 0 : style_current_state );
1308     }
1309
1310
1311 #if 0
1312 #ifdef style_USE_PROTOS
1313 static void styleunput( style_CHAR c, register style_CHAR *style_bp )
1314 #else
1315 static void styleunput( c, style_bp )
1316 style_CHAR c;
1317 register style_CHAR *style_bp;
1318 #endif
1319
1320     {
1321     register style_CHAR *style_cp = style_c_buf_p;
1322
1323     /* undo effects of setting up styletext */
1324     *style_cp = style_hold_char;
1325
1326     if ( style_cp < style_current_buffer->style_ch_buf + 2 )
1327         { /* need to shift things up to make room */
1328         register int number_to_move = style_n_chars + 2; /* +2 for EOB chars */
1329         register style_CHAR *dest =
1330             &style_current_buffer->style_ch_buf[style_current_buffer->style_buf_size + 2];
1331         register style_CHAR *source =
1332             &style_current_buffer->style_ch_buf[number_to_move];
1333
1334         while ( source > style_current_buffer->style_ch_buf )
1335             *--dest = *--source;
1336
1337         style_cp += dest - source;
1338         style_bp += dest - source;
1339         style_n_chars = style_current_buffer->style_buf_size;
1340
1341         if ( style_cp < style_current_buffer->style_ch_buf + 2 )
1342             style_FATAL_ERROR( "flex scanner push-back overflow" );
1343         }
1344
1345     if ( style_cp > style_bp && style_cp[-1] == '\n' )
1346         style_cp[-2] = '\n';
1347
1348     *--style_cp = c;
1349
1350     /* note: the formal parameter *must* be called "style_bp" for this
1351      *       macro to now work correctly
1352      */
1353     style_DO_BEFORE_ACTION; /* set up styletext again */
1354     }
1355 #endif
1356
1357
1358 #ifdef __cplusplus
1359 static int styleinput()
1360 #else
1361 static int input()
1362 #endif
1363
1364     {
1365     int c;
1366     style_CHAR *style_cp = style_c_buf_p;
1367
1368     *style_cp = style_hold_char;
1369
1370     if ( *style_c_buf_p == style_END_OF_BUFFER_CHAR )
1371         {
1372         /* style_c_buf_p now points to the character we want to return.
1373          * If this occurs *before* the EOB characters, then it's a
1374          * valid NUL; if not, then we've hit the end of the buffer.
1375          */
1376         if ( style_c_buf_p < &style_current_buffer->style_ch_buf[style_n_chars] )
1377             /* this was really a NUL */
1378             *style_c_buf_p = '\0';
1379
1380         else
1381             { /* need more input */
1382             styletext = style_c_buf_p;
1383             ++style_c_buf_p;
1384
1385             switch ( style_get_next_buffer() )
1386                 {
1387                 case EOB_ACT_END_OF_FILE:
1388                     {
1389                     if ( stylewrap() )
1390                         {
1391                         style_c_buf_p = styletext + style_MORE_ADJ;
1392                         return ( EOF );
1393                         }
1394
1395                     style_NEW_FILE;
1396
1397 #ifdef __cplusplus
1398                     return ( styleinput() );
1399 #else
1400                     return ( input() );
1401 #endif
1402                     }
1403                     break;
1404
1405                 case EOB_ACT_CONTINUE_SCAN:
1406                     style_c_buf_p = styletext + style_MORE_ADJ;
1407                     break;
1408
1409                 case EOB_ACT_LAST_MATCH:
1410 #ifdef __cplusplus
1411                     style_FATAL_ERROR( "unexpected last match in styleinput()" );
1412 #else
1413                     style_FATAL_ERROR( "unexpected last match in input()" );
1414 #endif
1415                 }
1416             }
1417         }
1418
1419     c = *style_c_buf_p;
1420     style_hold_char = *++style_c_buf_p;
1421
1422     return ( c );
1423     }
1424
1425
1426 #ifdef style_USE_PROTOS
1427 void stylerestart( FILE *input_file )
1428 #else
1429 void stylerestart( input_file )
1430 FILE *input_file;
1431 #endif
1432
1433     {
1434     style_init_buffer( style_current_buffer, input_file );
1435     style_load_buffer_state();
1436     }
1437
1438
1439 #ifdef style_USE_PROTOS
1440 void style_switch_to_buffer( style_BUFFER_STATE new_buffer )
1441 #else
1442 void style_switch_to_buffer( new_buffer )
1443 style_BUFFER_STATE new_buffer;
1444 #endif
1445
1446     {
1447     if ( style_current_buffer == new_buffer )
1448         return;
1449
1450     if ( style_current_buffer )
1451         {
1452         /* flush out information for old buffer */
1453         *style_c_buf_p = style_hold_char;
1454         style_current_buffer->style_buf_pos = style_c_buf_p;
1455         style_current_buffer->style_n_chars = style_n_chars;
1456         }
1457
1458     style_current_buffer = new_buffer;
1459     style_load_buffer_state();
1460
1461     /* we don't actually know whether we did this switch during
1462      * EOF (stylewrap()) processing, but the only time this flag
1463      * is looked at is after stylewrap() is called, so it's safe
1464      * to go ahead and always set it.
1465      */
1466     style_did_buffer_switch_on_eof = 1;
1467     }
1468
1469
1470 #ifdef style_USE_PROTOS
1471 void style_load_buffer_state( void )
1472 #else
1473 void style_load_buffer_state()
1474 #endif
1475
1476     {
1477     style_n_chars = style_current_buffer->style_n_chars;
1478     styletext = style_c_buf_p = style_current_buffer->style_buf_pos;
1479     stylein = style_current_buffer->style_input_file;
1480     style_hold_char = *style_c_buf_p;
1481     }
1482
1483
1484 #ifdef style_USE_PROTOS
1485 style_BUFFER_STATE style_create_buffer( FILE *file, int size )
1486 #else
1487 style_BUFFER_STATE style_create_buffer( file, size )
1488 FILE *file;
1489 int size;
1490 #endif
1491
1492     {
1493     style_BUFFER_STATE b;
1494
1495     b = (style_BUFFER_STATE) malloc( sizeof( struct style_buffer_state ) );
1496
1497     if ( ! b )
1498         style_FATAL_ERROR( "out of dynamic memory in style_create_buffer()" );
1499
1500     b->style_buf_size = size;
1501
1502     /* style_ch_buf has to be 2 characters longer than the size given because
1503      * we need to put in 2 end-of-buffer characters.
1504      */
1505     b->style_ch_buf = (style_CHAR *) malloc( (unsigned) (b->style_buf_size + 2) );
1506
1507     if ( ! b->style_ch_buf )
1508         style_FATAL_ERROR( "out of dynamic memory in style_create_buffer()" );
1509
1510     style_init_buffer( b, file );
1511
1512     return ( b );
1513     }
1514
1515
1516 #ifdef style_USE_PROTOS
1517 void style_delete_buffer( style_BUFFER_STATE b )
1518 #else
1519 void style_delete_buffer( b )
1520 style_BUFFER_STATE b;
1521 #endif
1522
1523     {
1524     if ( b == style_current_buffer )
1525         style_current_buffer = (style_BUFFER_STATE) 0;
1526
1527     free( (char *) b->style_ch_buf );
1528     free( (char *) b );
1529     }
1530
1531
1532 #ifdef style_USE_PROTOS
1533 void style_init_buffer( style_BUFFER_STATE b, FILE *file )
1534 #else
1535 void style_init_buffer( b, file )
1536 style_BUFFER_STATE b;
1537 FILE *file;
1538 #endif
1539
1540     {
1541     b->style_input_file = file;
1542
1543     /* we put in the '\n' and start reading from [1] so that an
1544      * initial match-at-newline will be true.
1545      */
1546
1547     b->style_ch_buf[0] = '\n';
1548     b->style_n_chars = 1;
1549
1550     /* we always need two end-of-buffer characters.  The first causes
1551      * a transition to the end-of-buffer state.  The second causes
1552      * a jam in that state.
1553      */
1554     b->style_ch_buf[1] = style_END_OF_BUFFER_CHAR;
1555     b->style_ch_buf[2] = style_END_OF_BUFFER_CHAR;
1556
1557     b->style_buf_pos = &b->style_ch_buf[1];
1558
1559     b->style_eof_status = EOF_NOT_SEEN;
1560     }
1561 # line 334 "tokenStyle.l"
1562
1563
1564 void enter_sgmlgi_context()
1565 {
1566    BEGIN sgmlgimode;
1567 }
1568
1569
1570 void report_error_location()
1571 {
1572    if ( commentBufferContentSize > 0 ) {
1573       cerr << commentBuffer << "\n";
1574    }
1575 }
1576
1577 void styleerror(char* msg)
1578 {
1579 #ifdef DEBUG
1580    cerr << "line " << stylelineno << ": " << msg << "\n";
1581 #endif
1582    throw(CASTSSEXCEPT StyleSheetSyntaxError());
1583 }
1584