fixed a bug in matching zero occurrence in a group

This commit is contained in:
2009-06-19 06:08:06 +00:00
parent 944a492c88
commit cf606b6819
20 changed files with 972 additions and 145 deletions

View File

@ -4,7 +4,7 @@ AUTOMAKE_OPTIONS = nostdinc
AM_CPPFLAGS = -I$(top_srcdir)/include
lib_LTLIBRARIES = libqseawk.la
libqseawk_la_SOURCES = awk.c err.c tree.c parse.c run.c rec.c val.c fnc.c misc.c rio.c std.c awk.h rio.h val.h fnc.h misc.h parse.h run.h tree.h
libqseawk_la_SOURCES = awk.c err.c tree.c parse.c run.c rec.c val.c fnc.c misc.c rio.c std.c awk.h err.h rio.h val.h fnc.h misc.h parse.h run.h tree.h
libqseawk_la_LDFLAGS = -L../cmn -version-info 1:0:0 -no-undefined
libqseawk_la_LIBADD = -lqsecmn $(LIBM)

View File

@ -237,7 +237,7 @@ top_srcdir = @top_srcdir@
AUTOMAKE_OPTIONS = nostdinc
AM_CPPFLAGS = -I$(top_srcdir)/include
lib_LTLIBRARIES = libqseawk.la $(am__append_1)
libqseawk_la_SOURCES = awk.c err.c tree.c parse.c run.c rec.c val.c fnc.c misc.c rio.c std.c awk.h rio.h val.h fnc.h misc.h parse.h run.h tree.h
libqseawk_la_SOURCES = awk.c err.c tree.c parse.c run.c rec.c val.c fnc.c misc.c rio.c std.c awk.h err.h rio.h val.h fnc.h misc.h parse.h run.h tree.h
libqseawk_la_LDFLAGS = -L../cmn -version-info 1:0:0 -no-undefined
libqseawk_la_LIBADD = -lqsecmn $(LIBM)
@ENABLE_CXX_TRUE@libqseawk___la_SOURCES = Awk.cpp StdAwk.cpp

View File

