added qse_awk_rtx_getvalstr() and qse_awk_rtx_freevalstr().

changed some code to use the 2 new functions.
added the sed module to awk. incomplete yet
This commit is contained in:
hyung-hwan 2014-02-19 15:24:33 +00:00
parent b5de91921c
commit 2e9bb90c39
20 changed files with 629 additions and 344 deletions

View File

@ -236,7 +236,7 @@
</set>
<set var="SOURCES_STATIC_AWK_MODULE">
<if cond="ENABLE_STATIC_MODULE=='1'">mod-dir.c mod-str.c mod-sys.c</if>
<if cond="ENABLE_STATIC_MODULE=='1'">mod-dir.c mod-sed.c mod-str.c mod-sys.c</if>
</set>
<set var="SOURCES_LIBQSEAWK">
@ -347,6 +347,23 @@
<sys-lib>$(SYSLIB_SOCKET2)</sys-lib>
</lib>
<dll id="dllqsesed" template="base" cond="ENABLE_DLL=='1'">
<libname>qsesed</libname>
<dllname>qsesed</dllname>
<set-srcdir>../../lib/sed</set-srcdir>
<sources>$(SOURCES_LIBQSESED)</sources>
<library>libqsecmn</library>
<depends>dllqsecmn</depends>
</dll>
<lib id="libqsesed" template="base" cond="ENABLE_DLL=='0'">
<libname>qsesed</libname>
<set-srcdir>../../lib/sed</set-srcdir>
<sources>$(SOURCES_LIBQSESED)</sources>
<library>libqsecmn</library>
<depends>libqsecmn</depends>
</lib>
<dll id="dllqseawk" template="base" cond="ENABLE_DLL=='1'">
<libname>qseawk</libname>
<dllname>qseawk</dllname>
@ -373,6 +390,18 @@
<depends>dllqseawk</depends>
</dll>
<dll id="modqseawksed" template="base" cond="ENABLE_STATIC_MODULE=='0'">
<dllname>$(AWKMODPREFIX)sed$(AWKMODPOSTFIX)</dllname>
<libname>$(AWKMODPREFIX)sed$(AWKMODPOSTFIX)</libname>
<set-srcdir>../../lib/awk</set-srcdir>
<sources>mod-sed.c</sources>
<library>libqsecmn</library>
<library>libqseawk</library>
<library>libqsesed</library>
<depends>dllqseawk</depends>
<depends>dllqsesed</depends>
</dll>
<dll id="modqseawkstr" template="base" cond="ENABLE_STATIC_MODULE=='0'">
<dllname>$(AWKMODPREFIX)str$(AWKMODPOSTFIX)</dllname>
<libname>$(AWKMODPREFIX)str$(AWKMODPOSTFIX)</libname>
@ -393,23 +422,6 @@
<depends>dllqseawk</depends>
</dll>
<dll id="dllqsesed" template="base" cond="ENABLE_DLL=='1'">
<libname>qsesed</libname>
<dllname>qsesed</dllname>
<set-srcdir>../../lib/sed</set-srcdir>
<sources>$(SOURCES_LIBQSESED)</sources>
<library>libqsecmn</library>
<depends>dllqsecmn</depends>
</dll>
<lib id="libqsesed" template="base" cond="ENABLE_DLL=='0'">
<libname>qsesed</libname>
<set-srcdir>../../lib/sed</set-srcdir>
<sources>$(SOURCES_LIBQSESED)</sources>
<library>libqsecmn</library>
<depends>libqsecmn</depends>
</lib>
<dll id="dllqsehttp" template="base" cond="ENABLE_DLL=='1'">
<libname>qsehttp</libname>
<dllname>qsehttp</dllname>

View File

@ -984,4 +984,66 @@ Now you run the following script on a UTF-8 console of a Linux box.
Note that 你 has been converted to a question mark since the letter is
not supported by cp949.
Modules
-------
QSEAWK supports various external modules.
## String ##
The *str* module provides an extensive set of string manipulation functions.
- str::index
- str::isalnum
- str::isalpha
- str::isblank
- str::iscntrl
- str::isdigit
- str::isgraph
- str::islower
- str::isprint
- str::ispunct
- str::isspace
- str::isupper
- str::isxdigit
- str::ltrim
- str::normspace
- str::rindex
- str::rtrim
- str::trim
## Directory ##
The *dir* module provides an interface to read file names in a specified directory.
- dir::open
- dir::close
- dir::read
- dir::reset
- dir::errno
- dir::errstr
~~~~~{.awk}
BEGIN {
x = dir::open (".");
while ((dir::read(x, file)) > 0) print file;
dir::close(x);
}'
~~~~~
## SED ##
The *sed* module provides built-in sed capabilities.
- sed::file_to_file
- sed::str_to_str
~~~~~{.awk}
BEGIN {
sed::file_to_file ("s/[a-z]/#/g", "in.txt", "out.txt");
}'
~~~~~
[awkbook]: http://cm.bell-labs.com/cm/cs/awkbook/

View File

