GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: usr.bin/keynote/lex.kv.c Lines: 0 314 0.0 %
Date: 2017-11-13 Branches: 0 221 0.0 %

Line Branch Exec Source
1
2
#line 3 "lex.kv.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 kv_create_buffer
11
#define yy_delete_buffer kv_delete_buffer
12
#define yy_flex_debug kv_flex_debug
13
#define yy_init_buffer kv_init_buffer
14
#define yy_flush_buffer kv_flush_buffer
15
#define yy_load_buffer_state kv_load_buffer_state
16
#define yy_switch_to_buffer kv_switch_to_buffer
17
#define yyin kvin
18
#define yyleng kvleng
19
#define yylex kvlex
20
#define yylineno kvlineno
21
#define yyout kvout
22
#define yyrestart kvrestart
23
#define yytext kvtext
24
#define yywrap kvwrap
25
#define yyalloc kvalloc
26
#define yyrealloc kvrealloc
27
#define yyfree kvfree
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 kvrestart(kvin  )
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 kvleng;
185
186
extern FILE *kvin, *kvout;
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 kvlex.
195
     *       One obvious solution it to make yy_act a global. I tried that, and saw
196
     *       a 5% performance hit in a non-kvlineno 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 < kvleng; ++yyl )\
203
                    if ( kvtext[yyl] == '\n' )\
204
                        --kvlineno;\
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
                        --kvlineno;\
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 kvtext. */ \
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 kvtext 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 kvrestart()), so that the user can continue scanning by
288
	 * just pointing kvin 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 kvtext 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 kvleng;
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 kvwrap()'s to do buffer switches
326
 * instead of setting up a fresh kvin.  A bit of a hack ...
327
 */