@ -1,5 +1,5 @@
/*
* $Id: parse.c 199 2009-06-14 08:40:52Z hyunghwan.chung $
* $Id: parse.c 204 2009-06-18 12:08:06Z hyunghwan.chung $
*
Copyright 2006-2009 Chung, Hyung-Hwan.
@ -4516,10 +4516,12 @@ static qse_awk_nde_t* parse_print (qse_awk_t* awk, qse_size_t line, int type)
{
if (ep->opcode == tab[i].opc)
{
qse_awk_nde_t* tmp;
if (tab[i].opt &&
!(awk->option&tab[i].opt)) break;
qse_awk_nde_t* tmp = args_tail;
tmp = args_tail;
if (tail_prev != QSE_NULL)
tail_prev->next = ep->left;
@ -4963,6 +4965,7 @@ static int get_token (qse_awk_t* awk)
else
{
int i;
qse_char_t cc;
static struct
{
qse_char_t c;
@ -4995,7 +4998,7 @@ static int get_token (qse_awk_t* awk)
}
}
qse_char_t cc = (qse_char_t)c;
cc = (qse_char_t)c;
SETERRARG (awk, QSE_AWK_ELXCHR, awk->token.line, &cc, 1);
return -1;
}

View File

@ -1,5 +1,5 @@
/*
* $Id: run.c 202 2009-06-16 06:05:40Z hyunghwan.chung $
* $Id: run.c 204 2009-06-18 12:08:06Z hyunghwan.chung $
*
Copyright 2006-2009 Chung, Hyung-Hwan.
@ -1469,9 +1469,12 @@ qse_awk_val_t* qse_awk_rtx_call (
qse_awk_fun_t* fun;
struct capture_retval_data_t crdata;
qse_awk_val_t* v;
struct pafv pafv = { args, nargs };
struct pafv pafv/*= { args, nargs }*/;
qse_awk_nde_call_t call;
pafv.args = args;
pafv.nargs = nargs;
if (rtx->exit_level >= EXIT_NEXT)
{
/* cannot call the function again when exit() is called

View File

@ -1,5 +1,5 @@
/*
* $Id: std.c 202 2009-06-16 06:05:40Z hyunghwan.chung $
* $Id: std.c 204 2009-06-18 12:08:06Z hyunghwan.chung $
*
Copyright 2006-2009 Chung, Hyung-Hwan.
@ -956,8 +956,9 @@ static int fnc_math_1 (
}
else
{
float (*rf) (float);
QSE_ASSERT (type == FNC_MATH_F);
float (*rf) (float) = (float(*)(float))f;
rf = (float(*)(float))f;
r = qse_awk_rtx_makerealval (run, rf(rv));
}
@ -1008,8 +1009,9 @@ static int fnc_math_2 (
}
else
{
float (*rf) (float,float);
QSE_ASSERT (type == FNC_MATH_F);
float (*rf) (float,float) = (float(*)(float,float))f;
rf = (float(*)(float,float))f;
r = qse_awk_rtx_makerealval (run, rf(rv0,rv1));
}

View File

@ -1,5 +1,5 @@
/*
* $Id: chr.c 127 2009-05-07 13:15:04Z hyunghwan.chung $
* $Id: chr.c 204 2009-06-18 12:08:06Z hyunghwan.chung $
*
Copyright 2006-2009 Chung, Hyung-Hwan.
@ -113,6 +113,7 @@ qse_bool_t qse_ccls_is (qse_cint_t c, qse_ccls_id_t type)
qse_cint_t qse_ccls_to (qse_cint_t c, qse_ccls_id_t type)
{
#ifdef HAVE_WCTRANS
static const char* name[] =
{
"toupper",
@ -126,10 +127,16 @@ qse_cint_t qse_ccls_to (qse_cint_t c, qse_ccls_id_t type)
};
QSE_ASSERTX (type >= QSE_CCLS_UPPER && type <= QSE_CCLS_LOWER,
"The character type should be one of QSE_CCLS_UPPER and QSE_CCLS_LOWER");
"The type should be one of QSE_CCLS_UPPER and QSE_CCLS_LOWER");
if (desc[type] == (wctrans_t)0) desc[type] = wctrans(name[type]);
return towctrans (c, desc[type]);
#else
QSE_ASSERTX (type >= QSE_CCLS_UPPER && type <= QSE_CCLS_LOWER,
"The type should be one of QSE_CCLS_UPPER and QSE_CCLS_LOWER");
return (type == QSE_CCLS_UPPER)? towupper(c): towlower(c);
#endif
}
#else

View File

@ -1,5 +1,5 @@
/*
* $Id: chr_cnv.c 76 2009-02-22 14:18:06Z hyunghwan.chung $
* $Id: chr_cnv.c 204 2009-06-18 12:08:06Z hyunghwan.chung $
*
Copyright 2006-2009 Chung, Hyung-Hwan.
@ -80,6 +80,15 @@ qse_size_t qse_wctomb (qse_wchar_t wc, qse_mchar_t* mb, qse_size_t mblen)
* of a character.
*/
#ifdef _SCO_DS
/* SCO defines MB_CUR_MAX as shown below:
* extern unsigned char __ctype[];
* #define MB_CUR_MAX ((int)__ctype[520])
* Some hacks are needed for compilation with a C89 compiler. */
# undef MB_CUR_MAX
# define MB_CUR_MAX 32
#endif
if (mblen < MB_CUR_MAX)
{
qse_mchar_t buf[MB_CUR_MAX];

View File

@ -1,5 +1,5 @@
/*
* $Id: fio.c 193 2009-06-08 13:09:01Z hyunghwan.chung $
* $Id: fio.c 204 2009-06-18 12:08:06Z hyunghwan.chung $
*
Copyright 2006-2009 Chung, Hyung-Hwan.
@ -29,6 +29,9 @@
# include <sys/types.h>
# include <fcntl.h>
# include <limits.h>
# ifndef PATH_MAX
# define PATH_MAX 2048
# endif
#endif
QSE_IMPLEMENT_COMMON_FUNCTIONS (fio)

View File

@ -1,5 +1,5 @@
/*
* $Id: rex.c 203 2009-06-17 12:43:50Z hyunghwan.chung $
* $Id: rex.c 204 2009-06-18 12:08:06Z hyunghwan.chung $
*
Copyright 2006-2009 Chung, Hyung-Hwan.
@ -1726,7 +1726,12 @@ static const qse_byte_t* match_group (
mat2.match_ptr = mat->match_ptr;
while (si < cp->ubound)
{
if (mat2.match_ptr >= matcher->match.str.end) break;
/* for eol($) check, it should not break when
* mat2.match_ptr == matcher->match.str.end.
* matcher->match.str.end is one character past the
* actual end */
/*if (mat2.match_ptr >= matcher->match.str.end) break;*/
if (mat2.match_ptr > matcher->match.str.end) break;
if (match_pattern (matcher, p, &mat2) == QSE_NULL)
{