@ -2648,6 +2648,33 @@ QSE_EXPORT qse_wchar_t* qse_awk_rtx_valtowcsdup (
qse_size_t* len /**< result length */
);
/**
* The qse_awk_rtx_getvalstr() function returns a string
* pointer converted from a value \a val. If the value
* type is #QSE_AWK_VAL_STR, it simply returns the internal
* pointer without duplication. Otherwise, it calls
* qse_awk_rtx_valtostrdup(). The length of the returned
* string is stored into the location pointed to by \a len.
*/
QSE_EXPORT qse_char_t* qse_awk_rtx_getvalstr (
qse_awk_rtx_t* rtx, /**< runtime context */
const qse_awk_val_t* val, /**< value to convert */
qse_size_t* len /**< result length */
);
/**
* The qse_awk_rtx_freevalstr() function frees the memory pointed
* to by \a str if \a val is not of the #QSE_AWK_VAL_STR type.
* This function expects a value pointer and a string pointer
* passed to and returned by qse_awk_rtx_getvalstr() respectively.
*/
QSE_EXPORT void qse_awk_rtx_freevalstr (
qse_awk_rtx_t* rtx, /**< runtime context */
const qse_awk_val_t* val, /**< value to convert */
qse_char_t* str /**< string pointer */
);
/**
* The qse_awk_rtx_valtonum() function converts a value to a number.
* If the value is converted to an integer, it is stored in the memory

View File

@ -169,6 +169,17 @@ QSE_EXPORT int qse_sed_compstdstr (
const qse_char_t* script
);
/**
* The qse_sed_compstd() function compiles a sed script of the
* length @a script_len pointed to by @a script.
* @return 0 on success, -1 on failure
*/
QSE_EXPORT int qse_sed_compstdstrx (
qse_sed_t* sed,
const qse_char_t* script,
qse_size_t script_len
);
/**
* The qse_sed_execstd() function executes a compiled script
* over input streams @a in and an output stream @a out.

View File

@ -1,2 +1,2 @@
SUBDIRS = cmn awk sed xli http
SUBDIRS = cmn sed awk xli http
DIST_SUBDIRS = $(SUBDIRS)

View File

@ -271,7 +271,7 @@ target_alias = @target_alias@
top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
SUBDIRS = cmn awk sed xli http
SUBDIRS = cmn sed awk xli http
DIST_SUBDIRS = $(SUBDIRS)
all: all-recursive

View File

@ -43,6 +43,7 @@ if ENABLE_STATIC_MODULE
##################################################
libqseawk_la_SOURCES += \
mod-dir.c mod-dir.h \
mod-sed.c mod-sed.h \
mod-str.c mod-str.h \
mod-sys.c mod-sys.h
@ -74,6 +75,12 @@ libqseawk_dir_la_CPPFLAGS = $(CPPFLAGS_MOD_COMMON)
libqseawk_dir_la_LDFLAGS = $(LDFLAGS_MOD_COMMON)
libqseawk_dir_la_LIBADD = $(LIBADD_MOD_COMMON)
modexec_LTLIBRARIES += libqseawk-sed.la
libqseawk_sed_la_SOURCES = mod-sed.c mod-sed.h
libqseawk_sed_la_CPPFLAGS = $(CPPFLAGS_MOD_COMMON)
libqseawk_sed_la_LDFLAGS = $(LDFLAGS_MOD_COMMON) -L../sed
libqseawk_sed_la_LIBADD = $(LIBADD_MOD_COMMON) -lqsesed
modexec_LTLIBRARIES += libqseawk-str.la
libqseawk_str_la_SOURCES = mod-str.c mod-str.h
libqseawk_str_la_CPPFLAGS = $(CPPFLAGS_MOD_COMMON)

View File

@ -46,6 +46,7 @@ host_triplet = @host@
##################################################
@ENABLE_STATIC_MODULE_TRUE@am__append_4 = \
@ENABLE_STATIC_MODULE_TRUE@ mod-dir.c mod-dir.h \
@ENABLE_STATIC_MODULE_TRUE@ mod-sed.c mod-sed.h \
@ENABLE_STATIC_MODULE_TRUE@ mod-str.c mod-str.h \
@ENABLE_STATIC_MODULE_TRUE@ mod-sys.c mod-sys.h
@ -127,6 +128,18 @@ libqseawk_mpi_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \
@ENABLE_STATIC_MODULE_FALSE@@HAVE_C_MPI_TRUE@am_libqseawk_mpi_la_rpath = \
@ENABLE_STATIC_MODULE_FALSE@@HAVE_C_MPI_TRUE@ -rpath \
@ENABLE_STATIC_MODULE_FALSE@@HAVE_C_MPI_TRUE@ $(modexecdir)
@ENABLE_STATIC_MODULE_FALSE@libqseawk_sed_la_DEPENDENCIES = \
@ENABLE_STATIC_MODULE_FALSE@ $(am__DEPENDENCIES_1)
am__libqseawk_sed_la_SOURCES_DIST = mod-sed.c mod-sed.h
@ENABLE_STATIC_MODULE_FALSE@am_libqseawk_sed_la_OBJECTS = \
@ENABLE_STATIC_MODULE_FALSE@ libqseawk_sed_la-mod-sed.lo
libqseawk_sed_la_OBJECTS = $(am_libqseawk_sed_la_OBJECTS)
libqseawk_sed_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \
$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \
$(AM_CFLAGS) $(CFLAGS) $(libqseawk_sed_la_LDFLAGS) $(LDFLAGS) \
-o $@
@ENABLE_STATIC_MODULE_FALSE@am_libqseawk_sed_la_rpath = -rpath \
@ENABLE_STATIC_MODULE_FALSE@ $(modexecdir)
@ENABLE_STATIC_MODULE_FALSE@libqseawk_str_la_DEPENDENCIES = \
@ENABLE_STATIC_MODULE_FALSE@ $(am__DEPENDENCIES_1)
am__libqseawk_str_la_SOURCES_DIST = mod-str.c mod-str.h
@ -169,10 +182,11 @@ libqseawk_la_DEPENDENCIES = $(am__DEPENDENCIES_2) \
$(am__DEPENDENCIES_3)
am__libqseawk_la_SOURCES_DIST = awk.c err.c tree.c parse.c run.c rec.c \
val.c fnc.c misc.c rio.c std.c awk.h err.h rio.h val.h fnc.h \
misc.h parse.h run.h tree.h mod-dir.c mod-dir.h mod-str.c \
mod-str.h mod-sys.c mod-sys.h mod-mpi.c mod-mpi.h mod-uci.c \
mod-uci.h
misc.h parse.h run.h tree.h mod-dir.c mod-dir.h mod-sed.c \
mod-sed.h mod-str.c mod-str.h mod-sys.c mod-sys.h mod-mpi.c \
mod-mpi.h mod-uci.c mod-uci.h
@ENABLE_STATIC_MODULE_TRUE@am__objects_1 = libqseawk_la-mod-dir.lo \
@ENABLE_STATIC_MODULE_TRUE@ libqseawk_la-mod-sed.lo \
@ENABLE_STATIC_MODULE_TRUE@ libqseawk_la-mod-str.lo \
@ENABLE_STATIC_MODULE_TRUE@ libqseawk_la-mod-sys.lo
@ENABLE_STATIC_MODULE_TRUE@@HAVE_C_MPI_TRUE@am__objects_2 = libqseawk_la-mod-mpi.lo
@ -239,11 +253,12 @@ AM_V_GEN = $(am__v_GEN_@AM_V@)
am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
am__v_GEN_0 = @echo " GEN " $@;
SOURCES = $(libqseawk_dir_la_SOURCES) $(libqseawk_mpi_la_SOURCES) \
$(libqseawk_str_la_SOURCES) $(libqseawk_sys_la_SOURCES) \
$(libqseawk_uci_la_SOURCES) $(libqseawk_la_SOURCES) \
$(libqseawkxx_la_SOURCES)
$(libqseawk_sed_la_SOURCES) $(libqseawk_str_la_SOURCES) \
$(libqseawk_sys_la_SOURCES) $(libqseawk_uci_la_SOURCES) \
$(libqseawk_la_SOURCES) $(libqseawkxx_la_SOURCES)
DIST_SOURCES = $(am__libqseawk_dir_la_SOURCES_DIST) \
$(am__libqseawk_mpi_la_SOURCES_DIST) \
$(am__libqseawk_sed_la_SOURCES_DIST) \
$(am__libqseawk_str_la_SOURCES_DIST) \
$(am__libqseawk_sys_la_SOURCES_DIST) \
$(am__libqseawk_uci_la_SOURCES_DIST) \
@ -462,12 +477,17 @@ libqseawk_la_LIBADD = $(LIBADD_LIB_COMMON) $(am__append_9)
@ENABLE_STATIC_MODULE_FALSE@LIBADD_MOD_COMMON = -lqseawk -lqsecmn
@ENABLE_STATIC_MODULE_FALSE@modexecdir = $(libdir)
@ENABLE_STATIC_MODULE_FALSE@modexec_LTLIBRARIES = libqseawk-dir.la \
@ENABLE_STATIC_MODULE_FALSE@ libqseawk-str.la libqseawk-sys.la \
@ENABLE_STATIC_MODULE_FALSE@ $(am__append_10) $(am__append_11)
@ENABLE_STATIC_MODULE_FALSE@ libqseawk-sed.la libqseawk-str.la \
@ENABLE_STATIC_MODULE_FALSE@ libqseawk-sys.la $(am__append_10) \
@ENABLE_STATIC_MODULE_FALSE@ $(am__append_11)
@ENABLE_STATIC_MODULE_FALSE@libqseawk_dir_la_SOURCES = mod-dir.c mod-dir.h
@ENABLE_STATIC_MODULE_FALSE@libqseawk_dir_la_CPPFLAGS = $(CPPFLAGS_MOD_COMMON)
@ENABLE_STATIC_MODULE_FALSE@libqseawk_dir_la_LDFLAGS = $(LDFLAGS_MOD_COMMON)
@ENABLE_STATIC_MODULE_FALSE@libqseawk_dir_la_LIBADD = $(LIBADD_MOD_COMMON)
@ENABLE_STATIC_MODULE_FALSE@libqseawk_sed_la_SOURCES = mod-sed.c mod-sed.h
@ENABLE_STATIC_MODULE_FALSE@libqseawk_sed_la_CPPFLAGS = $(CPPFLAGS_MOD_COMMON)
@ENABLE_STATIC_MODULE_FALSE@libqseawk_sed_la_LDFLAGS = $(LDFLAGS_MOD_COMMON) -L../sed
@ENABLE_STATIC_MODULE_FALSE@libqseawk_sed_la_LIBADD = $(LIBADD_MOD_COMMON) -lqsesed
@ENABLE_STATIC_MODULE_FALSE@libqseawk_str_la_SOURCES = mod-str.c mod-str.h
@ENABLE_STATIC_MODULE_FALSE@libqseawk_str_la_CPPFLAGS = $(CPPFLAGS_MOD_COMMON)
@ENABLE_STATIC_MODULE_FALSE@libqseawk_str_la_LDFLAGS = $(LDFLAGS_MOD_COMMON)
@ -584,6 +604,8 @@ libqseawk-dir.la: $(libqseawk_dir_la_OBJECTS) $(libqseawk_dir_la_DEPENDENCIES) $
$(AM_V_CCLD)$(libqseawk_dir_la_LINK) $(am_libqseawk_dir_la_rpath) $(libqseawk_dir_la_OBJECTS) $(libqseawk_dir_la_LIBADD) $(LIBS)
libqseawk-mpi.la: $(libqseawk_mpi_la_OBJECTS) $(libqseawk_mpi_la_DEPENDENCIES) $(EXTRA_libqseawk_mpi_la_DEPENDENCIES)
$(AM_V_CCLD)$(libqseawk_mpi_la_LINK) $(am_libqseawk_mpi_la_rpath) $(libqseawk_mpi_la_OBJECTS) $(libqseawk_mpi_la_LIBADD) $(LIBS)
libqseawk-sed.la: $(libqseawk_sed_la_OBJECTS) $(libqseawk_sed_la_DEPENDENCIES) $(EXTRA_libqseawk_sed_la_DEPENDENCIES)
$(AM_V_CCLD)$(libqseawk_sed_la_LINK) $(am_libqseawk_sed_la_rpath) $(libqseawk_sed_la_OBJECTS) $(libqseawk_sed_la_LIBADD) $(LIBS)
libqseawk-str.la: $(libqseawk_str_la_OBJECTS) $(libqseawk_str_la_DEPENDENCIES) $(EXTRA_libqseawk_str_la_DEPENDENCIES)
$(AM_V_CCLD)$(libqseawk_str_la_LINK) $(am_libqseawk_str_la_rpath) $(libqseawk_str_la_OBJECTS) $(libqseawk_str_la_LIBADD) $(LIBS)
libqseawk-sys.la: $(libqseawk_sys_la_OBJECTS) $(libqseawk_sys_la_DEPENDENCIES) $(EXTRA_libqseawk_sys_la_DEPENDENCIES)
@ -608,6 +630,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libqseawk_la-misc.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libqseawk_la-mod-dir.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libqseawk_la-mod-mpi.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libqseawk_la-mod-sed.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libqseawk_la-mod-str.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libqseawk_la-mod-sys.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libqseawk_la-mod-uci.Plo@am__quote@
@ -619,6 +642,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libqseawk_la-tree.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libqseawk_la-val.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libqseawk_mpi_la-mod-mpi.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libqseawk_sed_la-mod-sed.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libqseawk_str_la-mod-str.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libqseawk_sys_la-mod-sys.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libqseawk_uci_la-mod-uci.Plo@am__quote@
@ -660,6 +684,13 @@ libqseawk_mpi_la-mod-mpi.lo: mod-mpi.c
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libqseawk_mpi_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libqseawk_mpi_la-mod-mpi.lo `test -f 'mod-mpi.c' || echo '$(srcdir)/'`mod-mpi.c
libqseawk_sed_la-mod-sed.lo: mod-sed.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libqseawk_sed_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libqseawk_sed_la-mod-sed.lo -MD -MP -MF $(DEPDIR)/libqseawk_sed_la-mod-sed.Tpo -c -o libqseawk_sed_la-mod-sed.lo `test -f 'mod-sed.c' || echo '$(srcdir)/'`mod-sed.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libqseawk_sed_la-mod-sed.Tpo $(DEPDIR)/libqseawk_sed_la-mod-sed.Plo
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mod-sed.c' object='libqseawk_sed_la-mod-sed.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libqseawk_sed_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libqseawk_sed_la-mod-sed.lo `test -f 'mod-sed.c' || echo '$(srcdir)/'`mod-sed.c
libqseawk_str_la-mod-str.lo: mod-str.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libqseawk_str_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libqseawk_str_la-mod-str.lo -MD -MP -MF $(DEPDIR)/libqseawk_str_la-mod-str.Tpo -c -o libqseawk_str_la-mod-str.lo `test -f 'mod-str.c' || echo '$(srcdir)/'`mod-str.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libqseawk_str_la-mod-str.Tpo $(DEPDIR)/libqseawk_str_la-mod-str.Plo
@ -765,6 +796,13 @@ libqseawk_la-mod-dir.lo: mod-dir.c
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libqseawk_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libqseawk_la-mod-dir.lo `test -f 'mod-dir.c' || echo '$(srcdir)/'`mod-dir.c
libqseawk_la-mod-sed.lo: mod-sed.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libqseawk_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libqseawk_la-mod-sed.lo -MD -MP -MF $(DEPDIR)/libqseawk_la-mod-sed.Tpo -c -o libqseawk_la-mod-sed.lo `test -f 'mod-sed.c' || echo '$(srcdir)/'`mod-sed.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libqseawk_la-mod-sed.Tpo $(DEPDIR)/libqseawk_la-mod-sed.Plo
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mod-sed.c' object='libqseawk_la-mod-sed.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libqseawk_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libqseawk_la-mod-sed.lo `test -f 'mod-sed.c' || echo '$(srcdir)/'`mod-sed.c
libqseawk_la-mod-str.lo: mod-str.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libqseawk_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libqseawk_la-mod-str.lo -MD -MP -MF $(DEPDIR)/libqseawk_la-mod-str.Tpo -c -o libqseawk_la-mod-str.lo `test -f 'mod-str.c' || echo '$(srcdir)/'`mod-str.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libqseawk_la-mod-str.Tpo $(DEPDIR)/libqseawk_la-mod-str.Plo

View File

@ -937,13 +937,13 @@ int StdAwk::open_console_in (Console& io)
v = (qse_awk_val_t*)QSE_HTB_VPTR(pair);
QSE_ASSERT (v != QSE_NULL);
as.ptr = qse_awk_rtx_valtostrdup (rtx, v, &as.len);
as.ptr = qse_awk_rtx_getvalstr (rtx, v, &as.len);
if (as.ptr == QSE_NULL) return -1;
if (as.len == 0)
{
/* the name is empty */
qse_awk_rtx_freemem (rtx, as.ptr);
qse_awk_rtx_freevalstr (rtx, v, as.ptr);
this->runarg_index++;
goto nextfile;
}
@ -955,7 +955,7 @@ int StdAwk::open_console_in (Console& io)
arg.ptr = as.ptr;
arg.len = qse_strlen (as.ptr);
((Run*)io)->setError (QSE_AWK_EIONMNL, &arg);
qse_awk_rtx_freemem (rtx, as.ptr);
qse_awk_rtx_freevalstr (rtx, v, as.ptr);
return -1;
}
@ -967,21 +967,20 @@ int StdAwk::open_console_in (Console& io)
sio = open_sio (QSE_NULL, io, file, QSE_SIO_READ | QSE_SIO_IGNOREMBWCERR);
if (sio == QSE_NULL)
{
qse_awk_rtx_freemem (rtx, as.ptr);
qse_awk_rtx_freevalstr (rtx, v, as.ptr);
return -1;
}
if (qse_awk_rtx_setfilename (rtx, file, qse_strlen(file)) <= -1)
{
qse_sio_close (sio);
qse_awk_rtx_freemem (rtx, as.ptr);
qse_awk_rtx_freevalstr (rtx, v, as.ptr);
return -1;
}
qse_awk_rtx_freemem (rtx, as.ptr);
qse_awk_rtx_freevalstr (rtx, v, as.ptr);
if (this->console_cmgr)
qse_sio_setcmgr (sio, this->console_cmgr);
if (this->console_cmgr) qse_sio_setcmgr (sio, this->console_cmgr);
io.setHandle (sio);

