GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: lib/libkeynote/lex.kn.c Lines: 0 354 0.0 %
Date: 2017-11-07 Branches: 0 237 0.0 %

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