Reorganized the directory structure
This commit is contained in:
18
lib/sed/Makefile.am
Normal file
18
lib/sed/Makefile.am
Normal file
@ -0,0 +1,18 @@
|
||||
AUTOMAKE_OPTIONS = nostdinc
|
||||
|
||||
AM_CPPFLAGS = \
|
||||
-I$(top_builddir)/include \
|
||||
-I$(top_srcdir)/include
|
||||
|
||||
noinst_HEADERS = sed-prv.h
|
||||
|
||||
lib_LTLIBRARIES = libqsesed.la
|
||||
libqsesed_la_SOURCES = sed.c err.c std.c
|
||||
libqsesed_la_LDFLAGS = -L../cmn -L../si -version-info 1:0:0 -no-undefined
|
||||
libqsesed_la_LIBADD = -lqsecmn -lqsesi
|
||||
libqsesed_la_DEPENDENCIES = ../../lib/cmn/libqsecmn.la ../../lib/si/libqsesi.la
|
||||
|
||||
if ENABLE_CXX
|
||||
libqsesed_la_SOURCES += Sed.cpp StdSed.cpp
|
||||
endif
|
||||
|
761
lib/sed/Makefile.in
Normal file
761
lib/sed/Makefile.in
Normal file
@ -0,0 +1,761 @@
|
||||
# Makefile.in generated by automake 1.16.2 from Makefile.am.
|
||||
# @configure_input@
|
||||
|
||||
# Copyright (C) 1994-2020 Free Software Foundation, Inc.
|
||||
|
||||
# This Makefile.in is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
# with or without modifications, as long as this notice is preserved.
|
||||
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
|
||||
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
# PARTICULAR PURPOSE.
|
||||
|
||||
@SET_MAKE@
|
||||
|
||||
|
||||
VPATH = @srcdir@
|
||||
am__is_gnu_make = { \
|
||||
if test -z '$(MAKELEVEL)'; then \
|
||||
false; \
|
||||
elif test -n '$(MAKE_HOST)'; then \
|
||||
true; \
|
||||
elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
|
||||
true; \
|
||||
else \
|
||||
false; \
|
||||
fi; \
|
||||
}
|
||||
am__make_running_with_option = \
|
||||
case $${target_option-} in \
|
||||
?) ;; \
|
||||
*) echo "am__make_running_with_option: internal error: invalid" \
|
||||
"target option '$${target_option-}' specified" >&2; \
|
||||
exit 1;; \
|
||||
esac; \
|
||||
has_opt=no; \
|
||||
sane_makeflags=$$MAKEFLAGS; \
|
||||
if $(am__is_gnu_make); then \
|
||||
sane_makeflags=$$MFLAGS; \
|
||||
else \
|
||||
case $$MAKEFLAGS in \
|
||||
*\\[\ \ ]*) \
|
||||
bs=\\; \
|
||||
sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
|
||||
| sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \
|
||||
esac; \
|
||||
fi; \
|
||||
skip_next=no; \
|
||||
strip_trailopt () \
|
||||
{ \
|
||||
flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
|
||||
}; \
|
||||
for flg in $$sane_makeflags; do \
|
||||
test $$skip_next = yes && { skip_next=no; continue; }; \
|
||||
case $$flg in \
|
||||
*=*|--*) continue;; \
|
||||
-*I) strip_trailopt 'I'; skip_next=yes;; \
|
||||
-*I?*) strip_trailopt 'I';; \
|
||||
-*O) strip_trailopt 'O'; skip_next=yes;; \
|
||||
-*O?*) strip_trailopt 'O';; \
|
||||
-*l) strip_trailopt 'l'; skip_next=yes;; \
|
||||
-*l?*) strip_trailopt 'l';; \
|
||||
-[dEDm]) skip_next=yes;; \
|
||||
-[JT]) skip_next=yes;; \
|
||||
esac; \
|
||||
case $$flg in \
|
||||
*$$target_option*) has_opt=yes; break;; \
|
||||
esac; \
|
||||
done; \
|
||||
test $$has_opt = yes
|
||||
am__make_dryrun = (target_option=n; $(am__make_running_with_option))
|
||||
am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
|
||||
pkgdatadir = $(datadir)/@PACKAGE@
|
||||
pkgincludedir = $(includedir)/@PACKAGE@
|
||||
pkglibdir = $(libdir)/@PACKAGE@
|
||||
pkglibexecdir = $(libexecdir)/@PACKAGE@
|
||||
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
|
||||
install_sh_DATA = $(install_sh) -c -m 644
|
||||
install_sh_PROGRAM = $(install_sh) -c
|
||||
install_sh_SCRIPT = $(install_sh) -c
|
||||
INSTALL_HEADER = $(INSTALL_DATA)
|
||||
transform = $(program_transform_name)
|
||||
NORMAL_INSTALL = :
|
||||
PRE_INSTALL = :
|
||||
POST_INSTALL = :
|
||||
NORMAL_UNINSTALL = :
|
||||
PRE_UNINSTALL = :
|
||||
POST_UNINSTALL = :
|
||||
build_triplet = @build@
|
||||
host_triplet = @host@
|
||||
@ENABLE_CXX_TRUE@am__append_1 = Sed.cpp StdSed.cpp
|
||||
subdir = lib/sed
|
||||
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
|
||||
am__aclocal_m4_deps = $(top_srcdir)/m4/ax_check_sign.m4 \
|
||||
$(top_srcdir)/m4/ax_cxx_compile_stdcxx.m4 \
|
||||
$(top_srcdir)/m4/ax_cxx_namespace.m4 \
|
||||
$(top_srcdir)/m4/ax_lib_mysql.m4 $(top_srcdir)/m4/ax_numval.m4 \
|
||||
$(top_srcdir)/m4/ax_pthread.m4 $(top_srcdir)/m4/libtool.m4 \
|
||||
$(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
|
||||
$(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \
|
||||
$(top_srcdir)/m4/lx_find_mpi.m4 \
|
||||
$(top_srcdir)/m4/qse_try_cflags.m4 $(top_srcdir)/configure.ac
|
||||
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
|
||||
$(ACLOCAL_M4)
|
||||
DIST_COMMON = $(srcdir)/Makefile.am $(noinst_HEADERS) \
|
||||
$(am__DIST_COMMON)
|
||||
mkinstalldirs = $(install_sh) -d
|
||||
CONFIG_HEADER = $(top_builddir)/include/qse/config.h
|
||||
CONFIG_CLEAN_FILES =
|
||||
CONFIG_CLEAN_VPATH_FILES =
|
||||
am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
|
||||
am__vpath_adj = case $$p in \
|
||||
$(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
|
||||
*) f=$$p;; \
|
||||
esac;
|
||||
am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
|
||||
am__install_max = 40
|
||||
am__nobase_strip_setup = \
|
||||
srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
|
||||
am__nobase_strip = \
|
||||
for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
|
||||
am__nobase_list = $(am__nobase_strip_setup); \
|
||||
for p in $$list; do echo "$$p $$p"; done | \
|
||||
sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
|
||||
$(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
|
||||
if (++n[$$2] == $(am__install_max)) \
|
||||
{ print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
|
||||
END { for (dir in files) print dir, files[dir] }'
|
||||
am__base_list = \
|
||||
sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
|
||||
sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
|
||||
am__uninstall_files_from_dir = { \
|
||||
test -z "$$files" \
|
||||
|| { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \
|
||||
|| { echo " ( cd '$$dir' && rm -f" $$files ")"; \
|
||||
$(am__cd) "$$dir" && rm -f $$files; }; \
|
||||
}
|
||||
am__installdirs = "$(DESTDIR)$(libdir)"
|
||||
LTLIBRARIES = $(lib_LTLIBRARIES)
|
||||
am__libqsesed_la_SOURCES_DIST = sed.c err.c std.c Sed.cpp StdSed.cpp
|
||||
@ENABLE_CXX_TRUE@am__objects_1 = Sed.lo StdSed.lo
|
||||
am_libqsesed_la_OBJECTS = sed.lo err.lo std.lo $(am__objects_1)
|
||||
libqsesed_la_OBJECTS = $(am_libqsesed_la_OBJECTS)
|
||||
AM_V_lt = $(am__v_lt_@AM_V@)
|
||||
am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
|
||||
am__v_lt_0 = --silent
|
||||
am__v_lt_1 =
|
||||
libqsesed_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
|
||||
$(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \
|
||||
$(CXXFLAGS) $(libqsesed_la_LDFLAGS) $(LDFLAGS) -o $@
|
||||
AM_V_P = $(am__v_P_@AM_V@)
|
||||
am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
|
||||
am__v_P_0 = false
|
||||
am__v_P_1 = :
|
||||
AM_V_GEN = $(am__v_GEN_@AM_V@)
|
||||
am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
|
||||
am__v_GEN_0 = @echo " GEN " $@;
|
||||
am__v_GEN_1 =
|
||||
AM_V_at = $(am__v_at_@AM_V@)
|
||||
am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
|
||||
am__v_at_0 = @
|
||||
am__v_at_1 =
|
||||
DEFAULT_INCLUDES =
|
||||
depcomp = $(SHELL) $(top_srcdir)/ac/depcomp
|
||||
am__maybe_remake_depfiles = depfiles
|
||||
am__depfiles_remade = ./$(DEPDIR)/Sed.Plo ./$(DEPDIR)/StdSed.Plo \
|
||||
./$(DEPDIR)/err.Plo ./$(DEPDIR)/sed.Plo ./$(DEPDIR)/std.Plo
|
||||
am__mv = mv -f
|
||||
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
|
||||
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
|
||||
LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
|
||||
$(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \
|
||||
$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
|
||||
$(AM_CFLAGS) $(CFLAGS)
|
||||
AM_V_CC = $(am__v_CC_@AM_V@)
|
||||
am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@)
|
||||
am__v_CC_0 = @echo " CC " $@;
|
||||
am__v_CC_1 =
|
||||
CCLD = $(CC)
|
||||
LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
|
||||
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
|
||||
$(AM_LDFLAGS) $(LDFLAGS) -o $@
|
||||
AM_V_CCLD = $(am__v_CCLD_@AM_V@)
|
||||
am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
|
||||
am__v_CCLD_0 = @echo " CCLD " $@;
|
||||
am__v_CCLD_1 =
|
||||
CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
|
||||
$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
|
||||
LTCXXCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
|
||||
$(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \
|
||||
$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
|
||||
$(AM_CXXFLAGS) $(CXXFLAGS)
|
||||
AM_V_CXX = $(am__v_CXX_@AM_V@)
|
||||
am__v_CXX_ = $(am__v_CXX_@AM_DEFAULT_V@)
|
||||
am__v_CXX_0 = @echo " CXX " $@;
|
||||
am__v_CXX_1 =
|
||||
CXXLD = $(CXX)
|
||||
CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
|
||||
$(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \
|
||||
$(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
|
||||
AM_V_CXXLD = $(am__v_CXXLD_@AM_V@)
|
||||
am__v_CXXLD_ = $(am__v_CXXLD_@AM_DEFAULT_V@)
|
||||
am__v_CXXLD_0 = @echo " CXXLD " $@;
|
||||
am__v_CXXLD_1 =
|
||||
SOURCES = $(libqsesed_la_SOURCES)
|
||||
DIST_SOURCES = $(am__libqsesed_la_SOURCES_DIST)
|
||||
am__can_run_installinfo = \
|
||||
case $$AM_UPDATE_INFO_DIR in \
|
||||
n|no|NO) false;; \
|
||||
*) (install-info --version) >/dev/null 2>&1;; \
|
||||
esac
|
||||
HEADERS = $(noinst_HEADERS)
|
||||
am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
|
||||
# Read a list of newline-separated strings from the standard input,
|
||||
# and print each of them once, without duplicates. Input order is
|
||||
# *not* preserved.
|
||||
am__uniquify_input = $(AWK) '\
|
||||
BEGIN { nonempty = 0; } \
|
||||
{ items[$$0] = 1; nonempty = 1; } \
|
||||
END { if (nonempty) { for (i in items) print i; }; } \
|
||||
'
|
||||
# Make sure the list of sources is unique. This is necessary because,
|
||||
# e.g., the same source file might be shared among _SOURCES variables
|
||||
# for different programs/libraries.
|
||||
am__define_uniq_tagged_files = \
|
||||
list='$(am__tagged_files)'; \
|
||||
unique=`for i in $$list; do \
|
||||
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
|
||||
done | $(am__uniquify_input)`
|
||||
ETAGS = etags
|
||||
CTAGS = ctags
|
||||
am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/ac/depcomp
|
||||
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
|
||||
ACLOCAL = @ACLOCAL@
|
||||
AMTAR = @AMTAR@
|
||||
AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
|
||||
AR = @AR@
|
||||
AUTOCONF = @AUTOCONF@
|
||||
AUTOHEADER = @AUTOHEADER@
|
||||
AUTOMAKE = @AUTOMAKE@
|
||||
AWK = @AWK@
|
||||
BUILD_MODE = @BUILD_MODE@
|
||||
CC = @CC@
|
||||
CCDEPMODE = @CCDEPMODE@
|
||||
CFLAGS = @CFLAGS@
|
||||
CPP = @CPP@
|
||||
CPPFLAGS = @CPPFLAGS@
|
||||
CXX = @CXX@
|
||||
CXXCPP = @CXXCPP@
|
||||
CXXDEPMODE = @CXXDEPMODE@
|
||||
CXXFLAGS = @CXXFLAGS@
|
||||
CYGPATH_W = @CYGPATH_W@
|
||||
DEFS = @DEFS@
|
||||
DEPDIR = @DEPDIR@
|
||||
DLLTOOL = @DLLTOOL@
|
||||
DL_LIBS = @DL_LIBS@
|
||||
DSYMUTIL = @DSYMUTIL@
|
||||
DUMPBIN = @DUMPBIN@
|
||||
ECHO = @ECHO@
|
||||
ECHO_C = @ECHO_C@
|
||||
ECHO_N = @ECHO_N@
|
||||
ECHO_T = @ECHO_T@
|
||||
EGREP = @EGREP@
|
||||
EXEEXT = @EXEEXT@
|
||||
FGREP = @FGREP@
|
||||
GREP = @GREP@
|
||||
HAVE_CXX = @HAVE_CXX@
|
||||
HAVE_CXX11 = @HAVE_CXX11@
|
||||
INSTALL = @INSTALL@
|
||||
INSTALL_DATA = @INSTALL_DATA@
|
||||
INSTALL_PROGRAM = @INSTALL_PROGRAM@
|
||||
INSTALL_SCRIPT = @INSTALL_SCRIPT@
|
||||
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
|
||||
LD = @LD@
|
||||
LDFLAGS = @LDFLAGS@
|
||||
LIBM = @LIBM@
|
||||
LIBOBJS = @LIBOBJS@
|
||||
LIBS = @LIBS@
|
||||
LIBTOOL = @LIBTOOL@
|
||||
LIBTOOL_DEPS = @LIBTOOL_DEPS@
|
||||
LIPO = @LIPO@
|
||||
LN_S = @LN_S@
|
||||
LTDL_LIBS = @LTDL_LIBS@
|
||||
LTLIBOBJS = @LTLIBOBJS@
|
||||
LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
|
||||
MAKEINFO = @MAKEINFO@
|
||||
MANIFEST_TOOL = @MANIFEST_TOOL@
|
||||
MKDIR_P = @MKDIR_P@
|
||||
MPICC = @MPICC@
|
||||
MPI_CFLAGS = @MPI_CFLAGS@
|
||||
MPI_CLDFLAGS = @MPI_CLDFLAGS@
|
||||
MYSQL_CFLAGS = @MYSQL_CFLAGS@
|
||||
MYSQL_CONFIG = @MYSQL_CONFIG@
|
||||
MYSQL_LDFLAGS = @MYSQL_LDFLAGS@
|
||||
MYSQL_LIBS = @MYSQL_LIBS@
|
||||
MYSQL_VERSION = @MYSQL_VERSION@
|
||||
NM = @NM@
|
||||
NMEDIT = @NMEDIT@
|
||||
OBJDUMP = @OBJDUMP@
|
||||
OBJEXT = @OBJEXT@
|
||||
OTOOL = @OTOOL@
|
||||
OTOOL64 = @OTOOL64@
|
||||
PACKAGE = @PACKAGE@
|
||||
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
|
||||
PACKAGE_NAME = @PACKAGE_NAME@
|
||||
PACKAGE_STRING = @PACKAGE_STRING@
|
||||
PACKAGE_TARNAME = @PACKAGE_TARNAME@
|
||||
PACKAGE_URL = @PACKAGE_URL@
|
||||
PACKAGE_VERSION = @PACKAGE_VERSION@
|
||||
PACKAGE_VERSION_MAJOR = @PACKAGE_VERSION_MAJOR@
|
||||
PACKAGE_VERSION_MINOR = @PACKAGE_VERSION_MINOR@
|
||||
PACKAGE_VERSION_PATCH = @PACKAGE_VERSION_PATCH@
|
||||
PATH_SEPARATOR = @PATH_SEPARATOR@
|
||||
PTHREAD_CC = @PTHREAD_CC@
|
||||
PTHREAD_CFLAGS = @PTHREAD_CFLAGS@
|
||||
PTHREAD_LIBS = @PTHREAD_LIBS@
|
||||
QSE_PROJECT_AUTHOR = @QSE_PROJECT_AUTHOR@
|
||||
QSE_PROJECT_URL = @QSE_PROJECT_URL@
|
||||
QUADMATH_LIBS = @QUADMATH_LIBS@
|
||||
RANLIB = @RANLIB@
|
||||
RM = @RM@
|
||||
RMDIR = @RMDIR@
|
||||
SED = @SED@
|
||||
SENDFILE_LIBS = @SENDFILE_LIBS@
|
||||
SET_MAKE = @SET_MAKE@
|
||||
SHELL = @SHELL@
|
||||
SOCKET_LIBS = @SOCKET_LIBS@
|
||||
SSL_LIBS = @SSL_LIBS@
|
||||
STRIP = @STRIP@
|
||||
TRUE = @TRUE@
|
||||
UCI_LIBS = @UCI_LIBS@
|
||||
UNICOWS_LIBS = @UNICOWS_LIBS@
|
||||
VERSION = @VERSION@
|
||||
abs_builddir = @abs_builddir@
|
||||
abs_srcdir = @abs_srcdir@
|
||||
abs_top_builddir = @abs_top_builddir@
|
||||
abs_top_srcdir = @abs_top_srcdir@
|
||||
ac_ct_AR = @ac_ct_AR@
|
||||
ac_ct_CC = @ac_ct_CC@
|
||||
ac_ct_CXX = @ac_ct_CXX@
|
||||
ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
|
||||
am__include = @am__include@
|
||||
am__leading_dot = @am__leading_dot@
|
||||
am__quote = @am__quote@
|
||||
am__tar = @am__tar@
|
||||
am__untar = @am__untar@
|
||||
ax_pthread_config = @ax_pthread_config@
|
||||
bindir = @bindir@
|
||||
build = @build@
|
||||
build_alias = @build_alias@
|
||||
build_cpu = @build_cpu@
|
||||
build_os = @build_os@
|
||||
build_vendor = @build_vendor@
|
||||
builddir = @builddir@
|
||||
datadir = @datadir@
|
||||
datarootdir = @datarootdir@
|
||||
docdir = @docdir@
|
||||
dvidir = @dvidir@
|
||||
exec_prefix = @exec_prefix@
|
||||
host = @host@
|
||||
host_alias = @host_alias@
|
||||
host_cpu = @host_cpu@
|
||||
host_os = @host_os@
|
||||
host_vendor = @host_vendor@
|
||||
htmldir = @htmldir@
|
||||
includedir = @includedir@
|
||||
infodir = @infodir@
|
||||
install_sh = @install_sh@
|
||||
libdir = @libdir@
|
||||
libexecdir = @libexecdir@
|
||||
localedir = @localedir@
|
||||
localstatedir = @localstatedir@
|
||||
mandir = @mandir@
|
||||
mkdir_p = @mkdir_p@
|
||||
oldincludedir = @oldincludedir@
|
||||
pdfdir = @pdfdir@
|
||||
prefix = @prefix@
|
||||
program_transform_name = @program_transform_name@
|
||||
psdir = @psdir@
|
||||
runstatedir = @runstatedir@
|
||||
sbindir = @sbindir@
|
||||
sharedstatedir = @sharedstatedir@
|
||||
srcdir = @srcdir@
|
||||
sysconfdir = @sysconfdir@
|
||||
target_alias = @target_alias@
|
||||
top_build_prefix = @top_build_prefix@
|
||||
top_builddir = @top_builddir@
|
||||
top_srcdir = @top_srcdir@
|
||||
AUTOMAKE_OPTIONS = nostdinc
|
||||
AM_CPPFLAGS = \
|
||||
-I$(top_builddir)/include \
|
||||
-I$(top_srcdir)/include
|
||||
|
||||
noinst_HEADERS = sed-prv.h
|
||||
lib_LTLIBRARIES = libqsesed.la
|
||||
libqsesed_la_SOURCES = sed.c err.c std.c $(am__append_1)
|
||||
libqsesed_la_LDFLAGS = -L../cmn -L../si -version-info 1:0:0 -no-undefined
|
||||
libqsesed_la_LIBADD = -lqsecmn -lqsesi
|
||||
libqsesed_la_DEPENDENCIES = ../../lib/cmn/libqsecmn.la ../../lib/si/libqsesi.la
|
||||
all: all-am
|
||||
|
||||
.SUFFIXES:
|
||||
.SUFFIXES: .c .cpp .lo .o .obj
|
||||
$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
|
||||
@for dep in $?; do \
|
||||
case '$(am__configure_deps)' in \
|
||||
*$$dep*) \
|
||||
( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
|
||||
&& { if test -f $@; then exit 0; else break; fi; }; \
|
||||
exit 1;; \
|
||||
esac; \
|
||||
done; \
|
||||
echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign lib/sed/Makefile'; \
|
||||
$(am__cd) $(top_srcdir) && \
|
||||
$(AUTOMAKE) --foreign lib/sed/Makefile
|
||||
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
|
||||
@case '$?' in \
|
||||
*config.status*) \
|
||||
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
|
||||
*) \
|
||||
echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \
|
||||
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \
|
||||
esac;
|
||||
|
||||
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
|
||||
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
|
||||
|
||||
$(top_srcdir)/configure: $(am__configure_deps)
|
||||
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
|
||||
$(ACLOCAL_M4): $(am__aclocal_m4_deps)
|
||||
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
|
||||
$(am__aclocal_m4_deps):
|
||||
|
||||
install-libLTLIBRARIES: $(lib_LTLIBRARIES)
|
||||
@$(NORMAL_INSTALL)
|
||||
@list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \
|
||||
list2=; for p in $$list; do \
|
||||
if test -f $$p; then \
|
||||
list2="$$list2 $$p"; \
|
||||
else :; fi; \
|
||||
done; \
|
||||
test -z "$$list2" || { \
|
||||
echo " $(MKDIR_P) '$(DESTDIR)$(libdir)'"; \
|
||||
$(MKDIR_P) "$(DESTDIR)$(libdir)" || exit 1; \
|
||||
echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(libdir)'"; \
|
||||
$(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(libdir)"; \
|
||||
}
|
||||
|
||||
uninstall-libLTLIBRARIES:
|
||||
@$(NORMAL_UNINSTALL)
|
||||
@list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \
|
||||
for p in $$list; do \
|
||||
$(am__strip_dir) \
|
||||
echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(libdir)/$$f'"; \
|
||||
$(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(libdir)/$$f"; \
|
||||
done
|
||||
|
||||
clean-libLTLIBRARIES:
|
||||
-test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES)
|
||||
@list='$(lib_LTLIBRARIES)'; \
|
||||
locs=`for p in $$list; do echo $$p; done | \
|
||||
sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \
|
||||
sort -u`; \
|
||||
test -z "$$locs" || { \
|
||||
echo rm -f $${locs}; \
|
||||
rm -f $${locs}; \
|
||||
}
|
||||
|
||||
libqsesed.la: $(libqsesed_la_OBJECTS) $(libqsesed_la_DEPENDENCIES) $(EXTRA_libqsesed_la_DEPENDENCIES)
|
||||
$(AM_V_CXXLD)$(libqsesed_la_LINK) -rpath $(libdir) $(libqsesed_la_OBJECTS) $(libqsesed_la_LIBADD) $(LIBS)
|
||||
|
||||
mostlyclean-compile:
|
||||
-rm -f *.$(OBJEXT)
|
||||
|
||||
distclean-compile:
|
||||
-rm -f *.tab.c
|
||||
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Sed.Plo@am__quote@ # am--include-marker
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/StdSed.Plo@am__quote@ # am--include-marker
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/err.Plo@am__quote@ # am--include-marker
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sed.Plo@am__quote@ # am--include-marker
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/std.Plo@am__quote@ # am--include-marker
|
||||
|
||||
$(am__depfiles_remade):
|
||||
@$(MKDIR_P) $(@D)
|
||||
@echo '# dummy' >$@-t && $(am__mv) $@-t $@
|
||||
|
||||
am--depfiles: $(am__depfiles_remade)
|
||||
|
||||
.c.o:
|
||||
@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
|
||||
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $<
|
||||
|
||||
.c.obj:
|
||||
@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
|
||||
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
|
||||
|
||||
.c.lo:
|
||||
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
|
||||
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $<
|
||||
|
||||
.cpp.o:
|
||||
@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
|
||||
@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
|
||||
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ $<
|
||||
|
||||
.cpp.obj:
|
||||
@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
|
||||
@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
|
||||
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
|
||||
|
||||
.cpp.lo:
|
||||
@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
|
||||
@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
|
||||
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LTCXXCOMPILE) -c -o $@ $<
|
||||
|
||||
mostlyclean-libtool:
|
||||
-rm -f *.lo
|
||||
|
||||
clean-libtool:
|
||||
-rm -rf .libs _libs
|
||||
|
||||
ID: $(am__tagged_files)
|
||||
$(am__define_uniq_tagged_files); mkid -fID $$unique
|
||||
tags: tags-am
|
||||
TAGS: tags
|
||||
|
||||
tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
|
||||
set x; \
|
||||
here=`pwd`; \
|
||||
$(am__define_uniq_tagged_files); \
|
||||
shift; \
|
||||
if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
|
||||
test -n "$$unique" || unique=$$empty_fix; \
|
||||
if test $$# -gt 0; then \
|
||||
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
|
||||
"$$@" $$unique; \
|
||||
else \
|
||||
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
|
||||
$$unique; \
|
||||
fi; \
|
||||
fi
|
||||
ctags: ctags-am
|
||||
|
||||
CTAGS: ctags
|
||||
ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
|
||||
$(am__define_uniq_tagged_files); \
|
||||
test -z "$(CTAGS_ARGS)$$unique" \
|
||||
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
|
||||
$$unique
|
||||
|
||||
GTAGS:
|
||||
here=`$(am__cd) $(top_builddir) && pwd` \
|
||||
&& $(am__cd) $(top_srcdir) \
|
||||
&& gtags -i $(GTAGS_ARGS) "$$here"
|
||||
cscopelist: cscopelist-am
|
||||
|
||||
cscopelist-am: $(am__tagged_files)
|
||||
list='$(am__tagged_files)'; \
|
||||
case "$(srcdir)" in \
|
||||
[\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
|
||||
*) sdir=$(subdir)/$(srcdir) ;; \
|
||||
esac; \
|
||||
for i in $$list; do \
|
||||
if test -f "$$i"; then \
|
||||
echo "$(subdir)/$$i"; \
|
||||
else \
|
||||
echo "$$sdir/$$i"; \
|
||||
fi; \
|
||||
done >> $(top_builddir)/cscope.files
|
||||
|
||||
distclean-tags:
|
||||
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
|
||||
|
||||
distdir: $(BUILT_SOURCES)
|
||||
$(MAKE) $(AM_MAKEFLAGS) distdir-am
|
||||
|
||||
distdir-am: $(DISTFILES)
|
||||
@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
|
||||
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
|
||||
list='$(DISTFILES)'; \
|
||||
dist_files=`for file in $$list; do echo $$file; done | \
|
||||
sed -e "s|^$$srcdirstrip/||;t" \
|
||||
-e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
|
||||
case $$dist_files in \
|
||||
*/*) $(MKDIR_P) `echo "$$dist_files" | \
|
||||
sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
|
||||
sort -u` ;; \
|
||||
esac; \
|
||||
for file in $$dist_files; do \
|
||||
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
|
||||
if test -d $$d/$$file; then \
|
||||
dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
|
||||
if test -d "$(distdir)/$$file"; then \
|
||||
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
|
||||
fi; \
|
||||
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
|
||||
cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
|
||||
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
|
||||
fi; \
|
||||
cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
|
||||
else \
|
||||
test -f "$(distdir)/$$file" \
|
||||
|| cp -p $$d/$$file "$(distdir)/$$file" \
|
||||
|| exit 1; \
|
||||
fi; \
|
||||
done
|
||||
check-am: all-am
|
||||
check: check-am
|
||||
all-am: Makefile $(LTLIBRARIES) $(HEADERS)
|
||||
installdirs:
|
||||
for dir in "$(DESTDIR)$(libdir)"; do \
|
||||
test -z "$$dir" || $(MKDIR_P) "$$dir"; \
|
||||
done
|
||||
install: install-am
|
||||
install-exec: install-exec-am
|
||||
install-data: install-data-am
|
||||
uninstall: uninstall-am
|
||||
|
||||
install-am: all-am
|
||||
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
|
||||
|
||||
installcheck: installcheck-am
|
||||
install-strip:
|
||||
if test -z '$(STRIP)'; then \
|
||||
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
|
||||
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
|
||||
install; \
|
||||
else \
|
||||
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
|
||||
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
|
||||
"INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
|
||||
fi
|
||||
mostlyclean-generic:
|
||||
|
||||
clean-generic:
|
||||
|
||||
distclean-generic:
|
||||
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
|
||||
-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
|
||||
|
||||
maintainer-clean-generic:
|
||||
@echo "This command is intended for maintainers to use"
|
||||
@echo "it deletes files that may require special tools to rebuild."
|
||||
clean: clean-am
|
||||
|
||||
clean-am: clean-generic clean-libLTLIBRARIES clean-libtool \
|
||||
mostlyclean-am
|
||||
|
||||
distclean: distclean-am
|
||||
-rm -f ./$(DEPDIR)/Sed.Plo
|
||||
-rm -f ./$(DEPDIR)/StdSed.Plo
|
||||
-rm -f ./$(DEPDIR)/err.Plo
|
||||
-rm -f ./$(DEPDIR)/sed.Plo
|
||||
-rm -f ./$(DEPDIR)/std.Plo
|
||||
-rm -f Makefile
|
||||
distclean-am: clean-am distclean-compile distclean-generic \
|
||||
distclean-tags
|
||||
|
||||
dvi: dvi-am
|
||||
|
||||
dvi-am:
|
||||
|
||||
html: html-am
|
||||
|
||||
html-am:
|
||||
|
||||
info: info-am
|
||||
|
||||
info-am:
|
||||
|
||||
install-data-am:
|
||||
|
||||
install-dvi: install-dvi-am
|
||||
|
||||
install-dvi-am:
|
||||
|
||||
install-exec-am: install-libLTLIBRARIES
|
||||
|
||||
install-html: install-html-am
|
||||
|
||||
install-html-am:
|
||||
|
||||
install-info: install-info-am
|
||||
|
||||
install-info-am:
|
||||
|
||||
install-man:
|
||||
|
||||
install-pdf: install-pdf-am
|
||||
|
||||
install-pdf-am:
|
||||
|
||||
install-ps: install-ps-am
|
||||
|
||||
install-ps-am:
|
||||
|
||||
installcheck-am:
|
||||
|
||||
maintainer-clean: maintainer-clean-am
|
||||
-rm -f ./$(DEPDIR)/Sed.Plo
|
||||
-rm -f ./$(DEPDIR)/StdSed.Plo
|
||||
-rm -f ./$(DEPDIR)/err.Plo
|
||||
-rm -f ./$(DEPDIR)/sed.Plo
|
||||
-rm -f ./$(DEPDIR)/std.Plo
|
||||
-rm -f Makefile
|
||||
maintainer-clean-am: distclean-am maintainer-clean-generic
|
||||
|
||||
mostlyclean: mostlyclean-am
|
||||
|
||||
mostlyclean-am: mostlyclean-compile mostlyclean-generic \
|
||||
mostlyclean-libtool
|
||||
|
||||
pdf: pdf-am
|
||||
|
||||
pdf-am:
|
||||
|
||||
ps: ps-am
|
||||
|
||||
ps-am:
|
||||
|
||||
uninstall-am: uninstall-libLTLIBRARIES
|
||||
|
||||
.MAKE: install-am install-strip
|
||||
|
||||
.PHONY: CTAGS GTAGS TAGS all all-am am--depfiles check check-am clean \
|
||||
clean-generic clean-libLTLIBRARIES clean-libtool cscopelist-am \
|
||||
ctags ctags-am distclean distclean-compile distclean-generic \
|
||||
distclean-libtool distclean-tags distdir dvi dvi-am html \
|
||||
html-am info info-am install install-am install-data \
|
||||
install-data-am install-dvi install-dvi-am install-exec \
|
||||
install-exec-am install-html install-html-am install-info \
|
||||
install-info-am install-libLTLIBRARIES install-man install-pdf \
|
||||
install-pdf-am install-ps install-ps-am install-strip \
|
||||
installcheck installcheck-am installdirs maintainer-clean \
|
||||
maintainer-clean-generic mostlyclean mostlyclean-compile \
|
||||
mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
|
||||
tags tags-am uninstall uninstall-am uninstall-libLTLIBRARIES
|
||||
|
||||
.PRECIOUS: Makefile
|
||||
|
||||
|
||||
# Tell versions [3.59,3.63) of GNU make to not export all variables.
|
||||
# Otherwise a system limit (for SysV at least) may be exceeded.
|
||||
.NOEXPORT:
|
269
lib/sed/Sed.cpp
Normal file
269
lib/sed/Sed.cpp
Normal file
@ -0,0 +1,269 @@
|
||||
/*
|
||||
* $Id$
|
||||
*
|
||||
Copyright (c) 2006-2019 Chung, Hyung-Hwan. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR
|
||||
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <qse/sed/Sed.hpp>
|
||||
#include <qse/si/sio.h>
|
||||
#include "../cmn/mem-prv.h"
|
||||
#include "sed-prv.h"
|
||||
|
||||
/////////////////////////////////
|
||||
QSE_BEGIN_NAMESPACE(QSE)
|
||||
/////////////////////////////////
|
||||
|
||||
struct xtn_t
|
||||
{
|
||||
Sed* sed;
|
||||
};
|
||||
|
||||
#if defined(QSE_HAVE_INLINE)
|
||||
static QSE_INLINE xtn_t* GET_XTN(qse_sed_t* sed) { return (xtn_t*)((qse_uint8_t*)qse_sed_getxtn(sed) - QSE_SIZEOF(xtn_t)); }
|
||||
#else
|
||||
#define GET_XTN(sed) ((xtn_t*)((qse_uint8_t*)qse_sed_getxtn(sed) - QSE_SIZEOF(xtn_t)))
|
||||
#endif
|
||||
|
||||
int Sed::open ()
|
||||
{
|
||||
qse_sed_errnum_t errnum;
|
||||
this->sed = qse_sed_open(this->getMmgr(), QSE_SIZEOF(xtn_t), &errnum);
|
||||
if (!this->sed)
|
||||
{
|
||||
this->setError (errnum);
|
||||
return -1;
|
||||
}
|
||||
|
||||
this->sed->_instsize += QSE_SIZEOF(xtn_t);
|
||||
|
||||
xtn_t* xtn = GET_XTN(this->sed);
|
||||
xtn->sed = this;
|
||||
|
||||
dflerrstr = qse_sed_geterrstr(this->sed);
|
||||
qse_sed_seterrstr (sed, xerrstr);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Sed::close ()
|
||||
{
|
||||
if (sed)
|
||||
{
|
||||
qse_sed_close (sed);
|
||||
sed = QSE_NULL;
|
||||
}
|
||||
}
|
||||
|
||||
int Sed::compile (Stream& sstream)
|
||||
{
|
||||
QSE_ASSERT (sed != QSE_NULL);
|
||||
|
||||
this->sstream = &sstream;
|
||||
return qse_sed_comp (sed, sin);
|
||||
}
|
||||
|
||||
int Sed::execute (Stream& iostream)
|
||||
{
|
||||
QSE_ASSERT (sed != QSE_NULL);
|
||||
|
||||
this->iostream = &iostream;
|
||||
return qse_sed_exec (sed, xin, xout);
|
||||
}
|
||||
|
||||
void Sed::halt ()
|
||||
{
|
||||
QSE_ASSERT (sed != QSE_NULL);
|
||||
qse_sed_halt (sed);
|
||||
}
|
||||
|
||||
bool Sed::isHalt () const
|
||||
{
|
||||
QSE_ASSERT (sed != QSE_NULL);
|
||||
return qse_sed_ishalt (sed);
|
||||
}
|
||||
|
||||
int Sed::getTrait () const
|
||||
{
|
||||
QSE_ASSERT (sed != QSE_NULL);
|
||||
int val;
|
||||
qse_sed_getopt (sed, QSE_SED_TRAIT, &val);
|
||||
return val;
|
||||
}
|
||||
|
||||
void Sed::setTrait (int trait)
|
||||
{
|
||||
QSE_ASSERT (sed != QSE_NULL);
|
||||
qse_sed_setopt (sed, QSE_SED_TRAIT, &trait);
|
||||
}
|
||||
|
||||
const Sed::char_t* Sed::getErrorMessage () const
|
||||
{
|
||||
return (sed == QSE_NULL)? QSE_T(""): qse_sed_geterrmsg (sed);
|
||||
}
|
||||
|
||||
Sed::loc_t Sed::getErrorLocation () const
|
||||
{
|
||||
if (sed == QSE_NULL)
|
||||
{
|
||||
loc_t loc;
|
||||
loc.line = 0;
|
||||
loc.colm = 0;
|
||||
return loc;
|
||||
}
|
||||
return *qse_sed_geterrloc (sed);
|
||||
}
|
||||
|
||||
Sed::errnum_t Sed::getErrorNumber () const
|
||||
{
|
||||
return (sed == QSE_NULL)? QSE_SED_ENOERR: qse_sed_geterrnum (sed);
|
||||
}
|
||||
|
||||
void Sed::setError (errnum_t err, const cstr_t* args, const loc_t* loc)
|
||||
{
|
||||
QSE_ASSERT (sed != QSE_NULL);
|
||||
qse_sed_seterror (sed, err, args, loc);
|
||||
}
|
||||
|
||||
const Sed::char_t* Sed::getCompileId () const
|
||||
{
|
||||
return qse_sed_getcompid (this->sed);
|
||||
}
|
||||
|
||||
const Sed::char_t* Sed::setCompileId (const char_t* id)
|
||||
{
|
||||
return qse_sed_setcompid (this->sed, id);
|
||||
}
|
||||
|
||||
Sed::size_t Sed::getConsoleLine ()
|
||||
{
|
||||
QSE_ASSERT (sed != QSE_NULL);
|
||||
return qse_sed_getlinenum (this->sed);
|
||||
}
|
||||
|
||||
void Sed::setConsoleLine (size_t num)
|
||||
{
|
||||
QSE_ASSERT (sed != QSE_NULL);
|
||||
qse_sed_setlinenum (this->sed, num);
|
||||
}
|
||||
|
||||
Sed::ssize_t Sed::sin (sed_t* s, io_cmd_t cmd, io_arg_t* arg, char_t* buf, size_t len)
|
||||
{
|
||||
xtn_t* xtn = GET_XTN(s);
|
||||
|
||||
Stream::Data iodata (xtn->sed, Stream::READ, arg);
|
||||
|
||||
try
|
||||
{
|
||||
switch (cmd)
|
||||
{
|
||||
case QSE_SED_IO_OPEN:
|
||||
return xtn->sed->sstream->open (iodata);
|
||||
case QSE_SED_IO_CLOSE:
|
||||
return xtn->sed->sstream->close (iodata);
|
||||
case QSE_SED_IO_READ:
|
||||
return xtn->sed->sstream->read (iodata, buf, len);
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
Sed::ssize_t Sed::xin (sed_t* s, io_cmd_t cmd, io_arg_t* arg, char_t* buf, size_t len)
|
||||
{
|
||||
xtn_t* xtn = GET_XTN(s);
|
||||
|
||||
Stream::Data iodata (xtn->sed, Stream::READ, arg);
|
||||
|
||||
try
|
||||
{
|
||||
switch (cmd)
|
||||
{
|
||||
case QSE_SED_IO_OPEN:
|
||||
return xtn->sed->iostream->open (iodata);
|
||||
case QSE_SED_IO_CLOSE:
|
||||
return xtn->sed->iostream->close (iodata);
|
||||
case QSE_SED_IO_READ:
|
||||
return xtn->sed->iostream->read (iodata, buf, len);
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
Sed::ssize_t Sed::xout (sed_t* s, io_cmd_t cmd, io_arg_t* arg, char_t* dat, size_t len)
|
||||
{
|
||||
xtn_t* xtn = GET_XTN(s);
|
||||
|
||||
Stream::Data iodata (xtn->sed, Stream::WRITE, arg);
|
||||
|
||||
try
|
||||
{
|
||||
switch (cmd)
|
||||
{
|
||||
case QSE_SED_IO_OPEN:
|
||||
return xtn->sed->iostream->open (iodata);
|
||||
case QSE_SED_IO_CLOSE:
|
||||
return xtn->sed->iostream->close (iodata);
|
||||
case QSE_SED_IO_WRITE:
|
||||
return xtn->sed->iostream->write (iodata, dat, len);
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
const Sed::char_t* Sed::getErrorString (errnum_t num) const
|
||||
{
|
||||
QSE_ASSERT (this->dflerrstr != QSE_NULL);
|
||||
return this->dflerrstr (sed, num);
|
||||
}
|
||||
|
||||
const Sed::char_t* Sed::xerrstr (sed_t* s, errnum_t num)
|
||||
{
|
||||
xtn_t* xtn = GET_XTN(s);
|
||||
try
|
||||
{
|
||||
return xtn->sed->getErrorString (num);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
return xtn->sed->dflerrstr (s, num);
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////////////////
|
||||
QSE_END_NAMESPACE(QSE)
|
||||
/////////////////////////////////
|
||||
|
301
lib/sed/StdSed.cpp
Normal file
301
lib/sed/StdSed.cpp
Normal file
@ -0,0 +1,301 @@
|
||||
/*
|
||||
* $Id$
|
||||
*
|
||||
Copyright (c) 2006-2019 Chung, Hyung-Hwan. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR
|
||||
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <qse/sed/StdSed.hpp>
|
||||
#include <qse/si/fio.h>
|
||||
#include <qse/si/sio.h>
|
||||
#include "sed-prv.h"
|
||||
#include "../cmn/mem-prv.h"
|
||||
|
||||
/////////////////////////////////
|
||||
QSE_BEGIN_NAMESPACE(QSE)
|
||||
/////////////////////////////////
|
||||
|
||||
static qse_sio_t* open_sio (StdSed::Stream::Data& io, const qse_char_t* file, int flags)
|
||||
{
|
||||
qse_sio_t* sio;
|
||||
|
||||
sio = qse_sio_open(qse_sed_getmmgr((StdSed::sed_t*)io), 0, file, flags);
|
||||
if (sio == QSE_NULL)
|
||||
{
|
||||
qse_cstr_t ea;
|
||||
ea.ptr = (StdSed::char_t*)file;
|
||||
ea.len = qse_strlen (file);
|
||||
((Sed*)io)->setError (QSE_SED_EIOFIL, &ea);
|
||||
}
|
||||
return sio;
|
||||
}
|
||||
|
||||
static qse_sio_t* open_sio_std (StdSed::Stream::Data& io, qse_sio_std_t std, int flags)
|
||||
{
|
||||
qse_sio_t* sio;
|
||||
static const StdSed::char_t* std_names[] =
|
||||
{
|
||||
QSE_T("stdin"),
|
||||
QSE_T("stdout"),
|
||||
QSE_T("stderr"),
|
||||
};
|
||||
|
||||
sio = qse_sio_openstd(qse_sed_getmmgr((StdSed::sed_t*)io), 0, std, flags);
|
||||
if (sio == QSE_NULL)
|
||||
{
|
||||
qse_cstr_t ea;
|
||||
ea.ptr = (StdSed::char_t*)std_names[std];
|
||||
ea.len = qse_strlen (std_names[std]);
|
||||
((Sed*)io)->setError (QSE_SED_EIOFIL, &ea);
|
||||
}
|
||||
return sio;
|
||||
}
|
||||
|
||||
int StdSed::FileStream::open (Data& io)
|
||||
{
|
||||
qse_sio_t* sio;
|
||||
const char_t* ioname = io.getName();
|
||||
int oflags;
|
||||
|
||||
if (io.getMode() == READ)
|
||||
oflags = QSE_SIO_READ | QSE_SIO_IGNOREMBWCERR;
|
||||
else
|
||||
oflags = QSE_SIO_WRITE | QSE_SIO_CREATE | QSE_SIO_TRUNCATE | QSE_SIO_IGNOREMBWCERR | QSE_SIO_LINEBREAK;
|
||||
|
||||
if (ioname == QSE_NULL)
|
||||
{
|
||||
//
|
||||
// a normal console is indicated by a null name or a dash
|
||||
//
|
||||
if (io.getMode() == READ)
|
||||
{
|
||||
sio = (infile == QSE_NULL || (infile[0] == QSE_T('-') && infile[1] == QSE_T('\0')))?
|
||||
open_sio_std (io, QSE_SIO_STDIN, oflags):
|
||||
open_sio (io, infile, oflags);
|
||||
}
|
||||
else
|
||||
{
|
||||
sio = (outfile == QSE_NULL || (outfile[0] == QSE_T('-') && outfile[1] == QSE_T('\0')))?
|
||||
open_sio_std (io, QSE_SIO_STDOUT, oflags):
|
||||
open_sio (io, outfile, oflags);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
// if ioname is not empty, it is a file name
|
||||
//
|
||||
sio = open_sio (io, ioname, oflags);
|
||||
}
|
||||
if (sio == QSE_NULL) return -1;
|
||||
|
||||
if (this->cmgr) qse_sio_setcmgr (sio, this->cmgr);
|
||||
io.setHandle (sio);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int StdSed::FileStream::close (Data& io)
|
||||
{
|
||||
qse_sio_close ((qse_sio_t*)io.getHandle());
|
||||
return 0;
|
||||
}
|
||||
|
||||
StdSed::ssize_t StdSed::FileStream::read (Data& io, char_t* buf, size_t len)
|
||||
{
|
||||
ssize_t n = qse_sio_getstrn ((qse_sio_t*)io.getHandle(), buf, len);
|
||||
|
||||
if (n == -1)
|
||||
{
|
||||
if (io.getName() == QSE_NULL && infile != QSE_NULL)
|
||||
{
|
||||
// if writing to outfile, set the error message
|
||||
// explicitly. other cases are handled by
|
||||
// the caller in sed.c.
|
||||
qse_cstr_t ea;
|
||||
ea.ptr = (char_t*)infile;
|
||||
ea.len = qse_strlen (infile);
|
||||
((Sed*)io)->setError (QSE_SED_EIOFIL, &ea);
|
||||
}
|
||||
}
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
StdSed::ssize_t StdSed::FileStream::write (Data& io, const char_t* buf, size_t len)
|
||||
{
|
||||
ssize_t n = qse_sio_putstrn ((qse_sio_t*)io.getHandle(), buf, len);
|
||||
|
||||
if (n == -1)
|
||||
{
|
||||
if (io.getName() == QSE_NULL && outfile != QSE_NULL)
|
||||
{
|
||||
// if writing to outfile, set the error message
|
||||
// explicitly. other cases are handled by
|
||||
// the caller in sed.c.
|
||||
qse_cstr_t ea;
|
||||
ea.ptr = (char_t*)outfile;
|
||||
ea.len = qse_strlen (outfile);
|
||||
((Sed*)io)->setError (QSE_SED_EIOFIL, &ea);
|
||||
}
|
||||
}
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
StdSed::StringStream::StringStream (const char_t* in)
|
||||
{
|
||||
this->in.ptr = in;
|
||||
this->in.end = in + qse_strlen(in);
|
||||
this->out.inited = false;
|
||||
}
|
||||
|
||||
StdSed::StringStream::StringStream (const char_t* in, size_t len)
|
||||
{
|
||||
this->in.ptr = in;
|
||||
this->in.end = in + len;
|
||||
this->out.inited = false;
|
||||
}
|
||||
|
||||
StdSed::StringStream::~StringStream ()
|
||||
{
|
||||
if (out.inited) qse_str_fini (&out.buf);
|
||||
}
|
||||
|
||||
int StdSed::StringStream::open (Data& io)
|
||||
{
|
||||
const char_t* ioname = io.getName ();
|
||||
|
||||
if (ioname == QSE_NULL)
|
||||
{
|
||||
// open a main data stream
|
||||
if (io.getMode() == READ)
|
||||
{
|
||||
in.cur = in.ptr;
|
||||
io.setHandle ((void*)in.ptr);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!out.inited)
|
||||
{
|
||||
if (qse_str_init (&out.buf, ((Sed*)io)->getMmgr(), 256) <= -1)
|
||||
{
|
||||
((Sed*)io)->setError (QSE_SED_ENOMEM);
|
||||
return -1;
|
||||
}
|
||||
|
||||
out.inited = true;
|
||||
}
|
||||
|
||||
qse_str_clear (&out.buf);
|
||||
io.setHandle (&out.buf);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// open files for a r or w command
|
||||
qse_sio_t* sio;
|
||||
int mode = (io.getMode() == READ)?
|
||||
QSE_SIO_READ:
|
||||
(QSE_SIO_WRITE|QSE_SIO_CREATE|QSE_SIO_TRUNCATE);
|
||||
|
||||
sio = qse_sio_open (((Sed*)io)->getMmgr(), 0, ioname, mode);
|
||||
if (sio == QSE_NULL) return -1;
|
||||
|
||||
io.setHandle (sio);
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int StdSed::StringStream::close (Data& io)
|
||||
{
|
||||
const void* handle = io.getHandle();
|
||||
if (handle != in.ptr && handle != &out.buf)
|
||||
qse_sio_close ((qse_sio_t*)handle);
|
||||
return 0;
|
||||
}
|
||||
|
||||
StdSed::ssize_t StdSed::StringStream::read (Data& io, char_t* buf, size_t len)
|
||||
{
|
||||
const void* handle = io.getHandle();
|
||||
|
||||
if (len == (size_t)-1) len--; // shrink buffer if too long
|
||||
if (handle == in.ptr)
|
||||
{
|
||||
size_t n = 0;
|
||||
while (in.cur < in.end && n < len)
|
||||
buf[n++] = *in.cur++;
|
||||
return (ssize_t)n;
|
||||
}
|
||||
else
|
||||
{
|
||||
QSE_ASSERT (handle != &out.buf);
|
||||
return qse_sio_getstrn ((qse_sio_t*)handle, buf, len);
|
||||
}
|
||||
}
|
||||
|
||||
StdSed::ssize_t StdSed::StringStream::write (Data& io, const char_t* data, size_t len)
|
||||
{
|
||||
const void* handle = io.getHandle();
|
||||
|
||||
if (len == (qse_size_t)-1) len--; // shrink data if too long
|
||||
|
||||
if (handle == &out.buf)
|
||||
{
|
||||
if (qse_str_ncat (&out.buf, data, len) == (qse_size_t)-1)
|
||||
{
|
||||
((Sed*)io)->setError (QSE_SED_ENOMEM);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return len;
|
||||
}
|
||||
else
|
||||
{
|
||||
QSE_ASSERT (handle != in.ptr);
|
||||
return qse_sio_putstrn ((qse_sio_t*)handle, data, len);
|
||||
}
|
||||
}
|
||||
|
||||
const StdSed::char_t* StdSed::StringStream::getInput (size_t* len) const
|
||||
{
|
||||
if (len) *len = in.end - in.ptr;
|
||||
return in.ptr;
|
||||
}
|
||||
|
||||
const StdSed::char_t* StdSed::StringStream::getOutput (size_t* len) const
|
||||
{
|
||||
if (out.inited)
|
||||
{
|
||||
if (len) *len = QSE_STR_LEN(&out.buf);
|
||||
return QSE_STR_PTR(&out.buf);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (len) *len = 0;
|
||||
return QSE_T("");
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////////////////
|
||||
QSE_END_NAMESPACE(QSE)
|
||||
/////////////////////////////////
|
149
lib/sed/err.c
Normal file
149
lib/sed/err.c
Normal file
@ -0,0 +1,149 @@
|
||||
/*
|
||||
* $Id$
|
||||
*
|
||||
Copyright (c) 2006-2019 Chung, Hyung-Hwan. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR
|
||||
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "sed-prv.h"
|
||||
#include "../cmn/mem-prv.h"
|
||||
|
||||
const qse_char_t* qse_sed_dflerrstr (qse_sed_t* sed, qse_sed_errnum_t errnum)
|
||||
{
|
||||
static const qse_char_t* errstr[] =
|
||||
{
|
||||
QSE_T("no error"),
|
||||
QSE_T("other error"),
|
||||
QSE_T("not implemented"),
|
||||
QSE_T("subsystem error"),
|
||||
QSE_T("internal error that should never have happened"),
|
||||
|
||||
QSE_T("insufficient memory"),
|
||||
QSE_T("invalid parameter or data"),
|
||||
QSE_T("command '${0}' not recognized"),
|
||||
QSE_T("command code missing"),
|
||||
QSE_T("command '${0}' incomplete"),
|
||||
QSE_T("regular expression '${0}' incomplete"),
|
||||
QSE_T("failed to compile regular expression '${0}'"),
|
||||
QSE_T("failed to match regular expression"),
|
||||
QSE_T("address 1 prohibited for '${0}'"),
|
||||
QSE_T("address 1 missing or invalid"),
|
||||
QSE_T("address 2 prohibited for '${0}'"),
|
||||
QSE_T("address 2 missing or invalid"),
|
||||
QSE_T("newline expected"),
|
||||
QSE_T("backslash expected"),
|
||||
QSE_T("backslash used as delimiter"),
|
||||
QSE_T("garbage after backslash"),
|
||||
QSE_T("semicolon expected"),
|
||||
QSE_T("empty label name"),
|
||||
QSE_T("duplicate label name '${0}'"),
|
||||
QSE_T("label '${0}' not found"),
|
||||
QSE_T("empty file name"),
|
||||
QSE_T("illegal file name"),
|
||||
QSE_T("strings in translation set not the same length"),
|
||||
QSE_T("group brackets not balanced"),
|
||||
QSE_T("group nesting too deep"),
|
||||
QSE_T("multiple occurrence specifiers"),
|
||||
QSE_T("occurrence specifier zero"),
|
||||
QSE_T("occurrence specifier too large"),
|
||||
QSE_T("no previous regular expression"),
|
||||
QSE_T("cut selector not valid"),
|
||||
QSE_T("I/O error with file '${0}'"),
|
||||
QSE_T("error returned by user I/O handler")
|
||||
};
|
||||
|
||||
return (errnum >= 0 && errnum < QSE_COUNTOF(errstr))?
|
||||
errstr[errnum]: QSE_T("unknown error");
|
||||
}
|
||||
|
||||
qse_sed_errstr_t qse_sed_geterrstr (qse_sed_t* sed)
|
||||
{
|
||||
return sed->errstr;
|
||||
}
|
||||
|
||||
void qse_sed_seterrstr (qse_sed_t* sed, qse_sed_errstr_t errstr)
|
||||
{
|
||||
sed->errstr = errstr;
|
||||
}
|
||||
|
||||
qse_sed_errnum_t qse_sed_geterrnum (qse_sed_t* sed)
|
||||
{
|
||||
return sed->errnum;
|
||||
}
|
||||
|
||||
const qse_sed_loc_t* qse_sed_geterrloc (qse_sed_t* sed)
|
||||
{
|
||||
return &sed->errloc;
|
||||
}
|
||||
|
||||
const qse_char_t* qse_sed_geterrmsg (qse_sed_t* sed)
|
||||
{
|
||||
return (sed->errmsg[0] == QSE_T('\0'))?
|
||||
qse_sed_geterrstr(sed)(sed,sed->errnum): sed->errmsg;
|
||||
}
|
||||
|
||||
void qse_sed_geterror (
|
||||
qse_sed_t* sed, qse_sed_errnum_t* errnum,
|
||||
const qse_char_t** errmsg, qse_sed_loc_t* errloc)
|
||||
{
|
||||
if (errnum != QSE_NULL) *errnum = sed->errnum;
|
||||
if (errmsg != QSE_NULL)
|
||||
{
|
||||
*errmsg = (sed->errmsg[0] == QSE_T('\0'))?
|
||||
qse_sed_geterrstr(sed)(sed,sed->errnum):
|
||||
sed->errmsg;
|
||||
}
|
||||
if (errloc != QSE_NULL) *errloc = sed->errloc;
|
||||
}
|
||||
|
||||
void qse_sed_seterrnum (
|
||||
qse_sed_t* sed, qse_sed_errnum_t errnum, const qse_cstr_t* errarg)
|
||||
{
|
||||
qse_sed_seterror (sed, errnum, errarg, QSE_NULL);
|
||||
}
|
||||
|
||||
void qse_sed_seterrmsg (
|
||||
qse_sed_t* sed, qse_sed_errnum_t errnum,
|
||||
const qse_char_t* errmsg, const qse_sed_loc_t* errloc)
|
||||
{
|
||||
sed->errnum = errnum;
|
||||
qse_strxcpy (sed->errmsg, QSE_COUNTOF(sed->errmsg), errmsg);
|
||||
if (errloc != QSE_NULL) sed->errloc = *errloc;
|
||||
else QSE_MEMSET (&sed->errloc, 0, QSE_SIZEOF(sed->errloc));
|
||||
}
|
||||
|
||||
void qse_sed_seterror (
|
||||
qse_sed_t* sed, qse_sed_errnum_t errnum,
|
||||
const qse_cstr_t* errarg, const qse_sed_loc_t* errloc)
|
||||
{
|
||||
const qse_char_t* errfmt;
|
||||
|
||||
sed->errnum = errnum;
|
||||
|
||||
errfmt = qse_sed_geterrstr(sed)(sed,sed->errnum);
|
||||
QSE_ASSERT (errfmt != QSE_NULL);
|
||||
qse_strxfncpy (sed->errmsg, QSE_COUNTOF(sed->errmsg), errfmt, errarg);
|
||||
|
||||
if (errloc != QSE_NULL) sed->errloc = *errloc;
|
||||
else QSE_MEMSET (&sed->errloc, 0, QSE_SIZEOF(sed->errloc));
|
||||
}
|
||||
|
247
lib/sed/sed-prv.h
Normal file
247
lib/sed/sed-prv.h
Normal file
@ -0,0 +1,247 @@
|
||||
/*
|
||||
* $Id$
|
||||
*
|
||||
Copyright (c) 2006-2019 Chung, Hyung-Hwan. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR
|
||||
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef _QSE_LIB_SED_SED_PRV_H_
|
||||
#define _QSE_LIB_SED_SED_PRV_H_
|
||||
|
||||
#include <qse/sed/sed.h>
|
||||
#include <qse/cmn/str.h>
|
||||
|
||||
#define QSE_MAP_AS_RBT
|
||||
#include <qse/cmn/map.h>
|
||||
|
||||
/* structure to maintain data to append
|
||||
* at the end of each cycle, triggered by r, R, and a */
|
||||
typedef struct qse_sed_app_t qse_sed_app_t;
|
||||
struct qse_sed_app_t
|
||||
{
|
||||
qse_sed_cmd_t* cmd;
|
||||
qse_sed_app_t* next;
|
||||
};
|
||||
|
||||
typedef struct qse_sed_cmd_blk_t qse_sed_cmd_blk_t;
|
||||
struct qse_sed_cmd_blk_t
|
||||
{
|
||||
qse_size_t len;
|
||||
qse_sed_cmd_t buf[256];
|
||||
qse_sed_cmd_blk_t* next;
|
||||
};
|
||||
|
||||
/* structure to maintain list of compiliation
|
||||
* identifiers */
|
||||
typedef struct qse_sed_cid_t qse_sed_cid_t;
|
||||
struct qse_sed_cid_t
|
||||
{
|
||||
qse_sed_cid_t* next;
|
||||
};
|
||||
|
||||
/* special structure to represent an unknown cid
|
||||
* used once the action of setting a new cid fails */
|
||||
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
|
||||
*/
|
||||
struct qse_sed_t
|
||||
{
|
||||
QSE_SED_HDR;
|
||||
|
||||
qse_sed_errnum_t errnum; /**< stores an error number */
|
||||
qse_char_t errmsg[128]; /**< error message holder */
|
||||
qse_sed_loc_t errloc; /**< location of the last error */
|
||||
qse_sed_errstr_t errstr; /**< error string getter */
|
||||
|
||||
struct
|
||||
{
|
||||
int trait;
|
||||
qse_sed_tracer_t tracer;
|
||||
qse_sed_lformatter_t lformatter;
|
||||
|
||||
struct
|
||||
{
|
||||
struct
|
||||
{
|
||||
qse_size_t build;
|
||||
qse_size_t match;
|
||||
} rex;
|
||||
} depth; /* useful only for rex.h */
|
||||
} opt;
|
||||
|
||||
qse_sed_ecb_t* ecb;
|
||||
|
||||
/** source text pointers */
|
||||
struct
|
||||
{
|
||||
qse_sed_io_impl_t fun; /**< input stream handler */
|
||||
qse_sed_io_arg_t arg;
|
||||
qse_char_t buf[1024];
|
||||
int eof;
|
||||
|
||||
qse_sed_cid_t* cid;
|
||||
qse_sed_unknown_cid_t unknown_cid;
|
||||
|
||||
qse_sed_loc_t loc; /**< location */
|
||||
qse_cint_t cc; /**< last character read */
|
||||
const qse_char_t* ptr; /**< beginning of the source text */
|
||||
const qse_char_t* end; /**< end of the source text */
|
||||
const qse_char_t* cur; /**< current source text pointer */
|
||||
} src;
|
||||
|
||||
/** temporary data for compiling */
|
||||
struct
|
||||
{
|
||||
qse_str_t rex; /**< regular expression buffer */
|
||||
qse_str_t lab; /**< label name buffer */
|
||||
|
||||
/** data structure to compile command groups */
|
||||
struct
|
||||
{
|
||||
/** current level of command group nesting */
|
||||
int level;
|
||||
/** keeps track of the begining of nested groups */
|
||||
qse_sed_cmd_t* cmd[128];
|
||||
} grp;
|
||||
|
||||
/** a table storing labels seen */
|
||||
qse_map_t labs;
|
||||
} tmp;
|
||||
|
||||
/** compiled commands */
|
||||
struct
|
||||
{
|
||||
qse_sed_cmd_blk_t fb; /**< the first block is static */
|
||||
qse_sed_cmd_blk_t* lb; /**< points to the last block */
|
||||
|
||||
qse_sed_cmd_t quit;
|
||||
qse_sed_cmd_t quit_quiet;
|
||||
qse_sed_cmd_t again;
|
||||
qse_sed_cmd_t over;
|
||||
} cmd;
|
||||
|
||||
/** data for execution */
|
||||
struct
|
||||
{
|
||||
/** data needed for output streams and files */
|
||||
struct
|
||||
{
|
||||
qse_sed_io_impl_t fun; /**< an output handler */
|
||||
qse_sed_io_arg_t arg; /**< output handling data */
|
||||
|
||||
qse_char_t buf[2048];
|
||||
qse_size_t len;
|
||||
int eof;
|
||||
|
||||
/*****************************************************/
|
||||
/* the following two fields are very tightly-coupled.
|
||||
* don't make any partial changes */
|
||||
qse_map_t files;
|
||||
qse_sed_t* files_ext;
|
||||
/*****************************************************/
|
||||
} out;
|
||||
|
||||
/** data needed for input streams */
|
||||
struct
|
||||
{
|
||||
qse_sed_io_impl_t fun; /**< input handler */
|
||||
qse_sed_io_arg_t arg; /**< input handling data */
|
||||
|
||||
qse_char_t xbuf[1]; /**< read-ahead buffer */
|
||||
int xbuf_len; /**< data length in the buffer */
|
||||
|
||||
qse_char_t buf[2048]; /**< input buffer */
|
||||
qse_size_t len; /**< data length in the buffer */
|
||||
qse_size_t pos; /**< current position in the buffer */
|
||||
int eof; /**< EOF indicator */
|
||||
|
||||
qse_str_t line; /**< pattern space */
|
||||
qse_size_t num; /**< current line number */
|
||||
} in;
|
||||
|
||||
struct
|
||||
{
|
||||
qse_size_t count; /* number of append entries in a static buffer. */
|
||||
qse_sed_app_t s[16]; /* handle up to 16 appends in a static buffer */
|
||||
struct
|
||||
{
|
||||
qse_sed_app_t* head;
|
||||
qse_sed_app_t* tail;
|
||||
} d;
|
||||
} append;
|
||||
|
||||
/** text buffers */
|
||||
struct
|
||||
{
|
||||
qse_str_t hold; /* hold space */
|
||||
qse_str_t scratch;
|
||||
} txt;
|
||||
|
||||
struct
|
||||
{
|
||||
qse_size_t nflds; /**< the number of fields */
|
||||
qse_size_t cflds; /**< capacity of flds field */
|
||||
qse_cstr_t sflds[128]; /**< static field buffer */
|
||||
qse_cstr_t* flds;
|
||||
int delimited;
|
||||
} cutf;
|
||||
|
||||
/** indicates if a successful substitution has been made
|
||||
* since the last read on the input stream. */
|
||||
int subst_done;
|
||||
void* last_rex;
|
||||
|
||||
/** halt requested */
|
||||
int haltreq;
|
||||
} e;
|
||||
};
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
int qse_sed_init (
|
||||
qse_sed_t* sed,
|
||||
qse_mmgr_t* mmgr
|
||||
);
|
||||
|
||||
void qse_sed_fini (
|
||||
qse_sed_t* sed
|
||||
);
|
||||
|
||||
const qse_char_t* qse_sed_dflerrstr (
|
||||
qse_sed_t* sed,
|
||||
qse_sed_errnum_t errnum
|
||||
);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
4207
lib/sed/sed.c
Normal file
4207
lib/sed/sed.c
Normal file
File diff suppressed because it is too large
Load Diff
923
lib/sed/std.c
Normal file
923
lib/sed/std.c
Normal file
@ -0,0 +1,923 @@
|
||||
/*
|
||||
* $Id$
|
||||
*
|
||||
Copyright (c) 2006-2019 Chung, Hyung-Hwan. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR
|
||||
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "sed-prv.h"
|
||||
#include <qse/sed/stdsed.h>
|
||||
#include <qse/cmn/str.h>
|
||||
#include <qse/si/sio.h>
|
||||
#include "../cmn/mem-prv.h"
|
||||
|
||||
typedef struct xtn_in_t xtn_in_t;
|
||||
struct xtn_in_t
|
||||
{
|
||||
qse_sed_iostd_t* ptr;
|
||||
qse_sed_iostd_t* cur;
|
||||
qse_size_t mempos;
|
||||
};
|
||||
|
||||
typedef struct xtn_out_t xtn_out_t;
|
||||
struct xtn_out_t
|
||||
{
|
||||
qse_sed_iostd_t* ptr;
|
||||
qse_str_t* memstr;
|
||||
};
|
||||
|
||||
typedef struct xtn_t xtn_t;
|
||||
struct xtn_t
|
||||
{
|
||||
struct
|
||||
{
|
||||
xtn_in_t in;
|
||||
qse_char_t last;
|
||||
int newline_squeezed;
|
||||
} s;
|
||||
struct
|
||||
{
|
||||
xtn_in_t in;
|
||||
xtn_out_t out;
|
||||
} e;
|
||||
};
|
||||
|
||||
#if defined(QSE_HAVE_INLINE)
|
||||
static QSE_INLINE xtn_t* GET_XTN(qse_sed_t* sed) { return (xtn_t*)((qse_uint8_t*)qse_sed_getxtn(sed) - QSE_SIZEOF(xtn_t)); }
|
||||
#else
|
||||
#define GET_XTN(sed) ((xtn_t*)((qse_uint8_t*)qse_sed_getxtn(sed) - QSE_SIZEOF(xtn_t)))
|
||||
#endif
|
||||
|
||||
static int int_to_str (qse_size_t val, qse_char_t* buf, qse_size_t buflen)
|
||||
{
|
||||
qse_size_t t;
|
||||
qse_size_t rlen = 0;
|
||||
|
||||
t = val;
|
||||
if (t == 0) rlen++;
|
||||
else
|
||||
{
|
||||
/* non-zero values */
|
||||
if (t < 0) { t = -t; rlen++; }
|
||||
while (t > 0) { rlen++; t /= 10; }
|
||||
}
|
||||
|
||||
if (rlen >= buflen) return -1; /* buffer too small */
|
||||
|
||||
buf[rlen] = QSE_T('\0');
|
||||
|
||||
t = val;
|
||||
if (t == 0) buf[0] = QSE_T('0');
|
||||
else
|
||||
{
|
||||
if (t < 0) t = -t;
|
||||
|
||||
/* fill in the buffer with digits */
|
||||
while (t > 0)
|
||||
{
|
||||
buf[--rlen] = (qse_char_t)(t % 10) + QSE_T('0');
|
||||
t /= 10;
|
||||
}
|
||||
|
||||
/* insert the negative sign if necessary */
|
||||
if (val < 0) buf[--rlen] = QSE_T('-');
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
qse_sed_t* qse_sed_openstd (qse_size_t xtnsize, qse_sed_errnum_t* errnum)
|
||||
{
|
||||
return qse_sed_openstdwithmmgr (QSE_MMGR_GETDFL(), xtnsize, errnum);
|
||||
}
|
||||
|
||||
qse_sed_t* qse_sed_openstdwithmmgr (qse_mmgr_t* mmgr, qse_size_t xtnsize, qse_sed_errnum_t* errnum)
|
||||
{
|
||||
qse_sed_t* sed;
|
||||
|
||||
sed = qse_sed_open (mmgr, QSE_SIZEOF(xtn_t) + xtnsize, errnum);
|
||||
if (!sed) return QSE_NULL;
|
||||
|
||||
sed->_instsize += QSE_SIZEOF(xtn_t);
|
||||
|
||||
return sed;
|
||||
}
|
||||
|
||||
static int verify_iostd_in (qse_sed_t* sed, qse_sed_iostd_t in[])
|
||||
{
|
||||
qse_size_t i;
|
||||
|
||||
if (in[0].type == QSE_SED_IOSTD_NULL)
|
||||
{
|
||||
/* if 'in' is specified, it must contains at least one
|
||||
* valid entry */
|
||||
qse_sed_seterrnum (sed, QSE_SED_EINVAL, QSE_NULL);
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (i = 0; in[i].type != QSE_SED_IOSTD_NULL; i++)
|
||||
{
|
||||
if (in[i].type != QSE_SED_IOSTD_FILE &&
|
||||
in[i].type != QSE_SED_IOSTD_STR &&
|
||||
in[i].type != QSE_SED_IOSTD_SIO)
|
||||
{
|
||||
qse_sed_seterrnum (sed, QSE_SED_EINVAL, QSE_NULL);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static qse_sio_t* open_sio_file (qse_sed_t* sed, const qse_char_t* file, int flags)
|
||||
{
|
||||
qse_sio_t* sio;
|
||||
|
||||
sio = qse_sio_open(qse_sed_getmmgr(sed), 0, file, flags);
|
||||
if (sio == QSE_NULL)
|
||||
{
|
||||
qse_cstr_t ea;
|
||||
ea.ptr = file;
|
||||
ea.len = qse_strlen (file);
|
||||
qse_sed_seterrnum (sed, QSE_SED_EIOFIL, &ea);
|
||||
}
|
||||
return sio;
|
||||
}
|
||||
|
||||
struct sio_std_name_t
|
||||
{
|
||||
const qse_char_t* ptr;
|
||||
qse_size_t len;
|
||||
};
|
||||
|
||||
static struct sio_std_name_t sio_std_names[] =
|
||||
{
|
||||
{ QSE_T("stdin"), 5 },
|
||||
{ QSE_T("stdout"), 6 },
|
||||
{ QSE_T("stderr"), 6 }
|
||||
};
|
||||
|
||||
static qse_sio_t* open_sio_std (qse_sed_t* sed, qse_sio_std_t std, int flags)
|
||||
{
|
||||
qse_sio_t* sio;
|
||||
|
||||
sio = qse_sio_openstd(qse_sed_getmmgr(sed), 0, std, flags);
|
||||
if (sio == QSE_NULL)
|
||||
{
|
||||
qse_cstr_t ea;
|
||||
ea.ptr = sio_std_names[std].ptr;
|
||||
ea.len = sio_std_names[std].len;
|
||||
qse_sed_seterrnum (sed, QSE_SED_EIOFIL, &ea);
|
||||
}
|
||||
return sio;
|
||||
}
|
||||
|
||||
static void close_main_stream (
|
||||
qse_sed_t* sed, qse_sed_io_arg_t* arg, qse_sed_iostd_t* io)
|
||||
{
|
||||
switch (io->type)
|
||||
{
|
||||
case QSE_SED_IOSTD_FILE:
|
||||
qse_sio_close (arg->handle);
|
||||
break;
|
||||
|
||||
case QSE_SED_IOSTD_STR:
|
||||
/* nothing to do for input.
|
||||
* i don't close xtn->e.out.memstr intentionally.
|
||||
* i close this in qse_awk_execstd()
|
||||
*/
|
||||
break;
|
||||
|
||||
case QSE_SED_IOSTD_SIO:
|
||||
/* nothing to do */
|
||||
break;
|
||||
|
||||
default:
|
||||
/* do nothing */
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static int open_input_stream (
|
||||
qse_sed_t* sed, qse_sed_io_arg_t* arg, qse_sed_iostd_t* io, xtn_in_t* base)
|
||||
{
|
||||
xtn_t* xtn = GET_XTN(sed);
|
||||
|
||||
QSE_ASSERT (io != QSE_NULL);
|
||||
switch (io->type)
|
||||
{
|
||||
case QSE_SED_IOSTD_FILE:
|
||||
{
|
||||
qse_sio_t* sio;
|
||||
|
||||
if (io->u.file.path == QSE_NULL ||
|
||||
(io->u.file.path[0] == QSE_T('-') &&
|
||||
io->u.file.path[1] == QSE_T('\0')))
|
||||
{
|
||||
sio = open_sio_std (
|
||||
sed, QSE_SIO_STDIN,
|
||||
QSE_SIO_READ | QSE_SIO_IGNOREMBWCERR
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
sio = open_sio_file (
|
||||
sed, io->u.file.path,
|
||||
QSE_SIO_READ | QSE_SIO_IGNOREMBWCERR);
|
||||
}
|
||||
if (sio == QSE_NULL) return -1;
|
||||
if (io->u.file.cmgr) qse_sio_setcmgr (sio, io->u.file.cmgr);
|
||||
arg->handle = sio;
|
||||
break;
|
||||
}
|
||||
|
||||
case QSE_SED_IOSTD_STR:
|
||||
/* don't store anything to arg->handle */
|
||||
base->mempos = 0;
|
||||
break;
|
||||
|
||||
case QSE_SED_IOSTD_SIO:
|
||||
arg->handle = io->u.sio;
|
||||
break;
|
||||
|
||||
default:
|
||||
QSE_ASSERTX (
|
||||
!"should never happen",
|
||||
"io-type must be one of SIO,FILE,STR"
|
||||
);
|
||||
qse_sed_seterrnum (sed, QSE_SED_EINTERN, QSE_NULL);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
if (base == &xtn->s.in)
|
||||
{
|
||||
/* reset script location */
|
||||
if (io->type == QSE_SED_IOSTD_FILE)
|
||||
{
|
||||
qse_sed_setcompid (
|
||||
sed,
|
||||
((io->u.file.path == QSE_NULL)?
|
||||
sio_std_names[QSE_SIO_STDIN].ptr: io->u.file.path)
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
qse_char_t buf[64];
|
||||
|
||||
/* format an identifier to be something like M#1, S#5 */
|
||||
buf[0] = (io->type == QSE_SED_IOSTD_STR)? QSE_T('M'): QSE_T('S');
|
||||
buf[1] = QSE_T('#');
|
||||
int_to_str (io - xtn->s.in.ptr, &buf[2], QSE_COUNTOF(buf) - 2);
|
||||
|
||||
/* don't care about failure int_to_str() though it's not
|
||||
* likely to happen */
|
||||
qse_sed_setcompid (sed, buf);
|
||||
}
|
||||
sed->src.loc.line = 1;
|
||||
sed->src.loc.colm = 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int open_output_stream (qse_sed_t* sed, qse_sed_io_arg_t* arg, qse_sed_iostd_t* io)
|
||||
{
|
||||
xtn_t* xtn = GET_XTN(sed);
|
||||
|
||||
QSE_ASSERT (io != QSE_NULL);
|
||||
switch (io->type)
|
||||
{
|
||||
case QSE_SED_IOSTD_FILE:
|
||||
{
|
||||
qse_sio_t* sio;
|
||||
if (io->u.file.path == QSE_NULL ||
|
||||
(io->u.file.path[0] == QSE_T('-') &&
|
||||
io->u.file.path[1] == QSE_T('\0')))
|
||||
{
|
||||
sio = open_sio_std (
|
||||
sed, QSE_SIO_STDOUT,
|
||||
QSE_SIO_WRITE |
|
||||
QSE_SIO_CREATE |
|
||||
QSE_SIO_TRUNCATE |
|
||||
QSE_SIO_IGNOREMBWCERR |
|
||||
QSE_SIO_LINEBREAK
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
sio = open_sio_file (
|
||||
sed, io->u.file.path,
|
||||
QSE_SIO_WRITE |
|
||||
QSE_SIO_CREATE |
|
||||
QSE_SIO_TRUNCATE |
|
||||
QSE_SIO_IGNOREMBWCERR
|
||||
);
|
||||
}
|
||||
if (sio == QSE_NULL) return -1;
|
||||
if (io->u.file.cmgr) qse_sio_setcmgr (sio, io->u.file.cmgr);
|
||||
arg->handle = sio;
|
||||
break;
|
||||
}
|
||||
|
||||
case QSE_SED_IOSTD_STR:
|
||||
/* don't store anything to arg->handle */
|
||||
xtn->e.out.memstr = qse_str_open(qse_sed_getmmgr(sed), 0, 512);
|
||||
if (xtn->e.out.memstr == QSE_NULL)
|
||||
{
|
||||
qse_sed_seterrnum (sed, QSE_SED_ENOMEM, QSE_NULL);
|
||||
return -1;
|
||||
}
|
||||
break;
|
||||
|
||||
case QSE_SED_IOSTD_SIO:
|
||||
arg->handle = io->u.sio;
|
||||
break;
|
||||
|
||||
default:
|
||||
QSE_ASSERTX (
|
||||
!"should never happen",
|
||||
"io-type must be one of SIO,FILE,STR"
|
||||
);
|
||||
qse_sed_seterrnum (sed, QSE_SED_EINTERN, QSE_NULL);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static qse_ssize_t read_input_stream (
|
||||
qse_sed_t* sed, qse_sed_io_arg_t* arg,
|
||||
qse_char_t* buf, qse_size_t len, xtn_in_t* base)
|
||||
{
|
||||
xtn_t* xtn = GET_XTN(sed);
|
||||
qse_sed_iostd_t* io, * next;
|
||||
void* old, * new;
|
||||
qse_ssize_t n = 0;
|
||||
|
||||
if (len > QSE_TYPE_MAX(qse_ssize_t)) len = QSE_TYPE_MAX(qse_ssize_t);
|
||||
|
||||
do
|
||||
{
|
||||
io = base->cur;
|
||||
|
||||
if (base == &xtn->s.in && xtn->s.newline_squeezed)
|
||||
{
|
||||
xtn->s.newline_squeezed = 0;
|
||||
goto open_next;
|
||||
}
|
||||
|
||||
QSE_ASSERT (io != QSE_NULL);
|
||||
|
||||
if (io->type == QSE_SED_IOSTD_STR)
|
||||
{
|
||||
n = 0;
|
||||
while (base->mempos < io->u.str.len && n < len)
|
||||
buf[n++] = io->u.str.ptr[base->mempos++];
|
||||
}
|
||||
else n = qse_sio_getstrn (arg->handle, buf, len);
|
||||
|
||||
if (n != 0)
|
||||
{
|
||||
if (n <= -1)
|
||||
{
|
||||
if (io->type == QSE_SED_IOSTD_FILE)
|
||||
{
|
||||
qse_cstr_t ea;
|
||||
if (io->u.file.path)
|
||||
{
|
||||
ea.ptr = io->u.file.path;
|
||||
ea.len = qse_strlen (io->u.file.path);
|
||||
}
|
||||
else
|
||||
{
|
||||
ea.ptr = sio_std_names[QSE_SIO_STDIN].ptr;
|
||||
ea.len = sio_std_names[QSE_SIO_STDIN].len;
|
||||
}
|
||||
qse_sed_seterrnum (sed, QSE_SED_EIOFIL, &ea);
|
||||
}
|
||||
}
|
||||
else if (base == &xtn->s.in)
|
||||
{
|
||||
xtn->s.last = buf[n-1];
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
/* ============================================= */
|
||||
/* == end of file on the current input stream == */
|
||||
/* ============================================= */
|
||||
|
||||
if (base == &xtn->s.in && xtn->s.last != QSE_T('\n'))
|
||||
{
|
||||
/* TODO: different line termination convension */
|
||||
buf[0] = QSE_T('\n');
|
||||
n = 1;
|
||||
xtn->s.newline_squeezed = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
open_next:
|
||||
next = base->cur + 1;
|
||||
if (next->type == QSE_SED_IOSTD_NULL)
|
||||
{
|
||||
/* no next stream available - return 0 */
|
||||
break;
|
||||
}
|
||||
|
||||
old = arg->handle;
|
||||
|
||||
/* try to open the next input stream */
|
||||
if (open_input_stream (sed, arg, next, base) <= -1)
|
||||
{
|
||||
/* failed to open the next input stream */
|
||||
if (next->type == QSE_SED_IOSTD_FILE)
|
||||
{
|
||||
qse_cstr_t ea;
|
||||
if (next->u.file.path)
|
||||
{
|
||||
ea.ptr = next->u.file.path;
|
||||
ea.len = qse_strlen (next->u.file.path);
|
||||
}
|
||||
else
|
||||
{
|
||||
ea.ptr = sio_std_names[QSE_SIO_STDIN].ptr;
|
||||
ea.len = sio_std_names[QSE_SIO_STDIN].len;
|
||||
}
|
||||
qse_sed_seterrnum (sed, QSE_SED_EIOFIL, &ea);
|
||||
}
|
||||
|
||||
n = -1;
|
||||
break;
|
||||
}
|
||||
|
||||
/* successfuly opened the next input stream */
|
||||
new = arg->handle;
|
||||
|
||||
arg->handle = old;
|
||||
|
||||
/* close the previous stream */
|
||||
close_main_stream (sed, arg, io);
|
||||
|
||||
arg->handle = new;
|
||||
|
||||
base->cur++;
|
||||
}
|
||||
while (1);
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
static qse_ssize_t s_in (
|
||||
qse_sed_t* sed, qse_sed_io_cmd_t cmd, qse_sed_io_arg_t* arg,
|
||||
qse_char_t* buf, qse_size_t len)
|
||||
{
|
||||
xtn_t* xtn = GET_XTN(sed);
|
||||
|
||||
switch (cmd)
|
||||
{
|
||||
case QSE_SED_IO_OPEN:
|
||||
{
|
||||
if (open_input_stream (sed, arg, xtn->s.in.cur, &xtn->s.in) <= -1) return -1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
case QSE_SED_IO_CLOSE:
|
||||
{
|
||||
close_main_stream (sed, arg, xtn->s.in.cur);
|
||||
return 0;
|
||||
}
|
||||
|
||||
case QSE_SED_IO_READ:
|
||||
{
|
||||
return read_input_stream (sed, arg, buf, len, &xtn->s.in);
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
QSE_ASSERTX (
|
||||
!"should never happen",
|
||||
"cmd must be one of OPEN,CLOSE,READ"
|
||||
);
|
||||
qse_sed_seterrnum (sed, QSE_SED_EINTERN, QSE_NULL);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static qse_ssize_t x_in (
|
||||
qse_sed_t* sed, qse_sed_io_cmd_t cmd, qse_sed_io_arg_t* arg,
|
||||
qse_char_t* buf, qse_size_t len)
|
||||
{
|
||||
qse_sio_t* sio;
|
||||
xtn_t* xtn = GET_XTN(sed);
|
||||
|
||||
switch (cmd)
|
||||
{
|
||||
case QSE_SED_IO_OPEN:
|
||||
{
|
||||
if (arg->path == QSE_NULL)
|
||||
{
|
||||
/* no file specified. console stream */
|
||||
if (xtn->e.in.ptr == QSE_NULL)
|
||||
{
|
||||
/* QSE_NULL passed into qse_sed_exec() for input */
|
||||
sio = open_sio_std (
|
||||
sed, QSE_SIO_STDIN, QSE_SIO_READ | QSE_SIO_IGNOREMBWCERR);
|
||||
if (sio == QSE_NULL) return -1;
|
||||
arg->handle = sio;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (open_input_stream (sed, arg, xtn->e.in.cur, &xtn->e.in) <= -1) return -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
sio = open_sio_file (sed, arg->path, QSE_SIO_READ | QSE_SIO_IGNOREMBWCERR);
|
||||
if (sio == QSE_NULL) return -1;
|
||||
arg->handle = sio;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
case QSE_SED_IO_CLOSE:
|
||||
{
|
||||
if (arg->path == QSE_NULL)
|
||||
{
|
||||
/* main data stream */
|
||||
if (xtn->e.in.ptr == QSE_NULL)
|
||||
qse_sio_close (arg->handle);
|
||||
else
|
||||
close_main_stream (sed, arg, xtn->e.in.cur);
|
||||
}
|
||||
else
|
||||
{
|
||||
qse_sio_close (arg->handle);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
case QSE_SED_IO_READ:
|
||||
{
|
||||
if (arg->path == QSE_NULL)
|
||||
{
|
||||
/* main data stream */
|
||||
if (xtn->e.in.ptr == QSE_NULL)
|
||||
{
|
||||
qse_ssize_t n;
|
||||
n = qse_sio_getstrn (arg->handle, buf, len);
|
||||
if (n <= -1)
|
||||
{
|
||||
qse_cstr_t ea;
|
||||
ea.ptr = sio_std_names[QSE_SIO_STDIN].ptr;
|
||||
ea.len = sio_std_names[QSE_SIO_STDIN].len;
|
||||
qse_sed_seterrnum (sed, QSE_SED_EIOFIL, &ea);
|
||||
}
|
||||
return n;
|
||||
}
|
||||
else
|
||||
return read_input_stream (sed, arg, buf, len, &xtn->e.in);
|
||||
}
|
||||
else
|
||||
{
|
||||
qse_ssize_t n;
|
||||
n = qse_sio_getstrn (arg->handle, buf, len);
|
||||
if (n <= -1)
|
||||
{
|
||||
qse_cstr_t ea;
|
||||
ea.ptr = arg->path;
|
||||
ea.len = qse_strlen (arg->path);
|
||||
qse_sed_seterrnum (sed, QSE_SED_EIOFIL, &ea);
|
||||
}
|
||||
return n;
|
||||
}
|
||||
}
|
||||
|
||||
default:
|
||||
QSE_ASSERTX (
|
||||
!"should never happen",
|
||||
"cmd must be one of OPEN,CLOSE,READ"
|
||||
);
|
||||
qse_sed_seterrnum (sed, QSE_SED_EINTERN, QSE_NULL);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
static qse_ssize_t x_out (
|
||||
qse_sed_t* sed, qse_sed_io_cmd_t cmd, qse_sed_io_arg_t* arg,
|
||||
qse_char_t* dat, qse_size_t len)
|
||||
{
|
||||
xtn_t* xtn = GET_XTN(sed);
|
||||
qse_sio_t* sio;
|
||||
|
||||
switch (cmd)
|
||||
{
|
||||
case QSE_SED_IO_OPEN:
|
||||
{
|
||||
if (arg->path == QSE_NULL)
|
||||
{
|
||||
/* main data stream */
|
||||
|
||||
if (xtn->e.out.ptr == QSE_NULL)
|
||||
{
|
||||
/* QSE_NULL passed into qse_sed_execstd() for output */
|
||||
sio = open_sio_std (
|
||||
sed, QSE_SIO_STDOUT,
|
||||
QSE_SIO_WRITE |
|
||||
QSE_SIO_CREATE |
|
||||
QSE_SIO_TRUNCATE |
|
||||
QSE_SIO_IGNOREMBWCERR |
|
||||
QSE_SIO_LINEBREAK
|
||||
);
|
||||
if (sio == QSE_NULL) return -1;
|
||||
arg->handle = sio;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (open_output_stream (sed, arg, xtn->e.out.ptr) <= -1) return -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
sio = open_sio_file (
|
||||
sed, arg->path,
|
||||
QSE_SIO_WRITE |
|
||||
QSE_SIO_CREATE |
|
||||
QSE_SIO_TRUNCATE |
|
||||
QSE_SIO_IGNOREMBWCERR
|
||||
);
|
||||
if (sio == QSE_NULL) return -1;
|
||||
arg->handle = sio;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
case QSE_SED_IO_CLOSE:
|
||||
{
|
||||
if (arg->path == QSE_NULL)
|
||||
{
|
||||
if (xtn->e.out.ptr == QSE_NULL)
|
||||
qse_sio_close (arg->handle);
|
||||
else
|
||||
close_main_stream (sed, arg, xtn->e.out.ptr);
|
||||
}
|
||||
else
|
||||
{
|
||||
qse_sio_close (arg->handle);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
case QSE_SED_IO_WRITE:
|
||||
{
|
||||
if (arg->path == QSE_NULL)
|
||||
{
|
||||
/* main data stream */
|
||||
if (xtn->e.out.ptr == QSE_NULL)
|
||||
{
|
||||
qse_ssize_t n;
|
||||
n = qse_sio_putstrn (arg->handle, dat, len);
|
||||
if (n <= -1)
|
||||
{
|
||||
qse_cstr_t ea;
|
||||
ea.ptr = sio_std_names[QSE_SIO_STDOUT].ptr;
|
||||
ea.len = sio_std_names[QSE_SIO_STDOUT].len;
|
||||
qse_sed_seterrnum (sed, QSE_SED_EIOFIL, &ea);
|
||||
}
|
||||
return n;
|
||||
}
|
||||
else
|
||||
{
|
||||
qse_sed_iostd_t* io = xtn->e.out.ptr;
|
||||
if (io->type == QSE_SED_IOSTD_STR)
|
||||
{
|
||||
if (len > QSE_TYPE_MAX(qse_ssize_t)) len = QSE_TYPE_MAX(qse_ssize_t);
|
||||
|
||||
if (qse_str_ncat (xtn->e.out.memstr, dat, len) == (qse_size_t)-1)
|
||||
{
|
||||
qse_sed_seterrnum (sed, QSE_SED_ENOMEM, QSE_NULL);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return len;
|
||||
}
|
||||
else
|
||||
{
|
||||
qse_ssize_t n;
|
||||
n = qse_sio_putstrn (arg->handle, dat, len);
|
||||
if (n <= -1)
|
||||
{
|
||||
qse_cstr_t ea;
|
||||
if (io->u.file.path)
|
||||
{
|
||||
ea.ptr = io->u.file.path;
|
||||
ea.len = qse_strlen(io->u.file.path);
|
||||
}
|
||||
else
|
||||
{
|
||||
ea.ptr = sio_std_names[QSE_SIO_STDOUT].ptr;
|
||||
ea.len = sio_std_names[QSE_SIO_STDOUT].len;
|
||||
}
|
||||
qse_sed_seterrnum (sed, QSE_SED_EIOFIL, &ea);
|
||||
}
|
||||
return n;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
qse_ssize_t n;
|
||||
n = qse_sio_putstrn (arg->handle, dat, len);
|
||||
if (n <= -1)
|
||||
{
|
||||
qse_cstr_t ea;
|
||||
ea.ptr = arg->path;
|
||||
ea.len = qse_strlen(arg->path);
|
||||
qse_sed_seterrnum (sed, QSE_SED_EIOFIL, &ea);
|
||||
}
|
||||
return n;
|
||||
}
|
||||
}
|
||||
|
||||
default:
|
||||
QSE_ASSERTX (
|
||||
!"should never happen",
|
||||
"cmd must be one of OPEN,CLOSE,WRITE"
|
||||
);
|
||||
qse_sed_seterrnum (sed, QSE_SED_EINTERN, QSE_NULL);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
int qse_sed_compstd (qse_sed_t* sed, qse_sed_iostd_t in[], qse_size_t* count)
|
||||
{
|
||||
xtn_t* xtn = GET_XTN(sed);
|
||||
int ret;
|
||||
|
||||
if (in == QSE_NULL)
|
||||
{
|
||||
/* it requires a valid array unlike qse_sed_execstd(). */
|
||||
qse_sed_seterrnum (sed, QSE_SED_EINVAL, QSE_NULL);
|
||||
return -1;
|
||||
}
|
||||
if (verify_iostd_in (sed, in) <= -1) return -1;
|
||||
|
||||
QSE_MEMSET (&xtn->s, 0, QSE_SIZEOF(xtn->s));
|
||||
xtn->s.in.ptr = in;
|
||||
xtn->s.in.cur = in;
|
||||
|
||||
ret = qse_sed_comp (sed, s_in);
|
||||
|
||||
if (count) *count = xtn->s.in.cur - xtn->s.in.ptr;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int qse_sed_execstd (
|
||||
qse_sed_t* sed, qse_sed_iostd_t in[], qse_sed_iostd_t* out)
|
||||
{
|
||||
int n;
|
||||
xtn_t* xtn = GET_XTN(sed);
|
||||
|
||||
if (in && verify_iostd_in (sed, in) <= -1) return -1;
|
||||
|
||||
if (out)
|
||||
{
|
||||
if (out->type != QSE_SED_IOSTD_FILE &&
|
||||
out->type != QSE_SED_IOSTD_STR &&
|
||||
out->type != QSE_SED_IOSTD_SIO)
|
||||
{
|
||||
qse_sed_seterrnum (sed, QSE_SED_EINVAL, QSE_NULL);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
QSE_MEMSET (&xtn->e, 0, QSE_SIZEOF(xtn->e));
|
||||
xtn->e.in.ptr = in;
|
||||
xtn->e.in.cur = in;
|
||||
xtn->e.out.ptr = out;
|
||||
|
||||
n = qse_sed_exec (sed, x_in, x_out);
|
||||
|
||||
if (out && out->type == QSE_SED_IOSTD_STR)
|
||||
{
|
||||
if (n >= 0)
|
||||
{
|
||||
QSE_ASSERT (xtn->e.out.memstr != QSE_NULL);
|
||||
qse_str_yield (xtn->e.out.memstr, &out->u.str, 0);
|
||||
}
|
||||
if (xtn->e.out.memstr) qse_str_close (xtn->e.out.memstr);
|
||||
}
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
int qse_sed_compstdfile (
|
||||
qse_sed_t* sed, const qse_char_t* file, qse_cmgr_t* cmgr)
|
||||
{
|
||||
qse_sed_iostd_t in[2];
|
||||
|
||||
in[0].type = QSE_SED_IOSTD_FILE;
|
||||
in[0].u.file.path = file;
|
||||
in[0].u.file.cmgr = cmgr;
|
||||
in[1].type = QSE_SED_IOSTD_NULL;
|
||||
|
||||
return qse_sed_compstd (sed, in, QSE_NULL);
|
||||
}
|
||||
|
||||
int qse_sed_compstdstr (qse_sed_t* sed, const qse_char_t* script)
|
||||
{
|
||||
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 = qse_strlen(script);
|
||||
in[1].type = QSE_SED_IOSTD_NULL;
|
||||
|
||||
return qse_sed_compstd (sed, in, QSE_NULL);
|
||||
}
|
||||
|
||||
int qse_sed_compstdxstr (qse_sed_t* sed, const qse_cstr_t* script)
|
||||
{
|
||||
qse_sed_iostd_t in[2];
|
||||
|
||||
in[0].type = QSE_SED_IOSTD_STR;
|
||||
in[0].u.str = *script;
|
||||
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)
|
||||
{
|
||||
qse_sed_iostd_t in[2];
|
||||
qse_sed_iostd_t out;
|
||||
qse_sed_iostd_t* pin = QSE_NULL, * pout = QSE_NULL;
|
||||
|
||||
if (infile)
|
||||
{
|
||||
in[0].type = QSE_SED_IOSTD_FILE;
|
||||
in[0].u.file.path = infile;
|
||||
in[0].u.file.cmgr = cmgr;
|
||||
in[1].type = QSE_SED_IOSTD_NULL;
|
||||
pin = in;
|
||||
}
|
||||
|
||||
if (outfile)
|
||||
{
|
||||
out.type = QSE_SED_IOSTD_FILE;
|
||||
out.u.file.path = outfile;
|
||||
out.u.file.cmgr = cmgr;
|
||||
pout = &out;
|
||||
}
|
||||
|
||||
return qse_sed_execstd (sed, pin, pout);
|
||||
}
|
||||
|
||||
int qse_sed_execstdxstr (
|
||||
qse_sed_t* sed, const qse_cstr_t* instr,
|
||||
qse_cstr_t* outstr, qse_cmgr_t* cmgr)
|
||||
{
|
||||
qse_sed_iostd_t in[2];
|
||||
qse_sed_iostd_t out;
|
||||
int n;
|
||||
|
||||
in[0].type = QSE_SED_IOSTD_STR;
|
||||
in[0].u.str = *instr;
|
||||
in[1].type = QSE_SED_IOSTD_NULL;
|
||||
|
||||
out.type = QSE_SED_IOSTD_STR;
|
||||
|
||||
n = qse_sed_execstd (sed, in, &out);
|
||||
|
||||
if (n >= 0) *outstr = out.u.str;
|
||||
|
||||
return n;
|
||||
}
|
Reference in New Issue
Block a user