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