updated samples and docs
This commit is contained in:
parent
dfafdc4656
commit
19b4e697af
@ -15,3 +15,5 @@ EXTRA_DIST = \
|
|||||||
page/sed.doc \
|
page/sed.doc \
|
||||||
image/qse-logo.png
|
image/qse-logo.png
|
||||||
|
|
||||||
|
all:
|
||||||
|
doxygen
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
Embedding Guide {#embedding-guide}
|
QSEAWK Embedding Guide {#awk-embed}
|
||||||
================================================================================
|
================================================================================
|
||||||
|
|
||||||
Overview
|
Overview
|
||||||
@ -28,7 +28,7 @@ Embedding QSEAWK involves the following steps in the simplest form:
|
|||||||
The sample below follows these steps using as many standard layer functions as
|
The sample below follows these steps using as many standard layer functions as
|
||||||
possible for convenience sake. It simply prints *hello, world* to the console.
|
possible for convenience sake. It simply prints *hello, world* to the console.
|
||||||
|
|
||||||
\includelineno awk01.c
|
\includelineno awk01.c
|
||||||
|
|
||||||
Separation of the awk object and the runtime context was devised to deal with
|
Separation of the awk object and the runtime context was devised to deal with
|
||||||
such cases as you want to reuse the same script over different data streams.
|
such cases as you want to reuse the same script over different data streams.
|
||||||
@ -47,11 +47,52 @@ to override the callback functions implemented by qse_awk_rtx_openstd()
|
|||||||
partially. This sample redefines the console handler while keeping the file
|
partially. This sample redefines the console handler while keeping the file
|
||||||
and pipe handler by qse_awk_rtx_openstd().
|
and pipe handler by qse_awk_rtx_openstd().
|
||||||
|
|
||||||
\includelineno awk02.c
|
\includelineno awk02.c
|
||||||
|
|
||||||
|
Entry Point
|
||||||
|
-----------
|
||||||
|
|
||||||
Changes
|
A typical AWK program executes BEGIN, patten-action, END blocks. QSEAWK provides
|
||||||
-------
|
a way to drive a AWK program in a different style. That is, you can execute
|
||||||
|
a particular user-defined function on demand. It can be useful if you want
|
||||||
|
to drive an AWK program in an event-driven mannger though you can free to
|
||||||
|
change the entry point for your preference. The qse_awk_rtx_call() function
|
||||||
|
used is limited to user-defined functions. It is not able to call built-in
|
||||||
|
functions like *gsub* or *index*.
|
||||||
|
|
||||||
|
\includelineno awk03.c
|
||||||
|
|
||||||
|
If you want to pass arguments to the function you call with qse_awk_rtx_call(),
|
||||||
|
you must create values with value creation functions, updates their reference
|
||||||
|
count, and pass them to qse_awk_rtx_call(). The sample below creates 2 integer
|
||||||
|
values with qse_awk_rtx_makeintval() and pass them to the *pow* function.
|
||||||
|
|
||||||
|
\includelineno awk04.c
|
||||||
|
|
||||||
|
While qse_awk_rtx_call() looks up a function in the function table by name,
|
||||||
|
you can find the function in advance and use the information found when
|
||||||
|
calling a function. qse_awk_rtx_findfun() and qse_awk_rtx_callfun() come
|
||||||
|
to play a role in this situation. qse_awk_rtx_call() in the sample above
|
||||||
|
can be translated into 2 separate calls to qse_awk_rtx_findfun() and
|
||||||
|
qse_awk_rtx_callfun(). You can reduce look-up overhead via these 2
|
||||||
|
functions if you have to execute the same function multiple times.
|
||||||
|
|
||||||
|
\includelineno awk05.c
|
||||||
|
|
||||||
|
Global Variables
|
||||||
|
----------------
|
||||||
|
|
||||||
|
You can add built-in global variables with qse_awk_addgbl().
|
||||||
|
Use qse_awk_getgbl() to get information.
|
||||||
|
|
||||||
|
Built-in Functions
|
||||||
|
------------------
|
||||||
|
|
||||||
|
You can add built-in functions with qse_awk_addfnc().
|
||||||
|
On the other hand, modular built-in functions reside in a shared object.
|
||||||
|
|
||||||
|
Changes in 0.6.0
|
||||||
|
----------------
|
||||||
|
|
||||||
### qse_awk_parsestd() ###
|
### qse_awk_parsestd() ###
|
||||||
|
|
||||||
@ -63,7 +104,7 @@ In 0.5.6, it accepted a single script.
|
|||||||
psin.u.str.len = qse_strlen(src);
|
psin.u.str.len = qse_strlen(src);
|
||||||
qse_awk_parsestd (awk, &psin, QSE_NULL);
|
qse_awk_parsestd (awk, &psin, QSE_NULL);
|
||||||
|
|
||||||
In 0.6.0 or later, it accepts an array of scripts.
|
In 0.6.X, it accepts an array of scripts.
|
||||||
|
|
||||||
qse_awk_parsestd_t psin[2];
|
qse_awk_parsestd_t psin[2];
|
||||||
psin[0].type = QSE_AWK_PARSESTD_STR;
|
psin[0].type = QSE_AWK_PARSESTD_STR;
|
||||||
@ -73,6 +114,8 @@ In 0.6.0 or later, it accepts an array of scripts.
|
|||||||
qse_awk_parsestd (awk, psin, QSE_NULL)
|
qse_awk_parsestd (awk, psin, QSE_NULL)
|
||||||
|
|
||||||
### qse_awk_parsestd_t ###
|
### qse_awk_parsestd_t ###
|
||||||
|
|
||||||
the cmgr field moved from the union member file to the outer structure.
|
the cmgr field moved from the union member file to the outer structure.
|
||||||
|
|
||||||
|
### 0 upon Opening ###
|
||||||
|
I/O handlers can return 0 for success upon opening.
|
||||||
|
@ -27,4 +27,5 @@ See the subpages for more information.
|
|||||||
- @subpage awk "AWK Interpreter"
|
- @subpage awk "AWK Interpreter"
|
||||||
- @subpage sed "SED Stream Editor"
|
- @subpage sed "SED Stream Editor"
|
||||||
- @subpage awk-lang
|
- @subpage awk-lang
|
||||||
|
- @subpage awk-embed
|
||||||
|
|
||||||
|
@ -1898,7 +1898,7 @@ QSE_EXPORT qse_awk_fun_t* qse_awk_rtx_findfun (
|
|||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The qse_awk_rtx_callfun() function invokdes an AWK function described by
|
* The qse_awk_rtx_callfun() function invokes an AWK function described by
|
||||||
* the structure pointed to by @a fun.
|
* the structure pointed to by @a fun.
|
||||||
* @sa qse_awk_rtx_call
|
* @sa qse_awk_rtx_call
|
||||||
*/
|
*/
|
||||||
@ -1913,17 +1913,17 @@ QSE_EXPORT qse_awk_val_t* qse_awk_rtx_callfun (
|
|||||||
* The qse_awk_rtx_call() function invokes an AWK function named @a name.
|
* The qse_awk_rtx_call() function invokes an AWK function named @a name.
|
||||||
* However, it is not able to invoke an intrinsic function such as split().
|
* However, it is not able to invoke an intrinsic function such as split().
|
||||||
* The #QSE_AWK_PABLOCK option can be turned off to make illegal the BEGIN
|
* The #QSE_AWK_PABLOCK option can be turned off to make illegal the BEGIN
|
||||||
* block, the pattern-action blocks, and the END block.
|
* blocks, the pattern-action blocks, and the END blocks.
|
||||||
*
|
*
|
||||||
* The example shows typical usage of the function.
|
* The example shows typical usage of the function.
|
||||||
* @code
|
* @code
|
||||||
* rtx = qse_awk_rtx_open (awk, 0, rio, QSE_NULL);
|
* rtx = qse_awk_rtx_open (awk, 0, rio, QSE_NULL);
|
||||||
* if (rtx != QSE_NULL)
|
* if (rtx)
|
||||||
* {
|
* {
|
||||||
* v = qse_awk_rtx_call (rtx, QSE_T("init"), QSE_NULL, 0);
|
* v = qse_awk_rtx_call (rtx, QSE_T("init"), QSE_NULL, 0);
|
||||||
* if (v != QSE_NULL) qse_awk_rtx_refdownval (rtx, v);
|
* if (v) qse_awk_rtx_refdownval (rtx, v);
|
||||||
* qse_awk_rtx_call (rtx, QSE_T("fini"), QSE_NULL, 0);
|
* qse_awk_rtx_call (rtx, QSE_T("fini"), QSE_NULL, 0);
|
||||||
* if (v != QSE_NULL) qse_awk_rtx_refdownval (rtx, v);
|
* if (v) qse_awk_rtx_refdownval (rtx, v);
|
||||||
* qse_awk_rtx_close (rtx);
|
* qse_awk_rtx_close (rtx);
|
||||||
* }
|
* }
|
||||||
* @endcode
|
* @endcode
|
||||||
|
@ -49,8 +49,8 @@
|
|||||||
*/
|
*/
|
||||||
enum qse_awk_parsestd_type_t
|
enum qse_awk_parsestd_type_t
|
||||||
{
|
{
|
||||||
QSE_AWK_PARSESTD_NULL = 0, /**< invalid type */
|
QSE_AWK_PARSESTD_NULL = 0, /**< pseudo-value to indicate no script */
|
||||||
QSE_AWK_PARSESTD_FILE = 1, /**< files */
|
QSE_AWK_PARSESTD_FILE = 1, /**< script file */
|
||||||
QSE_AWK_PARSESTD_STR = 2 /**< length-bounded string */
|
QSE_AWK_PARSESTD_STR = 2 /**< length-bounded string */
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -67,7 +67,7 @@ struct qse_awk_parsestd_t
|
|||||||
{
|
{
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
/** file path to open. QSE_NULL or '-' for stdin/stdout. */
|
/** file path to open. #QSE_NULL or '-' for stdin/stdout. */
|
||||||
const qse_char_t* path;
|
const qse_char_t* path;
|
||||||
} file;
|
} file;
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@ AM_CPPFLAGS = \
|
|||||||
-I$(top_srcdir)/include \
|
-I$(top_srcdir)/include \
|
||||||
-I$(includedir)
|
-I$(includedir)
|
||||||
|
|
||||||
bin_PROGRAMS = awk01 awk02 awk03 awk04 awk09 awk10 awk11 awk15
|
bin_PROGRAMS = awk01 awk02 awk03 awk04 awk05 awk09 awk10 awk11 awk15
|
||||||
|
|
||||||
LDFLAGS = -L../../lib/awk -L../../lib/cmn
|
LDFLAGS = -L../../lib/awk -L../../lib/cmn
|
||||||
LDADD = -lqseawk -lqsecmn $(LIBM)
|
LDADD = -lqseawk -lqsecmn $(LIBM)
|
||||||
@ -20,6 +20,7 @@ awk01_SOURCES = awk01.c
|
|||||||
awk02_SOURCES = awk02.c
|
awk02_SOURCES = awk02.c
|
||||||
awk03_SOURCES = awk03.c
|
awk03_SOURCES = awk03.c
|
||||||
awk04_SOURCES = awk04.c
|
awk04_SOURCES = awk04.c
|
||||||
|
awk05_SOURCES = awk05.c
|
||||||
awk09_SOURCES = awk09.c
|
awk09_SOURCES = awk09.c
|
||||||
awk10_SOURCES = awk10.c
|
awk10_SOURCES = awk10.c
|
||||||
awk11_SOURCES = awk11.c
|
awk11_SOURCES = awk11.c
|
||||||
@ -29,21 +30,21 @@ if ENABLE_CXX
|
|||||||
|
|
||||||
CXXLIB = -lqseawkxx -lqsecmnxx
|
CXXLIB = -lqseawkxx -lqsecmnxx
|
||||||
|
|
||||||
bin_PROGRAMS += awk05 awk06 awk07 awk08 awk12 awk13 awk14
|
bin_PROGRAMS += awk21 awk22 awk23 awk24 awk25 awk26 awk27
|
||||||
|
|
||||||
awk05_SOURCES = awk05.cpp
|
awk21_SOURCES = awk21.cpp
|
||||||
awk06_SOURCES = awk06.cpp
|
awk22_SOURCES = awk22.cpp
|
||||||
awk07_SOURCES = awk07.cpp
|
awk23_SOURCES = awk23.cpp
|
||||||
awk08_SOURCES = awk08.cpp
|
awk24_SOURCES = awk24.cpp
|
||||||
awk12_SOURCES = awk12.cpp
|
awk25_SOURCES = awk25.cpp
|
||||||
awk13_SOURCES = awk13.cpp
|
awk26_SOURCES = awk26.cpp
|
||||||
awk14_SOURCES = awk14.cpp
|
awk27_SOURCES = awk27.cpp
|
||||||
|
|
||||||
awk05_LDADD = $(CXXLIB) $(LDADD)
|
awk21_LDADD = $(CXXLIB) $(LDADD)
|
||||||
awk06_LDADD = $(CXXLIB) $(LDADD)
|
awk22_LDADD = $(CXXLIB) $(LDADD)
|
||||||
awk07_LDADD = $(CXXLIB) $(LDADD)
|
awk23_LDADD = $(CXXLIB) $(LDADD)
|
||||||
awk08_LDADD = $(CXXLIB) $(LDADD)
|
awk24_LDADD = $(CXXLIB) $(LDADD)
|
||||||
awk12_LDADD = $(CXXLIB) $(LDADD)
|
awk25_LDADD = $(CXXLIB) $(LDADD)
|
||||||
awk13_LDADD = $(CXXLIB) $(LDADD)
|
awk26_LDADD = $(CXXLIB) $(LDADD)
|
||||||
awk14_LDADD = $(CXXLIB) $(LDADD)
|
awk27_LDADD = $(CXXLIB) $(LDADD)
|
||||||
endif
|
endif
|
||||||
|
@ -35,10 +35,10 @@ POST_UNINSTALL = :
|
|||||||
build_triplet = @build@
|
build_triplet = @build@
|
||||||
host_triplet = @host@
|
host_triplet = @host@
|
||||||
bin_PROGRAMS = awk01$(EXEEXT) awk02$(EXEEXT) awk03$(EXEEXT) \
|
bin_PROGRAMS = awk01$(EXEEXT) awk02$(EXEEXT) awk03$(EXEEXT) \
|
||||||
awk04$(EXEEXT) awk09$(EXEEXT) awk10$(EXEEXT) awk11$(EXEEXT) \
|
awk04$(EXEEXT) awk05$(EXEEXT) awk09$(EXEEXT) awk10$(EXEEXT) \
|
||||||
awk15$(EXEEXT) $(am__EXEEXT_1)
|
awk11$(EXEEXT) awk15$(EXEEXT) $(am__EXEEXT_1)
|
||||||
@WCHAR_TRUE@@WIN32_TRUE@am__append_1 = $(UNICOWS_LIBS)
|
@WCHAR_TRUE@@WIN32_TRUE@am__append_1 = $(UNICOWS_LIBS)
|
||||||
@ENABLE_CXX_TRUE@am__append_2 = awk05 awk06 awk07 awk08 awk12 awk13 awk14
|
@ENABLE_CXX_TRUE@am__append_2 = awk21 awk22 awk23 awk24 awk25 awk26 awk27
|
||||||
subdir = samples/awk
|
subdir = samples/awk
|
||||||
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
|
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
|
||||||
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
|
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
|
||||||
@ -54,9 +54,9 @@ mkinstalldirs = $(install_sh) -d
|
|||||||
CONFIG_HEADER = $(top_builddir)/include/qse/config.h
|
CONFIG_HEADER = $(top_builddir)/include/qse/config.h
|
||||||
CONFIG_CLEAN_FILES =
|
CONFIG_CLEAN_FILES =
|
||||||
CONFIG_CLEAN_VPATH_FILES =
|
CONFIG_CLEAN_VPATH_FILES =
|
||||||
@ENABLE_CXX_TRUE@am__EXEEXT_1 = awk05$(EXEEXT) awk06$(EXEEXT) \
|
@ENABLE_CXX_TRUE@am__EXEEXT_1 = awk21$(EXEEXT) awk22$(EXEEXT) \
|
||||||
@ENABLE_CXX_TRUE@ awk07$(EXEEXT) awk08$(EXEEXT) awk12$(EXEEXT) \
|
@ENABLE_CXX_TRUE@ awk23$(EXEEXT) awk24$(EXEEXT) awk25$(EXEEXT) \
|
||||||
@ENABLE_CXX_TRUE@ awk13$(EXEEXT) awk14$(EXEEXT)
|
@ENABLE_CXX_TRUE@ awk26$(EXEEXT) awk27$(EXEEXT)
|
||||||
am__installdirs = "$(DESTDIR)$(bindir)"
|
am__installdirs = "$(DESTDIR)$(bindir)"
|
||||||
PROGRAMS = $(bin_PROGRAMS)
|
PROGRAMS = $(bin_PROGRAMS)
|
||||||
am_awk01_OBJECTS = awk01.$(OBJEXT)
|
am_awk01_OBJECTS = awk01.$(OBJEXT)
|
||||||
@ -77,27 +77,10 @@ am_awk04_OBJECTS = awk04.$(OBJEXT)
|
|||||||
awk04_OBJECTS = $(am_awk04_OBJECTS)
|
awk04_OBJECTS = $(am_awk04_OBJECTS)
|
||||||
awk04_LDADD = $(LDADD)
|
awk04_LDADD = $(LDADD)
|
||||||
awk04_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_2)
|
awk04_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_2)
|
||||||
am__awk05_SOURCES_DIST = awk05.cpp
|
am_awk05_OBJECTS = awk05.$(OBJEXT)
|
||||||
@ENABLE_CXX_TRUE@am_awk05_OBJECTS = awk05.$(OBJEXT)
|
|
||||||
awk05_OBJECTS = $(am_awk05_OBJECTS)
|
awk05_OBJECTS = $(am_awk05_OBJECTS)
|
||||||
am__DEPENDENCIES_3 = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_2)
|
awk05_LDADD = $(LDADD)
|
||||||
@ENABLE_CXX_TRUE@awk05_DEPENDENCIES = $(am__DEPENDENCIES_1) \
|
awk05_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_2)
|
||||||
@ENABLE_CXX_TRUE@ $(am__DEPENDENCIES_3)
|
|
||||||
am__awk06_SOURCES_DIST = awk06.cpp
|
|
||||||
@ENABLE_CXX_TRUE@am_awk06_OBJECTS = awk06.$(OBJEXT)
|
|
||||||
awk06_OBJECTS = $(am_awk06_OBJECTS)
|
|
||||||
@ENABLE_CXX_TRUE@awk06_DEPENDENCIES = $(am__DEPENDENCIES_1) \
|
|
||||||
@ENABLE_CXX_TRUE@ $(am__DEPENDENCIES_3)
|
|
||||||
am__awk07_SOURCES_DIST = awk07.cpp
|
|
||||||
@ENABLE_CXX_TRUE@am_awk07_OBJECTS = awk07.$(OBJEXT)
|
|
||||||
awk07_OBJECTS = $(am_awk07_OBJECTS)
|
|
||||||
@ENABLE_CXX_TRUE@awk07_DEPENDENCIES = $(am__DEPENDENCIES_1) \
|
|
||||||
@ENABLE_CXX_TRUE@ $(am__DEPENDENCIES_3)
|
|
||||||
am__awk08_SOURCES_DIST = awk08.cpp
|
|
||||||
@ENABLE_CXX_TRUE@am_awk08_OBJECTS = awk08.$(OBJEXT)
|
|
||||||
awk08_OBJECTS = $(am_awk08_OBJECTS)
|
|
||||||
@ENABLE_CXX_TRUE@awk08_DEPENDENCIES = $(am__DEPENDENCIES_1) \
|
|
||||||
@ENABLE_CXX_TRUE@ $(am__DEPENDENCIES_3)
|
|
||||||
am_awk09_OBJECTS = awk09.$(OBJEXT)
|
am_awk09_OBJECTS = awk09.$(OBJEXT)
|
||||||
awk09_OBJECTS = $(am_awk09_OBJECTS)
|
awk09_OBJECTS = $(am_awk09_OBJECTS)
|
||||||
awk09_LDADD = $(LDADD)
|
awk09_LDADD = $(LDADD)
|
||||||
@ -110,25 +93,46 @@ am_awk11_OBJECTS = awk11.$(OBJEXT)
|
|||||||
awk11_OBJECTS = $(am_awk11_OBJECTS)
|
awk11_OBJECTS = $(am_awk11_OBJECTS)
|
||||||
awk11_LDADD = $(LDADD)
|
awk11_LDADD = $(LDADD)
|
||||||
awk11_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_2)
|
awk11_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_2)
|
||||||
am__awk12_SOURCES_DIST = awk12.cpp
|
|
||||||
@ENABLE_CXX_TRUE@am_awk12_OBJECTS = awk12.$(OBJEXT)
|
|
||||||
awk12_OBJECTS = $(am_awk12_OBJECTS)
|
|
||||||
@ENABLE_CXX_TRUE@awk12_DEPENDENCIES = $(am__DEPENDENCIES_1) \
|
|
||||||
@ENABLE_CXX_TRUE@ $(am__DEPENDENCIES_3)
|
|
||||||
am__awk13_SOURCES_DIST = awk13.cpp
|
|
||||||
@ENABLE_CXX_TRUE@am_awk13_OBJECTS = awk13.$(OBJEXT)
|
|
||||||
awk13_OBJECTS = $(am_awk13_OBJECTS)
|
|
||||||
@ENABLE_CXX_TRUE@awk13_DEPENDENCIES = $(am__DEPENDENCIES_1) \
|
|
||||||
@ENABLE_CXX_TRUE@ $(am__DEPENDENCIES_3)
|
|
||||||
am__awk14_SOURCES_DIST = awk14.cpp
|
|
||||||
@ENABLE_CXX_TRUE@am_awk14_OBJECTS = awk14.$(OBJEXT)
|
|
||||||
awk14_OBJECTS = $(am_awk14_OBJECTS)
|
|
||||||
@ENABLE_CXX_TRUE@awk14_DEPENDENCIES = $(am__DEPENDENCIES_1) \
|
|
||||||
@ENABLE_CXX_TRUE@ $(am__DEPENDENCIES_3)
|
|
||||||
am_awk15_OBJECTS = awk15.$(OBJEXT)
|
am_awk15_OBJECTS = awk15.$(OBJEXT)
|
||||||
awk15_OBJECTS = $(am_awk15_OBJECTS)
|
awk15_OBJECTS = $(am_awk15_OBJECTS)
|
||||||
awk15_LDADD = $(LDADD)
|
awk15_LDADD = $(LDADD)
|
||||||
awk15_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_2)
|
awk15_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_2)
|
||||||
|
am__awk21_SOURCES_DIST = awk21.cpp
|
||||||
|
@ENABLE_CXX_TRUE@am_awk21_OBJECTS = awk21.$(OBJEXT)
|
||||||
|
awk21_OBJECTS = $(am_awk21_OBJECTS)
|
||||||
|
am__DEPENDENCIES_3 = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_2)
|
||||||
|
@ENABLE_CXX_TRUE@awk21_DEPENDENCIES = $(am__DEPENDENCIES_1) \
|
||||||
|
@ENABLE_CXX_TRUE@ $(am__DEPENDENCIES_3)
|
||||||
|
am__awk22_SOURCES_DIST = awk22.cpp
|
||||||
|
@ENABLE_CXX_TRUE@am_awk22_OBJECTS = awk22.$(OBJEXT)
|
||||||
|
awk22_OBJECTS = $(am_awk22_OBJECTS)
|
||||||
|
@ENABLE_CXX_TRUE@awk22_DEPENDENCIES = $(am__DEPENDENCIES_1) \
|
||||||
|
@ENABLE_CXX_TRUE@ $(am__DEPENDENCIES_3)
|
||||||
|
am__awk23_SOURCES_DIST = awk23.cpp
|
||||||
|
@ENABLE_CXX_TRUE@am_awk23_OBJECTS = awk23.$(OBJEXT)
|
||||||
|
awk23_OBJECTS = $(am_awk23_OBJECTS)
|
||||||
|
@ENABLE_CXX_TRUE@awk23_DEPENDENCIES = $(am__DEPENDENCIES_1) \
|
||||||
|
@ENABLE_CXX_TRUE@ $(am__DEPENDENCIES_3)
|
||||||
|
am__awk24_SOURCES_DIST = awk24.cpp
|
||||||
|
@ENABLE_CXX_TRUE@am_awk24_OBJECTS = awk24.$(OBJEXT)
|
||||||
|
awk24_OBJECTS = $(am_awk24_OBJECTS)
|
||||||
|
@ENABLE_CXX_TRUE@awk24_DEPENDENCIES = $(am__DEPENDENCIES_1) \
|
||||||
|
@ENABLE_CXX_TRUE@ $(am__DEPENDENCIES_3)
|
||||||
|
am__awk25_SOURCES_DIST = awk25.cpp
|
||||||
|
@ENABLE_CXX_TRUE@am_awk25_OBJECTS = awk25.$(OBJEXT)
|
||||||
|
awk25_OBJECTS = $(am_awk25_OBJECTS)
|
||||||
|
@ENABLE_CXX_TRUE@awk25_DEPENDENCIES = $(am__DEPENDENCIES_1) \
|
||||||
|
@ENABLE_CXX_TRUE@ $(am__DEPENDENCIES_3)
|
||||||
|
am__awk26_SOURCES_DIST = awk26.cpp
|
||||||
|
@ENABLE_CXX_TRUE@am_awk26_OBJECTS = awk26.$(OBJEXT)
|
||||||
|
awk26_OBJECTS = $(am_awk26_OBJECTS)
|
||||||
|
@ENABLE_CXX_TRUE@awk26_DEPENDENCIES = $(am__DEPENDENCIES_1) \
|
||||||
|
@ENABLE_CXX_TRUE@ $(am__DEPENDENCIES_3)
|
||||||
|
am__awk27_SOURCES_DIST = awk27.cpp
|
||||||
|
@ENABLE_CXX_TRUE@am_awk27_OBJECTS = awk27.$(OBJEXT)
|
||||||
|
awk27_OBJECTS = $(am_awk27_OBJECTS)
|
||||||
|
@ENABLE_CXX_TRUE@awk27_DEPENDENCIES = $(am__DEPENDENCIES_1) \
|
||||||
|
@ENABLE_CXX_TRUE@ $(am__DEPENDENCIES_3)
|
||||||
DEFAULT_INCLUDES =
|
DEFAULT_INCLUDES =
|
||||||
depcomp = $(SHELL) $(top_srcdir)/ac/depcomp
|
depcomp = $(SHELL) $(top_srcdir)/ac/depcomp
|
||||||
am__depfiles_maybe = depfiles
|
am__depfiles_maybe = depfiles
|
||||||
@ -152,17 +156,18 @@ CXXLINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
|
|||||||
--mode=link $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
|
--mode=link $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
|
||||||
$(LDFLAGS) -o $@
|
$(LDFLAGS) -o $@
|
||||||
SOURCES = $(awk01_SOURCES) $(awk02_SOURCES) $(awk03_SOURCES) \
|
SOURCES = $(awk01_SOURCES) $(awk02_SOURCES) $(awk03_SOURCES) \
|
||||||
$(awk04_SOURCES) $(awk05_SOURCES) $(awk06_SOURCES) \
|
$(awk04_SOURCES) $(awk05_SOURCES) $(awk09_SOURCES) \
|
||||||
$(awk07_SOURCES) $(awk08_SOURCES) $(awk09_SOURCES) \
|
$(awk10_SOURCES) $(awk11_SOURCES) $(awk15_SOURCES) \
|
||||||
$(awk10_SOURCES) $(awk11_SOURCES) $(awk12_SOURCES) \
|
$(awk21_SOURCES) $(awk22_SOURCES) $(awk23_SOURCES) \
|
||||||
$(awk13_SOURCES) $(awk14_SOURCES) $(awk15_SOURCES)
|
$(awk24_SOURCES) $(awk25_SOURCES) $(awk26_SOURCES) \
|
||||||
|
$(awk27_SOURCES)
|
||||||
DIST_SOURCES = $(awk01_SOURCES) $(awk02_SOURCES) $(awk03_SOURCES) \
|
DIST_SOURCES = $(awk01_SOURCES) $(awk02_SOURCES) $(awk03_SOURCES) \
|
||||||
$(awk04_SOURCES) $(am__awk05_SOURCES_DIST) \
|
$(awk04_SOURCES) $(awk05_SOURCES) $(awk09_SOURCES) \
|
||||||
$(am__awk06_SOURCES_DIST) $(am__awk07_SOURCES_DIST) \
|
$(awk10_SOURCES) $(awk11_SOURCES) $(awk15_SOURCES) \
|
||||||
$(am__awk08_SOURCES_DIST) $(awk09_SOURCES) $(awk10_SOURCES) \
|
$(am__awk21_SOURCES_DIST) $(am__awk22_SOURCES_DIST) \
|
||||||
$(awk11_SOURCES) $(am__awk12_SOURCES_DIST) \
|
$(am__awk23_SOURCES_DIST) $(am__awk24_SOURCES_DIST) \
|
||||||
$(am__awk13_SOURCES_DIST) $(am__awk14_SOURCES_DIST) \
|
$(am__awk25_SOURCES_DIST) $(am__awk26_SOURCES_DIST) \
|
||||||
$(awk15_SOURCES)
|
$(am__awk27_SOURCES_DIST)
|
||||||
ETAGS = etags
|
ETAGS = etags
|
||||||
CTAGS = ctags
|
CTAGS = ctags
|
||||||
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
|
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
|
||||||
@ -348,25 +353,26 @@ awk01_SOURCES = awk01.c
|
|||||||
awk02_SOURCES = awk02.c
|
awk02_SOURCES = awk02.c
|
||||||
awk03_SOURCES = awk03.c
|
awk03_SOURCES = awk03.c
|
||||||
awk04_SOURCES = awk04.c
|
awk04_SOURCES = awk04.c
|
||||||
|
awk05_SOURCES = awk05.c
|
||||||
awk09_SOURCES = awk09.c
|
awk09_SOURCES = awk09.c
|
||||||
awk10_SOURCES = awk10.c
|
awk10_SOURCES = awk10.c
|
||||||
awk11_SOURCES = awk11.c
|
awk11_SOURCES = awk11.c
|
||||||
awk15_SOURCES = awk15.c
|
awk15_SOURCES = awk15.c
|
||||||
@ENABLE_CXX_TRUE@CXXLIB = -lqseawkxx -lqsecmnxx
|
@ENABLE_CXX_TRUE@CXXLIB = -lqseawkxx -lqsecmnxx
|
||||||
@ENABLE_CXX_TRUE@awk05_SOURCES = awk05.cpp
|
@ENABLE_CXX_TRUE@awk21_SOURCES = awk21.cpp
|
||||||
@ENABLE_CXX_TRUE@awk06_SOURCES = awk06.cpp
|
@ENABLE_CXX_TRUE@awk22_SOURCES = awk22.cpp
|
||||||
@ENABLE_CXX_TRUE@awk07_SOURCES = awk07.cpp
|
@ENABLE_CXX_TRUE@awk23_SOURCES = awk23.cpp
|
||||||
@ENABLE_CXX_TRUE@awk08_SOURCES = awk08.cpp
|
@ENABLE_CXX_TRUE@awk24_SOURCES = awk24.cpp
|
||||||
@ENABLE_CXX_TRUE@awk12_SOURCES = awk12.cpp
|
@ENABLE_CXX_TRUE@awk25_SOURCES = awk25.cpp
|
||||||
@ENABLE_CXX_TRUE@awk13_SOURCES = awk13.cpp
|
@ENABLE_CXX_TRUE@awk26_SOURCES = awk26.cpp
|
||||||
@ENABLE_CXX_TRUE@awk14_SOURCES = awk14.cpp
|
@ENABLE_CXX_TRUE@awk27_SOURCES = awk27.cpp
|
||||||
@ENABLE_CXX_TRUE@awk05_LDADD = $(CXXLIB) $(LDADD)
|
@ENABLE_CXX_TRUE@awk21_LDADD = $(CXXLIB) $(LDADD)
|
||||||
@ENABLE_CXX_TRUE@awk06_LDADD = $(CXXLIB) $(LDADD)
|
@ENABLE_CXX_TRUE@awk22_LDADD = $(CXXLIB) $(LDADD)
|
||||||
@ENABLE_CXX_TRUE@awk07_LDADD = $(CXXLIB) $(LDADD)
|
@ENABLE_CXX_TRUE@awk23_LDADD = $(CXXLIB) $(LDADD)
|
||||||
@ENABLE_CXX_TRUE@awk08_LDADD = $(CXXLIB) $(LDADD)
|
@ENABLE_CXX_TRUE@awk24_LDADD = $(CXXLIB) $(LDADD)
|
||||||
@ENABLE_CXX_TRUE@awk12_LDADD = $(CXXLIB) $(LDADD)
|
@ENABLE_CXX_TRUE@awk25_LDADD = $(CXXLIB) $(LDADD)
|
||||||
@ENABLE_CXX_TRUE@awk13_LDADD = $(CXXLIB) $(LDADD)
|
@ENABLE_CXX_TRUE@awk26_LDADD = $(CXXLIB) $(LDADD)
|
||||||
@ENABLE_CXX_TRUE@awk14_LDADD = $(CXXLIB) $(LDADD)
|
@ENABLE_CXX_TRUE@awk27_LDADD = $(CXXLIB) $(LDADD)
|
||||||
all: all-am
|
all: all-am
|
||||||
|
|
||||||
.SUFFIXES:
|
.SUFFIXES:
|
||||||
@ -458,16 +464,7 @@ awk04$(EXEEXT): $(awk04_OBJECTS) $(awk04_DEPENDENCIES) $(EXTRA_awk04_DEPENDENCIE
|
|||||||
$(LINK) $(awk04_OBJECTS) $(awk04_LDADD) $(LIBS)
|
$(LINK) $(awk04_OBJECTS) $(awk04_LDADD) $(LIBS)
|
||||||
awk05$(EXEEXT): $(awk05_OBJECTS) $(awk05_DEPENDENCIES) $(EXTRA_awk05_DEPENDENCIES)
|
awk05$(EXEEXT): $(awk05_OBJECTS) $(awk05_DEPENDENCIES) $(EXTRA_awk05_DEPENDENCIES)
|
||||||
@rm -f awk05$(EXEEXT)
|
@rm -f awk05$(EXEEXT)
|
||||||
$(CXXLINK) $(awk05_OBJECTS) $(awk05_LDADD) $(LIBS)
|
$(LINK) $(awk05_OBJECTS) $(awk05_LDADD) $(LIBS)
|
||||||
awk06$(EXEEXT): $(awk06_OBJECTS) $(awk06_DEPENDENCIES) $(EXTRA_awk06_DEPENDENCIES)
|
|
||||||
@rm -f awk06$(EXEEXT)
|
|
||||||
$(CXXLINK) $(awk06_OBJECTS) $(awk06_LDADD) $(LIBS)
|
|
||||||
awk07$(EXEEXT): $(awk07_OBJECTS) $(awk07_DEPENDENCIES) $(EXTRA_awk07_DEPENDENCIES)
|
|
||||||
@rm -f awk07$(EXEEXT)
|
|
||||||
$(CXXLINK) $(awk07_OBJECTS) $(awk07_LDADD) $(LIBS)
|
|
||||||
awk08$(EXEEXT): $(awk08_OBJECTS) $(awk08_DEPENDENCIES) $(EXTRA_awk08_DEPENDENCIES)
|
|
||||||
@rm -f awk08$(EXEEXT)
|
|
||||||
$(CXXLINK) $(awk08_OBJECTS) $(awk08_LDADD) $(LIBS)
|
|
||||||
awk09$(EXEEXT): $(awk09_OBJECTS) $(awk09_DEPENDENCIES) $(EXTRA_awk09_DEPENDENCIES)
|
awk09$(EXEEXT): $(awk09_OBJECTS) $(awk09_DEPENDENCIES) $(EXTRA_awk09_DEPENDENCIES)
|
||||||
@rm -f awk09$(EXEEXT)
|
@rm -f awk09$(EXEEXT)
|
||||||
$(LINK) $(awk09_OBJECTS) $(awk09_LDADD) $(LIBS)
|
$(LINK) $(awk09_OBJECTS) $(awk09_LDADD) $(LIBS)
|
||||||
@ -477,18 +474,30 @@ awk10$(EXEEXT): $(awk10_OBJECTS) $(awk10_DEPENDENCIES) $(EXTRA_awk10_DEPENDENCIE
|
|||||||
awk11$(EXEEXT): $(awk11_OBJECTS) $(awk11_DEPENDENCIES) $(EXTRA_awk11_DEPENDENCIES)
|
awk11$(EXEEXT): $(awk11_OBJECTS) $(awk11_DEPENDENCIES) $(EXTRA_awk11_DEPENDENCIES)
|
||||||
@rm -f awk11$(EXEEXT)
|
@rm -f awk11$(EXEEXT)
|
||||||
$(LINK) $(awk11_OBJECTS) $(awk11_LDADD) $(LIBS)
|
$(LINK) $(awk11_OBJECTS) $(awk11_LDADD) $(LIBS)
|
||||||
awk12$(EXEEXT): $(awk12_OBJECTS) $(awk12_DEPENDENCIES) $(EXTRA_awk12_DEPENDENCIES)
|
|
||||||
@rm -f awk12$(EXEEXT)
|
|
||||||
$(CXXLINK) $(awk12_OBJECTS) $(awk12_LDADD) $(LIBS)
|
|
||||||
awk13$(EXEEXT): $(awk13_OBJECTS) $(awk13_DEPENDENCIES) $(EXTRA_awk13_DEPENDENCIES)
|
|
||||||
@rm -f awk13$(EXEEXT)
|
|
||||||
$(CXXLINK) $(awk13_OBJECTS) $(awk13_LDADD) $(LIBS)
|
|
||||||
awk14$(EXEEXT): $(awk14_OBJECTS) $(awk14_DEPENDENCIES) $(EXTRA_awk14_DEPENDENCIES)
|
|
||||||
@rm -f awk14$(EXEEXT)
|
|
||||||
$(CXXLINK) $(awk14_OBJECTS) $(awk14_LDADD) $(LIBS)
|
|
||||||
awk15$(EXEEXT): $(awk15_OBJECTS) $(awk15_DEPENDENCIES) $(EXTRA_awk15_DEPENDENCIES)
|
awk15$(EXEEXT): $(awk15_OBJECTS) $(awk15_DEPENDENCIES) $(EXTRA_awk15_DEPENDENCIES)
|
||||||
@rm -f awk15$(EXEEXT)
|
@rm -f awk15$(EXEEXT)
|
||||||
$(LINK) $(awk15_OBJECTS) $(awk15_LDADD) $(LIBS)
|
$(LINK) $(awk15_OBJECTS) $(awk15_LDADD) $(LIBS)
|
||||||
|
awk21$(EXEEXT): $(awk21_OBJECTS) $(awk21_DEPENDENCIES) $(EXTRA_awk21_DEPENDENCIES)
|
||||||
|
@rm -f awk21$(EXEEXT)
|
||||||
|
$(CXXLINK) $(awk21_OBJECTS) $(awk21_LDADD) $(LIBS)
|
||||||
|
awk22$(EXEEXT): $(awk22_OBJECTS) $(awk22_DEPENDENCIES) $(EXTRA_awk22_DEPENDENCIES)
|
||||||
|
@rm -f awk22$(EXEEXT)
|
||||||
|
$(CXXLINK) $(awk22_OBJECTS) $(awk22_LDADD) $(LIBS)
|
||||||
|
awk23$(EXEEXT): $(awk23_OBJECTS) $(awk23_DEPENDENCIES) $(EXTRA_awk23_DEPENDENCIES)
|
||||||
|
@rm -f awk23$(EXEEXT)
|
||||||
|
$(CXXLINK) $(awk23_OBJECTS) $(awk23_LDADD) $(LIBS)
|
||||||
|
awk24$(EXEEXT): $(awk24_OBJECTS) $(awk24_DEPENDENCIES) $(EXTRA_awk24_DEPENDENCIES)
|
||||||
|
@rm -f awk24$(EXEEXT)
|
||||||
|
$(CXXLINK) $(awk24_OBJECTS) $(awk24_LDADD) $(LIBS)
|
||||||
|
awk25$(EXEEXT): $(awk25_OBJECTS) $(awk25_DEPENDENCIES) $(EXTRA_awk25_DEPENDENCIES)
|
||||||
|
@rm -f awk25$(EXEEXT)
|
||||||
|
$(CXXLINK) $(awk25_OBJECTS) $(awk25_LDADD) $(LIBS)
|
||||||
|
awk26$(EXEEXT): $(awk26_OBJECTS) $(awk26_DEPENDENCIES) $(EXTRA_awk26_DEPENDENCIES)
|
||||||
|
@rm -f awk26$(EXEEXT)
|
||||||
|
$(CXXLINK) $(awk26_OBJECTS) $(awk26_LDADD) $(LIBS)
|
||||||
|
awk27$(EXEEXT): $(awk27_OBJECTS) $(awk27_DEPENDENCIES) $(EXTRA_awk27_DEPENDENCIES)
|
||||||
|
@rm -f awk27$(EXEEXT)
|
||||||
|
$(CXXLINK) $(awk27_OBJECTS) $(awk27_LDADD) $(LIBS)
|
||||||
|
|
||||||
mostlyclean-compile:
|
mostlyclean-compile:
|
||||||
-rm -f *.$(OBJEXT)
|
-rm -f *.$(OBJEXT)
|
||||||
@ -501,16 +510,17 @@ distclean-compile:
|
|||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/awk03.Po@am__quote@
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/awk03.Po@am__quote@
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/awk04.Po@am__quote@
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/awk04.Po@am__quote@
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/awk05.Po@am__quote@
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/awk05.Po@am__quote@
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/awk06.Po@am__quote@
|
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/awk07.Po@am__quote@
|
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/awk08.Po@am__quote@
|
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/awk09.Po@am__quote@
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/awk09.Po@am__quote@
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/awk10.Po@am__quote@
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/awk10.Po@am__quote@
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/awk11.Po@am__quote@
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/awk11.Po@am__quote@
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/awk12.Po@am__quote@
|
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/awk13.Po@am__quote@
|
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/awk14.Po@am__quote@
|
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/awk15.Po@am__quote@
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/awk15.Po@am__quote@
|
||||||
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/awk21.Po@am__quote@
|
||||||
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/awk22.Po@am__quote@
|
||||||
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/awk23.Po@am__quote@
|
||||||
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/awk24.Po@am__quote@
|
||||||
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/awk25.Po@am__quote@
|
||||||
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/awk26.Po@am__quote@
|
||||||
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/awk27.Po@am__quote@
|
||||||
|
|
||||||
.c.o:
|
.c.o:
|
||||||
@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
|
@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
|
||||||
|
@ -19,6 +19,7 @@ int main ()
|
|||||||
goto oops;
|
goto oops;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* prepare a script to parse */
|
||||||
psin[0].type = QSE_AWK_PARSESTD_STR;
|
psin[0].type = QSE_AWK_PARSESTD_STR;
|
||||||
psin[0].u.str.ptr = script;
|
psin[0].u.str.ptr = script;
|
||||||
psin[0].u.str.len = qse_strlen(script);
|
psin[0].u.str.len = qse_strlen(script);
|
||||||
|
@ -12,7 +12,7 @@ static const qse_char_t* conin =
|
|||||||
QSE_T("Beth 4.00 0\nDan 3.74 0\nKathy 4.00 10\nMark 5.00 20\nMary 5.50 22\nSusie 4.25 18\n");
|
QSE_T("Beth 4.00 0\nDan 3.74 0\nKathy 4.00 10\nMark 5.00 20\nMary 5.50 22\nSusie 4.25 18\n");
|
||||||
static qse_size_t coninpos = 0;
|
static qse_size_t coninpos = 0;
|
||||||
|
|
||||||
/* i'll store the console output to this buffer */
|
/* the console output is stored into this buffer */
|
||||||
static qse_char_t conout[10000];
|
static qse_char_t conout[10000];
|
||||||
static qse_size_t conoutpos = 0;
|
static qse_size_t conoutpos = 0;
|
||||||
|
|
||||||
|
@ -1,24 +1,3 @@
|
|||||||
/*
|
|
||||||
* $Id: awk03.c 523 2011-07-25 15:42:35Z hyunghwan.chung $
|
|
||||||
*
|
|
||||||
Copyright 2006-2012 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 <qse/awk/awk.h>
|
|
||||||
#include <qse/awk/std.h>
|
#include <qse/awk/std.h>
|
||||||
#include <qse/cmn/stdio.h>
|
#include <qse/cmn/stdio.h>
|
||||||
|
|
||||||
@ -42,12 +21,10 @@ int main ()
|
|||||||
{
|
{
|
||||||
qse_awk_t* awk = QSE_NULL;
|
qse_awk_t* awk = QSE_NULL;
|
||||||
qse_awk_rtx_t* rtx = QSE_NULL;
|
qse_awk_rtx_t* rtx = QSE_NULL;
|
||||||
|
|
||||||
qse_awk_parsestd_t psin[2];
|
qse_awk_parsestd_t psin[2];
|
||||||
|
|
||||||
int ret, i, opt;
|
int ret, i, opt;
|
||||||
|
|
||||||
/* create a main processor */
|
/* create an awk object */
|
||||||
awk = qse_awk_openstd (0);
|
awk = qse_awk_openstd (0);
|
||||||
if (awk == QSE_NULL)
|
if (awk == QSE_NULL)
|
||||||
{
|
{
|
||||||
@ -55,16 +32,20 @@ int main ()
|
|||||||
ret = -1; goto oops;
|
ret = -1; goto oops;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* get the awk's trait */
|
||||||
qse_awk_getopt (awk, QSE_AWK_TRAIT, &opt);
|
qse_awk_getopt (awk, QSE_AWK_TRAIT, &opt);
|
||||||
/* don't allow BEGIN, END, pattern-action blocks */
|
/* change the trait value to disallow BEGIN, END, pattern-action blocks */
|
||||||
opt &= ~QSE_AWK_PABLOCK;
|
opt &= ~QSE_AWK_PABLOCK;
|
||||||
|
/* update the trait */
|
||||||
qse_awk_setopt (awk, QSE_AWK_TRAIT, &opt);
|
qse_awk_setopt (awk, QSE_AWK_TRAIT, &opt);
|
||||||
|
|
||||||
|
/* prepare a script to parse */
|
||||||
psin[0].type = QSE_AWK_PARSESTD_STR;
|
psin[0].type = QSE_AWK_PARSESTD_STR;
|
||||||
psin[0].u.str.ptr = src;
|
psin[0].u.str.ptr = src;
|
||||||
psin[0].u.str.len = qse_strlen(src);
|
psin[0].u.str.len = qse_strlen(src);
|
||||||
psin[1].type = QSE_AWK_PARSESTD_NULL;
|
psin[1].type = QSE_AWK_PARSESTD_NULL;
|
||||||
|
|
||||||
|
/* parse a script */
|
||||||
ret = qse_awk_parsestd (awk, psin, QSE_NULL);
|
ret = qse_awk_parsestd (awk, psin, QSE_NULL);
|
||||||
if (ret == -1)
|
if (ret == -1)
|
||||||
{
|
{
|
||||||
@ -89,13 +70,15 @@ int main ()
|
|||||||
ret = -1; goto oops;
|
ret = -1; goto oops;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* invoke functions as indicated in the array fnc */
|
/* call init() initially, followed by 4 calls to main(),
|
||||||
|
* and a final call to fini() */
|
||||||
for (i = 0; i < QSE_COUNTOF(fnc); i++)
|
for (i = 0; i < QSE_COUNTOF(fnc); i++)
|
||||||
{
|
{
|
||||||
qse_awk_val_t* v;
|
qse_awk_val_t* v;
|
||||||
qse_char_t* str;
|
qse_char_t* str;
|
||||||
qse_size_t len;
|
qse_size_t len;
|
||||||
|
|
||||||
|
/* call the function */
|
||||||
v = qse_awk_rtx_call (rtx, fnc[i], QSE_NULL, 0);
|
v = qse_awk_rtx_call (rtx, fnc[i], QSE_NULL, 0);
|
||||||
if (v == QSE_NULL)
|
if (v == QSE_NULL)
|
||||||
{
|
{
|
||||||
@ -104,27 +87,31 @@ int main ()
|
|||||||
ret = -1; goto oops;
|
ret = -1; goto oops;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* convert the return value to a string with duplication */
|
||||||
str = qse_awk_rtx_valtostrdup (rtx, v, &len);
|
str = qse_awk_rtx_valtostrdup (rtx, v, &len);
|
||||||
|
|
||||||
|
/* clear the return value */
|
||||||
|
qse_awk_rtx_refdownval (rtx, v);
|
||||||
|
|
||||||
if (str == QSE_NULL)
|
if (str == QSE_NULL)
|
||||||
{
|
{
|
||||||
qse_fprintf (QSE_STDERR, QSE_T("error: %s\n"),
|
qse_fprintf (QSE_STDERR, QSE_T("error: %s\n"),
|
||||||
qse_awk_rtx_geterrmsg(rtx));
|
qse_awk_rtx_geterrmsg(rtx));
|
||||||
|
|
||||||
qse_awk_rtx_refdownval (rtx, v);
|
|
||||||
ret = -1; goto oops;
|
ret = -1; goto oops;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* print the return value */
|
||||||
qse_printf (QSE_T("return: [%.*s]\n"), (int)len, str);
|
qse_printf (QSE_T("return: [%.*s]\n"), (int)len, str);
|
||||||
qse_awk_rtx_freemem (rtx, str);
|
|
||||||
|
|
||||||
/* clear the return value */
|
/* destroy the duplicated string */
|
||||||
qse_awk_rtx_refdownval (rtx, v);
|
qse_awk_rtx_freemem (rtx, str);
|
||||||
}
|
}
|
||||||
|
|
||||||
oops:
|
oops:
|
||||||
/* destroy a runtime context */
|
/* destroy a runtime context */
|
||||||
if (rtx != QSE_NULL) qse_awk_rtx_close (rtx);
|
if (rtx) qse_awk_rtx_close (rtx);
|
||||||
/* destroy the processor */
|
/* destroy the awk object */
|
||||||
if (awk != QSE_NULL) qse_awk_close (awk);
|
if (awk) qse_awk_close (awk);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -1,24 +1,3 @@
|
|||||||
/*
|
|
||||||
* $Id: awk04.c 523 2011-07-25 15:42:35Z hyunghwan.chung $
|
|
||||||
*
|
|
||||||
Copyright 2006-2012 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 <qse/awk/awk.h>
|
|
||||||
#include <qse/awk/std.h>
|
#include <qse/awk/std.h>
|
||||||
#include <qse/cmn/stdio.h>
|
#include <qse/cmn/stdio.h>
|
||||||
|
|
||||||
@ -35,13 +14,9 @@ int main ()
|
|||||||
qse_size_t len;
|
qse_size_t len;
|
||||||
qse_awk_val_t* rtv = QSE_NULL;
|
qse_awk_val_t* rtv = QSE_NULL;
|
||||||
qse_awk_val_t* arg[2] = { QSE_NULL, QSE_NULL };
|
qse_awk_val_t* arg[2] = { QSE_NULL, QSE_NULL };
|
||||||
qse_awk_fun_t* fun;
|
|
||||||
int ret, i, opt;
|
int ret, i, opt;
|
||||||
|
|
||||||
qse_awk_rtx_valtostr_out_t out;
|
/* create an awk object */
|
||||||
qse_char_t numbuf[128];
|
|
||||||
|
|
||||||
/* create a main processor */
|
|
||||||
awk = qse_awk_openstd (0);
|
awk = qse_awk_openstd (0);
|
||||||
if (awk == QSE_NULL)
|
if (awk == QSE_NULL)
|
||||||
{
|
{
|
||||||
@ -49,18 +24,20 @@ int main ()
|
|||||||
ret = -1; goto oops;
|
ret = -1; goto oops;
|
||||||
}
|
}
|
||||||
|
|
||||||
qse_awk_getopt (awk, QSE_AWK_TRAIT, &opt);
|
/* get the awk's trait */
|
||||||
/* don't allow BEGIN, END, pattern-action blocks */
|
qse_awk_getopt (awk, QSE_AWK_TRAIT, &opt);
|
||||||
|
/* change the trait value to disallow BEGIN, END, pattern-action blocks */
|
||||||
opt &= ~QSE_AWK_PABLOCK;
|
opt &= ~QSE_AWK_PABLOCK;
|
||||||
/* enable ** */
|
/* update the trait */
|
||||||
qse_awk_setopt (awk, QSE_AWK_TRAIT, &opt);
|
qse_awk_setopt (awk, QSE_AWK_TRAIT, &opt);
|
||||||
|
|
||||||
|
|
||||||
|
/* prepare an awk script to parse */
|
||||||
psin[0].type = QSE_AWK_PARSESTD_STR;
|
psin[0].type = QSE_AWK_PARSESTD_STR;
|
||||||
psin[0].u.str.ptr = src;
|
psin[0].u.str.ptr = src;
|
||||||
psin[0].u.str.len = qse_strlen(src);
|
psin[0].u.str.len = qse_strlen(src);
|
||||||
psin[1].type = QSE_AWK_PARSESTD_NULL;
|
psin[1].type = QSE_AWK_PARSESTD_NULL;
|
||||||
|
|
||||||
|
/* parse the script */
|
||||||
ret = qse_awk_parsestd (awk, psin, QSE_NULL);
|
ret = qse_awk_parsestd (awk, psin, QSE_NULL);
|
||||||
if (ret == -1)
|
if (ret == -1)
|
||||||
{
|
{
|
||||||
@ -73,7 +50,7 @@ int main ()
|
|||||||
rtx = qse_awk_rtx_openstd (
|
rtx = qse_awk_rtx_openstd (
|
||||||
awk,
|
awk,
|
||||||
0,
|
0,
|
||||||
QSE_T("awk04"),
|
QSE_T("awk04"),
|
||||||
QSE_NULL, /* stdin */
|
QSE_NULL, /* stdin */
|
||||||
QSE_NULL, /* stdout */
|
QSE_NULL, /* stdout */
|
||||||
QSE_NULL /* default cmgr */
|
QSE_NULL /* default cmgr */
|
||||||
@ -85,7 +62,7 @@ int main ()
|
|||||||
ret = -1; goto oops;
|
ret = -1; goto oops;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* invoke the pow function */
|
/* create the first argument to the pow function to call */
|
||||||
arg[0] = qse_awk_rtx_makeintval (rtx, 50);
|
arg[0] = qse_awk_rtx_makeintval (rtx, 50);
|
||||||
if (arg[0] == QSE_NULL)
|
if (arg[0] == QSE_NULL)
|
||||||
{
|
{
|
||||||
@ -95,6 +72,7 @@ int main ()
|
|||||||
}
|
}
|
||||||
qse_awk_rtx_refupval (rtx, arg[0]);
|
qse_awk_rtx_refupval (rtx, arg[0]);
|
||||||
|
|
||||||
|
/* create the second argument to the pow function to call */
|
||||||
arg[1] = qse_awk_rtx_makeintval (rtx, 3);
|
arg[1] = qse_awk_rtx_makeintval (rtx, 3);
|
||||||
if (arg[1] == QSE_NULL)
|
if (arg[1] == QSE_NULL)
|
||||||
{
|
{
|
||||||
@ -104,6 +82,7 @@ int main ()
|
|||||||
}
|
}
|
||||||
qse_awk_rtx_refupval (rtx, arg[1]);
|
qse_awk_rtx_refupval (rtx, arg[1]);
|
||||||
|
|
||||||
|
/* call the pow function */
|
||||||
rtv = qse_awk_rtx_call (rtx, QSE_T("pow"), arg, 2);
|
rtv = qse_awk_rtx_call (rtx, QSE_T("pow"), arg, 2);
|
||||||
if (rtv == QSE_NULL)
|
if (rtv == QSE_NULL)
|
||||||
{
|
{
|
||||||
@ -112,7 +91,12 @@ int main ()
|
|||||||
ret = -1; goto oops;
|
ret = -1; goto oops;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* duplicate the return value to a string */
|
||||||
str = qse_awk_rtx_valtostrdup (rtx, rtv, &len);
|
str = qse_awk_rtx_valtostrdup (rtx, rtv, &len);
|
||||||
|
|
||||||
|
/* clear the return value */
|
||||||
|
qse_awk_rtx_refdownval (rtx, rtv);
|
||||||
|
|
||||||
if (str == QSE_NULL)
|
if (str == QSE_NULL)
|
||||||
{
|
{
|
||||||
qse_fprintf (QSE_STDERR, QSE_T("error: %s\n"),
|
qse_fprintf (QSE_STDERR, QSE_T("error: %s\n"),
|
||||||
@ -121,52 +105,11 @@ int main ()
|
|||||||
}
|
}
|
||||||
|
|
||||||
qse_printf (QSE_T("[%.*s]\n"), (int)len, str);
|
qse_printf (QSE_T("[%.*s]\n"), (int)len, str);
|
||||||
|
|
||||||
|
/* destroy the duplicated string */
|
||||||
qse_awk_rtx_freemem (rtx, str);
|
qse_awk_rtx_freemem (rtx, str);
|
||||||
|
|
||||||
if (rtv)
|
|
||||||
{
|
|
||||||
qse_awk_rtx_refdownval (rtx, rtv);
|
|
||||||
rtv = QSE_NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* call the function again using different API functions */
|
|
||||||
fun = qse_awk_rtx_findfun (rtx, QSE_T("pow"));
|
|
||||||
if (fun == QSE_NULL)
|
|
||||||
{
|
|
||||||
qse_fprintf (QSE_STDERR, QSE_T("error: %s\n"),
|
|
||||||
qse_awk_rtx_geterrmsg(rtx));
|
|
||||||
ret = -1; goto oops;
|
|
||||||
}
|
|
||||||
|
|
||||||
rtv = qse_awk_rtx_callfun (rtx, fun, arg, 2);
|
|
||||||
if (rtv == QSE_NULL)
|
|
||||||
{
|
|
||||||
qse_fprintf (QSE_STDERR, QSE_T("error: %s\n"),
|
|
||||||
qse_awk_rtx_geterrmsg(rtx));
|
|
||||||
ret = -1; goto oops;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Convert a value to a string in a different way */
|
|
||||||
out.type = QSE_AWK_RTX_VALTOSTR_CPL;
|
|
||||||
out.u.cpl.ptr = numbuf; /* used if the value is not a string */
|
|
||||||
out.u.cpl.len = QSE_COUNTOF(numbuf);
|
|
||||||
if (qse_awk_rtx_valtostr (rtx, rtv, &out) <= -1)
|
|
||||||
{
|
|
||||||
qse_fprintf (QSE_STDERR, QSE_T("error: %s\n"),
|
|
||||||
qse_awk_rtx_geterrmsg(rtx));
|
|
||||||
ret = -1; goto oops;
|
|
||||||
}
|
|
||||||
|
|
||||||
qse_printf (QSE_T("[%.*s]\n"), (int)out.u.cpl.len, out.u.cpl.ptr);
|
|
||||||
|
|
||||||
oops:
|
oops:
|
||||||
/* clear the return value */
|
|
||||||
if (rtv)
|
|
||||||
{
|
|
||||||
qse_awk_rtx_refdownval (rtx, rtv);
|
|
||||||
rtv = QSE_NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* dereference all arguments */
|
/* dereference all arguments */
|
||||||
for (i = 0; i < QSE_COUNTOF(arg); i++)
|
for (i = 0; i < QSE_COUNTOF(arg); i++)
|
||||||
{
|
{
|
||||||
@ -177,5 +120,6 @@ oops:
|
|||||||
if (rtx) qse_awk_rtx_close (rtx);
|
if (rtx) qse_awk_rtx_close (rtx);
|
||||||
/* destroy the processor */
|
/* destroy the processor */
|
||||||
if (awk) qse_awk_close (awk);
|
if (awk) qse_awk_close (awk);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
105
qse/samples/awk/awk21.cpp
Normal file
105
qse/samples/awk/awk21.cpp
Normal file
@ -0,0 +1,105 @@
|
|||||||
|
/*
|
||||||
|
* $Id$
|
||||||
|
*
|
||||||
|
Copyright 2006-2012 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 <qse/awk/StdAwk.hpp>
|
||||||
|
#include <qse/cmn/stdio.h>
|
||||||
|
#include <qse/cmn/main.h>
|
||||||
|
#include <qse/cmn/mbwc.h>
|
||||||
|
|
||||||
|
#include <locale.h>
|
||||||
|
#if defined(_WIN32)
|
||||||
|
# include <windows.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static void print_error (
|
||||||
|
const QSE::StdAwk::loc_t& loc, const QSE::StdAwk::char_t* msg)
|
||||||
|
{
|
||||||
|
if (loc.line > 0 || loc.colm > 0)
|
||||||
|
qse_fprintf (QSE_STDERR, QSE_T("ERROR: %s at LINE %lu COLUMN %lu\n"), msg, loc.line, loc.colm);
|
||||||
|
else
|
||||||
|
qse_fprintf (QSE_STDERR, QSE_T("ERROR: %s\n"), msg);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
static int run_awk (QSE::StdAwk& awk)
|
||||||
|
{
|
||||||
|
// ARGV[0]
|
||||||
|
if (awk.addArgument (QSE_T("awk05")) <= -1) return -1;
|
||||||
|
|
||||||
|
// ARGV[1] and/or the first console input file
|
||||||
|
if (awk.addArgument (QSE_T("Makefile")) <= -1) return -1;
|
||||||
|
|
||||||
|
const qse_char_t* script = QSE_T(
|
||||||
|
"BEGIN { print \">> PRINT ALL LINES WHOSE LENGTH IS GREATER THAN 0\"; }\n"
|
||||||
|
"length($0) > 0 { print $0; count++; }\n"
|
||||||
|
"END { print \">> TOTAL\", count, \"LINES\"; }\n"
|
||||||
|
);
|
||||||
|
|
||||||
|
QSE::StdAwk::SourceString in (script);
|
||||||
|
QSE::StdAwk::SourceFile out (QSE_T("awk05.out"));
|
||||||
|
|
||||||
|
// parse the script string and deparse it to awk05.out.
|
||||||
|
if (awk.parse (in, out) == QSE_NULL) return -1;
|
||||||
|
|
||||||
|
QSE::StdAwk::Value r;
|
||||||
|
// execute the BEGIN, pattern-action, END blocks.
|
||||||
|
return awk.loop (&r);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int awk_main (int argc, qse_char_t* argv[])
|
||||||
|
{
|
||||||
|
QSE::StdAwk awk;
|
||||||
|
|
||||||
|
int ret = awk.open ();
|
||||||
|
if (ret >= 0) ret = run_awk (awk);
|
||||||
|
|
||||||
|
if (ret <= -1)
|
||||||
|
{
|
||||||
|
QSE::StdAwk::loc_t loc = awk.getErrorLocation();
|
||||||
|
print_error (loc, awk.getErrorMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
awk.close ();
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
int qse_main (int argc, qse_achar_t* argv[])
|
||||||
|
{
|
||||||
|
#if defined(_WIN32)
|
||||||
|
char locale[100];
|
||||||
|
UINT codepage = GetConsoleOutputCP();
|
||||||
|
if (codepage == CP_UTF8)
|
||||||
|
{
|
||||||
|
/*SetConsoleOUtputCP (CP_UTF8);*/
|
||||||
|
qse_setdflcmgrbyid (QSE_CMGR_UTF8);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sprintf (locale, ".%u", (unsigned int)codepage);
|
||||||
|
setlocale (LC_ALL, locale);
|
||||||
|
qse_setdflcmgrbyid (QSE_CMGR_SLMB);
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
setlocale (LC_ALL, "");
|
||||||
|
qse_setdflcmgrbyid (QSE_CMGR_SLMB);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return qse_runmain (argc,argv,awk_main);
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user