YugabyteDB (2.13.1.0-b60, 21121d69985fbf76aa6958d8f04a9bfa936293b5)

Coverage Report

Created: 2022-03-22 16:43

/Users/deen/code/yugabyte-db/build/debugcov-clang-dynamic-arm64-ninja/postgres_build/src/bin/psql/psqlscanslash.c
Line
Count
Source (jump to first uncovered line)
1
#line 1 "psqlscanslash.c"
2
/*-------------------------------------------------------------------------
3
 *
4
 * psqlscanslash.l
5
 *    lexical scanner for psql backslash commands
6
 *
7
 * XXX Avoid creating backtracking cases --- see the backend lexer for info.
8
 *
9
 * See fe_utils/psqlscan_int.h for additional commentary.
10
 *
11
 * Portions Copyright (c) 1996-2018, PostgreSQL Global Development Group
12
 * Portions Copyright (c) 1994, Regents of the University of California
13
 *
14
 * IDENTIFICATION
15
 *    src/bin/psql/psqlscanslash.l
16
 *
17
 *-------------------------------------------------------------------------
18
 */
19
#include "postgres_fe.h"
20
21
#include "psqlscanslash.h"
22
#include "fe_utils/conditional.h"
23
24
#include "libpq-fe.h"
25
26
#line 26 "psqlscanslash.c"
27
28
#define  YY_INT_ALIGNED short int
29
30
/* A lexical scanner generated by flex */
31
32
#define FLEX_SCANNER
33
#define YY_FLEX_MAJOR_VERSION 2
34
#define YY_FLEX_MINOR_VERSION 6
35
#define YY_FLEX_SUBMINOR_VERSION 3
36
#if YY_FLEX_SUBMINOR_VERSION > 0
37
#define FLEX_BETA
38
#endif
39
40
    #define yy_create_buffer slash_yy_create_buffer
41
42
    #define yy_delete_buffer slash_yy_delete_buffer
43
44
    #define yy_scan_buffer slash_yy_scan_buffer
45
46
    #define yy_scan_string slash_yy_scan_string
47
48
    #define yy_scan_bytes slash_yy_scan_bytes
49
50
    #define yy_init_buffer slash_yy_init_buffer
51
52
    #define yy_flush_buffer slash_yy_flush_buffer
53
54
    #define yy_load_buffer_state slash_yy_load_buffer_state
55
56
278
    #define yy_switch_to_buffer slash_yy_switch_to_buffer
57
58
    #define yypush_buffer_state slash_yypush_buffer_state
59
60
    #define yypop_buffer_state slash_yypop_buffer_state
61
62
    #define yyensure_buffer_stack slash_yyensure_buffer_stack
63
64
278
    #define yylex slash_yylex
65
66
    #define yyrestart slash_yyrestart
67
68
    #define yylex_init slash_yylex_init
69
70
    #define yylex_init_extra slash_yylex_init_extra
71
72
    #define yylex_destroy slash_yylex_destroy
73
74
    #define yyget_debug slash_yyget_debug
75
76
    #define yyset_debug slash_yyset_debug
77
78
    #define yyget_extra slash_yyget_extra
79
80
    #define yyset_extra slash_yyset_extra
81
82
    #define yyget_in slash_yyget_in
83
84
    #define yyset_in slash_yyset_in
85
86
    #define yyget_out slash_yyget_out
87
88
    #define yyset_out slash_yyset_out
89
90
    #define yyget_leng slash_yyget_leng
91
92
    #define yyget_text slash_yyget_text
93
94
    #define yyget_lineno slash_yyget_lineno
95
96
    #define yyset_lineno slash_yyset_lineno
97
98
        #define yyget_column slash_yyget_column
99
100
        #define yyset_column slash_yyset_column
101
102
    #define yywrap slash_yywrap
103
104
    #define yyget_lval slash_yyget_lval
105
106
    #define yyset_lval slash_yyset_lval
107
108
    #define yyalloc slash_yyalloc
109
110
    #define yyrealloc slash_yyrealloc
111
112
    #define yyfree slash_yyfree
113
114
/* First, we deal with  platform-specific or compiler-specific issues. */
115
116
/* begin standard C headers. */
117
#include <stdio.h>
118
#include <string.h>
119
#include <errno.h>
120
#include <stdlib.h>
121
122
/* end standard C headers. */
123
124
/* flex integer type definitions */
125
126
#ifndef FLEXINT_H
127
#define FLEXINT_H
128
129
/* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */
130
131
#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
132
133
/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h,
134
 * if you want the limit (max/min) macros for int types. 
135
 */
136
#ifndef __STDC_LIMIT_MACROS
137
#define __STDC_LIMIT_MACROS 1
138
#endif
139
140
#include <inttypes.h>
141
typedef int8_t flex_int8_t;
142
typedef uint8_t flex_uint8_t;
143
typedef int16_t flex_int16_t;
144
typedef uint16_t flex_uint16_t;
145
typedef int32_t flex_int32_t;
146
typedef uint32_t flex_uint32_t;
147
#else
148
typedef signed char flex_int8_t;
149
typedef short int flex_int16_t;
150
typedef int flex_int32_t;
151
typedef unsigned char flex_uint8_t; 
152
typedef unsigned short int flex_uint16_t;
153
typedef unsigned int flex_uint32_t;
154
155
/* Limits of integral types. */
156
#ifndef INT8_MIN
157
#define INT8_MIN               (-128)
158
#endif
159
#ifndef INT16_MIN
160
#define INT16_MIN              (-32767-1)
161
#endif
162
#ifndef INT32_MIN
163
#define INT32_MIN              (-2147483647-1)
164
#endif
165
#ifndef INT8_MAX
166
#define INT8_MAX               (127)
167
#endif
168
#ifndef INT16_MAX
169
#define INT16_MAX              (32767)
170
#endif
171
#ifndef INT32_MAX
172
#define INT32_MAX              (2147483647)
173
#endif
174
#ifndef UINT8_MAX
175
#define UINT8_MAX              (255U)
176
#endif
177
#ifndef UINT16_MAX
178
#define UINT16_MAX             (65535U)
179
#endif
180
#ifndef UINT32_MAX
181
#define UINT32_MAX             (4294967295U)
182
#endif
183
184
#endif /* ! C99 */
185
186
#endif /* ! FLEXINT_H */
187
188
/* TODO: this is always defined, so inline it */
189
#define yyconst const
190
191
#if defined(__GNUC__) && __GNUC__ >= 3
192
#define yynoreturn __attribute__((__noreturn__))
193
#else
194
#define yynoreturn
195
#endif
196
197
/* Returned upon end-of-file. */
198
#define YY_NULL 0
199
200
/* Promotes a possibly negative, possibly signed char to an
201
 *   integer in range [0..255] for use as an array index.
202
 */
203
2.47k
#define YY_SC_TO_UI(c) ((YY_CHAR) (c))
204
205
/* An opaque pointer. */
206
#ifndef YY_TYPEDEF_YY_SCANNER_T
207
#define YY_TYPEDEF_YY_SCANNER_T
208
typedef void* yyscan_t;
209
#endif
210
211
/* For convenience, these vars (plus the bison vars far below)
212
   are macros in the reentrant scanner. */
213
59
#define yyin yyg->yyin_r
214
0
#define yyout yyg->yyout_r
215
278
#define yyextra yyg->yyextra_r
216
2.13k
#define yyleng yyg->yyleng_r
217
790
#define yytext yyg->yytext_r
218
0
#define yylineno (YY_CURRENT_BUFFER_LVALUE->yy_bs_lineno)
219
0
#define yycolumn (YY_CURRENT_BUFFER_LVALUE->yy_bs_column)
220
0
#define yy_flex_debug yyg->yy_flex_debug_r
221
222
/* Enter a start condition.  This macro really ought to take a parameter,
223
 * but we do it the disgusting crufty way forced on us by the ()-less
224
 * definition of BEGIN.
225
 */
226
329
#define BEGIN yyg->yy_start = 1 + 2 *
227
/* Translate the current start state into a value that can be later handed
228
 * to BEGIN to return to the state.  The YYSTATE alias is for lex
229
 * compatibility.
230
 */
231
278
#define YY_START ((yyg->yy_start - 1) / 2)
232
#define YYSTATE YY_START
233
/* Action number for EOF rule of a given start state. */
234
1.29k
#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
235
/* Special action meaning "start processing a new file". */
236
0
#define YY_NEW_FILE slash_yyrestart(yyin ,yyscanner )
237
0
#define YY_END_OF_BUFFER_CHAR 0
238
239
/* Size of default input buffer. */
240
#ifndef YY_BUF_SIZE
241
#ifdef __ia64__
242
/* On IA-64, the buffer size is 16k, not 8k.
243
 * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case.
244
 * Ditto for the __ia64__ case accordingly.
245
 */
246
#define YY_BUF_SIZE 32768
247
#else
248
0
#define YY_BUF_SIZE 16384
249
#endif /* __ia64__ */
250
#endif
251
252
/* The state buf must be large enough to hold one state per character in the main buffer.
253
 */
254
#define YY_STATE_BUF_SIZE   ((YY_BUF_SIZE + 2) * sizeof(yy_state_type))
255
256
#ifndef YY_TYPEDEF_YY_BUFFER_STATE
257
#define YY_TYPEDEF_YY_BUFFER_STATE
258
typedef struct yy_buffer_state *YY_BUFFER_STATE;
259
#endif
260
261
#ifndef YY_TYPEDEF_YY_SIZE_T
262
#define YY_TYPEDEF_YY_SIZE_T
263
typedef size_t yy_size_t;
264
#endif
265
266
0
#define EOB_ACT_CONTINUE_SCAN 0
267
432
#define EOB_ACT_END_OF_FILE 1
268
118
#define EOB_ACT_LAST_MATCH 2
269
    
270
    #define YY_LESS_LINENO(n)
271
    #define YY_LINENO_REWIND_TO(ptr)
272
    
273
/* Return all but the first "n" matched characters back to the input stream. */
274
#define yyless(n) \
275
112
  do \
276
112
    { \
277
112
    /* Undo effects of setting up yytext. */ \
278
112
        int yyless_macro_arg = (n); \
279
112
        YY_LESS_LINENO(yyless_macro_arg);\
280
112
    *yy_cp = yyg->yy_hold_char; \
281
112
    YY_RESTORE_YY_MORE_OFFSET \
282
112
    yyg->yy_c_buf_p = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \
283
112
    YY_DO_BEFORE_ACTION; /* set up yytext again */ \
284
112
    } \
285
112
  while ( 0 )
286
#define unput(c) yyunput( c, yyg->yytext_ptr , yyscanner )
287
288
#ifndef YY_STRUCT_YY_BUFFER_STATE
289
#define YY_STRUCT_YY_BUFFER_STATE
290
struct yy_buffer_state
291
  {
292
  FILE *yy_input_file;
293
294
  char *yy_ch_buf;    /* input buffer */
295
  char *yy_buf_pos;   /* current position in input buffer */
296
297
  /* Size of input buffer in bytes, not including room for EOB
298
   * characters.
299
   */
300
  int yy_buf_size;
301
302
  /* Number of characters read into yy_ch_buf, not including EOB
303
   * characters.
304
   */
305
  int yy_n_chars;
306
307
  /* Whether we "own" the buffer - i.e., we know we created it,
308
   * and can realloc() it to grow it, and should free() it to
309
   * delete it.
310
   */
311
  int yy_is_our_buffer;
312
313
  /* Whether this is an "interactive" input source; if so, and
314
   * if we're using stdio for input, then we want to use getc()
315
   * instead of fread(), to make sure we stop fetching input after
316
   * each newline.
317
   */
318
  int yy_is_interactive;
319
320
  /* Whether we're considered to be at the beginning of a line.
321
   * If so, '^' rules will be active on the next match, otherwise
322
   * not.
323
   */
324
  int yy_at_bol;
325
326
    int yy_bs_lineno; /**< The line count. */
327
    int yy_bs_column; /**< The column count. */
328
329
  /* Whether to try to fill the input buffer when we reach the
330
   * end of it.
331
   */
332
  int yy_fill_buffer;
333
334
  int yy_buffer_status;
335
336
275
#define YY_BUFFER_NEW 0
337
59
#define YY_BUFFER_NORMAL 1
338
  /* When an EOF's been seen but there's still some text to process
339
   * then we mark the buffer as YY_EOF_PENDING, to indicate that we
340
   * shouldn't try reading from the input source any more.  We might
341
   * still have a bunch of tokens to match, though, because of
342
   * possible backing-up.
343
   *
344
   * When we actually see the EOF, we change the status to "new"
345
   * (via slash_yyrestart()), so that the user can continue scanning by
346
   * just pointing yyin at a new input file.
347
   */
348
0
#define YY_BUFFER_EOF_PENDING 2
349
350
  };
351
#endif /* !YY_STRUCT_YY_BUFFER_STATE */
352
353
/* We provide macros for accessing buffer states in case in the
354
 * future we want to put the buffer states in a more general
355
 * "scanner state".
356
 *
357
 * Returns the top of the stack, or NULL.
358
 */
359
278
#define YY_CURRENT_BUFFER ( yyg->yy_buffer_stack \
360
278
                          ? yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] \
361
278
                          : NULL)
362
/* Same as previous macro, but useful when we know that the buffer stack is not
363
 * NULL or when we need an lvalue. For internal use only.
364
 */
365
1.61k
#define YY_CURRENT_BUFFER_LVALUE yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]
366
367
void slash_yyrestart ( FILE *input_file , yyscan_t yyscanner );
368
void slash_yy_switch_to_buffer ( YY_BUFFER_STATE new_buffer , yyscan_t yyscanner );
369
YY_BUFFER_STATE slash_yy_create_buffer ( FILE *file, int size , yyscan_t yyscanner );
370
void slash_yy_delete_buffer ( YY_BUFFER_STATE b , yyscan_t yyscanner );
371
void slash_yy_flush_buffer ( YY_BUFFER_STATE b , yyscan_t yyscanner );
372
void slash_yypush_buffer_state ( YY_BUFFER_STATE new_buffer , yyscan_t yyscanner );
373
void slash_yypop_buffer_state ( yyscan_t yyscanner );
374
375
static void slash_yyensure_buffer_stack ( yyscan_t yyscanner );
376
static void slash_yy_load_buffer_state ( yyscan_t yyscanner );
377
static void slash_yy_init_buffer ( YY_BUFFER_STATE b, FILE *file , yyscan_t yyscanner );
378
#define YY_FLUSH_BUFFER slash_yy_flush_buffer(YY_CURRENT_BUFFER ,yyscanner)
379
380
YY_BUFFER_STATE slash_yy_scan_buffer ( char *base, yy_size_t size , yyscan_t yyscanner );
381
YY_BUFFER_STATE slash_yy_scan_string ( const char *yy_str , yyscan_t yyscanner );
382
YY_BUFFER_STATE slash_yy_scan_bytes ( const char *bytes, int len , yyscan_t yyscanner );
383
384
void *slash_yyalloc ( yy_size_t , yyscan_t yyscanner );
385
void *slash_yyrealloc ( void *, yy_size_t , yyscan_t yyscanner );
386
void slash_yyfree ( void * , yyscan_t yyscanner );
387
388
#define yy_new_buffer slash_yy_create_buffer
389
#define yy_set_interactive(is_interactive) \
390
  { \
391
  if ( ! YY_CURRENT_BUFFER ){ \
392
        slash_yyensure_buffer_stack (yyscanner); \
393
    YY_CURRENT_BUFFER_LVALUE =    \
394
            slash_yy_create_buffer(yyin,YY_BUF_SIZE ,yyscanner); \
395
  } \
396
  YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \
397
  }
398
#define yy_set_bol(at_bol) \
399
  { \
400
  if ( ! YY_CURRENT_BUFFER ){\
401
        slash_yyensure_buffer_stack (yyscanner); \
402
    YY_CURRENT_BUFFER_LVALUE =    \
403
            slash_yy_create_buffer(yyin,YY_BUF_SIZE ,yyscanner); \
404
  } \
405
  YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \
406
  }
