interim commit

This commit is contained in:
hyung-hwan 2009-08-17 02:08:58 +00:00
parent 1caca1fa41
commit 08d87ca85e
11 changed files with 213 additions and 229 deletions

View File

@ -1,7 +1,7 @@
ACLOCAL_AMFLAGS = -I ac/m4
AUTOMAKE_OPTION = foreign
# EXTRA_DIST =
EXTRA_DIST = ac/au ac/m4
SUBDIRS = lib cmd
DIST_SUBDIRS = $(SUBDIRS) include regress samples doc
@ -11,3 +11,6 @@ install-data-hook:
uninstall-hook:
cd include && $(MAKE) uninstall
distclean-local:
$(RM) -r autom4te.cache

View File

@ -211,7 +211,7 @@ top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
ACLOCAL_AMFLAGS = -I ac/m4
AUTOMAKE_OPTION = foreign
# EXTRA_DIST =
EXTRA_DIST = ac/au ac/m4
SUBDIRS = lib cmd
DIST_SUBDIRS = $(SUBDIRS) include regress samples doc
all: all-recursive
@ -575,7 +575,7 @@ distclean: distclean-recursive
-rm -f $(am__CONFIG_DISTCLEAN_FILES)
-rm -f Makefile
distclean-am: clean-am distclean-generic distclean-libtool \
distclean-tags
distclean-local distclean-tags
dvi: dvi-recursive
@ -636,17 +636,18 @@ uninstall-am:
all all-am am--refresh check check-am clean clean-generic \
clean-libtool ctags ctags-recursive dist dist-all dist-bzip2 \
dist-gzip dist-lzma dist-shar dist-tarZ dist-zip distcheck \
distclean distclean-generic distclean-libtool distclean-tags \
distcleancheck distdir distuninstallcheck dvi dvi-am html \
html-am info info-am install install-am install-data \
install-data-am install-data-hook install-dvi install-dvi-am \
install-exec install-exec-am install-html install-html-am \
install-info install-info-am install-man install-pdf \
install-pdf-am install-ps install-ps-am install-strip \
installcheck installcheck-am installdirs installdirs-am \
maintainer-clean maintainer-clean-generic mostlyclean \
mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
tags tags-recursive uninstall uninstall-am uninstall-hook
distclean distclean-generic distclean-libtool distclean-local \
distclean-tags distcleancheck distdir distuninstallcheck dvi \
dvi-am html html-am info info-am install install-am \
install-data install-data-am install-data-hook install-dvi \
install-dvi-am install-exec install-exec-am install-html \
install-html-am install-info install-info-am install-man \
install-pdf install-pdf-am install-ps install-ps-am \
install-strip installcheck installcheck-am installdirs \
installdirs-am maintainer-clean maintainer-clean-generic \
mostlyclean mostlyclean-generic mostlyclean-libtool pdf pdf-am \
ps ps-am tags tags-recursive uninstall uninstall-am \
uninstall-hook
install-data-hook:
@ -654,6 +655,9 @@ install-data-hook:
uninstall-hook:
cd include && $(MAKE) uninstall
distclean-local:
$(RM) -r autom4te.cache
# 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.
.NOEXPORT:

View File

