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