added QSE_AWK_INCLUDEDIRS. actual impl still pending

This commit is contained in:
hyung-hwan 2013-01-22 14:20:10 +00:00
parent 0e48b7bc88
commit c7d88c455a
4 changed files with 47 additions and 17 deletions

View File

@ -984,6 +984,8 @@ enum qse_awk_opt_t
QSE_AWK_MODPREFIX,
QSE_AWK_MODPOSTFIX,
QSE_AWK_INCLUDEDIRS,
QSE_AWK_DEPTH_INCLUDE,
QSE_AWK_DEPTH_BLOCK_PARSE,
QSE_AWK_DEPTH_BLOCK_RUN,

View File

@ -434,6 +434,27 @@ void qse_awk_setprm (qse_awk_t* awk, const qse_awk_prm_t* prm)
awk->prm = *prm;
}
static int dup_str_opt (qse_awk_t* awk, const void* value, qse_xstr_t* tmp)
{
if (value)
{
tmp->ptr = qse_strdup (value, awk->mmgr);
if (tmp->ptr == QSE_NULL)
{
qse_awk_seterrnum (awk, QSE_AWK_ENOMEM, QSE_NULL);
return -1;
}
tmp->len = qse_strlen (tmp->ptr);
}
else
{
tmp->ptr = QSE_NULL;
tmp->len = 0;
}
return 0;
}
int qse_awk_setopt (qse_awk_t* awk, qse_awk_opt_t id, const void* value)
{
switch (id)
@ -448,30 +469,26 @@ int qse_awk_setopt (qse_awk_t* awk, qse_awk_opt_t id, const void* value)
qse_xstr_t tmp;
int idx;
idx = id - QSE_AWK_MODPREFIX;
if (value)
{
tmp.ptr = qse_strdup (value, awk->mmgr);
if (tmp.ptr == QSE_NULL)
{
qse_awk_seterrnum (awk, QSE_AWK_ENOMEM, QSE_NULL);
return -1;
}
tmp.len = qse_strlen (tmp.ptr);
}
else
{
tmp.ptr = QSE_NULL;
tmp.len = 0;
}
if (dup_str_opt (awk, value, &tmp) <= -1) return -1;
if (awk->opt.mod[idx].ptr)
idx = id - QSE_AWK_MODPREFIX;
if (awk->opt.mod[idx].ptr)
QSE_MMGR_FREE (awk->mmgr, awk->opt.mod[idx].ptr);
awk->opt.mod[idx] = tmp;
return 0;
}
case QSE_AWK_INCLUDEDIRS:
{
qse_xstr_t tmp;
if (dup_str_opt (awk, value, &tmp) <= -1) return -1;
if (awk->opt.incldirs.ptr)
QSE_MMGR_FREE (awk->mmgr, awk->opt.incldirs.ptr);
awk->opt.incldirs = tmp;
return 0;
}
case QSE_AWK_DEPTH_INCLUDE:
case QSE_AWK_DEPTH_BLOCK_PARSE:
case QSE_AWK_DEPTH_BLOCK_RUN:
@ -500,6 +517,10 @@ int qse_awk_getopt (qse_awk_t* awk, qse_awk_opt_t id, void* value)
*(const qse_char_t**)value = awk->opt.mod[id - QSE_AWK_MODPREFIX].ptr;
return 0;
case QSE_AWK_INCLUDEDIRS:
*(const qse_char_t**)value = awk->opt.incldirs.ptr;
return 0;
case QSE_AWK_DEPTH_INCLUDE:
case QSE_AWK_DEPTH_BLOCK_PARSE:
case QSE_AWK_DEPTH_BLOCK_RUN:

View File

@ -124,6 +124,7 @@ struct qse_awk_t
{
int trait;
qse_xstr_t mod[2];
qse_xstr_t incldirs;
union
{

View File

@ -751,6 +751,12 @@ static int begin_include (qse_awk_t* awk)
/*QSE_HTB_VPTR(pair) = QSE_HTB_KPTR(pair);
QSE_HTB_VLEN(pair) = QSE_HTB_KLEN(pair);*/
if (awk->opt.incldirs.ptr)
{
/* include directory is set... */
/* TODO: */
}
arg = (qse_awk_sio_arg_t*) qse_awk_callocmem (awk, QSE_SIZEOF(*arg));
if (arg == QSE_NULL)
{