summaryrefslogtreecommitdiffstats
path: root/contrib/ipfilter/tools/lex_var.h
diff options
context:
space:
mode:
authorngie <ngie@FreeBSD.org>2015-10-05 03:26:51 +0000
committerngie <ngie@FreeBSD.org>2015-10-05 03:26:51 +0000
commite1dd16d965b177f109afb771e59432e36f335d0a (patch)
tree15db092a5401cf329f1bff9d3bf700d1fde0f121 /contrib/ipfilter/tools/lex_var.h
parent115d008392113efc6f844baa7cc407e9eaae63db (diff)
downloadFreeBSD-src-e1dd16d965b177f109afb771e59432e36f335d0a.zip
FreeBSD-src-e1dd16d965b177f109afb771e59432e36f335d0a.tar.gz
Revert r288682
I meant to do this on ^/user/ngie/more-tests Pointyhat to: ngie (use svn info next time...)
Diffstat (limited to 'contrib/ipfilter/tools/lex_var.h')
-rw-r--r--contrib/ipfilter/tools/lex_var.h60
1 files changed, 60 insertions, 0 deletions
diff --git a/contrib/ipfilter/tools/lex_var.h b/contrib/ipfilter/tools/lex_var.h
new file mode 100644
index 0000000..eb59f58
--- /dev/null
+++ b/contrib/ipfilter/tools/lex_var.h
@@ -0,0 +1,60 @@
+/* $FreeBSD$ */
+
+/*
+ * Copyright (C) 2012 by Darren Reed.
+ *
+ * See the IPFILTER.LICENCE file for details on licencing.
+ */
+
+extern long string_start;
+extern long string_end;
+extern char *string_val;
+extern long pos;
+
+#define YY_INPUT(buf, result, max_size) \
+ if (pos >= string_start && pos <= string_end) { \
+ buf[0] = string_val[pos - string_start]; \
+ pos++; \
+ result = 1; \
+ } else if ( yy_current_buffer->yy_is_interactive ) \
+ { \
+ int c = '*', n; \
+ for ( n = 0; n < 1 && \
+ (c = getc( yyin )) != EOF && c != '\n'; ++n ) \
+ buf[n] = (char) c; \
+ if ( c == '\n' ) \
+ buf[n++] = (char) c; \
+ if ( c == EOF && ferror( yyin ) ) \
+ YY_FATAL_ERROR( "input in flex scanner failed" ); \
+ result = n; \
+ pos++; \
+ } \
+ else if ( ((result = fread( buf, 1, 1, yyin )) == 0) \
+ && ferror( yyin ) ) \
+ YY_FATAL_ERROR( "input in flex scanner failed" );
+
+#ifdef input
+# undef input
+# define input() (((pos >= string_start) && (pos < string_end)) ? \
+ yysptr = yysbuf, string_val[pos++ - string_start] : \
+ ((yytchar = yysptr > yysbuf ? U(*--yysptr) : \
+ getc(yyin)) == 10 ? (pos++, yylineno++, yytchar) : \
+ yytchar) == EOF ? (pos++, 0) : (pos++, yytchar))
+#endif
+
+#ifdef lex_input
+# undef lex_input
+# define lex_input() (((pos >= string_start) && (pos < string_end)) ? \
+ yysptr = yysbuf, string_val[pos++ - string_start] : \
+ ((yytchar = yysptr > yysbuf ? U(*--yysptr) : \
+ getc(yyin)) == 10 ? (pos++, yylineno++, yytchar) : \
+ yytchar) == EOF ? (pos++, 0) : (pos++, yytchar))
+#endif
+
+#ifdef unput
+# undef unput
+# define unput(c) { if (pos > 0) pos--; \
+ yytchar = (c); if (yytchar == '\n') yylineno--; \
+ *yysptr++ = yytchar; }
+#endif
+
OpenPOWER on IntegriCloud