Added scanner flags stack.
ccl.c \
dfa.c \
ecs.c \
+ scanflags.c \
gen.c \
main.c \
misc.c \
ccl.o: ccl.c flexdef.h flexint.h
dfa.o: dfa.c flexdef.h flexint.h tables.h tables_shared.h
ecs.o: ecs.c flexdef.h flexint.h
+scanflags.o: scanflags.c flexdef.h flexint.h
gen.o: gen.c flexdef.h flexint.h tables.h tables_shared.h
libmain.o: libmain.c
libyywrap.o: libyywrap.c
ccl.c \
dfa.c \
ecs.c \
+ scanflags.c \
filter.c \
flexdef.h \
gen.c \
AC_CHECK_HEADERS(cunistd)
AC_CHECK_HEADERS(locale.h libintl.h)
AC_CHECK_HEADERS(regex.h)
+AC_CHECK_HEADERS(assert.h)
dnl checks for types
#include <string.h>
#include <math.h>
#endif
+#ifdef HAVE_ASSERT_H
+#include <assert.h>
+#else
+#define assert(Pred)
+#endif
+
#ifdef HAVE_LIMITS_H
#include <limits.h>
#endif
/* The percentage the number of homogeneous out-transitions of a state
* must be of the number of total out-transitions of the state in order
- * that the state's transition table is first compared with a potential
+ * that the state's transition table is first compared with a potential
* template of the most common out-transition instead of with the first
* proto in the proto queue.
*/
* use_stdout - the -t flag
* input_files - array holding names of input files
* num_input_files - size of input_files array
- * program_name - name with which program was invoked
+ * program_name - name with which program was invoked
*
* action_array - array to hold the rule actions
* action_size - size of action_array
int regmatch_strtol (regmatch_t * m, const char *src, char **endptr, int base);
bool regmatch_empty (regmatch_t * m);
+/* From "scanflags.h" */
+typedef unsigned int scanflags_t;
+extern scanflags_t* _sf_stk;
+extern size_t _sf_n, _sf_max; /**< stack of scanner flags. */
+#define _SF_CASE_INS 0x0001
+#define _SF_DOT_ALL 0x0002
+#define _SF_SKIP_WS 0x0004
+
+#define sf_top() (_sf_stk[sf_n])
+#define sf_case_ins() (sf_top() & _SF_CASE_INS)
+#define sf_dot_all() (sf_top() & _SF_DOT_ALL)
+#define sf_skip_ws() (sf_top() & _SF_SKIP_WS)
+#define sf_set_case_ins(X) ((X) ? (sf_top() |= _SF_CASE_INS) : (sf_top() &= ~_SF_CASE_INS))
+#define sf_set_dot_all(X) ((X) ? (sf_top() |= _SF_DOT_ALL) : (sf_top() &= ~_SF_DOT_ALL))
+#define sf_set_skip_ws(X) ((X) ? (sf_top() |= _SF_SKIP_WS) : (sf_top() &= ~_SF_SKIP_WS))
+
+extern void sf_push(void);
+extern void sf_pop(void);
+
+
#endif /* not defined FLEXDEF_H */
--- /dev/null
+/* scanflags - flags used by scanning. */
+
+/* Copyright (c) 1990 The Regents of the University of California. */
+/* All rights reserved. */
+
+/* This code is derived from software contributed to Berkeley by */
+/* Vern Paxson. */
+
+/* The United States Government has rights in this work pursuant */
+/* to contract no. DE-AC03-76SF00098 between the United States */
+/* Department of Energy and the University of California. */
+
+/* This file is part of flex. */
+
+/* Redistribution and use in source and binary forms, with or without */
+/* modification, are permitted provided that the following conditions */
+/* are met: */
+
+/* 1. Redistributions of source code must retain the above copyright */
+/* notice, this list of conditions and the following disclaimer. */
+/* 2. Redistributions in binary form must reproduce the above copyright */
+/* notice, this list of conditions and the following disclaimer in the */
+/* documentation and/or other materials provided with the distribution. */
+
+/* Neither the name of the University nor the names of its contributors */
+/* may be used to endorse or promote products derived from this software */
+/* without specific prior written permission. */
+
+/* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR */
+/* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED */
+/* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR */
+/* PURPOSE. */
+
+#include "flexdef.h"
+
+scanflags_t* _sf_stk = NULL;
+size_t _sf_n=0, _sf_max=0;
+
+void
+sf_push (void)
+{
+ if (_sf_n + 1 >= _sf_max)
+ _sf_stk = (scanflags_t*) flex_realloc ( (void*) _sf_stk, sizeof(scanflags_t) * (_sf_max += 32));
+
+ // copy the top element
+ _sf_stk[_sf_n + 1] = _sf_stk[_sf_n];
+ ++_sf_n;
+}
+
+void
+sf_pop (void)
+{
+ assert(_sf_n > 0);
+ --_sf_n;
+}
+
+/* one-time initialization. Should be called before any sf_ functions. */
+void
+sf_init (void)
+{
+ assert(_sf_stk == NULL);
+ _sf_stk = (scanflags_t*) flex_alloc ( sizeof(scanflags_t) * (_sf_max = 32));
+ _sf_stk[_sf_n] = 0;
+}
+
+/* vim:set expandtab cindent tabstop=4 softtabstop=4 shiftwidth=4 textwidth=0: */