touched up code

This commit is contained in:
2009-12-10 05:35:54 +00:00
parent b5dd6fa606
commit 93adbf9244
8 changed files with 93 additions and 100 deletions

View File

@ -1,5 +1,5 @@
/*
* $Id: err.c 307 2009-11-25 13:32:20Z hyunghwan.chung $
* $Id: err.c 311 2009-12-09 11:35:54Z hyunghwan.chung $
*
Copyright 2006-2009 Chung, Hyung-Hwan.
This file is part of QSE.
@ -143,14 +143,12 @@ const qse_char_t* qse_awk_dflerrstr (qse_awk_t* awk, qse_awk_errnum_t errnum)
QSE_T("right parenthesis expected in regular expression"),
QSE_T("right bracket expected in regular expression"),
QSE_T("right brace expected in regular expression"),
QSE_T("unbalanced parenthesis in regular expression"),
QSE_T("invalid brace in regular expression"),
QSE_T("colon expected in regular expression"),
QSE_T("invalid character range in regular expression"),
QSE_T("invalid character class in regular expression"),
QSE_T("invalid occurrence bound in regular expression"),
QSE_T("premature end of regular expression"),
QSE_T("garbage after regular expression")
QSE_T("special character at wrong position"),
QSE_T("premature end of regular expression")
};
return (errnum >= 0 && errnum < QSE_COUNTOF(errstr))?

View File

@ -1,5 +1,5 @@
/*
* $Id: misc.c 307 2009-11-25 13:32:20Z hyunghwan.chung $
* $Id: misc.c 311 2009-12-09 11:35:54Z hyunghwan.chung $
*
Copyright 2006-2009 Chung, Hyung-Hwan.
This file is part of QSE.
@ -1035,14 +1035,12 @@ qse_char_t* qse_awk_rtx_strxnfld (
(err == QSE_REX_ERPAREN)? QSE_AWK_EREXRPAREN: \
(err == QSE_REX_ERBRACK)? QSE_AWK_EREXRBRACK: \
(err == QSE_REX_ERBRACE)? QSE_AWK_EREXRBRACE: \
(err == QSE_REX_EUNBALPAREN)? QSE_AWK_EREXUNBALPAREN: \
(err == QSE_REX_EINVALBRACE)? QSE_AWK_EREXINVALBRACE: \
(err == QSE_REX_ECOLON)? QSE_AWK_EREXCOLON: \
(err == QSE_REX_ECRANGE)? QSE_AWK_EREXCRANGE: \
(err == QSE_REX_ECCLASS)? QSE_AWK_EREXCCLASS: \
(err == QSE_REX_EBOUND)? QSE_AWK_EREXBOUND: \
(err == QSE_REX_ESPCAWP)? QSE_AWK_EREXSPCAWP: \
(err == QSE_REX_EPREEND)? QSE_AWK_EREXPREEND: \
(err == QSE_REX_EGARBAGE)? QSE_AWK_EREXGARBAGE: \
QSE_AWK_EINTERN)
void* qse_awk_buildrex (

View File

@ -1,5 +1,5 @@
/*
* $Id: rex.c 307 2009-11-25 13:32:20Z hyunghwan.chung $
* $Id: rex.c 311 2009-12-09 11:35:54Z hyunghwan.chung $
*
Copyright 2006-2009 Chung, Hyung-Hwan.
This file is part of QSE.
@ -384,22 +384,7 @@ void* qse_buildrex (
if (builder.ptn.curc.type != CT_EOF)
{
if (errnum != QSE_NULL)
{
if (builder.ptn.curc.type == CT_SPECIAL &&
builder.ptn.curc.value == QSE_T(')'))
{
*errnum = QSE_REX_EUNBALPAREN;
}
else if (builder.ptn.curc.type == CT_SPECIAL &&
builder.ptn.curc.value == QSE_T('{'))
{
*errnum = QSE_REX_EINVALBRACE;
}
else
{
*errnum = QSE_REX_EGARBAGE;
}
}
*errnum = QSE_REX_ESPCAWP;
QSE_MMGR_FREE (builder.mmgr, builder.code.buf);
return QSE_NULL;

View File

@ -210,14 +210,12 @@ const qse_char_t* qse_rex_geterrmsg (qse_rex_t* rex)
QSE_T("right parenthesis expected"),
QSE_T("right bracket expected"),
QSE_T("right brace expected"),
QSE_T("unbalanced parenthesis"),
QSE_T("invalid brace"),
QSE_T("colon expected"),
QSE_T("invalid character range"),
QSE_T("invalid character class"),
QSE_T("invalid occurrence bound"),
QSE_T("premature expression end"),
QSE_T("garbage after expression"),
QSE_T("special character at wrong position"),
QSE_T("premature expression end")
};
return (rex->errnum >= 0 && rex->errnum < QSE_COUNTOF(errstr))?
@ -793,6 +791,20 @@ static qse_rex_node_t* comp2 (comp_t* com)
break;
default:
if (com->rex->option & QSE_REX_STRICT)
{
qse_char_t spc[] = QSE_T(")?*+{");
if (com->rex->option & QSE_REX_NOBOUND)
spc[4] = QSE_T('\0');
if (qse_strchr (spc, com->c.value) != QSE_NULL)
{
com->rex->errnum = QSE_REX_ESPCAWP;
return QSE_NULL;
}
}
goto normal_char;
}
}
@ -1202,13 +1214,21 @@ else
qse_printf (QSE_T("adding %d NA\n"), node->id);
*/
if (qse_lda_search (
&e->cand.set[e->cand.pending],
0,
&cand, 1) != QSE_LDA_NIL)
{
return 0;
}
if (qse_lda_search (
&e->cand.set[e->cand.pending],
0, &cand, 1) != QSE_LDA_NIL)
{
/* exclude any existing entries in the array.
* see comp_cand() for the equality test used.
* note this linear search may be a performance bottle neck
* if the arrary grows large. not so sure if it should be
* switched to a different data structure such as a hash table.
* the problem is that most practical regular expressions
* won't have many candidates for a particular match point.
* so i'm a bit skeptical about data struct switching.
*/
return 0;
}
if (qse_lda_insert (
&e->cand.set[e->cand.pending],
@ -1810,8 +1830,9 @@ static int comp_cand (qse_lda_t* lda,
{
cand_t* c1 = (cand_t*)dptr1;
cand_t* c2 = (cand_t*)dptr2;
if (c1->node == c2->node) return 0;
return 1;
return (c1->node == c2->node &&
c1->mptr == c2->mptr &&
c1->occ == c2->occ)? 0: 1;
}
static int init_exec_dds (exec_t* e, qse_mmgr_t* mmgr)