328
static int yy_did_buffer_switch_on_eof;
329
330
void kvrestart (FILE *input_file  );
331
void kv_switch_to_buffer (YY_BUFFER_STATE new_buffer  );
332
YY_BUFFER_STATE kv_create_buffer (FILE *file,int size  );
333
void kv_delete_buffer (YY_BUFFER_STATE b  );
334
void kv_flush_buffer (YY_BUFFER_STATE b  );
335
void kvpush_buffer_state (YY_BUFFER_STATE new_buffer  );
336
void kvpop_buffer_state (void );
337
338
static void kvensure_buffer_stack (void );
339
static void kv_load_buffer_state (void );
340
static void kv_init_buffer (YY_BUFFER_STATE b,FILE *file  );
341
342
#define YY_FLUSH_BUFFER kv_flush_buffer(YY_CURRENT_BUFFER )
343
344
YY_BUFFER_STATE kv_scan_buffer (char *base,yy_size_t size  );
345
YY_BUFFER_STATE kv_scan_string (yyconst char *yy_str  );
346
YY_BUFFER_STATE kv_scan_bytes (yyconst char *bytes,yy_size_t len  );
347
348
void *kvalloc (yy_size_t  );
349
void *kvrealloc (void *,yy_size_t  );
350
void kvfree (void *  );
351
352
#define yy_new_buffer kv_create_buffer
353
354
#define yy_set_interactive(is_interactive) \
355
	{ \
356
	if ( ! YY_CURRENT_BUFFER ){ \
357
        kvensure_buffer_stack (); \
358
		YY_CURRENT_BUFFER_LVALUE =    \
359
            kv_create_buffer(kvin,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
        kvensure_buffer_stack (); \
368
		YY_CURRENT_BUFFER_LVALUE =    \
369
            kv_create_buffer(kvin,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 kvwrap() 1
379
#define YY_SKIP_YYWRAP
380
381
typedef unsigned char YY_CHAR;
382
383
FILE *kvin = (FILE *) 0, *kvout = (FILE *) 0;
384
385
typedef int yy_state_type;
386
387
extern int kvlineno;
388
389
int kvlineno = 1;
390
391
extern char *kvtext;
392
#define yytext_ptr kvtext
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 kvtext.
401
 */
402
#define YY_DO_BEFORE_ACTION \
403
	(yytext_ptr) = yy_bp; \
404
	kvleng = (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 7
410
#define YY_END_OF_BUFFER 8
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[23] =
419
    {   0,
420
        8,    6,    7,    5,    6,    7,    5,    7,    4,    6,
421
        7,    2,    6,    7,    1,    6,    7,    6,    7,    4,
422
        2,    3
423
    } ;
424
425
static yyconst flex_int16_t yy_accept[27] =
426
    {   0,
427
        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
428
        1,    2,    4,    7,    9,   12,   15,   18,   20,   21,
429
       22,   22,   23,   23,   23,   23
430
    } ;
431
432
static yyconst flex_int32_t yy_ec[256] =
433
    {   0,
434
        1,    1,    1,    1,    1,    1,    1,    1,    2,    3,
435
        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
436
        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
437
        1,    2,    1,    4,    5,    1,    1,    1,    1,    1,
438
        1,    1,    1,    1,    1,    1,    1,    6,    6,    6,
439
        6,    6,    6,    6,    6,    6,    6,    1,    1,    1,
440
        7,    1,    1,    1,    6,    6,    6,    6,    6,    6,
441
        6,    6,    6,    6,    6,    6,    6,    6,    6,    6,
442
        6,    6,    6,    6,    6,    6,    6,    6,    6,    6,
443
        1,    8,    1,    1,    9,    1,    6,    6,    6,    6,
444
445
        6,    6,    6,    6,    6,    6,    6,    6,    6,    6,
446
        6,    6,    6,    6,    6,    6,    6,    6,    6,    6,
447
        6,    6,    1,    1,    1,    1,    1,    1,    1,    1,
448
        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
449
        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
450
        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
451
        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
452
        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
453
        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
454
        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
455
456
        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
457
        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
458
        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
459
        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
460
        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
461
        1,    1,    1,    1,    1
462
    } ;
463
464
static yyconst flex_int32_t yy_meta[10] =
465
    {   0,
466
        1,    1,    2,    1,    1,    3,    1,    1,    3
467
    } ;
468
469
static yyconst flex_int16_t yy_base[30] =
470
    {   0,
471
        0,    2,    1,    0,   11,   10,   12,    9,    4,    0,
472
       12,   35,   35,   35,    0,    0,   35,    6,    0,    0,
473
       11,   35,   17,    0,   35,   25,   28,    8,   31
474
    } ;
475
476
static yyconst flex_int16_t yy_def[30] =
477
    {   0,
478
       26,   26,    2,    3,    2,    2,    2,    2,    2,    9,
479
       25,   25,   25,   25,   27,   28,   25,   29,   27,   28,
480
       29,   25,   29,   21,    0,   25,   25,   25,   25
481
    } ;
482
483
static yyconst flex_int16_t yy_nxt[45] =
484
    {   0,
485
       25,   13,   14,   13,   14,   15,   16,   18,   15,   22,
486
       20,   25,   18,   23,   22,   18,   17,   17,   23,   21,
487
       25,   25,   25,   25,   24,   12,   12,   12,   19,   25,
488
       19,   21,   25,   21,   11,   25,   25,   25,   25,   25,
489
       25,   25,   25,   25
490
    } ;
491
492
static yyconst flex_int16_t yy_chk[45] =
493
    {   0,
494
        0,    1,    1,    2,    2,    3,    3,    9,    9,   18,
495
       28,   11,    8,   18,   21,    7,    6,    5,   21,   23,
496
        0,    0,    0,    0,   23,   26,   26,   26,   27,    0,
497
       27,   29,    0,   29,   25,   25,   25,   25,   25,   25,
498
       25,   25,   25,   25
499
    } ;
500
501
/* Table of booleans, true if rule could match eol. */
502
static yyconst flex_int32_t yy_rule_can_match_eol[8] =
503
    {   0,
504
0, 0, 1, 0, 1, 0, 0,     };
505
506
extern int kv_flex_debug;
507
int kv_flex_debug = 0;
508
509
static yy_state_type *yy_state_buf=0, *yy_state_ptr=0;
510
static char *yy_full_match;
511
static int yy_lp;
512
#define REJECT \
513
{ \
514
*yy_cp = (yy_hold_char); /* undo effects of setting up kvtext */ \
515
yy_cp = (yy_full_match); /* restore poss. backed-over text */ \
516
++(yy_lp); \
517
goto find_rule; \
518
}
519
520
#define yymore() yymore_used_but_not_detected
521
#define YY_MORE_ADJ 0
522
#define YY_RESTORE_YY_MORE_OFFSET
523
char *kvtext;
524
#line 1 "/usr/src/usr.bin/keynote/../../lib/libkeynote/keynote-ver.l"
525
#line 2 "/usr/src/usr.bin/keynote/../../lib/libkeynote/keynote-ver.l"
526
/* $OpenBSD: keynote-ver.l,v 1.20 2017/08/28 17:07:19 millert Exp $ */
527
/*
528
 * The author of this code is Angelos D. Keromytis (angelos@dsl.cis.upenn.edu)
529
 *
530
 * This code was written by Angelos D. Keromytis in Philadelphia, PA, USA,
531
 * in April-May 1998
532
 *
533
 * Copyright (C) 1998, 1999 by Angelos D. Keromytis.
534
 *
535
 * Permission to use, copy, and modify this software with or without fee
536
 * is hereby granted, provided that this entire notice is included in
537
 * all copies of any software which is or includes a copy or
538
 * modification of this software.
539
 *
540
 * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR
541
 * IMPLIED WARRANTY. IN PARTICULAR, THE AUTHORS MAKES NO
542
 * REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE
543
 * MERCHANTABILITY OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR
544
 * PURPOSE.
545
 */
546
547
#include <sys/time.h>
548
#include <sys/types.h>
549
550
#include <ctype.h>
551
#include <regex.h>
552
#include <string.h>
553
#include <time.h>
554
#include <unistd.h>
555
556
#include "z.tab.h"
557
#include "header.h"
558
#include "keynote.h"
559
560
static void mystrncpy(char *, char *, int);
561
562
#define YY_NO_INPUT 1
563
#line 564 "lex.kv.c"
564
565
#define INITIAL 0
566
#define FIRSTPART 1
567
#define MIDDLEPART 2
568
#define SECONDPART 3
569
#define KEYSTATE 4
570
571
#ifndef YY_NO_UNISTD_H
572
/* Special case for "unistd.h", since it is non-ANSI. We include it way
573
 * down here because we want the user's section 1 to have been scanned first.
574
 * The user has a chance to override it with an option.
575
 */
576
#include <unistd.h>
577
#endif
578
579
#ifndef YY_EXTRA_TYPE
580
#define YY_EXTRA_TYPE void *
581
#endif
582
583
static int yy_init_globals (void );
584
585
/* Accessor methods to globals.
586
   These are made visible to non-reentrant scanners for convenience. */
587
588
int kvlex_destroy (void );
589
590
int kvget_debug (void );
591
592
void kvset_debug (int debug_flag  );
593
594
YY_EXTRA_TYPE kvget_extra (void );
595
596
void kvset_extra (YY_EXTRA_TYPE user_defined  );
597
598
FILE *kvget_in (void );
599
600
void kvset_in  (FILE * in_str  );
601
602
FILE *kvget_out (void );
603
604
void kvset_out  (FILE * out_str  );
605
606
yy_size_t kvget_leng (void );
607
608
char *kvget_text (void );
609
610
int kvget_lineno (void );
611
612
void kvset_lineno (int line_number  );
613
614
/* Macros after this point can all be overridden by user definitions in
615
 * section 1.
616
 */
617
618
#ifndef YY_SKIP_YYWRAP
619
#ifdef __cplusplus
620
extern "C" int kvwrap (void );
621
#else
622
extern int kvwrap (void );
623
#endif
624
#endif
625
626
    static void yyunput (int c,char *buf_ptr  );
627
628
#ifndef yytext_ptr
629
static void yy_flex_strncpy (char *,yyconst char *,int );
630
#endif
631
632
#ifdef YY_NEED_STRLEN
633
static int yy_flex_strlen (yyconst char * );
634
#endif
635
636
#ifndef YY_NO_INPUT
637
638
#ifdef __cplusplus
639
static int yyinput (void );
640
#else
641
static int input (void );
642
#endif
643
644
#endif
645
646
/* Amount of stuff to slurp up with each read. */
647
#ifndef YY_READ_BUF_SIZE
648
#define YY_READ_BUF_SIZE 8192
649
#endif
650
651
/* Copy whatever the last rule matched to the standard output. */
652
#ifndef ECHO
653
/* This used to be an fputs(), but since the string might contain NUL's,
654
 * we now use fwrite().
655
 */
656
#define ECHO do { if (fwrite( kvtext, kvleng, 1, kvout )) {} } while (0)
657
#endif
658
659
/* Gets input and stuffs it into "buf".  number of characters read, or YY_NULL,
660
 * is returned in "result".
661
 */
662
#ifndef YY_INPUT
663
#define YY_INPUT(buf,result,max_size) \
664
	if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
665
		{ \
666
		int c = '*'; \
667
		size_t n; \
668
		for ( n = 0; n < max_size && \
669
			     (c = getc( kvin )) != EOF && c != '\n'; ++n ) \
670
			buf[n] = (char) c; \
671
		if ( c == '\n' ) \
672
			buf[n++] = (char) c; \
673
		if ( c == EOF && ferror( kvin ) ) \
674
			YY_FATAL_ERROR( "input in flex scanner failed" ); \
675
		result = n; \
676
		} \
677
	else \
678
		{ \
679
		errno=0; \
680
		while ( (result = fread(buf, 1, max_size, kvin))==0 && ferror(kvin)) \
681
			{ \
682
			if( errno != EINTR) \
683
				{ \
684
				YY_FATAL_ERROR( "input in flex scanner failed" ); \
685
				break; \
686
				} \
687
			errno=0; \
688
			clearerr(kvin); \
689
			} \
690
		}\
691
\
692
693
#endif
694
695
/* No semi-colon after return; correct usage is to write "yyterminate();" -
696
 * we don't want an extra ';' after the "return" because that will cause
697
 * some compilers to complain about unreachable statements.
698
 */
699
#ifndef yyterminate
700
#define yyterminate() return YY_NULL
701
#endif
702
703
/* Number of entries by which start-condition stack grows. */
704
#ifndef YY_START_STACK_INCR
705
#define YY_START_STACK_INCR 25
706
#endif
707
708
/* Report a fatal error. */
709
#ifndef YY_FATAL_ERROR
710
#define YY_FATAL_ERROR(msg) yy_fatal_error( msg )
711
#endif
712
713
/* end tables serialization structures and prototypes */
714
715
/* Default declaration of generated scanner - a define so the user can
716
 * easily add parameters.
717
 */
718
#ifndef YY_DECL
719
#define YY_DECL_IS_OURS 1
720
721
extern int kvlex (void);
722
723
#define YY_DECL int kvlex (void)
724
#endif /* !YY_DECL */
725
726
/* Code executed at the beginning of each rule, after kvtext and kvleng
727
 * have been set up.
728
 */
729
#ifndef YY_USER_ACTION
730
#define YY_USER_ACTION
731
#endif
732
733
/* Code executed at the end of each rule. */
734
#ifndef YY_BREAK
735
#define YY_BREAK break;
736
#endif
737
738
#define YY_RULE_SETUP \
739
	YY_USER_ACTION
740
741
/** The main scanner function which does all the work.
742
 */
743
YY_DECL
744
{
745
	yy_state_type yy_current_state;
746
	char *yy_cp, *yy_bp;
747
	int yy_act;
748
749
	if ( !(yy_init) )
750
		{
751
		(yy_init) = 1;
752
753
#ifdef YY_USER_INIT
754
		YY_USER_INIT;
755
#endif
756
757
        /* Create the reject buffer large enough to save one state per allowed character. */
758
        if ( ! (yy_state_buf) )
759
            (yy_state_buf) = (yy_state_type *)kvalloc(YY_STATE_BUF_SIZE  );
760
            if ( ! (yy_state_buf) )
761
                YY_FATAL_ERROR( "out of dynamic memory in kvlex()" );
762
763
		if ( ! (yy_start) )
764
			(yy_start) = 1;	/* first start state */
765
766
		if ( ! kvin )
767
			kvin = stdin;
768
769
		if ( ! kvout )
770
			kvout = stdout;
771
772
		if ( ! YY_CURRENT_BUFFER ) {
773
			kvensure_buffer_stack ();
774
			YY_CURRENT_BUFFER_LVALUE =
775
				kv_create_buffer(kvin,YY_BUF_SIZE );
776
		}
777
778
		kv_load_buffer_state( );
779
		}
780
781
	{
782
#line 44 "/usr/src/usr.bin/keynote/../../lib/libkeynote/keynote-ver.l"
783
784
785
#line 786 "lex.kv.c"
786
787
	while ( 1 )		/* loops until end-of-file is reached */
788
		{
789
		yy_cp = (yy_c_buf_p);
790
791
		/* Support of kvtext. */
792
		*yy_cp = (yy_hold_char);
793
794
		/* yy_bp points to the position in yy_ch_buf of the start of
795
		 * the current run.
796
		 */
797
		yy_bp = yy_cp;
798
799
		yy_current_state = (yy_start);
800
801
		(yy_state_ptr) = (yy_state_buf);
802
		*(yy_state_ptr)++ = yy_current_state;
803
804
yy_match:
805
		do
806
			{
807
			YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)] ;
808
			while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
809
				{
810
				yy_current_state = (int) yy_def[yy_current_state];
811
				if ( yy_current_state >= 26 )
812
					yy_c = yy_meta[(unsigned int) yy_c];
813
				}
814
			yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
815
			*(yy_state_ptr)++ = yy_current_state;
816
			++yy_cp;
817
			}
818
		while ( yy_current_state != 25 );
819
820
yy_find_action:
821
		yy_current_state = *--(yy_state_ptr);
822
		(yy_lp) = yy_accept[yy_current_state];
823
find_rule: /* we branch to this label when backing up */
824
		for ( ; ; ) /* until we find what rule we matched */
825
			{
826
			if ( (yy_lp) && (yy_lp) < yy_accept[yy_current_state + 1] )
827
				{
828
				yy_act = yy_acclist[(yy_lp)];
829
					{
830
					(yy_full_match) = yy_cp;
831
					break;
832
					}
833
				}
834
			--yy_cp;
835
			yy_current_state = *--(yy_state_ptr);
836
			(yy_lp) = yy_accept[yy_current_state];
837
			}
838
839
		YY_DO_BEFORE_ACTION;
840
841
		if ( yy_act != YY_END_OF_BUFFER && yy_rule_can_match_eol[yy_act] )
842
			{
843
			yy_size_t yyl;
844
			for ( yyl = 0; yyl < kvleng; ++yyl )
845
				if ( kvtext[yyl] == '\n' )
846
847
    kvlineno++;
848
;
849
			}
850
851
do_action:	/* This label is used only to access EOF actions. */
852
853
		switch ( yy_act )
854
	{ /* beginning of action switch */
855
case 1:
856
YY_RULE_SETUP
857
#line 46 "/usr/src/usr.bin/keynote/../../lib/libkeynote/keynote-ver.l"
858
{
859
				BEGIN(SECONDPART);
860
			        return EQ;
861
			      }
862
	YY_BREAK
863
case 2:
864
YY_RULE_SETUP
865
#line 50 "/usr/src/usr.bin/keynote/../../lib/libkeynote/keynote-ver.l"
866
{
867
				int len = strlen(kvtext) + 1;
868
				kvlval.s.string = calloc(len, sizeof(char));
869
                                if (kvlval.s.string == NULL) {
870
				    keynote_errno = ERROR_MEMORY;
871
				    return -1;
872
				}
873
				strlcpy(kvlval.s.string, kvtext, len);
874
				BEGIN(MIDDLEPART);
875
                                return VSTRING;
876
                              }
877
	YY_BREAK
878
case 3:
879
/* rule 3 can match eol */
880
YY_RULE_SETUP
881
#line 61 "/usr/src/usr.bin/keynote/../../lib/libkeynote/keynote-ver.l"
882
{ kvlval.s.string = calloc(strlen(kvtext) - 1,
883
				  		         sizeof(char));
884
                                   if (kvlval.s.string == NULL) {
885
				       keynote_errno = ERROR_MEMORY;
886
				       return -1;
887
				   }
888
				   mystrncpy(kvlval.s.string, kvtext + 1,
889
					     strlen(kvtext) - 2);
890
				   BEGIN(FIRSTPART);
891
				   return STRING;
892
                                 }
893
	YY_BREAK
894
case 4:
895
YY_RULE_SETUP
896
#line 72 "/usr/src/usr.bin/keynote/../../lib/libkeynote/keynote-ver.l"
897
;
898
	YY_BREAK
899
case 5:
900
/* rule 5 can match eol */
901
YY_RULE_SETUP
902
#line 73 "/usr/src/usr.bin/keynote/../../lib/libkeynote/keynote-ver.l"
903
;
904
	YY_BREAK
905
case 6:
906
YY_RULE_SETUP
907
#line 74 "/usr/src/usr.bin/keynote/../../lib/libkeynote/keynote-ver.l"
908
{ keynote_errno = ERROR_SYNTAX; return -1; REJECT; }
909
	YY_BREAK
910
case 7:
911
YY_RULE_SETUP
912
#line 76 "/usr/src/usr.bin/keynote/../../lib/libkeynote/keynote-ver.l"
913
YY_FATAL_ERROR( "flex scanner jammed" );
914
	YY_BREAK
915
#line 916 "lex.kv.c"
916
			case YY_STATE_EOF(INITIAL):
917
			case YY_STATE_EOF(FIRSTPART):
918
			case YY_STATE_EOF(MIDDLEPART):
919
			case YY_STATE_EOF(SECONDPART):
920
			case YY_STATE_EOF(KEYSTATE):
921
				yyterminate();
922
923
	case YY_END_OF_BUFFER:
924
		{
925
		/* Amount of text matched not including the EOB char. */
926
		int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1;
927
928
		/* Undo the effects of YY_DO_BEFORE_ACTION. */
929
		*yy_cp = (yy_hold_char);
930
		YY_RESTORE_YY_MORE_OFFSET
931
932
		if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW )
933
			{
934
			/* We're scanning a new file or input source.  It's
935
			 * possible that this happened because the user
936
			 * just pointed kvin at a new source and called
937
			 * kvlex().  If so, then we have to assure
938
			 * consistency between YY_CURRENT_BUFFER and our
939
			 * globals.  Here is the right place to do so, because
940
			 * this is the first action (other than possibly a
941
			 * back-up) that will match for the new input source.
942
			 */
943
			(yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
944
			YY_CURRENT_BUFFER_LVALUE->yy_input_file = kvin;
945
			YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL;
946
			}
947
948
		/* Note that here we test for yy_c_buf_p "<=" to the position
949
		 * of the first EOB in the buffer, since yy_c_buf_p will
950
		 * already have been incremented past the NUL character
951
		 * (since all states make transitions on EOB to the
952
		 * end-of-buffer state).  Contrast this with the test
953
		 * in input().
954
		 */
955
		if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
956
			{ /* This was really a NUL. */
957
			yy_state_type yy_next_state;
958
959
			(yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text;
960
961
			yy_current_state = yy_get_previous_state(  );
962
963
			/* Okay, we're now positioned to make the NUL
964
			 * transition.  We couldn't have
965
			 * yy_get_previous_state() go ahead and do it
966
			 * for us because it doesn't know how to deal
967
			 * with the possibility of jamming (and we don't
968
			 * want to build jamming into it because then it
969
			 * will run more slowly).
970
			 */
971
972
			yy_next_state = yy_try_NUL_trans( yy_current_state );
973
974
			yy_bp = (yytext_ptr) + YY_MORE_ADJ;
975
976
			if ( yy_next_state )
977
				{
978
				/* Consume the NUL. */
979
				yy_cp = ++(yy_c_buf_p);
980
				yy_current_state = yy_next_state;
981
				goto yy_match;
982
				}
983
984
			else
985
				{
986
				yy_cp = (yy_c_buf_p);
987
				goto yy_find_action;
988
				}
989
			}
990
991
		else switch ( yy_get_next_buffer(  ) )
992
			{
993
			case EOB_ACT_END_OF_FILE:
994
				{
995
				(yy_did_buffer_switch_on_eof) = 0;
996
997
				if ( kvwrap( ) )
998
					{
999
					/* Note: because we've taken care in
1000
					 * yy_get_next_buffer() to have set up
1001
					 * kvtext, we can now set up
1002
					 * yy_c_buf_p so that if some total
1003
					 * hoser (like flex itself) wants to
1004
					 * call the scanner after we return the
1005
					 * YY_NULL, it'll still work - another
1006
					 * YY_NULL will get returned.
1007
					 */
1008
					(yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ;
1009
1010
					yy_act = YY_STATE_EOF(YY_START);
1011
					goto do_action;
1012
					}
1013
1014
				else
1015
					{
1016
					if ( ! (yy_did_buffer_switch_on_eof) )
1017
						YY_NEW_FILE;
1018
					}
1019
				break;
1020
				}
1021
1022
			case EOB_ACT_CONTINUE_SCAN:
1023
				(yy_c_buf_p) =
1024
					(yytext_ptr) + yy_amount_of_matched_text;
1025
1026
				yy_current_state = yy_get_previous_state(  );
1027
1028
				yy_cp = (yy_c_buf_p);
1029
				yy_bp = (yytext_ptr) + YY_MORE_ADJ;
1030
				goto yy_match;
1031
1032
			case EOB_ACT_LAST_MATCH:
1033
				(yy_c_buf_p) =
1034
				&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)];
1035
1036
				yy_current_state = yy_get_previous_state(  );
1037
1038
				yy_cp = (yy_c_buf_p);
1039
				yy_bp = (yytext_ptr) + YY_MORE_ADJ;
1040
				goto yy_find_action;
1041
			}
1042
		break;
1043
		}
1044
1045
	default:
1046
		YY_FATAL_ERROR(
1047
			"fatal flex scanner internal error--no action found" );
1048
	} /* end of action switch */
1049
		} /* end of scanning one token */
1050
	} /* end of user's declarations */
1051
} /* end of kvlex */
1052
1053
/* yy_get_next_buffer - try to read in a new buffer
1054
 *
1055
 * Returns a code representing an action:
1056
 *	EOB_ACT_LAST_MATCH -
1057
 *	EOB_ACT_CONTINUE_SCAN - continue scanning from current position
1058
 *	EOB_ACT_END_OF_FILE - end of file
1059
 */
1060
static int yy_get_next_buffer (void)
1061
{
1062
    	char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
1063
	char *source = (yytext_ptr);
1064
	int number_to_move, i;
1065
	int ret_val;
1066
1067
	if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] )
1068
		YY_FATAL_ERROR(
1069
		"fatal flex scanner internal error--end of buffer missed" );
1070
1071
	if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 )
1072
		{ /* Don't try to fill the buffer, so this is an EOF. */
1073
		if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 )
1074
			{
1075
			/* We matched a single character, the EOB, so
1076
			 * treat this as a final EOF.
1077
			 */
1078
			return EOB_ACT_END_OF_FILE;
1079
			}
1080
1081
		else
1082
			{
1083
			/* We matched some text prior to the EOB, first
1084
			 * process it.
1085
			 */
1086
			return EOB_ACT_LAST_MATCH;
1087
			}
1088
		}
