LCOV - code coverage report
Current view: top level - src/backend/utils/misc - guc-file.c (source / functions) Hit Total Coverage
Test: PostgreSQL Lines: 180 351 51.3 %
Date: 2017-09-29 15:12:54 Functions: 14 33 42.4 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.11