407
#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol)
408
409
/* Begin user sect3 */
410
411
216
#define slash_yywrap(yyscanner) (/*CONSTCOND*/1)
412
#define YY_SKIP_YYWRAP
413
typedef flex_uint8_t YY_CHAR;
414
415
typedef int yy_state_type;
416
417
2.50k
#define yytext_ptr yytext_r
418
419
static const flex_int16_t yy_nxt[][22] =
420
    {
421
    {
422
        0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
423
        0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
424
        0,    0
425
    },
426
427
    {
428
       19,   20,   20,   20,   20,   20,   20,   20,   20,   20,
429
       20,   20,   20,   20,   20,   20,   20,   20,   20,   20,
430
       20,   20
431
    },
432
433
    {
434
       19,   20,   20,   20,   20,   20,   20,   20,   20,   20,
435
       20,   20,   20,   20,   20,   20,   20,   20,   20,   20,
436
       20,   20
437
    },
438
439
    {
440
       19,   21,   22,   23,   21,   21,   21,   21,   21,   21,
441
442
       21,   22,   21,   21,   21,   21,   21,   21,   21,   21,
443
       21,   21
444
    },
445
446
    {
447
       19,   21,   22,   23,   21,   21,   21,   21,   21,   21,
448
       21,   22,   21,   21,   21,   21,   21,   21,   21,   21,
449
       21,   21
450
    },
451
452
    {
453
       19,   24,   25,   26,   24,   24,   24,   24,   24,   24,
454
       24,   24,   24,   24,   24,   24,   24,   24,   24,   24,
455
       27,   24
456
    },
457
458
    {
459
       19,   24,   25,   26,   24,   24,   24,   24,   24,   24,
460
       24,   24,   24,   24,   24,   24,   24,   24,   24,   24,
461
462
       27,   24
463
    },
464
465
    {
466
       19,   28,   29,   30,   31,   32,   28,   28,   33,   28,
467
       28,   29,   34,   28,   28,   28,   28,   28,   28,   28,
468
       28,   28
469
    },
470
471
    {
472
       19,   28,   29,   30,   31,   32,   28,   28,   33,   28,
473
       28,   29,   34,   28,   28,   28,   28,   28,   28,   28,
474
       28,   28
475
    },
476
477
    {
478
       19,   35,   35,   35,   35,   36,   35,   35,   35,   35,
479
       35,   37,   35,   35,   35,   35,   35,   35,   35,   35,
480
       35,   35
481
482
    },
483
484
    {
485
       19,   35,   35,   35,   35,   36,   35,   35,   35,   35,
486
       35,   37,   35,   35,   35,   35,   35,   35,   35,   35,
487
       35,   35
488
    },
489
490
    {
491
       19,   38,   38,   38,   38,   38,   38,   38,   39,   38,
492
       38,   38,   40,   38,   38,   38,   38,   38,   38,   38,
493
       38,   38
494
    },
495
496
    {
497
       19,   38,   38,   38,   38,   38,   38,   38,   39,   38,
498
       38,   38,   40,   38,   38,   38,   38,   38,   38,   38,
499
       38,   38
500
    },
501
502
    {
503
       19,   41,   41,   41,   42,   41,   41,   41,   41,   41,
504
505
       41,   41,   41,   41,   41,   41,   41,   41,   41,   41,
506
       41,   41
507
    },
508
509
    {
510
       19,   41,   41,   41,   42,   41,   41,   41,   41,   41,
511
       41,   41,   41,   41,   41,   41,   41,   41,   41,   41,
512
       41,   41
513
    },
514
515
    {
516
       19,   43,   44,   45,   43,   43,   43,   43,   43,   43,
517
       43,   43,   43,   43,   43,   43,   43,   43,   43,   43,
518
       43,   43
519
    },
520
521
    {
522
       19,   43,   44,   45,   43,   43,   43,   43,   43,   43,
523
       43,   43,   43,   43,   43,   43,   43,   43,   43,   43,
524
525
       43,   43
526
    },
527
528
    {
529
       19,   46,   46,   46,   46,   46,   46,   46,   46,   46,
530
       46,   47,   46,   46,   46,   46,   46,   46,   46,   46,
531
       46,   46
532
    },
533
534
    {
535
       19,   46,   46,   46,   46,   46,   46,   46,   46,   46,
536
       46,   47,   46,   46,   46,   46,   46,   46,   46,   46,
537
       46,   46
538
    },
539
540
    {
541
      -19,  -19,  -19,  -19,  -19,  -19,  -19,  -19,  -19,  -19,
542
      -19,  -19,  -19,  -19,  -19,  -19,  -19,  -19,  -19,  -19,
543
      -19,  -19
544
545
    },
546
547
    {
548
       19,  -20,  -20,  -20,  -20,  -20,  -20,  -20,  -20,  -20,
549
      -20,  -20,  -20,  -20,  -20,  -20,  -20,  -20,  -20,  -20,
550
      -20,  -20
551
    },
552
553
    {
554
       19,  -21,  -21,  -21,  -21,  -21,  -21,  -21,  -21,  -21,
555
      -21,  -21,  -21,  -21,  -21,  -21,  -21,  -21,  -21,  -21,
556
      -21,  -21
557
    },
558
559
    {
560
       19,  -22,  -22,  -22,  -22,  -22,  -22,  -22,  -22,  -22,
561
      -22,  -22,  -22,  -22,  -22,  -22,  -22,  -22,  -22,  -22,
562
      -22,  -22
563
    },
564
565
    {
566
       19,  -23,  -23,  -23,  -23,  -23,  -23,  -23,  -23,  -23,
567
568
      -23,  -23,  -23,  -23,  -23,  -23,  -23,  -23,  -23,  -23,
569
      -23,  -23
570
    },
571
572
    {
573
       19,  -24,  -24,  -24,  -24,  -24,  -24,  -24,  -24,  -24,
574
      -24,  -24,  -24,  -24,  -24,  -24,  -24,  -24,  -24,  -24,
575
      -24,  -24
576
    },
577
578
    {
579
       19,  -25,   48,   48,  -25,  -25,  -25,  -25,  -25,  -25,
580
      -25,  -25,  -25,  -25,  -25,  -25,  -25,  -25,  -25,  -25,
581
      -25,  -25
582
    },
583
584
    {
585
       19,  -26,   48,   48,  -26,  -26,  -26,  -26,  -26,  -26,
586
      -26,  -26,  -26,  -26,  -26,  -26,  -26,  -26,  -26,  -26,
587
588
      -26,  -26
589
    },
590
591
    {
592
       19,  -27,  -27,  -27,  -27,  -27,  -27,  -27,  -27,  -27,
593
      -27,  -27,  -27,  -27,  -27,  -27,  -27,  -27,  -27,  -27,
594
      -27,  -27
595
    },
596
597
    {
598
       19,  -28,  -28,  -28,  -28,  -28,  -28,  -28,  -28,  -28,
599
      -28,  -28,  -28,  -28,  -28,  -28,  -28,  -28,  -28,  -28,
600
      -28,  -28
601
    },
602
603
    {
604
       19,  -29,  -29,  -29,  -29,  -29,  -29,  -29,  -29,  -29,
605
      -29,  -29,  -29,  -29,  -29,  -29,  -29,  -29,  -29,  -29,
606
      -29,  -29
607
608
    },
609
610
    {
611
       19,  -30,  -30,  -30,  -30,  -30,  -30,  -30,  -30,  -30,
612
      -30,  -30,  -30,  -30,  -30,  -30,  -30,  -30,  -30,  -30,
613
      -30,  -30
614
    },
615
616
    {
617
       19,  -31,  -31,  -31,  -31,  -31,  -31,  -31,  -31,  -31,
618
      -31,  -31,  -31,  -31,  -31,  -31,  -31,  -31,  -31,  -31,
619
      -31,  -31
620
    },
621
622
    {
623
       19,  -32,  -32,  -32,  -32,  -32,  -32,  -32,  -32,  -32,
624
      -32,  -32,  -32,  -32,  -32,  -32,  -32,  -32,  -32,  -32,
625
      -32,  -32
626
    },
627
628
    {
629
       19,  -33,  -33,  -33,   49,   50,   51,   51,  -33,  -33,
630
631
       51,  -33,  -33,   51,   51,   51,   51,   51,   51,   52,
632
      -33,  -33
633
    },
634
635
    {
636
       19,  -34,  -34,  -34,  -34,  -34,  -34,  -34,  -34,  -34,
637
      -34,  -34,  -34,  -34,  -34,  -34,  -34,  -34,  -34,  -34,
638
      -34,  -34
639
    },
640
641
    {
642
       19,  -35,  -35,  -35,  -35,  -35,  -35,  -35,  -35,  -35,
643
      -35,  -35,  -35,  -35,  -35,  -35,  -35,  -35,  -35,  -35,
644
      -35,  -35
645
    },
646
647
    {
648
       19,  -36,  -36,  -36,  -36,   53,  -36,  -36,  -36,  -36,
649
      -36,  -36,  -36,  -36,  -36,  -36,  -36,  -36,  -36,  -36,
650
651
      -36,  -36
652
    },
653
654
    {
655
       19,   54,   54,  -37,   54,   54,   55,   54,   54,   54,
656
       54,   54,   54,   56,   57,   58,   59,   60,   61,   54,
657
       54,   54
658
    },
659
660
    {
661
       19,  -38,  -38,  -38,  -38,  -38,  -38,  -38,  -38,  -38,
662
      -38,  -38,  -38,  -38,  -38,  -38,  -38,  -38,  -38,  -38,
663
      -38,  -38
664
    },
665
666
    {
667
       19,  -39,  -39,  -39,  -39,   62,   63,   63,  -39,  -39,
668
       63,  -39,  -39,   63,   63,   63,   63,   63,   63,  -39,
669
      -39,  -39
670
671
    },
672
673
    {
674
       19,  -40,  -40,  -40,  -40,  -40,  -40,  -40,  -40,  -40,
675
      -40,  -40,  -40,  -40,  -40,  -40,  -40,  -40,  -40,  -40,
676
      -40,  -40
677
    },
678
679
    {
680
       19,  -41,  -41,  -41,  -41,  -41,  -41,  -41,  -41,  -41,
681
      -41,  -41,  -41,  -41,  -41,  -41,  -41,  -41,  -41,  -41,
682
      -41,  -41
683
    },
684
685
    {
686
       19,  -42,  -42,  -42,  -42,  -42,  -42,  -42,  -42,  -42,
687
      -42,  -42,  -42,  -42,  -42,  -42,  -42,  -42,  -42,  -42,
688
      -42,  -42
689
    },
690
691
    {
692
       19,  -43,  -43,  -43,  -43,  -43,  -43,  -43,  -43,  -43,
693
694
      -43,  -43,  -43,  -43,  -43,  -43,  -43,  -43,  -43,  -43,
695
      -43,  -43
696
    },
697
698
    {
699
       19,  -44,   64,   64,  -44,  -44,  -44,  -44,  -44,  -44,
700
      -44,  -44,  -44,  -44,  -44,  -44,  -44,  -44,  -44,  -44,
701
      -44,  -44
702
    },
703
704
    {
705
       19,  -45,   64,   64,  -45,  -45,  -45,  -45,  -45,  -45,
706
      -45,  -45,  -45,  -45,  -45,  -45,  -45,  -45,  -45,  -45,
707
      -45,  -45
708
    },
709
710
    {
711
       19,  -46,  -46,  -46,  -46,  -46,  -46,  -46,  -46,  -46,
712
      -46,  -46,  -46,  -46,  -46,  -46,  -46,  -46,  -46,  -46,
713
714
      -46,  -46
715
    },
716
717
    {
718
       19,  -47,  -47,  -47,  -47,  -47,  -47,  -47,  -47,  -47,
719
      -47,   65,  -47,  -47,  -47,  -47,  -47,  -47,  -47,  -47,
720
      -47,  -47
721
    },
722
723
    {
724
       19,  -48,   48,   48,  -48,  -48,  -48,  -48,  -48,  -48,
725
      -48,  -48,  -48,  -48,  -48,  -48,  -48,  -48,  -48,  -48,
726
      -48,  -48
727
    },
728
729
    {
730
       19,  -49,  -49,  -49,  -49,  -49,   66,   66,  -49,  -49,
731
       66,  -49,  -49,   66,   66,   66,   66,   66,   66,  -49,
732
      -49,  -49
733
734
    },
735
736
    {
737
       19,  -50,  -50,  -50,  -50,  -50,   67,   67,  -50,  -50,
738
       67,  -50,  -50,   67,   67,   67,   67,   67,   67,  -50,
739
      -50,  -50
740
    },
741
742
    {
743
       19,  -51,  -51,  -51,  -51,  -51,   51,   51,  -51,  -51,
744
       51,  -51,  -51,   51,   51,   51,   51,   51,   51,  -51,
745
      -51,  -51
746
    },
747
748
    {
749
       19,  -52,  -52,  -52,  -52,  -52,  -52,  -52,  -52,   68,
750
      -52,  -52,  -52,  -52,  -52,  -52,  -52,  -52,  -52,  -52,
751
      -52,  -52
752
    },
753
754
    {
755
       19,  -53,  -53,  -53,  -53,  -53,  -53,  -53,  -53,  -53,
756
757
      -53,  -53,  -53,  -53,  -53,  -53,  -53,  -53,  -53,  -53,
758
      -53,  -53
759
    },
760
761
    {
762
       19,  -54,  -54,  -54,  -54,  -54,  -54,  -54,  -54,  -54,
763
      -54,  -54,  -54,  -54,  -54,  -54,  -54,  -54,  -54,  -54,
764
      -54,  -54
765
    },
766
767
    {
768
       19,  -55,  -55,  -55,  -55,  -55,   69,  -55,  -55,  -55,
769
      -55,  -55,  -55,  -55,  -55,  -55,  -55,  -55,  -55,  -55,
770
      -55,  -55
771
    },
772
773
    {
774
       19,  -56,  -56,  -56,  -56,  -56,  -56,  -56,  -56,  -56,
775
      -56,  -56,  -56,  -56,  -56,  -56,  -56,  -56,  -56,  -56,
776
777
      -56,  -56
778
    },
779
780
    {
781
       19,  -57,  -57,  -57,  -57,  -57,  -57,  -57,  -57,  -57,
782
      -57,  -57,  -57,  -57,  -57,  -57,  -57,  -57,  -57,  -57,
783
      -57,  -57
784
    },
785
786
    {
787
       19,  -58,  -58,  -58,  -58,  -58,  -58,  -58,  -58,  -58,
788
      -58,  -58,  -58,  -58,  -58,  -58,  -58,  -58,  -58,  -58,
789
      -58,  -58
790
    },
791
792
    {
793
       19,  -59,  -59,  -59,  -59,  -59,  -59,  -59,  -59,  -59,
794
      -59,  -59,  -59,  -59,  -59,  -59,  -59,  -59,  -59,  -59,
795
      -59,  -59
796
797
    },
798
799
    {
800
       19,  -60,  -60,  -60,  -60,  -60,  -60,  -60,  -60,  -60,
801
      -60,  -60,  -60,  -60,  -60,  -60,  -60,  -60,  -60,  -60,
802
      -60,  -60
803
    },
804
805
    {
806
       19,  -61,  -61,  -61,  -61,  -61,   70,   70,  -61,  -61,
807
      -61,  -61,  -61,   70,   70,  -61,  -61,  -61,  -61,  -61,
808
      -61,  -61
809
    },
810
811
    {
812
       19,  -62,  -62,  -62,  -62,  -62,   71,   71,  -62,  -62,
813
       71,  -62,  -62,   71,   71,   71,   71,   71,   71,  -62,
814
      -62,  -62
815
    },
816
817
    {
818
       19,  -63,  -63,  -63,  -63,  -63,   63,   63,  -63,  -63,
819
820
       63,  -63,  -63,   63,   63,   63,   63,   63,   63,  -63,
821
      -63,  -63
822
    },
823
824
    {
825
       19,  -64,   64,   64,  -64,  -64,  -64,  -64,  -64,  -64,
826
      -64,  -64,  -64,  -64,  -64,  -64,  -64,  -64,  -64,  -64,
827
      -64,  -64
828
    },
829
830
    {
831
       19,  -65,  -65,  -65,  -65,  -65,  -65,  -65,  -65,  -65,
832
      -65,  -65,  -65,  -65,  -65,  -65,  -65,  -65,  -65,  -65,
833
      -65,  -65
834
    },
835
836
    {
837
       19,  -66,  -66,  -66,   72,  -66,   66,   66,  -66,  -66,
838
       66,  -66,  -66,   66,   66,   66,   66,   66,   66,  -66,
839
840
      -66,  -66
841
    },
842
843
    {
844
       19,  -67,  -67,  -67,  -67,   73,   67,   67,  -67,  -67,
845
       67,  -67,  -67,   67,   67,   67,   67,   67,   67,  -67,
846
      -67,  -67
847
    },
848
849
    {
850
       19,  -68,  -68,  -68,  -68,  -68,   74,   74,  -68,  -68,
851
       74,  -68,  -68,   74,   74,   74,   74,   74,   74,  -68,
852
      -68,  -68
853
    },
854
855
    {
856
       19,  -69,  -69,  -69,  -69,  -69,   75,  -69,  -69,  -69,
857
      -69,  -69,  -69,  -69,  -69,  -69,  -69,  -69,  -69,  -69,
858
      -69,  -69
859
860
    },
861
862
    {
863
       19,  -70,  -70,  -70,  -70,  -70,   76,   76,  -70,  -70,
864
      -70,  -70,  -70,   76,   76,  -70,  -70,  -70,  -70,  -70,
865
      -70,  -70
866
    },
867
868
    {
869
       19,  -71,  -71,  -71,  -71,   77,   71,   71,  -71,  -71,
870
       71,  -71,  -71,   71,   71,   71,   71,   71,   71,  -71,
871
      -71,  -71
872
    },
873
874
    {
875
       19,  -72,  -72,  -72,  -72,  -72,  -72,  -72,  -72,  -72,
876
      -72,  -72,  -72,  -72,  -72,  -72,  -72,  -72,  -72,  -72,
877
      -72,  -72
878
    },
879
880
    {
881
       19,  -73,  -73,  -73,  -73,  -73,  -73,  -73,  -73,  -73,
882
883
      -73,  -73,  -73,  -73,  -73,  -73,  -73,  -73,  -73,  -73,
884
      -73,  -73
885
    },
886
887
    {
888
       19,  -74,  -74,  -74,  -74,  -74,   74,   74,  -74,  -74,
889
       74,  -74,  -74,   74,   74,   74,   74,   74,   74,  -74,
890
      -74,   78
891
    },
892
893
    {
894
       19,  -75,  -75,  -75,  -75,  -75,  -75,  -75,  -75,  -75,
895
      -75,  -75,  -75,  -75,  -75,  -75,  -75,  -75,  -75,  -75,
896
      -75,  -75
897
    },
898
899
    {
900
       19,  -76,  -76,  -76,  -76,  -76,  -76,  -76,  -76,  -76,
901
      -76,  -76,  -76,  -76,  -76,  -76,  -76,  -76,  -76,  -76,
902
903
      -76,  -76
904
    },
905
906
    {
907
       19,  -77,  -77,  -77,  -77,  -77,  -77,  -77,  -77,  -77,
908
      -77,  -77,  -77,  -77,  -77,  -77,  -77,  -77,  -77,  -77,
909
      -77,  -77
910
    },
911
912
    {
913
       19,  -78,  -78,  -78,  -78,  -78,  -78,  -78,  -78,  -78,
914
      -78,  -78,  -78,  -78,  -78,  -78,  -78,  -78,  -78,  -78,
915
      -78,  -78
916
    },
917
918
    } ;
