1 #ifdef HAVE_CONFIG_H
2 # include "config.h"
3 #endif /* HAVE_CONFIG_H */
4
5 #include "manconfig.h"
6
7 /* Flex emits several functions which might reasonably have various
8 * attributes applied and many unused macros; none of these are our problem.
9 */
10 #if GNUC_PREREQ(8,0)
11 # pragma GCC diagnostic ignored "-Wsuggest-attribute=malloc"
12 #endif
13 #pragma GCC diagnostic ignored "-Wsuggest-attribute=pure"
14 #pragma GCC diagnostic ignored "-Wunused-macros"
15
16 #line 17 "zsoelim.c"
17
18 #define YY_INT_ALIGNED short int
19
20 /* A lexical scanner generated by flex */
21
22 #define FLEX_SCANNER
23 #define YY_FLEX_MAJOR_VERSION 2
24 #define YY_FLEX_MINOR_VERSION 6
25 #define YY_FLEX_SUBMINOR_VERSION 4
26 #if YY_FLEX_SUBMINOR_VERSION > 0
27 #define FLEX_BETA
28 #endif
29
30 /* First, we deal with platform-specific or compiler-specific issues. */
31
32 /* begin standard C headers. */
33 #include <stdio.h>
34 #include <string.h>
35 #include <errno.h>
36 #include <stdlib.h>
37
38 /* end standard C headers. */
39
40 /* flex integer type definitions */
41
42 #ifndef FLEXINT_H
43 #define FLEXINT_H
44
45 /* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */
46
47 #if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
48
49 /* C99 says to define __STDC_LIMIT_MACROS before including stdint.h,
50 * if you want the limit (max/min) macros for int types.
51 */
52 #ifndef __STDC_LIMIT_MACROS
53 #define __STDC_LIMIT_MACROS 1
54 #endif
55
56 #include <inttypes.h>
57 typedef int8_t flex_int8_t;
58 typedef uint8_t flex_uint8_t;
59 typedef int16_t flex_int16_t;
60 typedef uint16_t flex_uint16_t;
61 typedef int32_t flex_int32_t;
62 typedef uint32_t flex_uint32_t;
63 #else
64 typedef signed char flex_int8_t;
65 typedef short int flex_int16_t;
66 typedef int flex_int32_t;
67 typedef unsigned char flex_uint8_t;
68 typedef unsigned short int flex_uint16_t;
69 typedef unsigned int flex_uint32_t;
70
71 /* Limits of integral types. */
72 #ifndef INT8_MIN
73 #define INT8_MIN (-128)
74 #endif
75 #ifndef INT16_MIN
76 #define INT16_MIN (-32767-1)
77 #endif
78 #ifndef INT32_MIN
79 #define INT32_MIN (-2147483647-1)
80 #endif
81 #ifndef INT8_MAX
82 #define INT8_MAX (127)
83 #endif
84 #ifndef INT16_MAX
85 #define INT16_MAX (32767)
86 #endif
87 #ifndef INT32_MAX
88 #define INT32_MAX (2147483647)
89 #endif
90 #ifndef UINT8_MAX
91 #define UINT8_MAX (255U)
92 #endif
93 #ifndef UINT16_MAX
94 #define UINT16_MAX (65535U)
95 #endif
96 #ifndef UINT32_MAX
97 #define UINT32_MAX (4294967295U)
98 #endif
99
100 #ifndef SIZE_MAX
101 #define SIZE_MAX (~(size_t)0)
102 #endif
103
104 #endif /* ! C99 */
105
106 #endif /* ! FLEXINT_H */
107
108 /* begin standard C++ headers. */
109
110 /* TODO: this is always defined, so inline it */
111 #define yyconst const
112
113 #if defined(__GNUC__) && __GNUC__ >= 3
114 #define yynoreturn __attribute__((__noreturn__))
115 #else
116 #define yynoreturn
117 #endif
118
119 /* Returned upon end-of-file. */
120 #define YY_NULL 0
121
122 /* Promotes a possibly negative, possibly signed char to an
123 * integer in range [0..255] for use as an array index.
124 */
125 #define YY_SC_TO_UI(c) ((YY_CHAR) (c))
126
127 /* Enter a start condition. This macro really ought to take a parameter,
128 * but we do it the disgusting crufty way forced on us by the ()-less
129 * definition of BEGIN.
130 */
131 #define BEGIN (yy_start) = 1 + 2 *
132 /* Translate the current start state into a value that can be later handed
133 * to BEGIN to return to the state. The YYSTATE alias is for lex
134 * compatibility.
135 */
136 #define YY_START (((yy_start) - 1) / 2)
137 #define YYSTATE YY_START
138 /* Action number for EOF rule of a given start state. */
139 #define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
140 /* Special action meaning "start processing a new file". */
141 #define YY_NEW_FILE yyrestart( yyin )
142 #define YY_END_OF_BUFFER_CHAR 0
143
144 /* Size of default input buffer. */
145 #ifndef YY_BUF_SIZE
146 #ifdef __ia64__
147 /* On IA-64, the buffer size is 16k, not 8k.
148 * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case.
149 * Ditto for the __ia64__ case accordingly.
150 */
151 #define YY_BUF_SIZE 32768
152 #else
153 #define YY_BUF_SIZE 16384
154 #endif /* __ia64__ */
155 #endif
156
157 /* The state buf must be large enough to hold one state per character in the main buffer.
158 */
159 #define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type))
160
161 #ifndef YY_TYPEDEF_YY_BUFFER_STATE
162 #define YY_TYPEDEF_YY_BUFFER_STATE
163 typedef struct yy_buffer_state *YY_BUFFER_STATE;
164 #endif
165
166 #ifndef YY_TYPEDEF_YY_SIZE_T
167 #define YY_TYPEDEF_YY_SIZE_T
168 typedef size_t yy_size_t;
169 #endif
170
171 extern int yyleng;
172
173 extern FILE *yyin, *yyout;
174
175 #define EOB_ACT_CONTINUE_SCAN 0
176 #define EOB_ACT_END_OF_FILE 1
177 #define EOB_ACT_LAST_MATCH 2
178
179 #define YY_LESS_LINENO(n)
180 #define YY_LINENO_REWIND_TO(ptr)
181
182 /* Return all but the first "n" matched characters back to the input stream. */
183 #define yyless(n) \
184 do \
185 { \
186 /* Undo effects of setting up yytext. */ \
187 int yyless_macro_arg = (n); \
188 YY_LESS_LINENO(yyless_macro_arg);\
189 *yy_cp = (yy_hold_char); \
190 YY_RESTORE_YY_MORE_OFFSET \
191 (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \
192 YY_DO_BEFORE_ACTION; /* set up yytext again */ \
193 } \
194 while ( 0 )
195 #define unput(c) yyunput( c, (yytext_ptr) )
196
197 #ifndef YY_STRUCT_YY_BUFFER_STATE
198 #define YY_STRUCT_YY_BUFFER_STATE
199 struct yy_buffer_state
200 {
201 FILE *yy_input_file;
202
203 char *yy_ch_buf; /* input buffer */
204 char *yy_buf_pos; /* current position in input buffer */
205
206 /* Size of input buffer in bytes, not including room for EOB
207 * characters.
208 */
209 int yy_buf_size;
210
211 /* Number of characters read into yy_ch_buf, not including EOB
212 * characters.
213 */
214 int yy_n_chars;
215
216 /* Whether we "own" the buffer - i.e., we know we created it,
217 * and can realloc() it to grow it, and should free() it to
218 * delete it.
219 */
220 int yy_is_our_buffer;
221
222 /* Whether this is an "interactive" input source; if so, and
223 * if we're using stdio for input, then we want to use getc()
224 * instead of fread(), to make sure we stop fetching input after
225 * each newline.
226 */
227 int yy_is_interactive;
228
229 /* Whether we're considered to be at the beginning of a line.
230 * If so, '^' rules will be active on the next match, otherwise
231 * not.
232 */
233 int yy_at_bol;
234
235 int yy_bs_lineno; /**< The line count. */
236 int yy_bs_column; /**< The column count. */
237
238 /* Whether to try to fill the input buffer when we reach the
239 * end of it.
240 */
241 int yy_fill_buffer;
242
243 int yy_buffer_status;
244
245 #define YY_BUFFER_NEW 0
246 #define YY_BUFFER_NORMAL 1
247 /* When an EOF's been seen but there's still some text to process
248 * then we mark the buffer as YY_EOF_PENDING, to indicate that we
249 * shouldn't try reading from the input source any more. We might
250 * still have a bunch of tokens to match, though, because of
251 * possible backing-up.
252 *
253 * When we actually see the EOF, we change the status to "new"
254 * (via yyrestart()), so that the user can continue scanning by
255 * just pointing yyin at a new input file.
256 */
257 #define YY_BUFFER_EOF_PENDING 2
258
259 };
260 #endif /* !YY_STRUCT_YY_BUFFER_STATE */
261
262 /* Stack of input buffers. */
263 static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */
264 static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */
265 static YY_BUFFER_STATE * yy_buffer_stack = NULL; /**< Stack as an array. */
266
267 /* We provide macros for accessing buffer states in case in the
268 * future we want to put the buffer states in a more general
269 * "scanner state".
270 *
271 * Returns the top of the stack, or NULL.
272 */
273 #define YY_CURRENT_BUFFER ( (yy_buffer_stack) \
274 ? (yy_buffer_stack)[(yy_buffer_stack_top)] \
275 : NULL)
276 /* Same as previous macro, but useful when we know that the buffer stack is not
277 * NULL or when we need an lvalue. For internal use only.
278 */
279 #define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)]
280
281 /* yy_hold_char holds the character lost when yytext is formed. */
282 static char yy_hold_char;
283 static int yy_n_chars; /* number of characters read into yy_ch_buf */
284 int yyleng;
285
286 /* Points to current character in buffer. */
287 static char *yy_c_buf_p = NULL;
288 static int yy_init = 0; /* whether we need to initialize */
289 static int yy_start = 0; /* start state number */
290
291 /* Flag which is used to allow yywrap()'s to do buffer switches
292 * instead of setting up a fresh yyin. A bit of a hack ...
293 */
294 static int yy_did_buffer_switch_on_eof;
295
296 void yyrestart ( FILE *input_file );
297 void yy_switch_to_buffer ( YY_BUFFER_STATE new_buffer );
298 YY_BUFFER_STATE yy_create_buffer ( FILE *file, int size );
299 void yy_delete_buffer ( YY_BUFFER_STATE b );
300 void yy_flush_buffer ( YY_BUFFER_STATE b );
301 void yypush_buffer_state ( YY_BUFFER_STATE new_buffer );
302 void yypop_buffer_state ( void );
303
304 static void yyensure_buffer_stack ( void );
305 static void yy_load_buffer_state ( void );
306 static void yy_init_buffer ( YY_BUFFER_STATE b, FILE *file );
307 #define YY_FLUSH_BUFFER yy_flush_buffer( YY_CURRENT_BUFFER )
308
309 YY_BUFFER_STATE yy_scan_buffer ( char *base, yy_size_t size );
310 YY_BUFFER_STATE yy_scan_string ( const char *yy_str );
311 YY_BUFFER_STATE yy_scan_bytes ( const char *bytes, int len );
312
313 void *yyalloc ( yy_size_t );
314 void *yyrealloc ( void *, yy_size_t );
315 void yyfree ( void * );
316
317 #define yy_new_buffer yy_create_buffer
318 #define yy_set_interactive(is_interactive) \
319 { \
320 if ( ! YY_CURRENT_BUFFER ){ \
321 yyensure_buffer_stack (); \
322 YY_CURRENT_BUFFER_LVALUE = \
323 yy_create_buffer( yyin, YY_BUF_SIZE ); \
324 } \
325 YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \
326 }
327 #define yy_set_bol(at_bol) \
328 { \
329 if ( ! YY_CURRENT_BUFFER ){\
330 yyensure_buffer_stack (); \
331 YY_CURRENT_BUFFER_LVALUE = \
332 yy_create_buffer( yyin, YY_BUF_SIZE ); \
333 } \
334 YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \
335 }
336 #define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol)
337
338 /* Begin user sect3 */
339
340 #define yywrap() (/*CONSTCOND*/1)
341 #define YY_SKIP_YYWRAP
342 typedef flex_uint8_t YY_CHAR;
343
344 FILE *yyin = NULL, *yyout = NULL;
345
346 typedef int yy_state_type;
347
348 extern int yylineno;
349 int yylineno = 1;
350
351 extern char *yytext;
352 #ifdef yytext_ptr
353 #undef yytext_ptr
354 #endif
355 #define yytext_ptr yytext
356
357 static const flex_int16_t yy_nxt[][13] =
358 {
359 {
360 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
361 0, 0, 0
362 },
363
364 {
365 13, 14, 14, 15, 14, 14, 14, 14, 14, 14,
366 14, 14, 14
367 },
368
369 {
370 13, 16, 16, 15, 16, 17, 16, 16, 16, 16,
371 16, 16, 16
372 },
373
374 {
375 13, 18, 19, 20, 21, 18, 18, 18, 18, 18,
376 18, 18, 18
377 },
378
379 {
380 13, 18, 19, 20, 21, 18, 18, 18, 18, 18,
381 18, 18, 18
382
383 },
384
385 {
386 13, 22, 22, 23, 22, 22, 22, 22, 22, 22,
387 22, 22, 22
388 },
389
390 {
391 13, 22, 22, 23, 22, 24, 22, 22, 22, 22,
392 22, 22, 22
393 },
394
395 {
396 13, 19, 25, 26, 19, 19, 19, 19, 19, 19,
397 19, 19, 19
398 },
399
400 {
401 13, 19, 25, 26, 19, 19, 19, 19, 19, 19,
402 19, 19, 19
403 },
404
405 {
406 13, 27, 27, 28, 29, 27, 30, 27, 27, 27,
407 27, 27, 27
408
409 },
410
411 {
412 13, 27, 27, 28, 29, 27, 30, 27, 27, 27,
413 27, 27, 27
414 },
415
416 {
417 13, 31, 32, 33, 34, 31, 31, 31, 31, 31,
418 31, 31, 31
419 },
420
421 {
422 13, 31, 32, 33, 34, 31, 31, 31, 31, 31,
423 31, 31, 31
424 },
425
426 {
427 -13, -13, -13, -13, -13, -13, -13, -13, -13, -13,
428 -13, -13, -13
429 },
430
431 {
432 13, -14, -14, -14, -14, -14, -14, -14, -14, -14,
433 -14, -14, -14
434
435 },
436
437 {
438 13, -15, -15, -15, -15, -15, -15, -15, -15, -15,
439 -15, -15, -15
440 },
441
442 {
443 13, 35, 35, -16, 35, 35, 35, 35, 35, 35,
444 35, 35, 35
445 },
446
447 {
448 13, 36, 36, 36, 36, 36, 36, 37, 36, 36,
449 38, 36, 39
450 },
451
452 {
453 13, 40, -18, -18, 41, 40, 40, 40, 40, 40,
454 40, 40, 40
455 },
456
457 {
458 13, -19, -19, -19, -19, -19, -19, -19, -19, -19,
459 -19, -19, -19
460
461 },
462
463 {
464 13, -20, -20, -20, -20, -20, -20, -20, -20, -20,
465 -20, -20, -20
466 },
467
468 {
469 13, 40, -21, -21, -21, 40, 40, 40, 40, 40,
470 40, 40, 40
471 },
472
473 {
474 13, 42, 42, -22, 42, 42, 42, 42, 42, 42,
475 42, 42, 42
476 },
477
478 {
479 13, -23, -23, -23, -23, -23, -23, -23, -23, -23,
480 -23, -23, -23
481 },
482
483 {
484 13, 42, 42, -24, 42, 43, 42, 42, 42, 42,
485 42, 42, 42
486
487 },
488
489 {
490 13, -25, 44, 45, -25, -25, -25, -25, -25, -25,
491 -25, -25, -25
492 },
493
494 {
495 13, -26, -26, -26, -26, -26, -26, -26, -26, -26,
496 -26, -26, -26
497 },
498
499 {
500 13, -27, -27, -27, -27, -27, -27, -27, -27, -27,
501 -27, -27, -27
502 },
503
504 {
505 13, -28, -28, -28, -28, -28, -28, -28, -28, -28,
506 -28, -28, -28
507 },
508
509 {
510 13, -29, -29, -29, -29, -29, 46, -29, -29, -29,
511 -29, -29, -29
512
513 },
514
515 {
516 13, -30, -30, -30, 47, -30, 46, -30, -30, -30,
517 -30, -30, -30
518 },
519
520 {
521 13, 48, -31, -31, 49, 48, 48, 48, 48, 48,
522 48, 48, 48
523 },
524
525 {
526 13, -32, 50, -32, -32, -32, -32, -32, -32, -32,
527 -32, -32, -32
528 },
529
530 {
531 13, -33, -33, -33, -33, -33, -33, -33, -33, -33,
532 -33, -33, -33
533 },
534
535 {
536 13, 48, -34, -34, -34, 48, 48, 48, 48, 48,
537 48, 48, 48
538
539 },
540
541 {
542 13, 35, 35, -35, 35, 35, 35, 35, 35, 35,
543 35, 35, 35
544 },
545
546 {
547 13, 51, 51, -36, 51, 51, 51, 51, 51, 51,
548 51, 51, 51
549 },
550
551 {
552 13, 51, 51, -37, 51, 51, 51, 51, 52, 51,
553 51, 51, 51
554 },
555
556 {
557 13, 53, 53, 53, 53, 53, 53, 53, 53, 54,
558 53, 53, 53
559 },
560
561 {
562 13, 55, 55, 55, 55, 55, 55, 55, 55, 55,
563 55, 56, 55
564
565 },
566
567 {
568 13, 40, -40, -40, 41, 40, 40, 40, 40, 40,
569 40, 40, 40
570 },
571
572 {
573 13, -41, -41, -41, -41, -41, -41, -41, -41, -41,
574 -41, -41, -41
575 },
576
577 {
578 13, 42, 42, -42, 42, 42, 42, 42, 42, 42,
579 42, 42, 42
580 },
581
582 {
583 13, 57, 57, -43, 57, 57, 57, 57, 57, 57,
584 57, 57, 57
585 },
586
587 {
588 13, -44, 44, 45, -44, -44, -44, -44, -44, -44,
589 -44, -44, -44
590
591 },
592
593 {
594 13, -45, -45, -45, -45, -45, -45, -45, -45, -45,
595 -45, -45, -45
596 },
597
598 {
599 13, -46, -46, -46, 47, -46, 46, -46, -46, -46,
600 -46, -46, -46
601 },
602
603 {
604 13, -47, -47, -47, -47, -47, -47, -47, -47, -47,
605 -47, -47, -47
606 },
607
608 {
609 13, 48, -48, -48, 49, 48, 48, 48, 48, 48,
610 48, 48, 48
611 },
612
613 {
614 13, -49, -49, -49, -49, -49, -49, -49, -49, -49,
615 -49, -49, -49
616
617 },
618
619 {
620 13, -50, 50, -50, -50, -50, -50, -50, -50, -50,
621 -50, -50, -50
622 },
623
624 {
625 13, 51, 51, -51, 51, 51, 51, 51, 51, 51,
626 51, 51, 51
627 },
628
629 {
630 13, 58, 59, -52, 58, 58, 58, 58, 58, 58,
631 58, 58, 58
632 },
633
634 {
635 13, 60, 60, -53, 60, 60, 60, 60, 60, 60,
636 60, 60, 60
637 },
638
639 {
640 13, -54, 61, -54, -54, -54, -54, -54, -54, -54,
641 -54, -54, -54
642
643 },
644
645 {
646 13, 62, 62, -55, 62, 62, 62, 62, 62, 62,
647 62, 62, 62
648 },
649
650 {
651 13, -56, 63, -56, -56, -56, -56, -56, -56, -56,
652 -56, -56, -56
653 },
654
655 {
656 13, 57, 57, -57, 57, 57, 57, 57, 57, 57,
657 57, 57, 57
658 },
659
660 {
661 13, 58, 58, -58, 58, 58, 58, 58, 58, 58,
662 58, 58, 58
663 },
664
665 {
666 13, 58, 59, -59, 58, 58, 58, 58, 58, 58,
667 58, 58, 58
668
669 },
670
671 {
672 13, 60, 60, -60, 60, 60, 60, 60, 60, 60,
673 60, 60, 60
674 },
675
676 {
677 13, -61, 61, -61, -61, -61, -61, -61, -61, -61,
678 -61, -61, -61
679 },
680
681 {
682 13, 62, 62, -62, 62, 62, 62, 62, 62, 62,
683 62, 62, 62
684 },
685
686 {
687 13, -63, 63, -63, -63, -63, -63, -63, -63, -63,
688 -63, -63, -63
689 },
690
691 } ;
692
693 static yy_state_type yy_get_previous_state ( void );
694 static yy_state_type yy_try_NUL_trans ( yy_state_type current_state );
695 static int yy_get_next_buffer ( void );
696 static void yynoreturn yy_fatal_error ( const char* msg );
697
698 /* Done after the current pattern has been matched and before the
699 * corresponding action - sets up yytext.
700 */
701 #define YY_DO_BEFORE_ACTION \
702 (yytext_ptr) = yy_bp; \
703 yyleng = (int) (yy_cp - yy_bp); \
704 (yy_hold_char) = *yy_cp; \
705 *yy_cp = '\0'; \
706 (yy_c_buf_p) = yy_cp;
707 #define YY_NUM_RULES 24
708 #define YY_END_OF_BUFFER 25
709 /* This struct is not used in this scanner,
710 but its presence is necessary. */
711 struct yy_trans_info
712 {
713 flex_int32_t yy_verify;
714 flex_int32_t yy_nxt;
715 };
716 static const flex_int16_t yy_accept[64] =
717 { 0,
718 0, 0, 0, 0, 16, 16, 0, 0, 0, 0,
719 0, 0, 25, 10, 11, 4, 10, 12, 24, 14,
720 24, 16, 17, 16, 24, 13, 22, 23, 22, 18,
721 19, 20, 21, 22, 4, 5, 5, 9, 8, 12,
722 12, 16, 15, 0, 13, 18, 18, 19, 19, 20,
723 5, 5, 6, 3, 7, 2, 15, 1, 1, 6,
724 3, 7, 2
725 } ;
726
727 static const YY_CHAR yy_ec[256] =
728 { 0,
729 1, 1, 1, 1, 1, 1, 1, 1, 2, 3,
730 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
731 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
732 1, 2, 1, 4, 1, 1, 1, 1, 1, 1,
733 1, 1, 1, 1, 1, 5, 1, 6, 6, 6,
734 6, 6, 6, 6, 6, 6, 6, 1, 1, 1,
735 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
736 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
737 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
738 1, 1, 1, 1, 1, 1, 1, 1, 1, 7,
739
740 8, 9, 1, 1, 1, 1, 1, 10, 1, 1,
741 11, 1, 1, 1, 12, 1, 1, 1, 1, 1,
742 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
743 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
744 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
745 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
746 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
747 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
748 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
749 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
750
751 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
752 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
753 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
754 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
755 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
756 1, 1, 1, 1, 1
757 } ;
758
759 static yy_state_type yy_last_accepting_state;
760 static char *yy_last_accepting_cpos;
761
762 extern int yy_flex_debug;
763 int yy_flex_debug = 0;
764
765 /* The intent behind this definition is that it'll catch
766 * any uses of REJECT which flex missed.
767 */
768 #define REJECT reject_used_but_not_detected
769 #define yymore() yymore_used_but_not_detected
770 #define YY_MORE_ADJ 0
771 #define YY_RESTORE_YY_MORE_OFFSET
772 char *yytext;
773 #line 1 "zsoelim.l"
774
775 #line 19 "zsoelim.l"
776
777 /*
778 * zsoelim.l: eliminate .so includes within *roff source
779 *
780 * Copyright (C) 1994, 1995 Graeme W. Wilford. (Wilf.)
781 * Copyright (C) 1997 Fabrizio Polacco.
782 * Copyright (C) 2001, 2002, 2003, 2004, 2006, 2007, 2008, 2009, 2010, 2011
783 * Colin Watson.
784 *
785 * This file is part of man-db.
786 *
787 * man-db is free software; you can redistribute it and/or modify it
788 * under the terms of the GNU General Public License as published by
789 * the Free Software Foundation; either version 2 of the License, or
790 * (at your option) any later version.
791 *
792 * man-db is distributed in the hope that it will be useful, but
793 * WITHOUT ANY WARRANTY; without even the implied warranty of
794 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
795 * GNU General Public License for more details.
796 *
797 * You should have received a copy of the GNU General Public License
798 * along with man-db; if not, write to the Free Software Foundation,
799 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
800 *
801 * Added functionality over gsoelim to allow for compressed .so includes.
802 * This is required as the first *roff preprocessor in order to deal with
803 * 100% of compressed source files correctly. A replacement tmac.andoc was
804 * considered, but would not have been portable to all systems.
805 *
806 * Wed Oct 12 18:46:11 BST 1994 Wilf. (G.Wilford@ee.surrey.ac.uk)
807 *
808 * Tue, 14 Oct 1997 Fabrizio Polacco <fpolacco@debian.org>
809 * - added changes that were done to .c instead of -l source
810 * - added new start condition to avoid execution of .so requests
811 * inside a macro definition.
812 */
813
814 #define MAX_SO_DEPTH 10 /* max .so recursion depth */
815 #undef ACCEPT_QUOTES /* accept quoted roff requests */
816
817 #include <assert.h>
818 #include <stdbool.h>
819 #include <string.h>
820 #include <stdlib.h>
821 #include <unistd.h>
822 #include <sys/types.h>
823 #include <sys/stat.h>
824 #include <fcntl.h>
825 #include <errno.h>
826
827 #define NAME so_name[so_stack_ptr]
828 #define LINE so_line[so_stack_ptr]
829 #define PIPE so_pipe[so_stack_ptr]
830
831 #include "dirname.h"
832 #include "error.h"
833 #include "gl_linkedhash_list.h"
834 #include "gl_xlist.h"
835 #include "xalloc.h"
836 #include "xgetcwd.h"
837 #include "xvasprintf.h"
838
839 #include "gettext.h"
840 #include <locale.h>
841 #define _(String) gettext (String)
842
843 #include "appendstr.h"
844 #include "compression.h"
845 #include "debug.h"
846 #include "fatal.h"
847 #include "glcontainers.h"
848
849 #include "decompress.h"
850 #include "globbing.h"
851 #include "zsoelim.h"
852
853 #ifdef ACCEPT_QUOTES
854 # define ZAP_QUOTES zap_quotes ()
855 static void zap_quotes (void);
856 #else
857 # define ZAP_QUOTES
858 #endif
859
860 static YY_BUFFER_STATE so_stack[MAX_SO_DEPTH];
861 static char *so_name[MAX_SO_DEPTH];
862 static int so_line[MAX_SO_DEPTH];
863 static decompress *so_pipe[MAX_SO_DEPTH];
864 static int so_stack_ptr;
865 static bool no_newline;
866 static gl_list_t so_manpathlist;
867 static const char *so_parent_path;
868
869 struct zsoelim_stdin_data {
870 char *path;
871 gl_list_t manpathlist;
872 };
873
874 /* The flex documentation says that yyin is only used by YY_INPUT, so we
875 * should safely be able to abuse it as a handy way to keep track of the
876 * current 'decompress *' rather than the usual 'FILE *'.
877 */
878 #define YY_INPUT(buf,result,max_size) { \
879 size_t size = max_size; \
880 const char *block = decompress_read ((decompress *) yyin, &size); \
881 if (block && size != 0) { \
882 memcpy (buf, block, size); \
883 buf[size] = '\0'; \
884 result = size; \
885 } else \
886 result = YY_NULL; \
887 }
888 #define YY_NO_INPUT
889 #line 890 "zsoelim.c"
890
891 #line 892 "zsoelim.c"
892
893 #define INITIAL 0
894 #define so 1
895 #define de 2
896 #define end_request 3
897 #define lfnumber 4
898 #define lfname 5
899
900 #ifndef YY_NO_UNISTD_H
901 /* Special case for "unistd.h", since it is non-ANSI. We include it way
902 * down here because we want the user's section 1 to have been scanned first.
903 * The user has a chance to override it with an option.
904 */
905 #include <unistd.h>
906 #endif
907
908 #ifndef YY_EXTRA_TYPE
909 #define YY_EXTRA_TYPE void *
910 #endif
911
912 static int yy_init_globals ( void );
913
914 /* Accessor methods to globals.
915 These are made visible to non-reentrant scanners for convenience. */
916
917 int yylex_destroy ( void );
918
919 int yyget_debug ( void );
920
921 void yyset_debug ( int debug_flag );
922
923 YY_EXTRA_TYPE yyget_extra ( void );
924
925 void yyset_extra ( YY_EXTRA_TYPE user_defined );
926
927 FILE *yyget_in ( void );
928
929 void yyset_in ( FILE * _in_str );
930
931 FILE *yyget_out ( void );
932
933 void yyset_out ( FILE * _out_str );
934
935 int yyget_leng ( void );
936
937 char *yyget_text ( void );
938
939 int yyget_lineno ( void );
940
941 void yyset_lineno ( int _line_number );
942
943 /* Macros after this point can all be overridden by user definitions in
944 * section 1.
945 */
946
947 #ifndef YY_SKIP_YYWRAP
948 #ifdef __cplusplus
949 extern "C" int yywrap ( void );
950 #else
951 extern int yywrap ( void );
952 #endif
953 #endif
954
955 #ifndef YY_NO_UNPUT
956
957 #endif
958
959 #ifndef yytext_ptr
960 static void yy_flex_strncpy ( char *, const char *, int );
961 #endif
962
963 #ifdef YY_NEED_STRLEN
964 static int yy_flex_strlen ( const char * );
965 #endif
966
967 #ifndef YY_NO_INPUT
968 #ifdef __cplusplus
969 static int yyinput ( void );
970 #else
971 static int input ( void );
972 #endif
973
974 #endif
975
976 /* Amount of stuff to slurp up with each read. */
977 #ifndef YY_READ_BUF_SIZE
978 #ifdef __ia64__
979 /* On IA-64, the buffer size is 16k, not 8k */
980 #define YY_READ_BUF_SIZE 16384
981 #else
982 #define YY_READ_BUF_SIZE 8192
983 #endif /* __ia64__ */
984 #endif
985
986 /* Copy whatever the last rule matched to the standard output. */
987 #ifndef ECHO
988 /* This used to be an fputs(), but since the string might contain NUL's,
989 * we now use fwrite().
990 */
991 #define ECHO do { if (fwrite( yytext, (size_t) yyleng, 1, yyout )) {} } while (0)
992 #endif
993
994 /* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
995 * is returned in "result".
996 */
997 #ifndef YY_INPUT
998 #define YY_INPUT(buf,result,max_size) \
999 if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
1000 { \
1001 int c = '*'; \
1002 int n; \
1003 for ( n = 0; n < max_size && \
1004 (c = getc( yyin )) != EOF && c != '\n'; ++n ) \
1005 buf[n] = (char) c; \
1006 if ( c == '\n' ) \
1007 buf[n++] = (char) c; \
1008 if ( c == EOF && ferror( yyin ) ) \
1009 YY_FATAL_ERROR( "input in flex scanner failed" ); \
1010 result = n; \
1011 } \
1012 else \
1013 { \
1014 errno=0; \
1015 while ( (result = (int) fread(buf, 1, (yy_size_t) max_size, yyin)) == 0 && ferror(yyin)) \
1016 { \
1017 if( errno != EINTR) \
1018 { \
1019 YY_FATAL_ERROR( "input in flex scanner failed" ); \
1020 break; \
1021 } \
1022 errno=0; \
1023 clearerr(yyin); \
1024 } \
1025 }\
1026 \
1027
1028 #endif
1029
1030 /* No semi-colon after return; correct usage is to write "yyterminate();" -
1031 * we don't want an extra ';' after the "return" because that will cause
1032 * some compilers to complain about unreachable statements.
1033 */
1034 #ifndef yyterminate
1035 #define yyterminate() return YY_NULL
1036 #endif
1037
1038 /* Number of entries by which start-condition stack grows. */
1039 #ifndef YY_START_STACK_INCR
1040 #define YY_START_STACK_INCR 25
1041 #endif
1042
1043 /* Report a fatal error. */
1044 #ifndef YY_FATAL_ERROR
1045 #define YY_FATAL_ERROR(msg) yy_fatal_error( msg )
1046 #endif
1047
1048 /* end tables serialization structures and prototypes */
1049
1050 /* Default declaration of generated scanner - a define so the user can
1051 * easily add parameters.
1052 */
1053 #ifndef YY_DECL
1054 #define YY_DECL_IS_OURS 1
1055
1056 extern int yylex (void);
1057
1058 #define YY_DECL int yylex (void)
1059 #endif /* !YY_DECL */
1060
1061 /* Code executed at the beginning of each rule, after yytext and yyleng
1062 * have been set up.
1063 */
1064 #ifndef YY_USER_ACTION
1065 #define YY_USER_ACTION
1066 #endif
1067
1068 /* Code executed at the end of each rule. */
1069 #ifndef YY_BREAK
1070 #define YY_BREAK /*LINTED*/break;
1071 #endif
1072
1073 #define YY_RULE_SETUP \
1074 if ( yyleng > 0 ) \
1075 YY_CURRENT_BUFFER_LVALUE->yy_at_bol = \
1076 (yytext[yyleng - 1] == '\n'); \
1077 YY_USER_ACTION
1078
1079 /** The main scanner function which does all the work.
1080 */
1081 YY_DECL
1082 {
1083 yy_state_type yy_current_state;
1084 char *yy_cp, *yy_bp;
1085 int yy_act;
1086
1087 if ( !(yy_init) )
1088 {
1089 (yy_init) = 1;
1090
1091 #ifdef YY_USER_INIT
1092 YY_USER_INIT;
1093 #endif
1094
1095 if ( ! (yy_start) )
1096 (yy_start) = 1; /* first start state */
1097
1098 if ( ! yyin )
1099 yyin = stdin;
1100
1101 if ( ! yyout )
1102 yyout = stdout;
1103
1104 if ( ! YY_CURRENT_BUFFER ) {
1105 yyensure_buffer_stack ();
1106 YY_CURRENT_BUFFER_LVALUE =
1107 yy_create_buffer( yyin, YY_BUF_SIZE );
1108 }
1109
1110 yy_load_buffer_state( );
1111 }
1112
1113 {
1114 #line 146 "zsoelim.l"
1115
1116
1117 #line 1118 "zsoelim.c"
1118
1119 while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */
1120 {
1121 yy_cp = (yy_c_buf_p);
1122
1123 /* Support of yytext. */
1124 *yy_cp = (yy_hold_char);
1125
1126 /* yy_bp points to the position in yy_ch_buf of the start of
1127 * the current run.
1128 */
1129 yy_bp = yy_cp;
1130
1131 yy_current_state = (yy_start);
1132 yy_current_state += YY_AT_BOL();
1133 yy_match:
1134 while ( (yy_current_state = yy_nxt[yy_current_state][ yy_ec[YY_SC_TO_UI(*yy_cp)] ]) > 0 )
1135 {
1136 if ( yy_accept[yy_current_state] )
1137 {
1138 (yy_last_accepting_state) = yy_current_state;
1139 (yy_last_accepting_cpos) = yy_cp;
1140 }
1141
1142 ++yy_cp;
1143 }
1144
1145 yy_current_state = -yy_current_state;
1146
1147 yy_find_action:
1148 yy_act = yy_accept[yy_current_state];
1149
1150 YY_DO_BEFORE_ACTION;
1151
1152 do_action: /* This label is used only to access EOF actions. */
1153
1154 switch ( yy_act )
1155 { /* beginning of action switch */
1156 case 0: /* must back up */
1157 /* undo the effects of YY_DO_BEFORE_ACTION */
1158 *yy_cp = (yy_hold_char);
1159 yy_cp = (yy_last_accepting_cpos) + 1;
1160 yy_current_state = (yy_last_accepting_state);
1161 goto yy_find_action;
1162
1163 case 1:
1164 YY_RULE_SETUP
1165 #line 148 "zsoelim.l"
1166 {
1167 no_newline = true;
1168 ECHO;
1169 BEGIN (de); /* Now we're inside of a macro definition: ends with a comment */
1170 }
1171 YY_BREAK
1172 case 2:
1173 YY_RULE_SETUP
1174 #line 154 "zsoelim.l"
1175 {
1176 no_newline = true;
1177 BEGIN (so); /* Now we're in the .so environment */
1178 }
1179 YY_BREAK
1180 case 3:
1181 YY_RULE_SETUP
1182 #line 159 "zsoelim.l"
1183 {
1184 no_newline = true;
1185 ECHO; /* Now we're in the .lf environment */
1186 BEGIN (lfnumber);
1187 }
1188 YY_BREAK
1189 case 4:
1190 #line 166 "zsoelim.l"
1191 case 5:
1192 /* rule 5 can match eol */
1193 #line 167 "zsoelim.l"
1194 case 6:
1195 /* rule 6 can match eol */
1196 #line 168 "zsoelim.l"
1197 case 7:
1198 /* rule 7 can match eol */
1199 #line 169 "zsoelim.l"
1200 case 8:
1201 /* rule 8 can match eol */
1202 #line 170 "zsoelim.l"
1203 case 9:
1204 /* rule 9 can match eol */
1205 #line 171 "zsoelim.l"
1206 case 10:
1207 /* rule 10 can match eol */
1208 YY_RULE_SETUP
1209 #line 171 "zsoelim.l"
1210 {
1211 no_newline = true;
1212 ECHO;
1213 }
1214 YY_BREAK
1215 case 11:
1216 /* rule 11 can match eol */
1217 YY_RULE_SETUP
1218 #line 176 "zsoelim.l"
1219 {
1220 no_newline = false;
1221 putchar ('\n');
1222 LINE++;
1223 }
1224 YY_BREAK
1225 case 12:
1226 YY_RULE_SETUP
1227 #line 183 "zsoelim.l"
1228 { /* file names including whitespace ? */
1229 if (so_stack_ptr == MAX_SO_DEPTH - 1)
1230 fatal (0,
1231 _("%s:%d: .so requests nested too "
1232 "deeply or are recursive"),
1233 NAME, LINE);
1234
1235 ZAP_QUOTES;
1236 so_stack[so_stack_ptr++] = YY_CURRENT_BUFFER;
1237 LINE = 1;
1238
1239 no_newline = false;
1240
1241 if (zsoelim_open_file (yytext, so_manpathlist,
1242 so_parent_path)) {
1243 --so_stack_ptr;
1244 #ifndef __alpha
1245 error (OK, 0,
1246 _("%s:%d: warning: failed .so request"),
1247 NAME, LINE);
1248 printf (".so %s\n", yytext);
1249 #endif
1250 BEGIN (end_request);
1251 } else {
1252 printf (".lf 1 %s\n", yytext);
1253 yy_switch_to_buffer
1254 (yy_create_buffer (yyin, YY_BUF_SIZE));
1255 BEGIN (INITIAL);
1256 }
1257
1258 }
1259 YY_BREAK
1260 case 13:
1261 /* rule 13 can match eol */
1262 YY_RULE_SETUP
1263 #line 215 "zsoelim.l"
1264 {
1265 no_newline = false;
1266 BEGIN (INITIAL);
1267 }
1268 YY_BREAK
1269 case 14:
1270 /* rule 14 can match eol */
1271 YY_RULE_SETUP
1272 #line 220 "zsoelim.l"
1273 {
1274 no_newline = false;
1275 error (OK, 0,
1276 _("%s:%d: warning: newline in .so request, "
1277 "ignoring"),
1278 NAME, LINE);
1279 putchar ('\n');
1280 LINE++;
1281 BEGIN (INITIAL);
1282 }
1283 YY_BREAK
1284 case 15:
1285 YY_RULE_SETUP
1286 #line 231 "zsoelim.l"
1287 {
1288 no_newline = true;
1289 ECHO;
1290 BEGIN (INITIAL);
1291 }
1292 YY_BREAK
1293 case 16:
1294 YY_RULE_SETUP
1295 #line 237 "zsoelim.l"
1296 {
1297 no_newline = true;
1298 ECHO;
1299 }
1300 YY_BREAK
1301 case 17:
1302 /* rule 17 can match eol */
1303 YY_RULE_SETUP
1304 #line 242 "zsoelim.l"
1305 {
1306 no_newline = false;
1307 putchar ('\n');
1308 LINE++;
1309 }
1310 YY_BREAK
1311 case 18:
1312 YY_RULE_SETUP
1313 #line 249 "zsoelim.l"
1314 {
1315 no_newline = true;
1316 ECHO;
1317 ZAP_QUOTES;
1318 LINE = atoi (yytext);
1319 BEGIN (lfname);
1320 }
1321 YY_BREAK
1322 case 19:
1323 YY_RULE_SETUP
1324 #line 257 "zsoelim.l"
1325 { /* file names including whitespace ?? */
1326 no_newline = true;
1327 ECHO;
1328 putchar ('\n');
1329 ZAP_QUOTES;
1330 if (NAME)
1331 free (NAME);
1332 NAME = xstrdup (yytext);
1333 BEGIN (end_request);
1334 }
1335 YY_BREAK
1336 case 20:
1337 YY_RULE_SETUP
1338 #line 268 "zsoelim.l"
1339 {
1340 no_newline = true;
1341 ECHO;
1342 }
1343 YY_BREAK
1344 case 21:
1345 /* rule 21 can match eol */
1346 YY_RULE_SETUP
1347 #line 273 "zsoelim.l"
1348 {
1349 no_newline = false;
1350 putchar ('\n');
1351 LINE++;
1352 BEGIN (INITIAL);
1353 }
1354 YY_BREAK
1355 case 22:
1356 YY_RULE_SETUP
1357 #line 280 "zsoelim.l"
1358 {
1359 no_newline = true;
1360 debug (
1361 "%s:%d: warning: unhandled .lf request; "
1362 "line numbers may be wrong\n",
1363 NAME, LINE);
1364 putchar (*yytext);
1365 BEGIN (INITIAL);
1366 }
1367 YY_BREAK
1368 case 23:
1369 /* rule 23 can match eol */
1370 YY_RULE_SETUP
1371 #line 290 "zsoelim.l"
1372 {
1373 no_newline = false;
1374 error (OK, 0,
1375 _("%s:%d: warning: newline in .lf request, "
1376 "ignoring"),
1377 NAME, LINE);
1378 putchar ('\n');
1379 LINE++;
1380 BEGIN (INITIAL);
1381 }
1382 YY_BREAK
1383 case YY_STATE_EOF(INITIAL):
1384 case YY_STATE_EOF(so):
1385 case YY_STATE_EOF(de):
1386 case YY_STATE_EOF(end_request):
1387 case YY_STATE_EOF(lfnumber):
1388 case YY_STATE_EOF(lfname):
1389 #line 301 "zsoelim.l"
1390 {
1391 decompress_wait (PIPE);
1392 decompress_free (PIPE);
1393 PIPE = NULL;
1394 free (NAME);
1395 NAME = NULL;
1396
1397 if (no_newline)
1398 putchar ('\n');
1399
1400 if (--so_stack_ptr < 0) {
1401 yyterminate ();
1402 } else {
1403 yy_delete_buffer (YY_CURRENT_BUFFER);
1404 yy_switch_to_buffer (so_stack[so_stack_ptr]);
1405 printf (".lf %d %s\n", LINE += 1, NAME);
1406 }
1407 no_newline = false;
1408 BEGIN (end_request);
1409 }
1410 YY_BREAK
1411 case 24:
1412 YY_RULE_SETUP
1413 #line 321 "zsoelim.l"
1414 ECHO;
1415 YY_BREAK
1416 #line 1417 "zsoelim.c"
1417
1418 case YY_END_OF_BUFFER:
1419 {
1420 /* Amount of text matched not including the EOB char. */
1421 int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1;
1422
1423 /* Undo the effects of YY_DO_BEFORE_ACTION. */
1424 *yy_cp = (yy_hold_char);
1425 YY_RESTORE_YY_MORE_OFFSET
1426
1427 if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW )
1428 {
1429 /* We're scanning a new file or input source. It's
1430 * possible that this happened because the user
1431 * just pointed yyin at a new source and called
1432 * yylex(). If so, then we have to assure
1433 * consistency between YY_CURRENT_BUFFER and our
1434 * globals. Here is the right place to do so, because
1435 * this is the first action (other than possibly a
1436 * back-up) that will match for the new input source.
1437 */
1438 (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
1439 YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin;
1440 YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL;
1441 }
1442
1443 /* Note that here we test for yy_c_buf_p "<=" to the position
1444 * of the first EOB in the buffer, since yy_c_buf_p will
1445 * already have been incremented past the NUL character
1446 * (since all states make transitions on EOB to the
1447 * end-of-buffer state). Contrast this with the test
1448 * in input().
1449 */
1450 if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
1451 { /* This was really a NUL. */
1452 yy_state_type yy_next_state;
1453
1454 (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text;
1455
1456 yy_current_state = yy_get_previous_state( );
1457
1458 /* Okay, we're now positioned to make the NUL
1459 * transition. We couldn't have
1460 * yy_get_previous_state() go ahead and do it
1461 * for us because it doesn't know how to deal
1462 * with the possibility of jamming (and we don't
1463 * want to build jamming into it because then it
1464 * will run more slowly).
1465 */
1466
1467 yy_next_state = yy_try_NUL_trans( yy_current_state );
1468
1469 yy_bp = (yytext_ptr) + YY_MORE_ADJ;
1470
1471 if ( yy_next_state )
1472 {
1473 /* Consume the NUL. */
1474 yy_cp = ++(yy_c_buf_p);
1475 yy_current_state = yy_next_state;
1476 goto yy_match;
1477 }
1478
1479 else
1480 {
1481 yy_cp = (yy_c_buf_p);
1482 goto yy_find_action;
1483 }
1484 }
1485
1486 else switch ( yy_get_next_buffer( ) )
1487 {
1488 case EOB_ACT_END_OF_FILE:
1489 {
1490 (yy_did_buffer_switch_on_eof) = 0;
1491
1492 if ( yywrap( ) )
1493 {
1494 /* Note: because we've taken care in
1495 * yy_get_next_buffer() to have set up
1496 * yytext, we can now set up
1497 * yy_c_buf_p so that if some total
1498 * hoser (like flex itself) wants to
1499 * call the scanner after we return the
1500 * YY_NULL, it'll still work - another
1501 * YY_NULL will get returned.
1502 */
1503 (yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ;
1504
1505 yy_act = YY_STATE_EOF(YY_START);
1506 goto do_action;
1507 }
1508
1509 else
1510 {
1511 if ( ! (yy_did_buffer_switch_on_eof) )
1512 YY_NEW_FILE;
1513 }
1514 break;
1515 }
1516
1517 case EOB_ACT_CONTINUE_SCAN:
1518 (yy_c_buf_p) =
1519 (yytext_ptr) + yy_amount_of_matched_text;
1520
1521 yy_current_state = yy_get_previous_state( );
1522
1523 yy_cp = (yy_c_buf_p);
1524 yy_bp = (yytext_ptr) + YY_MORE_ADJ;
1525 goto yy_match;
1526
1527 case EOB_ACT_LAST_MATCH:
1528 (yy_c_buf_p) =
1529 &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)];
1530
1531 yy_current_state = yy_get_previous_state( );
1532
1533 yy_cp = (yy_c_buf_p);
1534 yy_bp = (yytext_ptr) + YY_MORE_ADJ;
1535 goto yy_find_action;
1536 }
1537 break;
1538 }
1539
1540 default:
1541 YY_FATAL_ERROR(
1542 "fatal flex scanner internal error--no action found" );
1543 } /* end of action switch */
1544 } /* end of scanning one token */
1545 } /* end of user's declarations */
1546 } /* end of yylex */
1547
1548 /* yy_get_next_buffer - try to read in a new buffer
1549 *
1550 * Returns a code representing an action:
1551 * EOB_ACT_LAST_MATCH -
1552 * EOB_ACT_CONTINUE_SCAN - continue scanning from current position
1553 * EOB_ACT_END_OF_FILE - end of file
1554 */
1555 static int yy_get_next_buffer (void)
1556 {
1557 char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
1558 char *source = (yytext_ptr);
1559 int number_to_move, i;
1560 int ret_val;
1561
1562 if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] )
1563 YY_FATAL_ERROR(
1564 "fatal flex scanner internal error--end of buffer missed" );
1565
1566 if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 )
1567 { /* Don't try to fill the buffer, so this is an EOF. */
1568 if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 )
1569 {
1570 /* We matched a single character, the EOB, so
1571 * treat this as a final EOF.
1572 */
1573 return EOB_ACT_END_OF_FILE;
1574 }
1575
1576 else
1577 {
1578 /* We matched some text prior to the EOB, first
1579 * process it.
1580 */
1581 return EOB_ACT_LAST_MATCH;
1582 }
1583 }
1584
1585 /* Try to read more data. */
1586
1587 /* First move last chars to start of buffer. */
1588 number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr) - 1);
1589
1590 for ( i = 0; i < number_to_move; ++i )
1591 *(dest++) = *(source++);
1592
1593 if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING )
1594 /* don't do the read, it's not guaranteed to return an EOF,
1595 * just force an EOF
1596 */
1597 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0;
1598
1599 else
1600 {
1601 int num_to_read =
1602 YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
1603
1604 while ( num_to_read <= 0 )
1605 { /* Not enough room in the buffer - grow it. */
1606
1607 /* just a shorter name for the current buffer */
1608 YY_BUFFER_STATE b = YY_CURRENT_BUFFER_LVALUE;
1609
1610 int yy_c_buf_p_offset =
1611 (int) ((yy_c_buf_p) - b->yy_ch_buf);
1612
1613 if ( b->yy_is_our_buffer )
1614 {
1615 int new_size = b->yy_buf_size * 2;
1616
1617 if ( new_size <= 0 )
1618 b->yy_buf_size += b->yy_buf_size / 8;
1619 else
1620 b->yy_buf_size *= 2;
1621
1622 b->yy_ch_buf = (char *)
1623 /* Include room in for 2 EOB chars. */
1624 yyrealloc( (void *) b->yy_ch_buf,
1625 (yy_size_t) (b->yy_buf_size + 2) );
1626 }
1627 else
1628 /* Can't grow it, we don't own it. */
1629 b->yy_ch_buf = NULL;
1630
1631 if ( ! b->yy_ch_buf )
1632 YY_FATAL_ERROR(
1633 "fatal error - scanner input buffer overflow" );
1634
1635 (yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset];
1636
1637 num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size -
1638 number_to_move - 1;
1639
1640 }
1641
1642 if ( num_to_read > YY_READ_BUF_SIZE )
1643 num_to_read = YY_READ_BUF_SIZE;
1644
1645 /* Read in more data. */
1646 YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]),
1647 (yy_n_chars), num_to_read );
1648
1649 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
1650 }
1651
1652 if ( (yy_n_chars) == 0 )
1653 {
1654 if ( number_to_move == YY_MORE_ADJ )
1655 {
1656 ret_val = EOB_ACT_END_OF_FILE;
1657 yyrestart( yyin );
1658 }
1659
1660 else
1661 {
1662 ret_val = EOB_ACT_LAST_MATCH;
1663 YY_CURRENT_BUFFER_LVALUE->yy_buffer_status =
1664 YY_BUFFER_EOF_PENDING;
1665 }
1666 }
1667
1668 else
1669 ret_val = EOB_ACT_CONTINUE_SCAN;
1670
1671 if (((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {
1672 /* Extend the array by 50%, plus the number we really need. */
1673 int new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1);
1674 YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc(
1675 (void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf, (yy_size_t) new_size );
1676 if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
1677 YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" );
1678 /* "- 2" to take care of EOB's */
1679 YY_CURRENT_BUFFER_LVALUE->yy_buf_size = (int) (new_size - 2);
1680 }
1681
1682 (yy_n_chars) += number_to_move;
1683 YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR;
1684 YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR;
1685
1686 (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0];
1687
1688 return ret_val;
1689 }
1690
1691 /* yy_get_previous_state - get the state just before the EOB char was reached */
1692
1693 static yy_state_type yy_get_previous_state (void)
1694 {
1695 yy_state_type yy_current_state;
1696 char *yy_cp;
1697
1698 yy_current_state = (yy_start);
1699 yy_current_state += YY_AT_BOL();
1700
1701 for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp )
1702 {
1703 yy_current_state = yy_nxt[yy_current_state][(*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1)];
1704 if ( yy_accept[yy_current_state] )
1705 {
1706 (yy_last_accepting_state) = yy_current_state;
1707 (yy_last_accepting_cpos) = yy_cp;
1708 }
1709 }
1710
1711 return yy_current_state;
1712 }
1713
1714 /* yy_try_NUL_trans - try to make a transition on the NUL character
1715 *
1716 * synopsis
1717 * next_state = yy_try_NUL_trans( current_state );
1718 */
1719 static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state )
1720 {
1721 int yy_is_jam;
1722 char *yy_cp = (yy_c_buf_p);
1723
1724 yy_current_state = yy_nxt[yy_current_state][1];
1725 yy_is_jam = (yy_current_state <= 0);
1726
1727 if ( ! yy_is_jam )
1728 {
1729 if ( yy_accept[yy_current_state] )
1730 {
1731 (yy_last_accepting_state) = yy_current_state;
1732 (yy_last_accepting_cpos) = yy_cp;
1733 }
1734 }
1735
1736 return yy_is_jam ? 0 : yy_current_state;
1737 }
1738
1739 #ifndef YY_NO_UNPUT
1740
1741 #endif
1742
1743 #ifndef YY_NO_INPUT
1744 #ifdef __cplusplus
1745 static int yyinput (void)
1746 #else
1747 static int input (void)
1748 #endif
1749
1750 {
1751 int c;
1752
1753 *(yy_c_buf_p) = (yy_hold_char);
1754
1755 if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR )
1756 {
1757 /* yy_c_buf_p now points to the character we want to return.
1758 * If this occurs *before* the EOB characters, then it's a
1759 * valid NUL; if not, then we've hit the end of the buffer.
1760 */
1761 if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
1762 /* This was really a NUL. */
1763 *(yy_c_buf_p) = '\0';
1764
1765 else
1766 { /* need more input */
1767 int offset = (int) ((yy_c_buf_p) - (yytext_ptr));
1768 ++(yy_c_buf_p);
1769
1770 switch ( yy_get_next_buffer( ) )
1771 {
1772 case EOB_ACT_LAST_MATCH:
1773 /* This happens because yy_g_n_b()
1774 * sees that we've accumulated a
1775 * token and flags that we need to
1776 * try matching the token before
1777 * proceeding. But for input(),
1778 * there's no matching to consider.
1779 * So convert the EOB_ACT_LAST_MATCH
1780 * to EOB_ACT_END_OF_FILE.
1781 */
1782
1783 /* Reset buffer status. */
1784 yyrestart( yyin );
1785
1786 /*FALLTHROUGH*/
1787
1788 case EOB_ACT_END_OF_FILE:
1789 {
1790 if ( yywrap( ) )
1791 return 0;
1792
1793 if ( ! (yy_did_buffer_switch_on_eof) )
1794 YY_NEW_FILE;
1795 #ifdef __cplusplus
1796 return yyinput();
1797 #else
1798 return input();
1799 #endif
1800 }
1801
1802 case EOB_ACT_CONTINUE_SCAN:
1803 (yy_c_buf_p) = (yytext_ptr) + offset;
1804 break;
1805 }
1806 }
1807 }
1808
1809 c = *(unsigned char *) (yy_c_buf_p); /* cast for 8-bit char's */
1810 *(yy_c_buf_p) = '\0'; /* preserve yytext */
1811 (yy_hold_char) = *++(yy_c_buf_p);
1812
1813 YY_CURRENT_BUFFER_LVALUE->yy_at_bol = (c == '\n');
1814
1815 return c;
1816 }
1817 #endif /* ifndef YY_NO_INPUT */
1818
1819 /** Immediately switch to a different input stream.
1820 * @param input_file A readable stream.
1821 *
1822 * @note This function does not reset the start condition to @c INITIAL .
1823 */
1824 void yyrestart (FILE * input_file )
1825 {
1826
1827 if ( ! YY_CURRENT_BUFFER ){
1828 yyensure_buffer_stack ();
1829 YY_CURRENT_BUFFER_LVALUE =
1830 yy_create_buffer( yyin, YY_BUF_SIZE );
1831 }
1832
1833 yy_init_buffer( YY_CURRENT_BUFFER, input_file );
1834 yy_load_buffer_state( );
1835 }
1836
1837 /** Switch to a different input buffer.
1838 * @param new_buffer The new input buffer.
1839 *
1840 */
1841 void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer )
1842 {
1843
1844 /* TODO. We should be able to replace this entire function body
1845 * with
1846 * yypop_buffer_state();
1847 * yypush_buffer_state(new_buffer);
1848 */
1849 yyensure_buffer_stack ();
1850 if ( YY_CURRENT_BUFFER == new_buffer )
1851 return;
1852
1853 if ( YY_CURRENT_BUFFER )
1854 {
1855 /* Flush out information for old buffer. */
1856 *(yy_c_buf_p) = (yy_hold_char);
1857 YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
1858 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
1859 }
1860
1861 YY_CURRENT_BUFFER_LVALUE = new_buffer;
1862 yy_load_buffer_state( );
1863
1864 /* We don't actually know whether we did this switch during
1865 * EOF (yywrap()) processing, but the only time this flag
1866 * is looked at is after yywrap() is called, so it's safe
1867 * to go ahead and always set it.
1868 */
1869 (yy_did_buffer_switch_on_eof) = 1;
1870 }
1871
1872 static void yy_load_buffer_state (void)
1873 {
1874 (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
1875 (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos;
1876 yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file;
1877 (yy_hold_char) = *(yy_c_buf_p);
1878 }
1879
1880 /** Allocate and initialize an input buffer state.
1881 * @param file A readable stream.
1882 * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE.
1883 *
1884 * @return the allocated buffer state.
1885 */
1886 YY_BUFFER_STATE yy_create_buffer (FILE * file, int size )
1887 {
1888 YY_BUFFER_STATE b;
1889
1890 b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) );
1891 if ( ! b )
1892 YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
1893
1894 b->yy_buf_size = size;
1895
1896 /* yy_ch_buf has to be 2 characters longer than the size given because
1897 * we need to put in 2 end-of-buffer characters.
1898 */
1899 b->yy_ch_buf = (char *) yyalloc( (yy_size_t) (b->yy_buf_size + 2) );
1900 if ( ! b->yy_ch_buf )
1901 YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
1902
1903 b->yy_is_our_buffer = 1;
1904
1905 yy_init_buffer( b, file );
1906
1907 return b;
1908 }
1909
1910 /** Destroy the buffer.
1911 * @param b a buffer created with yy_create_buffer()
1912 *
1913 */
1914 void yy_delete_buffer (YY_BUFFER_STATE b )
1915 {
1916
1917 if ( ! b )
1918 return;
1919
1920 if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */
1921 YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0;
1922
1923 if ( b->yy_is_our_buffer )
1924 yyfree( (void *) b->yy_ch_buf );
1925
1926 yyfree( (void *) b );
1927 }
1928
1929 /* Initializes or reinitializes a buffer.
1930 * This function is sometimes called more than once on the same buffer,
1931 * such as during a yyrestart() or at EOF.
1932 */
1933 static void yy_init_buffer (YY_BUFFER_STATE b, FILE * file )
1934
1935 {
1936 int oerrno = errno;
1937
1938 yy_flush_buffer( b );
1939
1940 b->yy_input_file = file;
1941 b->yy_fill_buffer = 1;
1942
1943 /* If b is the current buffer, then yy_init_buffer was _probably_
1944 * called from yyrestart() or through yy_get_next_buffer.
1945 * In that case, we don't want to reset the lineno or column.
1946 */
1947 if (b != YY_CURRENT_BUFFER){
1948 b->yy_bs_lineno = 1;
1949 b->yy_bs_column = 0;
1950 }
1951
1952 b->yy_is_interactive = 0;
1953
1954 errno = oerrno;
1955 }
1956
1957 /** Discard all buffered characters. On the next scan, YY_INPUT will be called.
1958 * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER.
1959 *
1960 */
1961 void yy_flush_buffer (YY_BUFFER_STATE b )
1962 {
1963 if ( ! b )
1964 return;
1965
1966 b->yy_n_chars = 0;
1967
1968 /* We always need two end-of-buffer characters. The first causes
1969 * a transition to the end-of-buffer state. The second causes
1970 * a jam in that state.
1971 */
1972 b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
1973 b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
1974
1975 b->yy_buf_pos = &b->yy_ch_buf[0];
1976
1977 b->yy_at_bol = 1;
1978 b->yy_buffer_status = YY_BUFFER_NEW;
1979
1980 if ( b == YY_CURRENT_BUFFER )
1981 yy_load_buffer_state( );
1982 }
1983
1984 /** Pushes the new state onto the stack. The new state becomes
1985 * the current state. This function will allocate the stack
1986 * if necessary.
1987 * @param new_buffer The new state.
1988 *
1989 */
1990 void yypush_buffer_state (YY_BUFFER_STATE new_buffer )
1991 {
1992 if (new_buffer == NULL)
1993 return;
1994
1995 yyensure_buffer_stack();
1996
1997 /* This block is copied from yy_switch_to_buffer. */
1998 if ( YY_CURRENT_BUFFER )
1999 {
2000 /* Flush out information for old buffer. */
2001 *(yy_c_buf_p) = (yy_hold_char);
2002 YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
2003 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
2004 }
2005
2006 /* Only push if top exists. Otherwise, replace top. */
2007 if (YY_CURRENT_BUFFER)
2008 (yy_buffer_stack_top)++;
2009 YY_CURRENT_BUFFER_LVALUE = new_buffer;
2010
2011 /* copied from yy_switch_to_buffer. */
2012 yy_load_buffer_state( );
2013 (yy_did_buffer_switch_on_eof) = 1;
2014 }
2015
2016 /** Removes and deletes the top of the stack, if present.
2017 * The next element becomes the new top.
2018 *
2019 */
2020 void yypop_buffer_state (void)
2021 {
2022 if (!YY_CURRENT_BUFFER)
2023 return;
2024
2025 yy_delete_buffer(YY_CURRENT_BUFFER );
2026 YY_CURRENT_BUFFER_LVALUE = NULL;
2027 if ((yy_buffer_stack_top) > 0)
2028 --(yy_buffer_stack_top);
2029
2030 if (YY_CURRENT_BUFFER) {
2031 yy_load_buffer_state( );
2032 (yy_did_buffer_switch_on_eof) = 1;
2033 }
2034 }
2035
2036 /* Allocates the stack if it does not exist.
2037 * Guarantees space for at least one push.
2038 */
2039 static void yyensure_buffer_stack (void)
2040 {
2041 yy_size_t num_to_alloc;
2042
2043 if (!(yy_buffer_stack)) {
2044
2045 /* First allocation is just for 2 elements, since we don't know if this
2046 * scanner will even need a stack. We use 2 instead of 1 to avoid an
2047 * immediate realloc on the next call.
2048 */
2049 num_to_alloc = 1; /* After all that talk, this was set to 1 anyways... */
2050 (yy_buffer_stack) = (struct yy_buffer_state**)yyalloc
2051 (num_to_alloc * sizeof(struct yy_buffer_state*)
2052 );
2053 if ( ! (yy_buffer_stack) )
2054 YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" );
2055
2056 memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*));
2057
2058 (yy_buffer_stack_max) = num_to_alloc;
2059 (yy_buffer_stack_top) = 0;
2060 return;
2061 }
2062
2063 if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){
2064
2065 /* Increase the buffer to prepare for a possible push. */
2066 yy_size_t grow_size = 8 /* arbitrary grow size */;
2067
2068 num_to_alloc = (yy_buffer_stack_max) + grow_size;
2069 (yy_buffer_stack) = (struct yy_buffer_state**)yyrealloc
2070 ((yy_buffer_stack),
2071 num_to_alloc * sizeof(struct yy_buffer_state*)
2072 );
2073 if ( ! (yy_buffer_stack) )
2074 YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" );
2075
2076 /* zero only the new slots.*/
2077 memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*));
2078 (yy_buffer_stack_max) = num_to_alloc;
2079 }
2080 }
2081
2082 /** Setup the input buffer state to scan directly from a user-specified character buffer.
2083 * @param base the character buffer
2084 * @param size the size in bytes of the character buffer
2085 *
2086 * @return the newly allocated buffer state object.
2087 */
2088 YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size )
2089 {
2090 YY_BUFFER_STATE b;
2091
2092 if ( size < 2 ||
2093 base[size-2] != YY_END_OF_BUFFER_CHAR ||
2094 base[size-1] != YY_END_OF_BUFFER_CHAR )
2095 /* They forgot to leave room for the EOB's. */
2096 return NULL;
2097
2098 b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) );
2099 if ( ! b )
2100 YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" );
2101
2102 b->yy_buf_size = (int) (size - 2); /* "- 2" to take care of EOB's */
2103 b->yy_buf_pos = b->yy_ch_buf = base;
2104 b->yy_is_our_buffer = 0;
2105 b->yy_input_file = NULL;
2106 b->yy_n_chars = b->yy_buf_size;
2107 b->yy_is_interactive = 0;
2108 b->yy_at_bol = 1;
2109 b->yy_fill_buffer = 0;
2110 b->yy_buffer_status = YY_BUFFER_NEW;
2111
2112 yy_switch_to_buffer( b );
2113
2114 return b;
2115 }
2116
2117 /** Setup the input buffer state to scan a string. The next call to yylex() will
2118 * scan from a @e copy of @a str.
2119 * @param yystr a NUL-terminated string to scan
2120 *
2121 * @return the newly allocated buffer state object.
2122 * @note If you want to scan bytes that may contain NUL values, then use
2123 * yy_scan_bytes() instead.
2124 */
2125 YY_BUFFER_STATE yy_scan_string (const char * yystr )
2126 {
2127
2128 return yy_scan_bytes( yystr, (int) strlen(yystr) );
2129 }
2130
2131 /** Setup the input buffer state to scan the given bytes. The next call to yylex() will
2132 * scan from a @e copy of @a bytes.
2133 * @param yybytes the byte buffer to scan
2134 * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes.
2135 *
2136 * @return the newly allocated buffer state object.
2137 */
2138 YY_BUFFER_STATE yy_scan_bytes (const char * yybytes, int _yybytes_len )
2139 {
2140 YY_BUFFER_STATE b;
2141 char *buf;
2142 yy_size_t n;
2143 int i;
2144
2145 /* Get memory for full buffer, including space for trailing EOB's. */
2146 n = (yy_size_t) (_yybytes_len + 2);
2147 buf = (char *) yyalloc( n );
2148 if ( ! buf )
2149 YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" );
2150
2151 for ( i = 0; i < _yybytes_len; ++i )
2152 buf[i] = yybytes[i];
2153
2154 buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR;
2155
2156 b = yy_scan_buffer( buf, n );
2157 if ( ! b )
2158 YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" );
2159
2160 /* It's okay to grow etc. this buffer, and we should throw it
2161 * away when we're done.
2162 */
2163 b->yy_is_our_buffer = 1;
2164
2165 return b;
2166 }
2167
2168 #ifndef YY_EXIT_FAILURE
2169 #define YY_EXIT_FAILURE 2
2170 #endif
2171
2172 static void yynoreturn yy_fatal_error (const char* msg )
2173 {
2174 fprintf( stderr, "%s\n", msg );
2175 exit( YY_EXIT_FAILURE );
2176 }
2177
2178 /* Redefine yyless() so it works in section 3 code. */
2179
2180 #undef yyless
2181 #define yyless(n) \
2182 do \
2183 { \
2184 /* Undo effects of setting up yytext. */ \
2185 int yyless_macro_arg = (n); \
2186 YY_LESS_LINENO(yyless_macro_arg);\
2187 yytext[yyleng] = (yy_hold_char); \
2188 (yy_c_buf_p) = yytext + yyless_macro_arg; \
2189 (yy_hold_char) = *(yy_c_buf_p); \
2190 *(yy_c_buf_p) = '\0'; \
2191 yyleng = yyless_macro_arg; \
2192 } \
2193 while ( 0 )
2194
2195 /* Accessor methods (get/set functions) to struct members. */
2196
2197 /** Get the current line number.
2198 *
2199 */
2200 int yyget_lineno (void)
2201 {
2202
2203 return yylineno;
2204 }
2205
2206 /** Get the input stream.
2207 *
2208 */
2209 FILE *yyget_in (void)
2210 {
2211 return yyin;
2212 }
2213
2214 /** Get the output stream.
2215 *
2216 */
2217 FILE *yyget_out (void)
2218 {
2219 return yyout;
2220 }
2221
2222 /** Get the length of the current token.
2223 *
2224 */
2225 int yyget_leng (void)
2226 {
2227 return yyleng;
2228 }
2229
2230 /** Get the current token.
2231 *
2232 */
2233
2234 char *yyget_text (void)
2235 {
2236 return yytext;
2237 }
2238
2239 /** Set the current line number.
2240 * @param _line_number line number
2241 *
2242 */
2243 void yyset_lineno (int _line_number )
2244 {
2245
2246 yylineno = _line_number;
2247 }
2248
2249 /** Set the input stream. This does not discard the current
2250 * input buffer.
2251 * @param _in_str A readable stream.
2252 *
2253 * @see yy_switch_to_buffer
2254 */
2255 void yyset_in (FILE * _in_str )
2256 {
2257 yyin = _in_str ;
2258 }
2259
2260 void yyset_out (FILE * _out_str )
2261 {
2262 yyout = _out_str ;
2263 }
2264
2265 int yyget_debug (void)
2266 {
2267 return yy_flex_debug;
2268 }
2269
2270 void yyset_debug (int _bdebug )
2271 {
2272 yy_flex_debug = _bdebug ;
2273 }
2274
2275 static int yy_init_globals (void)
2276 {
2277 /* Initialization is the same as for the non-reentrant scanner.
2278 * This function is called from yylex_destroy(), so don't allocate here.
2279 */
2280
2281 (yy_buffer_stack) = NULL;
2282 (yy_buffer_stack_top) = 0;
2283 (yy_buffer_stack_max) = 0;
2284 (yy_c_buf_p) = NULL;
2285 (yy_init) = 0;
2286 (yy_start) = 0;
2287
2288 /* Defined in main.c */
2289 #ifdef YY_STDINIT
2290 yyin = stdin;
2291 yyout = stdout;
2292 #else
2293 yyin = NULL;
2294 yyout = NULL;
2295 #endif
2296
2297 /* For future reference: Set errno on error, since we are called by
2298 * yylex_init()
2299 */
2300 return 0;
2301 }
2302
2303 /* yylex_destroy is for both reentrant and non-reentrant scanners. */
2304 int yylex_destroy (void)
2305 {
2306
2307 /* Pop the buffer stack, destroying each element. */
2308 while(YY_CURRENT_BUFFER){
2309 yy_delete_buffer( YY_CURRENT_BUFFER );
2310 YY_CURRENT_BUFFER_LVALUE = NULL;
2311 yypop_buffer_state();
2312 }
2313
2314 /* Destroy the stack itself. */
2315 yyfree((yy_buffer_stack) );
2316 (yy_buffer_stack) = NULL;
2317
2318 /* Reset the globals. This is important in a non-reentrant scanner so the next time
2319 * yylex() is called, initialization will occur. */
2320 yy_init_globals( );
2321
2322 return 0;
2323 }
2324
2325 /*
2326 * Internal utility routines.
2327 */
2328
2329 #ifndef yytext_ptr
2330 static void yy_flex_strncpy (char* s1, const char * s2, int n )
2331 {
2332
2333 int i;
2334 for ( i = 0; i < n; ++i )
2335 s1[i] = s2[i];
2336 }
2337 #endif
2338
2339 #ifdef YY_NEED_STRLEN
2340 static int yy_flex_strlen (const char * s )
2341 {
2342 int n;
2343 for ( n = 0; s[n]; ++n )
2344 ;
2345
2346 return n;
2347 }
2348 #endif
2349
2350 void *yyalloc (yy_size_t size )
2351 {
2352 return malloc(size);
2353 }
2354
2355 void *yyrealloc (void * ptr, yy_size_t size )
2356 {
2357
2358 /* The cast to (char *) in the following accommodates both
2359 * implementations that use char* generic pointers, and those
2360 * that use void* generic pointers. It works with the latter
2361 * because both ANSI C and C++ allow castless assignment from
2362 * any pointer type to void*, and deal with argument conversions
2363 * as though doing an assignment.
2364 */
2365 return realloc(ptr, size);
2366 }
2367
2368 void yyfree (void * ptr )
2369 {
2370 free( (char *) ptr ); /* see yyrealloc() for (char *) cast */
2371 }
2372
2373 #define YYTABLES_NAME "yytables"
2374
2375 #line 321 "zsoelim.l"
2376
2377
2378 #ifdef ACCEPT_QUOTES
2379 /* remove leading and trailing quotes in requests */
2380 static void zap_quotes (void)
2381 {
2382 if (*yytext == '"') {
2383 if (yytext[yyleng - 1] == '"') {
2384 yytext[yyleng - 1] = '\0';
2385 yytext++;
2386 } else
2387 error (OK, 0,
2388 _("%s:%d: unterminated quote in roff request"),
2389 NAME, LINE);
2390 }
2391 }
2392 #endif
2393
2394 /* initialise the stack and call the parser */
2395 void zsoelim_parse_file (gl_list_t manpathlist, const char *parent_path)
2396 {
2397 const char *line;
2398 int linenum = 1;
2399
2400 so_stack_ptr = 0;
2401 so_manpathlist = manpathlist;
2402 so_parent_path = parent_path;
2403
2404 /* Skip over the first line if it's something that manconv might
2405 * need to know about.
2406 */
2407 line = decompress_peekline ((decompress *) yyin);
2408 if (line &&
2409 (STRNEQ (line, PP_COOKIE, 4) || STRNEQ (line, ".\\\" ", 4))) {
2410 fputs (line, stdout);
2411 decompress_peek_skip ((decompress *) yyin, strlen (line));
2412 ++linenum;
2413 }
2414
2415 printf (".lf %d %s\n", linenum, NAME);
2416 LINE = 1;
2417 yylex ();
2418 }
2419
2420 static decompress *try_compressed (char **filename)
2421 {
2422 struct compression *comp;
2423 size_t len = strlen (*filename);
2424 decompress *decomp;
2425
2426 /* Try the uncompressed name first. */
2427 (*filename)[len - 1] = '\0';
2428 debug ("trying %s\n", *filename);
2429 decomp = decompress_open (*filename, DECOMPRESS_ALLOW_INPROCESS);
2430 if (decomp)
2431 return decomp;
2432 (*filename)[len - 1] = '.';
2433
2434 for (comp = comp_list; comp->ext; ++comp) {
2435 *filename = appendstr (*filename, comp->ext, NULL);
2436 debug ("trying %s\n", *filename);
2437 decomp = decompress_open (*filename,
2438 DECOMPRESS_ALLOW_INPROCESS);
2439 if (decomp)
2440 return decomp;
2441 (*filename)[len] = '\0';
2442 }
2443
2444 return NULL;
2445 }
2446
2447 /* This routine is used to open the specified file or uncompress a compressed
2448 version and open that instead */
2449 bool zsoelim_open_file (const char *filename, gl_list_t manpathlist,
2450 const char *parent_path)
2451 {
2452 decompress *decomp = NULL;
2453
2454 if (parent_path)
2455 debug ("opening %s (parent path: %s)\n",
2456 filename, parent_path);
2457 else
2458 debug ("opening %s\n", filename);
2459
2460 if (strcmp (filename, "-") == 0) {
2461 decomp = decompress_fdopen (dup (STDIN_FILENO));
2462 NAME = xstrdup (filename);
2463 } else {
2464 char *compfile;
2465 const char *mp;
2466
2467 /* If there is no parent path, try opening directly first. */
2468 if (!parent_path) {
2469 compfile = xasprintf ("%s.", filename);
2470 assert (compfile);
2471
2472 decomp = try_compressed (&compfile);
2473 if (decomp) {
2474 NAME = compfile;
2475 goto out;
2476 } else
2477 free (compfile);
2478 }
2479
2480 if (strchr (filename, '/')) {
2481 /* File name with a directory part. Try looking it
2482 * up within each manpath entry.
2483 */
2484 if (parent_path) {
2485 compfile = xasprintf ("%s/%s.", parent_path,
2486 filename);
2487 assert (compfile);
2488
2489 decomp = try_compressed (&compfile);
2490 if (decomp) {
2491 NAME = compfile;
2492 goto out;
2493 }
2494
2495 free (compfile);
2496 }
2497
2498 GL_LIST_FOREACH (manpathlist, mp) {
2499 if (parent_path && STREQ (mp, parent_path))
2500 continue;
2501
2502 compfile = xasprintf ("%s/%s.", mp, filename);
2503 assert (compfile);
2504
2505 decomp = try_compressed (&compfile);
2506 if (decomp) {
2507 NAME = compfile;
2508 goto out;
2509 }
2510
2511 free (compfile);
2512 }
2513 } else {
2514 /* File name with no directory part. Try searching
2515 * the manpath.
2516 */
2517 char *name, *sec, *dot;
2518 gl_list_t names;
2519 const char *found_name;
2520
2521 name = xstrdup (filename);
2522 dot = strchr (name, '.');
2523 if (!dot) {
2524 free (name);
2525 goto out;
2526 }
2527 *dot++ = '\0';
2528 sec = dot;
2529 dot = strchr (dot, '.');
2530 if (dot)
2531 *dot = '\0';
2532
2533 if (parent_path) {
2534 names = look_for_file (parent_path, sec, name,
2535 false, LFF_MATCHCASE);
2536 GL_LIST_FOREACH (names, found_name) {
2537 decomp = decompress_open
2538 (found_name,
2539 DECOMPRESS_ALLOW_INPROCESS);
2540 if (decomp) {
2541 NAME = xstrdup (found_name);
2542 gl_list_free (names);
2543 goto out;
2544 }
2545 }
2546 gl_list_free (names);
2547 }
2548
2549 GL_LIST_FOREACH (manpathlist, mp) {
2550 if (parent_path && STREQ (mp, parent_path))
2551 continue;
2552
2553 names = look_for_file (mp, sec, name,
2554 false, LFF_MATCHCASE);
2555 GL_LIST_FOREACH (names, found_name) {
2556 decomp = decompress_open
2557 (found_name,
2558 DECOMPRESS_ALLOW_INPROCESS);
2559 if (decomp) {
2560 NAME = xstrdup (found_name);
2561 gl_list_free (names);
2562 free (name);
2563 goto out;
2564 }
2565 }
2566 gl_list_free (names);
2567 }
2568
2569 free (name);
2570 }
2571
2572 /* If there is a parent path, try opening directly last. */
2573 if (parent_path) {
2574 compfile = xasprintf ("%s.", filename);
2575 assert (compfile);
2576
2577 decomp = try_compressed (&compfile);
2578 if (decomp) {
2579 NAME = compfile;
2580 goto out;
2581 } else
2582 free (compfile);
2583 }
2584
2585 out:
2586 if (!decomp) {
2587 error (0, errno, _("can't open %s"), filename);
2588 return true;
2589 }
2590 }
2591
2592 debug ("opened %s\n", NAME);
2593
2594 decompress_start (decomp);
2595 PIPE = decomp;
2596 /* only used by YY_INPUT, which casts it back to 'decompress *' */
2597 yyin = (FILE *) decomp;
2598
2599 return false;
2600 }
2601
2602 void zsoelim_stdin (void *data)
2603 {
2604 struct zsoelim_stdin_data *zsoelim_data = data;
2605 gl_list_t empty;
2606
2607 empty = gl_list_create_empty (GL_LINKEDHASH_LIST, NULL, NULL, NULL,
2608 true);
2609 zsoelim_open_file ("-", empty, zsoelim_data->path);
2610 gl_list_free (empty);
2611 zsoelim_parse_file (zsoelim_data->manpathlist, zsoelim_data->path);
2612 }
2613
2614 struct zsoelim_stdin_data *zsoelim_stdin_data_new (const char *path,
2615 gl_list_t manpathlist)
2616 {
2617 struct zsoelim_stdin_data *data = XMALLOC (struct zsoelim_stdin_data);
2618
2619 data->path = path ? xstrdup (path) : NULL;
2620 data->manpathlist = manpathlist;
2621
2622 return data;
2623 }
2624
2625 void zsoelim_stdin_data_free (void *data)
2626 {
2627 struct zsoelim_stdin_data *zsoelim_data = data;
2628
2629 free (zsoelim_data->path);
2630 free (zsoelim_data);
2631 }
2632