xref: /illumos-gate/usr/src/cmd/ipf/tools/lex_var.h (revision 7c478bd9)
1*7c478bd9Sstevel@tonic-gate 
2*7c478bd9Sstevel@tonic-gate extern	long		string_start;
3*7c478bd9Sstevel@tonic-gate extern	long		string_end;
4*7c478bd9Sstevel@tonic-gate extern	char		*string_val;
5*7c478bd9Sstevel@tonic-gate extern	long		pos;
6*7c478bd9Sstevel@tonic-gate 
7*7c478bd9Sstevel@tonic-gate #define YY_INPUT(buf, result, max_size) \
8*7c478bd9Sstevel@tonic-gate 	if (pos >= string_start && pos <= string_end) { \
9*7c478bd9Sstevel@tonic-gate 		buf[0] = string_val[pos - string_start]; \
10*7c478bd9Sstevel@tonic-gate 		pos++; \
11*7c478bd9Sstevel@tonic-gate 		result = 1; \
12*7c478bd9Sstevel@tonic-gate 	} else if ( yy_current_buffer->yy_is_interactive ) \
13*7c478bd9Sstevel@tonic-gate 		{ \
14*7c478bd9Sstevel@tonic-gate 		int c = '*', n; \
15*7c478bd9Sstevel@tonic-gate 		for ( n = 0; n < 1 && \
16*7c478bd9Sstevel@tonic-gate 			     (c = getc( yyin )) != EOF && c != '\n'; ++n ) \
17*7c478bd9Sstevel@tonic-gate 			buf[n] = (char) c; \
18*7c478bd9Sstevel@tonic-gate 		if ( c == '\n' ) \
19*7c478bd9Sstevel@tonic-gate 			buf[n++] = (char) c; \
20*7c478bd9Sstevel@tonic-gate 		if ( c == EOF && ferror( yyin ) ) \
21*7c478bd9Sstevel@tonic-gate 			YY_FATAL_ERROR( "input in flex scanner failed" ); \
22*7c478bd9Sstevel@tonic-gate 		result = n; \
23*7c478bd9Sstevel@tonic-gate 		pos++; \
24*7c478bd9Sstevel@tonic-gate 		} \
25*7c478bd9Sstevel@tonic-gate 	else if ( ((result = fread( buf, 1, 1, yyin )) == 0) \
26*7c478bd9Sstevel@tonic-gate 		  && ferror( yyin ) ) \
27*7c478bd9Sstevel@tonic-gate 		YY_FATAL_ERROR( "input in flex scanner failed" );
28*7c478bd9Sstevel@tonic-gate 
29*7c478bd9Sstevel@tonic-gate #ifdef input
30*7c478bd9Sstevel@tonic-gate # undef input
31*7c478bd9Sstevel@tonic-gate # define input() (((pos >= string_start) && (pos < string_end)) ? \
32*7c478bd9Sstevel@tonic-gate 		  yysptr = yysbuf, string_val[pos++ - string_start] : \
33*7c478bd9Sstevel@tonic-gate 		  ((yytchar = yysptr > yysbuf ? U(*--yysptr) : \
34*7c478bd9Sstevel@tonic-gate 		   getc(yyin)) == 10 ? (pos++, yylineno++, yytchar) : \
35*7c478bd9Sstevel@tonic-gate 		  yytchar) == EOF ? (pos++, 0) : (pos++, yytchar))
36*7c478bd9Sstevel@tonic-gate #endif
37*7c478bd9Sstevel@tonic-gate 
38*7c478bd9Sstevel@tonic-gate #ifdef lex_input
39*7c478bd9Sstevel@tonic-gate # undef lex_input
40*7c478bd9Sstevel@tonic-gate # define lex_input() (((pos >= string_start) && (pos < string_end)) ? \
41*7c478bd9Sstevel@tonic-gate 		  yysptr = yysbuf, string_val[pos++ - string_start] : \
42*7c478bd9Sstevel@tonic-gate 		  ((yytchar = yysptr > yysbuf ? U(*--yysptr) : \
43*7c478bd9Sstevel@tonic-gate 		   getc(yyin)) == 10 ? (pos++, yylineno++, yytchar) : \
44*7c478bd9Sstevel@tonic-gate 		  yytchar) == EOF ? (pos++, 0) : (pos++, yytchar))
45*7c478bd9Sstevel@tonic-gate #endif
46*7c478bd9Sstevel@tonic-gate 
47*7c478bd9Sstevel@tonic-gate #ifdef unput
48*7c478bd9Sstevel@tonic-gate # undef unput
49*7c478bd9Sstevel@tonic-gate # define unput(c) { if (pos > 0) pos--; \
50*7c478bd9Sstevel@tonic-gate 		    yytchar = (c); if (yytchar == '\n') yylineno--; \
51*7c478bd9Sstevel@tonic-gate 		    *yysptr++ = yytchar; }
52*7c478bd9Sstevel@tonic-gate #endif
53*7c478bd9Sstevel@tonic-gate 
54