919
920
static yy_state_type yy_get_previous_state ( yyscan_t yyscanner );
921
static yy_state_type yy_try_NUL_trans ( yy_state_type current_state  , yyscan_t yyscanner);
922
static int yy_get_next_buffer ( yyscan_t yyscanner );
923
static void yynoreturn yy_fatal_error ( const char* msg , yyscan_t yyscanner );
924
925
/* Done after the current pattern has been matched and before the
926
 * corresponding action - sets up yytext.
927
 */
928
#define YY_DO_BEFORE_ACTION \
929
1.34k
  yyg->yytext_ptr = yy_bp; \
930
1.34k
  yyleng = (int) (yy_cp - yy_bp); \
931
1.34k
  yyg->yy_hold_char = *yy_cp; \
932
1.34k
  *yy_cp = '\0'; \
933
1.34k
  yyg->yy_c_buf_p = yy_cp;
934
#define YY_NUM_RULES 42
935
1.56k
#define YY_END_OF_BUFFER 43
936
/* This struct is not used in this scanner,
937
   but its presence is necessary. */
938
struct yy_trans_info
939
  {
940
  flex_int32_t yy_verify;
941
  flex_int32_t yy_nxt;
942
  };
943
static const flex_int16_t yy_accept[79] =
944
    {   0,
945
        0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
946
        0,    0,    0,    0,    0,    0,    0,    0,   43,    1,
947
        3,    2,    2,    6,    4,    4,    5,   19,    7,    7,
948
       10,    8,   19,    9,   30,   20,   30,   35,   35,   31,
949
       37,   36,   39,   38,   38,   41,   41,    4,   16,   15,
950
       11,   18,   21,   29,   27,   24,   26,   22,   25,   23,
951
       29,   34,   32,   38,   40,   16,   15,   17,   27,   28,
952
       34,   13,   12,   17,   27,   28,   33,   14
953
    } ;
954
955
static const YY_CHAR yy_ec[256] =
956
    {   0,
957
        1,    1,    1,    1,    1,    1,    1,    1,    2,    3,
958
        1,    2,    2,    1,    1,    1,    1,    1,    1,    1,
959
        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
960
        1,    2,    1,    4,    1,    1,    1,    1,    5,    1,
961
        1,    1,    1,    1,    1,    1,    1,    6,    6,    6,
962
        6,    6,    6,    6,    6,    7,    7,    8,    1,    1,
963
        1,    1,    9,    1,    7,    7,    7,    7,    7,    7,
964
       10,   10,   10,   10,   10,   10,   10,   10,   10,   10,
965
       10,   10,   10,   10,   10,   10,   10,   10,   10,   10,
966
        1,   11,    1,    1,   10,   12,    7,   13,    7,    7,
967
968
        7,   14,   10,   10,   10,   10,   10,   10,   10,   15,
969
       10,   10,   10,   16,   10,   17,   10,   10,   10,   18,
970
       10,   10,   19,   20,   21,    1,    1,   10,   10,   10,
971
       10,   10,   10,   10,   10,   10,   10,   10,   10,   10,
972
       10,   10,   10,   10,   10,   10,   10,   10,   10,   10,
973
       10,   10,   10,   10,   10,   10,   10,   10,   10,   10,
974
       10,   10,   10,   10,   10,   10,   10,   10,   10,   10,
975
       10,   10,   10,   10,   10,   10,   10,   10,   10,   10,
976
       10,   10,   10,   10,   10,   10,   10,   10,   10,   10,
977
       10,   10,   10,   10,   10,   10,   10,   10,   10,   10,
978
979
       10,   10,   10,   10,   10,   10,   10,   10,   10,   10,
980
       10,   10,   10,   10,   10,   10,   10,   10,   10,   10,
981
       10,   10,   10,   10,   10,   10,   10,   10,   10,   10,
982
       10,   10,   10,   10,   10,   10,   10,   10,   10,   10,
983
       10,   10,   10,   10,   10,   10,   10,   10,   10,   10,
984
       10,   10,   10,   10,   10
985
    } ;
986
987
/* The intent behind this definition is that it'll catch
988
 * any uses of REJECT which flex missed.
989
 */
990
#define REJECT reject_used_but_not_detected
991
#define yymore() yymore_used_but_not_detected
992
721
#define YY_MORE_ADJ 0
993
#define YY_RESTORE_YY_MORE_OFFSET
994
#line 1 "psqlscanslash.l"
995
996
#line 28 "psqlscanslash.l"
997
#include "fe_utils/psqlscan_int.h"
998
999
55
#define PQmblenBounded(s, e)  strnlen(s, PQmblen(s, e))
1000
1001
/*
1002
 * We must have a typedef YYSTYPE for yylex's first argument, but this lexer
1003
 * doesn't presently make use of that argument, so just declare it as int.
1004
 */
1005
typedef int YYSTYPE;
1006
1007
/*
1008
 * Set the type of yyextra; we use it as a pointer back to the containing
1009
 * PsqlScanState.
1010
 */
1011
#define YY_EXTRA_TYPE PsqlScanState
1012
1013
/*
1014
 * These variables do not need to be saved across calls.  Yeah, it's a bit
1015
 * of a hack, but putting them into PsqlScanStateData would be klugy too.
1016
 */
1017
static enum slash_option_type option_type;
1018
static char *option_quote;
1019
static int  unquoted_option_chars;
1020
static int  backtick_start_offset;
1021
1022
1023
/* Return values from yylex() */
1024
216
#define LEXRES_EOL      0  /* end of input */
1025
62
#define LEXRES_OK     1  /* OK completion of backslash argument */
1026
1027
1028
static void evaluate_backtick(PsqlScanState state);
1029
1030
790
#define ECHO psqlscan_emit(cur_state, yytext, yyleng)
1031
1032
/*
1033
 * Work around a bug in flex 2.5.35: it emits a couple of functions that
1034
 * it forgets to emit declarations for.  Since we use -Wmissing-prototypes,
1035
 * this would cause warnings.  Providing our own declarations should be
1036
 * harmless even when the bug gets fixed.
1037
 */
1038
extern int  slash_yyget_column(yyscan_t yyscanner);
1039
extern void slash_yyset_column(int column_no, yyscan_t yyscanner);
1040
1041
/* LCOV_EXCL_START */
1042
1043
#line 1043 "psqlscanslash.c"
1044
/* Except for the prefix, these options should match psqlscan.l */
1045
#define YY_NO_INPUT 1
1046
/*
1047
 * OK, here is a short description of lex/flex rules behavior.
1048
 * The longest pattern which matches an input string is always chosen.
1049
 * For equal-length patterns, the first occurring in the rules list is chosen.
1050
 * INITIAL is the starting state, to which all non-conditional rules apply.
1051
 * Exclusive states change parsing rules while the state is active.  When in
1052
 * an exclusive state, only those rules defined for that state apply.
1053
 */
1054
/* Exclusive states for lexing backslash commands */
1055
1056
/*
1057
 * Assorted character class definitions that should match psqlscan.l.
1058
 */
1059
#line 1059 "psqlscanslash.c"
1060
1061
#define INITIAL 0
1062
60
#define xslashcmd 1
1063
245
#define xslashargstart 2
1064
102
#define xslasharg 3
1065
0
#define xslashquote 4
1066
0
#define xslashbackquote 5
1067
0
#define xslashdquote 6
1068
20
#define xslashwholeline 7
1069
60
#define xslashend 8
1070
1071
#ifndef YY_NO_UNISTD_H
1072
/* Special case for "unistd.h", since it is non-ANSI. We include it way
1073
 * down here because we want the user's section 1 to have been scanned first.
1074
 * The user has a chance to override it with an option.
1075
 */
1076
#include <unistd.h>
1077
#endif
1078
1079
#ifndef YY_EXTRA_TYPE
1080
#define YY_EXTRA_TYPE void *
1081
#endif
1082
1083
/* Holds the entire state of the reentrant scanner. */
1084
struct yyguts_t
1085
    {
1086
1087
    /* User-defined. Not touched by flex. */
1088
    YY_EXTRA_TYPE yyextra_r;
1089
1090
    /* The rest are the same as the globals declared in the non-reentrant scanner. */
1091
    FILE *yyin_r, *yyout_r;
1092
    size_t yy_buffer_stack_top; /**< index of top of stack. */
1093
    size_t yy_buffer_stack_max; /**< capacity of stack. */
1094
    YY_BUFFER_STATE * yy_buffer_stack; /**< Stack as an array. */
1095
    char yy_hold_char;
1096
    int yy_n_chars;
1097
    int yyleng_r;
1098
    char *yy_c_buf_p;
1099
    int yy_init;
1100
    int yy_start;
1101
    int yy_did_buffer_switch_on_eof;
1102
    int yy_start_stack_ptr;
1103
    int yy_start_stack_depth;
1104
    int *yy_start_stack;
1105
    yy_state_type yy_last_accepting_state;
1106
    char* yy_last_accepting_cpos;
1107
1108
    int yylineno_r;
1109
    int yy_flex_debug_r;
1110
1111
    char *yytext_r;
1112
    int yy_more_flag;
1113
    int yy_more_len;
1114
1115
    YYSTYPE * yylval_r;
1116
1117
    }; /* end struct yyguts_t */
1118
1119
static int yy_init_globals ( yyscan_t yyscanner );
1120
1121
    /* This must go here because YYSTYPE and YYLTYPE are included
1122
     * from bison output in section 1.*/
1123
278
    #    define yylval yyg->yylval_r
1124
    
1125
int slash_yylex_init (yyscan_t* scanner);
1126
1127
int slash_yylex_init_extra ( YY_EXTRA_TYPE user_defined, yyscan_t* scanner);
1128
1129
/* Accessor methods to globals.
1130
   These are made visible to non-reentrant scanners for convenience. */
1131
1132
int slash_yylex_destroy ( yyscan_t yyscanner );
1133
1134
int slash_yyget_debug ( yyscan_t yyscanner );
1135
1136
void slash_yyset_debug ( int debug_flag , yyscan_t yyscanner );
1137
1138
YY_EXTRA_TYPE slash_yyget_extra ( yyscan_t yyscanner );
1139
1140
void slash_yyset_extra ( YY_EXTRA_TYPE user_defined , yyscan_t yyscanner );
1141
1142
FILE *slash_yyget_in ( yyscan_t yyscanner );
1143
1144
void slash_yyset_in  ( FILE * _in_str , yyscan_t yyscanner );
1145
1146
FILE *slash_yyget_out ( yyscan_t yyscanner );
1147
1148
void slash_yyset_out  ( FILE * _out_str , yyscan_t yyscanner );
1149
1150
      int slash_yyget_leng ( yyscan_t yyscanner );
1151
1152
char *slash_yyget_text ( yyscan_t yyscanner );
1153
1154
int slash_yyget_lineno ( yyscan_t yyscanner );
1155
1156
void slash_yyset_lineno ( int _line_number , yyscan_t yyscanner );
1157
1158
int slash_yyget_column  ( yyscan_t yyscanner );
1159
1160
void slash_yyset_column ( int _column_no , yyscan_t yyscanner );
1161
1162
YYSTYPE * slash_yyget_lval ( yyscan_t yyscanner );
1163
1164
void slash_yyset_lval ( YYSTYPE * yylval_param , yyscan_t yyscanner );
1165
1166
/* Macros after this point can all be overridden by user definitions in
1167
 * section 1.
1168
 */
1169
1170
#ifndef YY_SKIP_YYWRAP
1171
#ifdef __cplusplus
1172
extern "C" int slash_yywrap ( yyscan_t yyscanner );
1173
#else
1174
extern int slash_yywrap ( yyscan_t yyscanner );
1175
#endif
1176
#endif
1177
1178
#ifndef YY_NO_UNPUT
1179
    
1180
#endif
1181
1182
#ifndef yytext_ptr
1183
static void yy_flex_strncpy ( char *, const char *, int , yyscan_t yyscanner);
1184
#endif
1185
1186
#ifdef YY_NEED_STRLEN
1187
static int yy_flex_strlen ( const char * , yyscan_t yyscanner);
1188
#endif
1189
1190
#ifndef YY_NO_INPUT
1191
#ifdef __cplusplus
1192
static int yyinput ( yyscan_t yyscanner );
1193
#else
1194
static int input ( yyscan_t yyscanner );
1195
#endif
1196
1197
#endif
1198
1199
/* Amount of stuff to slurp up with each read. */
1200
#ifndef YY_READ_BUF_SIZE
1201
#ifdef __ia64__
1202
/* On IA-64, the buffer size is 16k, not 8k */
1203
#define YY_READ_BUF_SIZE 16384
1204
#else
1205
0
#define YY_READ_BUF_SIZE 8192
1206
#endif /* __ia64__ */
1207
#endif
1208
1209
/* Copy whatever the last rule matched to the standard output. */
1210
#ifndef ECHO
1211
/* This used to be an fputs(), but since the string might contain NUL's,
1212
 * we now use fwrite().
1213
 */
