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