1089
1090
	/* Try to read more data. */
1091
1092
	/* First move last chars to start of buffer. */
1093
	number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr)) - 1;
1094
1095
	for ( i = 0; i < number_to_move; ++i )
1096
		*(dest++) = *(source++);
1097
1098
	if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING )
1099
		/* don't do the read, it's not guaranteed to return an EOF,
1100
		 * just force an EOF
1101
		 */
1102
		YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0;
1103
1104
	else
1105
		{
1106
			yy_size_t num_to_read =
1107
			YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
1108
1109
		while ( num_to_read <= 0 )
1110
			{ /* Not enough room in the buffer - grow it. */
1111
1112
			YY_FATAL_ERROR(
1113
"input buffer overflow, can't enlarge buffer because scanner uses REJECT" );
1114
1115
			}
1116
1117
		if ( num_to_read > YY_READ_BUF_SIZE )
1118
			num_to_read = YY_READ_BUF_SIZE;
1119
1120
		/* Read in more data. */
1121
		YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]),
1122
			(yy_n_chars), num_to_read );
1123
1124
		YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
1125
		}
1126
1127
	if ( (yy_n_chars) == 0 )
1128
		{
1129
		if ( number_to_move == YY_MORE_ADJ )
1130
			{
1131
			ret_val = EOB_ACT_END_OF_FILE;
1132
			kvrestart(kvin  );
1133
			}
1134
1135
		else
1136
			{
1137
			ret_val = EOB_ACT_LAST_MATCH;
1138
			YY_CURRENT_BUFFER_LVALUE->yy_buffer_status =
1139
				YY_BUFFER_EOF_PENDING;
1140
			}
1141
		}