1214
#define ECHO do { if (fwrite( yytext, (size_t) yyleng, 1, yyout )) {} } while (0)
1215
#endif
1216
1217
/* Gets input and stuffs it into "buf".  number of characters read, or YY_NULL,
1218
 * is returned in "result".
1219
 */
1220
#ifndef YY_INPUT
1221
#define YY_INPUT(buf,result,max_size) \
1222
0
  if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
1223
0
    { \
1224
0
    int c = '*'; \
1225
0
    int n; \
1226
0
    for ( n = 0; n < max_size && \
1227
0
           (c = getc( yyin )) != EOF && c != '\n'; ++n ) \
1228
0
      buf[n] = (char) c; \
1229
0
    if ( c == '\n' ) \
1230
0
      buf[n++] = (char) c; \
1231
0
    if ( c == EOF && ferror( yyin ) ) \
1232
0
      YY_FATAL_ERROR( "input in flex scanner failed" ); \
1233
0
    result = n; \
1234
0
    } \
1235
0
  else \
1236
0
    { \
1237
0
    errno=0; \
1238
0
    while ( (result = (int) fread(buf, 1, (yy_size_t) max_size, yyin)) == 0 && ferror(yyin)) \
1239
0
      { \
1240
0
      if( errno != EINTR) \
1241
0
        { \
1242
0
        YY_FATAL_ERROR( "input in flex scanner failed" ); \
1243
0
        break; \
1244
0
        } \
1245
0
      errno=0; \
1246
0
      clearerr(yyin); \
1247
0
      } \
1248
0
    }\
1249
\
1250
1251
#endif
1252
1253
/* No semi-colon after return; correct usage is to write "yyterminate();" -
1254
 * we don't want an extra ';' after the "return" because that will cause
1255
 * some compilers to complain about unreachable statements.
1256
 */
1257
#ifndef yyterminate
1258
#define yyterminate() return YY_NULL
1259
#endif
1260
1261
/* Number of entries by which start-condition stack grows. */
1262
#ifndef YY_START_STACK_INCR
1263
#define YY_START_STACK_INCR 25
1264
#endif
1265
1266
/* Report a fatal error. */
1267
#ifndef YY_FATAL_ERROR
1268
0
#define YY_FATAL_ERROR(msg) yy_fatal_error( msg , yyscanner)
1269
#endif
1270
1271
/* end tables serialization structures and prototypes */
1272
1273
/* Default declaration of generated scanner - a define so the user can
1274
 * easily add parameters.
1275
 */
1276
#ifndef YY_DECL
1277
#define YY_DECL_IS_OURS 1
1278
1279
extern int slash_yylex \
1280
               (YYSTYPE * yylval_param , yyscan_t yyscanner);
1281
1282
#define YY_DECL int slash_yylex \
1283
               (YYSTYPE * yylval_param , yyscan_t yyscanner)
1284
#endif /* !YY_DECL */
1285
1286
/* Code executed at the beginning of each rule, after yytext and yyleng
1287
 * have been set up.
1288
 */
1289
#ifndef YY_USER_ACTION
1290
#define YY_USER_ACTION
1291
#endif
1292
1293
/* Code executed at the end of each rule. */
1294
#ifndef YY_BREAK
1295
900
#define YY_BREAK /*LINTED*/break;
1296
#endif
1297
1298
#define YY_RULE_SETUP \
1299
  YY_USER_ACTION
1300
1301
/** The main scanner function which does all the work.
1302
 */
1303
YY_DECL
1304
278
{
1305
278
  yy_state_type yy_current_state;
1306
278
  char *yy_cp, *yy_bp;
1307
278
  int yy_act;
1308
278
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1309
1310
278
    yylval = yylval_param;
1311
1312
278
  if ( !yyg->yy_init )
1313
0
    {
1314
0
    yyg->yy_init = 1;
1315
1316
#ifdef YY_USER_INIT
1317
    YY_USER_INIT;
1318
#endif
1319
1320
0
    if ( ! yyg->yy_start )
1321
0
      yyg->yy_start = 1; /* first start state */
1322
1323
0
    if ( ! yyin )
1324
0
      yyin = stdin;
1325
1326
0
    if ( ! yyout )
1327
0
      yyout = stdout;
1328
1329
0
    if ( ! YY_CURRENT_BUFFER ) {
1330
0
      slash_yyensure_buffer_stack (yyscanner);
1331
0
      YY_CURRENT_BUFFER_LVALUE =
1332
0
        slash_yy_create_buffer(yyin,YY_BUF_SIZE ,yyscanner);
1333
0
    }
1334
1335
0
    slash_yy_load_buffer_state(yyscanner );
1336
0
    }
1337
1338
278
  {
1339
278
#line 120 "psqlscanslash.l"
1340
1341
1342
1343
278
#line 124 "psqlscanslash.l"
1344
    /* Declare some local variables inside yylex(), for convenience */
1345
278
    PsqlScanState cur_state = yyextra;
1346
278
    PQExpBuffer output_buf = cur_state->output_buf;
1347
1348
    /*
1349
     * Force flex into the state indicated by start_state.  This has a
1350
     * couple of purposes: it lets some of the functions below set a new
1351
     * starting state without ugly direct access to flex variables, and it
1352
     * allows us to transition from one flex lexer to another so that we
1353
     * can lex different parts of the source string using separate lexers.
1354
     */
1355
278
    BEGIN(cur_state->start_state);
1356
1357
1358
  /*
1359
   * We don't really expect to be invoked in the INITIAL state in this
1360
   * lexer; but if we are, just spit data to the output_buf until EOF.
1361
   */
1362
1363
278
#line 1363 "psqlscanslash.c"
1364
1365
1.17k
  while ( /*CONSTCOND*/1 )    /* loops until end-of-file is reached */
1366
1.17k
    {
1367
1.17k
    yy_cp = yyg->yy_c_buf_p;
1368
1369
    /* Support of yytext. */
1370
1.17k
    *yy_cp = yyg->yy_hold_char;
1371
1372
    /* yy_bp points to the position in yy_ch_buf of the start of
1373
     * the current run.
1374
     */
1375
1.17k
    yy_bp = yy_cp;
1376
1377
1.17k
    yy_current_state = yyg->yy_start;
1378
1.17k
yy_match:
1379
2.41k
    while ( (yy_current_state = yy_nxt[yy_current_state][ yy_ec[YY_SC_TO_UI(*yy_cp)]  ]) > 0 )
1380
1.23k
      ++yy_cp;
1381
1382
1.17k
    yy_current_state = -yy_current_state;
1383
1384
1.23k
yy_find_action:
1385
1.23k
    yy_act = yy_accept[yy_current_state];
1386
1387
1.23k
    YY_DO_BEFORE_ACTION;
1388
1389
1.45k
do_action:  /* This label is used only to access EOF actions. */
1390
1391
1.45k
    switch ( yy_act )
1392
1.45k
  { /* beginning of action switch */
1393
0
case 1:
1394
/* rule 1 can match eol */
1395
0
YY_RULE_SETUP
1396
0
#line 143 "psqlscanslash.l"
1397
0
{ ECHO; }
1398
0
  YY_BREAK
1399
/*
1400
   * Exclusive lexer states to handle backslash command lexing
1401
   */
1402
1403
/* command name ends at whitespace or backslash; eat all else */
1404
52
case 2:
1405
/* rule 2 can match eol */
1406
52
YY_RULE_SETUP
1407
52
#line 152 "psqlscanslash.l"
1408
52
{
1409
52
          yyless(0);
1410
52
          cur_state->start_state = YY_START;
1411
52
          return LEXRES_OK;
1412
0
        }
1413
0
  YY_BREAK
1414
143
case 3:
1415
143
YY_RULE_SETUP
1416
143
#line 158 "psqlscanslash.l"
1417
143
{ ECHO; }
1418
143
  YY_BREAK
1419
1420
1421
/*
1422
   * Discard any whitespace before argument, then go to xslasharg state.
1423
   * An exception is that "|" is only special at start of argument, so we
1424
   * check for it here.
1425
   */
1426
50
case 4:
1427
/* rule 4 can match eol */
1428
50
YY_RULE_SETUP
1429
50
#line 169 "psqlscanslash.l"
1430
50
{ }
1431
50
  YY_BREAK
1432
0
case 5:
1433
0
YY_RULE_SETUP
1434
0
#line 171 "psqlscanslash.l"
1435
0
{
1436
0
          if (option_type == OT_FILEPIPE)
1437
0
          {
1438
            /* treat like whole-string case */
1439
0
            ECHO;
1440
0
            BEGIN(xslashwholeline);
1441
0
          }
1442
0
          else
1443
0
          {
1444
            /* vertical bar is not special otherwise */
1445
0
            yyless(0);
1446
0
            BEGIN(xslasharg);
1447
0
          }
1448
0
        }
1449
0
  YY_BREAK
1450
51
case 6:
1451
51
YY_RULE_SETUP
1452
51
#line 186 "psqlscanslash.l"
1453
51
{
1454
51
          yyless(0);
1455
51
          BEGIN(xslasharg);
1456
51
        }
1457
51
  YY_BREAK
1458
1459
1460
/*
1461
   * Default processing of text in a slash command's argument.
1462
   *
1463
   * Note: unquoted_option_chars counts the number of characters at the
1464
   * end of the argument that were not subject to any form of quoting.
1465
   * psql_scan_slash_option needs this to strip trailing semicolons safely.
1466
   */
1467
9
case 7:
1468
/* rule 7 can match eol */
1469
9
YY_RULE_SETUP
1470
9
#line 202 "psqlscanslash.l"
1471
9
{
1472
          /*
1473
           * Unquoted space is end of arg; do not eat.  Likewise
1474
           * backslash is end of command or next command, do not eat
1475
           *
1476
           * XXX this means we can't conveniently accept options
1477
           * that include unquoted backslashes; therefore, option
1478
           * processing that encourages use of backslashes is rather
1479
           * broken.
1480
           */
1481
9
          yyless(0);
1482
9
          cur_state->start_state = YY_START;
1483
9
          return LEXRES_OK;
1484
0
        }
1485
0
  YY_BREAK
1486
0
case 8:
1487
0
YY_RULE_SETUP
1488
0
#line 217 "psqlscanslash.l"
1489
0
{
1490
0
          *option_quote = '\'';
1491
0
          unquoted_option_chars = 0;
1492
0
          BEGIN(xslashquote);
1493
0
        }
1494
0
  YY_BREAK
1495
0
case 9:
1496
0
YY_RULE_SETUP
1497
0
#line 223 "psqlscanslash.l"
1498
0
{
1499
0
          backtick_start_offset = output_buf->len;
1500
0
          *option_quote = '`';
1501
0
          unquoted_option_chars = 0;
1502
0
          BEGIN(xslashbackquote);
1503
0
        }
1504
0
  YY_BREAK
1505
0
case 10:
1506
0
YY_RULE_SETUP
1507
0
#line 230 "psqlscanslash.l"
1508
0
{
1509
0
          ECHO;
1510
0
          *option_quote = '"';
1511
0
          unquoted_option_chars = 0;
1512
0
          BEGIN(xslashdquote);
1513
0
        }
1514
0
  YY_BREAK
1515
0
case 11:
1516
0
YY_RULE_SETUP
1517
0
#line 237 "psqlscanslash.l"
1518
0
{
1519
          /* Possible psql variable substitution */
1520
0
          if (cur_state->callbacks->get_variable == NULL)
1521
0
            ECHO;
1522
0
          else
1523
0
          {
1524
0
            char     *varname;
1525
0
            char     *value;
1526
1527
0
            varname = psqlscan_extract_substring(cur_state,
1528
0
                               yytext + 1,
1529
0
                               yyleng - 1);
1530
0
            value = cur_state->callbacks->get_variable(varname,
1531
0
                                   PQUOTE_PLAIN,
1532
0
                                   cur_state->cb_passthrough);
1533
0
            free(varname);
1534
1535
            /*
1536
             * The variable value is just emitted without any
1537
             * further examination.  This is consistent with the
1538
             * pre-8.0 code behavior, if not with the way that
1539
             * variables are handled outside backslash commands.
1540
             * Note that we needn't guard against recursion here.
1541
             */
1542
0
            if (value)
1543
0
            {
1544
0
              appendPQExpBufferStr(output_buf, value);
1545
0
              free(value);
1546
0
            }
1547
0
            else
1548
0
              ECHO;
1549
1550
0
            *option_quote = ':';
1551
0
          }
1552
0
          unquoted_option_chars = 0;
1553
0
        }
1554
0
  YY_BREAK
1555
0
case 12:
1556
0
YY_RULE_SETUP
1557
0
#line 274 "psqlscanslash.l"
1558
0
{
1559
0
          psqlscan_escape_variable(cur_state, yytext, yyleng,
1560
0
                       PQUOTE_SQL_LITERAL);
1561
0
          *option_quote = ':';
1562
0
          unquoted_option_chars = 0;
1563
0
        }
1564
0
  YY_BREAK
1565
0
case 13:
1566
0
YY_RULE_SETUP
1567
0
#line 282 "psqlscanslash.l"
1568
0
{
1569
0
          psqlscan_escape_variable(cur_state, yytext, yyleng,
1570
0
                       PQUOTE_SQL_IDENT);
1571
0
          *option_quote = ':';
1572
0
          unquoted_option_chars = 0;
1573
0
        }
1574
0
  YY_BREAK
1575
0
case 14:
1576
0
YY_RULE_SETUP
1577
0
#line 289 "psqlscanslash.l"
1578
0
{
1579
0
          psqlscan_test_variable(cur_state, yytext, yyleng);
1580
0
        }
1581
0
  YY_BREAK
1582
0
case 15:
1583
0
YY_RULE_SETUP
1584
0
#line 293 "psqlscanslash.l"
1585
0
{
1586
          /* Throw back everything but the colon */
1587
0
          yyless(1);
1588
0
          unquoted_option_chars++;
1589
0
          ECHO;
1590
0
        }
1591
0
  YY_BREAK
1592
0
case 16:
1593
0
YY_RULE_SETUP
1594
0
#line 300 "psqlscanslash.l"
1595
0
{
1596
          /* Throw back everything but the colon */
1597
0
          yyless(1);
1598
0
          unquoted_option_chars++;
1599
0
          ECHO;
1600
0
        }
1601
0
  YY_BREAK
1602
0
case 17:
1603
0
YY_RULE_SETUP
1604
0
#line 307 "psqlscanslash.l"
1605
0
{
1606
          /* Throw back everything but the colon */
1607
0
          yyless(1);
1608
0
          unquoted_option_chars++;
1609
0
          ECHO;
1610
0
        }
1611
0
  YY_BREAK
1612
0
case 18:
1613
0
YY_RULE_SETUP
1614
0
#line 314 "psqlscanslash.l"
1615
0
{
1616
          /* Throw back everything but the colon */
1617
0
          yyless(1);
1618
0
          unquoted_option_chars++;
1619
0
          ECHO;
1620
0
        }
1621
0
  YY_BREAK
1622
332
case 19:
1623
332
YY_RULE_SETUP
1624
332
#line 321 "psqlscanslash.l"
1625
332
{
1626
332
          unquoted_option_chars++;
1627
332
          ECHO;
1628
332
        }
1629
332
  YY_BREAK
1630
1631
1632
/*
1633
   * single-quoted text: copy literally except for '' and backslash
1634
   * sequences
1635
   */
1636
0
case 20:
1637
0
YY_RULE_SETUP
1638
0
#line 334 "psqlscanslash.l"
1639
0
{ BEGIN(xslasharg); }
1640
0
  YY_BREAK
1641
0
case 21:
1642
0
YY_RULE_SETUP
1643
0
#line 336 "psqlscanslash.l"
1644
0
{ appendPQExpBufferChar(output_buf, '\''); }
1645
0
  YY_BREAK
1646
0
case 22:
1647
0
YY_RULE_SETUP
1648
0
#line 338 "psqlscanslash.l"
1649
0
{ appendPQExpBufferChar(output_buf, '\n'); }
1650
0
  YY_BREAK
1651
0
case 23:
1652
0
YY_RULE_SETUP
1653
0
#line 339 "psqlscanslash.l"
1654
0
{ appendPQExpBufferChar(output_buf, '\t'); }
1655
0
  YY_BREAK
1656
0
case 24:
1657
0
YY_RULE_SETUP
1658
0
#line 340 "psqlscanslash.l"
1659
0
{ appendPQExpBufferChar(output_buf, '\b'); }
1660
0
  YY_BREAK
1661
0
case 25:
1662
0
YY_RULE_SETUP
1663
0
#line 341 "psqlscanslash.l"
1664
0
{ appendPQExpBufferChar(output_buf, '\r'); }
1665
0
  YY_BREAK
1666
0
case 26:
1667
0
YY_RULE_SETUP
1668
0
#line 342 "psqlscanslash.l"
1669
0
{ appendPQExpBufferChar(output_buf, '\f'); }
1670
0
  YY_BREAK
1671
0
case 27:
1672
0
YY_RULE_SETUP
1673
0
#line 344 "psqlscanslash.l"
1674
0
{
1675
          /* octal case */
1676
0
          appendPQExpBufferChar(output_buf,
1677
0
                      (char) strtol(yytext + 1, NULL, 8));
1678
0
        }
1679
0
  YY_BREAK
1680
0
case 28:
1681
0
YY_RULE_SETUP
1682
0
#line 350 "psqlscanslash.l"
1683
0
{
1684
          /* hex case */
1685
0
          appendPQExpBufferChar(output_buf,
1686
0
                      (char) strtol(yytext + 2, NULL, 16));
1687
0
        }
1688
0
  YY_BREAK
1689
0
case 29:
1690
0
YY_RULE_SETUP
1691
0
#line 356 "psqlscanslash.l"
1692
0
{ psqlscan_emit(cur_state, yytext + 1, 1); }
1693
0
  YY_BREAK
1694
0
case 30:
1695
/* rule 30 can match eol */
1696
0
YY_RULE_SETUP
1697
0
#line 358 "psqlscanslash.l"
1698
0
{ ECHO; }
1699
0
  YY_BREAK
1700
1701
1702
/*
1703
   * backticked text: copy everything until next backquote (expanding
1704
   * variable references, but doing nought else), then evaluate.
1705
   */
1706
0
case 31:
1707
0
YY_RULE_SETUP
1708
0
#line 368 "psqlscanslash.l"
1709
0
{
1710
          /* In an inactive \if branch, don't evaluate the command */
1711
0
          if (cur_state->cb_passthrough == NULL ||
1712
0
            conditional_active((ConditionalStack) cur_state->cb_passthrough))
1713
0
            evaluate_backtick(cur_state);
1714
0
          BEGIN(xslasharg);
1715
0
        }
1716
0
  YY_BREAK
1717
0
case 32:
1718
0
YY_RULE_SETUP
1719
0
#line 376 "psqlscanslash.l"
1720
0
{
1721
          /* Possible psql variable substitution */
1722
0
          if (cur_state->callbacks->get_variable == NULL)
1723
0
            ECHO;
1724
0
          else
1725
0
          {
1726
0
            char     *varname;
1727
0
            char     *value;
1728
1729
0
            varname = psqlscan_extract_substring(cur_state,
1730
0
                               yytext + 1,
1731
0
                               yyleng - 1);
1732
0
            value = cur_state->callbacks->get_variable(varname,
1733
0
                                   PQUOTE_PLAIN,
1734
0
                                   cur_state->cb_passthrough);
1735
0
            free(varname);
1736
1737
0
            if (value)
1738
0
            {
1739
0
              appendPQExpBufferStr(output_buf, value);
1740
0
              free(value);
1741
0
            }
1742
0
            else
1743
0
              ECHO;
1744
0
          }
1745
0
        }
1746
0
  YY_BREAK
1747
0
case 33:
1748
0
YY_RULE_SETUP
1749
0
#line 403 "psqlscanslash.l"
1750
0
{
1751
0
          psqlscan_escape_variable(cur_state, yytext, yyleng,
1752
0
                       PQUOTE_SHELL_ARG);
1753
0
        }
1754
0
  YY_BREAK
1755
0
case 34:
1756
0
YY_RULE_SETUP
1757
0
#line 408 "psqlscanslash.l"
1758
0
{
1759
          /* Throw back everything but the colon */
1760
0
          yyless(1);
1761
0
          ECHO;
1762
0
        }
1763
0
  YY_BREAK
1764
0
case 35:
1765
/* rule 35 can match eol */
1766
0
YY_RULE_SETUP
1767
0
#line 414 "psqlscanslash.l"
1768
0
{ ECHO; }
1769
0
  YY_BREAK
1770
1771
1772
/* double-quoted text: copy verbatim, including the double quotes */
1773
0
case 36:
1774
0
YY_RULE_SETUP
1775
0
#line 421 "psqlscanslash.l"
1776
0
{
1777
0
          ECHO;
1778
0
          BEGIN(xslasharg);
1779
0
        }
1780
0
  YY_BREAK
1781
0
case 37:
1782
/* rule 37 can match eol */
1783
0
YY_RULE_SETUP
1784
0
#line 426 "psqlscanslash.l"
1785
0
{ ECHO; }
1786
0
  YY_BREAK
1787
1788
1789
/* copy everything until end of input line */
1790
/* but suppress leading whitespace */
1791
27
case 38:
1792
/* rule 38 can match eol */
1793
27
YY_RULE_SETUP
1794
27
#line 434 "psqlscanslash.l"
1795
27
{
1796
27
          if (output_buf->len > 0)
1797
18
            ECHO;
1798
27
        }
1799
27
  YY_BREAK
1800
297
case 39:
1801
297
YY_RULE_SETUP
1802
297
#line 439 "psqlscanslash.l"
1803
297
{ ECHO; }
1804
297
  YY_BREAK
1805
1806
1807
/* at end of command, eat a double backslash, but not anything else */
1808
1
case 40:
1809
1
YY_RULE_SETUP
1810
1
#line 446 "psqlscanslash.l"
1811
1
{
1812
1
          cur_state->start_state = YY_START;
1813
1
          return LEXRES_OK;
1814
0
        }
1815
0
  YY_BREAK
1816
0
case 41:
1817
/* rule 41 can match eol */
1818
0
YY_RULE_SETUP
1819
0
#line 451 "psqlscanslash.l"
1820
0
{
1821
0
          yyless(0);
1822
0
          cur_state->start_state = YY_START;
1823
0
          return LEXRES_OK;
1824
0
        }
1825
0
  YY_BREAK
1826
1827
0
case YY_STATE_EOF(INITIAL):
1828
8
case YY_STATE_EOF(xslashcmd):
1829
105
case YY_STATE_EOF(xslashargstart):
1830
147
case YY_STATE_EOF(xslasharg):
1831
147
case YY_STATE_EOF(xslashquote):
1832
147
case YY_STATE_EOF(xslashbackquote):
1833
147
case YY_STATE_EOF(xslashdquote):
1834
157
case YY_STATE_EOF(xslashwholeline):
1835
216
case YY_STATE_EOF(xslashend):
1836
216
#line 459 "psqlscanslash.l"
1837
216
{
1838
216
          if (cur_state->buffer_stack == NULL)
1839
216
          {
1840
216
            cur_state->start_state = YY_START;
1841
216
            return LEXRES_EOL;   /* end of input reached */
1842
216
          }
1843
1844
          /*
1845
           * We were expanding a variable, so pop the inclusion
1846
           * stack and keep lexing
1847
           */
1848
0
          psqlscan_pop_buffer_stack(cur_state);
1849
0
          psqlscan_select_top_buffer(cur_state);
1850
0
        }
1851
0
  YY_BREAK
1852
0
case 42:
1853
0
YY_RULE_SETUP
1854
0
#line 474 "psqlscanslash.l"
1855
0
YY_FATAL_ERROR( "flex scanner jammed" );
1856
0
  YY_BREAK
1857
0
#line 1857 "psqlscanslash.c"
1858
1859
275
  case YY_END_OF_BUFFER:
1860
275
    {
1861
    /* Amount of text matched not including the EOB char. */
1862
275
    int yy_amount_of_matched_text = (int) (yy_cp - yyg->yytext_ptr) - 1;
1863
1864
    /* Undo the effects of YY_DO_BEFORE_ACTION. */
1865
275
    *yy_cp = yyg->yy_hold_char;
1866
275
    YY_RESTORE_YY_MORE_OFFSET
1867
1868
275
    if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW )
1869
59
      {
1870
      /* We're scanning a new file or input source.  It's
1871
       * possible that this happened because the user
1872
       * just pointed yyin at a new source and called
1873
       * slash_yylex().  If so, then we have to assure
1874
       * consistency between YY_CURRENT_BUFFER and our
1875
       * globals.  Here is the right place to do so, because
1876
       * this is the first action (other than possibly a
1877
       * back-up) that will match for the new input source.
1878
       */
1879
59
      yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
1880
59
      YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin;
1881
59
      YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL;
1882
59
      }
1883
1884
    /* Note that here we test for yy_c_buf_p "<=" to the position
1885
     * of the first EOB in the buffer, since yy_c_buf_p will
1886
     * already have been incremented past the NUL character
1887
     * (since all states make transitions on EOB to the
1888
     * end-of-buffer state).  Contrast this with the test
1889
     * in input().
1890
     */
1891
275
    if ( yyg->yy_c_buf_p <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] )
1892
0
      { /* This was really a NUL. */
1893
0
      yy_state_type yy_next_state;
1894
1895
0
      yyg->yy_c_buf_p = yyg->yytext_ptr + yy_amount_of_matched_text;
1896
1897
0
      yy_current_state = yy_get_previous_state( yyscanner );
1898
1899
      /* Okay, we're now positioned to make the NUL
1900
       * transition.  We couldn't have
1901
       * yy_get_previous_state() go ahead and do it
1902
       * for us because it doesn't know how to deal
1903
       * with the possibility of jamming (and we don't
1904
       * want to build jamming into it because then it
1905
       * will run more slowly).
1906
       */
1907
1908
0
      yy_next_state = yy_try_NUL_trans( yy_current_state , yyscanner);
1909
1910
0
      yy_bp = yyg->yytext_ptr + YY_MORE_ADJ;
1911
1912
0
      if ( yy_next_state )
1913
0
        {
1914
        /* Consume the NUL. */
1915
0
        yy_cp = ++yyg->yy_c_buf_p;
1916
0
        yy_current_state = yy_next_state;
1917
0
        goto yy_match;
1918
0
        }
1919
1920
0
      else
1921
0
        {
1922
0
        yy_cp = yyg->yy_c_buf_p;
1923
0
        goto yy_find_action;
1924
0
        }
1925
0
      }
1926
1927
275
    else switch ( yy_get_next_buffer( yyscanner ) )
1928
275
      {
1929
216
      case EOB_ACT_END_OF_FILE:
1930
216
        {
1931
216
        yyg->yy_did_buffer_switch_on_eof = 0;
1932
1933
216
        if ( slash_yywrap(yyscanner ) )
1934
216
          {
1935
          /* Note: because we've taken care in
1936
           * yy_get_next_buffer() to have set up
1937
           * yytext, we can now set up
1938
           * yy_c_buf_p so that if some total
1939
           * hoser (like flex itself) wants to
1940
           * call the scanner after we return the
1941
           * YY_NULL, it'll still work - another
1942
           * YY_NULL will get returned.
1943
           */
1944
216
          yyg->yy_c_buf_p = yyg->yytext_ptr + YY_MORE_ADJ;
1945
1946
216
          yy_act = YY_STATE_EOF(YY_START);
1947
216
          goto do_action;
1948
216
          }
1949
1950
0
        else
1951
0
          {
1952
0
          if ( ! yyg->yy_did_buffer_switch_on_eof )
1953
0
            YY_NEW_FILE;
1954
0
          }
1955
0
        break;
1956
216
        }
1957
1958
0
      case EOB_ACT_CONTINUE_SCAN:
1959
0
        yyg->yy_c_buf_p =
1960
0
          yyg->yytext_ptr + yy_amount_of_matched_text;
1961
1962
0
        yy_current_state = yy_get_previous_state( yyscanner );
1963
1964
0
        yy_cp = yyg->yy_c_buf_p;
1965
0
        yy_bp = yyg->yytext_ptr + YY_MORE_ADJ;
1966
0
        goto yy_match;
1967
1968
59
      case EOB_ACT_LAST_MATCH:
1969
59
        yyg->yy_c_buf_p =
1970
59
        &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars];
1971
1972
59
        yy_current_state = yy_get_previous_state( yyscanner );
1973
1974
59
        yy_cp = yyg->yy_c_buf_p;
1975
59
        yy_bp = yyg->yytext_ptr + YY_MORE_ADJ;
1976
59
        goto yy_find_action;
1977
275
      }
1978
0
    break;
1979
275
    }
1980
1981
0
  default:
1982
0
    YY_FATAL_ERROR(
1983
1.45k
      "fatal flex scanner internal error--no action found" );
1984
1.45k
  } /* end of action switch */
