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