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-2021, 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 
806 /* LCOV_EXCL_START */
807 
808 #line 809 "guc-file.c"
809 #define YY_NO_INPUT 1
810 #line 811 "guc-file.c"
811 
812 #define INITIAL 0
813 
814 #ifndef YY_NO_UNISTD_H
815 /* Special case for "unistd.h", since it is non-ANSI. We include it way
816  * down here because we want the user's section 1 to have been scanned first.
817  * The user has a chance to override it with an option.
818  */
819 #include <unistd.h>
820 #endif
821 
822 #ifndef YY_EXTRA_TYPE
823 #define YY_EXTRA_TYPE void *
824 #endif
825 
826 static int yy_init_globals ( void );
827 
828 /* Accessor methods to globals.
829    These are made visible to non-reentrant scanners for convenience. */
830 
831 int yylex_destroy ( void );
832 
833 int yyget_debug ( void );
834 
835 void yyset_debug ( int debug_flag  );
836 
837 YY_EXTRA_TYPE yyget_extra ( void );
838 
839 void yyset_extra ( YY_EXTRA_TYPE user_defined  );
840 
841 FILE *yyget_in ( void );
842 
843 void yyset_in  ( FILE * _in_str  );
844 
845 FILE *yyget_out ( void );
846 
847 void yyset_out  ( FILE * _out_str  );
848 
849 			int yyget_leng ( void );
850 
851 char *yyget_text ( void );
852 
853 int yyget_lineno ( void );
854 
855 void yyset_lineno ( int _line_number  );
856 
857 /* Macros after this point can all be overridden by user definitions in
858  * section 1.
859  */
860 
861 #ifndef YY_SKIP_YYWRAP
862 #ifdef __cplusplus
863 extern "C" int yywrap ( void );
864 #else
865 extern int yywrap ( void );
866 #endif
867 #endif
868 
869 #ifndef YY_NO_UNPUT
870 
871 #endif
872 
873 #ifndef yytext_ptr
874 static void yy_flex_strncpy ( char *, const char *, int );
875 #endif
876 
877 #ifdef YY_NEED_STRLEN
878 static int yy_flex_strlen ( const char * );
879 #endif
880 
881 #ifndef YY_NO_INPUT
882 #ifdef __cplusplus
883 static int yyinput ( void );
884 #else
885 static int input ( void );
886 #endif
887 
888 #endif
889 
890 /* Amount of stuff to slurp up with each read. */
891 #ifndef YY_READ_BUF_SIZE
892 #ifdef __ia64__
893 /* On IA-64, the buffer size is 16k, not 8k */
894 #define YY_READ_BUF_SIZE 16384
895 #else
896 #define YY_READ_BUF_SIZE 8192
897 #endif /* __ia64__ */
898 #endif
899 
900 /* Copy whatever the last rule matched to the standard output. */
901 #ifndef ECHO
902 /* This used to be an fputs(), but since the string might contain NUL's,
903  * we now use fwrite().
904  */
905 #define ECHO do { if (fwrite( yytext, (size_t) yyleng, 1, yyout )) {} } while (0)
906 #endif
907 
908 /* Gets input and stuffs it into "buf".  number of characters read, or YY_NULL,
909  * is returned in "result".
910  */
911 #ifndef YY_INPUT
912 #define YY_INPUT(buf,result,max_size) \
913 	if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
914 		{ \
915 		int c = '*'; \
916 		int n; \
917 		for ( n = 0; n < max_size && \
918 			     (c = getc( yyin )) != EOF && c != '\n'; ++n ) \
919 			buf[n] = (char) c; \
920 		if ( c == '\n' ) \
921 			buf[n++] = (char) c; \
922 		if ( c == EOF && ferror( yyin ) ) \
923 			YY_FATAL_ERROR( "input in flex scanner failed" ); \
924 		result = n; \
925 		} \
926 	else \
927 		{ \
928 		errno=0; \
929 		while ( (result = (int) fread(buf, 1, (yy_size_t) max_size, yyin)) == 0 && ferror(yyin)) \
930 			{ \
931 			if( errno != EINTR) \
932 				{ \
933 				YY_FATAL_ERROR( "input in flex scanner failed" ); \
934 				break; \
935 				} \
936 			errno=0; \
937 			clearerr(yyin); \
938 			} \
939 		}\
940 \
941 
942 #endif
943 
944 /* No semi-colon after return; correct usage is to write "yyterminate();" -
945  * we don't want an extra ';' after the "return" because that will cause
946  * some compilers to complain about unreachable statements.
947  */
948 #ifndef yyterminate
949 #define yyterminate() return YY_NULL
950 #endif
951 
952 /* Number of entries by which start-condition stack grows. */
953 #ifndef YY_START_STACK_INCR
954 #define YY_START_STACK_INCR 25
955 #endif
956 
957 /* Report a fatal error. */
958 #ifndef YY_FATAL_ERROR
959 #define YY_FATAL_ERROR(msg) yy_fatal_error( msg )
960 #endif
961 
962 /* end tables serialization structures and prototypes */
963 
964 /* Default declaration of generated scanner - a define so the user can
965  * easily add parameters.
966  */
967 #ifndef YY_DECL
968 #define YY_DECL_IS_OURS 1
969 
970 extern int yylex (void);
971 
972 #define YY_DECL int yylex (void)
973 #endif /* !YY_DECL */
974 
975 /* Code executed at the beginning of each rule, after yytext and yyleng
976  * have been set up.
977  */
978 #ifndef YY_USER_ACTION
979 #define YY_USER_ACTION
980 #endif
981 
982 /* Code executed at the end of each rule. */
983 #ifndef YY_BREAK
984 #define YY_BREAK /*LINTED*/break;
985 #endif
986 
987 #define YY_RULE_SETUP \
988 	YY_USER_ACTION
989 
990 /** The main scanner function which does all the work.
991  */
992 YY_DECL
993 {
994 	yy_state_type yy_current_state;
995 	char *yy_cp, *yy_bp;
996 	int yy_act;
997 
998 	if ( !(yy_init) )
999 		{
1000 		(yy_init) = 1;
1001 
1002 #ifdef YY_USER_INIT
1003 		YY_USER_INIT;
1004 #endif
1005 
1006 		if ( ! (yy_start) )
1007 			(yy_start) = 1;	/* first start state */
1008 
1009 		if ( ! yyin )
1010 			yyin = stdin;
1011 
1012 		if ( ! yyout )
1013 			yyout = stdout;
1014 
1015 		if ( ! YY_CURRENT_BUFFER ) {
1016 			yyensure_buffer_stack ();
1017 			YY_CURRENT_BUFFER_LVALUE =
1018 				yy_create_buffer( yyin, YY_BUF_SIZE );
1019 		}
1020 
1021 		yy_load_buffer_state(  );
1022 		}
1023 
1024 	{
1025 #line 93 "guc-file.l"
1026 
1027 
1028 #line 1029 "guc-file.c"
1029 
1030 	while ( /*CONSTCOND*/1 )		/* loops until end-of-file is reached */
1031 		{
1032 		yy_cp = (yy_c_buf_p);
1033 
1034 		/* Support of yytext. */
1035 		*yy_cp = (yy_hold_char);
1036 
1037 		/* yy_bp points to the position in yy_ch_buf of the start of
1038 		 * the current run.
1039 		 */
1040 		yy_bp = yy_cp;
1041 
1042 		yy_current_state = (yy_start);
1043 yy_match:
1044 		do
1045 			{
1046 			YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)] ;
1047 			if ( yy_accept[yy_current_state] )
1048 				{
1049 				(yy_last_accepting_state) = yy_current_state;
1050 				(yy_last_accepting_cpos) = yy_cp;
1051 				}
1052 			while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1053 				{
1054 				yy_current_state = (int) yy_def[yy_current_state];
1055 				if ( yy_current_state >= 41 )
1056 					yy_c = yy_meta[yy_c];
1057 				}
1058 			yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
1059 			++yy_cp;
1060 			}
1061 		while ( yy_current_state != 40 );
1062 		yy_cp = (yy_last_accepting_cpos);
1063 		yy_current_state = (yy_last_accepting_state);
1064 
1065 yy_find_action:
1066 		yy_act = yy_accept[yy_current_state];
1067 
1068 		YY_DO_BEFORE_ACTION;
1069 
1070 do_action:	/* This label is used only to access EOF actions. */
1071 
1072 		switch ( yy_act )
1073 	{ /* beginning of action switch */
1074 			case 0: /* must back up */
1075 			/* undo the effects of YY_DO_BEFORE_ACTION */
1076 			*yy_cp = (yy_hold_char);
1077 			yy_cp = (yy_last_accepting_cpos);
1078 			yy_current_state = (yy_last_accepting_state);
1079 			goto yy_find_action;
1080 
1081 case 1:
1082 /* rule 1 can match eol */
1083 YY_RULE_SETUP
1084 #line 95 "guc-file.l"
1085 ConfigFileLineno++; return GUC_EOL;
1086 	YY_BREAK
1087 case 2:
1088 YY_RULE_SETUP
1089 #line 96 "guc-file.l"
1090 /* eat whitespace */
1091 	YY_BREAK
1092 case 3:
1093 YY_RULE_SETUP
1094 #line 97 "guc-file.l"
1095 /* eat comment (.* matches anything until newline) */
1096 	YY_BREAK
1097 case 4:
1098 YY_RULE_SETUP
1099 #line 99 "guc-file.l"
1100 return GUC_ID;
1101 	YY_BREAK
1102 case 5:
1103 YY_RULE_SETUP
1104 #line 100 "guc-file.l"
1105 return GUC_QUALIFIED_ID;
1106 	YY_BREAK
1107 case 6:
1108 YY_RULE_SETUP
1109 #line 101 "guc-file.l"
1110 return GUC_STRING;
1111 	YY_BREAK
1112 case 7:
1113 YY_RULE_SETUP
1114 #line 102 "guc-file.l"
1115 return GUC_UNQUOTED_STRING;
1116 	YY_BREAK
1117 case 8:
1118 YY_RULE_SETUP
1119 #line 103 "guc-file.l"
1120 return GUC_INTEGER;
1121 	YY_BREAK
1122 case 9:
1123 YY_RULE_SETUP
1124 #line 104 "guc-file.l"
1125 return GUC_REAL;
1126 	YY_BREAK
1127 case 10:
1128 YY_RULE_SETUP
1129 #line 105 "guc-file.l"
1130 return GUC_EQUALS;
1131 	YY_BREAK
1132 case 11:
1133 YY_RULE_SETUP
1134 #line 107 "guc-file.l"
1135 return GUC_ERROR;
1136 	YY_BREAK
1137 case 12:
1138 YY_RULE_SETUP
1139 #line 109 "guc-file.l"
1140 YY_FATAL_ERROR( "flex scanner jammed" );
1141 	YY_BREAK
1142 #line 1143 "guc-file.c"
1143 case YY_STATE_EOF(INITIAL):
1144 	yyterminate();
1145 
1146 	case YY_END_OF_BUFFER:
1147 		{
1148 		/* Amount of text matched not including the EOB char. */
1149 		int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1;
1150 
1151 		/* Undo the effects of YY_DO_BEFORE_ACTION. */
1152 		*yy_cp = (yy_hold_char);
1153 		YY_RESTORE_YY_MORE_OFFSET
1154 
1155 		if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW )
1156 			{
1157 			/* We're scanning a new file or input source.  It's
1158 			 * possible that this happened because the user
1159 			 * just pointed yyin at a new source and called
1160 			 * yylex().  If so, then we have to assure
1161 			 * consistency between YY_CURRENT_BUFFER and our
1162 			 * globals.  Here is the right place to do so, because
1163 			 * this is the first action (other than possibly a
1164 			 * back-up) that will match for the new input source.
1165 			 */
1166 			(yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
1167 			YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin;
1168 			YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL;
1169 			}
1170 
1171 		/* Note that here we test for yy_c_buf_p "<=" to the position
1172 		 * of the first EOB in the buffer, since yy_c_buf_p will
1173 		 * already have been incremented past the NUL character
1174 		 * (since all states make transitions on EOB to the
1175 		 * end-of-buffer state).  Contrast this with the test
1176 		 * in input().
1177 		 */
1178 		if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
1179 			{ /* This was really a NUL. */
1180 			yy_state_type yy_next_state;
1181 
1182 			(yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text;
1183 
1184 			yy_current_state = yy_get_previous_state(  );
1185 
1186 			/* Okay, we're now positioned to make the NUL
1187 			 * transition.  We couldn't have
1188 			 * yy_get_previous_state() go ahead and do it
1189 			 * for us because it doesn't know how to deal
1190 			 * with the possibility of jamming (and we don't
1191 			 * want to build jamming into it because then it
1192 			 * will run more slowly).
1193 			 */
1194 
1195 			yy_next_state = yy_try_NUL_trans( yy_current_state );
1196 
1197 			yy_bp = (yytext_ptr) + YY_MORE_ADJ;
1198 
1199 			if ( yy_next_state )
1200 				{
1201 				/* Consume the NUL. */
1202 				yy_cp = ++(yy_c_buf_p);
1203 				yy_current_state = yy_next_state;
1204 				goto yy_match;
1205 				}
1206 
1207 			else
1208 				{
1209 				yy_cp = (yy_last_accepting_cpos);
1210 				yy_current_state = (yy_last_accepting_state);
1211 				goto yy_find_action;
1212 				}
1213 			}
1214 
1215 		else switch ( yy_get_next_buffer(  ) )
1216 			{
1217 			case EOB_ACT_END_OF_FILE:
1218 				{
1219 				(yy_did_buffer_switch_on_eof) = 0;
1220 
1221 				if ( yywrap(  ) )
1222 					{
1223 					/* Note: because we've taken care in
1224 					 * yy_get_next_buffer() to have set up
1225 					 * yytext, we can now set up
1226 					 * yy_c_buf_p so that if some total
1227 					 * hoser (like flex itself) wants to
1228 					 * call the scanner after we return the
1229 					 * YY_NULL, it'll still work - another
1230 					 * YY_NULL will get returned.
1231 					 */
1232 					(yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ;
1233 
1234 					yy_act = YY_STATE_EOF(YY_START);
1235 					goto do_action;
1236 					}
1237 
1238 				else
1239 					{
1240 					if ( ! (yy_did_buffer_switch_on_eof) )
1241 						YY_NEW_FILE;
1242 					}
1243 				break;
1244 				}
1245 
1246 			case EOB_ACT_CONTINUE_SCAN:
1247 				(yy_c_buf_p) =
1248 					(yytext_ptr) + yy_amount_of_matched_text;
1249 
1250 				yy_current_state = yy_get_previous_state(  );
1251 
1252 				yy_cp = (yy_c_buf_p);
1253 				yy_bp = (yytext_ptr) + YY_MORE_ADJ;
1254 				goto yy_match;
1255 
1256 			case EOB_ACT_LAST_MATCH:
1257 				(yy_c_buf_p) =
1258 				&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)];
1259 
1260 				yy_current_state = yy_get_previous_state(  );
1261 
1262 				yy_cp = (yy_c_buf_p);
1263 				yy_bp = (yytext_ptr) + YY_MORE_ADJ;
1264 				goto yy_find_action;
1265 			}
1266 		break;
1267 		}
1268 
1269 	default:
1270 		YY_FATAL_ERROR(
1271 			"fatal flex scanner internal error--no action found" );
1272 	} /* end of action switch */
1273 		} /* end of scanning one token */
1274 	} /* end of user's declarations */
1275 } /* end of yylex */
1276 
1277 /* yy_get_next_buffer - try to read in a new buffer
1278  *
1279  * Returns a code representing an action:
1280  *	EOB_ACT_LAST_MATCH -
1281  *	EOB_ACT_CONTINUE_SCAN - continue scanning from current position
1282  *	EOB_ACT_END_OF_FILE - end of file
1283  */
yy_get_next_buffer(void)1284 static int yy_get_next_buffer (void)
1285 {
1286     	char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
1287 	char *source = (yytext_ptr);
1288 	int number_to_move, i;
1289 	int ret_val;
1290 
1291 	if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] )
1292 		YY_FATAL_ERROR(
1293 		"fatal flex scanner internal error--end of buffer missed" );
1294 
1295 	if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 )
1296 		{ /* Don't try to fill the buffer, so this is an EOF. */
1297 		if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 )
1298 			{
1299 			/* We matched a single character, the EOB, so
1300 			 * treat this as a final EOF.
1301 			 */
1302 			return EOB_ACT_END_OF_FILE;
1303 			}
1304 
1305 		else
1306 			{
1307 			/* We matched some text prior to the EOB, first
1308 			 * process it.
1309 			 */
1310 			return EOB_ACT_LAST_MATCH;
1311 			}
1312 		}
1313 
1314 	/* Try to read more data. */
1315 
1316 	/* First move last chars to start of buffer. */
1317 	number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr) - 1);
1318 
1319 	for ( i = 0; i < number_to_move; ++i )
1320 		*(dest++) = *(source++);
1321 
1322 	if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING )
1323 		/* don't do the read, it's not guaranteed to return an EOF,
1324 		 * just force an EOF
1325 		 */
1326 		YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0;
1327 
1328 	else
1329 		{
1330 			int num_to_read =
1331 			YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
1332 
1333 		while ( num_to_read <= 0 )
1334 			{ /* Not enough room in the buffer - grow it. */
1335 
1336 			/* just a shorter name for the current buffer */
1337 			YY_BUFFER_STATE b = YY_CURRENT_BUFFER_LVALUE;
1338 
1339 			int yy_c_buf_p_offset =
1340 				(int) ((yy_c_buf_p) - b->yy_ch_buf);
1341 
1342 			if ( b->yy_is_our_buffer )
1343 				{
1344 				int new_size = b->yy_buf_size * 2;
1345 
1346 				if ( new_size <= 0 )
1347 					b->yy_buf_size += b->yy_buf_size / 8;
1348 				else
1349 					b->yy_buf_size *= 2;
1350 
1351 				b->yy_ch_buf = (char *)
1352 					/* Include room in for 2 EOB chars. */
1353 					yyrealloc( (void *) b->yy_ch_buf,
1354 							 (yy_size_t) (b->yy_buf_size + 2)  );
1355 				}
1356 			else
1357 				/* Can't grow it, we don't own it. */
1358 				b->yy_ch_buf = NULL;
1359 
1360 			if ( ! b->yy_ch_buf )
1361 				YY_FATAL_ERROR(
1362 				"fatal error - scanner input buffer overflow" );
1363 
1364 			(yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset];
1365 
1366 			num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size -
1367 						number_to_move - 1;
1368 
1369 			}
1370 
1371 		if ( num_to_read > YY_READ_BUF_SIZE )
1372 			num_to_read = YY_READ_BUF_SIZE;
1373 
1374 		/* Read in more data. */
1375 		YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]),
1376 			(yy_n_chars), num_to_read );
1377 
1378 		YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
1379 		}
1380 
1381 	if ( (yy_n_chars) == 0 )
1382 		{
1383 		if ( number_to_move == YY_MORE_ADJ )
1384 			{
1385 			ret_val = EOB_ACT_END_OF_FILE;
1386 			yyrestart( yyin  );
1387 			}
1388 
1389 		else
1390 			{
1391 			ret_val = EOB_ACT_LAST_MATCH;
1392 			YY_CURRENT_BUFFER_LVALUE->yy_buffer_status =
1393 				YY_BUFFER_EOF_PENDING;
1394 			}
1395 		}
1396 
1397 	else
1398 		ret_val = EOB_ACT_CONTINUE_SCAN;
1399 
1400 	if (((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {
1401 		/* Extend the array by 50%, plus the number we really need. */
1402 		int new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1);
1403 		YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc(
1404 			(void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf, (yy_size_t) new_size  );
1405 		if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
1406 			YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" );
1407 		/* "- 2" to take care of EOB's */
1408 		YY_CURRENT_BUFFER_LVALUE->yy_buf_size = (int) (new_size - 2);
1409 	}
1410 
1411 	(yy_n_chars) += number_to_move;
1412 	YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR;
1413 	YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR;
1414 
1415 	(yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0];
1416 
1417 	return ret_val;
1418 }
1419 
1420 /* yy_get_previous_state - get the state just before the EOB char was reached */
1421 
yy_get_previous_state(void)1422     static yy_state_type yy_get_previous_state (void)
1423 {
1424 	yy_state_type yy_current_state;
1425 	char *yy_cp;
1426 
1427 	yy_current_state = (yy_start);
1428 
1429 	for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp )
1430 		{
1431 		YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
1432 		if ( yy_accept[yy_current_state] )
1433 			{
1434 			(yy_last_accepting_state) = yy_current_state;
1435 			(yy_last_accepting_cpos) = yy_cp;
1436 			}
1437 		while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1438 			{
1439 			yy_current_state = (int) yy_def[yy_current_state];
1440 			if ( yy_current_state >= 41 )
1441 				yy_c = yy_meta[yy_c];
1442 			}
1443 		yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
1444 		}
1445 
1446 	return yy_current_state;
1447 }
1448 
1449 /* yy_try_NUL_trans - try to make a transition on the NUL character
1450  *
1451  * synopsis
1452  *	next_state = yy_try_NUL_trans( current_state );
1453  */
yy_try_NUL_trans(yy_state_type yy_current_state)1454     static yy_state_type yy_try_NUL_trans  (yy_state_type yy_current_state )
1455 {
1456 	int yy_is_jam;
1457     	char *yy_cp = (yy_c_buf_p);
1458 
1459 	YY_CHAR yy_c = 1;
1460 	if ( yy_accept[yy_current_state] )
1461 		{
1462 		(yy_last_accepting_state) = yy_current_state;
1463 		(yy_last_accepting_cpos) = yy_cp;
1464 		}
1465 	while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1466 		{
1467 		yy_current_state = (int) yy_def[yy_current_state];
1468 		if ( yy_current_state >= 41 )
1469 			yy_c = yy_meta[yy_c];
1470 		}
1471 	yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
1472 	yy_is_jam = (yy_current_state == 40);
1473 
1474 		return yy_is_jam ? 0 : yy_current_state;
1475 }
1476 
1477 #ifndef YY_NO_UNPUT
1478 
1479 #endif
1480 
1481 #ifndef YY_NO_INPUT
1482 #ifdef __cplusplus
yyinput(void)1483     static int yyinput (void)
1484 #else
1485     static int input  (void)
1486 #endif
1487 
1488 {
1489 	int c;
1490 
1491 	*(yy_c_buf_p) = (yy_hold_char);
1492 
1493 	if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR )
1494 		{
1495 		/* yy_c_buf_p now points to the character we want to return.
1496 		 * If this occurs *before* the EOB characters, then it's a
1497 		 * valid NUL; if not, then we've hit the end of the buffer.
1498 		 */
1499 		if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
1500 			/* This was really a NUL. */
1501 			*(yy_c_buf_p) = '\0';
1502 
1503 		else
1504 			{ /* need more input */
1505 			int offset = (int) ((yy_c_buf_p) - (yytext_ptr));
1506 			++(yy_c_buf_p);
1507 
1508 			switch ( yy_get_next_buffer(  ) )
1509 				{
1510 				case EOB_ACT_LAST_MATCH:
1511 					/* This happens because yy_g_n_b()
1512 					 * sees that we've accumulated a
1513 					 * token and flags that we need to
1514 					 * try matching the token before
1515 					 * proceeding.  But for input(),
1516 					 * there's no matching to consider.
1517 					 * So convert the EOB_ACT_LAST_MATCH
1518 					 * to EOB_ACT_END_OF_FILE.
1519 					 */
1520 
1521 					/* Reset buffer status. */
1522 					yyrestart( yyin );
1523 
1524 					/*FALLTHROUGH*/
1525 
1526 				case EOB_ACT_END_OF_FILE:
1527 					{
1528 					if ( yywrap(  ) )
1529 						return 0;
1530 
1531 					if ( ! (yy_did_buffer_switch_on_eof) )
1532 						YY_NEW_FILE;
1533 #ifdef __cplusplus
1534 					return yyinput();
1535 #else
1536 					return input();
1537 #endif
1538 					}
1539 
1540 				case EOB_ACT_CONTINUE_SCAN:
1541 					(yy_c_buf_p) = (yytext_ptr) + offset;
1542 					break;
1543 				}
1544 			}
1545 		}
1546 
1547 	c = *(unsigned char *) (yy_c_buf_p);	/* cast for 8-bit char's */
1548 	*(yy_c_buf_p) = '\0';	/* preserve yytext */
1549 	(yy_hold_char) = *++(yy_c_buf_p);
1550 
1551 	return c;
1552 }
1553 #endif	/* ifndef YY_NO_INPUT */
1554 
1555 /** Immediately switch to a different input stream.
1556  * @param input_file A readable stream.
1557  *
1558  * @note This function does not reset the start condition to @c INITIAL .
1559  */
yyrestart(FILE * input_file)1560     void yyrestart  (FILE * input_file )
1561 {
1562 
1563 	if ( ! YY_CURRENT_BUFFER ){
1564         yyensure_buffer_stack ();
1565 		YY_CURRENT_BUFFER_LVALUE =
1566             yy_create_buffer( yyin, YY_BUF_SIZE );
1567 	}
1568 
1569 	yy_init_buffer( YY_CURRENT_BUFFER, input_file );
1570 	yy_load_buffer_state(  );
1571 }
1572 
1573 /** Switch to a different input buffer.
1574  * @param new_buffer The new input buffer.
1575  *
1576  */
yy_switch_to_buffer(YY_BUFFER_STATE new_buffer)1577     void yy_switch_to_buffer  (YY_BUFFER_STATE  new_buffer )
1578 {
1579 
1580 	/* TODO. We should be able to replace this entire function body
1581 	 * with
1582 	 *		yypop_buffer_state();
1583 	 *		yypush_buffer_state(new_buffer);
1584      */
1585 	yyensure_buffer_stack ();
1586 	if ( YY_CURRENT_BUFFER == new_buffer )
1587 		return;
1588 
1589 	if ( YY_CURRENT_BUFFER )
1590 		{
1591 		/* Flush out information for old buffer. */
1592 		*(yy_c_buf_p) = (yy_hold_char);
1593 		YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
1594 		YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
1595 		}
1596 
1597 	YY_CURRENT_BUFFER_LVALUE = new_buffer;
1598 	yy_load_buffer_state(  );
1599 
1600 	/* We don't actually know whether we did this switch during
1601 	 * EOF (yywrap()) processing, but the only time this flag
1602 	 * is looked at is after yywrap() is called, so it's safe
1603 	 * to go ahead and always set it.
1604 	 */
1605 	(yy_did_buffer_switch_on_eof) = 1;
1606 }
1607 
yy_load_buffer_state(void)1608 static void yy_load_buffer_state  (void)
1609 {
1610     	(yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
1611 	(yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos;
1612 	yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file;
1613 	(yy_hold_char) = *(yy_c_buf_p);
1614 }
1615 
1616 /** Allocate and initialize an input buffer state.
1617  * @param file A readable stream.
1618  * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE.
1619  *
1620  * @return the allocated buffer state.
1621  */
yy_create_buffer(FILE * file,int size)1622     YY_BUFFER_STATE yy_create_buffer  (FILE * file, int  size )
1623 {
1624 	YY_BUFFER_STATE b;
1625 
1626 	b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state )  );
1627 	if ( ! b )
1628 		YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
1629 
1630 	b->yy_buf_size = size;
1631 
1632 	/* yy_ch_buf has to be 2 characters longer than the size given because
1633 	 * we need to put in 2 end-of-buffer characters.
1634 	 */
1635 	b->yy_ch_buf = (char *) yyalloc( (yy_size_t) (b->yy_buf_size + 2)  );
1636 	if ( ! b->yy_ch_buf )
1637 		YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
1638 
1639 	b->yy_is_our_buffer = 1;
1640 
1641 	yy_init_buffer( b, file );
1642 
1643 	return b;
1644 }
1645 
1646 /** Destroy the buffer.
1647  * @param b a buffer created with yy_create_buffer()
1648  *
1649  */
yy_delete_buffer(YY_BUFFER_STATE b)1650     void yy_delete_buffer (YY_BUFFER_STATE  b )
1651 {
1652 
1653 	if ( ! b )
1654 		return;
1655 
1656 	if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */
1657 		YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0;
1658 
1659 	if ( b->yy_is_our_buffer )
1660 		yyfree( (void *) b->yy_ch_buf  );
1661 
1662 	yyfree( (void *) b  );
1663 }
1664 
1665 /* Initializes or reinitializes a buffer.
1666  * This function is sometimes called more than once on the same buffer,
1667  * such as during a yyrestart() or at EOF.
1668  */
yy_init_buffer(YY_BUFFER_STATE b,FILE * file)1669     static void yy_init_buffer  (YY_BUFFER_STATE  b, FILE * file )
1670 
1671 {
1672 	int oerrno = errno;
1673 
1674 	yy_flush_buffer( b );
1675 
1676 	b->yy_input_file = file;
1677 	b->yy_fill_buffer = 1;
1678 
1679     /* If b is the current buffer, then yy_init_buffer was _probably_
1680      * called from yyrestart() or through yy_get_next_buffer.
1681      * In that case, we don't want to reset the lineno or column.
1682      */
1683     if (b != YY_CURRENT_BUFFER){
1684         b->yy_bs_lineno = 1;
1685         b->yy_bs_column = 0;
1686     }
1687 
1688         b->yy_is_interactive = 0;
1689 
1690 	errno = oerrno;
1691 }
1692 
1693 /** Discard all buffered characters. On the next scan, YY_INPUT will be called.
1694  * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER.
1695  *
1696  */
yy_flush_buffer(YY_BUFFER_STATE b)1697     void yy_flush_buffer (YY_BUFFER_STATE  b )
1698 {
1699     	if ( ! b )
1700 		return;
1701 
1702 	b->yy_n_chars = 0;
1703 
1704 	/* We always need two end-of-buffer characters.  The first causes
1705 	 * a transition to the end-of-buffer state.  The second causes
1706 	 * a jam in that state.
1707 	 */
1708 	b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
1709 	b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
1710 
1711 	b->yy_buf_pos = &b->yy_ch_buf[0];
1712 
1713 	b->yy_at_bol = 1;
1714 	b->yy_buffer_status = YY_BUFFER_NEW;
1715 
1716 	if ( b == YY_CURRENT_BUFFER )
1717 		yy_load_buffer_state(  );
1718 }
1719 
1720 /** Pushes the new state onto the stack. The new state becomes
1721  *  the current state. This function will allocate the stack
1722  *  if necessary.
1723  *  @param new_buffer The new state.
1724  *
1725  */
yypush_buffer_state(YY_BUFFER_STATE new_buffer)1726 void yypush_buffer_state (YY_BUFFER_STATE new_buffer )
1727 {
1728     	if (new_buffer == NULL)
1729 		return;
1730 
1731 	yyensure_buffer_stack();
1732 
1733 	/* This block is copied from yy_switch_to_buffer. */
1734 	if ( YY_CURRENT_BUFFER )
1735 		{
1736 		/* Flush out information for old buffer. */
1737 		*(yy_c_buf_p) = (yy_hold_char);
1738 		YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
1739 		YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
1740 		}
1741 
1742 	/* Only push if top exists. Otherwise, replace top. */
1743 	if (YY_CURRENT_BUFFER)
1744 		(yy_buffer_stack_top)++;
1745 	YY_CURRENT_BUFFER_LVALUE = new_buffer;
1746 
1747 	/* copied from yy_switch_to_buffer. */
1748 	yy_load_buffer_state(  );
1749 	(yy_did_buffer_switch_on_eof) = 1;
1750 }
1751 
1752 /** Removes and deletes the top of the stack, if present.
1753  *  The next element becomes the new top.
1754  *
1755  */
yypop_buffer_state(void)1756 void yypop_buffer_state (void)
1757 {
1758     	if (!YY_CURRENT_BUFFER)
1759 		return;
1760 
1761 	yy_delete_buffer(YY_CURRENT_BUFFER );
1762 	YY_CURRENT_BUFFER_LVALUE = NULL;
1763 	if ((yy_buffer_stack_top) > 0)
1764 		--(yy_buffer_stack_top);
1765 
1766 	if (YY_CURRENT_BUFFER) {
1767 		yy_load_buffer_state(  );
1768 		(yy_did_buffer_switch_on_eof) = 1;
1769 	}
1770 }
1771 
1772 /* Allocates the stack if it does not exist.
1773  *  Guarantees space for at least one push.
1774  */
yyensure_buffer_stack(void)1775 static void yyensure_buffer_stack (void)
1776 {
1777 	yy_size_t num_to_alloc;
1778 
1779 	if (!(yy_buffer_stack)) {
1780 
1781 		/* First allocation is just for 2 elements, since we don't know if this
1782 		 * scanner will even need a stack. We use 2 instead of 1 to avoid an
1783 		 * immediate realloc on the next call.
1784          */
1785       num_to_alloc = 1; /* After all that talk, this was set to 1 anyways... */
1786 		(yy_buffer_stack) = (struct yy_buffer_state**)yyalloc
1787 								(num_to_alloc * sizeof(struct yy_buffer_state*)
1788 								);
1789 		if ( ! (yy_buffer_stack) )
1790 			YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" );
1791 
1792 		memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*));
1793 
1794 		(yy_buffer_stack_max) = num_to_alloc;
1795 		(yy_buffer_stack_top) = 0;
1796 		return;
1797 	}
1798 
1799 	if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){
1800 
1801 		/* Increase the buffer to prepare for a possible push. */
1802 		yy_size_t grow_size = 8 /* arbitrary grow size */;
1803 
1804 		num_to_alloc = (yy_buffer_stack_max) + grow_size;
1805 		(yy_buffer_stack) = (struct yy_buffer_state**)yyrealloc
1806 								((yy_buffer_stack),
1807 								num_to_alloc * sizeof(struct yy_buffer_state*)
1808 								);
1809 		if ( ! (yy_buffer_stack) )
1810 			YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" );
1811 
1812 		/* zero only the new slots.*/
1813 		memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*));
1814 		(yy_buffer_stack_max) = num_to_alloc;
1815 	}
1816 }
1817 
1818 /** Setup the input buffer state to scan directly from a user-specified character buffer.
1819  * @param base the character buffer
1820  * @param size the size in bytes of the character buffer
1821  *
1822  * @return the newly allocated buffer state object.
1823  */
yy_scan_buffer(char * base,yy_size_t size)1824 YY_BUFFER_STATE yy_scan_buffer  (char * base, yy_size_t  size )
1825 {
1826 	YY_BUFFER_STATE b;
1827 
1828 	if ( size < 2 ||
1829 	     base[size-2] != YY_END_OF_BUFFER_CHAR ||
1830 	     base[size-1] != YY_END_OF_BUFFER_CHAR )
1831 		/* They forgot to leave room for the EOB's. */
1832 		return NULL;
1833 
1834 	b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state )  );
1835 	if ( ! b )
1836 		YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" );
1837 
1838 	b->yy_buf_size = (int) (size - 2);	/* "- 2" to take care of EOB's */
1839 	b->yy_buf_pos = b->yy_ch_buf = base;
1840 	b->yy_is_our_buffer = 0;
1841 	b->yy_input_file = NULL;
1842 	b->yy_n_chars = b->yy_buf_size;
1843 	b->yy_is_interactive = 0;
1844 	b->yy_at_bol = 1;
1845 	b->yy_fill_buffer = 0;
1846 	b->yy_buffer_status = YY_BUFFER_NEW;
1847 
1848 	yy_switch_to_buffer( b  );
1849 
1850 	return b;
1851 }
1852 
1853 /** Setup the input buffer state to scan a string. The next call to yylex() will
1854  * scan from a @e copy of @a str.
1855  * @param yystr a NUL-terminated string to scan
1856  *
1857  * @return the newly allocated buffer state object.
1858  * @note If you want to scan bytes that may contain NUL values, then use
1859  *       yy_scan_bytes() instead.
1860  */
yy_scan_string(const char * yystr)1861 YY_BUFFER_STATE yy_scan_string (const char * yystr )
1862 {
1863 
1864 	return yy_scan_bytes( yystr, (int) strlen(yystr) );
1865 }
1866 
1867 /** Setup the input buffer state to scan the given bytes. The next call to yylex() will
1868  * scan from a @e copy of @a bytes.
1869  * @param yybytes the byte buffer to scan
1870  * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes.
1871  *
1872  * @return the newly allocated buffer state object.
1873  */
yy_scan_bytes(const char * yybytes,int _yybytes_len)1874 YY_BUFFER_STATE yy_scan_bytes  (const char * yybytes, int  _yybytes_len )
1875 {
1876 	YY_BUFFER_STATE b;
1877 	char *buf;
1878 	yy_size_t n;
1879 	int i;
1880 
1881 	/* Get memory for full buffer, including space for trailing EOB's. */
1882 	n = (yy_size_t) (_yybytes_len + 2);
1883 	buf = (char *) yyalloc( n  );
1884 	if ( ! buf )
1885 		YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" );
1886 
1887 	for ( i = 0; i < _yybytes_len; ++i )
1888 		buf[i] = yybytes[i];
1889 
1890 	buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR;
1891 
1892 	b = yy_scan_buffer( buf, n );
1893 	if ( ! b )
1894 		YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" );
1895 
1896 	/* It's okay to grow etc. this buffer, and we should throw it
1897 	 * away when we're done.
1898 	 */
1899 	b->yy_is_our_buffer = 1;
1900 
1901 	return b;
1902 }
1903 
1904 #ifndef YY_EXIT_FAILURE
1905 #define YY_EXIT_FAILURE 2
1906 #endif
1907 
yy_fatal_error(const char * msg)1908 static void yynoreturn yy_fatal_error (const char* msg )
1909 {
1910 			fprintf( stderr, "%s\n", msg );
1911 	exit( YY_EXIT_FAILURE );
1912 }
1913 
1914 /* Redefine yyless() so it works in section 3 code. */
1915 
1916 #undef yyless
1917 #define yyless(n) \
1918 	do \
1919 		{ \
1920 		/* Undo effects of setting up yytext. */ \
1921         int yyless_macro_arg = (n); \
1922         YY_LESS_LINENO(yyless_macro_arg);\
1923 		yytext[yyleng] = (yy_hold_char); \
1924 		(yy_c_buf_p) = yytext + yyless_macro_arg; \
1925 		(yy_hold_char) = *(yy_c_buf_p); \
1926 		*(yy_c_buf_p) = '\0'; \
1927 		yyleng = yyless_macro_arg; \
1928 		} \
1929 	while ( 0 )
1930 
1931 /* Accessor  methods (get/set functions) to struct members. */
1932 
1933 /** Get the current line number.
1934  *
1935  */
yyget_lineno(void)1936 int yyget_lineno  (void)
1937 {
1938 
1939     return yylineno;
1940 }
1941 
1942 /** Get the input stream.
1943  *
1944  */
yyget_in(void)1945 FILE *yyget_in  (void)
1946 {
1947         return yyin;
1948 }
1949 
1950 /** Get the output stream.
1951  *
1952  */
yyget_out(void)1953 FILE *yyget_out  (void)
1954 {
1955         return yyout;
1956 }
1957 
1958 /** Get the length of the current token.
1959  *
1960  */
yyget_leng(void)1961 int yyget_leng  (void)
1962 {
1963         return yyleng;
1964 }
1965 
1966 /** Get the current token.
1967  *
1968  */
1969 
yyget_text(void)1970 char *yyget_text  (void)
1971 {
1972         return yytext;
1973 }
1974 
1975 /** Set the current line number.
1976  * @param _line_number line number
1977  *
1978  */
yyset_lineno(int _line_number)1979 void yyset_lineno (int  _line_number )
1980 {
1981 
1982     yylineno = _line_number;
1983 }
1984 
1985 /** Set the input stream. This does not discard the current
1986  * input buffer.
1987  * @param _in_str A readable stream.
1988  *
1989  * @see yy_switch_to_buffer
1990  */
yyset_in(FILE * _in_str)1991 void yyset_in (FILE *  _in_str )
1992 {
1993         yyin = _in_str ;
1994 }
1995 
yyset_out(FILE * _out_str)1996 void yyset_out (FILE *  _out_str )
1997 {
1998         yyout = _out_str ;
1999 }
2000 
yyget_debug(void)2001 int yyget_debug  (void)
2002 {
2003         return yy_flex_debug;
2004 }
2005 
yyset_debug(int _bdebug)2006 void yyset_debug (int  _bdebug )
2007 {
2008         yy_flex_debug = _bdebug ;
2009 }
2010 
yy_init_globals(void)2011 static int yy_init_globals (void)
2012 {
2013         /* Initialization is the same as for the non-reentrant scanner.
2014      * This function is called from yylex_destroy(), so don't allocate here.
2015      */
2016 
2017     (yy_buffer_stack) = NULL;
2018     (yy_buffer_stack_top) = 0;
2019     (yy_buffer_stack_max) = 0;
2020     (yy_c_buf_p) = NULL;
2021     (yy_init) = 0;
2022     (yy_start) = 0;
2023 
2024 /* Defined in main.c */
2025 #ifdef YY_STDINIT
2026     yyin = stdin;
2027     yyout = stdout;
2028 #else
2029     yyin = NULL;
2030     yyout = NULL;
2031 #endif
2032 
2033     /* For future reference: Set errno on error, since we are called by
2034      * yylex_init()
2035      */
2036     return 0;
2037 }
2038 
2039 /* yylex_destroy is for both reentrant and non-reentrant scanners. */
yylex_destroy(void)2040 int yylex_destroy  (void)
2041 {
2042 
2043     /* Pop the buffer stack, destroying each element. */
2044 	while(YY_CURRENT_BUFFER){
2045 		yy_delete_buffer( YY_CURRENT_BUFFER  );
2046 		YY_CURRENT_BUFFER_LVALUE = NULL;
2047 		yypop_buffer_state();
2048 	}
2049 
2050 	/* Destroy the stack itself. */
2051 	yyfree((yy_buffer_stack) );
2052 	(yy_buffer_stack) = NULL;
2053 
2054     /* Reset the globals. This is important in a non-reentrant scanner so the next time
2055      * yylex() is called, initialization will occur. */
2056     yy_init_globals( );
2057 
2058     return 0;
2059 }
2060 
2061 /*
2062  * Internal utility routines.
2063  */
2064 
2065 #ifndef yytext_ptr
yy_flex_strncpy(char * s1,const char * s2,int n)2066 static void yy_flex_strncpy (char* s1, const char * s2, int n )
2067 {
2068 
2069 	int i;
2070 	for ( i = 0; i < n; ++i )
2071 		s1[i] = s2[i];
2072 }
2073 #endif
2074 
2075 #ifdef YY_NEED_STRLEN
yy_flex_strlen(const char * s)2076 static int yy_flex_strlen (const char * s )
2077 {
2078 	int n;
2079 	for ( n = 0; s[n]; ++n )
2080 		;
2081 
2082 	return n;
2083 }
2084 #endif
2085 
yyalloc(yy_size_t size)2086 void *yyalloc (yy_size_t  size )
2087 {
2088 			return malloc(size);
2089 }
2090 
yyrealloc(void * ptr,yy_size_t size)2091 void *yyrealloc  (void * ptr, yy_size_t  size )
2092 {
2093 
2094 	/* The cast to (char *) in the following accommodates both
2095 	 * implementations that use char* generic pointers, and those
2096 	 * that use void* generic pointers.  It works with the latter
2097 	 * because both ANSI C and C++ allow castless assignment from
2098 	 * any pointer type to void*, and deal with argument conversions
2099 	 * as though doing an assignment.
2100 	 */
2101 	return realloc(ptr, size);
2102 }
2103 
yyfree(void * ptr)2104 void yyfree (void * ptr )
2105 {
2106 			free( (char *) ptr );	/* see yyrealloc() for (char *) cast */
2107 }
2108 
2109 #define YYTABLES_NAME "yytables"
2110 
2111 #line 109 "guc-file.l"
2112 
2113 
2114 /* LCOV_EXCL_STOP */
2115 
2116 /*
2117  * Exported function to read and process the configuration file. The
2118  * parameter indicates in what context the file is being read --- either
2119  * postmaster startup (including standalone-backend startup) or SIGHUP.
2120  * All options mentioned in the configuration file are set to new values.
2121  * If a hard error occurs, no values will be changed.  (There can also be
2122  * errors that prevent just one value from being changed.)
2123  */
2124 void
ProcessConfigFile(GucContext context)2125 ProcessConfigFile(GucContext context)
2126 {
2127 	int			elevel;
2128 	MemoryContext config_cxt;
2129 	MemoryContext caller_cxt;
2130 
2131 	/*
2132 	 * Config files are processed on startup (by the postmaster only) and on
2133 	 * SIGHUP (by the postmaster and its children)
2134 	 */
2135 	Assert((context == PGC_POSTMASTER && !IsUnderPostmaster) ||
2136 		   context == PGC_SIGHUP);
2137 
2138 	/*
2139 	 * To avoid cluttering the log, only the postmaster bleats loudly about
2140 	 * problems with the config file.
2141 	 */
2142 	elevel = IsUnderPostmaster ? DEBUG2 : LOG;
2143 
2144 	/*
2145 	 * This function is usually called within a process-lifespan memory
2146 	 * context.  To ensure that any memory leaked during GUC processing does
2147 	 * not accumulate across repeated SIGHUP cycles, do the work in a private
2148 	 * context that we can free at exit.
2149 	 */
2150 	config_cxt = AllocSetContextCreate(CurrentMemoryContext,
2151 									   "config file processing",
2152 									   ALLOCSET_DEFAULT_SIZES);
2153 	caller_cxt = MemoryContextSwitchTo(config_cxt);
2154 
2155 	/*
2156 	 * Read and apply the config file.  We don't need to examine the result.
2157 	 */
2158 	(void) ProcessConfigFileInternal(context, true, elevel);
2159 
2160 	/* Clean up */
2161 	MemoryContextSwitchTo(caller_cxt);
2162 	MemoryContextDelete(config_cxt);
2163 }
2164 
2165 /*
2166  * This function handles both actual config file (re)loads and execution of
2167  * show_all_file_settings() (i.e., the pg_file_settings view).  In the latter
2168  * case we don't apply any of the settings, but we make all the usual validity
2169  * checks, and we return the ConfigVariable list so that it can be printed out
2170  * by show_all_file_settings().
2171  */
2172 static ConfigVariable *
ProcessConfigFileInternal(GucContext context,bool applySettings,int elevel)2173 ProcessConfigFileInternal(GucContext context, bool applySettings, int elevel)
2174 {
2175 	bool		error = false;
2176 	bool		applying = false;
2177 	const char *ConfFileWithError;
2178 	ConfigVariable *item,
2179 			   *head,
2180 			   *tail;
2181 	int			i;
2182 
2183 	/* Parse the main config file into a list of option names and values */
2184 	ConfFileWithError = ConfigFileName;
2185 	head = tail = NULL;
2186 
2187 	if (!ParseConfigFile(ConfigFileName, true,
2188 						 NULL, 0, 0, elevel,
2189 						 &head, &tail))
2190 	{
2191 		/* Syntax error(s) detected in the file, so bail out */
2192 		error = true;
2193 		goto bail_out;
2194 	}
2195 
2196 	/*
2197 	 * Parse the PG_AUTOCONF_FILENAME file, if present, after the main file to
2198 	 * replace any parameters set by ALTER SYSTEM command.  Because this file
2199 	 * is in the data directory, we can't read it until the DataDir has been
2200 	 * set.
2201 	 */
2202 	if (DataDir)
2203 	{
2204 		if (!ParseConfigFile(PG_AUTOCONF_FILENAME, false,
2205 							 NULL, 0, 0, elevel,
2206 							 &head, &tail))
2207 		{
2208 			/* Syntax error(s) detected in the file, so bail out */
2209 			error = true;
2210 			ConfFileWithError = PG_AUTOCONF_FILENAME;
2211 			goto bail_out;
2212 		}
2213 	}
2214 	else
2215 	{
2216 		/*
2217 		 * If DataDir is not set, the PG_AUTOCONF_FILENAME file cannot be
2218 		 * read.  In this case, we don't want to accept any settings but
2219 		 * data_directory from postgresql.conf, because they might be
2220 		 * overwritten with settings in the PG_AUTOCONF_FILENAME file which
2221 		 * will be read later. OTOH, since data_directory isn't allowed in the
2222 		 * PG_AUTOCONF_FILENAME file, it will never be overwritten later.
2223 		 */
2224 		ConfigVariable *newlist = NULL;
2225 
2226 		/*
2227 		 * Prune all items except the last "data_directory" from the list.
2228 		 */
2229 		for (item = head; item; item = item->next)
2230 		{
2231 			if (!item->ignore &&
2232 				strcmp(item->name, "data_directory") == 0)
2233 				newlist = item;
2234 		}
2235 
2236 		if (newlist)
2237 			newlist->next = NULL;
2238 		head = tail = newlist;
2239 
2240 		/*
2241 		 * Quick exit if data_directory is not present in file.
2242 		 *
2243 		 * We need not do any further processing, in particular we don't set
2244 		 * PgReloadTime; that will be set soon by subsequent full loading of
2245 		 * the config file.
2246 		 */
2247 		if (head == NULL)
2248 			goto bail_out;
2249 	}
2250 
2251 	/*
2252 	 * Mark all extant GUC variables as not present in the config file. We
2253 	 * need this so that we can tell below which ones have been removed from
2254 	 * the file since we last processed it.
2255 	 */
2256 	for (i = 0; i < num_guc_variables; i++)
2257 	{
2258 		struct config_generic *gconf = guc_variables[i];
2259 
2260 		gconf->status &= ~GUC_IS_IN_FILE;
2261 	}
2262 
2263 	/*
2264 	 * Check if all the supplied option names are valid, as an additional
2265 	 * quasi-syntactic check on the validity of the config file.  It is
2266 	 * important that the postmaster and all backends agree on the results of
2267 	 * this phase, else we will have strange inconsistencies about which
2268 	 * processes accept a config file update and which don't.  Hence, unknown
2269 	 * custom variable names have to be accepted without complaint.  For the
2270 	 * same reason, we don't attempt to validate the options' values here.
2271 	 *
2272 	 * In addition, the GUC_IS_IN_FILE flag is set on each existing GUC
2273 	 * variable mentioned in the file; and we detect duplicate entries in the
2274 	 * file and mark the earlier occurrences as ignorable.
2275 	 */
2276 	for (item = head; item; item = item->next)
2277 	{
2278 		struct config_generic *record;
2279 
2280 		/* Ignore anything already marked as ignorable */
2281 		if (item->ignore)
2282 			continue;
2283 
2284 		/*
2285 		 * Try to find the variable; but do not create a custom placeholder if
2286 		 * it's not there already.
2287 		 */
2288 		record = find_option(item->name, false, true, elevel);
2289 
2290 		if (record)
2291 		{
2292 			/* If it's already marked, then this is a duplicate entry */
2293 			if (record->status & GUC_IS_IN_FILE)
2294 			{
2295 				/*
2296 				 * Mark the earlier occurrence(s) as dead/ignorable.  We could
2297 				 * avoid the O(N^2) behavior here with some additional state,
2298 				 * but it seems unlikely to be worth the trouble.
2299 				 */
2300 				ConfigVariable *pitem;
2301 
2302 				for (pitem = head; pitem != item; pitem = pitem->next)
2303 				{
2304 					if (!pitem->ignore &&
2305 						strcmp(pitem->name, item->name) == 0)
2306 						pitem->ignore = true;
2307 				}
2308 			}
2309 			/* Now mark it as present in file */
2310 			record->status |= GUC_IS_IN_FILE;
2311 		}
2312 		else if (!valid_custom_variable_name(item->name))
2313 		{
2314 			/* Invalid non-custom variable, so complain */
2315 			ereport(elevel,
2316 					(errcode(ERRCODE_UNDEFINED_OBJECT),
2317 					 errmsg("unrecognized configuration parameter \"%s\" in file \"%s\" line %d",
2318 							item->name,
2319 							item->filename, item->sourceline)));
2320 			item->errmsg = pstrdup("unrecognized configuration parameter");
2321 			error = true;
2322 			ConfFileWithError = item->filename;
2323 		}
2324 	}
2325 
2326 	/*
2327 	 * If we've detected any errors so far, we don't want to risk applying any
2328 	 * changes.
2329 	 */
2330 	if (error)
2331 		goto bail_out;
2332 
2333 	/* Otherwise, set flag that we're beginning to apply changes */
2334 	applying = true;
2335 
2336 	/*
2337 	 * Check for variables having been removed from the config file, and
2338 	 * revert their reset values (and perhaps also effective values) to the
2339 	 * boot-time defaults.  If such a variable can't be changed after startup,
2340 	 * report that and continue.
2341 	 */
2342 	for (i = 0; i < num_guc_variables; i++)
2343 	{
2344 		struct config_generic *gconf = guc_variables[i];
2345 		GucStack   *stack;
2346 
2347 		if (gconf->reset_source != PGC_S_FILE ||
2348 			(gconf->status & GUC_IS_IN_FILE))
2349 			continue;
2350 		if (gconf->context < PGC_SIGHUP)
2351 		{
2352 			/* The removal can't be effective without a restart */
2353 			gconf->status |= GUC_PENDING_RESTART;
2354 			ereport(elevel,
2355 					(errcode(ERRCODE_CANT_CHANGE_RUNTIME_PARAM),
2356 					 errmsg("parameter \"%s\" cannot be changed without restarting the server",
2357 							gconf->name)));
2358 			record_config_file_error(psprintf("parameter \"%s\" cannot be changed without restarting the server",
2359 											  gconf->name),
2360 									 NULL, 0,
2361 									 &head, &tail);
2362 			error = true;
2363 			continue;
2364 		}
2365 
2366 		/* No more to do if we're just doing show_all_file_settings() */
2367 		if (!applySettings)
2368 			continue;
2369 
2370 		/*
2371 		 * Reset any "file" sources to "default", else set_config_option will
2372 		 * not override those settings.
2373 		 */
2374 		if (gconf->reset_source == PGC_S_FILE)
2375 			gconf->reset_source = PGC_S_DEFAULT;
2376 		if (gconf->source == PGC_S_FILE)
2377 			gconf->source = PGC_S_DEFAULT;
2378 		for (stack = gconf->stack; stack; stack = stack->prev)
2379 		{
2380 			if (stack->source == PGC_S_FILE)
2381 				stack->source = PGC_S_DEFAULT;
2382 		}
2383 
2384 		/* Now we can re-apply the wired-in default (i.e., the boot_val) */
2385 		if (set_config_option(gconf->name, NULL,
2386 							  context, PGC_S_DEFAULT,
2387 							  GUC_ACTION_SET, true, 0, false) > 0)
2388 		{
2389 			/* Log the change if appropriate */
2390 			if (context == PGC_SIGHUP)
2391 				ereport(elevel,
2392 						(errmsg("parameter \"%s\" removed from configuration file, reset to default",
2393 								gconf->name)));
2394 		}
2395 	}
2396 
2397 	/*
2398 	 * Restore any variables determined by environment variables or
2399 	 * dynamically-computed defaults.  This is a no-op except in the case
2400 	 * where one of these had been in the config file and is now removed.
2401 	 *
2402 	 * In particular, we *must not* do this during the postmaster's initial
2403 	 * loading of the file, since the timezone functions in particular should
2404 	 * be run only after initialization is complete.
2405 	 *
2406 	 * XXX this is an unmaintainable crock, because we have to know how to set
2407 	 * (or at least what to call to set) every variable that could potentially
2408 	 * have PGC_S_DYNAMIC_DEFAULT or PGC_S_ENV_VAR source. However, there's no
2409 	 * time to redesign it for 9.1.
2410 	 */
2411 	if (context == PGC_SIGHUP && applySettings)
2412 	{
2413 		InitializeGUCOptionsFromEnvironment();
2414 		pg_timezone_abbrev_initialize();
2415 		/* this selects SQL_ASCII in processes not connected to a database */
2416 		SetConfigOption("client_encoding", GetDatabaseEncodingName(),
2417 						PGC_BACKEND, PGC_S_DYNAMIC_DEFAULT);
2418 	}
2419 
2420 	/*
2421 	 * Now apply the values from the config file.
2422 	 */
2423 	for (item = head; item; item = item->next)
2424 	{
2425 		char	   *pre_value = NULL;
2426 		int			scres;
2427 
2428 		/* Ignore anything marked as ignorable */
2429 		if (item->ignore)
2430 			continue;
2431 
2432 		/* In SIGHUP cases in the postmaster, we want to report changes */
2433 		if (context == PGC_SIGHUP && applySettings && !IsUnderPostmaster)
2434 		{
2435 			const char *preval = GetConfigOption(item->name, true, false);
2436 
2437 			/* If option doesn't exist yet or is NULL, treat as empty string */
2438 			if (!preval)
2439 				preval = "";
2440 			/* must dup, else might have dangling pointer below */
2441 			pre_value = pstrdup(preval);
2442 		}
2443 
2444 		scres = set_config_option(item->name, item->value,
2445 								  context, PGC_S_FILE,
2446 								  GUC_ACTION_SET, applySettings, 0, false);
2447 		if (scres > 0)
2448 		{
2449 			/* variable was updated, so log the change if appropriate */
2450 			if (pre_value)
2451 			{
2452 				const char *post_value = GetConfigOption(item->name, true, false);
2453 
2454 				if (!post_value)
2455 					post_value = "";
2456 				if (strcmp(pre_value, post_value) != 0)
2457 					ereport(elevel,
2458 							(errmsg("parameter \"%s\" changed to \"%s\"",
2459 									item->name, item->value)));
2460 			}
2461 			item->applied = true;
2462 		}
2463 		else if (scres == 0)
2464 		{
2465 			error = true;
2466 			item->errmsg = pstrdup("setting could not be applied");
2467 			ConfFileWithError = item->filename;
2468 		}
2469 		else
2470 		{
2471 			/* no error, but variable's active value was not changed */
2472 			item->applied = true;
2473 		}
2474 
2475 		/*
2476 		 * We should update source location unless there was an error, since
2477 		 * even if the active value didn't change, the reset value might have.
2478 		 * (In the postmaster, there won't be a difference, but it does matter
2479 		 * in backends.)
2480 		 */
2481 		if (scres != 0 && applySettings)
2482 			set_config_sourcefile(item->name, item->filename,
2483 								  item->sourceline);
2484 
2485 		if (pre_value)
2486 			pfree(pre_value);
2487 	}
2488 
2489 	/* Remember when we last successfully loaded the config file. */
2490 	if (applySettings)
2491 		PgReloadTime = GetCurrentTimestamp();
2492 
2493 bail_out:
2494 	if (error && applySettings)
2495 	{
2496 		/* During postmaster startup, any error is fatal */
2497 		if (context == PGC_POSTMASTER)
2498 			ereport(ERROR,
2499 					(errcode(ERRCODE_CONFIG_FILE_ERROR),
2500 					 errmsg("configuration file \"%s\" contains errors",
2501 							ConfFileWithError)));
2502 		else if (applying)
2503 			ereport(elevel,
2504 					(errcode(ERRCODE_CONFIG_FILE_ERROR),
2505 					 errmsg("configuration file \"%s\" contains errors; unaffected changes were applied",
2506 							ConfFileWithError)));
2507 		else
2508 			ereport(elevel,
2509 					(errcode(ERRCODE_CONFIG_FILE_ERROR),
2510 					 errmsg("configuration file \"%s\" contains errors; no changes were applied",
2511 							ConfFileWithError)));
2512 	}
2513 
2514 	/* Successful or otherwise, return the collected data list */
2515 	return head;
2516 }
2517 
2518 /*
2519  * Given a configuration file or directory location that may be a relative
2520  * path, return an absolute one.  We consider the location to be relative to
2521  * the directory holding the calling file, or to DataDir if no calling file.
2522  */
2523 static char *
AbsoluteConfigLocation(const char * location,const char * calling_file)2524 AbsoluteConfigLocation(const char *location, const char *calling_file)
2525 {
2526 	char		abs_path[MAXPGPATH];
2527 
2528 	if (is_absolute_path(location))
2529 		return pstrdup(location);
2530 	else
2531 	{
2532 		if (calling_file != NULL)
2533 		{
2534 			strlcpy(abs_path, calling_file, sizeof(abs_path));
2535 			get_parent_directory(abs_path);
2536 			join_path_components(abs_path, abs_path, location);
2537 			canonicalize_path(abs_path);
2538 		}
2539 		else
2540 		{
2541 			AssertState(DataDir);
2542 			join_path_components(abs_path, DataDir, location);
2543 			canonicalize_path(abs_path);
2544 		}
2545 		return pstrdup(abs_path);
2546 	}
2547 }
2548 
2549 /*
2550  * Read and parse a single configuration file.  This function recurses
2551  * to handle "include" directives.
2552  *
2553  * If "strict" is true, treat failure to open the config file as an error,
2554  * otherwise just skip the file.
2555  *
2556  * calling_file/calling_lineno identify the source of the request.
2557  * Pass NULL/0 if not recursing from an inclusion request.
2558  *
2559  * See ParseConfigFp for further details.  This one merely adds opening the
2560  * config file rather than working from a caller-supplied file descriptor,
2561  * and absolute-ifying the path name if necessary.
2562  */
2563 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)2564 ParseConfigFile(const char *config_file, bool strict,
2565 				const char *calling_file, int calling_lineno,
2566 				int depth, int elevel,
2567 				ConfigVariable **head_p,
2568 				ConfigVariable **tail_p)
2569 {
2570 	char	   *abs_path;
2571 	bool		OK = true;
2572 	FILE	   *fp;
2573 
2574 	/*
2575 	 * Reject file name that is all-blank (including empty), as that leads to
2576 	 * confusion --- we'd try to read the containing directory as a file.
2577 	 */
2578 	if (strspn(config_file, " \t\r\n") == strlen(config_file))
2579 	{
2580 		ereport(elevel,
2581 				(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
2582 				 errmsg("empty configuration file name: \"%s\"",
2583 						config_file)));
2584 		record_config_file_error("empty configuration file name",
2585 								 calling_file, calling_lineno,
2586 								 head_p, tail_p);
2587 		return false;
2588 	}
2589 
2590 	/*
2591 	 * Reject too-deep include nesting depth.  This is just a safety check to
2592 	 * avoid dumping core due to stack overflow if an include file loops back
2593 	 * to itself.  The maximum nesting depth is pretty arbitrary.
2594 	 */
2595 	if (depth > 10)
2596 	{
2597 		ereport(elevel,
2598 				(errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
2599 				 errmsg("could not open configuration file \"%s\": maximum nesting depth exceeded",
2600 						config_file)));
2601 		record_config_file_error("nesting depth exceeded",
2602 								 calling_file, calling_lineno,
2603 								 head_p, tail_p);
2604 		return false;
2605 	}
2606 
2607 	abs_path = AbsoluteConfigLocation(config_file, calling_file);
2608 
2609 	/*
2610 	 * Reject direct recursion.  Indirect recursion is also possible, but it's
2611 	 * harder to detect and so doesn't seem worth the trouble.  (We test at
2612 	 * this step because the canonicalization done by AbsoluteConfigLocation
2613 	 * makes it more likely that a simple strcmp comparison will match.)
2614 	 */
2615 	if (calling_file && strcmp(abs_path, calling_file) == 0)
2616 	{
2617 		ereport(elevel,
2618 				(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
2619 				 errmsg("configuration file recursion in \"%s\"",
2620 						calling_file)));
2621 		record_config_file_error("configuration file recursion",
2622 								 calling_file, calling_lineno,
2623 								 head_p, tail_p);
2624 		pfree(abs_path);
2625 		return false;
2626 	}
2627 
2628 	fp = AllocateFile(abs_path, "r");
2629 	if (!fp)
2630 	{
2631 		if (strict)
2632 		{
2633 			ereport(elevel,
2634 					(errcode_for_file_access(),
2635 					 errmsg("could not open configuration file \"%s\": %m",
2636 							abs_path)));
2637 			record_config_file_error(psprintf("could not open file \"%s\"",
2638 											  abs_path),
2639 									 calling_file, calling_lineno,
2640 									 head_p, tail_p);
2641 			OK = false;
2642 		}
2643 		else
2644 		{
2645 			ereport(LOG,
2646 					(errmsg("skipping missing configuration file \"%s\"",
2647 							abs_path)));
2648 		}
2649 		goto cleanup;
2650 	}
2651 
2652 	OK = ParseConfigFp(fp, abs_path, depth, elevel, head_p, tail_p);
2653 
2654 cleanup:
2655 	if (fp)
2656 		FreeFile(fp);
2657 	pfree(abs_path);
2658 
2659 	return OK;
2660 }
2661 
2662 /*
2663  * Capture an error message in the ConfigVariable list returned by
2664  * config file parsing.
2665  */
2666 static void
record_config_file_error(const char * errmsg,const char * config_file,int lineno,ConfigVariable ** head_p,ConfigVariable ** tail_p)2667 record_config_file_error(const char *errmsg,
2668 						 const char *config_file,
2669 						 int lineno,
2670 						 ConfigVariable **head_p,
2671 						 ConfigVariable **tail_p)
2672 {
2673 	ConfigVariable *item;
2674 
2675 	item = palloc(sizeof *item);
2676 	item->name = NULL;
2677 	item->value = NULL;
2678 	item->errmsg = pstrdup(errmsg);
2679 	item->filename = config_file ? pstrdup(config_file) : NULL;
2680 	item->sourceline = lineno;
2681 	item->ignore = true;
2682 	item->applied = false;
2683 	item->next = NULL;
2684 	if (*head_p == NULL)
2685 		*head_p = item;
2686 	else
2687 		(*tail_p)->next = item;
2688 	*tail_p = item;
2689 }
2690 
2691 /*
2692  * Flex fatal errors bring us here.  Stash the error message and jump back to
2693  * ParseConfigFp().  Assume all msg arguments point to string constants; this
2694  * holds for flex 2.5.31 (earliest we support) and flex 2.5.35 (latest as of
2695  * this writing).  Otherwise, we would need to copy the message.
2696  *
2697  * We return "int" since this takes the place of calls to fprintf().
2698 */
2699 static int
GUC_flex_fatal(const char * msg)2700 GUC_flex_fatal(const char *msg)
2701 {
2702 	GUC_flex_fatal_errmsg = msg;
2703 	siglongjmp(*GUC_flex_fatal_jmp, 1);
2704 	return 0;					/* keep compiler quiet */
2705 }
2706 
2707 /*
2708  * Read and parse a single configuration file.  This function recurses
2709  * to handle "include" directives.
2710  *
2711  * Input parameters:
2712  *	fp: file pointer from AllocateFile for the configuration file to parse
2713  *	config_file: absolute or relative path name of the configuration file
2714  *	depth: recursion depth (should be 0 in the outermost call)
2715  *	elevel: error logging level to use
2716  * Input/Output parameters:
2717  *	head_p, tail_p: head and tail of linked list of name/value pairs
2718  *
2719  * *head_p and *tail_p must be initialized, either to NULL or valid pointers
2720  * to a ConfigVariable list, before calling the outer recursion level.  Any
2721  * name-value pairs read from the input file(s) will be appended to the list.
2722  * Error reports will also be appended to the list, if elevel < ERROR.
2723  *
2724  * Returns TRUE if successful, FALSE if an error occurred.  The error has
2725  * already been ereport'd, it is only necessary for the caller to clean up
2726  * its own state and release the ConfigVariable list.
2727  *
2728  * Note: if elevel >= ERROR then an error will not return control to the
2729  * caller, so there is no need to check the return value in that case.
2730  *
2731  * Note: this function is used to parse not only postgresql.conf, but
2732  * various other configuration files that use the same "name = value"
2733  * syntax.  Hence, do not do anything here or in the subsidiary routines
2734  * ParseConfigFile/ParseConfigDirectory that assumes we are processing
2735  * GUCs specifically.
2736  */
2737 bool
ParseConfigFp(FILE * fp,const char * config_file,int depth,int elevel,ConfigVariable ** head_p,ConfigVariable ** tail_p)2738 ParseConfigFp(FILE *fp, const char *config_file, int depth, int elevel,
2739 			  ConfigVariable **head_p, ConfigVariable **tail_p)
2740 {
2741 	volatile bool OK = true;
2742 	unsigned int save_ConfigFileLineno = ConfigFileLineno;
2743 	sigjmp_buf *save_GUC_flex_fatal_jmp = GUC_flex_fatal_jmp;
2744 	sigjmp_buf	flex_fatal_jmp;
2745 	volatile YY_BUFFER_STATE lex_buffer = NULL;
2746 	int			errorcount;
2747 	int			token;
2748 
2749 	if (sigsetjmp(flex_fatal_jmp, 1) == 0)
2750 		GUC_flex_fatal_jmp = &flex_fatal_jmp;
2751 	else
2752 	{
2753 		/*
2754 		 * Regain control after a fatal, internal flex error.  It may have
2755 		 * corrupted parser state.  Consequently, abandon the file, but trust
2756 		 * that the state remains sane enough for yy_delete_buffer().
2757 		 */
2758 		elog(elevel, "%s at file \"%s\" line %u",
2759 			 GUC_flex_fatal_errmsg, config_file, ConfigFileLineno);
2760 		record_config_file_error(GUC_flex_fatal_errmsg,
2761 								 config_file, ConfigFileLineno,
2762 								 head_p, tail_p);
2763 		OK = false;
2764 		goto cleanup;
2765 	}
2766 
2767 	/*
2768 	 * Parse
2769 	 */
2770 	ConfigFileLineno = 1;
2771 	errorcount = 0;
2772 
2773 	lex_buffer = yy_create_buffer(fp, YY_BUF_SIZE);
2774 	yy_switch_to_buffer(lex_buffer);
2775 
2776 	/* This loop iterates once per logical line */
2777 	while ((token = yylex()))
2778 	{
2779 		char	   *opt_name = NULL;
2780 		char	   *opt_value = NULL;
2781 		ConfigVariable *item;
2782 
2783 		if (token == GUC_EOL)	/* empty or comment line */
2784 			continue;
2785 
2786 		/* first token on line is option name */
2787 		if (token != GUC_ID && token != GUC_QUALIFIED_ID)
2788 			goto parse_error;
2789 		opt_name = pstrdup(yytext);
2790 
2791 		/* next we have an optional equal sign; discard if present */
2792 		token = yylex();
2793 		if (token == GUC_EQUALS)
2794 			token = yylex();
2795 
2796 		/* now we must have the option value */
2797 		if (token != GUC_ID &&
2798 			token != GUC_STRING &&
2799 			token != GUC_INTEGER &&
2800 			token != GUC_REAL &&
2801 			token != GUC_UNQUOTED_STRING)
2802 			goto parse_error;
2803 		if (token == GUC_STRING)	/* strip quotes and escapes */
2804 			opt_value = DeescapeQuotedString(yytext);
2805 		else
2806 			opt_value = pstrdup(yytext);
2807 
2808 		/* now we'd like an end of line, or possibly EOF */
2809 		token = yylex();
2810 		if (token != GUC_EOL)
2811 		{
2812 			if (token != 0)
2813 				goto parse_error;
2814 			/* treat EOF like \n for line numbering purposes, cf bug 4752 */
2815 			ConfigFileLineno++;
2816 		}
2817 
2818 		/* OK, process the option name and value */
2819 		if (guc_name_compare(opt_name, "include_dir") == 0)
2820 		{
2821 			/*
2822 			 * An include_dir directive isn't a variable and should be
2823 			 * processed immediately.
2824 			 */
2825 			if (!ParseConfigDirectory(opt_value,
2826 									  config_file, ConfigFileLineno - 1,
2827 									  depth + 1, elevel,
2828 									  head_p, tail_p))
2829 				OK = false;
2830 			yy_switch_to_buffer(lex_buffer);
2831 			pfree(opt_name);
2832 			pfree(opt_value);
2833 		}
2834 		else if (guc_name_compare(opt_name, "include_if_exists") == 0)
2835 		{
2836 			/*
2837 			 * An include_if_exists directive isn't a variable and should be
2838 			 * processed immediately.
2839 			 */
2840 			if (!ParseConfigFile(opt_value, false,
2841 								 config_file, ConfigFileLineno - 1,
2842 								 depth + 1, elevel,
2843 								 head_p, tail_p))
2844 				OK = false;
2845 			yy_switch_to_buffer(lex_buffer);
2846 			pfree(opt_name);
2847 			pfree(opt_value);
2848 		}
2849 		else if (guc_name_compare(opt_name, "include") == 0)
2850 		{
2851 			/*
2852 			 * An include directive isn't a variable and should be processed
2853 			 * immediately.
2854 			 */
2855 			if (!ParseConfigFile(opt_value, true,
2856 								 config_file, ConfigFileLineno - 1,
2857 								 depth + 1, elevel,
2858 								 head_p, tail_p))
2859 				OK = false;
2860 			yy_switch_to_buffer(lex_buffer);
2861 			pfree(opt_name);
2862 			pfree(opt_value);
2863 		}
2864 		else
2865 		{
2866 			/* ordinary variable, append to list */
2867 			item = palloc(sizeof *item);
2868 			item->name = opt_name;
2869 			item->value = opt_value;
2870 			item->errmsg = NULL;
2871 			item->filename = pstrdup(config_file);
2872 			item->sourceline = ConfigFileLineno - 1;
2873 			item->ignore = false;
2874 			item->applied = false;
2875 			item->next = NULL;
2876 			if (*head_p == NULL)
2877 				*head_p = item;
2878 			else
2879 				(*tail_p)->next = item;
2880 			*tail_p = item;
2881 		}
2882 
2883 		/* break out of loop if read EOF, else loop for next line */
2884 		if (token == 0)
2885 			break;
2886 		continue;
2887 
2888 parse_error:
2889 		/* release storage if we allocated any on this line */
2890 		if (opt_name)
2891 			pfree(opt_name);
2892 		if (opt_value)
2893 			pfree(opt_value);
2894 
2895 		/* report the error */
2896 		if (token == GUC_EOL || token == 0)
2897 		{
2898 			ereport(elevel,
2899 					(errcode(ERRCODE_SYNTAX_ERROR),
2900 			  errmsg("syntax error in file \"%s\" line %u, near end of line",
2901 					 config_file, ConfigFileLineno - 1)));
2902 			record_config_file_error("syntax error",
2903 									 config_file, ConfigFileLineno - 1,
2904 									 head_p, tail_p);
2905 		}
2906 		else
2907 		{
2908 			ereport(elevel,
2909 					(errcode(ERRCODE_SYNTAX_ERROR),
2910 			 errmsg("syntax error in file \"%s\" line %u, near token \"%s\"",
2911 					config_file, ConfigFileLineno, yytext)));
2912 			record_config_file_error("syntax error",
2913 									 config_file, ConfigFileLineno,
2914 									 head_p, tail_p);
2915 		}
2916 		OK = false;
2917 		errorcount++;
2918 
2919 		/*
2920 		 * To avoid producing too much noise when fed a totally bogus file,
2921 		 * give up after 100 syntax errors per file (an arbitrary number).
2922 		 * Also, if we're only logging the errors at DEBUG level anyway, might
2923 		 * as well give up immediately.  (This prevents postmaster children
2924 		 * from bloating the logs with duplicate complaints.)
2925 		 */
2926 		if (errorcount >= 100 || elevel <= DEBUG1)
2927 		{
2928 			ereport(elevel,
2929 					(errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
2930 			   errmsg("too many syntax errors found, abandoning file \"%s\"",
2931 					  config_file)));
2932 			break;
2933 		}
2934 
2935 		/* resync to next end-of-line or EOF */
2936 		while (token != GUC_EOL && token != 0)
2937 			token = yylex();
2938 		/* break out of loop on EOF */
2939 		if (token == 0)
2940 			break;
2941 	}
2942 
2943 cleanup:
2944 	yy_delete_buffer(lex_buffer);
2945 	/* Each recursion level must save and restore these static variables. */
2946 	ConfigFileLineno = save_ConfigFileLineno;
2947 	GUC_flex_fatal_jmp = save_GUC_flex_fatal_jmp;
2948 	return OK;
2949 }
2950 
2951 /*
2952  * Read and parse all config files in a subdirectory in alphabetical order
2953  *
2954  * includedir is the absolute or relative path to the subdirectory to scan.
2955  *
2956  * calling_file/calling_lineno identify the source of the request.
2957  * Pass NULL/0 if not recursing from an inclusion request.
2958  *
2959  * See ParseConfigFp for further details.
2960  */
2961 bool
ParseConfigDirectory(const char * includedir,const char * calling_file,int calling_lineno,int depth,int elevel,ConfigVariable ** head_p,ConfigVariable ** tail_p)2962 ParseConfigDirectory(const char *includedir,
2963 					 const char *calling_file, int calling_lineno,
2964 					 int depth, int elevel,
2965 					 ConfigVariable **head_p,
2966 					 ConfigVariable **tail_p)
2967 {
2968 	char	   *directory;
2969 	DIR		   *d;
2970 	struct dirent *de;
2971 	char	  **filenames;
2972 	int			num_filenames;
2973 	int			size_filenames;
2974 	bool		status;
2975 
2976 	/*
2977 	 * Reject directory name that is all-blank (including empty), as that
2978 	 * leads to confusion --- we'd read the containing directory, typically
2979 	 * resulting in recursive inclusion of the same file(s).
2980 	 */
2981 	if (strspn(includedir, " \t\r\n") == strlen(includedir))
2982 	{
2983 		ereport(elevel,
2984 				(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
2985 				 errmsg("empty configuration directory name: \"%s\"",
2986 						includedir)));
2987 		record_config_file_error("empty configuration directory name",
2988 								 calling_file, calling_lineno,
2989 								 head_p, tail_p);
2990 		return false;
2991 	}
2992 
2993 	/*
2994 	 * We don't check for recursion or too-deep nesting depth here; the
2995 	 * subsequent calls to ParseConfigFile will take care of that.
2996 	 */
2997 
2998 	directory = AbsoluteConfigLocation(includedir, calling_file);
2999 	d = AllocateDir(directory);
3000 	if (d == NULL)
3001 	{
3002 		ereport(elevel,
3003 				(errcode_for_file_access(),
3004 				 errmsg("could not open configuration directory \"%s\": %m",
3005 						directory)));
3006 		record_config_file_error(psprintf("could not open directory \"%s\"",
3007 										  directory),
3008 								 calling_file, calling_lineno,
3009 								 head_p, tail_p);
3010 		status = false;
3011 		goto cleanup;
3012 	}
3013 
3014 	/*
3015 	 * Read the directory and put the filenames in an array, so we can sort
3016 	 * them prior to processing the contents.
3017 	 */
3018 	size_filenames = 32;
3019 	filenames = (char **) palloc(size_filenames * sizeof(char *));
3020 	num_filenames = 0;
3021 
3022 	while ((de = ReadDir(d, directory)) != NULL)
3023 	{
3024 		struct stat st;
3025 		char		filename[MAXPGPATH];
3026 
3027 		/*
3028 		 * Only parse files with names ending in ".conf".  Explicitly reject
3029 		 * files starting with ".".  This excludes things like "." and "..",
3030 		 * as well as typical hidden files, backup files, and editor debris.
3031 		 */
3032 		if (strlen(de->d_name) < 6)
3033 			continue;
3034 		if (de->d_name[0] == '.')
3035 			continue;
3036 		if (strcmp(de->d_name + strlen(de->d_name) - 5, ".conf") != 0)
3037 			continue;
3038 
3039 		join_path_components(filename, directory, de->d_name);
3040 		canonicalize_path(filename);
3041 		if (stat(filename, &st) == 0)
3042 		{
3043 			if (!S_ISDIR(st.st_mode))
3044 			{
3045 				/* Add file to array, increasing its size in blocks of 32 */
3046 				if (num_filenames >= size_filenames)
3047 				{
3048 					size_filenames += 32;
3049 					filenames = (char **) repalloc(filenames,
3050 											size_filenames * sizeof(char *));
3051 				}
3052 				filenames[num_filenames] = pstrdup(filename);
3053 				num_filenames++;
3054 			}
3055 		}
3056 		else
3057 		{
3058 			/*
3059 			 * stat does not care about permissions, so the most likely reason
3060 			 * a file can't be accessed now is if it was removed between the
3061 			 * directory listing and now.
3062 			 */
3063 			ereport(elevel,
3064 					(errcode_for_file_access(),
3065 					 errmsg("could not stat file \"%s\": %m",
3066 							filename)));
3067 			record_config_file_error(psprintf("could not stat file \"%s\"",
3068 											  filename),
3069 									 calling_file, calling_lineno,
3070 									 head_p, tail_p);
3071 			status = false;
3072 			goto cleanup;
3073 		}
3074 	}
3075 
3076 	if (num_filenames > 0)
3077 	{
3078 		int			i;
3079 
3080 		qsort(filenames, num_filenames, sizeof(char *), pg_qsort_strcmp);
3081 		for (i = 0; i < num_filenames; i++)
3082 		{
3083 			if (!ParseConfigFile(filenames[i], true,
3084 								 calling_file, calling_lineno,
3085 								 depth, elevel,
3086 								 head_p, tail_p))
3087 			{
3088 				status = false;
3089 				goto cleanup;
3090 			}
3091 		}
3092 	}
3093 	status = true;
3094 
3095 cleanup:
3096 	if (d)
3097 		FreeDir(d);
3098 	pfree(directory);
3099 	return status;
3100 }
3101 
3102 /*
3103  * Free a list of ConfigVariables, including the names and the values
3104  */
3105 void
FreeConfigVariables(ConfigVariable * list)3106 FreeConfigVariables(ConfigVariable *list)
3107 {
3108 	ConfigVariable *item;
3109 
3110 	item = list;
3111 	while (item)
3112 	{
3113 		ConfigVariable *next = item->next;
3114 
3115 		FreeConfigVariable(item);
3116 		item = next;
3117 	}
3118 }
3119 
3120 /*
3121  * Free a single ConfigVariable
3122  */
3123 static void
FreeConfigVariable(ConfigVariable * item)3124 FreeConfigVariable(ConfigVariable *item)
3125 {
3126 	if (item->name)
3127 		pfree(item->name);
3128 	if (item->value)
3129 		pfree(item->value);
3130 	if (item->errmsg)
3131 		pfree(item->errmsg);
3132 	if (item->filename)
3133 		pfree(item->filename);
3134 	pfree(item);
3135 }
3136 
3137 
3138 /*
3139  *		DeescapeQuotedString
3140  *
3141  * Strip the quotes surrounding the given string, and collapse any embedded
3142  * '' sequences and backslash escapes.
3143  *
3144  * The string returned is palloc'd and should eventually be pfree'd by the
3145  * caller.
3146  *
3147  * This is exported because it is also used by the bootstrap scanner.
3148  */
3149 char *
DeescapeQuotedString(const char * s)3150 DeescapeQuotedString(const char *s)
3151 {
3152 	char	   *newStr;
3153 	int			len,
3154 				i,
3155 				j;
3156 
3157 	/* We just Assert that there are leading and trailing quotes */
3158 	Assert(s != NULL && s[0] == '\'');
3159 	len = strlen(s);
3160 	Assert(len >= 2);
3161 	Assert(s[len - 1] == '\'');
3162 
3163 	/* Skip the leading quote; we'll handle the trailing quote below */
3164 	s++, len--;
3165 
3166 	/* Since len still includes trailing quote, this is enough space */
3167 	newStr = palloc(len);
3168 
3169 	for (i = 0, j = 0; i < len; i++)
3170 	{
3171 		if (s[i] == '\\')
3172 		{
3173 			i++;
3174 			switch (s[i])
3175 			{
3176 				case 'b':
3177 					newStr[j] = '\b';
3178 					break;
3179 				case 'f':
3180 					newStr[j] = '\f';
3181 					break;
3182 				case 'n':
3183 					newStr[j] = '\n';
3184 					break;
3185 				case 'r':
3186 					newStr[j] = '\r';
3187 					break;
3188 				case 't':
3189 					newStr[j] = '\t';
3190 					break;
3191 				case '0':
3192 				case '1':
3193 				case '2':
3194 				case '3':
3195 				case '4':
3196 				case '5':
3197 				case '6':
3198 				case '7':
3199 					{
3200 						int			k;
3201 						long		octVal = 0;
3202 
3203 						for (k = 0;
3204 							 s[i + k] >= '0' && s[i + k] <= '7' && k < 3;
3205 							 k++)
3206 							octVal = (octVal << 3) + (s[i + k] - '0');
3207 						i += k - 1;
3208 						newStr[j] = ((char) octVal);
3209 					}
3210 					break;
3211 				default:
3212 					newStr[j] = s[i];
3213 					break;
3214 			}					/* switch */
3215 		}
3216 		else if (s[i] == '\'' && s[i + 1] == '\'')
3217 		{
3218 			/* doubled quote becomes just one quote */
3219 			newStr[j] = s[++i];
3220 		}
3221 		else
3222 			newStr[j] = s[i];
3223 		j++;
3224 	}
3225 
3226 	/* We copied the ending quote to newStr, so replace with \0 */
3227 	Assert(j > 0 && j <= len);
3228 	newStr[--j] = '\0';
3229 
3230 	return newStr;
3231 }
3232 
3233