1985
1.45k
    } /* end of scanning one token */
1986
278
  } /* end of user's declarations */
1987
278
} /* end of slash_yylex */
1988
1989
/* yy_get_next_buffer - try to read in a new buffer
1990
 *
1991
 * Returns a code representing an action:
1992
 *  EOB_ACT_LAST_MATCH -
1993
 *  EOB_ACT_CONTINUE_SCAN - continue scanning from current position
1994
 *  EOB_ACT_END_OF_FILE - end of file
1995
 */
1996
static int yy_get_next_buffer (yyscan_t yyscanner)
1997
275
{
1998
275
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1999
275
  char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
2000
275
  char *source = yyg->yytext_ptr;
2001
275
  int number_to_move, i;
2002
275
  int ret_val;
2003
2004
275
  if ( yyg->yy_c_buf_p > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] )
2005
0
    YY_FATAL_ERROR(
2006
275
    "fatal flex scanner internal error--end of buffer missed" );
2007
2008
275
  if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 )
2009
275
    { /* Don't try to fill the buffer, so this is an EOF. */
2010
275
    if ( yyg->yy_c_buf_p - yyg->yytext_ptr - YY_MORE_ADJ == 1 )
2011
216
      {
2012
      /* We matched a single character, the EOB, so
2013
       * treat this as a final EOF.
2014
       */
2015
216
      return EOB_ACT_END_OF_FILE;
2016
216
      }
2017
2018
59
    else
2019
59
      {
2020
      /* We matched some text prior to the EOB, first
2021
       * process it.
2022
       */
2023
59
      return EOB_ACT_LAST_MATCH;
2024
59
      }
2025
275
    }
2026
2027
  /* Try to read more data. */
2028
2029
  /* First move last chars to start of buffer. */
2030
0
  number_to_move = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr - 1);
2031
2032
0
  for ( i = 0; i < number_to_move; ++i )
2033
0
    *(dest++) = *(source++);
2034
2035
0
  if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING )
2036
    /* don't do the read, it's not guaranteed to return an EOF,
2037
     * just force an EOF
2038
     */
2039
0
    YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars = 0;
2040
2041
0
  else
2042
0
    {
2043
0
      int num_to_read =
2044
0
      YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
2045
2046
0
    while ( num_to_read <= 0 )
2047
0
      { /* Not enough room in the buffer - grow it. */
2048
2049
      /* just a shorter name for the current buffer */
2050
0
      YY_BUFFER_STATE b = YY_CURRENT_BUFFER_LVALUE;
2051
2052
0
      int yy_c_buf_p_offset =
2053
0
        (int) (yyg->yy_c_buf_p - b->yy_ch_buf);
2054
2055
0
      if ( b->yy_is_our_buffer )
2056
0
        {
2057
0
        int new_size = b->yy_buf_size * 2;
2058
2059
0
        if ( new_size <= 0 )
2060
0
          b->yy_buf_size += b->yy_buf_size / 8;
2061
0
        else
2062
0
          b->yy_buf_size *= 2;
2063
2064
0
        b->yy_ch_buf = (char *)
2065
          /* Include room in for 2 EOB chars. */
2066
0
          slash_yyrealloc((void *) b->yy_ch_buf,(yy_size_t) (b->yy_buf_size + 2) ,yyscanner );
2067
0
        }
2068
0
      else
2069
        /* Can't grow it, we don't own it. */
2070
0
        b->yy_ch_buf = NULL;
2071
2072
0
      if ( ! b->yy_ch_buf )
2073
0
        YY_FATAL_ERROR(
2074
0
        "fatal error - scanner input buffer overflow" );
2075
2076
0
      yyg->yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset];
2077
2078
0
      num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size -
2079
0
            number_to_move - 1;
2080
2081
0
      }
