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