improving regular expression handler

This commit is contained in:
hyung-hwan 2009-11-28 07:46:49 +00:00
parent 6b98760c2c
commit c7d45b6099
5 changed files with 110 additions and 112 deletions

View File

@ -1,5 +1,5 @@
/* /*
* $Id: rex.h 307 2009-11-25 13:32:20Z hyunghwan.chung $ * $Id: rex.h 309 2009-11-27 13:46:49Z hyunghwan.chung $
* *
Copyright 2006-2009 Chung, Hyung-Hwan. Copyright 2006-2009 Chung, Hyung-Hwan.
This file is part of QSE. This file is part of QSE.
@ -236,11 +236,10 @@ qse_rex_node_t* qse_rex_comp (
); );
int qse_rex_exec ( int qse_rex_exec (
qse_rex_t* rex, qse_rex_t* rex,
const qse_char_t* str, const qse_cstr_t* str,
qse_size_t len, const qse_cstr_t* substr,
const qse_char_t* substr, qse_cstr_t* matstr
qse_size_t sublen
); );
void* qse_buildrex ( void* qse_buildrex (

View File

@ -739,7 +739,7 @@ static qse_rex_node_t* comp2 (comp_t* com)
/* enter a subgroup */ /* enter a subgroup */
qse_rex_node_t* x, * ge; qse_rex_node_t* x, * ge;
n = newgroupnode (com, QSE_NULL); n = newgroupnode (com, QSE_NULL);
if (n == QSE_NULL) return QSE_NULL; if (n == QSE_NULL) return QSE_NULL;
@ -765,7 +765,6 @@ static qse_rex_node_t* comp2 (comp_t* com)
break; break;
} }
case QSE_T('.'): case QSE_T('.'):
n = newnode (com, QSE_REX_NODE_ANY); n = newnode (com, QSE_REX_NODE_ANY);
if (n == QSE_NULL) return QSE_NULL; if (n == QSE_NULL) return QSE_NULL;
@ -1036,8 +1035,11 @@ static group_t* dupgroupstack (exec_t* e, group_t* gs)
return head; return head;
} }
/* creates a new group stack duplicating 'gs' and push 'gn' to it */ /* push 'gn' to the group stack 'gs'.
static group_t* dupgroupstackpush (exec_t* e, group_t* gs, qse_rex_node_t* gn) * if dup is non-zero, the group stack is duplicated and 'gn' is pushed to
* its top */
static group_t* __groupstackpush (
exec_t* e, group_t* gs, qse_rex_node_t* gn, int dup)
{ {
group_t* head, * elem; group_t* head, * elem;
@ -1064,9 +1066,16 @@ static group_t* dupgroupstackpush (exec_t* e, group_t* gs, qse_rex_node_t* gn)
} }
else else
{ {
/* duplicate existing stack */ if (dup)
head = dupgroupstack (e, gs); {
if (head == QSE_NULL) return QSE_NULL; /* duplicate existing stack */
head = dupgroupstack (e, gs);
if (head == QSE_NULL) return QSE_NULL;
}
else
{
head = gs;
}
} }
/* create a new stack element */ /* create a new stack element */
@ -1076,7 +1085,8 @@ static group_t* dupgroupstackpush (exec_t* e, group_t* gs, qse_rex_node_t* gn)
/* rollback */ /* rollback */
if (gs == QSE_NULL) if (gs == QSE_NULL)
QSE_MMGR_FREE (e->rex->mmgr, head); QSE_MMGR_FREE (e->rex->mmgr, head);
else freegroupstack (head, e->rex->mmgr); else if (dup)
freegroupstack (head, e->rex->mmgr);
e->rex->errnum = QSE_REX_ENOMEM; e->rex->errnum = QSE_REX_ENOMEM;
return QSE_NULL; return QSE_NULL;
@ -1093,6 +1103,9 @@ static group_t* dupgroupstackpush (exec_t* e, group_t* gs, qse_rex_node_t* gn)
return head; return head;
} }
#define dupgroupstackpush(e,gs,gn) __groupstackpush(e,gs,gn,1)
#define groupstackpush(e,gs,gn) __groupstackpush(e,gs,gn,0)
/* duplidate a group stack excluding the top data element */ /* duplidate a group stack excluding the top data element */
static group_t* dupgroupstackpop (exec_t* e, group_t* gs) static group_t* dupgroupstackpop (exec_t* e, group_t* gs)
{ {
@ -1195,7 +1208,7 @@ static int addcands (
{ {
case QSE_REX_NODE_END: case QSE_REX_NODE_END:
{ {
qse_printf (QSE_T("== ADDING THE END(MATCH) NODE MEANING MATCH FOUND == \n")); /*qse_printf (QSE_T("== ADDING THE END(MATCH) NODE MEANING MATCH FOUND == \n"));*/
if (e->matchend == QSE_NULL || mptr >= e->matchend) if (e->matchend == QSE_NULL || mptr >= e->matchend)
e->matchend = mptr; e->matchend = mptr;
e->nmatches++; e->nmatches++;
@ -1258,12 +1271,19 @@ qse_printf (QSE_T("== ADDING THE END(MATCH) NODE MEANING MATCH FOUND == \n"));
group_t* gx; group_t* gx;
/* push the current group node (candnode) to /* push the current group node (candnode) to
* the group stack duplicated. */ * the group stack. if candnode->next is
* added to the candidate array, which means
* the group stack has already been used to
* a different path, the group stack is
* duplicated for this path. */
gx = dupgroupstackpush (e, group, candnode); gx = (candnode->occ.min <= 0)?
dupgroupstackpush (e, group, candnode):
groupstackpush (e, group, candnode);
if (gx == QSE_NULL) return -1; if (gx == QSE_NULL) return -1;
/* add the first node in the group */ /* add the first node in the group to
* the candidate array */
refupgroupstack (gx); refupgroupstack (gx);
n = addcands (e, gx, n = addcands (e, gx,
candnode, candnode->u.g.head, mptr); candnode, candnode->u.g.head, mptr);
@ -1287,7 +1307,14 @@ qse_printf (QSE_T("== ADDING THE END(MATCH) NODE MEANING MATCH FOUND == \n"));
if (prevnode == candnode) if (prevnode == candnode)
{ {
qse_printf (QSE_T("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\n")); /* consider a pattern like (x*)*.
* when GROUPEND is reached, an 'if' block below
* tries to add the first node(node->u.g.head)
* in the group again. however, it('x') is optional,
* a possible path reach GROUPEND directly without
* adding a candidate. this check is needed to
* avoid the infinite loop, which otherwise is not
* avoidable. */
break; break;
} }
@ -1302,7 +1329,10 @@ qse_printf (QSE_T("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\n"));
{ {
group_t* gx; group_t* gx;
/* take the next atom as a candidate. /* the lower bound has been met.
* for a pattern (abc){3,4}, 'abc' has been
* repeated 3 times. in this case, the next
* node can be added to the candiate array.
* it is actually a branch case. move on. */ * it is actually a branch case. move on. */
if (top->next == QSE_NULL) if (top->next == QSE_NULL)
@ -1354,7 +1384,6 @@ qse_printf (QSE_T("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\n"));
break; break;
} }
default: default:
{ {
int n; int n;
@ -1373,10 +1402,14 @@ qse_printf (QSE_T("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\n"));
{ {
group_t* gx; group_t* gx;
/* if the upper bound is greater than 0,
* this node is added to the candidate array */
if (group != QSE_NULL && candnode->occ.min <= 0) if (group != QSE_NULL && candnode->occ.min <= 0)
{ {
/* if it belongs to a group and it has been /* if a group stack exists(group != QSE_NULL)
* pushed to a different path above, * for this path and it has been
* used for a different path above,
* duplicate the group stack */ * duplicate the group stack */
gx = dupgroupstack (e, group); gx = dupgroupstack (e, group);
if (gx == QSE_NULL) return -1; if (gx == QSE_NULL) return -1;
@ -1511,7 +1544,7 @@ static int match (exec_t* e)
* next chracter.*/ * next chracter.*/
nmptr = cand->mptr + 1; nmptr = cand->mptr + 1;
} }
//qse_printf (QSE_T("matched %c\n"), node->u.c); /*qse_printf (QSE_T("matched %c\n"), node->u.c);*/
break; break;
case QSE_REX_NODE_CSET: case QSE_REX_NODE_CSET:
@ -1626,6 +1659,7 @@ static int exec (exec_t* e)
/* clear the pending set */ /* clear the pending set */
qse_lda_clear (&e->cand.set[e->cand.pending]); qse_lda_clear (&e->cand.set[e->cand.pending]);
#if 0
{ {
int i; int i;
qse_printf (QSE_T("SET=")); qse_printf (QSE_T("SET="));
@ -1645,20 +1679,24 @@ for (i = 0; i < QSE_LDA_SIZE(&e->cand.set[e->cand.active]); i++)
} }
qse_printf (QSE_T("\n")); qse_printf (QSE_T("\n"));
} }
#endif
if (match (e) <= -1) return -1; if (match (e) <= -1) return -1;
} }
while (1); while (1);
#if 0
if (e->nmatches > 0) if (e->nmatches > 0)
{ {
qse_printf (QSE_T("MATCH: %d [%.*s]\n"), qse_printf (QSE_T("MATCH: %d [%.*s]\n"),
(int)(e->matchend - e->sub.ptr), (int)(e->matchend - e->sub.ptr),
(int)(e->matchend - e->sub.ptr), e->sub.ptr); (int)(e->matchend - e->sub.ptr), e->sub.ptr);
} }
qse_printf (QSE_T("TOTAL MATCHES FOUND... %d\n"), e->nmatches); qse_printf (QSE_T("TOTAL MATCHES FOUND... %d\n"), e->nmatches);
return 0; #endif
return (e->nmatches > 0)? 1: 0;
} }
static void refdowngroupstack_incand (qse_lda_t* lda, void* dptr, qse_size_t dlen) static void refdowngroupstack_incand (qse_lda_t* lda, void* dptr, qse_size_t dlen)
@ -1700,9 +1738,9 @@ static void fini_exec_dds (exec_t* e)
qse_lda_fini (&e->cand.set[0]); qse_lda_fini (&e->cand.set[0]);
} }
int qse_rex_exec (qse_rex_t* rex, int qse_rex_exec (
const qse_char_t* str, qse_size_t len, qse_rex_t* rex, const qse_cstr_t* str,
const qse_char_t* substr, qse_size_t sublen) const qse_cstr_t* substr, qse_cstr_t* matstr)
{ {
exec_t e; exec_t e;
int n = 0; int n = 0;
@ -1716,10 +1754,10 @@ int qse_rex_exec (qse_rex_t* rex,
QSE_MEMSET (&e, 0, QSE_SIZEOF(e)); QSE_MEMSET (&e, 0, QSE_SIZEOF(e));
e.rex = rex; e.rex = rex;
e.str.ptr = str; e.str.ptr = str->ptr;
e.str.end = str + len; e.str.end = str->ptr + str->len;
e.sub.ptr = substr; e.sub.ptr = substr->ptr;
e.sub.end = substr + sublen; e.sub.end = substr->ptr + substr->len;
if (init_exec_dds (&e, rex->mmgr) <= -1) return -1; if (init_exec_dds (&e, rex->mmgr) <= -1) return -1;
@ -1732,7 +1770,14 @@ int qse_rex_exec (qse_rex_t* rex,
break; break;
} }
if (e.nmatches > 0) break; if (n >= 1)
{
QSE_ASSERT (e.nmatches > 0);
QSE_ASSERT (e.matchend != QSE_NULL);
matstr->ptr = e.sub.ptr;
matstr->len = e.matchend - e.sub.ptr;
break;
}
e.sub.ptr++; e.sub.ptr++;
} }

View File

@ -18,9 +18,9 @@ rex01_SOURCES = rex01.c
if ENABLE_CXX if ENABLE_CXX
bin_PROGRAMS += rex02 #bin_PROGRAMS += rex02
rex02_SOURCES = rex02.cpp #rex02_SOURCES = rex02.cpp
rex02_CXXFLAGS = -I/usr/lib/wx/include/gtk2-unicode-release-2.8 -I/usr/include/wx-2.8 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES -D__WXGTK__ -pthread #rex02_CXXFLAGS = -I/usr/lib/wx/include/gtk2-unicode-release-2.8 -I/usr/include/wx-2.8 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES -D__WXGTK__ -pthread
rex02_LDFLAGS = -pthread -Wl,-Bsymbolic-functions -lwx_gtk2ud_richtext-2.8 -lwx_gtk2ud_aui-2.8 -lwx_gtk2ud_xrc-2.8 -lwx_gtk2ud_qa-2.8 -lwx_gtk2ud_html-2.8 -lwx_gtk2ud_adv-2.8 -lwx_gtk2ud_core-2.8 -lwx_baseud_xml-2.8 -lwx_baseud_net-2.8 -lwx_baseud-2.8 #rex02_LDFLAGS = -pthread -Wl,-Bsymbolic-functions -lwx_gtk2ud_richtext-2.8 -lwx_gtk2ud_aui-2.8 -lwx_gtk2ud_xrc-2.8 -lwx_gtk2ud_qa-2.8 -lwx_gtk2ud_html-2.8 -lwx_gtk2ud_adv-2.8 -lwx_gtk2ud_core-2.8 -lwx_baseud_xml-2.8 -lwx_baseud_net-2.8 -lwx_baseud-2.8
endif endif

View File

@ -36,8 +36,7 @@ build_triplet = @build@
host_triplet = @host@ host_triplet = @host@
bin_PROGRAMS = chr$(EXEEXT) str$(EXEEXT) sll$(EXEEXT) map$(EXEEXT) \ bin_PROGRAMS = chr$(EXEEXT) str$(EXEEXT) sll$(EXEEXT) map$(EXEEXT) \
lda$(EXEEXT) fio$(EXEEXT) pio$(EXEEXT) sio$(EXEEXT) \ lda$(EXEEXT) fio$(EXEEXT) pio$(EXEEXT) sio$(EXEEXT) \
time$(EXEEXT) rex01$(EXEEXT) $(am__EXEEXT_1) time$(EXEEXT) rex01$(EXEEXT)
@ENABLE_CXX_TRUE@am__append_1 = rex02
subdir = samples/cmn subdir = samples/cmn
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
@ -52,7 +51,6 @@ 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 = rex02$(EXEEXT)
am__installdirs = "$(DESTDIR)$(bindir)" am__installdirs = "$(DESTDIR)$(bindir)"
PROGRAMS = $(bin_PROGRAMS) PROGRAMS = $(bin_PROGRAMS)
am_chr_OBJECTS = chr.$(OBJEXT) am_chr_OBJECTS = chr.$(OBJEXT)
@ -79,14 +77,6 @@ am_rex01_OBJECTS = rex01.$(OBJEXT)
rex01_OBJECTS = $(am_rex01_OBJECTS) rex01_OBJECTS = $(am_rex01_OBJECTS)
rex01_LDADD = $(LDADD) rex01_LDADD = $(LDADD)
rex01_DEPENDENCIES = rex01_DEPENDENCIES =
am__rex02_SOURCES_DIST = rex02.cpp
@ENABLE_CXX_TRUE@am_rex02_OBJECTS = rex02-rex02.$(OBJEXT)
rex02_OBJECTS = $(am_rex02_OBJECTS)
rex02_LDADD = $(LDADD)
rex02_DEPENDENCIES =
rex02_LINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
--mode=link $(CXXLD) $(rex02_CXXFLAGS) $(CXXFLAGS) \
$(rex02_LDFLAGS) $(LDFLAGS) -o $@
am_sio_OBJECTS = sio.$(OBJEXT) am_sio_OBJECTS = sio.$(OBJEXT)
sio_OBJECTS = $(am_sio_OBJECTS) sio_OBJECTS = $(am_sio_OBJECTS)
sio_LDADD = $(LDADD) sio_LDADD = $(LDADD)
@ -116,22 +106,12 @@ CCLD = $(CC)
LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
--mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
$(LDFLAGS) -o $@ $(LDFLAGS) -o $@
CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
LTCXXCOMPILE = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
--mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
CXXLD = $(CXX)
CXXLINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
--mode=link $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
$(LDFLAGS) -o $@
SOURCES = $(chr_SOURCES) $(fio_SOURCES) $(lda_SOURCES) $(map_SOURCES) \ SOURCES = $(chr_SOURCES) $(fio_SOURCES) $(lda_SOURCES) $(map_SOURCES) \
$(pio_SOURCES) $(rex01_SOURCES) $(rex02_SOURCES) \ $(pio_SOURCES) $(rex01_SOURCES) $(sio_SOURCES) $(sll_SOURCES) \
$(sio_SOURCES) $(sll_SOURCES) $(str_SOURCES) $(time_SOURCES)
DIST_SOURCES = $(chr_SOURCES) $(fio_SOURCES) $(lda_SOURCES) \
$(map_SOURCES) $(pio_SOURCES) $(rex01_SOURCES) \
$(am__rex02_SOURCES_DIST) $(sio_SOURCES) $(sll_SOURCES) \
$(str_SOURCES) $(time_SOURCES) $(str_SOURCES) $(time_SOURCES)
DIST_SOURCES = $(chr_SOURCES) $(fio_SOURCES) $(lda_SOURCES) \
$(map_SOURCES) $(pio_SOURCES) $(rex01_SOURCES) $(sio_SOURCES) \
$(sll_SOURCES) $(str_SOURCES) $(time_SOURCES)
ETAGS = etags ETAGS = etags
CTAGS = ctags CTAGS = ctags
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
@ -284,13 +264,10 @@ pio_SOURCES = pio.c
sio_SOURCES = sio.c sio_SOURCES = sio.c
time_SOURCES = time.c time_SOURCES = time.c
rex01_SOURCES = rex01.c rex01_SOURCES = rex01.c
@ENABLE_CXX_TRUE@rex02_SOURCES = rex02.cpp
@ENABLE_CXX_TRUE@rex02_CXXFLAGS = -I/usr/lib/wx/include/gtk2-unicode-release-2.8 -I/usr/include/wx-2.8 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES -D__WXGTK__ -pthread
@ENABLE_CXX_TRUE@rex02_LDFLAGS = -pthread -Wl,-Bsymbolic-functions -lwx_gtk2ud_richtext-2.8 -lwx_gtk2ud_aui-2.8 -lwx_gtk2ud_xrc-2.8 -lwx_gtk2ud_qa-2.8 -lwx_gtk2ud_html-2.8 -lwx_gtk2ud_adv-2.8 -lwx_gtk2ud_core-2.8 -lwx_baseud_xml-2.8 -lwx_baseud_net-2.8 -lwx_baseud-2.8
all: all-am all: all-am
.SUFFIXES: .SUFFIXES:
.SUFFIXES: .c .cpp .lo .o .obj .SUFFIXES: .c .lo .o .obj
$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
@for dep in $?; do \ @for dep in $?; do \
case '$(am__configure_deps)' in \ case '$(am__configure_deps)' in \
@ -382,9 +359,6 @@ pio$(EXEEXT): $(pio_OBJECTS) $(pio_DEPENDENCIES)
rex01$(EXEEXT): $(rex01_OBJECTS) $(rex01_DEPENDENCIES) rex01$(EXEEXT): $(rex01_OBJECTS) $(rex01_DEPENDENCIES)
@rm -f rex01$(EXEEXT) @rm -f rex01$(EXEEXT)
$(LINK) $(rex01_OBJECTS) $(rex01_LDADD) $(LIBS) $(LINK) $(rex01_OBJECTS) $(rex01_LDADD) $(LIBS)
rex02$(EXEEXT): $(rex02_OBJECTS) $(rex02_DEPENDENCIES)
@rm -f rex02$(EXEEXT)
$(rex02_LINK) $(rex02_OBJECTS) $(rex02_LDADD) $(LIBS)
sio$(EXEEXT): $(sio_OBJECTS) $(sio_DEPENDENCIES) sio$(EXEEXT): $(sio_OBJECTS) $(sio_DEPENDENCIES)
@rm -f sio$(EXEEXT) @rm -f sio$(EXEEXT)
$(LINK) $(sio_OBJECTS) $(sio_LDADD) $(LIBS) $(LINK) $(sio_OBJECTS) $(sio_LDADD) $(LIBS)
@ -410,7 +384,6 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/map.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/map.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pio.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pio.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rex01.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rex01.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rex02-rex02.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sio.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sio.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sll.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sll.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/str.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/str.Po@am__quote@
@ -437,41 +410,6 @@ distclean-compile:
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< @am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $<
.cpp.o:
@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
@am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $<
.cpp.obj:
@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
@am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
.cpp.lo:
@am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
@am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(LTCXXCOMPILE) -c -o $@ $<
rex02-rex02.o: rex02.cpp
@am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(rex02_CXXFLAGS) $(CXXFLAGS) -MT rex02-rex02.o -MD -MP -MF $(DEPDIR)/rex02-rex02.Tpo -c -o rex02-rex02.o `test -f 'rex02.cpp' || echo '$(srcdir)/'`rex02.cpp
@am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/rex02-rex02.Tpo $(DEPDIR)/rex02-rex02.Po
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='rex02.cpp' object='rex02-rex02.o' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(rex02_CXXFLAGS) $(CXXFLAGS) -c -o rex02-rex02.o `test -f 'rex02.cpp' || echo '$(srcdir)/'`rex02.cpp
rex02-rex02.obj: rex02.cpp
@am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(rex02_CXXFLAGS) $(CXXFLAGS) -MT rex02-rex02.obj -MD -MP -MF $(DEPDIR)/rex02-rex02.Tpo -c -o rex02-rex02.obj `if test -f 'rex02.cpp'; then $(CYGPATH_W) 'rex02.cpp'; else $(CYGPATH_W) '$(srcdir)/rex02.cpp'; fi`
@am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/rex02-rex02.Tpo $(DEPDIR)/rex02-rex02.Po
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='rex02.cpp' object='rex02-rex02.obj' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(rex02_CXXFLAGS) $(CXXFLAGS) -c -o rex02-rex02.obj `if test -f 'rex02.cpp'; then $(CYGPATH_W) 'rex02.cpp'; else $(CYGPATH_W) '$(srcdir)/rex02.cpp'; fi`
mostlyclean-libtool: mostlyclean-libtool:
-rm -f *.lo -rm -f *.lo
@ -679,6 +617,11 @@ uninstall-am: uninstall-binPROGRAMS
uninstall-binPROGRAMS uninstall-binPROGRAMS
#bin_PROGRAMS += rex02
#rex02_SOURCES = rex02.cpp
#rex02_CXXFLAGS = -I/usr/lib/wx/include/gtk2-unicode-release-2.8 -I/usr/include/wx-2.8 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES -D__WXGTK__ -pthread
#rex02_LDFLAGS = -pthread -Wl,-Bsymbolic-functions -lwx_gtk2ud_richtext-2.8 -lwx_gtk2ud_aui-2.8 -lwx_gtk2ud_xrc-2.8 -lwx_gtk2ud_qa-2.8 -lwx_gtk2ud_html-2.8 -lwx_gtk2ud_adv-2.8 -lwx_gtk2ud_core-2.8 -lwx_baseud_xml-2.8 -lwx_baseud_net-2.8 -lwx_baseud-2.8
# Tell versions [3.59,3.63) of GNU make to not export all variables. # 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. # Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT: .NOEXPORT:

View File

@ -8,6 +8,9 @@ static int rex_main (int argc, qse_char_t* argv[])
{ {
qse_rex_t* rex; qse_rex_t* rex;
qse_rex_node_t* start; qse_rex_node_t* start;
qse_cstr_t str;
qse_cstr_t matstr;
int n;
if (argc != 3) if (argc != 3)
{ {
@ -32,15 +35,23 @@ static int rex_main (int argc, qse_char_t* argv[])
return -1; return -1;
} }
if (qse_rex_exec (rex, str.ptr = argv[2];
argv[2], qse_strlen(argv[2]), str.len = qse_strlen(argv[2]);
argv[2], qse_strlen(argv[2])) <= -1)
n = qse_rex_exec (rex, &str, &str, &matstr);
if (n <= -1)
{ {
qse_printf (QSE_T("ERROR: cannot execute - %s\n"), qse_printf (QSE_T("ERROR: cannot execute - %s\n"),
qse_rex_geterrmsg(rex)); qse_rex_geterrmsg(rex));
qse_rex_close (rex); qse_rex_close (rex);
return -1; return -1;
} }
if (n >= 1)
{
qse_printf (QSE_T("MATCH: [%.*s] beginning from char #%d\n"),
(int)matstr.len, matstr.ptr,
(int)(matstr.ptr, matstr.ptr - str.ptr + 1));
}
qse_rex_close (rex); qse_rex_close (rex);
return 0; return 0;