Home | History | Annotate | Line # | Download | only in tools
      1 /*	$NetBSD: lex_var.h,v 1.1.1.2 2012/07/22 13:44:58 darrenr Exp $	*/
      2 
      3 /*
      4  * Copyright (C) 2012 by Darren Reed.
      5  *
      6  * See the IPFILTER.LICENCE file for details on licencing.
      7  */
      8 
      9 extern	long		string_start;
     10 extern	long		string_end;
     11 extern	char		*string_val;
     12 extern	long		pos;
     13 
     14 #define YY_INPUT(buf, result, max_size) \
     15 	if (pos >= string_start && pos <= string_end) { \
     16 		buf[0] = string_val[pos - string_start]; \
     17 		pos++; \
     18 		result = 1; \
     19 	} else if ( yy_current_buffer->yy_is_interactive ) \
     20 		{ \
     21 		int c = '*', n; \
     22 		for ( n = 0; n < 1 && \
     23 			     (c = getc( yyin )) != EOF && c != '\n'; ++n ) \
     24 			buf[n] = (char) c; \
     25 		if ( c == '\n' ) \
     26 			buf[n++] = (char) c; \
     27 		if ( c == EOF && ferror( yyin ) ) \
     28 			YY_FATAL_ERROR( "input in flex scanner failed" ); \
     29 		result = n; \
     30 		pos++; \
     31 		} \
     32 	else if ( ((result = fread( buf, 1, 1, yyin )) == 0) \
     33 		  && ferror( yyin ) ) \
     34 		YY_FATAL_ERROR( "input in flex scanner failed" );
     35 
     36 #ifdef input
     37 # undef input
     38 # define input() (((pos >= string_start) && (pos < string_end)) ? \
     39 		  yysptr = yysbuf, string_val[pos++ - string_start] : \
     40 		  ((yytchar = yysptr > yysbuf ? U(*--yysptr) : \
     41 		   getc(yyin)) == 10 ? (pos++, yylineno++, yytchar) : \
     42 		  yytchar) == EOF ? (pos++, 0) : (pos++, yytchar))
     43 #endif
     44 
     45 #ifdef lex_input
     46 # undef lex_input
     47 # define lex_input() (((pos >= string_start) && (pos < string_end)) ? \
     48 		  yysptr = yysbuf, string_val[pos++ - string_start] : \
     49 		  ((yytchar = yysptr > yysbuf ? U(*--yysptr) : \
     50 		   getc(yyin)) == 10 ? (pos++, yylineno++, yytchar) : \
     51 		  yytchar) == EOF ? (pos++, 0) : (pos++, yytchar))
     52 #endif
     53 
     54 #ifdef unput
     55 # undef unput
     56 # define unput(c) { if (pos > 0) pos--; \
     57 		    yytchar = (c); if (yytchar == '\n') yylineno--; \
     58 		    *yysptr++ = yytchar; }
     59 #endif
     60 
     61