View File

@ -214,33 +214,16 @@ static int fnc_close (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi)
if (nargs >= 2) a1 = qse_awk_rtx_getarg (rtx, 1);
QSE_ASSERT (a0 != QSE_NULL);
if (a0->type == QSE_AWK_VAL_STR)
{
name = ((qse_awk_val_str_t*)a0)->val.ptr;
len = ((qse_awk_val_str_t*)a0)->val.len;
}
else
{
name = qse_awk_rtx_valtostrdup (rtx, a0, &len);
if (name == QSE_NULL) return -1;
}
name = qse_awk_rtx_getvalstr (rtx, a0, &len);
if (name == QSE_NULL) return -1;
if (a1)
{
if (a1->type == QSE_AWK_VAL_STR)
opt = qse_awk_rtx_getvalstr (rtx, a1, &optlen);
if (opt == QSE_NULL)
{
opt = ((qse_awk_val_str_t*)a1)->val.ptr;
optlen = ((qse_awk_val_str_t*)a1)->val.len;
}
else
{
opt = qse_awk_rtx_valtostrdup (rtx, a1, &optlen);
if (opt == QSE_NULL)
{
if (a1->type != QSE_AWK_VAL_STR)
QSE_AWK_FREE (rtx->awk, name);
return -1;
}
qse_awk_rtx_freevalstr (rtx, a0, name);
return -1;
}
}
@ -291,10 +274,8 @@ static int fnc_close (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi)
*/
skip_close:
if (a1 != QSE_NULL && a1->type != QSE_AWK_VAL_STR)
QSE_AWK_FREE (rtx->awk, opt);
if (a0->type != QSE_AWK_VAL_STR) QSE_AWK_FREE (rtx->awk, name);
if (a1) qse_awk_rtx_freevalstr (rtx, a1, opt);
qse_awk_rtx_freevalstr (rtx, a0, name);
v = qse_awk_rtx_makeintval (rtx, (qse_awk_int_t)n);
if (v == QSE_NULL) return -1;
@ -333,15 +314,15 @@ static int flush_io (
return n;
}
static int fnc_fflush (qse_awk_rtx_t* run, const qse_awk_fnc_info_t* fi)
static int fnc_fflush (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi)
{
qse_size_t nargs;
qse_awk_val_t* a0;
qse_awk_val_t* a0, * v;
qse_char_t* str0;
qse_size_t len0;
int n;
nargs = qse_awk_rtx_getnargs (run);
nargs = qse_awk_rtx_getnargs (rtx);
QSE_ASSERT (nargs == 0 || nargs == 1);
if (nargs == 0)
@ -356,23 +337,15 @@ static int fnc_fflush (qse_awk_rtx_t* run, const qse_awk_fnc_info_t* fi)
* BEGIN { flush(); } # flush() returns -1
* BEGIN { print 1; flush(); } # flush() returns 0
*/
n = qse_awk_rtx_flushio (run, QSE_AWK_OUT_CONSOLE, QSE_T(""));
n = qse_awk_rtx_flushio (rtx, QSE_AWK_OUT_CONSOLE, QSE_T(""));
}
else
{
qse_char_t* ptr, * end;
a0 = qse_awk_rtx_getarg (run, 0);
if (a0->type == QSE_AWK_VAL_STR)
{
str0 = ((qse_awk_val_str_t*)a0)->val.ptr;
len0 = ((qse_awk_val_str_t*)a0)->val.len;
}
else
{
str0 = qse_awk_rtx_valtostrdup (run, a0, &len0);
if (str0 == QSE_NULL) return -1;
}
a0 = qse_awk_rtx_getarg (rtx, 0);
str0 = qse_awk_rtx_getvalstr (rtx, a0, &len0);
if (str0 == QSE_NULL) return -1;
/* the target name contains a null character.
* make fflush return -1 */
@ -408,19 +381,19 @@ static int fnc_fflush (qse_awk_rtx_t* run, const qse_awk_fnc_info_t* fi)
*/
n = flush_io (
run, QSE_AWK_OUT_FILE,
rtx, QSE_AWK_OUT_FILE,
((len0 == 0)? QSE_NULL: str0), 1);
/*if (n == -99) return -1;*/
n = flush_io (
run, QSE_AWK_OUT_APFILE,
rtx, QSE_AWK_OUT_APFILE,
((len0 == 0)? QSE_NULL: str0), n);
/*if (n == -99) return -1;*/
n = flush_io (
run, QSE_AWK_OUT_PIPE,
rtx, QSE_AWK_OUT_PIPE,
((len0 == 0)? QSE_NULL: str0), n);
/*if (n == -99) return -1;*/
n = flush_io (
run, QSE_AWK_OUT_RWPIPE,
rtx, QSE_AWK_OUT_RWPIPE,
((len0 == 0)? QSE_NULL: str0), n);
/*if (n == -99) return -1;*/
@ -431,20 +404,20 @@ static int fnc_fflush (qse_awk_rtx_t* run, const qse_awk_fnc_info_t* fi)
if (n != 0) n = -1;
skip_flush:
if (a0->type != QSE_AWK_VAL_STR) QSE_AWK_FREE (run->awk, str0);
qse_awk_rtx_freevalstr (rtx, a0, str0);
}
a0 = qse_awk_rtx_makeintval (run, (qse_awk_int_t)n);
if (a0 == QSE_NULL) return -1;
v = qse_awk_rtx_makeintval (rtx, (qse_awk_int_t)n);
if (v == QSE_NULL) return -1;
qse_awk_rtx_setretval (run, a0);
qse_awk_rtx_setretval (rtx, v);
return 0;
}
static int fnc_index (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi)
{
qse_size_t nargs;
qse_awk_val_t* a0, * a1;
qse_awk_val_t* a0, * a1, * v;
qse_char_t* str0, * str1, * ptr;
qse_size_t len0, len1;
qse_awk_int_t idx, start = 1;
@ -465,31 +438,14 @@ static int fnc_index (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi)
if (n <= -1) return -1;
}
if (a0->type == QSE_AWK_VAL_STR)
{
str0 = ((qse_awk_val_str_t*)a0)->val.ptr;
len0 = ((qse_awk_val_str_t*)a0)->val.len;
}
else
{
str0 = qse_awk_rtx_valtostrdup (rtx, a0, &len0);
if (str0 == QSE_NULL) return -1;
}
str0 = qse_awk_rtx_getvalstr (rtx, a0, &len0);
if (str0 == QSE_NULL) return -1;
if (a1->type == QSE_AWK_VAL_STR)
str1 = qse_awk_rtx_getvalstr (rtx, a1, &len1);
if (str1 == QSE_NULL)
{
str1 = ((qse_awk_val_str_t*)a1)->val.ptr;
len1 = ((qse_awk_val_str_t*)a1)->val.len;
}
else
{
str1 = qse_awk_rtx_valtostrdup (rtx, a1, &len1);
if (str1 == QSE_NULL)
{
if (a0->type != QSE_AWK_VAL_STR)
QSE_AWK_FREE (rtx->awk, str0);
return -1;
}
qse_awk_rtx_freevalstr (rtx, a0, str0);
return -1;
}
if (start == 0) start = 1;
@ -502,13 +458,13 @@ static int fnc_index (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi)
idx = (ptr == QSE_NULL)? 0: ((qse_awk_int_t)(ptr-str0) + 1);
if (a0->type != QSE_AWK_VAL_STR) QSE_AWK_FREE (rtx->awk, str0);
if (a1->type != QSE_AWK_VAL_STR) QSE_AWK_FREE (rtx->awk, str1);
qse_awk_rtx_freevalstr (rtx, a1, str1);
qse_awk_rtx_freevalstr (rtx, a0, str0);
a0 = qse_awk_rtx_makeintval (rtx, idx);
if (a0 == QSE_NULL) return -1;
v = qse_awk_rtx_makeintval (rtx, idx);
if (v == QSE_NULL) return -1;
qse_awk_rtx_setretval (rtx, a0);
qse_awk_rtx_setretval (rtx, v);
return 0;
}
@ -572,21 +528,13 @@ static int fnc_substr (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi)
a1 = qse_awk_rtx_getarg (rtx, 1);
a2 = (nargs >= 3)? qse_awk_rtx_getarg (rtx, 2): QSE_NULL;
if (a0->type == QSE_AWK_VAL_STR)
{
str = ((qse_awk_val_str_t*)a0)->val.ptr;
len = ((qse_awk_val_str_t*)a0)->val.len;
}
else
{
str = qse_awk_rtx_valtostrdup (rtx, a0, &len);
if (str == QSE_NULL) return -1;
}
str = qse_awk_rtx_getvalstr (rtx, a0, &len);
if (str == QSE_NULL) return -1;
n = qse_awk_rtx_valtoint (rtx, a1, &lindex);
if (n <= -1)
{
if (a0->type != QSE_AWK_VAL_STR) QSE_AWK_FREE (rtx->awk, str);
qse_awk_rtx_freevalstr (rtx, a0, str);
return -1;
}
@ -596,8 +544,7 @@ static int fnc_substr (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi)
n = qse_awk_rtx_valtoint (rtx, a2, &lcount);
if (n <= -1)
{
if (a0->type != QSE_AWK_VAL_STR)
QSE_AWK_FREE (rtx->awk, str);
qse_awk_rtx_freevalstr (rtx, a0, str);
return -1;
}
}
@ -615,11 +562,11 @@ static int fnc_substr (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi)
r = qse_awk_rtx_makestrval (rtx, &str[lindex], (qse_size_t)lcount);
if (r == QSE_NULL)
{
if (a0->type != QSE_AWK_VAL_STR) QSE_AWK_FREE (rtx->awk, str);
qse_awk_rtx_freevalstr (rtx, a0, str);
return -1;
}
if (a0->type != QSE_AWK_VAL_STR) QSE_AWK_FREE (rtx->awk, str);
qse_awk_rtx_freevalstr (rtx, a0, str);
qse_awk_rtx_setretval (rtx, r);
return 0;
}
@ -825,77 +772,61 @@ oops:
return -1;
}
static int fnc_tolower (qse_awk_rtx_t* run, const qse_awk_fnc_info_t* fi)
static int fnc_tolower (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi)
{
qse_size_t nargs;
qse_size_t i;
qse_awk_val_t* a0, * r;
qse_xstr_t str;
nargs = qse_awk_rtx_getnargs (run);
nargs = qse_awk_rtx_getnargs (rtx);
QSE_ASSERT (nargs == 1);
a0 = qse_awk_rtx_getarg (run, 0);
a0 = qse_awk_rtx_getarg (rtx, 0);
if (a0->type == QSE_AWK_VAL_STR)
{
str.ptr = ((qse_awk_val_str_t*)a0)->val.ptr;
str.len = ((qse_awk_val_str_t*)a0)->val.len;
}
else
{
str.ptr = qse_awk_rtx_valtostrdup (run, a0, &str.len);
if (str.ptr == QSE_NULL) return -1;
}
str.ptr = qse_awk_rtx_getvalstr (rtx, a0, &str.len);
if (str.ptr == QSE_NULL) return -1;
for (i = 0; i < str.len; i++) str.ptr[i] = QSE_AWK_TOLOWER (run->awk, str.ptr[i]);
for (i = 0; i < str.len; i++) str.ptr[i] = QSE_AWK_TOLOWER (rtx->awk, str.ptr[i]);
r = qse_awk_rtx_makestrvalwithcstr (run, (qse_cstr_t*)&str);
r = qse_awk_rtx_makestrvalwithcstr (rtx, (qse_cstr_t*)&str);
if (r == QSE_NULL)
{
if (a0->type != QSE_AWK_VAL_STR) QSE_AWK_FREE (run->awk, str.ptr);
qse_awk_rtx_freevalstr (rtx, a0, str.ptr);
return -1;
}
if (a0->type != QSE_AWK_VAL_STR) QSE_AWK_FREE (run->awk, str.ptr);
qse_awk_rtx_setretval (run, r);
qse_awk_rtx_freevalstr (rtx, a0, str.ptr);
qse_awk_rtx_setretval (rtx, r);
return 0;
}
static int fnc_toupper (qse_awk_rtx_t* run, const qse_awk_fnc_info_t* fi)
static int fnc_toupper (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi)
{
qse_size_t nargs;
qse_size_t i;
qse_awk_val_t* a0, * r;
qse_xstr_t str;
nargs = qse_awk_rtx_getnargs (run);
nargs = qse_awk_rtx_getnargs (rtx);
QSE_ASSERT (nargs == 1);
a0 = qse_awk_rtx_getarg (run, 0);
a0 = qse_awk_rtx_getarg (rtx, 0);
if (a0->type == QSE_AWK_VAL_STR)
{
str.ptr = ((qse_awk_val_str_t*)a0)->val.ptr;
str.len = ((qse_awk_val_str_t*)a0)->val.len;
}
else
{
str.ptr = qse_awk_rtx_valtostrdup (run, a0, &str.len);
if (str.ptr == QSE_NULL) return -1;
}
str.ptr = qse_awk_rtx_getvalstr (rtx, a0, &str.len);
if (str.ptr == QSE_NULL) return -1;
for (i = 0; i < str.len; i++) str.ptr[i] = QSE_AWK_TOUPPER (run->awk, str.ptr[i]);
for (i = 0; i < str.len; i++) str.ptr[i] = QSE_AWK_TOUPPER (rtx->awk, str.ptr[i]);
r = qse_awk_rtx_makestrvalwithcstr (run, (qse_cstr_t*)&str);
r = qse_awk_rtx_makestrvalwithcstr (rtx, (qse_cstr_t*)&str);
if (r == QSE_NULL)
{
if (a0->type != QSE_AWK_VAL_STR) QSE_AWK_FREE (run->awk, str.ptr);
qse_awk_rtx_freevalstr (rtx, a0, str.ptr);
return -1;
}
if (a0->type != QSE_AWK_VAL_STR) QSE_AWK_FREE (run->awk, str.ptr);
qse_awk_rtx_setretval (run, r);
qse_awk_rtx_freevalstr (rtx, a0, str.ptr);
qse_awk_rtx_setretval (rtx, r);
return 0;
}
@ -1211,16 +1142,8 @@ static int fnc_match (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi)
}
}
if (a0->type == QSE_AWK_VAL_STR)
{
str0 = ((qse_awk_val_str_t*)a0)->val.ptr;
len0 = ((qse_awk_val_str_t*)a0)->val.len;
}
else
{
str0 = qse_awk_rtx_valtostrdup (rtx, a0, &len0);
if (str0 == QSE_NULL) return -1;
}
str0 = qse_awk_rtx_getvalstr (rtx, a0, &len0);
if (str0 == QSE_NULL) return -1;
if (start == 0) start = 1;
else if (start < 0) start = len0 + start + 1;
@ -1238,7 +1161,7 @@ static int fnc_match (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi)
if (n <= -1) return -1;
}
if (a0->type != QSE_AWK_VAL_STR) QSE_AWK_FREE (rtx->awk, str0);
qse_awk_rtx_freevalstr (rtx, a0, str0);
idx = (n == 0)? 0: ((qse_awk_int_t)(mat.ptr-str0) + 1);
@ -1278,7 +1201,7 @@ static int fnc_match (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi)
return 0;
}
static int fnc_sprintf (qse_awk_rtx_t* run, const qse_awk_fnc_info_t* fi)
static int fnc_sprintf (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi)
{
qse_size_t nargs;
qse_awk_val_t* a0;
@ -1287,45 +1210,38 @@ static int fnc_sprintf (qse_awk_rtx_t* run, const qse_awk_fnc_info_t* fi)
qse_xstr_t cs0;
qse_xstr_t x;
nargs = qse_awk_rtx_getnargs (run);
nargs = qse_awk_rtx_getnargs (rtx);
QSE_ASSERT (nargs > 0);
if (qse_str_init (&out, run->awk->mmgr, 256) <= -1)
if (qse_str_init (&out, rtx->awk->mmgr, 256) <= -1)
{
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOMEM, QSE_NULL);
qse_awk_rtx_seterrnum (rtx, QSE_AWK_ENOMEM, QSE_NULL);
goto oops;
}
out_inited = 1;
if (qse_str_init (&fbu, run->awk->mmgr, 256) <= -1)
if (qse_str_init (&fbu, rtx->awk->mmgr, 256) <= -1)
{
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOMEM, QSE_NULL);
qse_awk_rtx_seterrnum (rtx, QSE_AWK_ENOMEM, QSE_NULL);
goto oops;
}
fbu_inited = 1;
a0 = qse_awk_rtx_getarg (run, 0);
if (a0->type == QSE_AWK_VAL_STR)
{
cs0 = ((qse_awk_val_str_t*)a0)->val;
}
else
{
cs0.ptr = qse_awk_rtx_valtostrdup (run, a0, &cs0.len);
if (cs0.ptr == QSE_NULL) goto oops;
}
a0 = qse_awk_rtx_getarg (rtx, 0);
cs0.ptr = qse_awk_rtx_getvalstr (rtx, a0, &cs0.len);
if (cs0.ptr == QSE_NULL) goto oops;
x.ptr = qse_awk_rtx_format (run,
x.ptr = qse_awk_rtx_format (rtx,
&out, &fbu, cs0.ptr, cs0.len, nargs, QSE_NULL, &x.len);
if (a0->type != QSE_AWK_VAL_STR) QSE_AWK_FREE (run->awk, cs0.ptr);
qse_awk_rtx_freevalstr (rtx, a0, cs0.ptr);
if (x.ptr == QSE_NULL) goto oops;
a0 = qse_awk_rtx_makestrvalwithcstr (run, (qse_cstr_t*)&x);
a0 = qse_awk_rtx_makestrvalwithcstr (rtx, (qse_cstr_t*)&x);
if (a0 == QSE_NULL) goto oops;
qse_str_fini (&fbu);
qse_str_fini (&out);
qse_awk_rtx_setretval (run, a0);
qse_awk_rtx_setretval (rtx, a0);
return 0;
oops:

View File

@ -1303,29 +1303,17 @@ int qse_awk_rtx_matchrex (
{
code = ((qse_awk_val_rex_t*)val)->code[icase];
}
else if (val->type == QSE_AWK_VAL_STR)
{
/* build a regular expression */
qse_awk_val_str_t* strv = (qse_awk_val_str_t*)val;
x = icase? qse_awk_buildrex (rtx->awk, strv->val.ptr, strv->val.len, &awkerr, QSE_NULL, &code):
qse_awk_buildrex (rtx->awk, strv->val.ptr, strv->val.len, &awkerr, &code, QSE_NULL);
if (x <= -1)
{
qse_awk_rtx_seterrnum (rtx, awkerr, QSE_NULL);
return -1;
}
}
else
{
/* convert to a string and build a regular expression */
qse_xstr_t tmp;
tmp.ptr = qse_awk_rtx_valtostrdup (rtx, val, &tmp.len);
tmp.ptr = qse_awk_rtx_getvalstr (rtx, val, &tmp.len);
if (tmp.ptr == QSE_NULL) return -1;
x = icase? qse_awk_buildrex (rtx->awk, tmp.ptr, tmp.len, &awkerr, QSE_NULL, &code):
qse_awk_buildrex (rtx->awk, tmp.ptr, tmp.len, &awkerr, &code, QSE_NULL);
qse_awk_rtx_freemem (rtx, tmp.ptr);
qse_awk_rtx_freevalstr (rtx, val, tmp.ptr);
if (x <= -1)
{
qse_awk_rtx_seterrnum (rtx, awkerr, QSE_NULL);

View File

@ -371,16 +371,18 @@ static int fnc_dir_open (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi)
qse_awk_int_t ret;
qse_char_t* path;
qse_awk_val_t* retv;
qse_awk_val_t* a0;
list = rtx_to_list (rtx, fi);
path = qse_awk_rtx_valtostrdup (rtx, qse_awk_rtx_getarg (rtx, 0), QSE_NULL);
a0 = qse_awk_rtx_getarg (rtx, 0);
path = qse_awk_rtx_getvalstr (rtx, a0, QSE_NULL);
if (path)
{
node = new_dir_node (rtx, list, path);
if (node) ret = node->id;
else ret = -1;
qse_awk_rtx_freemem (rtx, path);
qse_awk_rtx_freevalstr (rtx, a0, path);
}
else
{
@ -440,11 +442,14 @@ static int fnc_dir_reset (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi)
}
else
{
path = qse_awk_rtx_valtostrdup (rtx, qse_awk_rtx_getarg(rtx, 1), QSE_NULL);
qse_awk_val_t* a1;
a1 = qse_awk_rtx_getarg (rtx, 1);
path = qse_awk_rtx_getvalstr (rtx, a1, QSE_NULL);
if (path)
{
ret = reset_byid (rtx, list, id, path);
qse_awk_rtx_freemem (rtx, path);
qse_awk_rtx_freevalstr (rtx, a1, path);
}
else
{

212
qse/lib/awk/mod-sed.c Normal file
View File

@ -0,0 +1,212 @@
/*
* $Id$
*
Copyright 2006-2014 Chung, Hyung-Hwan.
This file is part of QSE.
QSE is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
QSE is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with QSE. If not, see <http://www.gnu.org/licenses/>.
*/
#include "mod-str.h"
#include <qse/sed/stdsed.h>
#include "../cmn/mem.h"
#if 0
static int fnc_errno (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi)
{
uctx_list_t* list;
qse_awk_val_t* retv;
list = rtx_to_list (rtx, fi);
retv = qse_awk_rtx_makeintval (rtx, list->errnum);
if (retv == QSE_NULL) return -1;
qse_awk_rtx_setretval (rtx, retv);
return 0;
}
static qse_char_t* errmsg[] =
{
QSE_T("no error"),
QSE_T("out of memory"),
QSE_T("invalid data"),
QSE_T("not found"),
QSE_T("I/O error"),
QSE_T("parse error"),
QSE_T("duplicate data"),
QSE_T("unknown error")
};
static int fnc_errstr (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi)
{
uctx_list_t* list;
qse_awk_val_t* retv;
qse_awk_int_t errnum;
list = rtx_to_list (rtx, fi);
if (qse_awk_rtx_getnargs (rtx) <= 0 ||
qse_awk_rtx_valtoint (rtx, qse_awk_rtx_getarg (rtx, 0), &errnum) <= -1)
{
errnum = list->errnum;
}
if (errnum < 0 || errnum >= QSE_COUNTOF(errmsg)) errnum = QSE_COUNTOF(errmsg) - 1;
retv = qse_awk_rtx_makestrvalwithstr (rtx, errmsg[errnum]);
if (retv == QSE_NULL) return -1;
qse_awk_rtx_setretval (rtx, retv);
return 0;
}
#endif
static int fnc_file_to_file (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi)
{
qse_sed_t* sed = QSE_NULL;
qse_awk_val_t* retv;
qse_awk_val_t* a[3];
qse_char_t* str[3];
qse_size_t len[3];
int i = 0, ret = 0;
/* result = sed::file_to_file ("s/ABC/123/g", input_file, output_file [, option_string]) */
sed = qse_sed_openstdwithmmgr (qse_awk_rtx_getmmgr(rtx), 0);
if (sed == QSE_NULL)
{
ret = -2;
goto oops;
}
/* TODO qse_set_opt (TRAIT) using the optional parameter */
for (i = 0; i < 3; i++)
{
a[i] = qse_awk_rtx_getarg (rtx, i);
str[i] = qse_awk_rtx_getvalstr (rtx, a[i], &len[i]);
if (str[i] == QSE_NULL)
{
ret = -2;
goto oops;
}
}
if (qse_sed_compstdstrx (sed, str[0], len[0]) <= -1)
{
ret = -3; /* compile error */
goto oops;
}
if (qse_sed_execstdfile (sed, str[1], str[2], QSE_NULL) <= -1)
{
ret = -4;
goto oops;
}
oops:
retv = qse_awk_rtx_makeintval (rtx, ret);
if (retv == QSE_NULL) retv = qse_awk_rtx_makeintval (rtx, -1);
while (i > 0)
{
--i;
qse_awk_rtx_freevalstr (rtx, a[i], str[i]);
}
if (sed) qse_sed_close (sed);
qse_awk_rtx_setretval (rtx, retv);
return 0;
}
static int fnc_str_to_str (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi)
{
return -1;
}
typedef struct fnctab_t fnctab_t;
struct fnctab_t
{
const qse_char_t* name;
qse_awk_mod_sym_fnc_t info;
};
static fnctab_t fnctab[] =
{
/* keep this table sorted for binary search in query(). */
{ QSE_T("file_to_file"), { { 3, 3, QSE_NULL }, fnc_file_to_file, 0 } },
{ QSE_T("str_to_str"), { { 3, 3, QSE_T("vvr")}, fnc_str_to_str, 0 } }
};
static int query (qse_awk_mod_t* mod, qse_awk_t* awk, const qse_char_t* name, qse_awk_mod_sym_t* sym)
{
qse_cstr_t ea;
int left, right, mid, n;
left = 0; right = QSE_COUNTOF(fnctab) - 1;
while (left <= right)
{
mid = (left + right) / 2;
n = qse_strcmp (fnctab[mid].name, name);
if (n > 0) right = mid - 1;
else if (n < 0) left = mid + 1;
else
{
sym->type = QSE_AWK_MOD_FNC;
sym->u.fnc = fnctab[mid].info;
return 0;
}
}
ea.ptr = name;
ea.len = qse_strlen(name);
qse_awk_seterror (awk, QSE_AWK_ENOENT, &ea, QSE_NULL);
return -1;
}
/* TODO: proper resource management */
static int init (qse_awk_mod_t* mod, qse_awk_rtx_t* rtx)
{
return 0;
}
static void fini (qse_awk_mod_t* mod, qse_awk_rtx_t* rtx)
{
/* TODO: anything */
}
static void unload (qse_awk_mod_t* mod, qse_awk_t* awk)
{
/* TODO: anything */
}
int qse_awk_mod_sed (qse_awk_mod_t* mod, qse_awk_t* awk)
{
mod->query = query;
mod->unload = unload;
mod->init = init;
mod->fini = fini;
/*
mod->ctx...
*/
return 0;
}

37
qse/lib/awk/mod-sed.h Normal file
View File

@ -0,0 +1,37 @@
/*
* $Id$
*
Copyright 2006-2014 Chung, Hyung-Hwan.
This file is part of QSE.
QSE is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
QSE is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with QSE. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _QSE_LIB_AWK_MOD_SED_H_
#define _QSE_LIB_AWK_MOD_SED_H_
#include <qse/awk/awk.h>
#if defined(__cplusplus)
extern "C" {
#endif
QSE_EXPORT int qse_awk_mod_sed (qse_awk_mod_t* mod, qse_awk_t* awk);
#if defined(__cplusplus)
}
#endif
#endif

View File

@ -31,14 +31,16 @@ static int fnc_normspace (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi)
*/
qse_xstr_t path;
qse_awk_val_t* retv;
qse_awk_val_t* a0;
path.ptr = qse_awk_rtx_valtostrdup (
rtx, qse_awk_rtx_getarg(rtx, 0), &path.len);
a0 = qse_awk_rtx_getarg(rtx, 0);
path.ptr = qse_awk_rtx_getvalstr (rtx, a0, &path.len);
if (path.ptr)
{
path.len = qse_strxpac (path.ptr, path.len);
retv = qse_awk_rtx_makestrval (rtx, path.ptr, path.len);
qse_awk_rtx_freemem (rtx, path.ptr);
qse_awk_rtx_freevalstr (rtx, a0, path.ptr);
if (retv) qse_awk_rtx_setretval (rtx, retv);
}
@ -50,14 +52,16 @@ static int trim (qse_awk_rtx_t* rtx, int flags)
qse_xstr_t path;
qse_char_t* npath;
qse_awk_val_t* retv;
qse_awk_val_t* a0;
path.ptr = qse_awk_rtx_valtostrdup (
rtx, qse_awk_rtx_getarg(rtx, 0), &path.len);
a0 = qse_awk_rtx_getarg(rtx, 0);
path.ptr = qse_awk_rtx_getvalstr (rtx, a0, &path.len);
if (path.ptr)
{
npath = qse_strxtrmx (path.ptr, &path.len, flags);
retv = qse_awk_rtx_makestrval (rtx, npath, path.len);
qse_awk_rtx_freemem (rtx, path.ptr);
qse_awk_rtx_freevalstr (rtx, a0, path.ptr);
if (retv) qse_awk_rtx_setretval (rtx, retv);
}
@ -106,31 +110,15 @@ static int index_or_rindex (qse_awk_rtx_t* rtx, int rindex)
if (n <= -1) return -1;
}
if (a0->type == QSE_AWK_VAL_STR)
{
str0 = ((qse_awk_val_str_t*)a0)->val.ptr;
len0 = ((qse_awk_val_str_t*)a0)->val.len;
}
else
{
str0 = qse_awk_rtx_valtostrdup (rtx, a0, &len0);
if (str0 == QSE_NULL) return -1;
}
str0 = qse_awk_rtx_getvalstr (rtx, a0, &len0);
if (str0 == QSE_NULL) return -1;
if (a1->type == QSE_AWK_VAL_STR)
str1 = qse_awk_rtx_getvalstr (rtx, a1, &len1);
if (str1 == QSE_NULL)
{
str1 = ((qse_awk_val_str_t*)a1)->val.ptr;
len1 = ((qse_awk_val_str_t*)a1)->val.len;
}
else
{
str1 = qse_awk_rtx_valtostrdup (rtx, a1, &len1);
if (str1 == QSE_NULL)
{
if (a0->type != QSE_AWK_VAL_STR)
qse_awk_rtx_freemem (rtx, str0);
return -1;
}
if (a0->type != QSE_AWK_VAL_STR)
qse_awk_rtx_freevalstr (rtx, a0, str0);
return -1;
}
if (nargs < 3)
@ -158,8 +146,8 @@ static int index_or_rindex (qse_awk_rtx_t* rtx, int rindex)
idx = (ptr == QSE_NULL)? 0: ((qse_awk_int_t)(ptr-str0) + 1);
if (a0->type != QSE_AWK_VAL_STR) qse_awk_rtx_freemem (rtx, str0);
if (a1->type != QSE_AWK_VAL_STR) qse_awk_rtx_freemem (rtx, str1);
qse_awk_rtx_freevalstr (rtx, a1, str1);
qse_awk_rtx_freevalstr (rtx, a0, str0);
a0 = qse_awk_rtx_makeintval (rtx, idx);
if (a0 == QSE_NULL) return -1;
@ -187,16 +175,8 @@ static int is_class (qse_awk_rtx_t* rtx, qse_ctype_t ctype)
a0 = qse_awk_rtx_getarg (rtx, 0);
if (a0->type == QSE_AWK_VAL_STR)
{
str0 = ((qse_awk_val_str_t*)a0)->val.ptr;
len0 = ((qse_awk_val_str_t*)a0)->val.len;
}
else
{
str0 = qse_awk_rtx_valtostrdup (rtx, a0, &len0);
if (str0 == QSE_NULL) return -1;
}
str0 = qse_awk_rtx_getvalstr (rtx, a0, &len0);
if (str0 == QSE_NULL) return -1;
if (len0 <= 0) tmp = 0;
else
@ -212,7 +192,7 @@ static int is_class (qse_awk_rtx_t* rtx, qse_ctype_t ctype)
}
}
while (len0 > 0);
if (a0->type != QSE_AWK_VAL_STR) qse_awk_rtx_freemem (rtx, str0);
qse_awk_rtx_freevalstr (rtx, a0, str0);
}
a0 = qse_awk_rtx_makeintval (rtx, tmp);

View File

@ -6585,6 +6585,7 @@ int qse_awk_putsrcstrn (
#include "mod-dir.h"
#include "mod-str.h"
#include "mod-sys.h"
#include "mod-sed.h"
#if defined(HAVE_MPI)
# include "mod-mpi.h"
#endif
@ -6608,6 +6609,7 @@ static struct
#if defined(HAVE_MPI)
{ QSE_T("mpi"), qse_awk_mod_mpi },
#endif
{ QSE_T("sed"), qse_awk_mod_sed },
{ QSE_T("str"), qse_awk_mod_str },
{ QSE_T("sys"), qse_awk_mod_sys },
#if defined(HAVE_UCI)

View File

@ -21,9 +21,9 @@
#include "awk.h"
#include <qse/cmn/fmt.h>
#ifdef DEBUG_RUN
//#ifdef DEBUG_RUN
#include <qse/cmn/sio.h>
#endif
//#endif
#define PRINT_IOERR -99
@ -4965,49 +4965,26 @@ static qse_awk_val_t* eval_binop_match0 (
const qse_awk_loc_t* lloc, const qse_awk_loc_t* rloc, int ret)
{
qse_awk_val_t* res;
qse_xstr_t out;
int n;
if (left->type == QSE_AWK_VAL_STR)
{
n = qse_awk_rtx_matchrex (
rtx, right,
xstr_to_cstr(&((qse_awk_val_str_t*)left)->val),
xstr_to_cstr(&((qse_awk_val_str_t*)left)->val), QSE_NULL);
if (n <= -1)
{
ADJERR_LOC (rtx, lloc);
return QSE_NULL;
}
out.ptr = qse_awk_rtx_getvalstr (rtx, left, &out.len);
if (out.ptr == QSE_NULL) return QSE_NULL;
res = qse_awk_rtx_makeintval (rtx, (n == ret));
if (res == QSE_NULL)
{
ADJERR_LOC (rtx, lloc);
return QSE_NULL;
}
n = qse_awk_rtx_matchrex (rtx, right, &out, &out, QSE_NULL);
qse_awk_rtx_freevalstr (rtx, left, out.ptr);
if (n <= -1)
{
ADJERR_LOC (rtx, lloc);
return QSE_NULL;
}
else
res = qse_awk_rtx_makeintval (rtx, (n == ret));
if (res == QSE_NULL)
{
qse_xstr_t out;
out.ptr = qse_awk_rtx_valtostrdup (rtx, left, &out.len);
if (out.ptr == QSE_NULL) return QSE_NULL;
n = qse_awk_rtx_matchrex (rtx, right, &out, &out, QSE_NULL);
QSE_AWK_FREE (rtx->awk, out.ptr);
if (n <= -1)
{
ADJERR_LOC (rtx, lloc);
return QSE_NULL;
}
res = qse_awk_rtx_makeintval (rtx, (n == ret));
if (res == QSE_NULL)
{
ADJERR_LOC (rtx, lloc);
return QSE_NULL;
}
ADJERR_LOC (rtx, lloc);
return QSE_NULL;
}
return res;

View File

@ -1561,13 +1561,13 @@ static int open_rio_console (qse_awk_rtx_t* rtx, qse_awk_rio_arg_t* riod)
v = QSE_HTB_VPTR(pair);
QSE_ASSERT (v != QSE_NULL);
as.ptr = qse_awk_rtx_valtostrdup (rtx, v, &as.len);
as.ptr = qse_awk_rtx_getvalstr (rtx, v, &as.len);
if (as.ptr == QSE_NULL) return -1;
if (as.len == 0)
{
/* the name is empty */
qse_awk_rtx_freemem (rtx, as.ptr);
qse_awk_rtx_freevalstr (rtx, v, as.ptr);
rxtn->c.in.index++;
goto nextfile;
}
@ -1584,7 +1584,7 @@ static int open_rio_console (qse_awk_rtx_t* rtx, qse_awk_rio_arg_t* riod)
qse_awk_rtx_seterrnum (rtx, QSE_AWK_EIONMNL, &errarg);
qse_awk_rtx_freemem (rtx, as.ptr);
qse_awk_rtx_freevalstr (rtx, v, as.ptr);
return -1;
}
@ -1597,7 +1597,7 @@ static int open_rio_console (qse_awk_rtx_t* rtx, qse_awk_rio_arg_t* riod)
QSE_SIO_READ | QSE_SIO_IGNOREMBWCERR);
if (sio == QSE_NULL)
{
qse_awk_rtx_freemem (rtx, as.ptr);
qse_awk_rtx_freevalstr (rtx, v, as.ptr);
return -1;
}
@ -1607,11 +1607,11 @@ static int open_rio_console (qse_awk_rtx_t* rtx, qse_awk_rio_arg_t* riod)
rtx, file, qse_strlen(file)) <= -1)
{
qse_sio_close (sio);
qse_awk_rtx_freemem (rtx, as.ptr);
qse_awk_rtx_freevalstr (rtx, v, as.ptr);
return -1;
}
qse_awk_rtx_freemem (rtx, as.ptr);
qse_awk_rtx_freevalstr (rtx, v, as.ptr);
riod->handle = sio;
/* increment the counter of files successfully opened */
@ -2209,22 +2209,14 @@ static int fnc_srand (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi)
static int fnc_system (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi)
{
qse_awk_val_t* v;
qse_awk_val_t* v, * a0;
qse_char_t* str;
qse_size_t len;
int n = 0;
v = qse_awk_rtx_getarg (rtx, 0);
if (v->type == QSE_AWK_VAL_STR)
{
str = ((qse_awk_val_str_t*)v)->val.ptr;
len = ((qse_awk_val_str_t*)v)->val.len;
}
else
{
str = qse_awk_rtx_valtostrdup (rtx, v, &len);
if (str == QSE_NULL) return -1;
}
a0 = qse_awk_rtx_getarg (rtx, 0);
str = qse_awk_rtx_getvalstr (rtx, a0, &len);
if (str == QSE_NULL) return -1;
/* the target name contains a null character.
* make system return -1 */
@ -2255,7 +2247,7 @@ static int fnc_system (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi)
#endif
skip_system:
if (v->type != QSE_AWK_VAL_STR) QSE_AWK_FREE (rtx->awk, str);
qse_awk_rtx_freevalstr (rtx, a0, str);
v = qse_awk_rtx_makeintval (rtx, (qse_awk_int_t)n);
if (v == QSE_NULL) return -1;
@ -2333,19 +2325,11 @@ static int fnc_setioattr (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi)
for (i = 0; i < 3; i++)
{
v[i] = qse_awk_rtx_getarg (rtx, i);
if (v[i]->type == QSE_AWK_VAL_STR)
ptr[i] = qse_awk_rtx_getvalstr (rtx, v[i], &len[i]);
if (ptr[i] == QSE_NULL)
{
ptr[i] = ((qse_awk_val_str_t*)v[i])->val.ptr;
len[i] = ((qse_awk_val_str_t*)v[i])->val.len;
}
else
{
ptr[i] = qse_awk_rtx_valtostrdup (rtx, v[i], &len[i]);
if (ptr[i] == QSE_NULL)
{
ret = -1;
goto done;
}
ret = -1;
goto done;
}
if (qse_strxchr (ptr[i], len[i], QSE_T('\0')))
@ -2430,8 +2414,7 @@ done:
while (i > 0)
{
i--;
if (v[i]->type != QSE_AWK_VAL_STR)
QSE_AWK_FREE (rtx->awk, ptr[i]);
qse_awk_rtx_freevalstr (rtx, v[i], ptr[i]);
}
if (ret >= 0)
@ -2463,19 +2446,11 @@ static int fnc_getioattr (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi)
for (i = 0; i < 2; i++)
{
v[i] = qse_awk_rtx_getarg (rtx, i);
if (v[i]->type == QSE_AWK_VAL_STR)
ptr[i] = qse_awk_rtx_getvalstr (rtx, v[i], &len[i]);
if (ptr[i] == QSE_NULL)
{
ptr[i] = ((qse_awk_val_str_t*)v[i])->val.ptr;
len[i] = ((qse_awk_val_str_t*)v[i])->val.len;
}
else
{
ptr[i] = qse_awk_rtx_valtostrdup (rtx, v[i], &len[i]);
if (ptr[i] == QSE_NULL)
{
ret = -1;
goto done;
}
ret = -1;
goto done;
}
if (qse_strxchr (ptr[i], len[i], QSE_T('\0'))) goto done;
@ -2521,7 +2496,7 @@ done:
while (i > 0)
{
i--;
if (v[i]->type != QSE_AWK_VAL_STR) QSE_AWK_FREE (rtx->awk, ptr[i]);
qse_awk_rtx_freevalstr (rtx, v[i], ptr[i]);
}
if (ret >= 0)

View File

@ -1471,6 +1471,31 @@ qse_wchar_t* qse_awk_rtx_valtowcsdup (
#endif
}
qse_char_t* qse_awk_rtx_getvalstr (
qse_awk_rtx_t* rtx, const qse_awk_val_t* v, qse_size_t* len)
{
if (v->type == QSE_AWK_VAL_STR)
{
if (len) *len = ((qse_awk_val_str_t*)v)->val.len;
return ((qse_awk_val_str_t*)v)->val.ptr;
}
else
{
return qse_awk_rtx_valtostrdup (rtx, v, len);
}
}
void qse_awk_rtx_freevalstr (
qse_awk_rtx_t* rtx, const qse_awk_val_t* v, qse_char_t* str)
{
if (v->type != QSE_AWK_VAL_STR &&
str != ((qse_awk_val_str_t*)v)->val.ptr)
{
qse_awk_rtx_freemem (rtx, str);
}
}
static int val_ref_to_num (
qse_awk_rtx_t* rtx, const qse_awk_val_ref_t* ref, qse_awk_int_t* l, qse_awk_flt_t* r)
{

View File

@ -849,6 +849,18 @@ int qse_sed_compstdstr (qse_sed_t* sed, const qse_char_t* script)
return qse_sed_compstd (sed, in, QSE_NULL);
}
int qse_sed_compstdstrx (qse_sed_t* sed, const qse_char_t* script, qse_size_t script_len)
{
qse_sed_iostd_t in[2];
in[0].type = QSE_SED_IOSTD_STR;
in[0].u.str.ptr = (qse_char_t*)script;
in[0].u.str.len = script_len;
in[1].type = QSE_SED_IOSTD_NULL;
return qse_sed_compstd (sed, in, QSE_NULL);
}
int qse_sed_execstdfile (
qse_sed_t* sed, const qse_char_t* infile,
const qse_char_t* outfile, qse_cmgr_t* cmgr)