1142
1143
	else
1144
		ret_val = EOB_ACT_CONTINUE_SCAN;
1145
1146
	if ((yy_size_t) ((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {
1147
		/* Extend the array by 50%, plus the number we really need. */
1148
		yy_size_t new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1);
1149
		YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) kvrealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size  );
1150
		if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
1151
			YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" );
1152
		/* "- 2" to take care of EOB's */
1153
		YY_CURRENT_BUFFER_LVALUE->yy_buf_size = (int) (new_size - 2);
1154
	}
1155
1156
	(yy_n_chars) += number_to_move;
1157
	YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR;
1158
	YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR;
1159
1160
	(yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0];
1161
1162
	return ret_val;
1163
}
1164
1165
/* yy_get_previous_state - get the state just before the EOB char was reached */
1166
1167
    static yy_state_type yy_get_previous_state (void)
1168
{
1169
	yy_state_type yy_current_state;
1170
	char *yy_cp;
1171
1172
	yy_current_state = (yy_start);
1173
1174
	(yy_state_ptr) = (yy_state_buf);
1175
	*(yy_state_ptr)++ = yy_current_state;
1176
1177
	for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp )
1178
		{
1179
		YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
1180
		while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1181
			{
1182
			yy_current_state = (int) yy_def[yy_current_state];
1183
			if ( yy_current_state >= 26 )
1184
				yy_c = yy_meta[(unsigned int) yy_c];
1185
			}
1186
		yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
1187
		*(yy_state_ptr)++ = yy_current_state;
1188
		}