@ -1,5 +1,5 @@
/*
* $Id: awk.h 251 2009-08-10 07:11:16Z hyunghwan.chung $
* $Id: awk.h 255 2009-08-16 08:08:58Z hyunghwan.chung $
*
Copyright 2006-2009 Chung, Hyung-Hwan.
@ -1041,9 +1041,16 @@ void qse_awk_geterrinf (
qse_awk_errinf_t* errinf /**< error information buffer */
);
/**
* The qse_awk_seterrnum() function sets the error information omitting
* error location. You must pass a non-NULL for @a errarg if the specified
* error number @a errnum requires one or more arguments to format an
* error message.
*/
void qse_awk_seterrnum (
qse_awk_t* awk,
qse_awk_errnum_t errnum
qse_awk_t* awk, /**< awk object */
qse_awk_errnum_t errnum, /**< error number */
const qse_cstr_t* errarg /**< arguments to format error message */
);
void qse_awk_seterrinf (
@ -1059,7 +1066,7 @@ void qse_awk_geterror (
);
/**
* The qse_awk_seterror() functon sets
* The qse_awk_seterror() functon sets error information.
*/
void qse_awk_seterror (
qse_awk_t* awk,
@ -1539,8 +1546,9 @@ void qse_awk_rtx_geterror (
);
void qse_awk_rtx_seterrnum (
qse_awk_rtx_t* rtx, /**< runtime context */
qse_awk_errnum_t errnum /**< error number */
qse_awk_rtx_t* rtx, /**< runtime context */
qse_awk_errnum_t errnum, /**< error number */
const qse_cstr_t* errarg /**< arguments to format error message */
);
void qse_awk_rtx_seterrinf (

View File

@ -1,5 +1,5 @@
/*
* $Id: awk.c 248 2009-08-06 08:27:14Z hyunghwan.chung $
* $Id: awk.c 255 2009-08-16 08:08:58Z hyunghwan.chung $
*
Copyright 2006-2009 Chung, Hyung-Hwan.
@ -25,8 +25,6 @@
QSE_IMPLEMENT_COMMON_FUNCTIONS (awk)
#define SETERR(awk,code) qse_awk_seterrnum(awk,code)
static void free_fun (qse_map_t* map, void* vptr, qse_size_t vlen)
{
qse_awk_t* awk = *(qse_awk_t**)QSE_XTN(map);
@ -416,7 +414,7 @@ int qse_awk_setword (
}
else if (okw == QSE_NULL)
{
SETERR (awk, QSE_AWK_EINVAL);
qse_awk_seterrnum (awk, QSE_AWK_EINVAL, QSE_NULL);
return -1;
}
@ -429,7 +427,7 @@ int qse_awk_setword (
(qse_char_t*)okw->ptr, okw->len,
(qse_char_t*)nkw->ptr, nkw->len) == QSE_NULL)
{
SETERR (awk, QSE_AWK_ENOMEM);
qse_awk_seterrnum (awk, QSE_AWK_ENOMEM, QSE_NULL);
return -1;
}
@ -439,7 +437,7 @@ int qse_awk_setword (
(qse_char_t*)okw->ptr, okw->len) == QSE_NULL)
{
qse_map_delete (awk->wtab, okw->ptr, okw->len);
SETERR (awk, QSE_AWK_ENOMEM);
qse_awk_seterrnum (awk, QSE_AWK_ENOMEM, QSE_NULL);
return -1;
}

View File

@ -1,5 +1,5 @@
/*
* $Id: err.c 248 2009-08-06 08:27:14Z hyunghwan.chung $
* $Id: err.c 255 2009-08-16 08:08:58Z hyunghwan.chung $
*
Copyright 2006-2009 Chung, Hyung-Hwan.
@ -205,11 +205,10 @@ void qse_awk_geterror (
}
}
void qse_awk_seterrnum (qse_awk_t* awk, qse_awk_errnum_t errnum)
void qse_awk_seterrnum (
qse_awk_t* awk, qse_awk_errnum_t errnum, const qse_cstr_t* errarg)
{
awk->errinf.num = errnum;
awk->errinf.lin = 0;
awk->errinf.msg[0] = QSE_T('\0');
qse_awk_seterror (awk, errnum, 0, errarg);
}
void qse_awk_seterrinf (qse_awk_t* awk, const qse_awk_errinf_t* errinf)
@ -224,7 +223,6 @@ void qse_awk_seterror (
const qse_char_t* errfmt;
awk->errinf.num = errnum;
awk->errinf.lin = errlin;
errfmt = qse_awk_geterrstr(awk)(awk,errnum);
QSE_ASSERT (errfmt != QSE_NULL);
@ -232,6 +230,8 @@ void qse_awk_seterror (
awk->errinf.msg, QSE_COUNTOF(awk->errinf.msg),
errfmt, errarg
);
awk->errinf.lin = errlin;
}
qse_awk_errnum_t qse_awk_rtx_geterrnum (qse_awk_rtx_t* rtx)
@ -273,11 +273,10 @@ void qse_awk_rtx_geterror (
}
}
void qse_awk_rtx_seterrnum (qse_awk_rtx_t* rtx, qse_awk_errnum_t errnum)
void qse_awk_rtx_seterrnum (
qse_awk_rtx_t* rtx, qse_awk_errnum_t errnum, const qse_cstr_t* errarg)
{
rtx->errinf.num = errnum;
rtx->errinf.lin = 0;
rtx->errinf.msg[0] = QSE_T('\0');
qse_awk_rtx_seterror (rtx, errnum, 0, errarg);
}
void qse_awk_rtx_seterrinf (qse_awk_rtx_t* rtx, const qse_awk_errinf_t* errinf)

View File

@ -1,5 +1,5 @@
/*
* $Id: fnc.c 235 2009-07-15 10:43:31Z hyunghwan.chung $
* $Id: fnc.c 255 2009-08-16 08:08:58Z hyunghwan.chung $
*
Copyright 2006-2009 Chung, Hyung-Hwan.
@ -68,7 +68,7 @@ void* qse_awk_addfnc (
if (name_len <= 0)
{
qse_awk_seterror (awk, QSE_AWK_EINVAL, 0, QSE_NULL);
qse_awk_seterrnum (awk, QSE_AWK_EINVAL, QSE_NULL);
return QSE_NULL;
}
@ -91,7 +91,7 @@ void* qse_awk_addfnc (
(spec_len+1) * QSE_SIZEOF(qse_char_t));
if (fnc == QSE_NULL)
{
qse_awk_seterrnum (awk, QSE_AWK_ENOMEM);
qse_awk_seterrnum (awk, QSE_AWK_ENOMEM, QSE_NULL);
return QSE_NULL;
}
@ -116,7 +116,7 @@ void* qse_awk_addfnc (
(qse_char_t*)name, name_len, fnc, 0) == QSE_NULL)
{
QSE_AWK_FREE (awk, fnc);
qse_awk_seterrnum (awk, QSE_AWK_ENOMEM);
qse_awk_seterrnum (awk, QSE_AWK_ENOMEM, QSE_NULL);
return QSE_NULL;
}
@ -293,11 +293,7 @@ skip_close:
if (a0->type != QSE_AWK_VAL_STR) QSE_AWK_FREE (run->awk, name);
v = qse_awk_rtx_makeintval (run, (qse_long_t)n);
if (v == QSE_NULL)
{
/*qse_awk_rtx_seterrnum (run, QSE_AWK_ENOMEM);*/
return -1;
}
if (v == QSE_NULL) return -1;
qse_awk_rtx_setretval (run, v);
return 0;
@ -401,11 +397,7 @@ static int fnc_fflush (qse_awk_rtx_t* run, const qse_cstr_t* fnm)
}
a0 = qse_awk_rtx_makeintval (run, (qse_long_t)n);
if (a0 == QSE_NULL)
{
/*qse_awk_rtx_seterrnum (run, QSE_AWK_ENOMEM);*/
return -1;
}
if (a0 == QSE_NULL) return -1;
qse_awk_rtx_setretval (run, a0);
return 0;
@ -459,11 +451,7 @@ static int fnc_index (qse_awk_rtx_t* run, const qse_cstr_t* fnm)
if (a1->type != QSE_AWK_VAL_STR) QSE_AWK_FREE (run->awk, str1);
a0 = qse_awk_rtx_makeintval (run, idx);
if (a0 == QSE_NULL)
{
/*qse_awk_rtx_seterrnum (run, QSE_AWK_ENOMEM);*/
return -1;
}
if (a0 == QSE_NULL) return -1;
qse_awk_rtx_setretval (run, a0);
return 0;
@ -500,11 +488,7 @@ static int fnc_length (qse_awk_rtx_t* rtx, const qse_cstr_t* fnm)
}
v = qse_awk_rtx_makeintval (rtx, len);
if (v == QSE_NULL)
{
/*qse_awk_rtx_seterrnum (rtx, QSE_AWK_ENOMEM);*/
return -1;
}
if (v == QSE_NULL) return -1;
qse_awk_rtx_setretval (rtx, v);
return 0;
@ -573,7 +557,6 @@ static int fnc_substr (qse_awk_rtx_t* run, const qse_cstr_t* fnm)
if (r == QSE_NULL)
{
if (a0->type != QSE_AWK_VAL_STR) QSE_AWK_FREE (run->awk, str);
/*qse_awk_rtx_seterrnum (run, QSE_AWK_ENOMEM);*/
return -1;
}
@ -610,14 +593,14 @@ static int fnc_split (qse_awk_rtx_t* run, const qse_cstr_t* fnm)
((qse_awk_val_ref_t*)a1)->id <= QSE_AWK_VAL_REF_ARGIDX)
{
/* an indexed value should not be assigned another map */
qse_awk_rtx_seterrnum (run, QSE_AWK_EIDXVALASSMAP);
qse_awk_rtx_seterrnum (run, QSE_AWK_EIDXVALASSMAP, QSE_NULL);
return -1;
}
if (((qse_awk_val_ref_t*)a1)->id == QSE_AWK_VAL_REF_POS)
{
/* a positional should not be assigned a map */
qse_awk_rtx_seterrnum (run, QSE_AWK_EPOSVALASSMAP);
qse_awk_rtx_seterrnum (run, QSE_AWK_EPOSVALASSMAP, QSE_NULL);
return -1;
}
@ -626,7 +609,7 @@ static int fnc_split (qse_awk_rtx_t* run, const qse_cstr_t* fnm)
(*a1_ref)->type != QSE_AWK_VAL_MAP)
{
/* cannot change a scalar value to a map */
qse_awk_rtx_seterrnum (run, QSE_AWK_ESCALARTOMAP);
qse_awk_rtx_seterrnum (run, QSE_AWK_ESCALARTOMAP, QSE_NULL);
return -1;
}
@ -707,7 +690,7 @@ static int fnc_split (qse_awk_rtx_t* run, const qse_cstr_t* fnm)
QSE_AWK_FREE (run->awk, str_free);
if (fs_free != QSE_NULL)
QSE_AWK_FREE (run->awk, fs_free);
qse_awk_rtx_seterrnum (run, errnum);
qse_awk_rtx_seterrnum (run, errnum, QSE_NULL);
return -1;
}
fs_rex_free = fs_rex;
@ -754,7 +737,7 @@ static int fnc_split (qse_awk_rtx_t* run, const qse_cstr_t* fnm)
QSE_AWK_FREE (run->awk, fs_free);
if (fs_rex_free != QSE_NULL)
QSE_AWK_FREEREX (run->awk, fs_rex_free);
qse_awk_rtx_seterrnum (run, errnum);
qse_awk_rtx_seterrnum (run, errnum, QSE_NULL);
return -1;
}
}
@ -777,7 +760,6 @@ static int fnc_split (qse_awk_rtx_t* run, const qse_cstr_t* fnm)
QSE_AWK_FREE (run->awk, fs_free);
if (fs_rex_free != QSE_NULL)
QSE_AWK_FREEREX (run->awk, fs_rex_free);
/*qse_awk_rtx_seterrnum (run, QSE_AWK_ENOMEM);*/
return -1;
}
@ -809,7 +791,7 @@ static int fnc_split (qse_awk_rtx_t* run, const qse_cstr_t* fnm)
/* qse_map_insert() fails if the key exists.
* that can't happen here. so set the error code
* to ENOMEM */
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOMEM);
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOMEM, QSE_NULL);
return -1;
}
@ -823,11 +805,7 @@ static int fnc_split (qse_awk_rtx_t* run, const qse_cstr_t* fnm)
/*nflds--;*/
t1 = qse_awk_rtx_makeintval (run, nflds);
if (t1 == QSE_NULL)
{
/*qse_awk_rtx_seterrnum (run, QSE_AWK_ENOMEM);*/
return -1;
}
if (t1 == QSE_NULL) return -1;
qse_awk_rtx_setretval (run, t1);
return 0;
@ -862,7 +840,6 @@ static int fnc_tolower (qse_awk_rtx_t* run, const qse_cstr_t* fnm)
if (r == QSE_NULL)
{
if (a0->type != QSE_AWK_VAL_STR) QSE_AWK_FREE (run->awk, str);
/*qse_awk_rtx_seterrnum (run, QSE_AWK_ENOMEM);*/
return -1;
}
@ -900,7 +877,6 @@ static int fnc_toupper (qse_awk_rtx_t* run, const qse_cstr_t* fnm)
if (r == QSE_NULL)
{
if (a0->type != QSE_AWK_VAL_STR) QSE_AWK_FREE (run->awk, str);
/*qse_awk_rtx_seterrnum (run, QSE_AWK_ENOMEM);*/
return -1;
}
@ -1017,7 +993,7 @@ static int __substitute (qse_awk_rtx_t* run, qse_long_t max_count)
{
FREE_A_PTRS (run->awk);
/* a map is not allowed as the third parameter */
qse_awk_rtx_seterrnum (run, QSE_AWK_EMAPNOTALLOWED);
qse_awk_rtx_seterrnum (run, QSE_AWK_EMAPNOTALLOWED, QSE_NULL);
return -1;
}
@ -1041,7 +1017,7 @@ static int __substitute (qse_awk_rtx_t* run, qse_long_t max_count)
if (qse_str_init (&new, run->awk->mmgr, a2_len) == QSE_NULL)
{
FREE_A_PTRS (run->awk);
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOMEM);
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOMEM, QSE_NULL);
return -1;
}
@ -1098,7 +1074,7 @@ static int __substitute (qse_awk_rtx_t* run, qse_long_t max_count)
FREE_A0_REX (run->awk, rex);
qse_str_fini (&new);
FREE_A_PTRS (run->awk);
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOMEM);
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOMEM, QSE_NULL);
return -1;
}
break;
@ -1119,7 +1095,7 @@ static int __substitute (qse_awk_rtx_t* run, qse_long_t max_count)
FREE_A0_REX (run->awk, rex);
qse_str_fini (&new);
FREE_A_PTRS (run->awk);
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOMEM);
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOMEM, QSE_NULL);
return -1;
}
@ -1146,7 +1122,7 @@ static int __substitute (qse_awk_rtx_t* run, qse_long_t max_count)
FREE_A0_REX (run->awk, rex);
qse_str_fini (&new);
FREE_A_PTRS (run->awk);
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOMEM);
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOMEM, QSE_NULL);
return -1;
}
}
@ -1168,7 +1144,7 @@ static int __substitute (qse_awk_rtx_t* run, qse_long_t max_count)
FREE_A0_REX (run->awk, rex);
qse_str_fini (&new);
FREE_A_PTRS (run->awk);
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOMEM);
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOMEM, QSE_NULL);
return -1;
}
@ -1321,11 +1297,7 @@ static int fnc_match (qse_awk_rtx_t* run, const qse_cstr_t* fnm)
idx = (n == 0)? 0: ((qse_long_t)(mat.ptr-str0) + 1);
a0 = qse_awk_rtx_makeintval (run, idx);
if (a0 == QSE_NULL)
{
/*qse_awk_rtx_seterrnum (run, QSE_AWK_ENOMEM);*/
return -1;
}
if (a0 == QSE_NULL) return -1;
qse_awk_rtx_refupval (run, a0);
@ -1334,7 +1306,6 @@ static int fnc_match (qse_awk_rtx_t* run, const qse_cstr_t* fnm)
if (a1 == QSE_NULL)
{
qse_awk_rtx_refdownval (run, a0);
/*qse_awk_rtx_seterrnum (run, QSE_AWK_ENOMEM);*/
return -1;
}
@ -1374,13 +1345,13 @@ static int fnc_sprintf (qse_awk_rtx_t* run, const qse_cstr_t* fnm)
if (qse_str_init (&out, run->awk->mmgr, 256) == QSE_NULL)
{
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOMEM);
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOMEM, QSE_NULL);
return -1;
}
if (qse_str_init (&fbu, run->awk->mmgr, 256) == QSE_NULL)
{
qse_str_fini (&out);
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOMEM);
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOMEM, QSE_NULL);
return -1;
}
@ -1417,7 +1388,6 @@ static int fnc_sprintf (qse_awk_rtx_t* run, const qse_cstr_t* fnm)
{
qse_str_fini (&fbu);
qse_str_fini (&out);
/*qse_awk_rtx_seterrnum (run, QSE_AWK_ENOMEM);*/
return -1;
}

