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