1189
1190
	return yy_current_state;
1191
}
1192
1193
/* yy_try_NUL_trans - try to make a transition on the NUL character
1194
 *
1195
 * synopsis
1196
 *	next_state = yy_try_NUL_trans( current_state );
1197
 */
1198
    static yy_state_type yy_try_NUL_trans  (yy_state_type yy_current_state )
1199
{
1200
	int yy_is_jam;
1201
1202
	YY_CHAR yy_c = 1;
1203
	while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1204
		{
1205
		yy_current_state = (int) yy_def[yy_current_state];
1206
		if ( yy_current_state >= 26 )
1207
			yy_c = yy_meta[(unsigned int) yy_c];
1208
		}
1209
	yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
1210
	yy_is_jam = (yy_current_state == 25);
1211
	if ( ! yy_is_jam )
1212
		*(yy_state_ptr)++ = yy_current_state;
1213
1214
		return yy_is_jam ? 0 : yy_current_state;
1215
}
1216
1217
    static void yyunput (int c, char * yy_bp )
1218
{
1219
	char *yy_cp;
1220
1221
    yy_cp = (yy_c_buf_p);
1222
1223
	/* undo effects of setting up kvtext */
1224
	*yy_cp = (yy_hold_char);
1225
1226
	if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 )
1227
		{ /* need to shift things up to make room */
1228
		/* +2 for EOB chars. */
1229
		yy_size_t number_to_move = (yy_n_chars) + 2;
1230
		char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[
1231
					YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2];
1232
		char *source =
1233
				&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move];
1234
1235
		while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
1236
			*--dest = *--source;
1237
1238
		yy_cp += (int) (dest - source);
1239
		yy_bp += (int) (dest - source);
1240
		YY_CURRENT_BUFFER_LVALUE->yy_n_chars =
1241
			(yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_buf_size;
1242
1243
		if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 )
1244
			YY_FATAL_ERROR( "flex scanner push-back overflow" );
1245
		}
1246
1247
	*--yy_cp = (char) c;
1248
1249
    if ( c == '\n' ){
1250
        --kvlineno;
1251
    }
1252
1253
	(yytext_ptr) = yy_bp;
1254
	(yy_hold_char) = *yy_cp;
1255
	(yy_c_buf_p) = yy_cp;
1256
}
1257
1258
#ifndef YY_NO_INPUT
1259
#ifdef __cplusplus
1260
    static int yyinput (void)
1261
#else
1262
    static int input  (void)
1263
#endif
1264
1265
{
1266
	int c;
1267
1268
	*(yy_c_buf_p) = (yy_hold_char);
1269
1270
	if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR )
1271
		{
1272
		/* yy_c_buf_p now points to the character we want to return.
1273
		 * If this occurs *before* the EOB characters, then it's a
1274
		 * valid NUL; if not, then we've hit the end of the buffer.
1275
		 */
1276
		if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
1277
			/* This was really a NUL. */
1278
			*(yy_c_buf_p) = '\0';
1279
1280
		else
1281
			{ /* need more input */
1282
			yy_size_t offset = (yy_c_buf_p) - (yytext_ptr);
1283
			++(yy_c_buf_p);
1284
1285
			switch ( yy_get_next_buffer(  ) )
1286
				{
1287
				case EOB_ACT_LAST_MATCH:
1288
					/* This happens because yy_g_n_b()
1289
					 * sees that we've accumulated a
1290
					 * token and flags that we need to
1291
					 * try matching the token before
1292
					 * proceeding.  But for input(),
1293
					 * there's no matching to consider.
1294
					 * So convert the EOB_ACT_LAST_MATCH
1295
					 * to EOB_ACT_END_OF_FILE.
1296
					 */
1297
1298
					/* Reset buffer status. */
1299
					kvrestart(kvin );
1300
1301
					/*FALLTHROUGH*/
1302
1303
				case EOB_ACT_END_OF_FILE:
1304
					{
1305
					if ( kvwrap( ) )
1306
						return EOF;
1307
1308
					if ( ! (yy_did_buffer_switch_on_eof) )
1309
						YY_NEW_FILE;
1310
#ifdef __cplusplus
1311
					return yyinput();
1312
#else
1313
					return input();
1314
#endif
1315
					}
1316
1317
				case EOB_ACT_CONTINUE_SCAN:
1318
					(yy_c_buf_p) = (yytext_ptr) + offset;
1319
					break;
1320
				}
1321
			}
1322
		}
1323
1324
	c = *(unsigned char *) (yy_c_buf_p);	/* cast for 8-bit char's */
1325
	*(yy_c_buf_p) = '\0';	/* preserve kvtext */
1326
	(yy_hold_char) = *++(yy_c_buf_p);
1327
1328
	if ( c == '\n' )
1329
1330
    kvlineno++;
1331
;
1332
1333
	return c;
1334
}
1335
#endif	/* ifndef YY_NO_INPUT */
1336
1337
/** Immediately switch to a different input stream.
1338
 * @param input_file A readable stream.
1339
 *
1340
 * @note This function does not reset the start condition to @c INITIAL .
1341
 */
1342
    void kvrestart  (FILE * input_file )
1343
{
1344
1345
	if ( ! YY_CURRENT_BUFFER ){
1346
        kvensure_buffer_stack ();
1347
		YY_CURRENT_BUFFER_LVALUE =
1348
            kv_create_buffer(kvin,YY_BUF_SIZE );
1349
	}
1350
1351
	kv_init_buffer(YY_CURRENT_BUFFER,input_file );
1352
	kv_load_buffer_state( );
1353
}
1354
1355
/** Switch to a different input buffer.
1356
 * @param new_buffer The new input buffer.
1357
 *
1358
 */
1359
    void kv_switch_to_buffer  (YY_BUFFER_STATE  new_buffer )