View File

@ -1,5 +1,5 @@
/*
* $Id: parse.c 250 2009-08-10 03:29:59Z hyunghwan.chung $
* $Id: parse.c 255 2009-08-16 08:08:58Z hyunghwan.chung $
*
Copyright 2006-2009 Chung, Hyung-Hwan.
@ -356,9 +356,9 @@ static global_t gtab[] =
#define MATCH(awk,token_type) ((awk)->token.type == (token_type))
#define CLRERR(awk) qse_awk_seterrnum(awk,QSE_AWK_ENOERR)
#define CLRERR(awk) qse_awk_seterrnum(awk,QSE_AWK_ENOERR,QSE_NULL)
#define ISNOERR(awk) ((awk)->errinf.num == QSE_AWK_ENOERR)
#define SETERR(awk,code) qse_awk_seterrnum(awk,code)
#define SETERR(awk,code) qse_awk_seterrnum(awk,code,QSE_NULL)
#define SETERRLIN(awk,code,line) qse_awk_seterror(awk,code,line,QSE_NULL);
#define SETERRTOK(awk,code) \
do { \

View File

@ -1,5 +1,5 @@
/*
* $Id: rec.c 205 2009-06-20 12:47:34Z hyunghwan.chung $
* $Id: rec.c 255 2009-08-16 08:08:58Z hyunghwan.chung $
*
Copyright 2006-2009 Chung, Hyung-Hwan.
@ -43,8 +43,7 @@ int qse_awk_rtx_setrec (
if (qse_str_ncpy (&run->inrec.line, str, len) == (qse_size_t)-1)
{
qse_awk_rtx_clrrec (run, QSE_FALSE);
qse_awk_rtx_seterror (
run, QSE_AWK_ENOMEM, 0, QSE_NULL);
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOMEM, QSE_NULL);
return -1;
}
}
@ -158,7 +157,7 @@ static int split_record (qse_awk_rtx_t* run)
{
if (fs_free != QSE_NULL)
QSE_AWK_FREE (run->awk, fs_free);
qse_awk_rtx_seterror (run, errnum, 0, QSE_NULL);
qse_awk_rtx_seterrnum (run, errnum, QSE_NULL);
return -1;
}
}
@ -186,7 +185,7 @@ static int split_record (qse_awk_rtx_t* run)
if (tmp == QSE_NULL)
{
if (fs_free != QSE_NULL) QSE_AWK_FREE (run->awk, fs_free);
qse_awk_rtx_seterror (run, QSE_AWK_ENOMEM, 0, QSE_NULL);
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOMEM, QSE_NULL);
return -1;
}
@ -220,7 +219,7 @@ static int split_record (qse_awk_rtx_t* run)
{
if (fs_free != QSE_NULL)
QSE_AWK_FREE (run->awk, fs_free);
qse_awk_rtx_seterror (run, errnum, 0, QSE_NULL);
qse_awk_rtx_seterrnum (run, errnum, QSE_NULL);
return -1;
}
}
@ -333,8 +332,7 @@ static int recomp_record_fields (
QSE_SIZEOF(*run->inrec.flds) * max);
if (tmp == QSE_NULL)
{
qse_awk_rtx_seterror (
run, QSE_AWK_ENOMEM, 0, QSE_NULL);
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOMEM, QSE_NULL);
return -1;
}
}
@ -344,8 +342,7 @@ static int recomp_record_fields (
run->awk, QSE_SIZEOF(*run->inrec.flds) * max);
if (tmp == QSE_NULL)
{
qse_awk_rtx_seterror (
run, QSE_AWK_ENOMEM, 0, QSE_NULL);
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOMEM, QSE_NULL);
return -1;
}
if (run->inrec.flds != QSE_NULL)
@ -373,8 +370,7 @@ static int recomp_record_fields (
run->gbl.ofs.ptr,
run->gbl.ofs.len) == (qse_size_t)-1)
{
qse_awk_rtx_seterror (
run, QSE_AWK_ENOMEM, 0, QSE_NULL);
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOMEM, QSE_NULL);
return -1;
}
}
@ -391,8 +387,7 @@ static int recomp_record_fields (
if (qse_str_ncat (
&run->inrec.line, str, len) == (qse_size_t)-1)
{
qse_awk_rtx_seterror (
run, QSE_AWK_ENOMEM, 0, QSE_NULL);
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOMEM, QSE_NULL);
return -1;
}
@ -416,8 +411,7 @@ static int recomp_record_fields (
if (qse_str_cat (
&run->inrec.line, QSE_T("")) == (qse_size_t)-1)
{
qse_awk_rtx_seterror (
run, QSE_AWK_ENOMEM, 0, QSE_NULL);
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOMEM, QSE_NULL);
return -1;
}
@ -443,8 +437,7 @@ static int recomp_record_fields (
if (qse_str_ncat (&run->inrec.line,
tmp->ptr, tmp->len) == (qse_size_t)-1)
{
qse_awk_rtx_seterror (
run, QSE_AWK_ENOMEM, 0, QSE_NULL);
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOMEM, QSE_NULL);
return -1;
}
}

View File

@ -1,5 +1,5 @@
/*
* $Id: rio.c 213 2009-06-26 13:05:19Z hyunghwan.chung $
* $Id: rio.c 255 2009-08-16 08:08:58Z hyunghwan.chung $
*
Copyright 2006-2009 Chung, Hyung-Hwan.
@ -394,8 +394,7 @@ int qse_awk_rtx_readio (
if (qse_str_ccat (buf, c) == (qse_size_t)-1)
{
qse_awk_rtx_seterror (
run, QSE_AWK_ENOMEM, 0, QSE_NULL);
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOMEM);
ret = -1;
break;
}
@ -494,8 +493,7 @@ int qse_awk_rtx_writeio_str (
run->awk, QSE_SIZEOF(qse_awk_rio_arg_t));
if (p == QSE_NULL)
{
qse_awk_rtx_seterror (
run, QSE_AWK_ENOMEM, 0, QSE_NULL);
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOMEM);
return -1;
}
@ -503,8 +501,7 @@ int qse_awk_rtx_writeio_str (
if (p->name == QSE_NULL)
{
QSE_AWK_FREE (run->awk, p);
qse_awk_rtx_seterror (
run, QSE_AWK_ENOMEM, 0, QSE_NULL);
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOMEM);
return -1;
}
@ -675,7 +672,7 @@ int qse_awk_rtx_nextio_read (
/* something is totally wrong */
QSE_ASSERT (
!"should never happen - cannot find the relevant rio entry");
qse_awk_rtx_seterror (run, QSE_AWK_EINTERN, 0, QSE_NULL);
qse_awk_rtx_seterrnum (run, QSE_AWK_EINTERN);
return -1;
}
@ -753,7 +750,7 @@ int qse_awk_rtx_nextio_write (
/* something is totally wrong */
QSE_ASSERT (!"should never happen - cannot find the relevant rio entry");
qse_awk_rtx_seterror (run, QSE_AWK_EINTERN, 0, QSE_NULL);
qse_awk_rtx_seterrnum (run, QSE_AWK_EINTERN);
return -1;
}
@ -826,7 +823,7 @@ int qse_awk_rtx_closio_read (
if (handler (run, QSE_AWK_RIO_CLOSE, p, QSE_NULL, 0) <= -1)
{
/* this is not a run-time error.*/
qse_awk_rtx_seterror (run, QSE_AWK_EIOIMPL, 0, QSE_NULL);
qse_awk_rtx_seterrnum (run, QSE_AWK_EIOIMPL);
return -1;
}
}
@ -868,7 +865,7 @@ int qse_awk_rtx_closio_write (
if (handler == QSE_NULL)
{
/* no io handler provided */
qse_awk_rtx_seterror (run, QSE_AWK_EIOUSER, 0, QSE_NULL);
qse_awk_rtx_seterrnum (run, QSE_AWK_EIOUSER);
return -1;
}

View File

@ -1,5 +1,5 @@
/*
* $Id: run.c 236 2009-07-16 08:27:53Z hyunghwan.chung $
* $Id: run.c 255 2009-08-16 08:08:58Z hyunghwan.chung $
*
Copyright 2006-2009 Chung, Hyung-Hwan.
@ -317,7 +317,7 @@ static int set_global (
idx != QSE_AWK_GBL_ARGV)
{
/* TODO: better error code */
qse_awk_rtx_seterrnum (run, QSE_AWK_ESCALARTOMAP);
qse_awk_rtx_seterrnum (run, QSE_AWK_ESCALARTOMAP, QSE_NULL);
return -1;
}
@ -335,7 +335,8 @@ static int set_global (
{
/* '\0' is included in the value */
QSE_AWK_FREE (run->awk, out.u.cpldup.ptr);
qse_awk_rtx_seterrnum (run, QSE_AWK_ECONVFMTCHR);
qse_awk_rtx_seterrnum (
run, QSE_AWK_ECONVFMTCHR, QSE_NULL);
return -1;
}
}
@ -465,7 +466,8 @@ static int set_global (
if (out.u.cpldup.ptr[i] == QSE_T('\0'))
{
QSE_AWK_FREE (run->awk, out.u.cpldup.ptr);
qse_awk_rtx_seterrnum (run, QSE_AWK_EOFMTCHR);
qse_awk_rtx_seterrnum (
run, QSE_AWK_EOFMTCHR, QSE_NULL);
return -1;
}
}
@ -655,7 +657,7 @@ qse_awk_rtx_t* qse_awk_rtx_open (
QSE_ASSERTX (awk->prm.sprintf != QSE_NULL, "Call qse_awk_setprm() first");
/* clear the awk error code */
qse_awk_seterror (awk, QSE_AWK_ENOERR, 0, QSE_NULL);
qse_awk_seterrnum (awk, QSE_AWK_ENOERR, QSE_NULL);
/* check if the code has ever been parsed */
if (awk->tree.ngbls == 0 &&
@ -664,7 +666,7 @@ qse_awk_rtx_t* qse_awk_rtx_open (
awk->tree.chain_size == 0 &&
qse_map_getsize(awk->tree.funs) == 0)
{
qse_awk_seterror (awk, QSE_AWK_ENOPER, 0, QSE_NULL);
qse_awk_seterrnum (awk, QSE_AWK_ENOPER, QSE_NULL);
return QSE_NULL;
}
@ -675,7 +677,7 @@ qse_awk_rtx_t* qse_awk_rtx_open (
{
/* if it fails, the failure is reported thru
* the awk object */
qse_awk_seterror (awk, QSE_AWK_ENOMEM, 0, QSE_NULL);
qse_awk_seterrnum (awk, QSE_AWK_ENOMEM, QSE_NULL);
return QSE_NULL;
}
@ -774,14 +776,14 @@ static int init_rtx (qse_awk_rtx_t* rtx, qse_awk_t* awk, qse_awk_rio_t* rio)
if (qse_str_init (
&rtx->inrec.line, MMGR(rtx), DEF_BUF_CAPA) == QSE_NULL)
{
qse_awk_seterror (awk, QSE_AWK_ENOMEM, 0, QSE_NULL);
qse_awk_seterrnum (awk, QSE_AWK_ENOMEM, QSE_NULL);
return -1;
}
if (qse_str_init (&rtx->format.out, MMGR(rtx), 256) == QSE_NULL)
{
qse_str_fini (&rtx->inrec.line);
qse_awk_seterror (awk, QSE_AWK_ENOMEM, 0, QSE_NULL);
qse_awk_seterrnum (awk, QSE_AWK_ENOMEM, QSE_NULL);
return -1;
}
@ -789,7 +791,7 @@ static int init_rtx (qse_awk_rtx_t* rtx, qse_awk_t* awk, qse_awk_rio_t* rio)
{
qse_str_fini (&rtx->format.out);
qse_str_fini (&rtx->inrec.line);
qse_awk_seterror (awk, QSE_AWK_ENOMEM, 0, QSE_NULL);
qse_awk_seterrnum (awk, QSE_AWK_ENOMEM, QSE_NULL);
return -1;
}
@ -800,7 +802,7 @@ static int init_rtx (qse_awk_rtx_t* rtx, qse_awk_t* awk, qse_awk_rio_t* rio)
qse_str_fini (&rtx->format.fmt);
qse_str_fini (&rtx->format.out);
qse_str_fini (&rtx->inrec.line);
qse_awk_seterror (awk, QSE_AWK_ENOMEM, 0, QSE_NULL);
qse_awk_seterrnum (awk, QSE_AWK_ENOMEM, QSE_NULL);
return -1;
}
*(qse_awk_rtx_t**)QSE_XTN(rtx->named) = rtx;
@ -817,7 +819,7 @@ static int init_rtx (qse_awk_rtx_t* rtx, qse_awk_t* awk, qse_awk_rio_t* rio)
qse_str_fini (&rtx->format.fmt);
qse_str_fini (&rtx->format.out);
qse_str_fini (&rtx->inrec.line);
qse_awk_seterror (awk, QSE_AWK_ENOMEM, 0, QSE_NULL);
qse_awk_seterrnum (awk, QSE_AWK_ENOMEM, QSE_NULL);
return -1;
}
rtx->format.tmp.len = 4096;
@ -834,7 +836,7 @@ static int init_rtx (qse_awk_rtx_t* rtx, qse_awk_t* awk, qse_awk_rio_t* rio)
qse_str_fini (&rtx->format.fmt);
qse_str_fini (&rtx->format.out);
qse_str_fini (&rtx->inrec.line);
qse_awk_seterror (awk, QSE_AWK_ENOMEM, 0, QSE_NULL);
qse_awk_seterrnum (awk, QSE_AWK_ENOMEM, QSE_NULL);
return -1;
}
@ -1035,7 +1037,8 @@ static int build_runarg (
* map will be freeed when v_argv is freed */
qse_awk_rtx_refdownval (run, v_argv);
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOMEM);
qse_awk_rtx_seterrnum (
run, QSE_AWK_ENOMEM, QSE_NULL);
return -1;
}
}
@ -1142,7 +1145,7 @@ static int prepare_globals (qse_awk_rtx_t* run, const qse_cstr_t* runarg)
--ngbls;
if (__raw_push(run,qse_awk_val_nil) == -1)
{
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOMEM);
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOMEM, QSE_NULL);
goto oops;
}
}
@ -1304,7 +1307,7 @@ oops:
* it is ok to do so as the values pushed are
* nils and binary numbers. */
run->stack_top = saved_stack_top;
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOMEM);
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOMEM, QSE_NULL);
return -1;
}
@ -1466,7 +1469,7 @@ qse_awk_val_t* qse_awk_rtx_call (
{
/* cannot call the function again when exit() is called
* in an AWK program or qse_awk_rtx_stop() is invoked */
qse_awk_rtx_seterror (rtx, QSE_AWK_ENOPER, 0, QSE_NULL);
qse_awk_rtx_seterrnum (rtx, QSE_AWK_ENOPER, QSE_NULL);
return QSE_NULL;
}
/*rtx->exit_level = EXIT_NONE;*/
@ -1500,7 +1503,7 @@ qse_awk_val_t* qse_awk_rtx_call (
{
/* TODO: is this correct? what if i want to
* allow arbitarary numbers of arguments? */
qse_awk_rtx_seterror (rtx, QSE_AWK_EARGTM, 0, QSE_NULL);
qse_awk_rtx_seterrnum (rtx, QSE_AWK_EARGTM, QSE_NULL);
return QSE_NULL;
}
@ -3881,7 +3884,7 @@ static qse_awk_val_t* eval_binop_bor (
if (n1 == -1 || n2 == -1)
{
qse_awk_rtx_seterrnum (run, QSE_AWK_EOPERAND);
qse_awk_rtx_seterrnum (run, QSE_AWK_EOPERAND, QSE_NULL);
return QSE_NULL;
}
@ -3905,7 +3908,7 @@ static qse_awk_val_t* eval_binop_bxor (
if (n1 == -1 || n2 == -1)
{
qse_awk_rtx_seterrnum (run, QSE_AWK_EOPERAND);
qse_awk_rtx_seterrnum (run, QSE_AWK_EOPERAND, QSE_NULL);
return QSE_NULL;
}
@ -3929,7 +3932,7 @@ static qse_awk_val_t* eval_binop_band (
if (n1 == -1 || n2 == -1)
{
qse_awk_rtx_seterrnum (run, QSE_AWK_EOPERAND);
qse_awk_rtx_seterrnum (run, QSE_AWK_EOPERAND, QSE_NULL);
return QSE_NULL;
}
@ -4253,7 +4256,7 @@ static int __cmp_val (
if (left->type == QSE_AWK_VAL_MAP || right->type == QSE_AWK_VAL_MAP)
{
/* a map can't be compared againt other values */
qse_awk_rtx_seterrnum (run, QSE_AWK_EOPERAND);
qse_awk_rtx_seterrnum (run, QSE_AWK_EOPERAND, QSE_NULL);
return CMP_ERROR;
}
@ -4327,7 +4330,7 @@ static qse_awk_val_t* eval_binop_lshift (
if (n1 == -1 || n2 == -1)
{
qse_awk_rtx_seterrnum (run, QSE_AWK_EOPERAND);
qse_awk_rtx_seterrnum (run, QSE_AWK_EOPERAND, QSE_NULL);
return QSE_NULL;
}
@ -4338,7 +4341,7 @@ static qse_awk_val_t* eval_binop_lshift (
}
else
{
qse_awk_rtx_seterrnum (run, QSE_AWK_EOPERAND);
qse_awk_rtx_seterrnum (run, QSE_AWK_EOPERAND, QSE_NULL);
return QSE_NULL;
}
}
@ -4355,7 +4358,7 @@ static qse_awk_val_t* eval_binop_rshift (
if (n1 == -1 || n2 == -1)
{
qse_awk_rtx_seterrnum (run, QSE_AWK_EOPERAND);
qse_awk_rtx_seterrnum (run, QSE_AWK_EOPERAND, QSE_NULL);
return QSE_NULL;
}
@ -4367,7 +4370,7 @@ static qse_awk_val_t* eval_binop_rshift (
}
else
{
qse_awk_rtx_seterrnum (run, QSE_AWK_EOPERAND);
qse_awk_rtx_seterrnum (run, QSE_AWK_EOPERAND, QSE_NULL);
return QSE_NULL;
}
}
@ -4384,7 +4387,7 @@ static qse_awk_val_t* eval_binop_plus (
if (n1 == -1 || n2 == -1)
{
qse_awk_rtx_seterrnum (run, QSE_AWK_EOPERAND);
qse_awk_rtx_seterrnum (run, QSE_AWK_EOPERAND, QSE_NULL);
return QSE_NULL;
}
/*
@ -4415,7 +4418,7 @@ static qse_awk_val_t* eval_binop_minus (
if (n1 == -1 || n2 == -1)
{
qse_awk_rtx_seterrnum (run, QSE_AWK_EOPERAND);
qse_awk_rtx_seterrnum (run, QSE_AWK_EOPERAND, QSE_NULL);
return QSE_NULL;
}
@ -4439,7 +4442,7 @@ static qse_awk_val_t* eval_binop_mul (
if (n1 == -1 || n2 == -1)
{
qse_awk_rtx_seterrnum (run, QSE_AWK_EOPERAND);
qse_awk_rtx_seterrnum (run, QSE_AWK_EOPERAND, QSE_NULL);
return QSE_NULL;
}
@ -4464,7 +4467,7 @@ static qse_awk_val_t* eval_binop_div (
if (n1 == -1 || n2 == -1)
{
qse_awk_rtx_seterrnum (run, QSE_AWK_EOPERAND);
qse_awk_rtx_seterrnum (run, QSE_AWK_EOPERAND, QSE_NULL);
return QSE_NULL;
}
@ -4473,7 +4476,7 @@ static qse_awk_val_t* eval_binop_div (
{
if (l2 == 0)
{
qse_awk_rtx_seterrnum (run, QSE_AWK_EDIVBY0);
qse_awk_rtx_seterrnum (run, QSE_AWK_EDIVBY0, QSE_NULL);
return QSE_NULL;
}
@ -4521,7 +4524,7 @@ static qse_awk_val_t* eval_binop_idiv (
if (n1 == -1 || n2 == -1)
{
qse_awk_rtx_seterrnum (run, QSE_AWK_EOPERAND);
qse_awk_rtx_seterrnum (run, QSE_AWK_EOPERAND, QSE_NULL);
return QSE_NULL;
}
@ -4530,7 +4533,7 @@ static qse_awk_val_t* eval_binop_idiv (
{
if (l2 == 0)
{
qse_awk_rtx_seterrnum (run, QSE_AWK_EDIVBY0);
qse_awk_rtx_seterrnum (run, QSE_AWK_EDIVBY0, QSE_NULL);
return QSE_NULL;
}
res = qse_awk_rtx_makeintval (
@ -4570,7 +4573,7 @@ static qse_awk_val_t* eval_binop_mod (
if (n1 == -1 || n2 == -1)
{
qse_awk_rtx_seterrnum (run, QSE_AWK_EOPERAND);
qse_awk_rtx_seterrnum (run, QSE_AWK_EOPERAND, QSE_NULL);
return QSE_NULL;
}
@ -4579,7 +4582,7 @@ static qse_awk_val_t* eval_binop_mod (
{
if (l2 == 0)
{
qse_awk_rtx_seterrnum (run, QSE_AWK_EDIVBY0);
qse_awk_rtx_seterrnum (run, QSE_AWK_EDIVBY0, QSE_NULL);
return QSE_NULL;
}
res = qse_awk_rtx_makeintval (
@ -4587,7 +4590,7 @@ static qse_awk_val_t* eval_binop_mod (
}
else
{
qse_awk_rtx_seterrnum (run, QSE_AWK_EOPERAND);
qse_awk_rtx_seterrnum (run, QSE_AWK_EOPERAND, QSE_NULL);
return QSE_NULL;
}
@ -4610,7 +4613,7 @@ static qse_awk_val_t* eval_binop_exp (
if (n1 == -1 || n2 == -1)
{
qse_awk_rtx_seterrnum (run, QSE_AWK_EOPERAND);
qse_awk_rtx_seterrnum (run, QSE_AWK_EOPERAND, QSE_NULL);
return QSE_NULL;
}
@ -4626,7 +4629,7 @@ static qse_awk_val_t* eval_binop_exp (
}
else if (l1 == 0)
{
qse_awk_rtx_seterrnum (run, QSE_AWK_EDIVBY0);
qse_awk_rtx_seterrnum (run, QSE_AWK_EDIVBY0, QSE_NULL);
return QSE_NULL;
}
else
@ -4648,7 +4651,7 @@ static qse_awk_val_t* eval_binop_exp (
}
else if (r1 == 0.0)
{
qse_awk_rtx_seterrnum (run, QSE_AWK_EDIVBY0);
qse_awk_rtx_seterrnum (run, QSE_AWK_EDIVBY0, QSE_NULL);
return QSE_NULL;
}
else
@ -6557,7 +6560,7 @@ static int shorten_record (qse_awk_rtx_t* run, qse_size_t nflds)
if (ofs_free != QSE_NULL)
QSE_AWK_FREE (run->awk, ofs_free);
if (nflds > 1) qse_awk_rtx_refdownval (run, v);
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOMEM);
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOMEM, QSE_NULL);
return -1;
}
@ -6569,7 +6572,7 @@ static int shorten_record (qse_awk_rtx_t* run, qse_size_t nflds)
if (ofs_free != QSE_NULL)
QSE_AWK_FREE (run->awk, ofs_free);
if (nflds > 1) qse_awk_rtx_refdownval (run, v);
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOMEM);
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOMEM, QSE_NULL);
return -1;
}
@ -6581,7 +6584,7 @@ static int shorten_record (qse_awk_rtx_t* run, qse_size_t nflds)
if (ofs_free != QSE_NULL)
QSE_AWK_FREE (run->awk, ofs_free);
if (nflds > 1) qse_awk_rtx_refdownval (run, v);
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOMEM);
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOMEM, QSE_NULL);
return -1;
}
}
@ -6742,7 +6745,7 @@ qse_char_t* qse_awk_rtx_format (
do { \
if (qse_str_ccat (out, (c)) == -1) \
{ \
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOMEM); \
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOMEM, QSE_NULL); \
return QSE_NULL; \
} \
} while (0)
@ -6751,7 +6754,7 @@ qse_char_t* qse_awk_rtx_format (
do { \
if (qse_str_ccat (fbu, (c)) == -1) \
{ \
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOMEM); \
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOMEM, QSE_NULL); \
return QSE_NULL; \
} \
} while (0)
@ -6820,7 +6823,7 @@ qse_char_t* qse_awk_rtx_format (
{
if (stack_arg_idx >= nargs_on_stack)
{
qse_awk_rtx_seterrnum (run, QSE_AWK_EFMTARG);
qse_awk_rtx_seterrnum (run, QSE_AWK_EFMTARG, QSE_NULL);
return QSE_NULL;
}
v = qse_awk_rtx_getarg (run, stack_arg_idx);
@ -6831,7 +6834,7 @@ qse_char_t* qse_awk_rtx_format (
{
if (stack_arg_idx >= nargs_on_stack)
{
qse_awk_rtx_seterrnum (run, QSE_AWK_EFMTARG);
qse_awk_rtx_seterrnum (run, QSE_AWK_EFMTARG, QSE_NULL);
return QSE_NULL;
}
v = val;
@ -6873,7 +6876,7 @@ qse_char_t* qse_awk_rtx_format (
GROW (&run->format.tmp);
if (run->format.tmp.ptr == QSE_NULL)
{
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOMEM);
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOMEM, QSE_NULL);
return QSE_NULL;
}
@ -6926,7 +6929,7 @@ qse_char_t* qse_awk_rtx_format (
{
if (stack_arg_idx >= nargs_on_stack)
{
qse_awk_rtx_seterrnum (run, QSE_AWK_EFMTARG);
qse_awk_rtx_seterrnum (run, QSE_AWK_EFMTARG, QSE_NULL);
return QSE_NULL;
}
v = qse_awk_rtx_getarg (run, stack_arg_idx);
@ -6937,7 +6940,7 @@ qse_char_t* qse_awk_rtx_format (
{
if (stack_arg_idx >= nargs_on_stack)
{
qse_awk_rtx_seterrnum (run, QSE_AWK_EFMTARG);
qse_awk_rtx_seterrnum (run, QSE_AWK_EFMTARG, QSE_NULL);
return QSE_NULL;
}
v = val;
@ -6977,7 +6980,7 @@ qse_char_t* qse_awk_rtx_format (
GROW (&run->format.tmp);
if (run->format.tmp.ptr == QSE_NULL)
{
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOMEM);
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOMEM, QSE_NULL);
return QSE_NULL;
}
@ -7047,7 +7050,7 @@ qse_char_t* qse_awk_rtx_format (
{
if (stack_arg_idx >= nargs_on_stack)
{
qse_awk_rtx_seterrnum (run, QSE_AWK_EFMTARG);
qse_awk_rtx_seterrnum (run, QSE_AWK_EFMTARG, QSE_NULL);
return QSE_NULL;
}
v = qse_awk_rtx_getarg (run, stack_arg_idx);
@ -7058,7 +7061,7 @@ qse_char_t* qse_awk_rtx_format (
{
if (stack_arg_idx >= nargs_on_stack)
{
qse_awk_rtx_seterrnum (run, QSE_AWK_EFMTARG);
qse_awk_rtx_seterrnum (run, QSE_AWK_EFMTARG, QSE_NULL);
return QSE_NULL;
}
v = val;
@ -7100,7 +7103,7 @@ qse_char_t* qse_awk_rtx_format (
GROW (&run->format.tmp);
if (run->format.tmp.ptr == QSE_NULL)
{
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOMEM);
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOMEM, QSE_NULL);
return QSE_NULL;
}
@ -7135,7 +7138,7 @@ qse_char_t* qse_awk_rtx_format (
{
if (stack_arg_idx >= nargs_on_stack)
{
qse_awk_rtx_seterrnum (run, QSE_AWK_EFMTARG);
qse_awk_rtx_seterrnum (run, QSE_AWK_EFMTARG, QSE_NULL);
return QSE_NULL;
}
v = qse_awk_rtx_getarg (run, stack_arg_idx);
@ -7146,7 +7149,7 @@ qse_char_t* qse_awk_rtx_format (
{
if (stack_arg_idx >= nargs_on_stack)
{
qse_awk_rtx_seterrnum (run, QSE_AWK_EFMTARG);
qse_awk_rtx_seterrnum (run, QSE_AWK_EFMTARG, QSE_NULL);
return QSE_NULL;
}
v = val;
@ -7184,7 +7187,7 @@ qse_char_t* qse_awk_rtx_format (
GROW (&run->format.tmp);
if (run->format.tmp.ptr == QSE_NULL)
{
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOMEM);
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOMEM, QSE_NULL);
return QSE_NULL;
}
@ -7212,7 +7215,7 @@ qse_char_t* qse_awk_rtx_format (
{
if (stack_arg_idx >= nargs_on_stack)
{
qse_awk_rtx_seterrnum (run, QSE_AWK_EFMTARG);
qse_awk_rtx_seterrnum (run, QSE_AWK_EFMTARG, QSE_NULL);
return QSE_NULL;
}
v = qse_awk_rtx_getarg (run, stack_arg_idx);
@ -7223,7 +7226,7 @@ qse_char_t* qse_awk_rtx_format (
{
if (stack_arg_idx >= nargs_on_stack)
{
qse_awk_rtx_seterrnum (run, QSE_AWK_EFMTARG);
qse_awk_rtx_seterrnum (run, QSE_AWK_EFMTARG, QSE_NULL);
return QSE_NULL;
}
v = val;
@ -7264,7 +7267,7 @@ qse_char_t* qse_awk_rtx_format (
else
{
qse_awk_rtx_refdownval (run, v);
qse_awk_rtx_seterrnum (run, QSE_AWK_EVALTYPE);
qse_awk_rtx_seterrnum (run, QSE_AWK_EVALTYPE, QSE_NULL);
return QSE_NULL;
}
@ -7278,7 +7281,8 @@ qse_char_t* qse_awk_rtx_format (
if (qse_str_ccat (out, QSE_T(' ')) == -1)
{
qse_awk_rtx_refdownval (run, v);
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOMEM);
qse_awk_rtx_seterrnum (
run, QSE_AWK_ENOMEM, QSE_NULL);
return QSE_NULL;
}
width--;
@ -7290,7 +7294,8 @@ qse_char_t* qse_awk_rtx_format (
if (qse_str_ccat (out, ch) == -1)
{
qse_awk_rtx_refdownval (run, v);
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOMEM);
qse_awk_rtx_seterrnum (
run, QSE_AWK_ENOMEM, QSE_NULL);
return QSE_NULL;
}
}
@ -7302,7 +7307,8 @@ qse_char_t* qse_awk_rtx_format (
if (qse_str_ccat (out, QSE_T(' ')) == -1)
{
qse_awk_rtx_refdownval (run, v);
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOMEM);
qse_awk_rtx_seterrnum (
run, QSE_AWK_ENOMEM, QSE_NULL);
return QSE_NULL;
}
width--;
@ -7322,7 +7328,8 @@ qse_char_t* qse_awk_rtx_format (
{
if (stack_arg_idx >= nargs_on_stack)
{
qse_awk_rtx_seterrnum (run, QSE_AWK_EFMTARG);
qse_awk_rtx_seterrnum (
run, QSE_AWK_EFMTARG, QSE_NULL);
return QSE_NULL;
}
v = qse_awk_rtx_getarg (run, stack_arg_idx);
@ -7333,7 +7340,8 @@ qse_char_t* qse_awk_rtx_format (
{
if (stack_arg_idx >= nargs_on_stack)
{
qse_awk_rtx_seterrnum (run, QSE_AWK_EFMTARG);
qse_awk_rtx_seterrnum (
run, QSE_AWK_EFMTARG, QSE_NULL);
return QSE_NULL;
}
v = val;
@ -7363,7 +7371,8 @@ qse_char_t* qse_awk_rtx_format (
if (v == val)
{
qse_awk_rtx_refdownval (run, v);
qse_awk_rtx_seterrnum (run, QSE_AWK_EFMTCNV);
qse_awk_rtx_seterrnum (
run, QSE_AWK_EFMTCNV, QSE_NULL);
return QSE_NULL;
}
@ -7391,7 +7400,8 @@ qse_char_t* qse_awk_rtx_format (
if (str_free != QSE_NULL)
QSE_AWK_FREE (run->awk, str_free);
qse_awk_rtx_refdownval (run, v);
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOMEM);
qse_awk_rtx_seterrnum (
run, QSE_AWK_ENOMEM, QSE_NULL);
return QSE_NULL;
}
width--;
@ -7405,7 +7415,8 @@ qse_char_t* qse_awk_rtx_format (
if (str_free != QSE_NULL)
QSE_AWK_FREE (run->awk, str_free);
qse_awk_rtx_refdownval (run, v);
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOMEM);
qse_awk_rtx_seterrnum (
run, QSE_AWK_ENOMEM, QSE_NULL);
return QSE_NULL;
}
}
@ -7419,7 +7430,8 @@ qse_char_t* qse_awk_rtx_format (
if (qse_str_ccat (out, QSE_T(' ')) == -1)
{
qse_awk_rtx_refdownval (run, v);
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOMEM);
qse_awk_rtx_seterrnum (
run, QSE_AWK_ENOMEM, QSE_NULL);
return QSE_NULL;
}
width--;

View File

@ -1,5 +1,5 @@
/*
* $Id: val.c 228 2009-07-11 03:01:36Z hyunghwan.chung $
* $Id: val.c 255 2009-08-16 08:08:58Z hyunghwan.chung $
*
Copyright 2006-2009 Chung, Hyung-Hwan.
@ -81,7 +81,7 @@ qse_awk_val_t* qse_awk_rtx_makeintval (qse_awk_rtx_t* run, qse_long_t v)
run->awk, QSE_SIZEOF(qse_awk_val_int_t));
if (val == QSE_NULL)
{
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOMEM);
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOMEM, QSE_NULL);
return QSE_NULL;
}
}
@ -104,7 +104,7 @@ qse_awk_val_t* qse_awk_rtx_makeintval (qse_awk_rtx_t* run, qse_long_t v)
c = QSE_AWK_ALLOC (run->awk, QSE_SIZEOF(qse_awk_val_ichunk_t));
if (c == QSE_NULL)
{
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOMEM);
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOMEM, QSE_NULL);
return QSE_NULL;
}
@ -157,7 +157,7 @@ qse_awk_val_t* qse_awk_rtx_makerealval (qse_awk_rtx_t* run, qse_real_t v)
run->awk, QSE_SIZEOF(qse_awk_val_real_t));
if (val == QSE_NULL)
{
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOMEM);
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOMEM, QSE_NULL);
return QSE_NULL;
}
}
@ -175,7 +175,7 @@ qse_awk_val_t* qse_awk_rtx_makerealval (qse_awk_rtx_t* run, qse_real_t v)
c = QSE_AWK_ALLOC (run->awk, QSE_SIZEOF(qse_awk_val_rchunk_t));
if (c == QSE_NULL)
{
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOMEM);
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOMEM, QSE_NULL);
return QSE_NULL;
}
@ -251,7 +251,7 @@ qse_awk_val_t* qse_awk_rtx_makestrval (
(rlen+1)*QSE_SIZEOF(qse_char_t));
if (val == QSE_NULL)
{
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOMEM);
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOMEM, QSE_NULL);
return QSE_NULL;
}
/*
@ -280,7 +280,7 @@ qse_awk_val_t* qse_awk_rtx_makestrval_nodup (
run->awk, QSE_SIZEOF(qse_awk_val_str_t));
if (val == QSE_NULL)
{
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOMEM);
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOMEM, QSE_NULL);
return QSE_NULL;
}
@ -325,7 +325,7 @@ qse_awk_val_t* qse_awk_rtx_makestrval2 (
(rlen+1)*QSE_SIZEOF(qse_char_t));
if (val == QSE_NULL)
{
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOMEM);
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOMEM, QSE_NULL);
return QSE_NULL;
}
@ -391,7 +391,7 @@ qse_awk_val_t* qse_awk_rtx_makerexval (
val = (qse_awk_val_rex_t*) QSE_AWK_ALLOC (run->awk, totsz);
if (val == QSE_NULL)
{
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOMEM);
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOMEM, QSE_NULL);
return QSE_NULL;
}
@ -443,7 +443,7 @@ qse_awk_val_t* qse_awk_rtx_makemapval (qse_awk_rtx_t* run)
run->awk, QSE_SIZEOF(qse_awk_val_map_t) );
if (val == QSE_NULL)
{
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOMEM);
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOMEM, QSE_NULL);
return QSE_NULL;
}
@ -455,7 +455,7 @@ qse_awk_val_t* qse_awk_rtx_makemapval (qse_awk_rtx_t* run)
if (val->map == QSE_NULL)
{
QSE_AWK_FREE (run->awk, val);
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOMEM);
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOMEM, QSE_NULL);
return QSE_NULL;
}
*/
@ -467,7 +467,7 @@ qse_awk_val_t* qse_awk_rtx_makemapval (qse_awk_rtx_t* run)
QSE_SIZEOF(run));
if (val == QSE_NULL)
{
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOMEM);
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOMEM, QSE_NULL);
return QSE_NULL;
}
@ -480,7 +480,7 @@ qse_awk_val_t* qse_awk_rtx_makemapval (qse_awk_rtx_t* run)
if (val->map == QSE_NULL)
{
QSE_AWK_FREE (run->awk, val);
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOMEM);
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOMEM, QSE_NULL);
return QSE_NULL;
}
*(qse_awk_rtx_t**)QSE_XTN(val->map) = run;
@ -514,7 +514,7 @@ qse_awk_val_t* qse_awk_rtx_makerefval (qse_awk_rtx_t* run, int id, qse_awk_val_t
run->awk, QSE_SIZEOF(qse_awk_val_ref_t));
if (val == QSE_NULL)
{
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOMEM);
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOMEM, QSE_NULL);
return QSE_NULL;
}
}
@ -726,7 +726,7 @@ static qse_char_t* str_to_str (
tmp = QSE_AWK_STRXDUP (run->awk, str, str_len);
if (tmp == QSE_NULL)
{
qse_awk_rtx_seterror (run, QSE_AWK_ENOMEM, 0, QSE_NULL);
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOMEM, QSE_NULL);
return QSE_NULL;
}
@ -739,7 +739,7 @@ static qse_char_t* str_to_str (
if (str_len >= *len)
{
qse_awk_rtx_seterror (run, QSE_AWK_EINVAL, 0, QSE_NULL);
qse_awk_rtx_seterrnum (run, QSE_AWK_EINVAL, QSE_NULL);
*len = str_len + 1;
return QSE_NULL;
}
@ -755,7 +755,7 @@ static qse_char_t* str_to_str (
n = qse_str_ncat (buf, str, str_len);
if (n == (qse_size_t)-1)
{
qse_awk_rtx_seterror (run, QSE_AWK_ENOMEM, 0, QSE_NULL);
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOMEM, QSE_NULL);
return QSE_NULL;
}
@ -777,7 +777,7 @@ static qse_char_t* str_to_str (
{
if (str_len >= out->u.cpl.len)
{
qse_awk_rtx_seterrnum (rtx, QSE_AWK_EINVAL);
qse_awk_rtx_seterrnum (rtx, QSE_AWK_EINVAL, QSE_NULL);
out->u.cpl.len = str_len + 1;
return QSE_NULL;
}
@ -794,7 +794,7 @@ static qse_char_t* str_to_str (
tmp = QSE_AWK_STRXDUP (rtx->awk, str, str_len);
if (tmp == QSE_NULL)
{
qse_awk_rtx_seterrnum (rtx, QSE_AWK_ENOMEM);
qse_awk_rtx_seterrnum (rtx, QSE_AWK_ENOMEM, QSE_NULL);
return QSE_NULL;
}
@ -811,7 +811,7 @@ static qse_char_t* str_to_str (
n = qse_str_ncat (out->u.strp, str, str_len);
if (n == (qse_size_t)-1)
{
qse_awk_rtx_seterrnum (rtx, QSE_AWK_ENOMEM);
qse_awk_rtx_seterrnum (rtx, QSE_AWK_ENOMEM, QSE_NULL);
return QSE_NULL;
}
@ -825,7 +825,7 @@ static qse_char_t* str_to_str (
n = qse_str_ncat (out->u.strpcat, str, str_len);
if (n == (qse_size_t)-1)
{
qse_awk_rtx_seterrnum (rtx, QSE_AWK_ENOMEM);
qse_awk_rtx_seterrnum (rtx, QSE_AWK_ENOMEM, QSE_NULL);
return QSE_NULL;
}
@ -833,7 +833,7 @@ static qse_char_t* str_to_str (
}
}
qse_awk_rtx_seterrnum (rtx, QSE_AWK_EINVAL);
qse_awk_rtx_seterrnum (rtx, QSE_AWK_EINVAL, QSE_NULL);
return QSE_NULL;
}
@ -855,7 +855,7 @@ static qse_char_t* val_int_to_str (
case QSE_AWK_RTX_VALTOSTR_CPL:
if (out->u.cpl.len <= 1)
{
qse_awk_rtx_seterrnum (rtx, QSE_AWK_EINVAL);
qse_awk_rtx_seterrnum (rtx, QSE_AWK_EINVAL, QSE_NULL);
/* store the buffer size needed */
out->u.cpl.len = 2;
return QSE_NULL;
@ -871,7 +871,7 @@ static qse_char_t* val_int_to_str (
rtx->awk, 2 * QSE_SIZEOF(qse_char_t));
if (tmp == QSE_NULL)
{
qse_awk_rtx_seterrnum (rtx, QSE_AWK_ENOMEM);
qse_awk_rtx_seterrnum (rtx, QSE_AWK_ENOMEM, QSE_NULL);
return QSE_NULL;
}
@ -886,7 +886,7 @@ static qse_char_t* val_int_to_str (
qse_str_clear (out->u.strp);
if (qse_str_ccat (out->u.strp, QSE_T('0')) == (qse_size_t)-1)
{
qse_awk_rtx_seterrnum (rtx, QSE_AWK_ENOMEM);
qse_awk_rtx_seterrnum (rtx, QSE_AWK_ENOMEM, QSE_NULL);
return QSE_NULL;
}
return QSE_STR_PTR(out->u.strp);
@ -894,13 +894,13 @@ static qse_char_t* val_int_to_str (
case QSE_AWK_RTX_VALTOSTR_STRPCAT:
if (qse_str_ccat (out->u.strpcat, QSE_T('0')) == (qse_size_t)-1)
{
qse_awk_rtx_seterrnum (rtx, QSE_AWK_ENOMEM);
qse_awk_rtx_seterrnum (rtx, QSE_AWK_ENOMEM, QSE_NULL);
return QSE_NULL;
}
return QSE_STR_PTR(out->u.strpcat);
}
qse_awk_rtx_seterrnum (rtx, QSE_AWK_EINVAL);
qse_awk_rtx_seterrnum (rtx, QSE_AWK_EINVAL, QSE_NULL);
return QSE_NULL;
}
@ -913,7 +913,7 @@ static qse_char_t* val_int_to_str (
case QSE_AWK_RTX_VALTOSTR_CPL:
if (rlen >= out->u.cpl.len)
{
qse_awk_rtx_seterrnum (rtx, QSE_AWK_EINVAL);
qse_awk_rtx_seterrnum (rtx, QSE_AWK_EINVAL, QSE_NULL);
/* store the buffer size needed */
out->u.cpl.len = rlen + 1;
return QSE_NULL;
@ -929,7 +929,7 @@ static qse_char_t* val_int_to_str (
rtx->awk, (rlen + 1) * QSE_SIZEOF(qse_char_t));
if (tmp == QSE_NULL)
{
qse_awk_rtx_seterrnum (rtx, QSE_AWK_ENOMEM);
qse_awk_rtx_seterrnum (rtx, QSE_AWK_ENOMEM, QSE_NULL);
return QSE_NULL;
}
@ -952,7 +952,7 @@ static qse_char_t* val_int_to_str (
n = qse_str_nccat (out->u.strp, QSE_T(' '), rlen);
if (n == (qse_size_t)-1)
{
qse_awk_rtx_seterrnum (rtx, QSE_AWK_ENOMEM);
qse_awk_rtx_seterrnum (rtx, QSE_AWK_ENOMEM, QSE_NULL);
return QSE_NULL;
}
break;
@ -969,7 +969,7 @@ static qse_char_t* val_int_to_str (
n = qse_str_nccat (out->u.strpcat, QSE_T(' '), rlen);
if (n == (qse_size_t)-1)
{
qse_awk_rtx_seterrnum (rtx, QSE_AWK_ENOMEM);
qse_awk_rtx_seterrnum (rtx, QSE_AWK_ENOMEM, QSE_NULL);
return QSE_NULL;
}
break;
@ -1021,14 +1021,14 @@ static qse_char_t* val_real_to_str (
if (qse_str_init (&buf, rtx->awk->mmgr, 256) == QSE_NULL)
{
qse_awk_rtx_seterrnum (rtx, QSE_AWK_ENOMEM);
qse_awk_rtx_seterrnum (rtx, QSE_AWK_ENOMEM, QSE_NULL);
return QSE_NULL;
}
if (qse_str_init (&fbu, rtx->awk->mmgr, 256) == QSE_NULL)
{
qse_str_fini (&buf);
qse_awk_rtx_seterrnum (rtx, QSE_AWK_ENOMEM);
qse_awk_rtx_seterrnum (rtx, QSE_AWK_ENOMEM, QSE_NULL);
return QSE_NULL;
}
@ -1047,7 +1047,7 @@ static qse_char_t* val_real_to_str (
if (out->u.cpl.len <= tmp_len)
{
qse_awk_rtx_seterrnum (rtx, QSE_AWK_EINVAL);
qse_awk_rtx_seterrnum (rtx, QSE_AWK_EINVAL, QSE_NULL);
/* store the buffer size required */
out->u.cpl.len = tmp_len + 1;
qse_str_close (&fbu);
@ -1084,7 +1084,7 @@ static qse_char_t* val_real_to_str (
{
qse_str_fini (&fbu);
qse_str_fini (&buf);
qse_awk_rtx_seterrnum (rtx, QSE_AWK_ENOMEM);
qse_awk_rtx_seterrnum (rtx, QSE_AWK_ENOMEM, QSE_NULL);
return QSE_NULL;
}
@ -1104,7 +1104,7 @@ static qse_char_t* val_real_to_str (
{
qse_str_fini (&fbu);
qse_str_fini (&buf);
qse_awk_rtx_seterrnum (rtx, QSE_AWK_ENOMEM);
qse_awk_rtx_seterrnum (rtx, QSE_AWK_ENOMEM, QSE_NULL);
return QSE_NULL;
}
@ -1118,7 +1118,7 @@ static qse_char_t* val_real_to_str (
qse_str_fini (&fbu);
qse_str_fini (&buf);
qse_awk_rtx_seterrnum (rtx, QSE_AWK_EINVAL);
qse_awk_rtx_seterrnum (rtx, QSE_AWK_EINVAL, QSE_NULL);
return QSE_NULL;
}
@ -1151,7 +1151,7 @@ qse_char_t* qse_awk_rtx_valtostr (
v->type);
#endif
qse_awk_rtx_seterrnum (rtx, QSE_AWK_EVALTYPE);
qse_awk_rtx_seterrnum (rtx, QSE_AWK_EVALTYPE, QSE_NULL);
return QSE_NULL;
}
@ -1204,7 +1204,7 @@ int qse_awk_rtx_valtonum (
v->type);
#endif
qse_awk_rtx_seterror (rtx, QSE_AWK_EVALTYPE, 0, QSE_NULL);
qse_awk_rtx_seterrnum (rtx, QSE_AWK_EVALTYPE, QSE_NULL);
return -1; /* error */
}