Debian Codegraph @

modules/gcide/idxgcide.c

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