1360
{
1361
1362
	/* TODO. We should be able to replace this entire function body
1363
	 * with
1364
	 *		kvpop_buffer_state();
1365
	 *		kvpush_buffer_state(new_buffer);
1366
     */
1367
	kvensure_buffer_stack ();
1368
	if ( YY_CURRENT_BUFFER == new_buffer )
1369
		return;
1370
1371
	if ( YY_CURRENT_BUFFER )
1372
		{
1373
		/* Flush out information for old buffer. */
1374
		*(yy_c_buf_p) = (yy_hold_char);
1375
		YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
1376
		YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
1377
		}
1378
1379
	YY_CURRENT_BUFFER_LVALUE = new_buffer;
1380
	kv_load_buffer_state( );
1381
1382
	/* We don't actually know whether we did this switch during
1383
	 * EOF (kvwrap()) processing, but the only time this flag
1384
	 * is looked at is after kvwrap() is called, so it's safe
1385
	 * to go ahead and always set it.
1386
	 */
1387
	(yy_did_buffer_switch_on_eof) = 1;
1388
}
1389
1390
static void kv_load_buffer_state  (void)
1391
{
1392
    	(yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
1393
	(yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos;
1394
	kvin = YY_CURRENT_BUFFER_LVALUE->yy_input_file;
1395
	(yy_hold_char) = *(yy_c_buf_p);
1396
}
1397
1398
/** Allocate and initialize an input buffer state.
1399
 * @param file A readable stream.
1400
 * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE.
1401
 *
1402
 * @return the allocated buffer state.
1403
 */
1404
    YY_BUFFER_STATE kv_create_buffer  (FILE * file, int  size )
1405
{
1406
	YY_BUFFER_STATE b;
1407
1408
	b = (YY_BUFFER_STATE) kvalloc(sizeof( struct yy_buffer_state )  );
1409
	if ( ! b )
1410
		YY_FATAL_ERROR( "out of dynamic memory in kv_create_buffer()" );
1411
1412
	b->yy_buf_size = size;
1413
1414
	/* yy_ch_buf has to be 2 characters longer than the size given because
1415
	 * we need to put in 2 end-of-buffer characters.
1416
	 */
1417
	b->yy_ch_buf = (char *) kvalloc(b->yy_buf_size + 2  );
1418
	if ( ! b->yy_ch_buf )
1419
		YY_FATAL_ERROR( "out of dynamic memory in kv_create_buffer()" );
1420
1421
	b->yy_is_our_buffer = 1;
1422
1423
	kv_init_buffer(b,file );
1424
1425
	return b;
1426
}
1427
1428
/** Destroy the buffer.
1429
 * @param b a buffer created with kv_create_buffer()
1430
 *
1431
 */
1432
    void kv_delete_buffer (YY_BUFFER_STATE  b )
1433
{
1434
1435
	if ( ! b )
1436
		return;
1437
1438
	if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */
1439
		YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0;
1440
1441
	if ( b->yy_is_our_buffer )
1442
		kvfree((void *) b->yy_ch_buf  );
1443
1444
	kvfree((void *) b  );
1445
}
1446
1447
/* Initializes or reinitializes a buffer.
1448
 * This function is sometimes called more than once on the same buffer,
1449
 * such as during a kvrestart() or at EOF.
1450
 */
1451
    static void kv_init_buffer  (YY_BUFFER_STATE  b, FILE * file )
1452
1453
{
1454
	int oerrno = errno;
1455
1456
	kv_flush_buffer(b );
1457
1458
	b->yy_input_file = file;
1459
	b->yy_fill_buffer = 1;
1460
1461
    /* If b is the current buffer, then kv_init_buffer was _probably_
1462
     * called from kvrestart() or through yy_get_next_buffer.
1463
     * In that case, we don't want to reset the lineno or column.
1464
     */
1465
    if (b != YY_CURRENT_BUFFER){
1466
        b->yy_bs_lineno = 1;
1467
        b->yy_bs_column = 0;
1468
    }
1469
1470
        b->yy_is_interactive = 0;
1471
1472
	errno = oerrno;
1473
}
1474
1475
/** Discard all buffered characters. On the next scan, YY_INPUT will be called.
1476
 * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER.
1477
 *
1478
 */
1479
    void kv_flush_buffer (YY_BUFFER_STATE  b )
1480
{
1481
    	if ( ! b )
1482
		return;
1483
1484
	b->yy_n_chars = 0;
1485
1486
	/* We always need two end-of-buffer characters.  The first causes
1487
	 * a transition to the end-of-buffer state.  The second causes
1488
	 * a jam in that state.
1489
	 */
1490
	b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
1491
	b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
1492
1493
	b->yy_buf_pos = &b->yy_ch_buf[0];
1494
1495
	b->yy_at_bol = 1;
1496
	b->yy_buffer_status = YY_BUFFER_NEW;
1497
1498
	if ( b == YY_CURRENT_BUFFER )
1499
		kv_load_buffer_state( );
1500
}
1501
1502
/** Pushes the new state onto the stack. The new state becomes
1503
 *  the current state. This function will allocate the stack
1504
 *  if necessary.
1505
 *  @param new_buffer The new state.
1506
 *
1507
 */
1508
void kvpush_buffer_state (YY_BUFFER_STATE new_buffer )
1509
{
1510
    	if (new_buffer == NULL)
1511
		return;
1512
1513
	kvensure_buffer_stack();
1514
1515
	/* This block is copied from kv_switch_to_buffer. */
1516
	if ( YY_CURRENT_BUFFER )
1517
		{
1518
		/* Flush out information for old buffer. */
1519
		*(yy_c_buf_p) = (yy_hold_char);
1520
		YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
1521
		YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
1522
		}
1523
1524
	/* Only push if top exists. Otherwise, replace top. */
1525
	if (YY_CURRENT_BUFFER)
1526
		(yy_buffer_stack_top)++;
1527
	YY_CURRENT_BUFFER_LVALUE = new_buffer;
1528
1529
	/* copied from kv_switch_to_buffer. */
1530
	kv_load_buffer_state( );
1531
	(yy_did_buffer_switch_on_eof) = 1;
1532
}
1533
1534
/** Removes and deletes the top of the stack, if present.
1535
 *  The next element becomes the new top.
1536
 *
1537
 */
1538
void kvpop_buffer_state (void)
1539
{
1540
    	if (!YY_CURRENT_BUFFER)
1541
		return;
1542
1543
	kv_delete_buffer(YY_CURRENT_BUFFER );
1544
	YY_CURRENT_BUFFER_LVALUE = NULL;
1545
	if ((yy_buffer_stack_top) > 0)
1546
		--(yy_buffer_stack_top);
1547
1548
	if (YY_CURRENT_BUFFER) {
1549
		kv_load_buffer_state( );
1550
		(yy_did_buffer_switch_on_eof) = 1;
1551
	}
1552
}
1553
1554
/* Allocates the stack if it does not exist.
1555
 *  Guarantees space for at least one push.
1556
 */
1557
static void kvensure_buffer_stack (void)
1558
{
1559
	yy_size_t num_to_alloc;
1560
1561
	if (!(yy_buffer_stack)) {
1562
1563
		/* First allocation is just for 2 elements, since we don't know if this
1564
		 * scanner will even need a stack. We use 2 instead of 1 to avoid an
1565
		 * immediate realloc on the next call.
1566
         */
1567
		num_to_alloc = 1;
1568
		(yy_buffer_stack) = (struct yy_buffer_state**)kvalloc
1569
								(num_to_alloc * sizeof(struct yy_buffer_state*)
1570
								);
1571
		if ( ! (yy_buffer_stack) )
1572
			YY_FATAL_ERROR( "out of dynamic memory in kvensure_buffer_stack()" );
1573
1574
		memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*));
1575
1576
		(yy_buffer_stack_max) = num_to_alloc;
1577
		(yy_buffer_stack_top) = 0;
1578
		return;
1579
	}
1580
1581
	if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){
1582
1583
		/* Increase the buffer to prepare for a possible push. */
1584
		int grow_size = 8 /* arbitrary grow size */;
1585
1586
		num_to_alloc = (yy_buffer_stack_max) + grow_size;
1587
		(yy_buffer_stack) = (struct yy_buffer_state**)kvrealloc
1588
								((yy_buffer_stack),
1589
								num_to_alloc * sizeof(struct yy_buffer_state*)
1590
								);
1591
		if ( ! (yy_buffer_stack) )
1592
			YY_FATAL_ERROR( "out of dynamic memory in kvensure_buffer_stack()" );
1593
1594
		/* zero only the new slots.*/
1595
		memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*));
1596
		(yy_buffer_stack_max) = num_to_alloc;
1597
	}
1598
}
1599
1600
/** Setup the input buffer state to scan directly from a user-specified character buffer.
1601
 * @param base the character buffer
1602
 * @param size the size in bytes of the character buffer
1603
 *
1604
 * @return the newly allocated buffer state object.
1605
 */