2082
2083
0
    if ( num_to_read > YY_READ_BUF_SIZE )
2084
0
      num_to_read = YY_READ_BUF_SIZE;
2085
2086
    /* Read in more data. */
2087
0
    YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]),
2088
0
      yyg->yy_n_chars, num_to_read );
2089
2090
0
    YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars;
2091
0
    }
2092
2093
0
  if ( yyg->yy_n_chars == 0 )
2094
0
    {
2095
0
    if ( number_to_move == YY_MORE_ADJ )
2096
0
      {
2097
0
      ret_val = EOB_ACT_END_OF_FILE;
2098
0
      slash_yyrestart(yyin  ,yyscanner);
2099
0
      }
2100
2101
0
    else
2102
0
      {
2103
0
      ret_val = EOB_ACT_LAST_MATCH;
2104
0
      YY_CURRENT_BUFFER_LVALUE->yy_buffer_status =
2105
0
        YY_BUFFER_EOF_PENDING;
2106
0
      }
2107
0
    }
2108
2109
0
  else
2110
0
    ret_val = EOB_ACT_CONTINUE_SCAN;
2111
2112
0
  if ((yyg->yy_n_chars + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {
2113
    /* Extend the array by 50%, plus the number we really need. */
2114
0
    int new_size = yyg->yy_n_chars + number_to_move + (yyg->yy_n_chars >> 1);
2115
0
    YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) slash_yyrealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,(yy_size_t) new_size ,yyscanner );
2116
0
    if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
2117
0
      YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" );
2118
0
  }
2119
2120
0
  yyg->yy_n_chars += number_to_move;
2121
0
  YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] = YY_END_OF_BUFFER_CHAR;
2122
0
  YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR;
2123
2124
0
  yyg->yytext_ptr = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0];
2125
2126
0
  return ret_val;
2127
0
}
2128
2129
/* yy_get_previous_state - get the state just before the EOB char was reached */
2130
2131
    static yy_state_type yy_get_previous_state (yyscan_t yyscanner)
2132
59
{
2133
59
  yy_state_type yy_current_state;
2134
59
  char *yy_cp;
2135
59
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2136
2137
59
  yy_current_state = yyg->yy_start;
2138
2139
118
  for ( yy_cp = yyg->
yytext_ptr59
+
YY_MORE_ADJ59
; yy_cp < yyg->yy_c_buf_p;
++yy_cp59
)
2140
59
    {
2141
59
    yy_current_state = yy_nxt[yy_current_state][(*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 
10
)];
2142
59
    }
2143
2144
59
  return yy_current_state;
2145
59
}
2146
2147
/* yy_try_NUL_trans - try to make a transition on the NUL character
2148
 *
2149
 * synopsis
2150
 *  next_state = yy_try_NUL_trans( current_state );
2151
 */
2152
    static yy_state_type yy_try_NUL_trans  (yy_state_type yy_current_state , yyscan_t yyscanner)
2153
0
{
2154
0
  int yy_is_jam;
2155
0
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* This var may be unused depending upon options. */
2156
2157
0
  yy_current_state = yy_nxt[yy_current_state][1];
2158
0
  yy_is_jam = (yy_current_state <= 0);
2159
2160
0
  (void)yyg;
2161
0
  return yy_is_jam ? 0 : yy_current_state;
2162
0
}
2163
2164
#ifndef YY_NO_UNPUT
2165
2166
#endif
2167
2168
#ifndef YY_NO_INPUT
2169
#ifdef __cplusplus
2170
    static int yyinput (yyscan_t yyscanner)
2171
#else
2172
    static int input  (yyscan_t yyscanner)
2173
#endif
2174
2175
{
2176
  int c;
2177
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2178
2179
  *yyg->yy_c_buf_p = yyg->yy_hold_char;
2180
2181
  if ( *yyg->yy_c_buf_p == YY_END_OF_BUFFER_CHAR )
2182
    {
2183
    /* yy_c_buf_p now points to the character we want to return.
2184
     * If this occurs *before* the EOB characters, then it's a
2185
     * valid NUL; if not, then we've hit the end of the buffer.
2186
     */
2187
    if ( yyg->yy_c_buf_p < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] )
2188
      /* This was really a NUL. */
2189
      *yyg->yy_c_buf_p = '\0';
2190
2191
    else
2192
      { /* need more input */
2193
      int offset = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr);
2194
      ++yyg->yy_c_buf_p;
2195
2196
      switch ( yy_get_next_buffer( yyscanner ) )
2197
        {
2198
        case EOB_ACT_LAST_MATCH:
2199
          /* This happens because yy_g_n_b()
2200
           * sees that we've accumulated a
2201
           * token and flags that we need to
2202
           * try matching the token before
2203
           * proceeding.  But for input(),
2204
           * there's no matching to consider.
2205
           * So convert the EOB_ACT_LAST_MATCH
2206
           * to EOB_ACT_END_OF_FILE.
2207
           */
2208
2209
          /* Reset buffer status. */
2210
          slash_yyrestart(yyin ,yyscanner);
2211
2212
          /*FALLTHROUGH*/
2213
2214
        case EOB_ACT_END_OF_FILE:
2215
          {
2216
          if ( slash_yywrap(yyscanner ) )
2217
            return 0;
2218
2219
          if ( ! yyg->yy_did_buffer_switch_on_eof )
2220
            YY_NEW_FILE;
2221
#ifdef __cplusplus
2222
          return yyinput(yyscanner);
2223
#else
2224
          return input(yyscanner);
2225
#endif
2226
          }
2227
2228
        case EOB_ACT_CONTINUE_SCAN:
2229
          yyg->yy_c_buf_p = yyg->yytext_ptr + offset;
2230
          break;
2231
        }
2232
      }
2233
    }
2234
2235
  c = *(unsigned char *) yyg->yy_c_buf_p; /* cast for 8-bit char's */
2236
  *yyg->yy_c_buf_p = '\0';  /* preserve yytext */
2237
  yyg->yy_hold_char = *++yyg->yy_c_buf_p;
2238
2239
  return c;
2240
}
2241
#endif  /* ifndef YY_NO_INPUT */
2242
2243
/** Immediately switch to a different input stream.
2244
 * @param input_file A readable stream.
2245
 * @param yyscanner The scanner object.
2246
 * @note This function does not reset the start condition to @c INITIAL .
2247
 */
2248
    void slash_yyrestart  (FILE * input_file , yyscan_t yyscanner)
2249
0
{
2250
0
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2251
2252
0
  if ( ! YY_CURRENT_BUFFER ){
2253
0
        slash_yyensure_buffer_stack (yyscanner);
2254
0
    YY_CURRENT_BUFFER_LVALUE =
2255
0
            slash_yy_create_buffer(yyin,YY_BUF_SIZE ,yyscanner);
2256
0
  }
2257
2258
0
  slash_yy_init_buffer(YY_CURRENT_BUFFER,input_file ,yyscanner);
2259
0
  slash_yy_load_buffer_state(yyscanner );
2260
0
}
2261
2262
/** Switch to a different input buffer.
2263
 * @param new_buffer The new input buffer.
2264
 * @param yyscanner The scanner object.
2265
 */
2266
    void slash_yy_switch_to_buffer  (YY_BUFFER_STATE  new_buffer , yyscan_t yyscanner)
2267
278
{
2268
278
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2269
2270
  /* TODO. We should be able to replace this entire function body
2271
   * with
2272
   *    slash_yypop_buffer_state();
2273
   *    slash_yypush_buffer_state(new_buffer);
2274
     */
2275
278
  slash_yyensure_buffer_stack (yyscanner);
2276
278
  if ( YY_CURRENT_BUFFER == new_buffer )
2277
278
    return;
2278
2279
0
  if ( YY_CURRENT_BUFFER )
2280
0
    {
2281
    /* Flush out information for old buffer. */
2282
0
    *yyg->yy_c_buf_p = yyg->yy_hold_char;
2283
0
    YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p;
2284
0
    YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars;
2285
0
    }
2286
2287
0
  YY_CURRENT_BUFFER_LVALUE = new_buffer;
2288
0
  slash_yy_load_buffer_state(yyscanner );
2289
2290
  /* We don't actually know whether we did this switch during
2291
   * EOF (slash_yywrap()) processing, but the only time this flag
2292
   * is looked at is after slash_yywrap() is called, so it's safe
2293
   * to go ahead and always set it.
2294
   */
2295
0
  yyg->yy_did_buffer_switch_on_eof = 1;
2296
0
}
2297
2298
static void slash_yy_load_buffer_state  (yyscan_t yyscanner)
2299
0
{
2300
0
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2301
0
  yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
2302
0
  yyg->yytext_ptr = yyg->yy_c_buf_p = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos;
2303
0
  yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file;
2304
0
  yyg->yy_hold_char = *yyg->yy_c_buf_p;
2305
0
}
2306
2307
/** Allocate and initialize an input buffer state.
2308
 * @param file A readable stream.
2309
 * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE.
2310
 * @param yyscanner The scanner object.
2311
 * @return the allocated buffer state.
2312
 */
2313
    YY_BUFFER_STATE slash_yy_create_buffer  (FILE * file, int  size , yyscan_t yyscanner)
2314
0
{
2315
0
  YY_BUFFER_STATE b;
2316
    
2317
0
  b = (YY_BUFFER_STATE) slash_yyalloc(sizeof( struct yy_buffer_state ) ,yyscanner );
2318
0
  if ( ! b )
2319
0
    YY_FATAL_ERROR( "out of dynamic memory in slash_yy_create_buffer()" );
2320
2321
0
  b->yy_buf_size = size;
2322
2323
  /* yy_ch_buf has to be 2 characters longer than the size given because
2324
   * we need to put in 2 end-of-buffer characters.
2325
   */
2326
0
  b->yy_ch_buf = (char *) slash_yyalloc((yy_size_t) (b->yy_buf_size + 2) ,yyscanner );
2327
0
  if ( ! b->yy_ch_buf )
2328
0
    YY_FATAL_ERROR( "out of dynamic memory in slash_yy_create_buffer()" );
2329
2330
0
  b->yy_is_our_buffer = 1;
2331
2332
0
  slash_yy_init_buffer(b,file ,yyscanner);
2333
2334
0
  return b;
2335
0
}
2336
2337
/** Destroy the buffer.
2338
 * @param b a buffer created with slash_yy_create_buffer()
2339
 * @param yyscanner The scanner object.
2340
 */
2341
    void slash_yy_delete_buffer (YY_BUFFER_STATE  b , yyscan_t yyscanner)
2342
0
{
2343
0
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2344
2345
0
  if ( ! b )
2346
0
    return;
2347
2348
0
  if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */
2349
0
    YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0;
2350
2351
0
  if ( b->yy_is_our_buffer )
2352
0
    slash_yyfree((void *) b->yy_ch_buf ,yyscanner );
2353
2354
0
  slash_yyfree((void *) b ,yyscanner );
2355
0
}
2356
2357
/* Initializes or reinitializes a buffer.
2358
 * This function is sometimes called more than once on the same buffer,
2359
 * such as during a slash_yyrestart() or at EOF.
2360
 */
2361
    static void slash_yy_init_buffer  (YY_BUFFER_STATE  b, FILE * file , yyscan_t yyscanner)
2362
2363
0
{
2364
0
  int oerrno = errno;
2365
0
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2366
2367
0
  slash_yy_flush_buffer(b ,yyscanner);
2368
2369
0
  b->yy_input_file = file;
2370
0
  b->yy_fill_buffer = 1;
2371
2372
    /* If b is the current buffer, then slash_yy_init_buffer was _probably_
2373
     * called from slash_yyrestart() or through yy_get_next_buffer.
2374
     * In that case, we don't want to reset the lineno or column.
2375
     */
2376
0
    if (b != YY_CURRENT_BUFFER){
2377
0
        b->yy_bs_lineno = 1;
2378
0
        b->yy_bs_column = 0;
2379
0
    }
2380
2381
0
        b->yy_is_interactive = 0;
2382
    
2383
0
  errno = oerrno;
2384
0
}
2385
2386
/** Discard all buffered characters. On the next scan, YY_INPUT will be called.
2387
 * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER.
2388
 * @param yyscanner The scanner object.
2389
 */
2390
    void slash_yy_flush_buffer (YY_BUFFER_STATE  b , yyscan_t yyscanner)
2391
0
{
2392
0
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2393
0
  if ( ! b )
2394
0
    return;
2395
2396
0
  b->yy_n_chars = 0;
2397
2398
  /* We always need two end-of-buffer characters.  The first causes
2399
   * a transition to the end-of-buffer state.  The second causes
2400
   * a jam in that state.
2401
   */
2402
0
  b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
2403
0
  b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
2404
2405
0
  b->yy_buf_pos = &b->yy_ch_buf[0];
2406
2407
0
  b->yy_at_bol = 1;
2408
0
  b->yy_buffer_status = YY_BUFFER_NEW;
2409
2410
0
  if ( b == YY_CURRENT_BUFFER )
2411
0
    slash_yy_load_buffer_state(yyscanner );
2412
0
}
2413
2414
/** Pushes the new state onto the stack. The new state becomes
2415
 *  the current state. This function will allocate the stack
2416
 *  if necessary.
2417
 *  @param new_buffer The new state.
2418
 *  @param yyscanner The scanner object.
2419
 */
2420
void slash_yypush_buffer_state (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner)
2421
0
{
2422
0
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2423
0
  if (new_buffer == NULL)
2424
0
    return;
2425
2426
0
  slash_yyensure_buffer_stack(yyscanner);
2427
2428
  /* This block is copied from slash_yy_switch_to_buffer. */
2429
0
  if ( YY_CURRENT_BUFFER )
2430
0
    {
2431
    /* Flush out information for old buffer. */
2432
0
    *yyg->yy_c_buf_p = yyg->yy_hold_char;
2433
0
    YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p;
2434
0
    YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars;
2435
0
    }
2436
2437
  /* Only push if top exists. Otherwise, replace top. */
2438
0
  if (YY_CURRENT_BUFFER)
2439
0
    yyg->yy_buffer_stack_top++;
2440
0
  YY_CURRENT_BUFFER_LVALUE = new_buffer;
2441
2442
  /* copied from slash_yy_switch_to_buffer. */
2443
0
  slash_yy_load_buffer_state(yyscanner );
2444
0
  yyg->yy_did_buffer_switch_on_eof = 1;
2445
0
}
2446
2447
/** Removes and deletes the top of the stack, if present.
2448
 *  The next element becomes the new top.
2449
 *  @param yyscanner The scanner object.
2450
 */
2451
void slash_yypop_buffer_state (yyscan_t yyscanner)
2452
0
{
2453
0
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2454
0
  if (!YY_CURRENT_BUFFER)
2455
0
    return;
2456
2457
0
  slash_yy_delete_buffer(YY_CURRENT_BUFFER ,yyscanner);
2458
0
  YY_CURRENT_BUFFER_LVALUE = NULL;
2459
0
  if (yyg->yy_buffer_stack_top > 0)
2460
0
    --yyg->yy_buffer_stack_top;
2461
2462
0
  if (YY_CURRENT_BUFFER) {
2463
0
    slash_yy_load_buffer_state(yyscanner );
2464
0
    yyg->yy_did_buffer_switch_on_eof = 1;
2465
0
  }
2466
0
}
2467
2468
/* Allocates the stack if it does not exist.
2469
 *  Guarantees space for at least one push.
2470
 */
