#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
-# Generated automatically using autoconf version 2.12
+# Generated automatically using autoconf version 2.13
# Copyright (C) 1992, 93, 94, 95, 96 Free Software Foundation, Inc.
#
# This configure script is free software; the Free Software Foundation
ac_help=
ac_default_prefix=/usr/local
# Any additions from configure.in:
+ac_help="$ac_help
+ --with-tclconfig Path for tclConfig.sh"
# Initialize some variables set by options.
# The variables have the same names as the options, with
# Initialize some other variables.
subdirs=
MFLAGS= MAKEFLAGS=
+SHELL=${CONFIG_SHELL-/bin/sh}
# Maximum number of lines to put in a shell here document.
ac_max_here_lines=12
verbose=yes ;;
-version | --version | --versio | --versi | --vers)
- echo "configure generated by autoconf version 2.12"
+ echo "configure generated by autoconf version 2.13"
exit 0 ;;
-with-* | --with-*)
# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
ac_cpp='$CPP $CPPFLAGS'
ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
-ac_link='${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
+ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
cross_compiling=$ac_cv_prog_cc_cross
+ac_exeext=
+ac_objext=o
if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then
# Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu.
if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then
+
+
+
# Extract the first word of "gcc", so it can be a program name with args.
set dummy gcc; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:526: checking for $ac_word" >&5
+echo "configure:534: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
if test -n "$CC"; then
ac_cv_prog_CC="$CC" # Let the user override the test.
else
- IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
- for ac_dir in $PATH; do
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
+ ac_dummy="$PATH"
+ for ac_dir in $ac_dummy; do
test -z "$ac_dir" && ac_dir=.
if test -f $ac_dir/$ac_word; then
ac_cv_prog_CC="gcc"
# Extract the first word of "cc", so it can be a program name with args.
set dummy cc; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:555: checking for $ac_word" >&5
+echo "configure:564: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
if test -n "$CC"; then
ac_cv_prog_CC="$CC" # Let the user override the test.
else
- IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
ac_prog_rejected=no
- for ac_dir in $PATH; do
+ ac_dummy="$PATH"
+ for ac_dir in $ac_dummy; do
test -z "$ac_dir" && ac_dir=.
if test -f $ac_dir/$ac_word; then
if test "$ac_dir/$ac_word" = "/usr/ucb/cc"; then
echo "$ac_t""no" 1>&6
fi
+ if test -z "$CC"; then
+ case "`uname -s`" in
+ *win32* | *WIN32*)
+ # Extract the first word of "cl", so it can be a program name with args.
+set dummy cl; ac_word=$2
+echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+echo "configure:615: checking for $ac_word" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ if test -n "$CC"; then
+ ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
+ ac_dummy="$PATH"
+ for ac_dir in $ac_dummy; do
+ test -z "$ac_dir" && ac_dir=.
+ if test -f $ac_dir/$ac_word; then
+ ac_cv_prog_CC="cl"
+ break
+ fi
+ done
+ IFS="$ac_save_ifs"
+fi
+fi
+CC="$ac_cv_prog_CC"
+if test -n "$CC"; then
+ echo "$ac_t""$CC" 1>&6
+else
+ echo "$ac_t""no" 1>&6
+fi
+ ;;
+ esac
+ fi
test -z "$CC" && { echo "configure: error: no acceptable cc found in \$PATH" 1>&2; exit 1; }
fi
echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6
-echo "configure:603: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5
+echo "configure:647: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5
ac_ext=c
# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
ac_cpp='$CPP $CPPFLAGS'
ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
-ac_link='${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
+ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
cross_compiling=$ac_cv_prog_cc_cross
-cat > conftest.$ac_ext <<EOF
-#line 613 "configure"
+cat > conftest.$ac_ext << EOF
+
+#line 658 "configure"
#include "confdefs.h"
+
main(){return(0);}
EOF
-if { (eval echo configure:617: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:663: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
ac_cv_prog_cc_works=yes
# If we can't run a trivial program, we are probably using a cross compiler.
if (./conftest; exit) 2>/dev/null; then
ac_cv_prog_cc_works=no
fi
rm -fr conftest*
+ac_ext=c
+# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
+ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
+cross_compiling=$ac_cv_prog_cc_cross
echo "$ac_t""$ac_cv_prog_cc_works" 1>&6
if test $ac_cv_prog_cc_works = no; then
{ echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; }
fi
echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6
-echo "configure:637: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5
+echo "configure:689: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5
echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6
cross_compiling=$ac_cv_prog_cc_cross
echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6
-echo "configure:642: checking whether we are using GNU C" >&5
+echo "configure:694: checking whether we are using GNU C" >&5
if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
yes;
#endif
EOF
-if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:651: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
+if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:703: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
ac_cv_prog_gcc=yes
else
ac_cv_prog_gcc=no
if test $ac_cv_prog_gcc = yes; then
GCC=yes
- ac_test_CFLAGS="${CFLAGS+set}"
- ac_save_CFLAGS="$CFLAGS"
- CFLAGS=
- echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6
-echo "configure:666: checking whether ${CC-cc} accepts -g" >&5
+else
+ GCC=
+fi
+
+ac_test_CFLAGS="${CFLAGS+set}"
+ac_save_CFLAGS="$CFLAGS"
+CFLAGS=
+echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6
+echo "configure:722: checking whether ${CC-cc} accepts -g" >&5
if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
fi
echo "$ac_t""$ac_cv_prog_cc_g" 1>&6
- if test "$ac_test_CFLAGS" = set; then
- CFLAGS="$ac_save_CFLAGS"
- elif test $ac_cv_prog_cc_g = yes; then
+if test "$ac_test_CFLAGS" = set; then
+ CFLAGS="$ac_save_CFLAGS"
+elif test $ac_cv_prog_cc_g = yes; then
+ if test "$GCC" = yes; then
CFLAGS="-g -O2"
else
- CFLAGS="-O2"
+ CFLAGS="-g"
fi
else
- GCC=
- test "${CFLAGS+set}" = set || CFLAGS="-g"
+ if test "$GCC" = yes; then
+ CFLAGS="-O2"
+ else
+ CFLAGS=
+ fi
fi
echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6
-echo "configure:694: checking how to run the C preprocessor" >&5
+echo "configure:754: checking how to run the C preprocessor" >&5
# On Suns, sometimes $CPP names a directory.
if test -n "$CPP" && test -d "$CPP"; then
CPP=
# On the NeXT, cc -E runs the code through the compiler's parser,
# not just through cpp.
cat > conftest.$ac_ext <<EOF
-#line 709 "configure"
+#line 769 "configure"
#include "confdefs.h"
#include <assert.h>
Syntax Error
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:715: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out`
+{ (eval echo configure:775: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
:
else
rm -rf conftest*
CPP="${CC-cc} -E -traditional-cpp"
cat > conftest.$ac_ext <<EOF
-#line 726 "configure"
+#line 786 "configure"
#include "confdefs.h"
#include <assert.h>
Syntax Error
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:732: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out`
+{ (eval echo configure:792: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+if test -z "$ac_err"; then
+ :
+else
+ echo "$ac_err" >&5
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ CPP="${CC-cc} -nologo -E"
+ cat > conftest.$ac_ext <<EOF
+#line 803 "configure"
+#include "confdefs.h"
+#include <assert.h>
+Syntax Error
+EOF
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:809: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
:
else
rm -f conftest*
fi
rm -f conftest*
+fi
+rm -f conftest*
ac_cv_prog_CPP="$CPP"
fi
CPP="$ac_cv_prog_CPP"
# SunOS /usr/etc/install
# IRIX /sbin/install
# AIX /bin/install
+# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag
# AFS /usr/afsws/bin/install, which mishandles nonexistent args
# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
# ./install, which can be erroneously created by make from ./install.sh.
echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6
-echo "configure:784: checking for a BSD compatible install" >&5
+echo "configure:864: checking for a BSD compatible install" >&5
if test -z "$INSTALL"; then
if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
- IFS="${IFS= }"; ac_save_IFS="$IFS"; IFS="${IFS}:"
+ IFS="${IFS= }"; ac_save_IFS="$IFS"; IFS=":"
for ac_dir in $PATH; do
# Account for people who put trailing slashes in PATH elements.
case "$ac_dir/" in
/|./|.//|/etc/*|/usr/sbin/*|/usr/etc/*|/sbin/*|/usr/afsws/bin/*|/usr/ucb/*) ;;
*)
# OSF1 and SCO ODT 3.0 have their own names for install.
- for ac_prog in ginstall installbsd scoinst install; do
+ # Don't use installbsd from OSF since it installs stuff as root
+ # by default.
+ for ac_prog in ginstall scoinst install; do
if test -f $ac_dir/$ac_prog; then
if test $ac_prog = install &&
grep dspmsg $ac_dir/$ac_prog >/dev/null 2>&1; then
# AIX install. It has an incompatible calling convention.
- # OSF/1 installbsd also uses dspmsg, but is usable.
:
else
ac_cv_path_install="$ac_dir/$ac_prog -c"
# It thinks the first close brace ends the variable substitution.
test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}'
+test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL_PROGRAM}'
+
test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
# Extract the first word of "ranlib", so it can be a program name with args.
set dummy ranlib; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:836: checking for $ac_word" >&5
+echo "configure:919: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
if test -n "$RANLIB"; then
ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test.
else
- IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
- for ac_dir in $PATH; do
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
+ ac_dummy="$PATH"
+ for ac_dir in $ac_dummy; do
test -z "$ac_dir" && ac_dir=.
if test -f $ac_dir/$ac_word; then
ac_cv_prog_RANLIB="ranlib"
echo "$ac_t""no" 1>&6
fi
+TCL_LIB=""
+TCL_INCLUDE=""
+tclconfig=NONE
+# Check whether --with-tclconfig or --without-tclconfig was given.
+if test "${with_tclconfig+set}" = set; then
+ withval="$with_tclconfig"
+ tclconfig=$withval
+fi
+
+if test "x$tclconfig" = xNONE; then
+ saveprefix=${prefix}
+ if test "x$prefix" = xNONE; then
+echo $ac_n "checking for prefix by $ac_c" 1>&6
+# Extract the first word of "tclsh", so it can be a program name with args.
+set dummy tclsh; ac_word=$2
+echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+echo "configure:962: checking for $ac_word" >&5
+if eval "test \"`echo '$''{'ac_cv_path_TCLSH'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ case "$TCLSH" in
+ /*)
+ ac_cv_path_TCLSH="$TCLSH" # Let the user override the test with a path.
+ ;;
+ ?:/*)
+ ac_cv_path_TCLSH="$TCLSH" # Let the user override the test with a dos path.
+ ;;
+ *)
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
+ ac_dummy="$PATH"
+ for ac_dir in $ac_dummy; do
+ test -z "$ac_dir" && ac_dir=.
+ if test -f $ac_dir/$ac_word; then
+ ac_cv_path_TCLSH="$ac_dir/$ac_word"
+ break
+ fi
+ done
+ IFS="$ac_save_ifs"
+ ;;
+esac
+fi
+TCLSH="$ac_cv_path_TCLSH"
+if test -n "$TCLSH"; then
+ echo "$ac_t""$TCLSH" 1>&6
+else
+ echo "$ac_t""no" 1>&6
+fi
+
+ if test -n "$ac_cv_path_TCLSH"; then
+ prefix=`echo $ac_cv_path_TCLSH|sed 's%/[^/][^/]*//*[^/][^/]*$%%'`
+ fi
+fi
+
+ tclconfig=${prefix}/lib
+ prefix=${saveprefix}
+fi
+if test -r ${tclconfig}/tclConfig.sh; then
+ echo $ac_n "checking for Tcl""... $ac_c" 1>&6
+echo "configure:1004: checking for Tcl" >&5
+ . ${tclconfig}/tclConfig.sh
+ TCL_LIB="$TCL_LIB_SPEC $TCL_LIBS"
+ TCL_INCLUDE=-I${TCL_PREFIX}/include
+ SHLIB_CFLAGS=$TCL_SHLIB_CFLAGS
+ SHLIB_LD=$TCL_SHLIB_LD
+ SHLIB_SUFFIX=$TCL_SHLIB_SUFFIX
+ SHLIB_VERSION=$TCL_SHLIB_VERSION
+ echo "$ac_t""$TCL_VERSION" 1>&6
+ ODEFS="-DHAVE_TCL_H=1"
+fi
checkBoth=0
echo $ac_n "checking for connect""... $ac_c" 1>&6
-echo "configure:864: checking for connect" >&5
+echo "configure:1017: checking for connect" >&5
if eval "test \"`echo '$''{'ac_cv_func_connect'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 869 "configure"
+#line 1022 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char connect(); below. */
; return 0; }
EOF
-if { (eval echo configure:892: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:1045: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_func_connect=yes"
else
if test "$ac_cv_func_connect" = "no"; then
echo $ac_n "checking for main in -lsocket""... $ac_c" 1>&6
-echo "configure:913: checking for main in -lsocket" >&5
+echo "configure:1066: checking for main in -lsocket" >&5
ac_lib_var=`echo socket'_'main | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
ac_save_LIBS="$LIBS"
LIBS="-lsocket $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 921 "configure"
+#line 1074 "configure"
#include "confdefs.h"
int main() {
main()
; return 0; }
EOF
-if { (eval echo configure:928: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:1081: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
oldLibs=$LIBS
LIBS="$LIBS -lsocket -lnsl"
echo $ac_n "checking for accept""... $ac_c" 1>&6
-echo "configure:954: checking for accept" >&5
+echo "configure:1107: checking for accept" >&5
if eval "test \"`echo '$''{'ac_cv_func_accept'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 959 "configure"
+#line 1112 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char accept(); below. */
; return 0; }
EOF
-if { (eval echo configure:982: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:1135: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_func_accept=yes"
else
fi
echo $ac_n "checking for gethostbyname""... $ac_c" 1>&6
-echo "configure:1004: checking for gethostbyname" >&5
+echo "configure:1157: checking for gethostbyname" >&5
if eval "test \"`echo '$''{'ac_cv_func_gethostbyname'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1009 "configure"
+#line 1162 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char gethostbyname(); below. */
; return 0; }
EOF
-if { (eval echo configure:1032: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:1185: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_func_gethostbyname=yes"
else
else
echo "$ac_t""no" 1>&6
echo $ac_n "checking for main in -lnsl""... $ac_c" 1>&6
-echo "configure:1050: checking for main in -lnsl" >&5
+echo "configure:1203: checking for main in -lnsl" >&5
ac_lib_var=`echo nsl'_'main | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
ac_save_LIBS="$LIBS"
LIBS="-lnsl $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 1058 "configure"
+#line 1211 "configure"
#include "confdefs.h"
int main() {
main()
; return 0; }
EOF
-if { (eval echo configure:1065: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:1218: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
fi
echo $ac_n "checking for main in -lwrap""... $ac_c" 1>&6
-echo "configure:1088: checking for main in -lwrap" >&5
+echo "configure:1241: checking for main in -lwrap" >&5
ac_lib_var=`echo wrap'_'main | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
ac_save_LIBS="$LIBS"
LIBS="-lwrap $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 1096 "configure"
+#line 1249 "configure"
#include "confdefs.h"
int main() {
main()
; return 0; }
EOF
-if { (eval echo configure:1103: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:1256: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
fi
echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6
-echo "configure:1124: checking for ANSI C header files" >&5
+echo "configure:1277: checking for ANSI C header files" >&5
if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1129 "configure"
+#line 1282 "configure"
#include "confdefs.h"
#include <stdlib.h>
#include <stdarg.h>
#include <float.h>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1137: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out`
+{ (eval echo configure:1290: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
rm -rf conftest*
ac_cv_header_stdc=yes
if test $ac_cv_header_stdc = yes; then
# SunOS 4.x string.h does not declare mem*, contrary to ANSI.
cat > conftest.$ac_ext <<EOF
-#line 1154 "configure"
+#line 1307 "configure"
#include "confdefs.h"
#include <string.h>
EOF
if test $ac_cv_header_stdc = yes; then
# ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
cat > conftest.$ac_ext <<EOF
-#line 1172 "configure"
+#line 1325 "configure"
#include "confdefs.h"
#include <stdlib.h>
EOF
:
else
cat > conftest.$ac_ext <<EOF
-#line 1193 "configure"
+#line 1346 "configure"
#include "confdefs.h"
#include <ctype.h>
#define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
exit (0); }
EOF
-if { (eval echo configure:1204: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:1357: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
then
:
else
# Ultrix sh set writes to stderr and can't be redirected directly,
# and sets the high bit in the cache file unless we assign to the vars.
(set) 2>&1 |
- case `(ac_space=' '; set) 2>&1` in
+ case `(ac_space=' '; set | grep ac_space) 2>&1` in
*ac_space=\ *)
# `set' does not quote correctly, so add quotes (double-quote substitution
# turns \\\\ into \\, and sed turns \\ into \).
echo "running \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion"
exec \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion ;;
-version | --version | --versio | --versi | --vers | --ver | --ve | --v)
- echo "$CONFIG_STATUS generated by autoconf version 2.12"
+ echo "$CONFIG_STATUS generated by autoconf version 2.13"
exit 0 ;;
-help | --help | --hel | --he | --h)
echo "\$ac_cs_usage"; exit 0 ;;
s/@@/%@/; s/@@/@%/; s/@g\$/%g/' > conftest.subs <<\\CEOF
$ac_vpsub
$extrasub
+s%@SHELL@%$SHELL%g
s%@CFLAGS@%$CFLAGS%g
s%@CPPFLAGS@%$CPPFLAGS%g
s%@CXXFLAGS@%$CXXFLAGS%g
+s%@FFLAGS@%$FFLAGS%g
s%@DEFS@%$DEFS%g
s%@LDFLAGS@%$LDFLAGS%g
s%@LIBS@%$LIBS%g
s%@infodir@%$infodir%g
s%@mandir@%$mandir%g
s%@ODEFS@%$ODEFS%g
+s%@TCL_INCLUDE@%$TCL_INCLUDE%g
+s%@TCL_LIB@%$TCL_LIB%g
s%@CC@%$CC%g
s%@CPP@%$CPP%g
s%@INSTALL_PROGRAM@%$INSTALL_PROGRAM%g
+s%@INSTALL_SCRIPT@%$INSTALL_SCRIPT%g
s%@INSTALL_DATA@%$INSTALL_DATA%g
s%@RANLIB@%$RANLIB%g
+s%@TCLSH@%$TCLSH%g
CEOF
EOF
/*
- * Copyright (C) 1994-1998, Index Data
+ * Copyright (C) 1994-1999, Index Data
* All rights reserved.
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: regxread.c,v $
- * Revision 1.22 1998-11-03 16:07:13 adam
+ * Revision 1.23 1999-05-20 12:57:18 adam
+ * Implemented TCL filter. Updated recctrl system.
+ *
+ * Revision 1.22 1998/11/03 16:07:13 adam
* Yet another fix.
*
* Revision 1.21 1998/11/03 15:43:39 adam
#include <dfa.h>
#include "grsread.h"
+#if HAVE_TCL_H
+#include <tcl.h>
+#endif
+
#define REGX_DEBUG 0
#define F_WIN_EOF 2000000000
#define REGX_END 4
#define REGX_CODE 5
#define REGX_CONTEXT 6
+#define REGX_INIT 7
struct regxCode {
char *str;
struct lexRule *rules;
struct lexRuleInfo **fastRule;
int ruleNo;
+ int initFlag;
struct lexRuleAction *beginActionList;
struct lexRuleAction *endActionList;
+ struct lexRuleAction *initActionList;
struct lexContext *next;
};
};
struct lexSpec {
-
char *name;
struct lexContext *context;
int lineNo;
NMEM m;
data1_handle dh;
+#if HAVE_TCL_H
+ Tcl_Interp *tcl_interp;
+#endif
void *f_win_fh;
void (*f_win_ef)(void *, off_t);
struct lexConcatBuf **concatBuf;
int maxLevel;
+ data1_node **d1_stack;
+ int d1_level;
+ int stop_flag;
+
+ int *arg_start;
+ int *arg_end;
+ int arg_no;
+ int ptr;
};
+struct lexSpecs {
+ struct lexSpec *spec;
+};
static char *f_win_get (struct lexSpec *spec, off_t start_pos, off_t end_pos,
int *size)
p->name = xstrdup (name);
p->ruleNo = 1;
+ p->initFlag = 0;
p->dfa = lexSpecDFA ();
p->rules = NULL;
p->fastRule = NULL;
p->beginActionList = NULL;
p->endActionList = NULL;
+ p->initActionList = NULL;
p->next = NULL;
return p;
}
xfree (p);
}
-static struct lexSpec *lexSpecCreate (const char *name)
+static struct lexSpec *lexSpecCreate (const char *name, data1_handle dh)
{
struct lexSpec *p;
int i;
-
+
p = xmalloc (sizeof(*p));
p->name = xmalloc (strlen(name)+1);
strcpy (p->name, name);
+#if HAVE_TCL_H
+ p->tcl_interp = 0;
+#endif
+ p->dh = dh;
p->context = NULL;
p->context_stack_size = 100;
p->context_stack = xmalloc (sizeof(*p->context_stack) *
p->concatBuf[i]->len = p->concatBuf[i]->max = 0;
p->concatBuf[i]->buf = 0;
}
+ p->d1_stack = xmalloc (sizeof(*p->d1_stack) * p->maxLevel);
+ p->d1_level = 0;
return p;
}
lexContextDestroy (lt);
lt = lt_next;
}
+#if HAVE_TCL_H
+ if (p->tcl_interp)
+ Tcl_DeleteInterp (p->tcl_interp);
+#endif
xfree (p->name);
xfree (p->f_win_buf);
xfree (p->context_stack);
+ xfree (p->d1_stack);
xfree (p);
*pp = NULL;
}
return REGX_BODY;
else if (!strcmp (cmd, "context"))
return REGX_CONTEXT;
+ else if (!strcmp (cmd, "init"))
+ return REGX_INIT;
else
{
logf (LOG_WARN, "bad command %s", cmd);
s++;
break;
case REGX_BEGIN:
- logf (LOG_WARN, "cannot use begin here");
+ logf (LOG_WARN, "cannot use BEGIN here");
+ continue;
+ case REGX_INIT:
+ logf (LOG_WARN, "cannot use INIT here");
continue;
case REGX_END:
*ap = xmalloc (sizeof(**ap));
actionListDel (&spec->context->endActionList);
actionListMk (spec, s, &spec->context->endActionList);
break;
+ case REGX_INIT:
+ actionListDel (&spec->context->initActionList);
+ actionListMk (spec, s, &spec->context->initActionList);
+ break;
case REGX_PATTERN:
#if REGX_DEBUG
logf (LOG_DEBUG, "rule %d %s", spec->context->ruleNo, s);
}
if (errors)
return -1;
+
return 0;
}
+#if 0
static struct lexSpec *curLexSpec = NULL;
+#endif
static void execData (struct lexSpec *spec,
- data1_node **d1_stack, int *d1_level,
const char *ebuf, int elen, int formatted_text)
{
struct data1_node *res, *parent;
logf (LOG_DEBUG, "data (%d bytes)", elen);
#endif
- if (*d1_level <= 1)
+ if (spec->d1_level <= 1)
return;
- parent = d1_stack[*d1_level -1];
+ parent = spec->d1_stack[spec->d1_level -1];
assert (parent);
- if ((res = d1_stack[*d1_level]) && res->which == DATA1N_data)
+ if ((res = spec->d1_stack[spec->d1_level]) && res->which == DATA1N_data)
org_len = res->u.data.len;
else
{
res->root = parent->root;
parent->last_child = res;
- if (d1_stack[*d1_level])
- d1_stack[*d1_level]->next = res;
+ if (spec->d1_stack[spec->d1_level])
+ spec->d1_stack[spec->d1_level]->next = res;
else
parent->child = res;
- d1_stack[*d1_level] = res;
+ spec->d1_stack[spec->d1_level] = res;
}
- if (org_len + elen >= spec->concatBuf[*d1_level]->max)
+ if (org_len + elen >= spec->concatBuf[spec->d1_level]->max)
{
char *old_buf, *new_buf;
- spec->concatBuf[*d1_level]->max = org_len + elen + 256;
- new_buf = xmalloc (spec->concatBuf[*d1_level]->max);
- if ((old_buf = spec->concatBuf[*d1_level]->buf))
+ spec->concatBuf[spec->d1_level]->max = org_len + elen + 256;
+ new_buf = xmalloc (spec->concatBuf[spec->d1_level]->max);
+ if ((old_buf = spec->concatBuf[spec->d1_level]->buf))
{
memcpy (new_buf, old_buf, org_len);
xfree (old_buf);
}
- spec->concatBuf[*d1_level]->buf = new_buf;
+ spec->concatBuf[spec->d1_level]->buf = new_buf;
}
- assert (spec->concatBuf[*d1_level]);
- memcpy (spec->concatBuf[*d1_level]->buf + org_len, ebuf, elen);
+ assert (spec->concatBuf[spec->d1_level]);
+ memcpy (spec->concatBuf[spec->d1_level]->buf + org_len, ebuf, elen);
res->u.data.len += elen;
}
static void execDataP (struct lexSpec *spec,
- data1_node **d1_stack, int *d1_level,
const char *ebuf, int elen, int formatted_text)
{
- execData (spec, d1_stack, d1_level, ebuf, elen, formatted_text);
+ execData (spec, ebuf, elen, formatted_text);
}
-static void tagDataRelease (struct lexSpec *spec,
- data1_node **d1_stack, int d1_level)
+static void tagDataRelease (struct lexSpec *spec)
{
data1_node *res;
- if ((res = d1_stack[d1_level]) &&
+ if ((res = spec->d1_stack[spec->d1_level]) &&
res->which == DATA1N_data &&
res->u.data.what == DATA1I_text)
{
res->u.data.data = nmem_malloc (spec->m, res->u.data.len);
else
res->u.data.data = res->lbuf;
- memcpy (res->u.data.data, spec->concatBuf[d1_level]->buf,
+ memcpy (res->u.data.data, spec->concatBuf[spec->d1_level]->buf,
res->u.data.len);
}
}
static void variantBegin (struct lexSpec *spec,
- data1_node **d1_stack, int *d1_level,
const char *class_str, int class_len,
const char *type_str, int type_len,
const char *value_str, int value_len)
{
- struct data1_node *parent = d1_stack[*d1_level -1];
+ struct data1_node *parent = spec->d1_stack[spec->d1_level -1];
char tclass[DATA1_MAX_SYMBOL], ttype[DATA1_MAX_SYMBOL];
data1_vartype *tp;
int i;
data1_node *res;
- if (*d1_level == 0)
+ if (spec->d1_level == 0)
{
logf (LOG_WARN, "in variant begin. No record type defined");
return ;
ttype[type_len] = '\0';
#if REGX_DEBUG
- logf (LOG_DEBUG, "variant begin %s %s (%d)", tclass, ttype, *d1_level);
+ logf (LOG_DEBUG, "variant begin %s %s (%d)", tclass, ttype,
+ spec->d1_level);
#endif
if (!(tp =
res->root = parent->root;
parent->last_child = res;
- if (d1_stack[*d1_level])
+ if (spec->d1_stack[spec->d1_level])
{
- tagDataRelease (spec, d1_stack, *d1_level);
- d1_stack[*d1_level]->next = res;
+ tagDataRelease (spec);
+ spec->d1_stack[spec->d1_level]->next = res;
}
else
parent->child = res;
- d1_stack[*d1_level] = res;
- d1_stack[++(*d1_level)] = NULL;
+ spec->d1_stack[spec->d1_level] = res;
+ spec->d1_stack[++(spec->d1_level)] = NULL;
}
- for (i = *d1_level-1; d1_stack[i]->which == DATA1N_variant; i--)
- if (d1_stack[i]->u.variant.type == tp)
+ for (i = spec->d1_level-1; spec->d1_stack[i]->which == DATA1N_variant; i--)
+ if (spec->d1_stack[i]->u.variant.type == tp)
{
- *d1_level = i;
+ spec->d1_level = i;
break;
}
#if REGX_DEBUG
- logf (LOG_DEBUG, "variant node (%d)", *d1_level);
+ logf (LOG_DEBUG, "variant node (%d)", spec->d1_level);
#endif
- parent = d1_stack[*d1_level-1];
+ parent = spec->d1_stack[spec->d1_level-1];
res = data1_mk_node (spec->dh, spec->m);
res->parent = parent;
res->which = DATA1N_variant;
res->u.variant.value = res->lbuf;
parent->last_child = res;
- if (d1_stack[*d1_level])
+ if (spec->d1_stack[spec->d1_level])
{
- tagDataRelease (spec, d1_stack, *d1_level);
- d1_stack[*d1_level]->next = res;
+ tagDataRelease (spec);
+ spec->d1_stack[spec->d1_level]->next = res;
}
else
parent->child = res;
- d1_stack[*d1_level] = res;
- d1_stack[++(*d1_level)] = NULL;
+ spec->d1_stack[spec->d1_level] = res;
+ spec->d1_stack[++(spec->d1_level)] = NULL;
}
static void tagStrip (const char **tag, int *len)
}
static void tagBegin (struct lexSpec *spec,
- data1_node **d1_stack, int *d1_level,
const char *tag, int len)
{
- struct data1_node *parent = d1_stack[*d1_level -1];
+ struct data1_node *parent = spec->d1_stack[spec->d1_level -1];
data1_element *elem = NULL;
data1_node *partag = get_parent_tag(spec->dh, parent);
data1_node *res;
data1_element *e = NULL;
int localtag = 0;
- if (*d1_level == 0)
+ if (spec->d1_level == 0)
{
logf (LOG_WARN, "in element begin. No record type defined");
return ;
res->u.tag.tag[len] = '\0';
#if REGX_DEBUG
- logf (LOG_DEBUG, "begin tag %s (%d)", res->u.tag.tag, *d1_level);
+ logf (LOG_DEBUG, "begin tag %s (%d)", res->u.tag.tag, spec->d1_level);
#endif
if (parent->which == DATA1N_variant)
return ;
if (!(e = partag->u.tag.element))
localtag = 1;
- elem = data1_getelementbytagname (spec->dh, d1_stack[0]->u.root.absyn,
+ elem = data1_getelementbytagname (spec->dh,
+ spec->d1_stack[0]->u.root.absyn,
e, res->u.tag.tag);
res->u.tag.element = elem;
res->u.tag.node_selected = 0;
res->root = parent->root;
parent->last_child = res;
- if (d1_stack[*d1_level])
+ if (spec->d1_stack[spec->d1_level])
{
- tagDataRelease (spec, d1_stack, *d1_level);
- d1_stack[*d1_level]->next = res;
+ tagDataRelease (spec);
+ spec->d1_stack[spec->d1_level]->next = res;
}
else
parent->child = res;
- d1_stack[*d1_level] = res;
- d1_stack[++(*d1_level)] = NULL;
+ spec->d1_stack[spec->d1_level] = res;
+ spec->d1_stack[++(spec->d1_level)] = NULL;
}
-static void tagEnd (struct lexSpec *spec,
- data1_node **d1_stack, int *d1_level, int min_level,
+static void tagEnd (struct lexSpec *spec, int min_level,
const char *tag, int len)
{
tagStrip (&tag, &len);
- while (*d1_level > min_level)
+ while (spec->d1_level > min_level)
{
- tagDataRelease (spec, d1_stack, *d1_level);
- (*d1_level)--;
- if (*d1_level == 0)
+ tagDataRelease (spec);
+ (spec->d1_level)--;
+ if (spec->d1_level == 0)
break;
- if ((d1_stack[*d1_level]->which == DATA1N_tag) &&
+ if ((spec->d1_stack[spec->d1_level]->which == DATA1N_tag) &&
(!tag ||
- (strlen(d1_stack[*d1_level]->u.tag.tag) == (size_t) len &&
- !memcmp (d1_stack[*d1_level]->u.tag.tag, tag, len))))
+ (strlen(spec->d1_stack[spec->d1_level]->u.tag.tag) ==
+ (size_t) len &&
+ !memcmp (spec->d1_stack[spec->d1_level]->u.tag.tag, tag, len))))
break;
}
#if REGX_DEBUG
- logf (LOG_DEBUG, "end tag (%d)", *d1_level);
+ logf (LOG_DEBUG, "end tag (%d)", spec->d1_level);
#endif
}
}
static int execTok (struct lexSpec *spec, const char **src,
- int arg_no, int *arg_start, int *arg_end,
const char **tokBuf, int *tokLen)
{
const char *s = *src;
s++;
while (*s >= '0' && *s <= '9')
n = n*10 + (*s++ -'0');
- if (arg_no == 0)
+ if (spec->arg_no == 0)
{
*tokBuf = "";
*tokLen = 0;
}
else
{
- if (n >= arg_no)
- n = arg_no-1;
- *tokBuf = f_win_get (spec, arg_start[n], arg_end[n], tokLen);
+ if (n >= spec->arg_no)
+ n = spec->arg_no-1;
+ *tokBuf = f_win_get (spec, spec->arg_start[n], spec->arg_end[n],
+ tokLen);
}
}
else if (*s == '\"')
return str;
}
-static int execCode (struct lexSpec *spec,
- int arg_no, int *arg_start, int *arg_end, int *pptr,
- struct regxCode *code,
- data1_node **d1_stack, int *d1_level)
+#if HAVE_TCL_H
+static int cmd_tcl_begin (ClientData clientData, Tcl_Interp *interp,
+ int argc, char **argv)
+{
+ struct lexSpec *spec = clientData;
+ if (argc < 2)
+ return TCL_ERROR;
+ if (!strcmp(argv[1], "record") && argc == 3)
+ {
+ char *absynName = argv[2];
+ data1_absyn *absyn;
+
+#if REGX_DEBUG
+ logf (LOG_DEBUG, "begin record %s", absynName);
+#endif
+ if (!(absyn = data1_get_absyn (spec->dh, absynName)))
+ logf (LOG_WARN, "Unknown tagset: %s", absynName);
+ else
+ {
+ data1_node *res;
+
+ res = data1_mk_node (spec->dh, spec->m);
+ res->which = DATA1N_root;
+ res->u.root.type = absynName;
+ res->u.root.absyn = absyn;
+ res->root = res;
+
+ spec->d1_stack[spec->d1_level] = res;
+ spec->d1_stack[++(spec->d1_level)] = NULL;
+ }
+ }
+ else if (!strcmp(argv[1], "element") && argc == 3)
+ {
+ tagBegin (spec, argv[2], strlen(argv[2]));
+ }
+ else if (!strcmp (argv[1], "variant") && argc == 5)
+ {
+ variantBegin (spec, argv[2], strlen(argv[2]),
+ argv[3], strlen(argv[3]),
+ argv[4], strlen(argv[4]));
+ }
+ else if (!strcmp (argv[1], "context") && argc == 3)
+ {
+ struct lexContext *lc = spec->context;
+#if REGX_DEBUG
+ logf (LOG_DEBUG, "begin context %s",argv[2]);
+#endif
+ while (lc && strcmp (argv[2], lc->name))
+ lc = lc->next;
+ if (lc)
+ {
+ spec->context_stack[++(spec->context_stack_top)] = lc;
+ }
+ else
+ logf (LOG_WARN, "unknown context %s", argv[2]);
+ }
+ else
+ return TCL_ERROR;
+ return TCL_OK;
+}
+
+static int cmd_tcl_end (ClientData clientData, Tcl_Interp *interp,
+ int argc, char **argv)
+{
+ struct lexSpec *spec = clientData;
+ if (argc < 2)
+ return TCL_ERROR;
+
+ if (!strcmp (argv[1], "record"))
+ {
+ while (spec->d1_level)
+ {
+ tagDataRelease (spec);
+ (spec->d1_level)--;
+ }
+#if REGX_DEBUG
+ logf (LOG_DEBUG, "end record");
+#endif
+ spec->stop_flag = 1;
+ }
+ else if (!strcmp (argv[1], "element"))
+ {
+ int min_level = 1;
+ char *element = 0;
+ if (!strcmp(argv[2], "-record"))
+ {
+ min_level = 0;
+ if (argc == 4)
+ element = argv[3];
+ }
+ else
+ {
+ if (argc == 3)
+ element = argv[2];
+ }
+ tagEnd (spec, min_level, element, (element ? strlen(element) : 0));
+ if (spec->d1_level == 0)
+ {
+#if REGX_DEBUG
+ logf (LOG_DEBUG, "end element end records");
+#endif
+ spec->stop_flag = 1;
+ }
+ }
+ else if (!strcmp (argv[1], "context"))
+ {
+#if REGX_DEBUG
+ logf (LOG_DEBUG, "end context");
+#endif
+ if (spec->context_stack_top)
+ (spec->context_stack_top)--;
+ }
+ else
+ return TCL_ERROR;
+ return TCL_OK;
+}
+
+static int cmd_tcl_data (ClientData clientData, Tcl_Interp *interp,
+ int argc, char **argv)
+{
+ int argi = 1;
+ int textFlag = 0;
+ const char *element = 0;
+ struct lexSpec *spec = clientData;
+
+ while (argi < argc)
+ {
+ if (!strcmp("-text", argv[argi]))
+ {
+ textFlag = 1;
+ argi++;
+ }
+ else if (!strcmp("-element", argv[argi]))
+ {
+ argi++;
+ if (argi < argc)
+ element = argv[argi++];
+ }
+ else
+ break;
+ }
+ if (element)
+ tagBegin (spec, element, strlen(element));
+
+ while (argi < argc)
+ {
+ execData (spec, argv[argi], strlen(argv[argi]), textFlag);
+ argi++;
+ }
+ if (element)
+ tagEnd (spec, 1, NULL, 0);
+ return TCL_OK;
+}
+
+static int cmd_tcl_unread (ClientData clientData, Tcl_Interp *interp,
+ int argc, char **argv)
+{
+ struct lexSpec *spec = clientData;
+ int argi = 1;
+ int offset = 0;
+ int no;
+
+ while (argi < argc)
+ {
+ if (!strcmp("-offset", argv[argi]))
+ {
+ argi++;
+ if (argi < argc)
+ {
+ offset = atoi(argv[argi]);
+ argi++;
+ }
+ }
+ else
+ break;
+ }
+ if (argi != argc-1)
+ return TCL_ERROR;
+ no = atoi(argv[argi]);
+ if (no >= spec->arg_no)
+ no = spec->arg_no - 1;
+ spec->ptr = spec->arg_start[no] + offset;
+ return TCL_OK;
+}
+
+static void execTcl (struct lexSpec *spec, struct regxCode *code)
+{
+ int i;
+ for (i = 0; i < spec->arg_no; i++)
+ {
+ char var_name[10], *var_buf;
+ int var_len, ch;
+
+ sprintf (var_name, "%d", i);
+ var_buf = f_win_get (spec, spec->arg_start[i], spec->arg_end[i],
+ &var_len);
+ if (var_buf)
+ {
+ ch = var_buf[var_len];
+ var_buf[var_len] = '\0';
+ Tcl_SetVar (spec->tcl_interp, var_name, var_buf, 0);
+ var_buf[var_len] = ch;
+ }
+ }
+ Tcl_Eval (spec->tcl_interp, code->str);
+}
+/* HAVE_TCL_H */
+#endif
+
+static void execCode (struct lexSpec *spec, struct regxCode *code)
{
const char *s = code->str;
int cmd_len, r;
- int returnCode = 1;
const char *cmd_str;
- r = execTok (spec, &s, arg_no, arg_start, arg_end, &cmd_str, &cmd_len);
+ r = execTok (spec, &s, &cmd_str, &cmd_len);
while (r)
{
char *p, ptmp[64];
if (r == 1)
{
- r = execTok (spec, &s, arg_no, arg_start, arg_end,
- &cmd_str, &cmd_len);
+ r = execTok (spec, &s, &cmd_str, &cmd_len);
continue;
}
p = regxStrz (cmd_str, cmd_len, ptmp);
if (!strcmp (p, "begin"))
{
- r = execTok (spec, &s, arg_no, arg_start, arg_end,
- &cmd_str, &cmd_len);
+ r = execTok (spec, &s, &cmd_str, &cmd_len);
if (r < 2)
{
logf (LOG_WARN, "missing keyword after 'begin'");
p = regxStrz (cmd_str, cmd_len, ptmp);
if (!strcmp (p, "record"))
{
- r = execTok (spec, &s, arg_no, arg_start, arg_end,
- &cmd_str, &cmd_len);
+ r = execTok (spec, &s, &cmd_str, &cmd_len);
if (r < 2)
continue;
- if (*d1_level == 0)
+ if (spec->d1_level == 0)
{
static char absynName[64];
data1_absyn *absyn;
res->u.root.absyn = absyn;
res->root = res;
- d1_stack[*d1_level] = res;
- d1_stack[++(*d1_level)] = NULL;
+ spec->d1_stack[spec->d1_level] = res;
+ spec->d1_stack[++(spec->d1_level)] = NULL;
}
}
- r = execTok (spec, &s, arg_no, arg_start, arg_end,
- &cmd_str, &cmd_len);
+ r = execTok (spec, &s, &cmd_str, &cmd_len);
}
else if (!strcmp (p, "element"))
{
- r = execTok (spec, &s, arg_no, arg_start, arg_end,
- &cmd_str, &cmd_len);
+ r = execTok (spec, &s, &cmd_str, &cmd_len);
if (r < 2)
continue;
- tagBegin (spec, d1_stack, d1_level, cmd_str, cmd_len);
- r = execTok (spec, &s, arg_no, arg_start, arg_end,
- &cmd_str, &cmd_len);
+ tagBegin (spec, cmd_str, cmd_len);
+ r = execTok (spec, &s, &cmd_str, &cmd_len);
}
else if (!strcmp (p, "variant"))
{
const char *type_str = NULL;
int value_len;
const char *value_str = NULL;
- r = execTok (spec, &s, arg_no, arg_start, arg_end,
- &cmd_str, &cmd_len);
+ r = execTok (spec, &s, &cmd_str, &cmd_len);
if (r < 2)
continue;
class_str = cmd_str;
class_len = cmd_len;
- r = execTok (spec, &s, arg_no, arg_start, arg_end,
- &cmd_str, &cmd_len);
+ r = execTok (spec, &s, &cmd_str, &cmd_len);
if (r < 2)
continue;
type_str = cmd_str;
type_len = cmd_len;
- r = execTok (spec, &s, arg_no, arg_start, arg_end,
- &cmd_str, &cmd_len);
+ r = execTok (spec, &s, &cmd_str, &cmd_len);
if (r < 2)
continue;
value_str = cmd_str;
value_len = cmd_len;
- variantBegin (spec, d1_stack, d1_level, class_str, class_len,
+ variantBegin (spec, class_str, class_len,
type_str, type_len, value_str, value_len);
- r = execTok (spec, &s, arg_no, arg_start, arg_end,
- &cmd_str, &cmd_len);
+ r = execTok (spec, &s, &cmd_str, &cmd_len);
}
else if (!strcmp (p, "context"))
{
if (r > 1)
{
struct lexContext *lc = spec->context;
- r = execTok (spec, &s, arg_no, arg_start, arg_end,
- &cmd_str, &cmd_len);
+ r = execTok (spec, &s, &cmd_str, &cmd_len);
p = regxStrz (cmd_str, cmd_len, ptmp);
#if REGX_DEBUG
logf (LOG_DEBUG, "begin context %s", p);
logf (LOG_WARN, "unknown context %s", p);
}
- r = execTok (spec, &s, arg_no, arg_start, arg_end,
- &cmd_str, &cmd_len);
+ r = execTok (spec, &s, &cmd_str, &cmd_len);
}
else
{
}
else if (!strcmp (p, "end"))
{
- r = execTok (spec, &s, arg_no, arg_start, arg_end,
- &cmd_str, &cmd_len);
+ r = execTok (spec, &s, &cmd_str, &cmd_len);
if (r < 2)
{
logf (LOG_WARN, "missing keyword after 'end'");
p = regxStrz (cmd_str, cmd_len, ptmp);
if (!strcmp (p, "record"))
{
- int i;
- for (i = *d1_level; i; --i)
- tagDataRelease (spec, d1_stack, i);
- *d1_level = 0;
- r = execTok (spec, &s, arg_no, arg_start, arg_end,
- &cmd_str, &cmd_len);
+ while (spec->d1_level)
+ {
+ tagDataRelease (spec);
+ (spec->d1_level)--;
+ }
+ r = execTok (spec, &s, &cmd_str, &cmd_len);
#if REGX_DEBUG
logf (LOG_DEBUG, "end record");
#endif
- returnCode = 0;
+ spec->stop_flag = 1;
}
else if (!strcmp (p, "element"))
{
int min_level = 1;
- while ((r = execTok (spec, &s, arg_no, arg_start, arg_end,
- &cmd_str, &cmd_len)) == 3)
+ while ((r = execTok (spec, &s, &cmd_str, &cmd_len)) == 3)
{
if (cmd_len==7 && !memcmp ("-record", cmd_str, cmd_len))
min_level = 0;
}
if (r > 2)
{
- tagEnd (spec, d1_stack, d1_level, min_level,
- cmd_str, cmd_len);
- r = execTok (spec, &s, arg_no, arg_start, arg_end,
- &cmd_str, &cmd_len);
+ tagEnd (spec, min_level, cmd_str, cmd_len);
+ r = execTok (spec, &s, &cmd_str, &cmd_len);
}
else
- tagEnd (spec, d1_stack, d1_level, min_level, NULL, 0);
- if (*d1_level == 0)
+ tagEnd (spec, min_level, NULL, 0);
+ if (spec->d1_level == 0)
{
#if REGX_DEBUG
logf (LOG_DEBUG, "end element end records");
#endif
- returnCode = 0;
+ spec->stop_flag = 1;
}
}
#endif
if (spec->context_stack_top)
(spec->context_stack_top)--;
- r = execTok (spec, &s, arg_no, arg_start, arg_end,
- &cmd_str, &cmd_len);
+ r = execTok (spec, &s, &cmd_str, &cmd_len);
}
else
logf (LOG_WARN, "bad keyword '%s' after end", p);
int element_len;
const char *element_str = NULL;
- while ((r = execTok (spec, &s, arg_no, arg_start, arg_end,
- &cmd_str, &cmd_len)) == 3)
+ while ((r = execTok (spec, &s, &cmd_str, &cmd_len)) == 3)
{
if (cmd_len==5 && !memcmp ("-text", cmd_str, cmd_len))
textFlag = 1;
else if (cmd_len==8 && !memcmp ("-element", cmd_str, cmd_len))
{
- r = execTok (spec, &s, arg_no, arg_start, arg_end,
- &element_str, &element_len);
+ r = execTok (spec, &s, &element_str, &element_len);
if (r < 2)
break;
}
continue;
}
if (element_str)
- tagBegin (spec, d1_stack, d1_level, element_str, element_len);
+ tagBegin (spec, element_str, element_len);
do
{
- execData (spec, d1_stack, d1_level, cmd_str, cmd_len,
- textFlag);
- r = execTok (spec, &s, arg_no, arg_start, arg_end,
- &cmd_str, &cmd_len);
+ execData (spec, cmd_str, cmd_len,textFlag);
+ r = execTok (spec, &s, &cmd_str, &cmd_len);
} while (r > 1);
if (element_str)
- tagEnd (spec, d1_stack, d1_level, 1, NULL, 0);
+ tagEnd (spec, 1, NULL, 0);
}
else if (!strcmp (p, "unread"))
{
int no, offset;
- r = execTok (spec, &s, arg_no, arg_start, arg_end,
- &cmd_str, &cmd_len);
+ r = execTok (spec, &s, &cmd_str, &cmd_len);
if (r==3 && cmd_len == 7 && !memcmp ("-offset", cmd_str, cmd_len))
{
- r = execTok (spec, &s, arg_no, arg_start, arg_end,
- &cmd_str, &cmd_len);
+ r = execTok (spec, &s, &cmd_str, &cmd_len);
if (r < 2)
{
logf (LOG_WARN, "missing number after -offset");
}
p = regxStrz (cmd_str, cmd_len, ptmp);
offset = atoi (p);
- r = execTok (spec, &s, arg_no, arg_start, arg_end,
- &cmd_str, &cmd_len);
+ r = execTok (spec, &s, &cmd_str, &cmd_len);
}
else
offset = 0;
else
{
no = *cmd_str - '0';
- if (no >= arg_no)
- no = arg_no - 1;
- *pptr = arg_start[no] + offset;
+ if (no >= spec->arg_no)
+ no = spec->arg_no - 1;
+ spec->ptr = spec->arg_start[no] + offset;
}
- r = execTok (spec, &s, arg_no, arg_start, arg_end,
- &cmd_str, &cmd_len);
+ r = execTok (spec, &s, &cmd_str, &cmd_len);
}
else if (!strcmp (p, "context"))
{
if (r > 1)
{
struct lexContext *lc = spec->context;
- r = execTok (spec, &s, arg_no, arg_start, arg_end,
- &cmd_str, &cmd_len);
+ r = execTok (spec, &s, &cmd_str, &cmd_len);
p = regxStrz (cmd_str, cmd_len, ptmp);
while (lc && strcmp (p, lc->name))
logf (LOG_WARN, "unknown context %s", p);
}
- r = execTok (spec, &s, arg_no, arg_start, arg_end,
- &cmd_str, &cmd_len);
+ r = execTok (spec, &s, &cmd_str, &cmd_len);
}
else
{
logf (LOG_WARN, "unknown code command '%.*s'", cmd_len, cmd_str);
- r = execTok (spec, &s, arg_no, arg_start, arg_end,
- &cmd_str, &cmd_len);
+ r = execTok (spec, &s, &cmd_str, &cmd_len);
continue;
}
if (r > 1)
{
logf (LOG_WARN, "ignoring token %.*s", cmd_len, cmd_str);
do {
- r = execTok (spec, &s, arg_no, arg_start, arg_end, &cmd_str,
- &cmd_len);
+ r = execTok (spec, &s, &cmd_str, &cmd_len);
} while (r > 1);
}
}
- return returnCode;
}
-/*
- * execAction: Execute action specified by 'ap'. Returns 0 if
- * the pattern(s) associated by rule and code could be executed
- * ok; returns 1 if code couldn't be executed.
- */
static int execAction (struct lexSpec *spec, struct lexRuleAction *ap,
- data1_node **d1_stack, int *d1_level,
int start_ptr, int *pptr)
{
int sptr;
int arg_end[20];
int arg_no = 1;
+ if (!ap)
+ return 1;
arg_start[0] = start_ptr;
arg_end[0] = *pptr;
+ spec->arg_start = arg_start;
+ spec->arg_end = arg_end;
while (ap)
{
arg_no++;
break;
case REGX_CODE:
- if (!execCode (spec, arg_no, arg_start, arg_end, pptr,
- ap->u.code, d1_stack, d1_level))
- return 0;
+ spec->arg_no = arg_no;
+ spec->ptr = *pptr;
+#if HAVE_TCL_H
+ if (spec->tcl_interp)
+ execTcl(spec, ap->u.code);
+ else
+ execCode (spec, ap->u.code);
+#else
+ execCode (spec, ap->u.code);
+#endif
+ *pptr = spec->ptr;
+ if (spec->stop_flag)
+ return 0;
break;
case REGX_END:
arg_start[arg_no] = *pptr;
}
static int execRule (struct lexSpec *spec, struct lexContext *context,
- data1_node **d1_stack, int *d1_level,
int ruleNo, int start_ptr, int *pptr)
{
#if REGX_DEBUG
logf (LOG_DEBUG, "exec rule %d", ruleNo);
#endif
return execAction (spec, context->fastRule[ruleNo]->actionList,
- d1_stack, d1_level, start_ptr, pptr);
+ start_ptr, pptr);
}
-data1_node *lexNode (struct lexSpec *spec,
- data1_node **d1_stack, int *d1_level, int *ptr)
+data1_node *lexNode (struct lexSpec *spec, int *ptr)
{
struct lexContext *context = spec->context_stack[spec->context_stack_top];
struct DFA_state *state = context->dfa->states[0];
int size;
char *buf;
buf = f_win_get (spec, skip_ptr, start_ptr, &size);
- execDataP (spec, d1_stack, d1_level, buf, size, 0);
+ execDataP (spec, buf, size, 0);
}
/* restore pointer */
*ptr = last_ptr;
/* execute rule */
- if (!execRule (spec, context, d1_stack, d1_level,
- last_rule, start_ptr, ptr))
- break;
+ if (!execRule (spec, context, last_rule, start_ptr, ptr))
+ break;
/* restore skip pointer */
skip_ptr = *ptr;
last_rule = 0;
int size;
char *buf;
buf = f_win_get (spec, skip_ptr, *ptr, &size);
- execDataP (spec, d1_stack, d1_level, buf, size, 0);
+ execDataP (spec, buf, size, 0);
}
if (*ptr == F_WIN_EOF)
break;
int size;
char *buf;
buf = f_win_get (spec, skip_ptr, start_ptr, &size);
- execDataP (spec, d1_stack, d1_level, buf, size, 0);
+ execDataP (spec, buf, size, 0);
}
/* restore pointer */
*ptr = last_ptr;
- if (!execRule (spec, context, d1_stack, d1_level,
- last_rule, start_ptr, ptr))
+ if (!execRule (spec, context, last_rule, start_ptr, ptr))
{
if (spec->f_win_ef && *ptr != F_WIN_EOF)
{
const char *context_name)
{
struct lexContext *lt = spec->context;
- data1_node *d1_stack[128];
- int d1_level = 0;
- int i, ptr = offset;
+ int ptr = offset;
+ spec->stop_flag = 0;
+ spec->d1_level = 0;
spec->context_stack_top = 0;
while (lt)
{
return NULL;
}
spec->context_stack[spec->context_stack_top] = lt;
- d1_stack[d1_level] = NULL;
- if (lt->beginActionList)
- execAction (spec, lt->beginActionList, d1_stack, &d1_level, 0, &ptr);
- lexNode (spec, d1_stack, &d1_level, &ptr);
- for (i = d1_level; i; --i)
- tagDataRelease (spec, d1_stack, i);
- if (lt->endActionList)
- execAction (spec, lt->endActionList, d1_stack, &d1_level, ptr, &ptr);
- return *d1_stack;
+ spec->d1_stack[spec->d1_level] = NULL;
+#if 1
+ if (!lt->initFlag)
+ {
+ lt->initFlag = 1;
+ execAction (spec, lt->initActionList, ptr, &ptr);
+ }
+#endif
+ execAction (spec, lt->beginActionList, ptr, &ptr);
+ lexNode (spec, &ptr);
+ while (spec->d1_level)
+ {
+ tagDataRelease (spec);
+ (spec->d1_level)--;
+ }
+ execAction (spec, lt->endActionList, ptr, &ptr);
+ return spec->d1_stack[0];
+}
+
+void grs_destroy(void *clientData)
+{
+ struct lexSpecs *specs = clientData;
+ if (specs->spec)
+ {
+ lexSpecDestroy(&specs->spec);
+ }
+ xfree (specs);
+}
+
+void *grs_init(void)
+{
+ struct lexSpecs *specs = xmalloc (sizeof(*specs));
+ specs->spec = 0;
+ return specs;
}
data1_node *grs_read_regx (struct grs_read_info *p)
{
int res;
+ struct lexSpecs *specs = p->clientData;
+ struct lexSpec **curLexSpec = &specs->spec;
#if REGX_DEBUG
logf (LOG_DEBUG, "grs_read_regx");
#endif
- if (!curLexSpec || strcmp (curLexSpec->name, p->type))
+ if (!*curLexSpec || strcmp ((*curLexSpec)->name, p->type))
+ {
+ if (*curLexSpec)
+ lexSpecDestroy (curLexSpec);
+ *curLexSpec = lexSpecCreate (p->type, p->dh);
+ res = readFileSpec (*curLexSpec);
+ if (res)
+ {
+ lexSpecDestroy (curLexSpec);
+ return NULL;
+ }
+ }
+ (*curLexSpec)->dh = p->dh;
+ if (!p->offset)
+ {
+ (*curLexSpec)->f_win_start = 0;
+ (*curLexSpec)->f_win_end = 0;
+ (*curLexSpec)->f_win_rf = p->readf;
+ (*curLexSpec)->f_win_sf = p->seekf;
+ (*curLexSpec)->f_win_fh = p->fh;
+ (*curLexSpec)->f_win_ef = p->endf;
+ (*curLexSpec)->f_win_size = 500000;
+ }
+ (*curLexSpec)->m = p->mem;
+ return lexRoot (*curLexSpec, p->offset, "main");
+}
+
+static struct recTypeGrs regx_type = {
+ "regx",
+ grs_init,
+ grs_destroy,
+ grs_read_regx
+};
+
+RecTypeGrs recTypeGrs_regx = ®x_type;
+
+#if HAVE_TCL_H
+data1_node *grs_read_tcl (struct grs_read_info *p)
+{
+ int res;
+ struct lexSpecs *specs = p->clientData;
+ struct lexSpec **curLexSpec = &specs->spec;
+
+#if REGX_DEBUG
+ logf (LOG_DEBUG, "grs_read_tcl");
+#endif
+ if (!*curLexSpec || strcmp ((*curLexSpec)->name, p->type))
{
- if (curLexSpec)
- lexSpecDestroy (&curLexSpec);
- curLexSpec = lexSpecCreate (p->type);
- curLexSpec->dh = p->dh;
- res = readFileSpec (curLexSpec);
+ Tcl_Interp *tcl_interp;
+ if (*curLexSpec)
+ lexSpecDestroy (curLexSpec);
+ *curLexSpec = lexSpecCreate (p->type, p->dh);
+ tcl_interp = (*curLexSpec)->tcl_interp = Tcl_CreateInterp();
+ Tcl_CreateCommand (tcl_interp, "begin", cmd_tcl_begin, *curLexSpec, 0);
+ Tcl_CreateCommand (tcl_interp, "end", cmd_tcl_end, *curLexSpec, 0);
+ Tcl_CreateCommand (tcl_interp, "data", cmd_tcl_data, *curLexSpec, 0);
+ Tcl_CreateCommand (tcl_interp, "unread", cmd_tcl_unread,
+ *curLexSpec, 0);
+ res = readFileSpec (*curLexSpec);
if (res)
{
- lexSpecDestroy (&curLexSpec);
+ lexSpecDestroy (curLexSpec);
return NULL;
}
}
- curLexSpec->dh = p->dh;
+ (*curLexSpec)->dh = p->dh;
if (!p->offset)
{
- curLexSpec->f_win_start = 0;
- curLexSpec->f_win_end = 0;
- curLexSpec->f_win_rf = p->readf;
- curLexSpec->f_win_sf = p->seekf;
- curLexSpec->f_win_fh = p->fh;
- curLexSpec->f_win_ef = p->endf;
- curLexSpec->f_win_size = 500000;
+ (*curLexSpec)->f_win_start = 0;
+ (*curLexSpec)->f_win_end = 0;
+ (*curLexSpec)->f_win_rf = p->readf;
+ (*curLexSpec)->f_win_sf = p->seekf;
+ (*curLexSpec)->f_win_fh = p->fh;
+ (*curLexSpec)->f_win_ef = p->endf;
+ (*curLexSpec)->f_win_size = 500000;
}
- curLexSpec->m = p->mem;
- return lexRoot (curLexSpec, p->offset, "main");
+ (*curLexSpec)->m = p->mem;
+ return lexRoot (*curLexSpec, p->offset, "main");
}
+
+static struct recTypeGrs tcl_type = {
+ "tcl",
+ grs_init,
+ grs_destroy,
+ grs_read_tcl
+};
+
+RecTypeGrs recTypeGrs_tcl = &tcl_type;
+#endif