1606
YY_BUFFER_STATE kv_scan_buffer  (char * base, yy_size_t  size )
1607
{
1608
	YY_BUFFER_STATE b;
1609
1610
	if ( size < 2 ||
1611
	     base[size-2] != YY_END_OF_BUFFER_CHAR ||
1612
	     base[size-1] != YY_END_OF_BUFFER_CHAR )
1613
		/* They forgot to leave room for the EOB's. */
1614
		return 0;
1615
1616
	b = (YY_BUFFER_STATE) kvalloc(sizeof( struct yy_buffer_state )  );
1617
	if ( ! b )
1618
		YY_FATAL_ERROR( "out of dynamic memory in kv_scan_buffer()" );
1619
1620
	b->yy_buf_size = size - 2;	/* "- 2" to take care of EOB's */
1621
	b->yy_buf_pos = b->yy_ch_buf = base;
1622
	b->yy_is_our_buffer = 0;
1623
	b->yy_input_file = 0;
1624
	b->yy_n_chars = b->yy_buf_size;
1625
	b->yy_is_interactive = 0;
1626
	b->yy_at_bol = 1;
1627
	b->yy_fill_buffer = 0;
1628
	b->yy_buffer_status = YY_BUFFER_NEW;
1629
1630
	kv_switch_to_buffer(b  );
1631
1632
	return b;
1633
}
1634
1635
/** Setup the input buffer state to scan a string. The next call to kvlex() will
1636
 * scan from a @e copy of @a str.
1637
 * @param yystr a NUL-terminated string to scan
1638
 *
1639
 * @return the newly allocated buffer state object.
1640
 * @note If you want to scan bytes that may contain NUL values, then use
1641
 *       kv_scan_bytes() instead.
1642
 */
1643
YY_BUFFER_STATE kv_scan_string (yyconst char * yystr )
1644
{
1645
1646
	return kv_scan_bytes(yystr,strlen(yystr) );
1647
}
1648
1649
/** Setup the input buffer state to scan the given bytes. The next call to kvlex() will
1650
 * scan from a @e copy of @a bytes.
1651
 * @param yybytes the byte buffer to scan
1652
 * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes.
1653
 *
1654
 * @return the newly allocated buffer state object.
1655
 */
1656
YY_BUFFER_STATE kv_scan_bytes  (yyconst char * yybytes, yy_size_t  _yybytes_len )
1657
{
1658
	YY_BUFFER_STATE b;
1659
	char *buf;
1660
	yy_size_t n;
1661
	yy_size_t i;
1662
1663
	/* Get memory for full buffer, including space for trailing EOB's. */
1664
	n = _yybytes_len + 2;
1665
	buf = (char *) kvalloc(n  );
1666
	if ( ! buf )
1667
		YY_FATAL_ERROR( "out of dynamic memory in kv_scan_bytes()" );
1668
1669
	for ( i = 0; i < _yybytes_len; ++i )
1670
		buf[i] = yybytes[i];
1671
1672
	buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR;
1673
1674
	b = kv_scan_buffer(buf,n );
1675
	if ( ! b )
1676
		YY_FATAL_ERROR( "bad buffer in kv_scan_bytes()" );
1677
1678
	/* It's okay to grow etc. this buffer, and we should throw it
1679
	 * away when we're done.
1680
	 */
1681
	b->yy_is_our_buffer = 1;
1682
1683
	return b;
1684
}
1685
1686
#ifndef YY_EXIT_FAILURE
1687
#define YY_EXIT_FAILURE 2
1688
#endif
1689
1690
static void yy_fatal_error (yyconst char* msg )
1691
{
1692
    	(void) fprintf( stderr, "%s\n", msg );
1693
	exit( YY_EXIT_FAILURE );
1694
}
1695
1696
/* Redefine yyless() so it works in section 3 code. */
1697
1698
#undef yyless
1699
#define yyless(n) \
1700
	do \
1701
		{ \
1702
		/* Undo effects of setting up kvtext. */ \
1703
        int yyless_macro_arg = (n); \
1704
        YY_LESS_LINENO(yyless_macro_arg);\
1705
		kvtext[kvleng] = (yy_hold_char); \
1706
		(yy_c_buf_p) = kvtext + yyless_macro_arg; \
1707
		(yy_hold_char) = *(yy_c_buf_p); \
1708
		*(yy_c_buf_p) = '\0'; \
1709
		kvleng = yyless_macro_arg; \
1710
		} \
1711
	while ( 0 )
1712
1713
/* Accessor  methods (get/set functions) to struct members. */
1714
1715
/** Get the current line number.
1716
 *
1717
 */
1718
int kvget_lineno  (void)
1719
{
1720
1721
    return kvlineno;
1722
}
1723
1724
/** Get the input stream.
1725
 *
1726
 */
1727
FILE *kvget_in  (void)
1728
{
1729
        return kvin;
1730
}
1731
1732
/** Get the output stream.
1733
 *
1734
 */
1735
FILE *kvget_out  (void)
1736
{
1737
        return kvout;
1738
}
1739
1740
/** Get the length of the current token.
1741
 *
1742
 */
1743
yy_size_t kvget_leng  (void)
1744
{
1745
        return kvleng;
1746
}
1747
1748
/** Get the current token.
1749
 *
1750
 */
1751
1752
char *kvget_text  (void)
1753
{
1754
        return kvtext;
1755
}
1756
1757
/** Set the current line number.
1758
 * @param line_number
1759
 *
1760
 */
1761
void kvset_lineno (int  line_number )
1762
{
1763
1764
    kvlineno = line_number;
1765
}
1766
1767
/** Set the input stream. This does not discard the current
1768
 * input buffer.
1769
 * @param in_str A readable stream.
1770
 *
1771
 * @see kv_switch_to_buffer
1772
 */
1773
void kvset_in (FILE *  in_str )
1774
{
1775
        kvin = in_str ;
1776
}
1777
1778
void kvset_out (FILE *  out_str )
1779
{
1780
        kvout = out_str ;
1781
}
1782
1783
int kvget_debug  (void)
1784
{
1785
        return kv_flex_debug;
1786
}
1787
1788
void kvset_debug (int  bdebug )
1789
{
1790
        kv_flex_debug = bdebug ;
1791
}
1792
1793
static int yy_init_globals (void)
1794
{
1795
        /* Initialization is the same as for the non-reentrant scanner.
1796
     * This function is called from kvlex_destroy(), so don't allocate here.
1797
     */
1798
1799
    /* We do not touch kvlineno unless the option is enabled. */
1800
    kvlineno =  1;
1801
1802
    (yy_buffer_stack) = 0;
1803
    (yy_buffer_stack_top) = 0;
1804
    (yy_buffer_stack_max) = 0;
1805
    (yy_c_buf_p) = (char *) 0;
1806
    (yy_init) = 0;
1807
    (yy_start) = 0;
1808
1809
    (yy_state_buf) = 0;
1810
    (yy_state_ptr) = 0;
1811
    (yy_full_match) = 0;
1812
    (yy_lp) = 0;
1813
1814
/* Defined in main.c */
1815
#ifdef YY_STDINIT
1816
    kvin = stdin;
1817
    kvout = stdout;
1818
#else
1819
    kvin = (FILE *) 0;
1820
    kvout = (FILE *) 0;
1821
#endif
1822
1823
    /* For future reference: Set errno on error, since we are called by
1824
     * kvlex_init()
1825
     */
1826
    return 0;
1827
}
1828
1829
/* kvlex_destroy is for both reentrant and non-reentrant scanners. */
1830
int kvlex_destroy  (void)
1831
{
1832
1833
    /* Pop the buffer stack, destroying each element. */
1834
	while(YY_CURRENT_BUFFER){
1835
		kv_delete_buffer(YY_CURRENT_BUFFER  );
1836
		YY_CURRENT_BUFFER_LVALUE = NULL;
1837
		kvpop_buffer_state();
1838
	}
1839
1840
	/* Destroy the stack itself. */
1841
	kvfree((yy_buffer_stack) );
1842
	(yy_buffer_stack) = NULL;
1843
1844
    kvfree ( (yy_state_buf) );
1845
    (yy_state_buf)  = NULL;
1846
1847
    /* Reset the globals. This is important in a non-reentrant scanner so the next time
1848
     * kvlex() is called, initialization will occur. */
1849
    yy_init_globals( );
1850
1851
    return 0;
1852
}
1853
1854
/*
1855
 * Internal utility routines.
1856
 */