2471
static void slash_yyensure_buffer_stack (yyscan_t yyscanner)
2472
278
{
2473
278
  yy_size_t num_to_alloc;
2474
278
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2475
2476
278
  if (!yyg->yy_buffer_stack) {
2477
2478
    /* First allocation is just for 2 elements, since we don't know if this
2479
     * scanner will even need a stack. We use 2 instead of 1 to avoid an
2480
     * immediate realloc on the next call.
2481
         */
2482
0
      num_to_alloc = 1; /* After all that talk, this was set to 1 anyways... */
2483
0
    yyg->yy_buffer_stack = (struct yy_buffer_state**)slash_yyalloc
2484
0
                (num_to_alloc * sizeof(struct yy_buffer_state*)
2485
0
                , yyscanner);
2486
0
    if ( ! yyg->yy_buffer_stack )
2487
0
      YY_FATAL_ERROR( "out of dynamic memory in slash_yyensure_buffer_stack()" );
2488
2489
0
    memset(yyg->yy_buffer_stack, 0, num_to_alloc * sizeof(struct yy_buffer_state*));
2490
2491
0
    yyg->yy_buffer_stack_max = num_to_alloc;
2492
0
    yyg->yy_buffer_stack_top = 0;
2493
0
    return;
2494
0
  }
2495
2496
278
  if (yyg->yy_buffer_stack_top >= (yyg->yy_buffer_stack_max) - 1){
2497
2498
    /* Increase the buffer to prepare for a possible push. */
2499
0
    yy_size_t grow_size = 8 /* arbitrary grow size */;
2500
2501
0
    num_to_alloc = yyg->yy_buffer_stack_max + grow_size;
2502
0
    yyg->yy_buffer_stack = (struct yy_buffer_state**)slash_yyrealloc
2503
0
                (yyg->yy_buffer_stack,
2504
0
                num_to_alloc * sizeof(struct yy_buffer_state*)
2505
0
                , yyscanner);
2506
0
    if ( ! yyg->yy_buffer_stack )
2507
0
      YY_FATAL_ERROR( "out of dynamic memory in slash_yyensure_buffer_stack()" );
2508
2509
    /* zero only the new slots.*/
2510
0
    memset(yyg->yy_buffer_stack + yyg->yy_buffer_stack_max, 0, grow_size * sizeof(struct yy_buffer_state*));
2511
0
    yyg->yy_buffer_stack_max = num_to_alloc;
2512
0
  }
2513
278
}
2514
2515
/** Setup the input buffer state to scan directly from a user-specified character buffer.
2516
 * @param base the character buffer
2517
 * @param size the size in bytes of the character buffer
2518
 * @param yyscanner The scanner object.
2519
 * @return the newly allocated buffer state object.
2520
 */
2521
YY_BUFFER_STATE slash_yy_scan_buffer  (char * base, yy_size_t  size , yyscan_t yyscanner)
2522
0
{
2523
0
  YY_BUFFER_STATE b;
2524
    
2525
0
  if ( size < 2 ||
2526
0
       base[size-2] != YY_END_OF_BUFFER_CHAR ||
2527
0
       base[size-1] != YY_END_OF_BUFFER_CHAR )
2528
    /* They forgot to leave room for the EOB's. */
2529
0
    return NULL;
2530
2531
0
  b = (YY_BUFFER_STATE) slash_yyalloc(sizeof( struct yy_buffer_state ) ,yyscanner );
2532
0
  if ( ! b )
2533
0
    YY_FATAL_ERROR( "out of dynamic memory in slash_yy_scan_buffer()" );
2534
2535
0
  b->yy_buf_size = (int) (size - 2);  /* "- 2" to take care of EOB's */
2536
0
  b->yy_buf_pos = b->yy_ch_buf = base;
2537
0
  b->yy_is_our_buffer = 0;
2538
0
  b->yy_input_file = NULL;
2539
0
  b->yy_n_chars = b->yy_buf_size;
2540
0
  b->yy_is_interactive = 0;
2541
0
  b->yy_at_bol = 1;
2542
0
  b->yy_fill_buffer = 0;
2543
0
  b->yy_buffer_status = YY_BUFFER_NEW;
2544
2545
0
  slash_yy_switch_to_buffer(b ,yyscanner );
2546
2547
0
  return b;
2548
0
}
2549
2550
/** Setup the input buffer state to scan a string. The next call to slash_yylex() will
2551
 * scan from a @e copy of @a str.
2552
 * @param yystr a NUL-terminated string to scan
2553
 * @param yyscanner The scanner object.
2554
 * @return the newly allocated buffer state object.
2555
 * @note If you want to scan bytes that may contain NUL values, then use
2556
 *       slash_yy_scan_bytes() instead.
2557
 */
2558
YY_BUFFER_STATE slash_yy_scan_string (const char * yystr , yyscan_t yyscanner)
2559
0
{
2560
    
2561
0
  return slash_yy_scan_bytes(yystr,(int) strlen(yystr) ,yyscanner);
2562
0
}
2563
2564
/** Setup the input buffer state to scan the given bytes. The next call to slash_yylex() will
2565
 * scan from a @e copy of @a bytes.
2566
 * @param yybytes the byte buffer to scan
2567
 * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes.
2568
 * @param yyscanner The scanner object.
2569
 * @return the newly allocated buffer state object.
2570
 */
2571
YY_BUFFER_STATE slash_yy_scan_bytes  (const char * yybytes, int  _yybytes_len , yyscan_t yyscanner)
2572
0
{
2573
0
  YY_BUFFER_STATE b;
2574
0
  char *buf;
2575
0
  yy_size_t n;
2576
0
  int i;
2577
    
2578
  /* Get memory for full buffer, including space for trailing EOB's. */
2579
0
  n = (yy_size_t) (_yybytes_len + 2);
2580
0
  buf = (char *) slash_yyalloc(n ,yyscanner );
2581
0
  if ( ! buf )
2582
0
    YY_FATAL_ERROR( "out of dynamic memory in slash_yy_scan_bytes()" );
2583
2584
0
  for ( i = 0; i < _yybytes_len; ++i )
2585
0
    buf[i] = yybytes[i];
2586
2587
0
  buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR;
2588
2589
0
  b = slash_yy_scan_buffer(buf,n ,yyscanner);
2590
0
  if ( ! b )
2591
0
    YY_FATAL_ERROR( "bad buffer in slash_yy_scan_bytes()" );
2592
2593
  /* It's okay to grow etc. this buffer, and we should throw it
2594
   * away when we're done.
2595
   */
2596
0
  b->yy_is_our_buffer = 1;
2597
2598
0
  return b;
2599
0
}
2600
2601
#ifndef YY_EXIT_FAILURE
2602
0
#define YY_EXIT_FAILURE 2
2603
#endif
2604
2605
static void yynoreturn yy_fatal_error (const char* msg , yyscan_t yyscanner)
2606
0
{
2607
0
  struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2608
0
  (void)yyg;
2609
0
  (void) fprintf( stderr, "%s\n", msg );
2610
0
  exit( YY_EXIT_FAILURE );
2611
0
}
2612
2613
/* Redefine yyless() so it works in section 3 code. */
2614
2615
#undef yyless
2616
#define yyless(n) \
2617
  do \
2618
    { \
2619
    /* Undo effects of setting up yytext. */ \
2620
        int yyless_macro_arg = (n); \
2621
        YY_LESS_LINENO(yyless_macro_arg);\
2622
    yytext[yyleng] = yyg->yy_hold_char; \
2623
    yyg->yy_c_buf_p = yytext + yyless_macro_arg; \
2624
    yyg->yy_hold_char = *yyg->yy_c_buf_p; \
2625
    *yyg->yy_c_buf_p = '\0'; \
2626
    yyleng = yyless_macro_arg; \
2627
    } \
2628
  while ( 0 )
2629
2630
/* Accessor  methods (get/set functions) to struct members. */
2631
2632
/** Get the user-defined data for this scanner.
2633
 * @param yyscanner The scanner object.
2634
 */
2635
YY_EXTRA_TYPE slash_yyget_extra  (yyscan_t yyscanner)
2636
0
{
2637
0
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2638
0
    return yyextra;
2639
0
}
2640
2641
/** Get the current line number.
2642
 * @param yyscanner The scanner object.
2643
 */
2644
int slash_yyget_lineno  (yyscan_t yyscanner)
2645
0
{
2646
0
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2647
2648
0
        if (! YY_CURRENT_BUFFER)
2649
0
            return 0;
2650
    
2651
0
    return yylineno;
2652
0
}
2653
2654
/** Get the current column number.
2655
 * @param yyscanner The scanner object.
2656
 */
2657
int slash_yyget_column  (yyscan_t yyscanner)
2658
0
{
2659
0
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2660
2661
0
        if (! YY_CURRENT_BUFFER)
2662
0
            return 0;
2663
    
2664
0
    return yycolumn;
2665
0
}
2666
2667
/** Get the input stream.
2668
 * @param yyscanner The scanner object.
2669
 */
2670
FILE *slash_yyget_in  (yyscan_t yyscanner)
2671
0
{
2672
0
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2673
0
    return yyin;
2674
0
}
2675
2676
/** Get the output stream.
2677
 * @param yyscanner The scanner object.
2678
 */
2679
FILE *slash_yyget_out  (yyscan_t yyscanner)
2680
0
{
2681
0
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2682
0
    return yyout;
2683
0
}
2684
2685
/** Get the length of the current token.
2686
 * @param yyscanner The scanner object.
2687
 */
2688
int slash_yyget_leng  (yyscan_t yyscanner)
2689
0
{
2690
0
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2691
0
    return yyleng;
2692
0
}
2693
2694
/** Get the current token.
2695
 * @param yyscanner The scanner object.
2696
 */
2697
2698
char *slash_yyget_text  (yyscan_t yyscanner)
2699
0
{
2700
0
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2701
0
    return yytext;
2702
0
}
2703
2704
/** Set the user-defined data. This data is never touched by the scanner.
2705
 * @param user_defined The data to be associated with this scanner.
2706
 * @param yyscanner The scanner object.
2707
 */
2708
void slash_yyset_extra (YY_EXTRA_TYPE  user_defined , yyscan_t yyscanner)
2709
0
{
2710
0
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2711
0
    yyextra = user_defined ;
2712
0
}
2713
2714
/** Set the current line number.
2715
 * @param _line_number line number
2716
 * @param yyscanner The scanner object.
2717
 */
2718
void slash_yyset_lineno (int  _line_number , yyscan_t yyscanner)
2719
0
{
2720
0
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2721
2722
        /* lineno is only valid if an input buffer exists. */
2723
0
        if (! YY_CURRENT_BUFFER )
2724
0
           YY_FATAL_ERROR( "slash_yyset_lineno called with no buffer" );
2725
    
2726
0
    yylineno = _line_number;
2727
0
}
2728
2729
/** Set the current column.
2730
 * @param _column_no column number
2731
 * @param yyscanner The scanner object.
2732
 */
2733
void slash_yyset_column (int  _column_no , yyscan_t yyscanner)
2734
0
{
2735
0
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2736
2737
        /* column is only valid if an input buffer exists. */
2738
0
        if (! YY_CURRENT_BUFFER )
2739
0
           YY_FATAL_ERROR( "slash_yyset_column called with no buffer" );
2740
    
2741
0
    yycolumn = _column_no;
2742
0
}
2743
2744
/** Set the input stream. This does not discard the current
2745
 * input buffer.
2746
 * @param _in_str A readable stream.
2747
 * @param yyscanner The scanner object.
2748
 * @see slash_yy_switch_to_buffer
2749
 */
2750
void slash_yyset_in (FILE *  _in_str , yyscan_t yyscanner)
2751
0
{
2752
0
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2753
0
    yyin = _in_str ;
2754
0
}
2755
2756
void slash_yyset_out (FILE *  _out_str , yyscan_t yyscanner)
2757
0
{
2758
0
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2759
0
    yyout = _out_str ;
2760
0
}
2761
2762
int slash_yyget_debug  (yyscan_t yyscanner)
2763
0
{
2764
0
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2765
0
    return yy_flex_debug;
2766
0
}
2767
2768
void slash_yyset_debug (int  _bdebug , yyscan_t yyscanner)
2769
0
{
2770
0
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2771
0
    yy_flex_debug = _bdebug ;
2772
0
}
2773
2774
/* Accessor methods for yylval and yylloc */
2775
2776
YYSTYPE * slash_yyget_lval  (yyscan_t yyscanner)
2777
0
{
2778
0
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2779
0
    return yylval;
2780
0
}
2781
2782
void slash_yyset_lval (YYSTYPE *  yylval_param , yyscan_t yyscanner)
2783
0
{
2784
0
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2785
0
    yylval = yylval_param;
2786
0
}
2787
2788
/* User-visible API */
2789
2790
/* slash_yylex_init is special because it creates the scanner itself, so it is
2791
 * the ONLY reentrant function that doesn't take the scanner as the last argument.
2792
 * That's why we explicitly handle the declaration, instead of using our macros.
2793
 */
2794
int slash_yylex_init(yyscan_t* ptr_yy_globals)
2795
0
{
2796
0
    if (ptr_yy_globals == NULL){
2797
0
        errno = EINVAL;
2798
0
        return 1;
2799
0
    }
2800
2801
0
    *ptr_yy_globals = (yyscan_t) slash_yyalloc ( sizeof( struct yyguts_t ), NULL );
2802
2803
0
    if (*ptr_yy_globals == NULL){
2804
0
        errno = ENOMEM;
2805
0
        return 1;
2806
0
    }
2807
2808
    /* By setting to 0xAA, we expose bugs in yy_init_globals. Leave at 0x00 for releases. */
2809
0
    memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t));
2810
2811
0
    return yy_init_globals ( *ptr_yy_globals );
2812
0
}
2813
2814
/* slash_yylex_init_extra has the same functionality as slash_yylex_init, but follows the
2815
 * convention of taking the scanner as the last argument. Note however, that
2816
 * this is a *pointer* to a scanner, as it will be allocated by this call (and
2817
 * is the reason, too, why this function also must handle its own declaration).
2818
 * The user defined value in the first argument will be available to slash_yyalloc in
2819
 * the yyextra field.
2820
 */
2821
int slash_yylex_init_extra(YY_EXTRA_TYPE yy_user_defined,yyscan_t* ptr_yy_globals )
2822
0
{
2823
0
    struct yyguts_t dummy_yyguts;
2824
2825
0
    slash_yyset_extra (yy_user_defined, &dummy_yyguts);
2826
2827
0
    if (ptr_yy_globals == NULL){
2828
0
        errno = EINVAL;
2829
0
        return 1;
2830
0
    }
2831
2832
0
    *ptr_yy_globals = (yyscan_t) slash_yyalloc ( sizeof( struct yyguts_t ), &dummy_yyguts );
2833
2834
0
    if (*ptr_yy_globals == NULL){
2835
0
        errno = ENOMEM;
2836
0
        return 1;
2837
0
    }
2838
2839
    /* By setting to 0xAA, we expose bugs in
2840
    yy_init_globals. Leave at 0x00 for releases. */
2841
0
    memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t));
2842
2843
0
    slash_yyset_extra (yy_user_defined, *ptr_yy_globals);
2844
2845
0
    return yy_init_globals ( *ptr_yy_globals );
2846
0
}
2847
2848
static int yy_init_globals (yyscan_t yyscanner)
2849
0
{
2850
0
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2851
    /* Initialization is the same as for the non-reentrant scanner.
2852
     * This function is called from slash_yylex_destroy(), so don't allocate here.
2853
     */
2854
2855
0
    yyg->yy_buffer_stack = NULL;
2856
0
    yyg->yy_buffer_stack_top = 0;
2857
0
    yyg->yy_buffer_stack_max = 0;
2858
0
    yyg->yy_c_buf_p = NULL;
2859
0
    yyg->yy_init = 0;
2860
0
    yyg->yy_start = 0;
2861
2862
0
    yyg->yy_start_stack_ptr = 0;
2863
0
    yyg->yy_start_stack_depth = 0;
2864
0
    yyg->yy_start_stack =  NULL;
2865
2866
/* Defined in main.c */
2867
#ifdef YY_STDINIT
2868
    yyin = stdin;
2869
    yyout = stdout;
2870
#else
2871
0
    yyin = NULL;
2872
0
    yyout = NULL;
2873
0
#endif
2874
2875
    /* For future reference: Set errno on error, since we are called by
2876
     * slash_yylex_init()
2877
     */
2878
0
    return 0;
2879
0
}
2880
2881
/* slash_yylex_destroy is for both reentrant and non-reentrant scanners. */
2882
int slash_yylex_destroy  (yyscan_t yyscanner)
2883
0
{
2884
0
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2885
2886
    /* Pop the buffer stack, destroying each element. */
2887
0
  while(YY_CURRENT_BUFFER){
2888
0
    slash_yy_delete_buffer(YY_CURRENT_BUFFER ,yyscanner );
2889
0
    YY_CURRENT_BUFFER_LVALUE = NULL;
2890
0
    slash_yypop_buffer_state(yyscanner);
2891
0
  }
2892
2893
  /* Destroy the stack itself. */
2894
0
  slash_yyfree(yyg->yy_buffer_stack ,yyscanner);
2895
0
  yyg->yy_buffer_stack = NULL;
2896
2897
    /* Destroy the start condition stack. */
2898
0
        slash_yyfree(yyg->yy_start_stack ,yyscanner );
2899
0
        yyg->yy_start_stack = NULL;
2900
2901
    /* Reset the globals. This is important in a non-reentrant scanner so the next time
2902
     * slash_yylex() is called, initialization will occur. */
2903
0
    yy_init_globals( yyscanner);
2904
2905
    /* Destroy the main struct (reentrant only). */
2906
0
    slash_yyfree ( yyscanner , yyscanner );
2907
0
    yyscanner = NULL;
2908
0
    return 0;
2909
0
}
2910
2911
/*
2912
 * Internal utility routines.
2913
 */
