made qse_sed_setexectracer() selectable at compile-time
This commit is contained in:
parent
915ef99f07
commit
5d774c198f
@ -34,7 +34,7 @@ POST_UNINSTALL = :
|
|||||||
build_triplet = @build@
|
build_triplet = @build@
|
||||||
host_triplet = @host@
|
host_triplet = @host@
|
||||||
subdir = .
|
subdir = .
|
||||||
DIST_COMMON = README $(am__configure_deps) $(srcdir)/Makefile.am \
|
DIST_COMMON = $(am__configure_deps) $(srcdir)/Makefile.am \
|
||||||
$(srcdir)/Makefile.in $(srcdir)/README.in \
|
$(srcdir)/Makefile.in $(srcdir)/README.in \
|
||||||
$(top_srcdir)/configure ac/config.guess ac/config.sub \
|
$(top_srcdir)/configure ac/config.guess ac/config.sub \
|
||||||
ac/depcomp ac/install-sh ac/ltmain.sh ac/missing
|
ac/depcomp ac/install-sh ac/ltmain.sh ac/missing
|
||||||
|
@ -64,7 +64,9 @@ static qse_char_t* g_output_file = QSE_NULL;
|
|||||||
static int g_infile_pos = 0;
|
static int g_infile_pos = 0;
|
||||||
static int g_option = 0;
|
static int g_option = 0;
|
||||||
static int g_separate = 0;
|
static int g_separate = 0;
|
||||||
|
#if defined(QSE_ENABLE_SEDTRACER)
|
||||||
static int g_trace = 0;
|
static int g_trace = 0;
|
||||||
|
#endif
|
||||||
static qse_ulong_t g_memlimit = 0;
|
static qse_ulong_t g_memlimit = 0;
|
||||||
static qse_sed_t* g_sed = QSE_NULL;
|
static qse_sed_t* g_sed = QSE_NULL;
|
||||||
|
|
||||||
@ -131,6 +133,9 @@ static void print_usage (QSE_FILE* out, int argc, qse_char_t* argv[])
|
|||||||
qse_fprintf (out, QSE_T(" <start~step>,<start,+line>,<start,~line>,<0,/regex/>\n"));
|
qse_fprintf (out, QSE_T(" <start~step>,<start,+line>,<start,~line>,<0,/regex/>\n"));
|
||||||
qse_fprintf (out, QSE_T(" -x allow text on the same line as c, a, i\n"));
|
qse_fprintf (out, QSE_T(" -x allow text on the same line as c, a, i\n"));
|
||||||
qse_fprintf (out, QSE_T(" -y ensure a newline at text end\n"));
|
qse_fprintf (out, QSE_T(" -y ensure a newline at text end\n"));
|
||||||
|
#if defined(QSE_ENABLE_SEDTRACER)
|
||||||
|
qse_fprintf (out, QSE_T(" -t print command traces\n"));
|
||||||
|
#endif
|
||||||
qse_fprintf (out, QSE_T(" -m number specify the maximum amount of memory to use in bytes\n"));
|
qse_fprintf (out, QSE_T(" -m number specify the maximum amount of memory to use in bytes\n"));
|
||||||
#if defined(QSE_BUILD_DEBUG)
|
#if defined(QSE_BUILD_DEBUG)
|
||||||
qse_fprintf (out, QSE_T(" -X number fail the number'th memory allocation\n"));
|
qse_fprintf (out, QSE_T(" -X number fail the number'th memory allocation\n"));
|
||||||
@ -160,7 +165,9 @@ static int add_script (const qse_char_t* str, int mem)
|
|||||||
if (mem)
|
if (mem)
|
||||||
{
|
{
|
||||||
g_script.io[g_script.size].type = QSE_SED_IOSTD_MEM;
|
g_script.io[g_script.size].type = QSE_SED_IOSTD_MEM;
|
||||||
g_script.io[g_script.size].u.mem.ptr = str;
|
/* though its type is not qualified to be const,
|
||||||
|
* u.mem.ptr is actually const when used for input */
|
||||||
|
g_script.io[g_script.size].u.mem.ptr = (qse_char_t*)str;
|
||||||
g_script.io[g_script.size].u.mem.len = qse_strlen(str);
|
g_script.io[g_script.size].u.mem.len = qse_strlen(str);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -270,8 +277,13 @@ static int handle_args (int argc, qse_char_t* argv[])
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case QSE_T('t'):
|
case QSE_T('t'):
|
||||||
|
#if defined(QSE_ENABLE_SEDTRACER)
|
||||||
g_trace = 1;
|
g_trace = 1;
|
||||||
break;
|
break;
|
||||||
|
#else
|
||||||
|
print_usage (QSE_STDERR, argc, argv);
|
||||||
|
goto oops;
|
||||||
|
#endif
|
||||||
|
|
||||||
case QSE_T('m'):
|
case QSE_T('m'):
|
||||||
g_memlimit = qse_strtoulong (opt.arg);
|
g_memlimit = qse_strtoulong (opt.arg);
|
||||||
@ -450,33 +462,39 @@ static void unset_intr_run (void)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(QSE_ENABLE_SEDTRACER)
|
||||||
static void trace_exec (qse_sed_t* sed, qse_sed_exec_op_t op, const qse_sed_cmd_t* cmd)
|
static void trace_exec (qse_sed_t* sed, qse_sed_exec_op_t op, const qse_sed_cmd_t* cmd)
|
||||||
{
|
{
|
||||||
switch (op)
|
switch (op)
|
||||||
{
|
{
|
||||||
#if 0
|
#if 0
|
||||||
case QSE_SED_EXEC_READ:
|
case QSE_SED_EXEC_READ:
|
||||||
qse_printf (QSE_T("reading...\n"));
|
qse_fprintf (QSE_STDERR, QSE_T("reading...\n"));
|
||||||
break;
|
break;
|
||||||
case QSE_SED_EXEC_WRITE:
|
case QSE_SED_EXEC_WRITE:
|
||||||
qse_printf (QSE_T("wrting...\n"));
|
qse_fprintf (QSE_STDERR, QSE_T("wrting...\n"));
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
/* TODO: use function to get hold space and pattern space and print them */
|
||||||
|
|
||||||
case QSE_SED_EXEC_MATCH:
|
case QSE_SED_EXEC_MATCH:
|
||||||
qse_printf (QSE_T("matching address for [%c] in %s at line %lu\n"),
|
qse_fprintf (QSE_STDERR, QSE_T("%s:%lu [%c] MA\n"),
|
||||||
cmd->type,
|
((cmd->lid && cmd->lid[0])? cmd->lid: QSE_T("<<UNKNOWN>>")),
|
||||||
(cmd->lid? cmd->lid: QSE_T("<<UNKNOWN>>")),
|
(unsigned long)cmd->loc.line,
|
||||||
(unsigned long)cmd->loc.line);
|
cmd->type
|
||||||
|
);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case QSE_SED_EXEC_EXEC:
|
case QSE_SED_EXEC_EXEC:
|
||||||
qse_printf (QSE_T("executing [%c] in %s at line %lu\n"),
|
qse_fprintf (QSE_STDERR, QSE_T("%s:%lu [%c] EC\n"),
|
||||||
cmd->type,
|
((cmd->lid && cmd->lid[0])? cmd->lid: QSE_T("<<UNKNOWN>>")),
|
||||||
(cmd->lid? cmd->lid: QSE_T("<<UNKNOWN>>")),
|
(unsigned long)cmd->loc.line,
|
||||||
(unsigned long)cmd->loc.line);
|
cmd->type
|
||||||
|
);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
int sed_main (int argc, qse_char_t* argv[])
|
int sed_main (int argc, qse_char_t* argv[])
|
||||||
{
|
{
|
||||||
@ -559,7 +577,9 @@ int sed_main (int argc, qse_char_t* argv[])
|
|||||||
goto oops;
|
goto oops;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(QSE_ENABLE_SEDTRACER)
|
||||||
if (g_trace) qse_sed_setexectracer (sed, trace_exec);
|
if (g_trace) qse_sed_setexectracer (sed, trace_exec);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (g_separate && g_infile_pos > 0)
|
if (g_separate && g_infile_pos > 0)
|
||||||
{
|
{
|
||||||
|
56
qse/configure
vendored
56
qse/configure
vendored
@ -902,6 +902,7 @@ enable_syscall
|
|||||||
enable_debug
|
enable_debug
|
||||||
enable_cxx
|
enable_cxx
|
||||||
enable_reentrant
|
enable_reentrant
|
||||||
|
enable_sedtracer
|
||||||
'
|
'
|
||||||
ac_precious_vars='build_alias
|
ac_precious_vars='build_alias
|
||||||
host_alias
|
host_alias
|
||||||
@ -1551,6 +1552,7 @@ Optional Features:
|
|||||||
--enable-cxx build the library for C++ if a C++ compiler is
|
--enable-cxx build the library for C++ if a C++ compiler is
|
||||||
available (default. yes)
|
available (default. yes)
|
||||||
--enable-reentrant define _REENTRANT (default. yes)
|
--enable-reentrant define _REENTRANT (default. yes)
|
||||||
|
--enable-sedtracer enable qse_sed_setexectracer() (default. yes)
|
||||||
|
|
||||||
Optional Packages:
|
Optional Packages:
|
||||||
--with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
|
--with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
|
||||||
@ -5696,13 +5698,13 @@ if test "${lt_cv_nm_interface+set}" = set; then :
|
|||||||
else
|
else
|
||||||
lt_cv_nm_interface="BSD nm"
|
lt_cv_nm_interface="BSD nm"
|
||||||
echo "int some_variable = 0;" > conftest.$ac_ext
|
echo "int some_variable = 0;" > conftest.$ac_ext
|
||||||
(eval echo "\"\$as_me:5699: $ac_compile\"" >&5)
|
(eval echo "\"\$as_me:5701: $ac_compile\"" >&5)
|
||||||
(eval "$ac_compile" 2>conftest.err)
|
(eval "$ac_compile" 2>conftest.err)
|
||||||
cat conftest.err >&5
|
cat conftest.err >&5
|
||||||
(eval echo "\"\$as_me:5702: $NM \\\"conftest.$ac_objext\\\"\"" >&5)
|
(eval echo "\"\$as_me:5704: $NM \\\"conftest.$ac_objext\\\"\"" >&5)
|
||||||
(eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out)
|
(eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out)
|
||||||
cat conftest.err >&5
|
cat conftest.err >&5
|
||||||
(eval echo "\"\$as_me:5705: output\"" >&5)
|
(eval echo "\"\$as_me:5707: output\"" >&5)
|
||||||
cat conftest.out >&5
|
cat conftest.out >&5
|
||||||
if $GREP 'External.*some_variable' conftest.out > /dev/null; then
|
if $GREP 'External.*some_variable' conftest.out > /dev/null; then
|
||||||
lt_cv_nm_interface="MS dumpbin"
|
lt_cv_nm_interface="MS dumpbin"
|
||||||
@ -6897,7 +6899,7 @@ ia64-*-hpux*)
|
|||||||
;;
|
;;
|
||||||
*-*-irix6*)
|
*-*-irix6*)
|
||||||
# Find out which ABI we are using.
|
# Find out which ABI we are using.
|
||||||
echo '#line 6900 "configure"' > conftest.$ac_ext
|
echo '#line 6902 "configure"' > conftest.$ac_ext
|
||||||
if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
|
if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
|
||||||
(eval $ac_compile) 2>&5
|
(eval $ac_compile) 2>&5
|
||||||
ac_status=$?
|
ac_status=$?
|
||||||
@ -8953,11 +8955,11 @@ else
|
|||||||
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
|
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
|
||||||
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
|
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
|
||||||
-e 's:$: $lt_compiler_flag:'`
|
-e 's:$: $lt_compiler_flag:'`
|
||||||
(eval echo "\"\$as_me:8956: $lt_compile\"" >&5)
|
(eval echo "\"\$as_me:8958: $lt_compile\"" >&5)
|
||||||
(eval "$lt_compile" 2>conftest.err)
|
(eval "$lt_compile" 2>conftest.err)
|
||||||
ac_status=$?
|
ac_status=$?
|
||||||
cat conftest.err >&5
|
cat conftest.err >&5
|
||||||
echo "$as_me:8960: \$? = $ac_status" >&5
|
echo "$as_me:8962: \$? = $ac_status" >&5
|
||||||
if (exit $ac_status) && test -s "$ac_outfile"; then
|
if (exit $ac_status) && test -s "$ac_outfile"; then
|
||||||
# The compiler can only warn and ignore the option if not recognized
|
# The compiler can only warn and ignore the option if not recognized
|
||||||
# So say no if there are warnings other than the usual output.
|
# So say no if there are warnings other than the usual output.
|
||||||
@ -9292,11 +9294,11 @@ else
|
|||||||
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
|
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
|
||||||
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
|
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
|
||||||
-e 's:$: $lt_compiler_flag:'`
|
-e 's:$: $lt_compiler_flag:'`
|
||||||
(eval echo "\"\$as_me:9295: $lt_compile\"" >&5)
|
(eval echo "\"\$as_me:9297: $lt_compile\"" >&5)
|
||||||
(eval "$lt_compile" 2>conftest.err)
|
(eval "$lt_compile" 2>conftest.err)
|
||||||
ac_status=$?
|
ac_status=$?
|
||||||
cat conftest.err >&5
|
cat conftest.err >&5
|
||||||
echo "$as_me:9299: \$? = $ac_status" >&5
|
echo "$as_me:9301: \$? = $ac_status" >&5
|
||||||
if (exit $ac_status) && test -s "$ac_outfile"; then
|
if (exit $ac_status) && test -s "$ac_outfile"; then
|
||||||
# The compiler can only warn and ignore the option if not recognized
|
# The compiler can only warn and ignore the option if not recognized
|
||||||
# So say no if there are warnings other than the usual output.
|
# So say no if there are warnings other than the usual output.
|
||||||
@ -9397,11 +9399,11 @@ else
|
|||||||
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
|
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
|
||||||
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
|
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
|
||||||
-e 's:$: $lt_compiler_flag:'`
|
-e 's:$: $lt_compiler_flag:'`
|
||||||
(eval echo "\"\$as_me:9400: $lt_compile\"" >&5)
|
(eval echo "\"\$as_me:9402: $lt_compile\"" >&5)
|
||||||
(eval "$lt_compile" 2>out/conftest.err)
|
(eval "$lt_compile" 2>out/conftest.err)
|
||||||
ac_status=$?
|
ac_status=$?
|
||||||
cat out/conftest.err >&5
|
cat out/conftest.err >&5
|
||||||
echo "$as_me:9404: \$? = $ac_status" >&5
|
echo "$as_me:9406: \$? = $ac_status" >&5
|
||||||
if (exit $ac_status) && test -s out/conftest2.$ac_objext
|
if (exit $ac_status) && test -s out/conftest2.$ac_objext
|
||||||
then
|
then
|
||||||
# The compiler can only warn and ignore the option if not recognized
|
# The compiler can only warn and ignore the option if not recognized
|
||||||
@ -9452,11 +9454,11 @@ else
|
|||||||
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
|
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
|
||||||
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
|
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
|
||||||
-e 's:$: $lt_compiler_flag:'`
|
-e 's:$: $lt_compiler_flag:'`
|
||||||
(eval echo "\"\$as_me:9455: $lt_compile\"" >&5)
|
(eval echo "\"\$as_me:9457: $lt_compile\"" >&5)
|
||||||
(eval "$lt_compile" 2>out/conftest.err)
|
(eval "$lt_compile" 2>out/conftest.err)
|
||||||
ac_status=$?
|
ac_status=$?
|
||||||
cat out/conftest.err >&5
|
cat out/conftest.err >&5
|
||||||
echo "$as_me:9459: \$? = $ac_status" >&5
|
echo "$as_me:9461: \$? = $ac_status" >&5
|
||||||
if (exit $ac_status) && test -s out/conftest2.$ac_objext
|
if (exit $ac_status) && test -s out/conftest2.$ac_objext
|
||||||
then
|
then
|
||||||
# The compiler can only warn and ignore the option if not recognized
|
# The compiler can only warn and ignore the option if not recognized
|
||||||
@ -11836,7 +11838,7 @@ else
|
|||||||
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
|
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
|
||||||
lt_status=$lt_dlunknown
|
lt_status=$lt_dlunknown
|
||||||
cat > conftest.$ac_ext <<_LT_EOF
|
cat > conftest.$ac_ext <<_LT_EOF
|
||||||
#line 11839 "configure"
|
#line 11841 "configure"
|
||||||
#include "confdefs.h"
|
#include "confdefs.h"
|
||||||
|
|
||||||
#if HAVE_DLFCN_H
|
#if HAVE_DLFCN_H
|
||||||
@ -11932,7 +11934,7 @@ else
|
|||||||
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
|
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
|
||||||
lt_status=$lt_dlunknown
|
lt_status=$lt_dlunknown
|
||||||
cat > conftest.$ac_ext <<_LT_EOF
|
cat > conftest.$ac_ext <<_LT_EOF
|
||||||
#line 11935 "configure"
|
#line 11937 "configure"
|
||||||
#include "confdefs.h"
|
#include "confdefs.h"
|
||||||
|
|
||||||
#if HAVE_DLFCN_H
|
#if HAVE_DLFCN_H
|
||||||
@ -13888,11 +13890,11 @@ else
|
|||||||
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
|
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
|
||||||
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
|
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
|
||||||
-e 's:$: $lt_compiler_flag:'`
|
-e 's:$: $lt_compiler_flag:'`
|
||||||
(eval echo "\"\$as_me:13891: $lt_compile\"" >&5)
|
(eval echo "\"\$as_me:13893: $lt_compile\"" >&5)
|
||||||
(eval "$lt_compile" 2>conftest.err)
|
(eval "$lt_compile" 2>conftest.err)
|
||||||
ac_status=$?
|
ac_status=$?
|
||||||
cat conftest.err >&5
|
cat conftest.err >&5
|
||||||
echo "$as_me:13895: \$? = $ac_status" >&5
|
echo "$as_me:13897: \$? = $ac_status" >&5
|
||||||
if (exit $ac_status) && test -s "$ac_outfile"; then
|
if (exit $ac_status) && test -s "$ac_outfile"; then
|
||||||
# The compiler can only warn and ignore the option if not recognized
|
# The compiler can only warn and ignore the option if not recognized
|
||||||
# So say no if there are warnings other than the usual output.
|
# So say no if there are warnings other than the usual output.
|
||||||
@ -13987,11 +13989,11 @@ else
|
|||||||
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
|
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
|
||||||
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
|
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
|
||||||
-e 's:$: $lt_compiler_flag:'`
|
-e 's:$: $lt_compiler_flag:'`
|
||||||
(eval echo "\"\$as_me:13990: $lt_compile\"" >&5)
|
(eval echo "\"\$as_me:13992: $lt_compile\"" >&5)
|
||||||
(eval "$lt_compile" 2>out/conftest.err)
|
(eval "$lt_compile" 2>out/conftest.err)
|
||||||
ac_status=$?
|
ac_status=$?
|
||||||
cat out/conftest.err >&5
|
cat out/conftest.err >&5
|
||||||
echo "$as_me:13994: \$? = $ac_status" >&5
|
echo "$as_me:13996: \$? = $ac_status" >&5
|
||||||
if (exit $ac_status) && test -s out/conftest2.$ac_objext
|
if (exit $ac_status) && test -s out/conftest2.$ac_objext
|
||||||
then
|
then
|
||||||
# The compiler can only warn and ignore the option if not recognized
|
# The compiler can only warn and ignore the option if not recognized
|
||||||
@ -14039,11 +14041,11 @@ else
|
|||||||
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
|
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
|
||||||
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
|
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
|
||||||
-e 's:$: $lt_compiler_flag:'`
|
-e 's:$: $lt_compiler_flag:'`
|
||||||
(eval echo "\"\$as_me:14042: $lt_compile\"" >&5)
|
(eval echo "\"\$as_me:14044: $lt_compile\"" >&5)
|
||||||
(eval "$lt_compile" 2>out/conftest.err)
|
(eval "$lt_compile" 2>out/conftest.err)
|
||||||
ac_status=$?
|
ac_status=$?
|
||||||
cat out/conftest.err >&5
|
cat out/conftest.err >&5
|
||||||
echo "$as_me:14046: \$? = $ac_status" >&5
|
echo "$as_me:14048: \$? = $ac_status" >&5
|
||||||
if (exit $ac_status) && test -s out/conftest2.$ac_objext
|
if (exit $ac_status) && test -s out/conftest2.$ac_objext
|
||||||
then
|
then
|
||||||
# The compiler can only warn and ignore the option if not recognized
|
# The compiler can only warn and ignore the option if not recognized
|
||||||
@ -17236,6 +17238,20 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
|
|||||||
CXXFLAGS="$CXXFLAGS $PTHREAD_CFLAGS"
|
CXXFLAGS="$CXXFLAGS $PTHREAD_CFLAGS"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Check whether --enable-sedtracer was given.
|
||||||
|
if test "${enable_sedtracer+set}" = set; then :
|
||||||
|
enableval=$enable_sedtracer; enable_sedtracer_is=$enableval
|
||||||
|
else
|
||||||
|
enable_sedtracer_is=yes
|
||||||
|
fi
|
||||||
|
|
||||||
|
if test "${enable_sedtracer_is}" = "yes"
|
||||||
|
then
|
||||||
|
|
||||||
|
$as_echo "#define QSE_ENABLE_SEDTRACER /**/" >>confdefs.h
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for socklen_t in sys/socket.h" >&5
|
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for socklen_t in sys/socket.h" >&5
|
||||||
$as_echo_n "checking for socklen_t in sys/socket.h... " >&6; }
|
$as_echo_n "checking for socklen_t in sys/socket.h... " >&6; }
|
||||||
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
|
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
|
||||||
|
@ -228,6 +228,13 @@ then
|
|||||||
[CXXFLAGS="$CXXFLAGS $PTHREAD_CFLAGS"]
|
[CXXFLAGS="$CXXFLAGS $PTHREAD_CFLAGS"]
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
AC_ARG_ENABLE([sedtracer], [AS_HELP_STRING([--enable-sedtracer],[enable qse_sed_setexectracer() (default. yes)])],
|
||||||
|
enable_sedtracer_is=$enableval,enable_sedtracer_is=yes)
|
||||||
|
if test "${enable_sedtracer_is}" = "yes"
|
||||||
|
then
|
||||||
|
AC_DEFINE([QSE_ENABLE_SEDTRACER],[],[enable qse_sed_setexectracer()])
|
||||||
|
fi
|
||||||
|
|
||||||
AC_MSG_CHECKING([for socklen_t in sys/socket.h])
|
AC_MSG_CHECKING([for socklen_t in sys/socket.h])
|
||||||
AC_TRY_COMPILE([#define _POSIX_PII_SOCKET
|
AC_TRY_COMPILE([#define _POSIX_PII_SOCKET
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
@ -284,6 +284,9 @@
|
|||||||
/* char is wchar */
|
/* char is wchar */
|
||||||
#undef QSE_CHAR_IS_WCHAR
|
#undef QSE_CHAR_IS_WCHAR
|
||||||
|
|
||||||
|
/* enable qse_sed_setexectracer() */
|
||||||
|
#undef QSE_ENABLE_SEDTRACER
|
||||||
|
|
||||||
/* Big Endian */
|
/* Big Endian */
|
||||||
#undef QSE_ENDIAN_BIG
|
#undef QSE_ENDIAN_BIG
|
||||||
|
|
||||||
|
@ -303,6 +303,7 @@ typedef int (*qse_sed_lformatter_t) (
|
|||||||
int (*cwriter) (qse_sed_t*, qse_char_t)
|
int (*cwriter) (qse_sed_t*, qse_char_t)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
#ifdef QSE_ENABLE_SEDTRACER
|
||||||
enum qse_sed_exec_op_t
|
enum qse_sed_exec_op_t
|
||||||
{
|
{
|
||||||
QSE_SED_EXEC_READ,
|
QSE_SED_EXEC_READ,
|
||||||
@ -317,6 +318,7 @@ typedef void (*qse_sed_exec_tracer_t) (
|
|||||||
qse_sed_exec_op_t op,
|
qse_sed_exec_op_t op,
|
||||||
const qse_sed_cmd_t* cmd
|
const qse_sed_cmd_t* cmd
|
||||||
);
|
);
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
@ -561,14 +563,24 @@ void qse_sed_setlinenum (
|
|||||||
qse_size_t num /**< a line number */
|
qse_size_t num /**< a line number */
|
||||||
);
|
);
|
||||||
|
|
||||||
|
#ifdef QSE_ENABLE_SEDTRACER
|
||||||
|
/**
|
||||||
|
* The qse_sed_getexectracer() function returns the execution tracer
|
||||||
|
* function.
|
||||||
|
*/
|
||||||
qse_sed_exec_tracer_t qse_sed_getexectracer (
|
qse_sed_exec_tracer_t qse_sed_getexectracer (
|
||||||
qse_sed_t* sed
|
qse_sed_t* sed
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The qse_sed_getexectracer() function sets a hook function via which
|
||||||
|
* you can trace commands being executed.
|
||||||
|
*/
|
||||||
void qse_sed_setexectracer (
|
void qse_sed_setexectracer (
|
||||||
qse_sed_t* sed,
|
qse_sed_t* sed,
|
||||||
qse_sed_exec_tracer_t tracer
|
qse_sed_exec_tracer_t tracer
|
||||||
);
|
);
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
@ -586,6 +586,9 @@ static void free_command (qse_sed_t* sed, qse_sed_cmd_t* cmd)
|
|||||||
|
|
||||||
static void free_all_cids (qse_sed_t* sed)
|
static void free_all_cids (qse_sed_t* sed)
|
||||||
{
|
{
|
||||||
|
if (sed->src.cid == (qse_sed_cid_t*)&sed->src.unknown_cid)
|
||||||
|
sed->src.cid = sed->src.cid->next;
|
||||||
|
|
||||||
while (sed->src.cid)
|
while (sed->src.cid)
|
||||||
{
|
{
|
||||||
qse_sed_cid_t* next = sed->src.cid->next;
|
qse_sed_cid_t* next = sed->src.cid->next;
|
||||||
@ -3542,7 +3545,9 @@ int qse_sed_exec (qse_sed_t* sed, qse_sed_io_fun_t inf, qse_sed_io_fun_t outf)
|
|||||||
|
|
||||||
while (!sed->e.stopreq)
|
while (!sed->e.stopreq)
|
||||||
{
|
{
|
||||||
|
#ifdef QSE_ENABLE_SEDTRACER
|
||||||
if (sed->e.tracer) sed->e.tracer (sed, QSE_SED_EXEC_READ, QSE_NULL);
|
if (sed->e.tracer) sed->e.tracer (sed, QSE_SED_EXEC_READ, QSE_NULL);
|
||||||
|
#endif
|
||||||
|
|
||||||
n = read_line (sed, 0);
|
n = read_line (sed, 0);
|
||||||
if (n <= -1) { ret = -1; goto done; }
|
if (n <= -1) { ret = -1; goto done; }
|
||||||
@ -3561,7 +3566,9 @@ int qse_sed_exec (qse_sed_t* sed, qse_sed_io_fun_t inf, qse_sed_io_fun_t outf)
|
|||||||
|
|
||||||
while (c != &sed->cmd.over)
|
while (c != &sed->cmd.over)
|
||||||
{
|
{
|
||||||
|
#ifdef QSE_ENABLE_SEDTRACER
|
||||||
if (sed->e.tracer) sed->e.tracer (sed, QSE_SED_EXEC_MATCH, c);
|
if (sed->e.tracer) sed->e.tracer (sed, QSE_SED_EXEC_MATCH, c);
|
||||||
|
#endif
|
||||||
|
|
||||||
n = match_address (sed, c);
|
n = match_address (sed, c);
|
||||||
if (n <= -1) { ret = -1; goto done; }
|
if (n <= -1) { ret = -1; goto done; }
|
||||||
@ -3573,7 +3580,9 @@ int qse_sed_exec (qse_sed_t* sed, qse_sed_io_fun_t inf, qse_sed_io_fun_t outf)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef QSE_ENABLE_SEDTRACER
|
||||||
if (sed->e.tracer) sed->e.tracer (sed, QSE_SED_EXEC_EXEC, c);
|
if (sed->e.tracer) sed->e.tracer (sed, QSE_SED_EXEC_EXEC, c);
|
||||||
|
#endif
|
||||||
j = exec_cmd (sed, c);
|
j = exec_cmd (sed, c);
|
||||||
if (j == QSE_NULL) { ret = -1; goto done; }
|
if (j == QSE_NULL) { ret = -1; goto done; }
|
||||||
if (j == &sed->cmd.quit_quiet) goto done;
|
if (j == &sed->cmd.quit_quiet) goto done;
|
||||||
@ -3590,7 +3599,9 @@ int qse_sed_exec (qse_sed_t* sed, qse_sed_io_fun_t inf, qse_sed_io_fun_t outf)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef QSE_ENABLE_SEDTRACER
|
||||||
if (sed->e.tracer) sed->e.tracer (sed, QSE_SED_EXEC_WRITE, QSE_NULL);
|
if (sed->e.tracer) sed->e.tracer (sed, QSE_SED_EXEC_WRITE, QSE_NULL);
|
||||||
|
#endif
|
||||||
if (emit_output (sed, 0) <= -1) { ret = -1; goto done; }
|
if (emit_output (sed, 0) <= -1) { ret = -1; goto done; }
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3635,14 +3646,29 @@ const qse_char_t* qse_sed_setcompid (qse_sed_t* sed, const qse_char_t* id)
|
|||||||
qse_sed_cid_t* cid;
|
qse_sed_cid_t* cid;
|
||||||
qse_size_t len;
|
qse_size_t len;
|
||||||
|
|
||||||
|
if (sed->src.cid == (qse_sed_cid_t*)&sed->src.unknown_cid)
|
||||||
|
{
|
||||||
|
/* if an error has occurred in a previously, you can't set it
|
||||||
|
* any more */
|
||||||
|
return (const qse_char_t*)(sed->src.cid + 1);
|
||||||
|
}
|
||||||
|
|
||||||
len = qse_strlen (id);
|
len = qse_strlen (id);
|
||||||
cid = QSE_MMGR_ALLOC (sed->mmgr, QSE_SIZEOF(*cid) + ((len + 1) * QSE_SIZEOF(*id)));
|
cid = QSE_MMGR_ALLOC (sed->mmgr,
|
||||||
if (cid == QSE_NULL) return QSE_NULL;
|
QSE_SIZEOF(*cid) + ((len + 1) * QSE_SIZEOF(*id)));
|
||||||
|
if (cid == QSE_NULL)
|
||||||
|
{
|
||||||
|
/* mark that an error has occurred */
|
||||||
|
sed->src.unknown_cid.buf[0] = QSE_T('\0');
|
||||||
|
cid = (qse_sed_cid_t*)&sed->src.unknown_cid;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
qse_strcpy ((qse_char_t*)(cid + 1), id);
|
||||||
|
}
|
||||||
|
|
||||||
cid->next = sed->src.cid;
|
cid->next = sed->src.cid;
|
||||||
sed->src.cid = cid;
|
sed->src.cid = cid;
|
||||||
qse_strcpy ((qse_char_t*)(cid + 1), id);
|
|
||||||
|
|
||||||
return (const qse_char_t*)(cid + 1);
|
return (const qse_char_t*)(cid + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3656,6 +3682,7 @@ void qse_sed_setlinenum (qse_sed_t* sed, qse_size_t num)
|
|||||||
sed->e.in.num = num;
|
sed->e.in.num = num;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef QSE_ENABLE_SEDTRACER
|
||||||
qse_sed_exec_tracer_t qse_sed_getexectracer (qse_sed_t* sed)
|
qse_sed_exec_tracer_t qse_sed_getexectracer (qse_sed_t* sed)
|
||||||
{
|
{
|
||||||
return sed->e.tracer;
|
return sed->e.tracer;
|
||||||
@ -3665,4 +3692,5 @@ void qse_sed_setexectracer (qse_sed_t* sed, qse_sed_exec_tracer_t tracer)
|
|||||||
{
|
{
|
||||||
sed->e.tracer = tracer;
|
sed->e.tracer = tracer;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
@ -61,6 +61,13 @@ struct qse_sed_cid_t
|
|||||||
qse_sed_cid_t* next;
|
qse_sed_cid_t* next;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
typedef struct qse_sed_unknown_cid_t qse_sed_unknown_cid_t;
|
||||||
|
struct qse_sed_unknown_cid_t
|
||||||
|
{
|
||||||
|
qse_sed_cid_t* next;
|
||||||
|
qse_char_t buf[1];
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The qse_sed_t type defines a stream editor
|
* The qse_sed_t type defines a stream editor
|
||||||
*/
|
*/
|
||||||
@ -95,6 +102,8 @@ struct qse_sed_t
|
|||||||
int eof;
|
int eof;
|
||||||
|
|
||||||
qse_sed_cid_t* cid;
|
qse_sed_cid_t* cid;
|
||||||
|
qse_sed_unknown_cid_t unknown_cid;
|
||||||
|
|
||||||
qse_sed_loc_t loc; /**< location */
|
qse_sed_loc_t loc; /**< location */
|
||||||
qse_cint_t cc; /**< last character read */
|
qse_cint_t cc; /**< last character read */
|
||||||
const qse_char_t* ptr; /**< beginning of the source text */
|
const qse_char_t* ptr; /**< beginning of the source text */
|
||||||
@ -197,8 +206,10 @@ struct qse_sed_t
|
|||||||
/** stop requested */
|
/** stop requested */
|
||||||
int stopreq;
|
int stopreq;
|
||||||
|
|
||||||
|
#ifdef QSE_ENABLE_SEDTRACER
|
||||||
/** trace function */
|
/** trace function */
|
||||||
qse_sed_exec_tracer_t tracer;
|
qse_sed_exec_tracer_t tracer;
|
||||||
|
#endif
|
||||||
} e;
|
} e;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user