1857
1858
#ifndef yytext_ptr
1859
static void yy_flex_strncpy (char* s1, yyconst char * s2, int n )
1860
{
1861
	int i;
1862
	for ( i = 0; i < n; ++i )
1863
		s1[i] = s2[i];
1864
}
1865
#endif
1866
1867
#ifdef YY_NEED_STRLEN
1868
static int yy_flex_strlen (yyconst char * s )
1869
{
1870
	int n;
1871
	for ( n = 0; s[n]; ++n )
1872
		;
1873
1874
	return n;
1875
}
1876
#endif
1877
1878
void *kvalloc (yy_size_t  size )
1879
{
1880
	return (void *) malloc( size );
1881
}
1882
1883
void *kvrealloc  (void * ptr, yy_size_t  size )
1884
{
1885
	/* The cast to (char *) in the following accommodates both
1886
	 * implementations that use char* generic pointers, and those
1887
	 * that use void* generic pointers.  It works with the latter
1888
	 * because both ANSI C and C++ allow castless assignment from
1889
	 * any pointer type to void*, and deal with argument conversions
1890
	 * as though doing an assignment.
1891
	 */
1892
	return (void *) realloc( (char *) ptr, size );
1893
}
1894
1895
void kvfree (void * ptr )
1896
{
1897
	free( (char *) ptr );	/* see kvrealloc() for (char *) cast */
1898
}
1899
1900
#define YYTABLES_NAME "yytables"
1901
1902
#line 76 "/usr/src/usr.bin/keynote/../../lib/libkeynote/keynote-ver.l"
1903
1904
1905
1906
/*
1907
 * Return RESULT_TRUE if character is octal digit, RESULT_FALSE otherwise.
1908
 */
1909
static int
1910
is_octal(char c)
1911
{
1912
    switch (c)
1913
    {
1914
	case '0': case '1': case '2': case '3':
1915
	case '4': case '5': case '6': case '7':
1916
	    return RESULT_TRUE;
1917
1918
	default:
1919
	    return RESULT_FALSE;
1920
    }
1921
}
1922
1923
/*
1924
 * Return octal value (non-zero) if argument starts with such a
1925
 * representation, otherwise 0.
1926
 */
1927
static unsigned char
1928
get_octal(char *s, int len, int *adv)
1929
{
1930
    unsigned char res = 0;
1931
1932
    if (*s == '0')
1933
    {
1934
	if (len > 0)
1935
	{
1936
	    if (is_octal(*(s + 1)))
1937
	    {
1938
		res = *(s + 1) - '0';
1939
		*adv = 2;
1940
1941
		if (is_octal(*(s + 2)) && (len - 1 > 0))
1942
		{
1943
		    res = res * 8 + (*(s + 2) - '0');
1944
		    *adv = 3;
1945
		}
1946
	    }
1947
	}
1948
    }
1949
    else
1950
      if (is_octal(*s) && (len - 1 > 0))  /* Non-zero leading */
1951
      {
1952
	  if (is_octal(*(s + 1)) &&
1953
	      is_octal(*(s + 2)))
1954
	  {
1955
	      *adv = 3;
1956
	      res = (((*s) - '0') * 64) +
1957
		    (((*(s + 1)) - '0') * 8) +
1958
		    ((*(s + 2)) - '0');
1959
	  }
1960
      }
1961
1962
    return res;
1963
}
1964
1965
/*
1966
 * Copy at most len characters to string s1 from string s2, taking
1967
 * care of escaped characters in the process. String s1 is assumed
1968
 * to have enough space, and be zero'ed.
1969
 */
1970
void
1971
mystrncpy(char *s1, char *s2, int len)
1972
{
1973
    unsigned char c;
1974
    int advance;
1975
1976
    if (len == 0)
1977
      return;
1978
1979
    while (len-- > 0)
1980
    {
1981
        if (*s2 == '\\')
1982
	{
1983
	    s2++;
1984
1985
	    if (len-- <= 0)
1986
	      break;
1987
1988
	    if (*s2 == '\n')
1989
	    {
1990
		while (isspace((unsigned char)*(++s2)) && (len-- > 0))
1991
		  ;
1992
	    }
1993
	    else
1994
	      if ((c = get_octal(s2, len, &advance)) != 0)
1995
	      {
1996
		  len -= advance - 1;
1997
		  s2 += advance;
1998
		  *s1++ = c;
1999
	      }
2000
	      else
2001
		if (*s2 == 'n')  /* Newline */
2002
		{
2003
		    *s1++ = '\n';
2004
		    s2++;
2005
		}
2006
		else
2007
		  if (*s2 == 't')  /* Tab */
2008
		  {
2009
		      *s1++ = '\t';
2010
		      s2++;
2011
		  }
2012
		  else
2013
		    if (*s2 == 'r')  /* Linefeed */
2014
		    {
2015
			*s1++ = '\r';
2016
			s2++;
2017
		    }
2018
		    else
2019
		      if (*s2 == 'f')  /* Formfeed */
2020
		      {
2021
			  *s1++ = '\f';
2022
			  s2++;
2023
		      }
2024
		      else
2025
			if ((*s1++ = *s2++) == 0)
2026
			  break;
2027
2028
	    continue;
2029
	}
2030
2031
        if ((*s1++ = *s2++) == 0)
2032
	  break;
2033
     }
2034
}
2035
2036
/*
2037
 * Parse a file that contains environment variable/value pairs.
2038
 * Return -1 on failure.
2039
 */
2040
int
2041
read_environment(char *filename)
2042
{
2043
    YY_BUFFER_STATE kvfoo;
2044
    FILE *fp;
2045
    int i;
2046
2047
    if ((fp = fopen(filename, "r")) == NULL) {
2048
	perror(filename);
2049
	return -1;
2050
    }
2051
2052
    kvfoo = kv_create_buffer(fp, YY_BUF_SIZE);
2053
    kv_switch_to_buffer(kvfoo);
2054
    BEGIN(FIRSTPART);
2055
    i = kvparse();
2056
    kv_delete_buffer(kvfoo);
2057
    fclose(fp);
2058
    switch (i)
2059
    {
2060
	case 0:
2061
	    return 0;
2062
2063
	default:
2064
	    if (keynote_errno == ERROR_MEMORY)
2065
	      fprintf(stderr,
2066
		      "Memory error while processing environment file <%s>\n",
2067
		      filename);
2068
	    else
2069
	      fprintf(stderr,
2070
		     "Syntax error in environment file <%s>, line %d\n",
2071
		     filename, kvlineno);
2072
	    return -1;
2073
    }
2074
2075
    /* Used to avoid compiler (-Wall) warnings. Never reached */
2076
    if (0)
2077
    {
2078
	yyunput(0, NULL);
2079
    }
2080
}
2081
2082
/*
2083
 * Parse a key.
2084
 */
2085
void
2086
parse_key(char *buf)
2087
{
2088
    YY_BUFFER_STATE key_state;
2089
    int err;
2090
2091
    key_state = kv_scan_string(buf);
2092
    BEGIN(KEYSTATE);
2093
    err = kvparse();
2094
    kv_delete_buffer(key_state);
2095
2096
    if (err != 0)
2097
      if (keynote_errno == 0)
2098
	keynote_errno = ERROR_SYNTAX;
2099
}
2100