2914
2915
#ifndef yytext_ptr
2916
static void yy_flex_strncpy (char* s1, const char * s2, int n , yyscan_t yyscanner)
2917
{
2918
  struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2919
  (void)yyg;
2920
2921
  int i;
2922
  for ( i = 0; i < n; ++i )
2923
    s1[i] = s2[i];
2924
}
2925
#endif
2926
2927
#ifdef YY_NEED_STRLEN
2928
static int yy_flex_strlen (const char * s , yyscan_t yyscanner)
2929
{
2930
  int n;
2931
  for ( n = 0; s[n]; ++n )
2932
    ;
2933
2934
  return n;
2935
}
2936
#endif
2937
2938
void *slash_yyalloc (yy_size_t  size , yyscan_t yyscanner)
2939
0
{
2940
0
  struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2941
0
  (void)yyg;
2942
0
  return malloc(size);
2943
0
}
2944
2945
void *slash_yyrealloc  (void * ptr, yy_size_t  size , yyscan_t yyscanner)
2946
0
{
2947
0
  struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2948
0
  (void)yyg;
2949
2950
  /* The cast to (char *) in the following accommodates both
2951
   * implementations that use char* generic pointers, and those
2952
   * that use void* generic pointers.  It works with the latter
2953
   * because both ANSI C and C++ allow castless assignment from
2954
   * any pointer type to void*, and deal with argument conversions
2955
   * as though doing an assignment.
2956
   */
2957
0
  return realloc(ptr, size);
2958
0
}
2959
2960
void slash_yyfree (void * ptr , yyscan_t yyscanner)
2961
0
{
2962
0
  struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2963
0
  (void)yyg;
2964
0
  free( (char *) ptr ); /* see slash_yyrealloc() for (char *) cast */
2965
0
}
2966
2967
#define YYTABLES_NAME "yytables"
2968
2969
#line 474 "psqlscanslash.l"
2970
2971
2972
/* LCOV_EXCL_STOP */
2973
2974
/*
2975
 * Scan the command name of a psql backslash command.  This should be called
2976
 * after psql_scan() returns PSCAN_BACKSLASH.  It is assumed that the input
2977
 * has been consumed through the leading backslash.
2978
 *
2979
 * The return value is a malloc'd copy of the command name, as parsed off
2980
 * from the input.
2981
 */
2982
char *
2983
psql_scan_slash_command(PsqlScanState state)
2984
60
{
2985
60
  PQExpBufferData mybuf;
2986
2987
  /* Must be scanning already */
2988
60
  Assert(state->scanbufhandle != NULL);
2989
2990
  /* Build a local buffer that we'll return the data of */
2991
0
  initPQExpBuffer(&mybuf);
2992
2993
  /* Set current output target */
2994
60
  state->output_buf = &mybuf;
2995
2996
  /* Set input source */
2997
60
  if (state->buffer_stack != NULL)
2998
0
    yy_switch_to_buffer(state->buffer_stack->buf, state->scanner);
2999
60
  else
3000
60
    yy_switch_to_buffer(state->scanbufhandle, state->scanner);
3001
3002
  /*
3003
   * Set lexer start state.  Note that this is sufficient to switch
3004
   * state->scanner over to using the tables in this lexer file.
3005
   */
3006
60
  state->start_state = xslashcmd;
3007
3008
  /* And lex. */
3009
60
  yylex(NULL, state->scanner);
3010
3011
  /* There are no possible errors in this lex state... */
3012
3013
  /*
3014
   * In case the caller returns to using the regular SQL lexer, reselect the
3015
   * appropriate initial state.
3016
   */
3017
60
  psql_scan_reselect_sql_lexer(state);
3018
3019
60
  return mybuf.data;
3020
60
}
3021
3022
/*
3023
 * Parse off the next argument for a backslash command, and return it as a
3024
 * malloc'd string.  If there are no more arguments, returns NULL.
3025
 *
3026
 * type tells what processing, if any, to perform on the option string;
3027
 * for example, if it's a SQL identifier, we want to downcase any unquoted
3028
 * letters.
3029
 *
3030
 * if quote is not NULL, *quote is set to 0 if no quoting was found, else
3031
 * the last quote symbol used in the argument.
3032
 *
3033
 * if semicolon is true, unquoted trailing semicolon(s) that would otherwise
3034
 * be taken as part of the option string will be stripped.
3035
 *
3036
 * NOTE: the only possible syntax errors for backslash options are unmatched
3037
 * quotes, which are detected when we run out of input.  Therefore, on a
3038
 * syntax error we just throw away the string and return NULL; there is no
3039
 * need to worry about flushing remaining input.
3040
 */
3041
char *
3042
psql_scan_slash_option(PsqlScanState state,
3043
             enum slash_option_type type,
3044
             char *quote,
3045
             bool semicolon)
3046
158
{
3047
158
  PQExpBufferData mybuf;
3048
158
  int     lexresult PG_USED_FOR_ASSERTS_ONLY;
3049
158
  int     final_state;
3050
158
  char    local_quote;
3051
3052
  /* Must be scanning already */
3053
158
  Assert(state->scanbufhandle != NULL);
3054
3055
158
  if (quote == NULL)
3056
122
    quote = &local_quote;
3057
158
  *quote = 0;
3058
3059
  /* Build a local buffer that we'll return the data of */
3060
158
  initPQExpBuffer(&mybuf);
3061
3062
  /* Set up static variables that will be used by yylex */
3063
158
  option_type = type;
3064
158
  option_quote = quote;
3065
158
  unquoted_option_chars = 0;
3066
3067
  /* Set current output target */
3068
158
  state->output_buf = &mybuf;
3069
3070
  /* Set input source */
3071
158
  if (state->buffer_stack != NULL)
3072
0
    yy_switch_to_buffer(state->buffer_stack->buf, state->scanner);
3073
158
  else
3074
158
    yy_switch_to_buffer(state->scanbufhandle, state->scanner);
3075
3076
  /* Set lexer start state */
3077
158
  if (type == OT_WHOLE_LINE)
3078
10
    state->start_state = xslashwholeline;
3079
148
  else
3080
148
    state->start_state = xslashargstart;
3081
3082
  /* And lex. */
3083
158
  lexresult = yylex(NULL, state->scanner);
3084
3085
  /* Save final state for a moment... */
3086
158
  final_state = state->start_state;
3087
3088
  /*
3089
   * In case the caller returns to using the regular SQL lexer, reselect the
3090
   * appropriate initial state.
3091
   */
3092
158
  psql_scan_reselect_sql_lexer(state);
3093
3094
  /*
3095
   * Check the lex result: we should have gotten back either LEXRES_OK
3096
   * or LEXRES_EOL (the latter indicating end of string).  If we were inside
3097
   * a quoted string, as indicated by final_state, EOL is an error.
3098
   */
3099
158
  Assert(lexresult == LEXRES_EOL || lexresult == LEXRES_OK);
3100
3101
0
  switch (final_state)
3102
158
  {
3103
97
    case xslashargstart:
3104
      /* empty arg */
3105
97
      break;
3106
51
    case xslasharg:
3107
      /* Strip any unquoted trailing semi-colons if requested */
3108
51
      if (semicolon)
3109
36
      {
3110
36
        while (unquoted_option_chars-- > 0 &&
3111
36
             mybuf.len > 0 &&
3112
36
             mybuf.data[mybuf.len - 1] == ';')
3113
0
        {
3114
0
          mybuf.data[--mybuf.len] = '\0';
3115
0
        }
3116
36
      }
3117
3118
      /*
3119
       * If SQL identifier processing was requested, then we strip out
3120
       * excess double quotes and optionally downcase unquoted letters.
3121
       */
3122
51
      if (type == OT_SQLID || type == OT_SQLIDHACK)
3123
9
      {
3124
9
        dequote_downcase_identifier(mybuf.data,
3125
9
                      (type != OT_SQLIDHACK),
3126
9
                      state->encoding);
3127
        /* update mybuf.len for possible shortening */
3128
9
        mybuf.len = strlen(mybuf.data);
3129
9
      }
3130
51
      break;
3131
0
    case xslashquote:
3132
0
    case xslashbackquote:
3133
0
    case xslashdquote:
3134
      /* must have hit EOL inside quotes */
3135
0
      state->callbacks->write_error("unterminated quoted string\n");
3136
0
      termPQExpBuffer(&mybuf);
3137
0
      return NULL;
3138
10
    case xslashwholeline:
3139
      /* always okay */
3140
10
      break;
3141
0
    default:
3142
      /* can't get here */
3143
0
      fprintf(stderr, "invalid YY_START\n");
3144
0
      exit(1);
3145
158
  }
3146
3147
  /*
3148
   * An unquoted empty argument isn't possible unless we are at end of
3149
   * command.  Return NULL instead.
3150
   */
3151
158
  if (mybuf.len == 0 && 
*quote == 0100
)
3152
100
  {
3153
100
    termPQExpBuffer(&mybuf);
3154
100
    return NULL;
3155
100
  }
3156
3157
  /* Else return the completed string. */
3158
58
  return mybuf.data;
3159
158
}
3160
3161
/*
3162
 * Eat up any unused \\ to complete a backslash command.
3163
 */
3164
void
3165
psql_scan_slash_command_end(PsqlScanState state)
3166
60
{
3167
  /* Must be scanning already */
3168
60
  Assert(state->scanbufhandle != NULL);
3169
3170
  /* Set current output target */
3171
0
  state->output_buf = NULL; /* we won't output anything */
3172
3173
  /* Set input source */
3174
60
  if (state->buffer_stack != NULL)
3175
0
    yy_switch_to_buffer(state->buffer_stack->buf, state->scanner);
3176
60
  else
3177
60
    yy_switch_to_buffer(state->scanbufhandle, state->scanner);
3178
3179
  /* Set lexer start state */
3180
60
  state->start_state = xslashend;
3181
3182
  /* And lex. */
3183
60
  yylex(NULL, state->scanner);
3184
3185
  /* There are no possible errors in this lex state... */
3186
3187
  /*
3188
   * We expect the caller to return to using the regular SQL lexer, so
3189
   * reselect the appropriate initial state.
3190
   */
3191
60
  psql_scan_reselect_sql_lexer(state);
3192
60
}
3193
3194
/*
3195
 * Fetch current paren nesting depth
3196
 */
3197
int
3198
psql_scan_get_paren_depth(PsqlScanState state)
3199
0
{
3200
0
  return state->paren_depth;
3201
0
}
3202
3203
/*
3204
 * Set paren nesting depth
3205
 */
3206
void
3207
psql_scan_set_paren_depth(PsqlScanState state, int depth)
3208
0
{
3209
0
  Assert(depth >= 0);
3210
0
  state->paren_depth = depth;
3211
0
}
3212
3213
/*
3214
 * De-quote and optionally downcase a SQL identifier.
3215
 *
3216
 * The string at *str is modified in-place; it can become shorter,
3217
 * but not longer.
3218
 *
3219
 * If downcase is true then non-quoted letters are folded to lower case.
3220
 * Ideally this behavior will match the backend's downcase_identifier();
3221
 * but note that it could differ if LC_CTYPE is different in the frontend.
3222
 *
3223
 * Note that a string like FOO"BAR"BAZ will be converted to fooBARbaz;
3224
 * this is somewhat inconsistent with the SQL spec, which would have us
3225
 * parse it as several identifiers.  But for psql's purposes, we want a
3226
 * string like "foo"."bar" to be treated as one option, so there's little
3227
 * choice; this routine doesn't get to change the token boundaries.
3228
 */
3229
void
3230
dequote_downcase_identifier(char *str, bool downcase, int encoding)
3231
9
{
3232
9
  bool    inquotes = false;
3233
9
  char     *cp = str;
3234
3235
64
  while (*cp)
3236
55
  {
3237
55
    if (*cp == '"')
3238
0
    {
3239
0
      if (inquotes && cp[1] == '"')
3240
0
      {
3241
        /* Keep the first quote, remove the second */
3242
0
        cp++;
3243
0
      }
3244
0
      else
3245
0
        inquotes = !inquotes;
3246
      /* Collapse out quote at *cp */
3247
0
      memmove(cp, cp + 1, strlen(cp));
3248
      /* do not advance cp */
3249
0
    }
3250
55
    else
3251
55
    {
3252
55
      if (downcase && 
!inquotes0
)
3253
0
        *cp = pg_tolower((unsigned char) *cp);
3254
55
      cp += PQmblenBounded(cp, encoding);
3255
55
    }
3256
55
  }
3257
9
}
3258
3259
/*
3260
 * Evaluate a backticked substring of a slash command's argument.
3261
 *
3262
 * The portion of output_buf starting at backtick_start_offset is evaluated
3263
 * as a shell command and then replaced by the command's output.
3264
 */
3265
static void
3266
evaluate_backtick(PsqlScanState state)
3267
0
{
3268
0
  PQExpBuffer output_buf = state->output_buf;
3269
0
  char     *cmd = output_buf->data + backtick_start_offset;
3270
0
  PQExpBufferData cmd_output;
3271
0
  FILE     *fd;
3272
0
  bool    error = false;
3273
0
  char    buf[512];
3274
0
  size_t    result;
3275
3276
0
  initPQExpBuffer(&cmd_output);
3277
3278
0
  fd = popen(cmd, PG_BINARY_R);
3279
0
  if (!fd)
3280
0
  {
3281
0
    state->callbacks->write_error("%s: %s\n", cmd, strerror(errno));
3282
0
    error = true;
3283
0
  }
3284
3285
0
  if (!error)
3286
0
  {
3287
0
    do
3288
0
    {
3289
0
      result = fread(buf, 1, sizeof(buf), fd);
3290
0
      if (ferror(fd))
3291
0
      {
3292
0
        state->callbacks->write_error("%s: %s\n", cmd, strerror(errno));
3293
0
        error = true;
3294
0
        break;
3295
0
      }
3296
0
      appendBinaryPQExpBuffer(&cmd_output, buf, result);
3297
0
    } while (!feof(fd));
3298
0
  }
3299
3300
0
  if (fd && pclose(fd) == -1)
3301
0
  {
3302
0
    state->callbacks->write_error("%s: %s\n", cmd, strerror(errno));
3303
0
    error = true;
3304
0
  }
3305
3306
0
  if (PQExpBufferDataBroken(cmd_output))
3307
0
  {
3308
0
    state->callbacks->write_error("%s: out of memory\n", cmd);
3309
0
    error = true;
3310
0
  }
3311
3312
  /* Now done with cmd, delete it from output_buf */
3313
0
  output_buf->len = backtick_start_offset;
3314
0
  output_buf->data[output_buf->len] = '\0';
3315
3316
  /* If no error, transfer result to output_buf */
3317
0
  if (!error)
3318
0
  {
3319
    /* strip any trailing newline */
3320
0
    if (cmd_output.len > 0 &&
3321
0
      cmd_output.data[cmd_output.len - 1] == '\n')
3322
0
      cmd_output.len--;
3323
0
    appendBinaryPQExpBuffer(output_buf, cmd_output.data, cmd_output.len);
3324
0
  }
3325
3326
0
  termPQExpBuffer(&cmd_output);
3327
0
}
3328