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