1 #line 2 "guc-file.c"
2
3 #line 4 "guc-file.c"
4
5 #define YY_INT_ALIGNED short int
6
7 /* A lexical scanner generated by flex */
8
9 #define yy_create_buffer GUC_yy_create_buffer
10 #define yy_delete_buffer GUC_yy_delete_buffer
11 #define yy_scan_buffer GUC_yy_scan_buffer
12 #define yy_scan_string GUC_yy_scan_string
13 #define yy_scan_bytes GUC_yy_scan_bytes
14 #define yy_init_buffer GUC_yy_init_buffer
15 #define yy_flush_buffer GUC_yy_flush_buffer
16 #define yy_load_buffer_state GUC_yy_load_buffer_state
17 #define yy_switch_to_buffer GUC_yy_switch_to_buffer
18 #define yypush_buffer_state GUC_yypush_buffer_state
19 #define yypop_buffer_state GUC_yypop_buffer_state
20 #define yyensure_buffer_stack GUC_yyensure_buffer_stack
21 #define yy_flex_debug GUC_yy_flex_debug
22 #define yyin GUC_yyin
23 #define yyleng GUC_yyleng
24 #define yylex GUC_yylex
25 #define yylineno GUC_yylineno
26 #define yyout GUC_yyout
27 #define yyrestart GUC_yyrestart
28 #define yytext GUC_yytext
29 #define yywrap GUC_yywrap
30 #define yyalloc GUC_yyalloc
31 #define yyrealloc GUC_yyrealloc
32 #define yyfree GUC_yyfree
33
34 #define FLEX_SCANNER
35 #define YY_FLEX_MAJOR_VERSION 2
36 #define YY_FLEX_MINOR_VERSION 6
37 #define YY_FLEX_SUBMINOR_VERSION 4
38 #if YY_FLEX_SUBMINOR_VERSION > 0
39 #define FLEX_BETA
40 #endif
41
42 #ifdef yy_create_buffer
43 #define GUC_yy_create_buffer_ALREADY_DEFINED
44 #else
45 #define yy_create_buffer GUC_yy_create_buffer
46 #endif
47
48 #ifdef yy_delete_buffer
49 #define GUC_yy_delete_buffer_ALREADY_DEFINED
50 #else
51 #define yy_delete_buffer GUC_yy_delete_buffer
52 #endif
53
54 #ifdef yy_scan_buffer
55 #define GUC_yy_scan_buffer_ALREADY_DEFINED
56 #else
57 #define yy_scan_buffer GUC_yy_scan_buffer
58 #endif
59
60 #ifdef yy_scan_string
61 #define GUC_yy_scan_string_ALREADY_DEFINED
62 #else
63 #define yy_scan_string GUC_yy_scan_string
64 #endif
65
66 #ifdef yy_scan_bytes
67 #define GUC_yy_scan_bytes_ALREADY_DEFINED
68 #else
69 #define yy_scan_bytes GUC_yy_scan_bytes
70 #endif
71
72 #ifdef yy_init_buffer
73 #define GUC_yy_init_buffer_ALREADY_DEFINED
74 #else
75 #define yy_init_buffer GUC_yy_init_buffer
76 #endif
77
78 #ifdef yy_flush_buffer
79 #define GUC_yy_flush_buffer_ALREADY_DEFINED
80 #else
81 #define yy_flush_buffer GUC_yy_flush_buffer
82 #endif
83
84 #ifdef yy_load_buffer_state
85 #define GUC_yy_load_buffer_state_ALREADY_DEFINED
86 #else
87 #define yy_load_buffer_state GUC_yy_load_buffer_state
88 #endif
89
90 #ifdef yy_switch_to_buffer
91 #define GUC_yy_switch_to_buffer_ALREADY_DEFINED
92 #else
93 #define yy_switch_to_buffer GUC_yy_switch_to_buffer
94 #endif
95
96 #ifdef yypush_buffer_state
97 #define GUC_yypush_buffer_state_ALREADY_DEFINED
98 #else
99 #define yypush_buffer_state GUC_yypush_buffer_state
100 #endif
101
102 #ifdef yypop_buffer_state
103 #define GUC_yypop_buffer_state_ALREADY_DEFINED
104 #else
105 #define yypop_buffer_state GUC_yypop_buffer_state
106 #endif
107
108 #ifdef yyensure_buffer_stack
109 #define GUC_yyensure_buffer_stack_ALREADY_DEFINED
110 #else
111 #define yyensure_buffer_stack GUC_yyensure_buffer_stack
112 #endif
113
114 #ifdef yylex
115 #define GUC_yylex_ALREADY_DEFINED
116 #else
117 #define yylex GUC_yylex
118 #endif
119
120 #ifdef yyrestart
121 #define GUC_yyrestart_ALREADY_DEFINED
122 #else
123 #define yyrestart GUC_yyrestart
124 #endif
125
126 #ifdef yylex_init
127 #define GUC_yylex_init_ALREADY_DEFINED
128 #else
129 #define yylex_init GUC_yylex_init
130 #endif
131
132 #ifdef yylex_init_extra
133 #define GUC_yylex_init_extra_ALREADY_DEFINED
134 #else
135 #define yylex_init_extra GUC_yylex_init_extra
136 #endif
137
138 #ifdef yylex_destroy
139 #define GUC_yylex_destroy_ALREADY_DEFINED
140 #else
141 #define yylex_destroy GUC_yylex_destroy
142 #endif
143
144 #ifdef yyget_debug
145 #define GUC_yyget_debug_ALREADY_DEFINED
146 #else
147 #define yyget_debug GUC_yyget_debug
148 #endif
149
150 #ifdef yyset_debug
151 #define GUC_yyset_debug_ALREADY_DEFINED
152 #else
153 #define yyset_debug GUC_yyset_debug
154 #endif
155
156 #ifdef yyget_extra
157 #define GUC_yyget_extra_ALREADY_DEFINED
158 #else
159 #define yyget_extra GUC_yyget_extra
160 #endif
161
162 #ifdef yyset_extra
163 #define GUC_yyset_extra_ALREADY_DEFINED
164 #else
165 #define yyset_extra GUC_yyset_extra
166 #endif
167
168 #ifdef yyget_in
169 #define GUC_yyget_in_ALREADY_DEFINED
170 #else
171 #define yyget_in GUC_yyget_in
172 #endif
173
174 #ifdef yyset_in
175 #define GUC_yyset_in_ALREADY_DEFINED
176 #else
177 #define yyset_in GUC_yyset_in
178 #endif
179
180 #ifdef yyget_out
181 #define GUC_yyget_out_ALREADY_DEFINED
182 #else
183 #define yyget_out GUC_yyget_out
184 #endif
185
186 #ifdef yyset_out
187 #define GUC_yyset_out_ALREADY_DEFINED
188 #else
189 #define yyset_out GUC_yyset_out
190 #endif
191
192 #ifdef yyget_leng
193 #define GUC_yyget_leng_ALREADY_DEFINED
194 #else
195 #define yyget_leng GUC_yyget_leng
196 #endif
197
198 #ifdef yyget_text
199 #define GUC_yyget_text_ALREADY_DEFINED
200 #else
201 #define yyget_text GUC_yyget_text
202 #endif
203
204 #ifdef yyget_lineno
205 #define GUC_yyget_lineno_ALREADY_DEFINED
206 #else
207 #define yyget_lineno GUC_yyget_lineno
208 #endif
209
210 #ifdef yyset_lineno
211 #define GUC_yyset_lineno_ALREADY_DEFINED
212 #else
213 #define yyset_lineno GUC_yyset_lineno
214 #endif
215
216 #ifdef yywrap
217 #define GUC_yywrap_ALREADY_DEFINED
218 #else
219 #define yywrap GUC_yywrap
220 #endif
221
222 #ifdef yyalloc
223 #define GUC_yyalloc_ALREADY_DEFINED
224 #else
225 #define yyalloc GUC_yyalloc
226 #endif
227
228 #ifdef yyrealloc
229 #define GUC_yyrealloc_ALREADY_DEFINED
230 #else
231 #define yyrealloc GUC_yyrealloc
232 #endif
233
234 #ifdef yyfree
235 #define GUC_yyfree_ALREADY_DEFINED
236 #else
237 #define yyfree GUC_yyfree
238 #endif
239
240 #ifdef yytext
241 #define GUC_yytext_ALREADY_DEFINED
242 #else
243 #define yytext GUC_yytext
244 #endif
245
246 #ifdef yyleng
247 #define GUC_yyleng_ALREADY_DEFINED
248 #else
249 #define yyleng GUC_yyleng
250 #endif
251
252 #ifdef yyin
253 #define GUC_yyin_ALREADY_DEFINED
254 #else
255 #define yyin GUC_yyin
256 #endif
257
258 #ifdef yyout
259 #define GUC_yyout_ALREADY_DEFINED
260 #else
261 #define yyout GUC_yyout
262 #endif
263
264 #ifdef yy_flex_debug
265 #define GUC_yy_flex_debug_ALREADY_DEFINED
266 #else
267 #define yy_flex_debug GUC_yy_flex_debug
268 #endif
269
270 #ifdef yylineno
271 #define GUC_yylineno_ALREADY_DEFINED
272 #else
273 #define yylineno GUC_yylineno
274 #endif
275
276 /* First, we deal with platform-specific or compiler-specific issues. */
277
278 /* begin standard C headers. */
279 #include <stdio.h>
280 #include <string.h>
281 #include <errno.h>
282 #include <stdlib.h>
283
284 /* end standard C headers. */
285
286 /* flex integer type definitions */
287
288 #ifndef FLEXINT_H
289 #define FLEXINT_H
290
291 /* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */
292
293 #if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
294
295 /* C99 says to define __STDC_LIMIT_MACROS before including stdint.h,
296 * if you want the limit (max/min) macros for int types.
297 */
298 #ifndef __STDC_LIMIT_MACROS
299 #define __STDC_LIMIT_MACROS 1
300 #endif
301
302 #include <inttypes.h>
303 typedef int8_t flex_int8_t;
304 typedef uint8_t flex_uint8_t;
305 typedef int16_t flex_int16_t;
306 typedef uint16_t flex_uint16_t;
307 typedef int32_t flex_int32_t;
308 typedef uint32_t flex_uint32_t;
309 #else
310 typedef signed char flex_int8_t;
311 typedef short int flex_int16_t;
312 typedef int flex_int32_t;
313 typedef unsigned char flex_uint8_t;
314 typedef unsigned short int flex_uint16_t;
315 typedef unsigned int flex_uint32_t;
316
317 /* Limits of integral types. */
318 #ifndef INT8_MIN
319 #define INT8_MIN (-128)
320 #endif
321 #ifndef INT16_MIN
322 #define INT16_MIN (-32767-1)
323 #endif
324 #ifndef INT32_MIN
325 #define INT32_MIN (-2147483647-1)
326 #endif
327 #ifndef INT8_MAX
328 #define INT8_MAX (127)
329 #endif
330 #ifndef INT16_MAX
331 #define INT16_MAX (32767)
332 #endif
333 #ifndef INT32_MAX
334 #define INT32_MAX (2147483647)
335 #endif
336 #ifndef UINT8_MAX
337 #define UINT8_MAX (255U)
338 #endif
339 #ifndef UINT16_MAX
340 #define UINT16_MAX (65535U)
341 #endif
342 #ifndef UINT32_MAX
343 #define UINT32_MAX (4294967295U)
344 #endif
345
346 #ifndef SIZE_MAX
347 #define SIZE_MAX (~(size_t)0)
348 #endif
349
350 #endif /* ! C99 */
351
352 #endif /* ! FLEXINT_H */
353
354 /* begin standard C++ headers. */
355
356 /* TODO: this is always defined, so inline it */
357 #define yyconst const
358
359 #if defined(__GNUC__) && __GNUC__ >= 3
360 #define yynoreturn __attribute__((__noreturn__))
361 #else
362 #define yynoreturn
363 #endif
364
365 /* Returned upon end-of-file. */
366 #define YY_NULL 0
367
368 /* Promotes a possibly negative, possibly signed char to an
369 * integer in range [0..255] for use as an array index.
370 */
371 #define YY_SC_TO_UI(c) ((YY_CHAR) (c))
372
373 /* Enter a start condition. This macro really ought to take a parameter,
374 * but we do it the disgusting crufty way forced on us by the ()-less
375 * definition of BEGIN.
376 */
377 #define BEGIN (yy_start) = 1 + 2 *
378 /* Translate the current start state into a value that can be later handed
379 * to BEGIN to return to the state. The YYSTATE alias is for lex
380 * compatibility.
381 */
382 #define YY_START (((yy_start) - 1) / 2)
383 #define YYSTATE YY_START
384 /* Action number for EOF rule of a given start state. */
385 #define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
386 /* Special action meaning "start processing a new file". */
387 #define YY_NEW_FILE yyrestart( yyin )
388 #define YY_END_OF_BUFFER_CHAR 0
389
390 /* Size of default input buffer. */
391 #ifndef YY_BUF_SIZE
392 #ifdef __ia64__
393 /* On IA-64, the buffer size is 16k, not 8k.
394 * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case.
395 * Ditto for the __ia64__ case accordingly.
396 */
397 #define YY_BUF_SIZE 32768
398 #else
399 #define YY_BUF_SIZE 16384
400 #endif /* __ia64__ */
401 #endif
402
403 /* The state buf must be large enough to hold one state per character in the main buffer.
404 */
405 #define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type))
406
407 #ifndef YY_TYPEDEF_YY_BUFFER_STATE
408 #define YY_TYPEDEF_YY_BUFFER_STATE
409 typedef struct yy_buffer_state *YY_BUFFER_STATE;
410 #endif
411
412 #ifndef YY_TYPEDEF_YY_SIZE_T
413 #define YY_TYPEDEF_YY_SIZE_T
414 typedef size_t yy_size_t;
415 #endif
416
417 extern int yyleng;
418
419 extern FILE *yyin, *yyout;
420
421 #define EOB_ACT_CONTINUE_SCAN 0
422 #define EOB_ACT_END_OF_FILE 1
423 #define EOB_ACT_LAST_MATCH 2
424
425 #define YY_LESS_LINENO(n)
426 #define YY_LINENO_REWIND_TO(ptr)
427
428 /* Return all but the first "n" matched characters back to the input stream. */
429 #define yyless(n) \
430 do \
431 { \
432 /* Undo effects of setting up yytext. */ \
433 int yyless_macro_arg = (n); \
434 YY_LESS_LINENO(yyless_macro_arg);\
435 *yy_cp = (yy_hold_char); \
436 YY_RESTORE_YY_MORE_OFFSET \
437 (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \
438 YY_DO_BEFORE_ACTION; /* set up yytext again */ \
439 } \
440 while ( 0 )
441 #define unput(c) yyunput( c, (yytext_ptr) )
442
443 #ifndef YY_STRUCT_YY_BUFFER_STATE
444 #define YY_STRUCT_YY_BUFFER_STATE
445 struct yy_buffer_state
446 {
447 FILE *yy_input_file;
448
449 char *yy_ch_buf; /* input buffer */
450 char *yy_buf_pos; /* current position in input buffer */
451
452 /* Size of input buffer in bytes, not including room for EOB
453 * characters.
454 */
455 int yy_buf_size;
456
457 /* Number of characters read into yy_ch_buf, not including EOB
458 * characters.
459 */
460 int yy_n_chars;
461
462 /* Whether we "own" the buffer - i.e., we know we created it,
463 * and can realloc() it to grow it, and should free() it to
464 * delete it.
465 */
466 int yy_is_our_buffer;
467
468 /* Whether this is an "interactive" input source; if so, and
469 * if we're using stdio for input, then we want to use getc()
470 * instead of fread(), to make sure we stop fetching input after
471 * each newline.
472 */
473 int yy_is_interactive;
474
475 /* Whether we're considered to be at the beginning of a line.
476 * If so, '^' rules will be active on the next match, otherwise
477 * not.
478 */
479 int yy_at_bol;
480
481 int yy_bs_lineno; /**< The line count. */
482 int yy_bs_column; /**< The column count. */
483
484 /* Whether to try to fill the input buffer when we reach the
485 * end of it.
486 */
487 int yy_fill_buffer;
488
489 int yy_buffer_status;
490
491 #define YY_BUFFER_NEW 0
492 #define YY_BUFFER_NORMAL 1
493 /* When an EOF's been seen but there's still some text to process
494 * then we mark the buffer as YY_EOF_PENDING, to indicate that we
495 * shouldn't try reading from the input source any more. We might
496 * still have a bunch of tokens to match, though, because of
497 * possible backing-up.
498 *
499 * When we actually see the EOF, we change the status to "new"
500 * (via yyrestart()), so that the user can continue scanning by
501 * just pointing yyin at a new input file.
502 */
503 #define YY_BUFFER_EOF_PENDING 2
504
505 };
506 #endif /* !YY_STRUCT_YY_BUFFER_STATE */
507
508 /* Stack of input buffers. */
509 static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */
510 static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */
511 static YY_BUFFER_STATE * yy_buffer_stack = NULL; /**< Stack as an array. */
512
513 /* We provide macros for accessing buffer states in case in the
514 * future we want to put the buffer states in a more general
515 * "scanner state".
516 *
517 * Returns the top of the stack, or NULL.
518 */
519 #define YY_CURRENT_BUFFER ( (yy_buffer_stack) \
520 ? (yy_buffer_stack)[(yy_buffer_stack_top)] \
521 : NULL)
522 /* Same as previous macro, but useful when we know that the buffer stack is not
523 * NULL or when we need an lvalue. For internal use only.
524 */
525 #define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)]
526
527 /* yy_hold_char holds the character lost when yytext is formed. */
528 static char yy_hold_char;
529 static int yy_n_chars; /* number of characters read into yy_ch_buf */
530 int yyleng;
531
532 /* Points to current character in buffer. */
533 static char *yy_c_buf_p = NULL;
534 static int yy_init = 0; /* whether we need to initialize */
535 static int yy_start = 0; /* start state number */
536
537 /* Flag which is used to allow yywrap()'s to do buffer switches
538 * instead of setting up a fresh yyin. A bit of a hack ...
539 */
540 static int yy_did_buffer_switch_on_eof;
541
542 void yyrestart ( FILE *input_file );
543 void yy_switch_to_buffer ( YY_BUFFER_STATE new_buffer );
544 YY_BUFFER_STATE yy_create_buffer ( FILE *file, int size );
545 void yy_delete_buffer ( YY_BUFFER_STATE b );
546 void yy_flush_buffer ( YY_BUFFER_STATE b );
547 void yypush_buffer_state ( YY_BUFFER_STATE new_buffer );
548 void yypop_buffer_state ( void );
549
550 static void yyensure_buffer_stack ( void );
551 static void yy_load_buffer_state ( void );
552 static void yy_init_buffer ( YY_BUFFER_STATE b, FILE *file );
553 #define YY_FLUSH_BUFFER yy_flush_buffer( YY_CURRENT_BUFFER )
554
555 YY_BUFFER_STATE yy_scan_buffer ( char *base, yy_size_t size );
556 YY_BUFFER_STATE yy_scan_string ( const char *yy_str );
557 YY_BUFFER_STATE yy_scan_bytes ( const char *bytes, int len );
558
559 void *yyalloc ( yy_size_t );
560 void *yyrealloc ( void *, yy_size_t );
561 void yyfree ( void * );
562
563 #define yy_new_buffer yy_create_buffer
564 #define yy_set_interactive(is_interactive) \
565 { \
566 if ( ! YY_CURRENT_BUFFER ){ \
567 yyensure_buffer_stack (); \
568 YY_CURRENT_BUFFER_LVALUE = \
569 yy_create_buffer( yyin, YY_BUF_SIZE ); \
570 } \
571 YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \
572 }
573 #define yy_set_bol(at_bol) \
574 { \
575 if ( ! YY_CURRENT_BUFFER ){\
576 yyensure_buffer_stack (); \
577 YY_CURRENT_BUFFER_LVALUE = \
578 yy_create_buffer( yyin, YY_BUF_SIZE ); \
579 } \
580 YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \
581 }
582 #define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol)
583
584 /* Begin user sect3 */
585
586 #define GUC_yywrap() (/*CONSTCOND*/1)
587 #define YY_SKIP_YYWRAP
588 typedef flex_uint8_t YY_CHAR;
589
590 FILE *yyin = NULL, *yyout = NULL;
591
592 typedef int yy_state_type;
593
594 extern int yylineno;
595 int yylineno = 1;
596
597 extern char *yytext;
598 #ifdef yytext_ptr
599 #undef yytext_ptr
600 #endif
601 #define yytext_ptr yytext
602
603 static yy_state_type yy_get_previous_state ( void );
604 static yy_state_type yy_try_NUL_trans ( yy_state_type current_state );
605 static int yy_get_next_buffer ( void );
606 static void yynoreturn yy_fatal_error ( const char* msg );
607
608 /* Done after the current pattern has been matched and before the
609 * corresponding action - sets up yytext.
610 */
611 #define YY_DO_BEFORE_ACTION \
612 (yytext_ptr) = yy_bp; \
613 yyleng = (int) (yy_cp - yy_bp); \
614 (yy_hold_char) = *yy_cp; \
615 *yy_cp = '\0'; \
616 (yy_c_buf_p) = yy_cp;
617 #define YY_NUM_RULES 12
618 #define YY_END_OF_BUFFER 13
619 /* This struct is not used in this scanner,
620 but its presence is necessary. */
621 struct yy_trans_info
622 {
623 flex_int32_t yy_verify;
624 flex_int32_t yy_nxt;
625 };
626 static const flex_int16_t yy_accept[41] =
627 { 0,
628 0, 0, 13, 11, 2, 1, 3, 11, 11, 9,
629 8, 8, 10, 4, 2, 3, 0, 6, 0, 9,
630 8, 8, 9, 0, 8, 8, 7, 7, 4, 4,
631 0, 9, 8, 8, 7, 5, 5, 5, 5, 0
632 } ;
633
634 static const YY_CHAR yy_ec[256] =
635 { 0,
636 1, 1, 1, 1, 1, 1, 1, 1, 2, 3,
637 1, 1, 2, 1, 1, 1, 1, 1, 1, 1,
638 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
639 1, 2, 1, 1, 4, 1, 1, 1, 5, 1,
640 1, 1, 6, 1, 7, 8, 9, 10, 11, 11,
641 11, 11, 11, 11, 11, 11, 11, 9, 1, 1,
642 12, 1, 1, 1, 13, 13, 13, 13, 14, 13,
643 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
644 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
645 1, 16, 1, 1, 17, 1, 13, 13, 13, 13,
646
647 14, 13, 15, 15, 15, 15, 15, 15, 15, 15,
648 15, 15, 15, 15, 15, 15, 15, 15, 15, 18,
649 15, 15, 1, 1, 1, 1, 1, 19, 19, 19,
650 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
651 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
652 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
653 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
654 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
655 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
656 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
657
658 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
659 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
660 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
661 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
662 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
663 19, 19, 19, 19, 19
664 } ;
665
666 static const YY_CHAR yy_meta[20] =
667 { 0,
668 1, 1, 2, 1, 1, 1, 3, 3, 3, 4,
669 4, 1, 5, 6, 5, 1, 3, 5, 3
670 } ;
671
672 static const flex_int16_t yy_base[48] =
673 { 0,
674 0, 0, 50, 148, 43, 148, 0, 15, 24, 30,
675 28, 22, 148, 40, 35, 0, 17, 25, 0, 15,
676 0, 10, 0, 52, 0, 54, 10, 66, 79, 0,
677 13, 15, 0, 0, 4, 90, 101, 0, 0, 148,
678 118, 124, 127, 131, 133, 137, 141
679 } ;
680
681 static const flex_int16_t yy_def[48] =
682 { 0,
683 40, 1, 40, 40, 40, 40, 41, 42, 40, 43,
684 40, 11, 40, 44, 40, 41, 42, 40, 42, 43,
685 11, 11, 20, 40, 45, 40, 46, 40, 44, 29,
686 40, 40, 26, 26, 46, 47, 47, 37, 37, 0,
687 40, 40, 40, 40, 40, 40, 40
688 } ;
689
690 static const flex_int16_t yy_nxt[168] =
691 { 0,
692 4, 5, 6, 7, 8, 9, 9, 10, 4, 11,
693 12, 13, 14, 14, 14, 4, 14, 14, 14, 18,
694 35, 18, 32, 32, 32, 32, 35, 25, 24, 17,
695 19, 20, 19, 21, 22, 20, 15, 22, 22, 25,
696 25, 25, 25, 24, 15, 26, 27, 28, 27, 40,
697 40, 40, 40, 40, 40, 40, 30, 31, 31, 40,
698 40, 32, 32, 33, 33, 40, 34, 34, 25, 40,
699 40, 25, 27, 27, 27, 27, 27, 40, 36, 36,
700 36, 40, 37, 36, 36, 27, 28, 27, 40, 40,
701 40, 40, 40, 40, 40, 30, 27, 27, 27, 40,
702
703 40, 40, 40, 40, 40, 40, 39, 27, 27, 27,
704 40, 40, 40, 40, 40, 40, 40, 39, 16, 40,
705 16, 16, 16, 16, 17, 40, 17, 17, 17, 17,
706 23, 40, 23, 29, 29, 29, 29, 25, 25, 27,
707 27, 27, 27, 38, 38, 38, 38, 3, 40, 40,
708 40, 40, 40, 40, 40, 40, 40, 40, 40, 40,
709 40, 40, 40, 40, 40, 40, 40
710 } ;
711
712 static const flex_int16_t yy_chk[168] =
713 { 0,
714 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
715 1, 1, 1, 1, 1, 1, 1, 1, 1, 8,
716 35, 17, 31, 31, 32, 32, 27, 22, 20, 18,
717 8, 9, 17, 9, 9, 11, 15, 11, 11, 12,
718 11, 11, 11, 10, 5, 11, 14, 14, 14, 3,
719 0, 0, 0, 0, 0, 0, 14, 24, 24, 0,
720 0, 24, 24, 26, 26, 0, 26, 26, 26, 0,
721 0, 26, 28, 28, 28, 28, 28, 0, 28, 28,
722 28, 0, 28, 28, 28, 29, 29, 29, 0, 0,
723 0, 0, 0, 0, 0, 29, 36, 36, 36, 0,
724
725 0, 0, 0, 0, 0, 0, 36, 37, 37, 37,
726 0, 0, 0, 0, 0, 0, 0, 37, 41, 0,
727 41, 41, 41, 41, 42, 0, 42, 42, 42, 42,
728 43, 0, 43, 44, 44, 44, 44, 45, 45, 46,
729 46, 46, 46, 47, 47, 47, 47, 40, 40, 40,
730 40, 40, 40, 40, 40, 40, 40, 40, 40, 40,
731 40, 40, 40, 40, 40, 40, 40
732 } ;
733
734 static yy_state_type yy_last_accepting_state;
735 static char *yy_last_accepting_cpos;
736
737 extern int yy_flex_debug;
738 int yy_flex_debug = 0;
739
740 /* The intent behind this definition is that it'll catch
741 * any uses of REJECT which flex missed.
742 */
743 #define REJECT reject_used_but_not_detected
744 #define yymore() yymore_used_but_not_detected
745 #define YY_MORE_ADJ 0
746 #define YY_RESTORE_YY_MORE_OFFSET
747 char *yytext;
748 #line 1 "guc-file.l"
749 /* -*-pgsql-c-*- */
750 /*
751 * Scanner for the configuration file
752 *
753 * Copyright (c) 2000-2016, PostgreSQL Global Development Group
754 *
755 * src/backend/utils/misc/guc-file.l
756 */
757 #line 11 "guc-file.l"
758
759 #include "postgres.h"
760
761 #include <ctype.h>
762 #include <unistd.h>
763
764 #include "mb/pg_wchar.h"
765 #include "miscadmin.h"
766 #include "storage/fd.h"
767 #include "utils/guc.h"
768
769
770 /*
771 * flex emits a yy_fatal_error() function that it calls in response to
772 * critical errors like malloc failure, file I/O errors, and detection of
773 * internal inconsistency. That function prints a message and calls exit().
774 * Mutate it to instead call our handler, which jumps out of the parser.
775 */
776 #undef fprintf
777 #define fprintf(file, fmt, msg) GUC_flex_fatal(msg)
778
779 enum
780 {
781 GUC_ID = 1,
782 GUC_STRING = 2,
783 GUC_INTEGER = 3,
784 GUC_REAL = 4,
785 GUC_EQUALS = 5,
786 GUC_UNQUOTED_STRING = 6,
787 GUC_QUALIFIED_ID = 7,
788 GUC_EOL = 99,
789 GUC_ERROR = 100
790 };
791
792 static unsigned int ConfigFileLineno;
793 static const char *GUC_flex_fatal_errmsg;
794 static sigjmp_buf *GUC_flex_fatal_jmp;
795
796 static void FreeConfigVariable(ConfigVariable *item);
797
798 static void record_config_file_error(const char *errmsg,
799 const char *config_file,
800 int lineno,
801 ConfigVariable **head_p,
802 ConfigVariable **tail_p);
803
804 static int GUC_flex_fatal(const char *msg);
805 static char *GUC_scanstr(const char *s);
806
807 #line 808 "guc-file.c"
808 #define YY_NO_INPUT 1
809 #line 810 "guc-file.c"
810
811 #define INITIAL 0
812
813 #ifndef YY_NO_UNISTD_H
814 /* Special case for "unistd.h", since it is non-ANSI. We include it way
815 * down here because we want the user's section 1 to have been scanned first.
816 * The user has a chance to override it with an option.
817 */
818 #include <unistd.h>
819 #endif
820
821 #ifndef YY_EXTRA_TYPE
822 #define YY_EXTRA_TYPE void *
823 #endif
824
825 static int yy_init_globals ( void );
826
827 /* Accessor methods to globals.
828 These are made visible to non-reentrant scanners for convenience. */
829
830 int yylex_destroy ( void );
831
832 int yyget_debug ( void );
833
834 void yyset_debug ( int debug_flag );
835
836 YY_EXTRA_TYPE yyget_extra ( void );
837
838 void yyset_extra ( YY_EXTRA_TYPE user_defined );
839
840 FILE *yyget_in ( void );
841
842 void yyset_in ( FILE * _in_str );
843
844 FILE *yyget_out ( void );
845
846 void yyset_out ( FILE * _out_str );
847
848 int yyget_leng ( void );
849
850 char *yyget_text ( void );
851
852 int yyget_lineno ( void );
853
854 void yyset_lineno ( int _line_number );
855
856 /* Macros after this point can all be overridden by user definitions in
857 * section 1.
858 */
859
860 #ifndef YY_SKIP_YYWRAP
861 #ifdef __cplusplus
862 extern "C" int yywrap ( void );
863 #else
864 extern int yywrap ( void );
865 #endif
866 #endif
867
868 #ifndef YY_NO_UNPUT
869
870 #endif
871
872 #ifndef yytext_ptr
873 static void yy_flex_strncpy ( char *, const char *, int );
874 #endif
875
876 #ifdef YY_NEED_STRLEN
877 static int yy_flex_strlen ( const char * );
878 #endif
879
880 #ifndef YY_NO_INPUT
881 #ifdef __cplusplus
882 static int yyinput ( void );
883 #else
884 static int input ( void );
885 #endif
886
887 #endif
888
889 /* Amount of stuff to slurp up with each read. */
890 #ifndef YY_READ_BUF_SIZE
891 #ifdef __ia64__
892 /* On IA-64, the buffer size is 16k, not 8k */
893 #define YY_READ_BUF_SIZE 16384
894 #else
895 #define YY_READ_BUF_SIZE 8192
896 #endif /* __ia64__ */
897 #endif
898
899 /* Copy whatever the last rule matched to the standard output. */
900 #ifndef ECHO
901 /* This used to be an fputs(), but since the string might contain NUL's,
902 * we now use fwrite().
903 */
904 #define ECHO do { if (fwrite( yytext, (size_t) yyleng, 1, yyout )) {} } while (0)
905 #endif
906
907 /* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
908 * is returned in "result".
909 */
910 #ifndef YY_INPUT
911 #define YY_INPUT(buf,result,max_size) \
912 if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
913 { \
914 int c = '*'; \
915 int n; \
916 for ( n = 0; n < max_size && \
917 (c = getc( yyin )) != EOF && c != '\n'; ++n ) \
918 buf[n] = (char) c; \
919 if ( c == '\n' ) \
920 buf[n++] = (char) c; \
921 if ( c == EOF && ferror( yyin ) ) \
922 YY_FATAL_ERROR( "input in flex scanner failed" ); \
923 result = n; \
924 } \
925 else \
926 { \
927 errno=0; \
928 while ( (result = (int) fread(buf, 1, (yy_size_t) max_size, yyin)) == 0 && ferror(yyin)) \
929 { \
930 if( errno != EINTR) \
931 { \
932 YY_FATAL_ERROR( "input in flex scanner failed" ); \
933 break; \
934 } \
935 errno=0; \
936 clearerr(yyin); \
937 } \
938 }\
939 \
940
941 #endif
942
943 /* No semi-colon after return; correct usage is to write "yyterminate();" -
944 * we don't want an extra ';' after the "return" because that will cause
945 * some compilers to complain about unreachable statements.
946 */
947 #ifndef yyterminate
948 #define yyterminate() return YY_NULL
949 #endif
950
951 /* Number of entries by which start-condition stack grows. */
952 #ifndef YY_START_STACK_INCR
953 #define YY_START_STACK_INCR 25
954 #endif
955
956 /* Report a fatal error. */
957 #ifndef YY_FATAL_ERROR
958 #define YY_FATAL_ERROR(msg) yy_fatal_error( msg )
959 #endif
960
961 /* end tables serialization structures and prototypes */
962
963 /* Default declaration of generated scanner - a define so the user can
964 * easily add parameters.
965 */
966 #ifndef YY_DECL
967 #define YY_DECL_IS_OURS 1
968
969 extern int yylex (void);
970
971 #define YY_DECL int yylex (void)
972 #endif /* !YY_DECL */
973
974 /* Code executed at the beginning of each rule, after yytext and yyleng
975 * have been set up.
976 */
977 #ifndef YY_USER_ACTION
978 #define YY_USER_ACTION
979 #endif
980
981 /* Code executed at the end of each rule. */
982 #ifndef YY_BREAK
983 #define YY_BREAK /*LINTED*/break;
984 #endif
985
986 #define YY_RULE_SETUP \
987 YY_USER_ACTION
988
989 /** The main scanner function which does all the work.
990 */
991 YY_DECL
992 {
993 yy_state_type yy_current_state;
994 char *yy_cp, *yy_bp;
995 int yy_act;
996
997 if ( !(yy_init) )
998 {
999 (yy_init) = 1;
1000
1001 #ifdef YY_USER_INIT
1002 YY_USER_INIT;
1003 #endif
1004
1005 if ( ! (yy_start) )
1006 (yy_start) = 1; /* first start state */
1007
1008 if ( ! yyin )
1009 yyin = stdin;
1010
1011 if ( ! yyout )
1012 yyout = stdout;
1013
1014 if ( ! YY_CURRENT_BUFFER ) {
1015 yyensure_buffer_stack ();
1016 YY_CURRENT_BUFFER_LVALUE =
1017 yy_create_buffer( yyin, YY_BUF_SIZE );
1018 }
1019
1020 yy_load_buffer_state( );
1021 }
1022
1023 {
1024 #line 92 "guc-file.l"
1025
1026
1027 #line 1028 "guc-file.c"
1028
1029 while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */
1030 {
1031 yy_cp = (yy_c_buf_p);
1032
1033 /* Support of yytext. */
1034 *yy_cp = (yy_hold_char);
1035
1036 /* yy_bp points to the position in yy_ch_buf of the start of
1037 * the current run.
1038 */
1039 yy_bp = yy_cp;
1040
1041 yy_current_state = (yy_start);
1042 yy_match:
1043 do
1044 {
1045 YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)] ;
1046 if ( yy_accept[yy_current_state] )
1047 {
1048 (yy_last_accepting_state) = yy_current_state;
1049 (yy_last_accepting_cpos) = yy_cp;
1050 }
1051 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1052 {
1053 yy_current_state = (int) yy_def[yy_current_state];
1054 if ( yy_current_state >= 41 )
1055 yy_c = yy_meta[yy_c];
1056 }
1057 yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
1058 ++yy_cp;
1059 }
1060 while ( yy_current_state != 40 );
1061 yy_cp = (yy_last_accepting_cpos);
1062 yy_current_state = (yy_last_accepting_state);
1063
1064 yy_find_action:
1065 yy_act = yy_accept[yy_current_state];
1066
1067 YY_DO_BEFORE_ACTION;
1068
1069 do_action: /* This label is used only to access EOF actions. */
1070
1071 switch ( yy_act )
1072 { /* beginning of action switch */
1073 case 0: /* must back up */
1074 /* undo the effects of YY_DO_BEFORE_ACTION */
1075 *yy_cp = (yy_hold_char);
1076 yy_cp = (yy_last_accepting_cpos);
1077 yy_current_state = (yy_last_accepting_state);
1078 goto yy_find_action;
1079
1080 case 1:
1081 /* rule 1 can match eol */
1082 YY_RULE_SETUP
1083 #line 94 "guc-file.l"
1084 ConfigFileLineno++; return GUC_EOL;
1085 YY_BREAK
1086 case 2:
1087 YY_RULE_SETUP
1088 #line 95 "guc-file.l"
1089 /* eat whitespace */
1090 YY_BREAK
1091 case 3:
1092 YY_RULE_SETUP
1093 #line 96 "guc-file.l"
1094 /* eat comment (.* matches anything until newline) */
1095 YY_BREAK
1096 case 4:
1097 YY_RULE_SETUP
1098 #line 98 "guc-file.l"
1099 return GUC_ID;
1100 YY_BREAK
1101 case 5:
1102 YY_RULE_SETUP
1103 #line 99 "guc-file.l"
1104 return GUC_QUALIFIED_ID;
1105 YY_BREAK
1106 case 6:
1107 YY_RULE_SETUP
1108 #line 100 "guc-file.l"
1109 return GUC_STRING;
1110 YY_BREAK
1111 case 7:
1112 YY_RULE_SETUP
1113 #line 101 "guc-file.l"
1114 return GUC_UNQUOTED_STRING;
1115 YY_BREAK
1116 case 8:
1117 YY_RULE_SETUP
1118 #line 102 "guc-file.l"
1119 return GUC_INTEGER;
1120 YY_BREAK
1121 case 9:
1122 YY_RULE_SETUP
1123 #line 103 "guc-file.l"
1124 return GUC_REAL;
1125 YY_BREAK
1126 case 10:
1127 YY_RULE_SETUP
1128 #line 104 "guc-file.l"
1129 return GUC_EQUALS;
1130 YY_BREAK
1131 case 11:
1132 YY_RULE_SETUP
1133 #line 106 "guc-file.l"
1134 return GUC_ERROR;
1135 YY_BREAK
1136 case 12:
1137 YY_RULE_SETUP
1138 #line 108 "guc-file.l"
1139 YY_FATAL_ERROR( "flex scanner jammed" );
1140 YY_BREAK
1141 #line 1142 "guc-file.c"
1142 case YY_STATE_EOF(INITIAL):
1143 yyterminate();
1144
1145 case YY_END_OF_BUFFER:
1146 {
1147 /* Amount of text matched not including the EOB char. */
1148 int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1;
1149
1150 /* Undo the effects of YY_DO_BEFORE_ACTION. */
1151 *yy_cp = (yy_hold_char);
1152 YY_RESTORE_YY_MORE_OFFSET
1153
1154 if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW )
1155 {
1156 /* We're scanning a new file or input source. It's
1157 * possible that this happened because the user
1158 * just pointed yyin at a new source and called
1159 * yylex(). If so, then we have to assure
1160 * consistency between YY_CURRENT_BUFFER and our
1161 * globals. Here is the right place to do so, because
1162 * this is the first action (other than possibly a
1163 * back-up) that will match for the new input source.
1164 */
1165 (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
1166 YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin;
1167 YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL;
1168 }
1169
1170 /* Note that here we test for yy_c_buf_p "<=" to the position
1171 * of the first EOB in the buffer, since yy_c_buf_p will
1172 * already have been incremented past the NUL character
1173 * (since all states make transitions on EOB to the
1174 * end-of-buffer state). Contrast this with the test
1175 * in input().
1176 */
1177 if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
1178 { /* This was really a NUL. */
1179 yy_state_type yy_next_state;
1180
1181 (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text;
1182
1183 yy_current_state = yy_get_previous_state( );
1184
1185 /* Okay, we're now positioned to make the NUL
1186 * transition. We couldn't have
1187 * yy_get_previous_state() go ahead and do it
1188 * for us because it doesn't know how to deal
1189 * with the possibility of jamming (and we don't
1190 * want to build jamming into it because then it
1191 * will run more slowly).
1192 */
1193
1194 yy_next_state = yy_try_NUL_trans( yy_current_state );
1195
1196 yy_bp = (yytext_ptr) + YY_MORE_ADJ;
1197
1198 if ( yy_next_state )
1199 {
1200 /* Consume the NUL. */
1201 yy_cp = ++(yy_c_buf_p);
1202 yy_current_state = yy_next_state;
1203 goto yy_match;
1204 }
1205
1206 else
1207 {
1208 yy_cp = (yy_last_accepting_cpos);
1209 yy_current_state = (yy_last_accepting_state);
1210 goto yy_find_action;
1211 }
1212 }
1213
1214 else switch ( yy_get_next_buffer( ) )
1215 {
1216 case EOB_ACT_END_OF_FILE:
1217 {
1218 (yy_did_buffer_switch_on_eof) = 0;
1219
1220 if ( yywrap( ) )
1221 {
1222 /* Note: because we've taken care in
1223 * yy_get_next_buffer() to have set up
1224 * yytext, we can now set up
1225 * yy_c_buf_p so that if some total
1226 * hoser (like flex itself) wants to
1227 * call the scanner after we return the
1228 * YY_NULL, it'll still work - another
1229 * YY_NULL will get returned.
1230 */
1231 (yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ;
1232
1233 yy_act = YY_STATE_EOF(YY_START);
1234 goto do_action;
1235 }
1236
1237 else
1238 {
1239 if ( ! (yy_did_buffer_switch_on_eof) )
1240 YY_NEW_FILE;
1241 }
1242 break;
1243 }
1244
1245 case EOB_ACT_CONTINUE_SCAN:
1246 (yy_c_buf_p) =
1247 (yytext_ptr) + yy_amount_of_matched_text;
1248
1249 yy_current_state = yy_get_previous_state( );
1250
1251 yy_cp = (yy_c_buf_p);
1252 yy_bp = (yytext_ptr) + YY_MORE_ADJ;
1253 goto yy_match;
1254
1255 case EOB_ACT_LAST_MATCH:
1256 (yy_c_buf_p) =
1257 &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)];
1258
1259 yy_current_state = yy_get_previous_state( );
1260
1261 yy_cp = (yy_c_buf_p);
1262 yy_bp = (yytext_ptr) + YY_MORE_ADJ;
1263 goto yy_find_action;
1264 }
1265 break;
1266 }
1267
1268 default:
1269 YY_FATAL_ERROR(
1270 "fatal flex scanner internal error--no action found" );
1271 } /* end of action switch */
1272 } /* end of scanning one token */
1273 } /* end of user's declarations */
1274 } /* end of yylex */
1275
1276 /* yy_get_next_buffer - try to read in a new buffer
1277 *
1278 * Returns a code representing an action:
1279 * EOB_ACT_LAST_MATCH -
1280 * EOB_ACT_CONTINUE_SCAN - continue scanning from current position
1281 * EOB_ACT_END_OF_FILE - end of file
1282 */
yy_get_next_buffer(void)1283 static int yy_get_next_buffer (void)
1284 {
1285 char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
1286 char *source = (yytext_ptr);
1287 int number_to_move, i;
1288 int ret_val;
1289
1290 if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] )
1291 YY_FATAL_ERROR(
1292 "fatal flex scanner internal error--end of buffer missed" );
1293
1294 if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 )
1295 { /* Don't try to fill the buffer, so this is an EOF. */
1296 if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 )
1297 {
1298 /* We matched a single character, the EOB, so
1299 * treat this as a final EOF.
1300 */
1301 return EOB_ACT_END_OF_FILE;
1302 }
1303
1304 else
1305 {
1306 /* We matched some text prior to the EOB, first
1307 * process it.
1308 */
1309 return EOB_ACT_LAST_MATCH;
1310 }
1311 }
1312
1313 /* Try to read more data. */
1314
1315 /* First move last chars to start of buffer. */
1316 number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr) - 1);
1317
1318 for ( i = 0; i < number_to_move; ++i )
1319 *(dest++) = *(source++);
1320
1321 if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING )
1322 /* don't do the read, it's not guaranteed to return an EOF,
1323 * just force an EOF
1324 */
1325 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0;
1326
1327 else
1328 {
1329 int num_to_read =
1330 YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
1331
1332 while ( num_to_read <= 0 )
1333 { /* Not enough room in the buffer - grow it. */
1334
1335 /* just a shorter name for the current buffer */
1336 YY_BUFFER_STATE b = YY_CURRENT_BUFFER_LVALUE;
1337
1338 int yy_c_buf_p_offset =
1339 (int) ((yy_c_buf_p) - b->yy_ch_buf);
1340
1341 if ( b->yy_is_our_buffer )
1342 {
1343 int new_size = b->yy_buf_size * 2;
1344
1345 if ( new_size <= 0 )
1346 b->yy_buf_size += b->yy_buf_size / 8;
1347 else
1348 b->yy_buf_size *= 2;
1349
1350 b->yy_ch_buf = (char *)
1351 /* Include room in for 2 EOB chars. */
1352 yyrealloc( (void *) b->yy_ch_buf,
1353 (yy_size_t) (b->yy_buf_size + 2) );
1354 }
1355 else
1356 /* Can't grow it, we don't own it. */
1357 b->yy_ch_buf = NULL;
1358
1359 if ( ! b->yy_ch_buf )
1360 YY_FATAL_ERROR(
1361 "fatal error - scanner input buffer overflow" );
1362
1363 (yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset];
1364
1365 num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size -
1366 number_to_move - 1;
1367
1368 }
1369
1370 if ( num_to_read > YY_READ_BUF_SIZE )
1371 num_to_read = YY_READ_BUF_SIZE;
1372
1373 /* Read in more data. */
1374 YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]),
1375 (yy_n_chars), num_to_read );
1376
1377 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
1378 }
1379
1380 if ( (yy_n_chars) == 0 )
1381 {
1382 if ( number_to_move == YY_MORE_ADJ )
1383 {
1384 ret_val = EOB_ACT_END_OF_FILE;
1385 yyrestart( yyin );
1386 }
1387
1388 else
1389 {
1390 ret_val = EOB_ACT_LAST_MATCH;
1391 YY_CURRENT_BUFFER_LVALUE->yy_buffer_status =
1392 YY_BUFFER_EOF_PENDING;
1393 }
1394 }
1395
1396 else
1397 ret_val = EOB_ACT_CONTINUE_SCAN;
1398
1399 if (((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {
1400 /* Extend the array by 50%, plus the number we really need. */
1401 int new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1);
1402 YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc(
1403 (void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf, (yy_size_t) new_size );
1404 if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
1405 YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" );
1406 /* "- 2" to take care of EOB's */
1407 YY_CURRENT_BUFFER_LVALUE->yy_buf_size = (int) (new_size - 2);
1408 }
1409
1410 (yy_n_chars) += number_to_move;
1411 YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR;
1412 YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR;
1413
1414 (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0];
1415
1416 return ret_val;
1417 }
1418
1419 /* yy_get_previous_state - get the state just before the EOB char was reached */
1420
yy_get_previous_state(void)1421 static yy_state_type yy_get_previous_state (void)
1422 {
1423 yy_state_type yy_current_state;
1424 char *yy_cp;
1425
1426 yy_current_state = (yy_start);
1427
1428 for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp )
1429 {
1430 YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
1431 if ( yy_accept[yy_current_state] )
1432 {
1433 (yy_last_accepting_state) = yy_current_state;
1434 (yy_last_accepting_cpos) = yy_cp;
1435 }
1436 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1437 {
1438 yy_current_state = (int) yy_def[yy_current_state];
1439 if ( yy_current_state >= 41 )
1440 yy_c = yy_meta[yy_c];
1441 }
1442 yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
1443 }
1444
1445 return yy_current_state;
1446 }
1447
1448 /* yy_try_NUL_trans - try to make a transition on the NUL character
1449 *
1450 * synopsis
1451 * next_state = yy_try_NUL_trans( current_state );
1452 */
yy_try_NUL_trans(yy_state_type yy_current_state)1453 static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state )
1454 {
1455 int yy_is_jam;
1456 char *yy_cp = (yy_c_buf_p);
1457
1458 YY_CHAR yy_c = 1;
1459 if ( yy_accept[yy_current_state] )
1460 {
1461 (yy_last_accepting_state) = yy_current_state;
1462 (yy_last_accepting_cpos) = yy_cp;
1463 }
1464 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1465 {
1466 yy_current_state = (int) yy_def[yy_current_state];
1467 if ( yy_current_state >= 41 )
1468 yy_c = yy_meta[yy_c];
1469 }
1470 yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
1471 yy_is_jam = (yy_current_state == 40);
1472
1473 return yy_is_jam ? 0 : yy_current_state;
1474 }
1475
1476 #ifndef YY_NO_UNPUT
1477
1478 #endif
1479
1480 #ifndef YY_NO_INPUT
1481 #ifdef __cplusplus
yyinput(void)1482 static int yyinput (void)
1483 #else
1484 static int input (void)
1485 #endif
1486
1487 {
1488 int c;
1489
1490 *(yy_c_buf_p) = (yy_hold_char);
1491
1492 if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR )
1493 {
1494 /* yy_c_buf_p now points to the character we want to return.
1495 * If this occurs *before* the EOB characters, then it's a
1496 * valid NUL; if not, then we've hit the end of the buffer.
1497 */
1498 if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
1499 /* This was really a NUL. */
1500 *(yy_c_buf_p) = '\0';
1501
1502 else
1503 { /* need more input */
1504 int offset = (int) ((yy_c_buf_p) - (yytext_ptr));
1505 ++(yy_c_buf_p);
1506
1507 switch ( yy_get_next_buffer( ) )
1508 {
1509 case EOB_ACT_LAST_MATCH:
1510 /* This happens because yy_g_n_b()
1511 * sees that we've accumulated a
1512 * token and flags that we need to
1513 * try matching the token before
1514 * proceeding. But for input(),
1515 * there's no matching to consider.
1516 * So convert the EOB_ACT_LAST_MATCH
1517 * to EOB_ACT_END_OF_FILE.
1518 */
1519
1520 /* Reset buffer status. */
1521 yyrestart( yyin );
1522
1523 /*FALLTHROUGH*/
1524
1525 case EOB_ACT_END_OF_FILE:
1526 {
1527 if ( yywrap( ) )
1528 return 0;
1529
1530 if ( ! (yy_did_buffer_switch_on_eof) )
1531 YY_NEW_FILE;
1532 #ifdef __cplusplus
1533 return yyinput();
1534 #else
1535 return input();
1536 #endif
1537 }
1538
1539 case EOB_ACT_CONTINUE_SCAN:
1540 (yy_c_buf_p) = (yytext_ptr) + offset;
1541 break;
1542 }
1543 }
1544 }
1545
1546 c = *(unsigned char *) (yy_c_buf_p); /* cast for 8-bit char's */
1547 *(yy_c_buf_p) = '\0'; /* preserve yytext */
1548 (yy_hold_char) = *++(yy_c_buf_p);
1549
1550 return c;
1551 }
1552 #endif /* ifndef YY_NO_INPUT */
1553
1554 /** Immediately switch to a different input stream.
1555 * @param input_file A readable stream.
1556 *
1557 * @note This function does not reset the start condition to @c INITIAL .
1558 */
yyrestart(FILE * input_file)1559 void yyrestart (FILE * input_file )
1560 {
1561
1562 if ( ! YY_CURRENT_BUFFER ){
1563 yyensure_buffer_stack ();
1564 YY_CURRENT_BUFFER_LVALUE =
1565 yy_create_buffer( yyin, YY_BUF_SIZE );
1566 }
1567
1568 yy_init_buffer( YY_CURRENT_BUFFER, input_file );
1569 yy_load_buffer_state( );
1570 }
1571
1572 /** Switch to a different input buffer.
1573 * @param new_buffer The new input buffer.
1574 *
1575 */
yy_switch_to_buffer(YY_BUFFER_STATE new_buffer)1576 void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer )
1577 {
1578
1579 /* TODO. We should be able to replace this entire function body
1580 * with
1581 * yypop_buffer_state();
1582 * yypush_buffer_state(new_buffer);
1583 */
1584 yyensure_buffer_stack ();
1585 if ( YY_CURRENT_BUFFER == new_buffer )
1586 return;
1587
1588 if ( YY_CURRENT_BUFFER )
1589 {
1590 /* Flush out information for old buffer. */
1591 *(yy_c_buf_p) = (yy_hold_char);
1592 YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
1593 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
1594 }
1595
1596 YY_CURRENT_BUFFER_LVALUE = new_buffer;
1597 yy_load_buffer_state( );
1598
1599 /* We don't actually know whether we did this switch during
1600 * EOF (yywrap()) processing, but the only time this flag
1601 * is looked at is after yywrap() is called, so it's safe
1602 * to go ahead and always set it.
1603 */
1604 (yy_did_buffer_switch_on_eof) = 1;
1605 }
1606
yy_load_buffer_state(void)1607 static void yy_load_buffer_state (void)
1608 {
1609 (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
1610 (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos;
1611 yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file;
1612 (yy_hold_char) = *(yy_c_buf_p);
1613 }
1614
1615 /** Allocate and initialize an input buffer state.
1616 * @param file A readable stream.
1617 * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE.
1618 *
1619 * @return the allocated buffer state.
1620 */
yy_create_buffer(FILE * file,int size)1621 YY_BUFFER_STATE yy_create_buffer (FILE * file, int size )
1622 {
1623 YY_BUFFER_STATE b;
1624
1625 b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) );
1626 if ( ! b )
1627 YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
1628
1629 b->yy_buf_size = size;
1630
1631 /* yy_ch_buf has to be 2 characters longer than the size given because
1632 * we need to put in 2 end-of-buffer characters.
1633 */
1634 b->yy_ch_buf = (char *) yyalloc( (yy_size_t) (b->yy_buf_size + 2) );
1635 if ( ! b->yy_ch_buf )
1636 YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
1637
1638 b->yy_is_our_buffer = 1;
1639
1640 yy_init_buffer( b, file );
1641
1642 return b;
1643 }
1644
1645 /** Destroy the buffer.
1646 * @param b a buffer created with yy_create_buffer()
1647 *
1648 */
yy_delete_buffer(YY_BUFFER_STATE b)1649 void yy_delete_buffer (YY_BUFFER_STATE b )
1650 {
1651
1652 if ( ! b )
1653 return;
1654
1655 if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */
1656 YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0;
1657
1658 if ( b->yy_is_our_buffer )
1659 yyfree( (void *) b->yy_ch_buf );
1660
1661 yyfree( (void *) b );
1662 }
1663
1664 /* Initializes or reinitializes a buffer.
1665 * This function is sometimes called more than once on the same buffer,
1666 * such as during a yyrestart() or at EOF.
1667 */
yy_init_buffer(YY_BUFFER_STATE b,FILE * file)1668 static void yy_init_buffer (YY_BUFFER_STATE b, FILE * file )
1669
1670 {
1671 int oerrno = errno;
1672
1673 yy_flush_buffer( b );
1674
1675 b->yy_input_file = file;
1676 b->yy_fill_buffer = 1;
1677
1678 /* If b is the current buffer, then yy_init_buffer was _probably_
1679 * called from yyrestart() or through yy_get_next_buffer.
1680 * In that case, we don't want to reset the lineno or column.
1681 */
1682 if (b != YY_CURRENT_BUFFER){
1683 b->yy_bs_lineno = 1;
1684 b->yy_bs_column = 0;
1685 }
1686
1687 b->yy_is_interactive = 0;
1688
1689 errno = oerrno;
1690 }
1691
1692 /** Discard all buffered characters. On the next scan, YY_INPUT will be called.
1693 * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER.
1694 *
1695 */
yy_flush_buffer(YY_BUFFER_STATE b)1696 void yy_flush_buffer (YY_BUFFER_STATE b )
1697 {
1698 if ( ! b )
1699 return;
1700
1701 b->yy_n_chars = 0;
1702
1703 /* We always need two end-of-buffer characters. The first causes
1704 * a transition to the end-of-buffer state. The second causes
1705 * a jam in that state.
1706 */
1707 b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
1708 b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
1709
1710 b->yy_buf_pos = &b->yy_ch_buf[0];
1711
1712 b->yy_at_bol = 1;
1713 b->yy_buffer_status = YY_BUFFER_NEW;
1714
1715 if ( b == YY_CURRENT_BUFFER )
1716 yy_load_buffer_state( );
1717 }
1718
1719 /** Pushes the new state onto the stack. The new state becomes
1720 * the current state. This function will allocate the stack
1721 * if necessary.
1722 * @param new_buffer The new state.
1723 *
1724 */
yypush_buffer_state(YY_BUFFER_STATE new_buffer)1725 void yypush_buffer_state (YY_BUFFER_STATE new_buffer )
1726 {
1727 if (new_buffer == NULL)
1728 return;
1729
1730 yyensure_buffer_stack();
1731
1732 /* This block is copied from yy_switch_to_buffer. */
1733 if ( YY_CURRENT_BUFFER )
1734 {
1735 /* Flush out information for old buffer. */
1736 *(yy_c_buf_p) = (yy_hold_char);
1737 YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
1738 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
1739 }
1740
1741 /* Only push if top exists. Otherwise, replace top. */
1742 if (YY_CURRENT_BUFFER)
1743 (yy_buffer_stack_top)++;
1744 YY_CURRENT_BUFFER_LVALUE = new_buffer;
1745
1746 /* copied from yy_switch_to_buffer. */
1747 yy_load_buffer_state( );
1748 (yy_did_buffer_switch_on_eof) = 1;
1749 }
1750
1751 /** Removes and deletes the top of the stack, if present.
1752 * The next element becomes the new top.
1753 *
1754 */
yypop_buffer_state(void)1755 void yypop_buffer_state (void)
1756 {
1757 if (!YY_CURRENT_BUFFER)
1758 return;
1759
1760 yy_delete_buffer(YY_CURRENT_BUFFER );
1761 YY_CURRENT_BUFFER_LVALUE = NULL;
1762 if ((yy_buffer_stack_top) > 0)
1763 --(yy_buffer_stack_top);
1764
1765 if (YY_CURRENT_BUFFER) {
1766 yy_load_buffer_state( );
1767 (yy_did_buffer_switch_on_eof) = 1;
1768 }
1769 }
1770
1771 /* Allocates the stack if it does not exist.
1772 * Guarantees space for at least one push.
1773 */
yyensure_buffer_stack(void)1774 static void yyensure_buffer_stack (void)
1775 {
1776 yy_size_t num_to_alloc;
1777
1778 if (!(yy_buffer_stack)) {
1779
1780 /* First allocation is just for 2 elements, since we don't know if this
1781 * scanner will even need a stack. We use 2 instead of 1 to avoid an
1782 * immediate realloc on the next call.
1783 */
1784 num_to_alloc = 1; /* After all that talk, this was set to 1 anyways... */
1785 (yy_buffer_stack) = (struct yy_buffer_state**)yyalloc
1786 (num_to_alloc * sizeof(struct yy_buffer_state*)
1787 );
1788 if ( ! (yy_buffer_stack) )
1789 YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" );
1790
1791 memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*));
1792
1793 (yy_buffer_stack_max) = num_to_alloc;
1794 (yy_buffer_stack_top) = 0;
1795 return;
1796 }
1797
1798 if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){
1799
1800 /* Increase the buffer to prepare for a possible push. */
1801 yy_size_t grow_size = 8 /* arbitrary grow size */;
1802
1803 num_to_alloc = (yy_buffer_stack_max) + grow_size;
1804 (yy_buffer_stack) = (struct yy_buffer_state**)yyrealloc
1805 ((yy_buffer_stack),
1806 num_to_alloc * sizeof(struct yy_buffer_state*)
1807 );
1808 if ( ! (yy_buffer_stack) )
1809 YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" );
1810
1811 /* zero only the new slots.*/
1812 memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*));
1813 (yy_buffer_stack_max) = num_to_alloc;
1814 }
1815 }
1816
1817 /** Setup the input buffer state to scan directly from a user-specified character buffer.
1818 * @param base the character buffer
1819 * @param size the size in bytes of the character buffer
1820 *
1821 * @return the newly allocated buffer state object.
1822 */
yy_scan_buffer(char * base,yy_size_t size)1823 YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size )
1824 {
1825 YY_BUFFER_STATE b;
1826
1827 if ( size < 2 ||
1828 base[size-2] != YY_END_OF_BUFFER_CHAR ||
1829 base[size-1] != YY_END_OF_BUFFER_CHAR )
1830 /* They forgot to leave room for the EOB's. */
1831 return NULL;
1832
1833 b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) );
1834 if ( ! b )
1835 YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" );
1836
1837 b->yy_buf_size = (int) (size - 2); /* "- 2" to take care of EOB's */
1838 b->yy_buf_pos = b->yy_ch_buf = base;
1839 b->yy_is_our_buffer = 0;
1840 b->yy_input_file = NULL;
1841 b->yy_n_chars = b->yy_buf_size;
1842 b->yy_is_interactive = 0;
1843 b->yy_at_bol = 1;
1844 b->yy_fill_buffer = 0;
1845 b->yy_buffer_status = YY_BUFFER_NEW;
1846
1847 yy_switch_to_buffer( b );
1848
1849 return b;
1850 }
1851
1852 /** Setup the input buffer state to scan a string. The next call to yylex() will
1853 * scan from a @e copy of @a str.
1854 * @param yystr a NUL-terminated string to scan
1855 *
1856 * @return the newly allocated buffer state object.
1857 * @note If you want to scan bytes that may contain NUL values, then use
1858 * yy_scan_bytes() instead.
1859 */
yy_scan_string(const char * yystr)1860 YY_BUFFER_STATE yy_scan_string (const char * yystr )
1861 {
1862
1863 return yy_scan_bytes( yystr, (int) strlen(yystr) );
1864 }
1865
1866 /** Setup the input buffer state to scan the given bytes. The next call to yylex() will
1867 * scan from a @e copy of @a bytes.
1868 * @param yybytes the byte buffer to scan
1869 * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes.
1870 *
1871 * @return the newly allocated buffer state object.
1872 */
yy_scan_bytes(const char * yybytes,int _yybytes_len)1873 YY_BUFFER_STATE yy_scan_bytes (const char * yybytes, int _yybytes_len )
1874 {
1875 YY_BUFFER_STATE b;
1876 char *buf;
1877 yy_size_t n;
1878 int i;
1879
1880 /* Get memory for full buffer, including space for trailing EOB's. */
1881 n = (yy_size_t) (_yybytes_len + 2);
1882 buf = (char *) yyalloc( n );
1883 if ( ! buf )
1884 YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" );
1885
1886 for ( i = 0; i < _yybytes_len; ++i )
1887 buf[i] = yybytes[i];
1888
1889 buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR;
1890
1891 b = yy_scan_buffer( buf, n );
1892 if ( ! b )
1893 YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" );
1894
1895 /* It's okay to grow etc. this buffer, and we should throw it
1896 * away when we're done.
1897 */
1898 b->yy_is_our_buffer = 1;
1899
1900 return b;
1901 }
1902
1903 #ifndef YY_EXIT_FAILURE
1904 #define YY_EXIT_FAILURE 2
1905 #endif
1906
yy_fatal_error(const char * msg)1907 static void yynoreturn yy_fatal_error (const char* msg )
1908 {
1909 fprintf( stderr, "%s\n", msg );
1910 exit( YY_EXIT_FAILURE );
1911 }
1912
1913 /* Redefine yyless() so it works in section 3 code. */
1914
1915 #undef yyless
1916 #define yyless(n) \
1917 do \
1918 { \
1919 /* Undo effects of setting up yytext. */ \
1920 int yyless_macro_arg = (n); \
1921 YY_LESS_LINENO(yyless_macro_arg);\
1922 yytext[yyleng] = (yy_hold_char); \
1923 (yy_c_buf_p) = yytext + yyless_macro_arg; \
1924 (yy_hold_char) = *(yy_c_buf_p); \
1925 *(yy_c_buf_p) = '\0'; \
1926 yyleng = yyless_macro_arg; \
1927 } \
1928 while ( 0 )
1929
1930 /* Accessor methods (get/set functions) to struct members. */
1931
1932 /** Get the current line number.
1933 *
1934 */
yyget_lineno(void)1935 int yyget_lineno (void)
1936 {
1937
1938 return yylineno;
1939 }
1940
1941 /** Get the input stream.
1942 *
1943 */
yyget_in(void)1944 FILE *yyget_in (void)
1945 {
1946 return yyin;
1947 }
1948
1949 /** Get the output stream.
1950 *
1951 */
yyget_out(void)1952 FILE *yyget_out (void)
1953 {
1954 return yyout;
1955 }
1956
1957 /** Get the length of the current token.
1958 *
1959 */
yyget_leng(void)1960 int yyget_leng (void)
1961 {
1962 return yyleng;
1963 }
1964
1965 /** Get the current token.
1966 *
1967 */
1968
yyget_text(void)1969 char *yyget_text (void)
1970 {
1971 return yytext;
1972 }
1973
1974 /** Set the current line number.
1975 * @param _line_number line number
1976 *
1977 */
yyset_lineno(int _line_number)1978 void yyset_lineno (int _line_number )
1979 {
1980
1981 yylineno = _line_number;
1982 }
1983
1984 /** Set the input stream. This does not discard the current
1985 * input buffer.
1986 * @param _in_str A readable stream.
1987 *
1988 * @see yy_switch_to_buffer
1989 */
yyset_in(FILE * _in_str)1990 void yyset_in (FILE * _in_str )
1991 {
1992 yyin = _in_str ;
1993 }
1994
yyset_out(FILE * _out_str)1995 void yyset_out (FILE * _out_str )
1996 {
1997 yyout = _out_str ;
1998 }
1999
yyget_debug(void)2000 int yyget_debug (void)
2001 {
2002 return yy_flex_debug;
2003 }
2004
yyset_debug(int _bdebug)2005 void yyset_debug (int _bdebug )
2006 {
2007 yy_flex_debug = _bdebug ;
2008 }
2009
yy_init_globals(void)2010 static int yy_init_globals (void)
2011 {
2012 /* Initialization is the same as for the non-reentrant scanner.
2013 * This function is called from yylex_destroy(), so don't allocate here.
2014 */
2015
2016 (yy_buffer_stack) = NULL;
2017 (yy_buffer_stack_top) = 0;
2018 (yy_buffer_stack_max) = 0;
2019 (yy_c_buf_p) = NULL;
2020 (yy_init) = 0;
2021 (yy_start) = 0;
2022
2023 /* Defined in main.c */
2024 #ifdef YY_STDINIT
2025 yyin = stdin;
2026 yyout = stdout;
2027 #else
2028 yyin = NULL;
2029 yyout = NULL;
2030 #endif
2031
2032 /* For future reference: Set errno on error, since we are called by
2033 * yylex_init()
2034 */
2035 return 0;
2036 }
2037
2038 /* yylex_destroy is for both reentrant and non-reentrant scanners. */
yylex_destroy(void)2039 int yylex_destroy (void)
2040 {
2041
2042 /* Pop the buffer stack, destroying each element. */
2043 while(YY_CURRENT_BUFFER){
2044 yy_delete_buffer( YY_CURRENT_BUFFER );
2045 YY_CURRENT_BUFFER_LVALUE = NULL;
2046 yypop_buffer_state();
2047 }
2048
2049 /* Destroy the stack itself. */
2050 yyfree((yy_buffer_stack) );
2051 (yy_buffer_stack) = NULL;
2052
2053 /* Reset the globals. This is important in a non-reentrant scanner so the next time
2054 * yylex() is called, initialization will occur. */
2055 yy_init_globals( );
2056
2057 return 0;
2058 }
2059
2060 /*
2061 * Internal utility routines.
2062 */
2063
2064 #ifndef yytext_ptr
yy_flex_strncpy(char * s1,const char * s2,int n)2065 static void yy_flex_strncpy (char* s1, const char * s2, int n )
2066 {
2067
2068 int i;
2069 for ( i = 0; i < n; ++i )
2070 s1[i] = s2[i];
2071 }
2072 #endif
2073
2074 #ifdef YY_NEED_STRLEN
yy_flex_strlen(const char * s)2075 static int yy_flex_strlen (const char * s )
2076 {
2077 int n;
2078 for ( n = 0; s[n]; ++n )
2079 ;
2080
2081 return n;
2082 }
2083 #endif
2084
yyalloc(yy_size_t size)2085 void *yyalloc (yy_size_t size )
2086 {
2087 return malloc(size);
2088 }
2089
yyrealloc(void * ptr,yy_size_t size)2090 void *yyrealloc (void * ptr, yy_size_t size )
2091 {
2092
2093 /* The cast to (char *) in the following accommodates both
2094 * implementations that use char* generic pointers, and those
2095 * that use void* generic pointers. It works with the latter
2096 * because both ANSI C and C++ allow castless assignment from
2097 * any pointer type to void*, and deal with argument conversions
2098 * as though doing an assignment.
2099 */
2100 return realloc(ptr, size);
2101 }
2102
yyfree(void * ptr)2103 void yyfree (void * ptr )
2104 {
2105 free( (char *) ptr ); /* see yyrealloc() for (char *) cast */
2106 }
2107
2108 #define YYTABLES_NAME "yytables"
2109
2110 #line 108 "guc-file.l"
2111
2112
2113
2114
2115 /*
2116 * Exported function to read and process the configuration file. The
2117 * parameter indicates in what context the file is being read --- either
2118 * postmaster startup (including standalone-backend startup) or SIGHUP.
2119 * All options mentioned in the configuration file are set to new values.
2120 * If a hard error occurs, no values will be changed. (There can also be
2121 * errors that prevent just one value from being changed.)
2122 */
2123 void
ProcessConfigFile(GucContext context)2124 ProcessConfigFile(GucContext context)
2125 {
2126 int elevel;
2127 MemoryContext config_cxt;
2128 MemoryContext caller_cxt;
2129
2130 /*
2131 * Config files are processed on startup (by the postmaster only) and on
2132 * SIGHUP (by the postmaster and its children)
2133 */
2134 Assert((context == PGC_POSTMASTER && !IsUnderPostmaster) ||
2135 context == PGC_SIGHUP);
2136
2137 /*
2138 * To avoid cluttering the log, only the postmaster bleats loudly about
2139 * problems with the config file.
2140 */
2141 elevel = IsUnderPostmaster ? DEBUG2 : LOG;
2142
2143 /*
2144 * This function is usually called within a process-lifespan memory
2145 * context. To ensure that any memory leaked during GUC processing does
2146 * not accumulate across repeated SIGHUP cycles, do the work in a private
2147 * context that we can free at exit.
2148 */
2149 config_cxt = AllocSetContextCreate(CurrentMemoryContext,
2150 "config file processing",
2151 ALLOCSET_DEFAULT_SIZES);
2152 caller_cxt = MemoryContextSwitchTo(config_cxt);
2153
2154 /*
2155 * Read and apply the config file. We don't need to examine the result.
2156 */
2157 (void) ProcessConfigFileInternal(context, true, elevel);
2158
2159 /* Clean up */
2160 MemoryContextSwitchTo(caller_cxt);
2161 MemoryContextDelete(config_cxt);
2162 }
2163
2164 /*
2165 * This function handles both actual config file (re)loads and execution of
2166 * show_all_file_settings() (i.e., the pg_file_settings view). In the latter
2167 * case we don't apply any of the settings, but we make all the usual validity
2168 * checks, and we return the ConfigVariable list so that it can be printed out
2169 * by show_all_file_settings().
2170 */
2171 static ConfigVariable *
ProcessConfigFileInternal(GucContext context,bool applySettings,int elevel)2172 ProcessConfigFileInternal(GucContext context, bool applySettings, int elevel)
2173 {
2174 bool error = false;
2175 bool applying = false;
2176 const char *ConfFileWithError;
2177 ConfigVariable *item,
2178 *head,
2179 *tail;
2180 int i;
2181
2182 /* Parse the main config file into a list of option names and values */
2183 ConfFileWithError = ConfigFileName;
2184 head = tail = NULL;
2185
2186 if (!ParseConfigFile(ConfigFileName, true,
2187 NULL, 0, 0, elevel,
2188 &head, &tail))
2189 {
2190 /* Syntax error(s) detected in the file, so bail out */
2191 error = true;
2192 goto bail_out;
2193 }
2194
2195 /*
2196 * Parse the PG_AUTOCONF_FILENAME file, if present, after the main file to
2197 * replace any parameters set by ALTER SYSTEM command. Because this file
2198 * is in the data directory, we can't read it until the DataDir has been
2199 * set.
2200 */
2201 if (DataDir)
2202 {
2203 if (!ParseConfigFile(PG_AUTOCONF_FILENAME, false,
2204 NULL, 0, 0, elevel,
2205 &head, &tail))
2206 {
2207 /* Syntax error(s) detected in the file, so bail out */
2208 error = true;
2209 ConfFileWithError = PG_AUTOCONF_FILENAME;
2210 goto bail_out;
2211 }
2212 }
2213 else
2214 {
2215 /*
2216 * If DataDir is not set, the PG_AUTOCONF_FILENAME file cannot be
2217 * read. In this case, we don't want to accept any settings but
2218 * data_directory from postgresql.conf, because they might be
2219 * overwritten with settings in the PG_AUTOCONF_FILENAME file which
2220 * will be read later. OTOH, since data_directory isn't allowed in the
2221 * PG_AUTOCONF_FILENAME file, it will never be overwritten later.
2222 */
2223 ConfigVariable *newlist = NULL;
2224
2225 /*
2226 * Prune all items except the last "data_directory" from the list.
2227 */
2228 for (item = head; item; item = item->next)
2229 {
2230 if (!item->ignore &&
2231 strcmp(item->name, "data_directory") == 0)
2232 newlist = item;
2233 }
2234
2235 if (newlist)
2236 newlist->next = NULL;
2237 head = tail = newlist;
2238
2239 /*
2240 * Quick exit if data_directory is not present in file.
2241 *
2242 * We need not do any further processing, in particular we don't set
2243 * PgReloadTime; that will be set soon by subsequent full loading of
2244 * the config file.
2245 */
2246 if (head == NULL)
2247 goto bail_out;
2248 }
2249
2250 /*
2251 * Mark all extant GUC variables as not present in the config file. We
2252 * need this so that we can tell below which ones have been removed from
2253 * the file since we last processed it.
2254 */
2255 for (i = 0; i < num_guc_variables; i++)
2256 {
2257 struct config_generic *gconf = guc_variables[i];
2258
2259 gconf->status &= ~GUC_IS_IN_FILE;
2260 }
2261
2262 /*
2263 * Check if all the supplied option names are valid, as an additional
2264 * quasi-syntactic check on the validity of the config file. It is
2265 * important that the postmaster and all backends agree on the results of
2266 * this phase, else we will have strange inconsistencies about which
2267 * processes accept a config file update and which don't. Hence, unknown
2268 * custom variable names have to be accepted without complaint. For the
2269 * same reason, we don't attempt to validate the options' values here.
2270 *
2271 * In addition, the GUC_IS_IN_FILE flag is set on each existing GUC
2272 * variable mentioned in the file; and we detect duplicate entries in the
2273 * file and mark the earlier occurrences as ignorable.
2274 */
2275 for (item = head; item; item = item->next)
2276 {
2277 struct config_generic *record;
2278
2279 /* Ignore anything already marked as ignorable */
2280 if (item->ignore)
2281 continue;
2282
2283 /*
2284 * Try to find the variable; but do not create a custom placeholder if
2285 * it's not there already.
2286 */
2287 record = find_option(item->name, false, elevel);
2288
2289 if (record)
2290 {
2291 /* If it's already marked, then this is a duplicate entry */
2292 if (record->status & GUC_IS_IN_FILE)
2293 {
2294 /*
2295 * Mark the earlier occurrence(s) as dead/ignorable. We could
2296 * avoid the O(N^2) behavior here with some additional state,
2297 * but it seems unlikely to be worth the trouble.
2298 */
2299 ConfigVariable *pitem;
2300
2301 for (pitem = head; pitem != item; pitem = pitem->next)
2302 {
2303 if (!pitem->ignore &&
2304 strcmp(pitem->name, item->name) == 0)
2305 pitem->ignore = true;
2306 }
2307 }
2308 /* Now mark it as present in file */
2309 record->status |= GUC_IS_IN_FILE;
2310 }
2311 else if (strchr(item->name, GUC_QUALIFIER_SEPARATOR) == NULL)
2312 {
2313 /* Invalid non-custom variable, so complain */
2314 ereport(elevel,
2315 (errcode(ERRCODE_UNDEFINED_OBJECT),
2316 errmsg("unrecognized configuration parameter \"%s\" in file \"%s\" line %u",
2317 item->name,
2318 item->filename, item->sourceline)));
2319 item->errmsg = pstrdup("unrecognized configuration parameter");
2320 error = true;
2321 ConfFileWithError = item->filename;
2322 }
2323 }
2324
2325 /*
2326 * If we've detected any errors so far, we don't want to risk applying any
2327 * changes.
2328 */
2329 if (error)
2330 goto bail_out;
2331
2332 /* Otherwise, set flag that we're beginning to apply changes */
2333 applying = true;
2334
2335 /*
2336 * Check for variables having been removed from the config file, and
2337 * revert their reset values (and perhaps also effective values) to the
2338 * boot-time defaults. If such a variable can't be changed after startup,
2339 * report that and continue.
2340 */
2341 for (i = 0; i < num_guc_variables; i++)
2342 {
2343 struct config_generic *gconf = guc_variables[i];
2344 GucStack *stack;
2345
2346 if (gconf->reset_source != PGC_S_FILE ||
2347 (gconf->status & GUC_IS_IN_FILE))
2348 continue;
2349 if (gconf->context < PGC_SIGHUP)
2350 {
2351 /* The removal can't be effective without a restart */
2352 gconf->status |= GUC_PENDING_RESTART;
2353 ereport(elevel,
2354 (errcode(ERRCODE_CANT_CHANGE_RUNTIME_PARAM),
2355 errmsg("parameter \"%s\" cannot be changed without restarting the server",
2356 gconf->name)));
2357 record_config_file_error(psprintf("parameter \"%s\" cannot be changed without restarting the server",
2358 gconf->name),
2359 NULL, 0,
2360 &head, &tail);
2361 error = true;
2362 continue;
2363 }
2364
2365 /* No more to do if we're just doing show_all_file_settings() */
2366 if (!applySettings)
2367 continue;
2368
2369 /*
2370 * Reset any "file" sources to "default", else set_config_option will
2371 * not override those settings.
2372 */
2373 if (gconf->reset_source == PGC_S_FILE)
2374 gconf->reset_source = PGC_S_DEFAULT;
2375 if (gconf->source == PGC_S_FILE)
2376 gconf->source = PGC_S_DEFAULT;
2377 for (stack = gconf->stack; stack; stack = stack->prev)
2378 {
2379 if (stack->source == PGC_S_FILE)
2380 stack->source = PGC_S_DEFAULT;
2381 }
2382
2383 /* Now we can re-apply the wired-in default (i.e., the boot_val) */
2384 if (set_config_option(gconf->name, NULL,
2385 context, PGC_S_DEFAULT,
2386 GUC_ACTION_SET, true, 0, false) > 0)
2387 {
2388 /* Log the change if appropriate */
2389 if (context == PGC_SIGHUP)
2390 ereport(elevel,
2391 (errmsg("parameter \"%s\" removed from configuration file, reset to default",
2392 gconf->name)));
2393 }
2394 }
2395
2396 /*
2397 * Restore any variables determined by environment variables or
2398 * dynamically-computed defaults. This is a no-op except in the case
2399 * where one of these had been in the config file and is now removed.
2400 *
2401 * In particular, we *must not* do this during the postmaster's initial
2402 * loading of the file, since the timezone functions in particular should
2403 * be run only after initialization is complete.
2404 *
2405 * XXX this is an unmaintainable crock, because we have to know how to set
2406 * (or at least what to call to set) every variable that could potentially
2407 * have PGC_S_DYNAMIC_DEFAULT or PGC_S_ENV_VAR source. However, there's no
2408 * time to redesign it for 9.1.
2409 */
2410 if (context == PGC_SIGHUP && applySettings)
2411 {
2412 InitializeGUCOptionsFromEnvironment();
2413 pg_timezone_abbrev_initialize();
2414 /* this selects SQL_ASCII in processes not connected to a database */
2415 SetConfigOption("client_encoding", GetDatabaseEncodingName(),
2416 PGC_BACKEND, PGC_S_DYNAMIC_DEFAULT);
2417 }
2418
2419 /*
2420 * Now apply the values from the config file.
2421 */
2422 for (item = head; item; item = item->next)
2423 {
2424 char *pre_value = NULL;
2425 int scres;
2426
2427 /* Ignore anything marked as ignorable */
2428 if (item->ignore)
2429 continue;
2430
2431 /* In SIGHUP cases in the postmaster, we want to report changes */
2432 if (context == PGC_SIGHUP && applySettings && !IsUnderPostmaster)
2433 {
2434 const char *preval = GetConfigOption(item->name, true, false);
2435
2436 /* If option doesn't exist yet or is NULL, treat as empty string */
2437 if (!preval)
2438 preval = "";
2439 /* must dup, else might have dangling pointer below */
2440 pre_value = pstrdup(preval);
2441 }
2442
2443 scres = set_config_option(item->name, item->value,
2444 context, PGC_S_FILE,
2445 GUC_ACTION_SET, applySettings, 0, false);
2446 if (scres > 0)
2447 {
2448 /* variable was updated, so log the change if appropriate */
2449 if (pre_value)
2450 {
2451 const char *post_value = GetConfigOption(item->name, true, false);
2452
2453 if (!post_value)
2454 post_value = "";
2455 if (strcmp(pre_value, post_value) != 0)
2456 ereport(elevel,
2457 (errmsg("parameter \"%s\" changed to \"%s\"",
2458 item->name, item->value)));
2459 }
2460 item->applied = true;
2461 }
2462 else if (scres == 0)
2463 {
2464 error = true;
2465 item->errmsg = pstrdup("setting could not be applied");
2466 ConfFileWithError = item->filename;
2467 }
2468 else
2469 {
2470 /* no error, but variable's active value was not changed */
2471 item->applied = true;
2472 }
2473
2474 /*
2475 * We should update source location unless there was an error, since
2476 * even if the active value didn't change, the reset value might have.
2477 * (In the postmaster, there won't be a difference, but it does matter
2478 * in backends.)
2479 */
2480 if (scres != 0 && applySettings)
2481 set_config_sourcefile(item->name, item->filename,
2482 item->sourceline);
2483
2484 if (pre_value)
2485 pfree(pre_value);
2486 }
2487
2488 /* Remember when we last successfully loaded the config file. */
2489 if (applySettings)
2490 PgReloadTime = GetCurrentTimestamp();
2491
2492 bail_out:
2493 if (error && applySettings)
2494 {
2495 /* During postmaster startup, any error is fatal */
2496 if (context == PGC_POSTMASTER)
2497 ereport(ERROR,
2498 (errcode(ERRCODE_CONFIG_FILE_ERROR),
2499 errmsg("configuration file \"%s\" contains errors",
2500 ConfFileWithError)));
2501 else if (applying)
2502 ereport(elevel,
2503 (errcode(ERRCODE_CONFIG_FILE_ERROR),
2504 errmsg("configuration file \"%s\" contains errors; unaffected changes were applied",
2505 ConfFileWithError)));
2506 else
2507 ereport(elevel,
2508 (errcode(ERRCODE_CONFIG_FILE_ERROR),
2509 errmsg("configuration file \"%s\" contains errors; no changes were applied",
2510 ConfFileWithError)));
2511 }
2512
2513 /* Successful or otherwise, return the collected data list */
2514 return head;
2515 }
2516
2517 /*
2518 * Given a configuration file or directory location that may be a relative
2519 * path, return an absolute one. We consider the location to be relative to
2520 * the directory holding the calling file, or to DataDir if no calling file.
2521 */
2522 static char *
AbsoluteConfigLocation(const char * location,const char * calling_file)2523 AbsoluteConfigLocation(const char *location, const char *calling_file)
2524 {
2525 char abs_path[MAXPGPATH];
2526
2527 if (is_absolute_path(location))
2528 return pstrdup(location);
2529 else
2530 {
2531 if (calling_file != NULL)
2532 {
2533 strlcpy(abs_path, calling_file, sizeof(abs_path));
2534 get_parent_directory(abs_path);
2535 join_path_components(abs_path, abs_path, location);
2536 canonicalize_path(abs_path);
2537 }
2538 else
2539 {
2540 AssertState(DataDir);
2541 join_path_components(abs_path, DataDir, location);
2542 canonicalize_path(abs_path);
2543 }
2544 return pstrdup(abs_path);
2545 }
2546 }
2547
2548 /*
2549 * Read and parse a single configuration file. This function recurses
2550 * to handle "include" directives.
2551 *
2552 * If "strict" is true, treat failure to open the config file as an error,
2553 * otherwise just skip the file.
2554 *
2555 * calling_file/calling_lineno identify the source of the request.
2556 * Pass NULL/0 if not recursing from an inclusion request.
2557 *
2558 * See ParseConfigFp for further details. This one merely adds opening the
2559 * config file rather than working from a caller-supplied file descriptor,
2560 * and absolute-ifying the path name if necessary.
2561 */
2562 bool
ParseConfigFile(const char * config_file,bool strict,const char * calling_file,int calling_lineno,int depth,int elevel,ConfigVariable ** head_p,ConfigVariable ** tail_p)2563 ParseConfigFile(const char *config_file, bool strict,
2564 const char *calling_file, int calling_lineno,
2565 int depth, int elevel,
2566 ConfigVariable **head_p,
2567 ConfigVariable **tail_p)
2568 {
2569 char *abs_path;
2570 bool OK = true;
2571 FILE *fp;
2572
2573 /*
2574 * Reject file name that is all-blank (including empty), as that leads to
2575 * confusion --- we'd try to read the containing directory as a file.
2576 */
2577 if (strspn(config_file, " \t\r\n") == strlen(config_file))
2578 {
2579 ereport(elevel,
2580 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
2581 errmsg("empty configuration file name: \"%s\"",
2582 config_file)));
2583 record_config_file_error("empty configuration file name",
2584 calling_file, calling_lineno,
2585 head_p, tail_p);
2586 return false;
2587 }
2588
2589 /*
2590 * Reject too-deep include nesting depth. This is just a safety check to
2591 * avoid dumping core due to stack overflow if an include file loops back
2592 * to itself. The maximum nesting depth is pretty arbitrary.
2593 */
2594 if (depth > 10)
2595 {
2596 ereport(elevel,
2597 (errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
2598 errmsg("could not open configuration file \"%s\": maximum nesting depth exceeded",
2599 config_file)));
2600 record_config_file_error("nesting depth exceeded",
2601 calling_file, calling_lineno,
2602 head_p, tail_p);
2603 return false;
2604 }
2605
2606 abs_path = AbsoluteConfigLocation(config_file, calling_file);
2607
2608 /*
2609 * Reject direct recursion. Indirect recursion is also possible, but it's
2610 * harder to detect and so doesn't seem worth the trouble. (We test at
2611 * this step because the canonicalization done by AbsoluteConfigLocation
2612 * makes it more likely that a simple strcmp comparison will match.)
2613 */
2614 if (calling_file && strcmp(abs_path, calling_file) == 0)
2615 {
2616 ereport(elevel,
2617 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
2618 errmsg("configuration file recursion in \"%s\"",
2619 calling_file)));
2620 record_config_file_error("configuration file recursion",
2621 calling_file, calling_lineno,
2622 head_p, tail_p);
2623 pfree(abs_path);
2624 return false;
2625 }
2626
2627 fp = AllocateFile(abs_path, "r");
2628 if (!fp)
2629 {
2630 if (strict)
2631 {
2632 ereport(elevel,
2633 (errcode_for_file_access(),
2634 errmsg("could not open configuration file \"%s\": %m",
2635 abs_path)));
2636 record_config_file_error(psprintf("could not open file \"%s\"",
2637 abs_path),
2638 calling_file, calling_lineno,
2639 head_p, tail_p);
2640 OK = false;
2641 }
2642 else
2643 {
2644 ereport(LOG,
2645 (errmsg("skipping missing configuration file \"%s\"",
2646 abs_path)));
2647 }
2648 goto cleanup;
2649 }
2650
2651 OK = ParseConfigFp(fp, abs_path, depth, elevel, head_p, tail_p);
2652
2653 cleanup:
2654 if (fp)
2655 FreeFile(fp);
2656 pfree(abs_path);
2657
2658 return OK;
2659 }
2660
2661 /*
2662 * Capture an error message in the ConfigVariable list returned by
2663 * config file parsing.
2664 */
2665 static void
record_config_file_error(const char * errmsg,const char * config_file,int lineno,ConfigVariable ** head_p,ConfigVariable ** tail_p)2666 record_config_file_error(const char *errmsg,
2667 const char *config_file,
2668 int lineno,
2669 ConfigVariable **head_p,
2670 ConfigVariable **tail_p)
2671 {
2672 ConfigVariable *item;
2673
2674 item = palloc(sizeof *item);
2675 item->name = NULL;
2676 item->value = NULL;
2677 item->errmsg = pstrdup(errmsg);
2678 item->filename = config_file ? pstrdup(config_file) : NULL;
2679 item->sourceline = lineno;
2680 item->ignore = true;
2681 item->applied = false;
2682 item->next = NULL;
2683 if (*head_p == NULL)
2684 *head_p = item;
2685 else
2686 (*tail_p)->next = item;
2687 *tail_p = item;
2688 }
2689
2690 /*
2691 * Flex fatal errors bring us here. Stash the error message and jump back to
2692 * ParseConfigFp(). Assume all msg arguments point to string constants; this
2693 * holds for flex 2.5.31 (earliest we support) and flex 2.5.35 (latest as of
2694 * this writing). Otherwise, we would need to copy the message.
2695 *
2696 * We return "int" since this takes the place of calls to fprintf().
2697 */
2698 static int
GUC_flex_fatal(const char * msg)2699 GUC_flex_fatal(const char *msg)
2700 {
2701 GUC_flex_fatal_errmsg = msg;
2702 siglongjmp(*GUC_flex_fatal_jmp, 1);
2703 return 0; /* keep compiler quiet */
2704 }
2705
2706 /*
2707 * Read and parse a single configuration file. This function recurses
2708 * to handle "include" directives.
2709 *
2710 * Input parameters:
2711 * fp: file pointer from AllocateFile for the configuration file to parse
2712 * config_file: absolute or relative path name of the configuration file
2713 * depth: recursion depth (should be 0 in the outermost call)
2714 * elevel: error logging level to use
2715 * Input/Output parameters:
2716 * head_p, tail_p: head and tail of linked list of name/value pairs
2717 *
2718 * *head_p and *tail_p must be initialized, either to NULL or valid pointers
2719 * to a ConfigVariable list, before calling the outer recursion level. Any
2720 * name-value pairs read from the input file(s) will be appended to the list.
2721 * Error reports will also be appended to the list, if elevel < ERROR.
2722 *
2723 * Returns TRUE if successful, FALSE if an error occurred. The error has
2724 * already been ereport'd, it is only necessary for the caller to clean up
2725 * its own state and release the ConfigVariable list.
2726 *
2727 * Note: if elevel >= ERROR then an error will not return control to the
2728 * caller, so there is no need to check the return value in that case.
2729 *
2730 * Note: this function is used to parse not only postgresql.conf, but
2731 * various other configuration files that use the same "name = value"
2732 * syntax. Hence, do not do anything here or in the subsidiary routines
2733 * ParseConfigFile/ParseConfigDirectory that assumes we are processing
2734 * GUCs specifically.
2735 */
2736 bool
ParseConfigFp(FILE * fp,const char * config_file,int depth,int elevel,ConfigVariable ** head_p,ConfigVariable ** tail_p)2737 ParseConfigFp(FILE *fp, const char *config_file, int depth, int elevel,
2738 ConfigVariable **head_p, ConfigVariable **tail_p)
2739 {
2740 volatile bool OK = true;
2741 unsigned int save_ConfigFileLineno = ConfigFileLineno;
2742 sigjmp_buf *save_GUC_flex_fatal_jmp = GUC_flex_fatal_jmp;
2743 sigjmp_buf flex_fatal_jmp;
2744 volatile YY_BUFFER_STATE lex_buffer = NULL;
2745 int errorcount;
2746 int token;
2747
2748 if (sigsetjmp(flex_fatal_jmp, 1) == 0)
2749 GUC_flex_fatal_jmp = &flex_fatal_jmp;
2750 else
2751 {
2752 /*
2753 * Regain control after a fatal, internal flex error. It may have
2754 * corrupted parser state. Consequently, abandon the file, but trust
2755 * that the state remains sane enough for yy_delete_buffer().
2756 */
2757 elog(elevel, "%s at file \"%s\" line %u",
2758 GUC_flex_fatal_errmsg, config_file, ConfigFileLineno);
2759 record_config_file_error(GUC_flex_fatal_errmsg,
2760 config_file, ConfigFileLineno,
2761 head_p, tail_p);
2762 OK = false;
2763 goto cleanup;
2764 }
2765
2766 /*
2767 * Parse
2768 */
2769 ConfigFileLineno = 1;
2770 errorcount = 0;
2771
2772 lex_buffer = yy_create_buffer(fp, YY_BUF_SIZE);
2773 yy_switch_to_buffer(lex_buffer);
2774
2775 /* This loop iterates once per logical line */
2776 while ((token = yylex()))
2777 {
2778 char *opt_name = NULL;
2779 char *opt_value = NULL;
2780 ConfigVariable *item;
2781
2782 if (token == GUC_EOL) /* empty or comment line */
2783 continue;
2784
2785 /* first token on line is option name */
2786 if (token != GUC_ID && token != GUC_QUALIFIED_ID)
2787 goto parse_error;
2788 opt_name = pstrdup(yytext);
2789
2790 /* next we have an optional equal sign; discard if present */
2791 token = yylex();
2792 if (token == GUC_EQUALS)
2793 token = yylex();
2794
2795 /* now we must have the option value */
2796 if (token != GUC_ID &&
2797 token != GUC_STRING &&
2798 token != GUC_INTEGER &&
2799 token != GUC_REAL &&
2800 token != GUC_UNQUOTED_STRING)
2801 goto parse_error;
2802 if (token == GUC_STRING) /* strip quotes and escapes */
2803 opt_value = GUC_scanstr(yytext);
2804 else
2805 opt_value = pstrdup(yytext);
2806
2807 /* now we'd like an end of line, or possibly EOF */
2808 token = yylex();
2809 if (token != GUC_EOL)
2810 {
2811 if (token != 0)
2812 goto parse_error;
2813 /* treat EOF like \n for line numbering purposes, cf bug 4752 */
2814 ConfigFileLineno++;
2815 }
2816
2817 /* OK, process the option name and value */
2818 if (guc_name_compare(opt_name, "include_dir") == 0)
2819 {
2820 /*
2821 * An include_dir directive isn't a variable and should be
2822 * processed immediately.
2823 */
2824 if (!ParseConfigDirectory(opt_value,
2825 config_file, ConfigFileLineno - 1,
2826 depth + 1, elevel,
2827 head_p, tail_p))
2828 OK = false;
2829 yy_switch_to_buffer(lex_buffer);
2830 pfree(opt_name);
2831 pfree(opt_value);
2832 }
2833 else if (guc_name_compare(opt_name, "include_if_exists") == 0)
2834 {
2835 /*
2836 * An include_if_exists directive isn't a variable and should be
2837 * processed immediately.
2838 */
2839 if (!ParseConfigFile(opt_value, false,
2840 config_file, ConfigFileLineno - 1,
2841 depth + 1, elevel,
2842 head_p, tail_p))
2843 OK = false;
2844 yy_switch_to_buffer(lex_buffer);
2845 pfree(opt_name);
2846 pfree(opt_value);
2847 }
2848 else if (guc_name_compare(opt_name, "include") == 0)
2849 {
2850 /*
2851 * An include directive isn't a variable and should be processed
2852 * immediately.
2853 */
2854 if (!ParseConfigFile(opt_value, true,
2855 config_file, ConfigFileLineno - 1,
2856 depth + 1, elevel,
2857 head_p, tail_p))
2858 OK = false;
2859 yy_switch_to_buffer(lex_buffer);
2860 pfree(opt_name);
2861 pfree(opt_value);
2862 }
2863 else
2864 {
2865 /* ordinary variable, append to list */
2866 item = palloc(sizeof *item);
2867 item->name = opt_name;
2868 item->value = opt_value;
2869 item->errmsg = NULL;
2870 item->filename = pstrdup(config_file);
2871 item->sourceline = ConfigFileLineno - 1;
2872 item->ignore = false;
2873 item->applied = false;
2874 item->next = NULL;
2875 if (*head_p == NULL)
2876 *head_p = item;
2877 else
2878 (*tail_p)->next = item;
2879 *tail_p = item;
2880 }
2881
2882 /* break out of loop if read EOF, else loop for next line */
2883 if (token == 0)
2884 break;
2885 continue;
2886
2887 parse_error:
2888 /* release storage if we allocated any on this line */
2889 if (opt_name)
2890 pfree(opt_name);
2891 if (opt_value)
2892 pfree(opt_value);
2893
2894 /* report the error */
2895 if (token == GUC_EOL || token == 0)
2896 {
2897 ereport(elevel,
2898 (errcode(ERRCODE_SYNTAX_ERROR),
2899 errmsg("syntax error in file \"%s\" line %u, near end of line",
2900 config_file, ConfigFileLineno - 1)));
2901 record_config_file_error("syntax error",
2902 config_file, ConfigFileLineno - 1,
2903 head_p, tail_p);
2904 }
2905 else
2906 {
2907 ereport(elevel,
2908 (errcode(ERRCODE_SYNTAX_ERROR),
2909 errmsg("syntax error in file \"%s\" line %u, near token \"%s\"",
2910 config_file, ConfigFileLineno, yytext)));
2911 record_config_file_error("syntax error",
2912 config_file, ConfigFileLineno,
2913 head_p, tail_p);
2914 }
2915 OK = false;
2916 errorcount++;
2917
2918 /*
2919 * To avoid producing too much noise when fed a totally bogus file,
2920 * give up after 100 syntax errors per file (an arbitrary number).
2921 * Also, if we're only logging the errors at DEBUG level anyway, might
2922 * as well give up immediately. (This prevents postmaster children
2923 * from bloating the logs with duplicate complaints.)
2924 */
2925 if (errorcount >= 100 || elevel <= DEBUG1)
2926 {
2927 ereport(elevel,
2928 (errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
2929 errmsg("too many syntax errors found, abandoning file \"%s\"",
2930 config_file)));
2931 break;
2932 }
2933
2934 /* resync to next end-of-line or EOF */
2935 while (token != GUC_EOL && token != 0)
2936 token = yylex();
2937 /* break out of loop on EOF */
2938 if (token == 0)
2939 break;
2940 }
2941
2942 cleanup:
2943 yy_delete_buffer(lex_buffer);
2944 /* Each recursion level must save and restore these static variables. */
2945 ConfigFileLineno = save_ConfigFileLineno;
2946 GUC_flex_fatal_jmp = save_GUC_flex_fatal_jmp;
2947 return OK;
2948 }
2949
2950 /*
2951 * Read and parse all config files in a subdirectory in alphabetical order
2952 *
2953 * includedir is the absolute or relative path to the subdirectory to scan.
2954 *
2955 * calling_file/calling_lineno identify the source of the request.
2956 * Pass NULL/0 if not recursing from an inclusion request.
2957 *
2958 * See ParseConfigFp for further details.
2959 */
2960 bool
ParseConfigDirectory(const char * includedir,const char * calling_file,int calling_lineno,int depth,int elevel,ConfigVariable ** head_p,ConfigVariable ** tail_p)2961 ParseConfigDirectory(const char *includedir,
2962 const char *calling_file, int calling_lineno,
2963 int depth, int elevel,
2964 ConfigVariable **head_p,
2965 ConfigVariable **tail_p)
2966 {
2967 char *directory;
2968 DIR *d;
2969 struct dirent *de;
2970 char **filenames;
2971 int num_filenames;
2972 int size_filenames;
2973 bool status;
2974
2975 /*
2976 * Reject directory name that is all-blank (including empty), as that
2977 * leads to confusion --- we'd read the containing directory, typically
2978 * resulting in recursive inclusion of the same file(s).
2979 */
2980 if (strspn(includedir, " \t\r\n") == strlen(includedir))
2981 {
2982 ereport(elevel,
2983 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
2984 errmsg("empty configuration directory name: \"%s\"",
2985 includedir)));
2986 record_config_file_error("empty configuration directory name",
2987 calling_file, calling_lineno,
2988 head_p, tail_p);
2989 return false;
2990 }
2991
2992 /*
2993 * We don't check for recursion or too-deep nesting depth here; the
2994 * subsequent calls to ParseConfigFile will take care of that.
2995 */
2996
2997 directory = AbsoluteConfigLocation(includedir, calling_file);
2998 d = AllocateDir(directory);
2999 if (d == NULL)
3000 {
3001 ereport(elevel,
3002 (errcode_for_file_access(),
3003 errmsg("could not open configuration directory \"%s\": %m",
3004 directory)));
3005 record_config_file_error(psprintf("could not open directory \"%s\"",
3006 directory),
3007 calling_file, calling_lineno,
3008 head_p, tail_p);
3009 status = false;
3010 goto cleanup;
3011 }
3012
3013 /*
3014 * Read the directory and put the filenames in an array, so we can sort
3015 * them prior to processing the contents.
3016 */
3017 size_filenames = 32;
3018 filenames = (char **) palloc(size_filenames * sizeof(char *));
3019 num_filenames = 0;
3020
3021 while ((de = ReadDir(d, directory)) != NULL)
3022 {
3023 struct stat st;
3024 char filename[MAXPGPATH];
3025
3026 /*
3027 * Only parse files with names ending in ".conf". Explicitly reject
3028 * files starting with ".". This excludes things like "." and "..",
3029 * as well as typical hidden files, backup files, and editor debris.
3030 */
3031 if (strlen(de->d_name) < 6)
3032 continue;
3033 if (de->d_name[0] == '.')
3034 continue;
3035 if (strcmp(de->d_name + strlen(de->d_name) - 5, ".conf") != 0)
3036 continue;
3037
3038 join_path_components(filename, directory, de->d_name);
3039 canonicalize_path(filename);
3040 if (stat(filename, &st) == 0)
3041 {
3042 if (!S_ISDIR(st.st_mode))
3043 {
3044 /* Add file to array, increasing its size in blocks of 32 */
3045 if (num_filenames >= size_filenames)
3046 {
3047 size_filenames += 32;
3048 filenames = (char **) repalloc(filenames,
3049 size_filenames * sizeof(char *));
3050 }
3051 filenames[num_filenames] = pstrdup(filename);
3052 num_filenames++;
3053 }
3054 }
3055 else
3056 {
3057 /*
3058 * stat does not care about permissions, so the most likely reason
3059 * a file can't be accessed now is if it was removed between the
3060 * directory listing and now.
3061 */
3062 ereport(elevel,
3063 (errcode_for_file_access(),
3064 errmsg("could not stat file \"%s\": %m",
3065 filename)));
3066 record_config_file_error(psprintf("could not stat file \"%s\"",
3067 filename),
3068 calling_file, calling_lineno,
3069 head_p, tail_p);
3070 status = false;
3071 goto cleanup;
3072 }
3073 }
3074
3075 if (num_filenames > 0)
3076 {
3077 int i;
3078
3079 qsort(filenames, num_filenames, sizeof(char *), pg_qsort_strcmp);
3080 for (i = 0; i < num_filenames; i++)
3081 {
3082 if (!ParseConfigFile(filenames[i], true,
3083 calling_file, calling_lineno,
3084 depth, elevel,
3085 head_p, tail_p))
3086 {
3087 status = false;
3088 goto cleanup;
3089 }
3090 }
3091 }
3092 status = true;
3093
3094 cleanup:
3095 if (d)
3096 FreeDir(d);
3097 pfree(directory);
3098 return status;
3099 }
3100
3101 /*
3102 * Free a list of ConfigVariables, including the names and the values
3103 */
3104 void
FreeConfigVariables(ConfigVariable * list)3105 FreeConfigVariables(ConfigVariable *list)
3106 {
3107 ConfigVariable *item;
3108
3109 item = list;
3110 while (item)
3111 {
3112 ConfigVariable *next = item->next;
3113
3114 FreeConfigVariable(item);
3115 item = next;
3116 }
3117 }
3118
3119 /*
3120 * Free a single ConfigVariable
3121 */
3122 static void
FreeConfigVariable(ConfigVariable * item)3123 FreeConfigVariable(ConfigVariable *item)
3124 {
3125 if (item->name)
3126 pfree(item->name);
3127 if (item->value)
3128 pfree(item->value);
3129 if (item->errmsg)
3130 pfree(item->errmsg);
3131 if (item->filename)
3132 pfree(item->filename);
3133 pfree(item);
3134 }
3135
3136
3137 /*
3138 * scanstr
3139 *
3140 * Strip the quotes surrounding the given string, and collapse any embedded
3141 * '' sequences and backslash escapes.
3142 *
3143 * the string returned is palloc'd and should eventually be pfree'd by the
3144 * caller.
3145 */
3146 static char *
GUC_scanstr(const char * s)3147 GUC_scanstr(const char *s)
3148 {
3149 char *newStr;
3150 int len,
3151 i,
3152 j;
3153
3154 Assert(s != NULL && s[0] == '\'');
3155 len = strlen(s);
3156 Assert(len >= 2);
3157 Assert(s[len - 1] == '\'');
3158
3159 /* Skip the leading quote; we'll handle the trailing quote below */
3160 s++, len--;
3161
3162 /* Since len still includes trailing quote, this is enough space */
3163 newStr = palloc(len);
3164
3165 for (i = 0, j = 0; i < len; i++)
3166 {
3167 if (s[i] == '\\')
3168 {
3169 i++;
3170 switch (s[i])
3171 {
3172 case 'b':
3173 newStr[j] = '\b';
3174 break;
3175 case 'f':
3176 newStr[j] = '\f';
3177 break;
3178 case 'n':
3179 newStr[j] = '\n';
3180 break;
3181 case 'r':
3182 newStr[j] = '\r';
3183 break;
3184 case 't':
3185 newStr[j] = '\t';
3186 break;
3187 case '0':
3188 case '1':
3189 case '2':
3190 case '3':
3191 case '4':
3192 case '5':
3193 case '6':
3194 case '7':
3195 {
3196 int k;
3197 long octVal = 0;
3198
3199 for (k = 0;
3200 s[i + k] >= '0' && s[i + k] <= '7' && k < 3;
3201 k++)
3202 octVal = (octVal << 3) + (s[i + k] - '0');
3203 i += k - 1;
3204 newStr[j] = ((char) octVal);
3205 }
3206 break;
3207 default:
3208 newStr[j] = s[i];
3209 break;
3210 } /* switch */
3211 }
3212 else if (s[i] == '\'' && s[i + 1] == '\'')
3213 {
3214 /* doubled quote becomes just one quote */
3215 newStr[j] = s[++i];
3216 }
3217 else
3218 newStr[j] = s[i];
3219 j++;
3220 }
3221
3222 /* We copied the ending quote to newStr, so replace with \0 */
3223 Assert(j > 0 && j <= len);
3224 newStr[--j] = '\0';
3225
3226 return newStr;
3227 }
3228
3229