minor code fix
This commit is contained in:
parent
9a24d57b8f
commit
65552ff85e
@ -365,7 +365,7 @@ void hawk_seterror (hawk_t* hawk, hawk_errnum_t errnum, const hawk_oocs_t* errar
|
|||||||
errfmt = hawk_geterrstr(hawk)(hawk, errnum);
|
errfmt = hawk_geterrstr(hawk)(hawk, errnum);
|
||||||
HAWK_ASSERT (errfmt != HAWK_NULL);
|
HAWK_ASSERT (errfmt != HAWK_NULL);
|
||||||
/* TODO: this change is buggy... copying won't process arguments...
|
/* TODO: this change is buggy... copying won't process arguments...
|
||||||
qse_strxfncpy (hawk->_gem.errmsg, HAWK_COUNTOF(hawk->_gem.errmsg), errfmt, errarg);
|
hawk_strxfncpy (hawk->_gem.errmsg, HAWK_COUNTOF(hawk->_gem.errmsg), errfmt, errarg);
|
||||||
*/
|
*/
|
||||||
hawk_copy_oocstr(hawk->_gem.errmsg, HAWK_COUNTOF(hawk->_gem.errmsg), errfmt);
|
hawk_copy_oocstr(hawk->_gem.errmsg, HAWK_COUNTOF(hawk->_gem.errmsg), errfmt);
|
||||||
/* TODO: remove awk_rtx_seterror() and substitute hawk_rtx_seterrfmt()/seterrbfmt()/seterrufmt() */
|
/* TODO: remove awk_rtx_seterror() and substitute hawk_rtx_seterrfmt()/seterrbfmt()/seterrufmt() */
|
||||||
@ -542,7 +542,7 @@ void hawk_rtx_seterror (hawk_rtx_t* rtx, hawk_errnum_t errnum, const hawk_oocs_t
|
|||||||
errfmt = hawk_geterrstr(hawk_rtx_gethawk(rtx))(hawk_rtx_gethawk(rtx), errnum);
|
errfmt = hawk_geterrstr(hawk_rtx_gethawk(rtx))(hawk_rtx_gethawk(rtx), errnum);
|
||||||
HAWK_ASSERT (errfmt != HAWK_NULL);
|
HAWK_ASSERT (errfmt != HAWK_NULL);
|
||||||
/* TODO: this change is buggy... copying won't process arguments...
|
/* TODO: this change is buggy... copying won't process arguments...
|
||||||
qse_strxfncpy (rtx->_gem.errmsg, HAWK_COUNTOF(rtx->_gem.errmsg), errfmt, errarg);
|
hawk_strxfncpy (rtx->_gem.errmsg, HAWK_COUNTOF(rtx->_gem.errmsg), errfmt, errarg);
|
||||||
*/
|
*/
|
||||||
hawk_copy_oocstr(rtx->_gem.errmsg, HAWK_COUNTOF(rtx->_gem.errmsg), errfmt);
|
hawk_copy_oocstr(rtx->_gem.errmsg, HAWK_COUNTOF(rtx->_gem.errmsg), errfmt);
|
||||||
/* TODO: remove awk_rtx_seterror() and substitute hawk_rtx_seterrfmt()/seterrbfmt()/seterrufmt() */
|
/* TODO: remove awk_rtx_seterror() and substitute hawk_rtx_seterrfmt()/seterrbfmt()/seterrufmt() */
|
||||||
|
@ -10,7 +10,7 @@ BEGIN {
|
|||||||
tab4="\t\t\t";
|
tab4="\t\t\t";
|
||||||
}
|
}
|
||||||
|
|
||||||
/^[[:space:]]*enum[[:space:]]+qse_awk_errnum_t[[:space:]]*$/ {
|
/^[[:space:]]*enum[[:space:]]+hawk_errnum_t[[:space:]]*$/ {
|
||||||
collect=1;
|
collect=1;
|
||||||
print tab3 "// generated by generrcode.awk";
|
print tab3 "// generated by generrcode.awk";
|
||||||
print tab3 "enum ErrorNumber";
|
print tab3 "enum ErrorNumber";
|
||||||
@ -24,10 +24,10 @@ collect && /^[[:space:]]*};[[:space:]]*$/ {
|
|||||||
collect=0;
|
collect=0;
|
||||||
}
|
}
|
||||||
|
|
||||||
collect && /^[[:space:]]*QSE_AWK_E[[:alnum:]]+/ {
|
collect && /^[[:space:]]*HAWK_E[[:alnum:]]+/ {
|
||||||
split ($1, flds, ",");
|
split ($1, flds, ",");
|
||||||
name=flds[1];
|
name=flds[1];
|
||||||
|
|
||||||
print tab4 "ERR_" substr (name,10,length(name)-9) " = " name ",";
|
print tab4 "ERR_" substr (name,7,length(name)-6) " = " name ",";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ BEGIN {
|
|||||||
tab4="\t\t\t";
|
tab4="\t\t\t";
|
||||||
}
|
}
|
||||||
|
|
||||||
/^[[:space:]]*enum[[:space:]]+qse_awk_option_t[[:space:]]*$/ {
|
/^[[:space:]]*enum[[:space:]]+hawk_trait_t[[:space:]]*$/ {
|
||||||
collect=1;
|
collect=1;
|
||||||
print tab3 "// generated by genoptcode.awk";
|
print tab3 "// generated by genoptcode.awk";
|
||||||
print tab3 "enum Option";
|
print tab3 "enum Option";
|
||||||
@ -24,10 +24,10 @@ collect && /^[[:space:]]*};[[:space:]]*$/ {
|
|||||||
collect=0;
|
collect=0;
|
||||||
}
|
}
|
||||||
|
|
||||||
collect && /^[[:space:]]*QSE_AWK_[[:alnum:]]+/ {
|
collect && /^[[:space:]]*HAWK_[[:alnum:]]+/ {
|
||||||
split ($1, flds, ",");
|
split ($1, flds, ",");
|
||||||
name=flds[1];
|
name=flds[1];
|
||||||
|
|
||||||
print tab4 "OPT_" substr (name,9,length(name)-8) " = " name ",";
|
print tab4 "TRAIT_" substr (name,6,length(name)-5) " = " name ",";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
notice, this list of conditions and the following disclaimer in the
|
notice, this list of conditions and the following disclaimer in the
|
||||||
documentation and/or other materials provided with the distribution.
|
documentation and/or other materials provided with the distribution.
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EQSERESS OR
|
THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR
|
||||||
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||||
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
@ -56,7 +56,7 @@ enum
|
|||||||
DIR_EMAPTOSCALAR
|
DIR_EMAPTOSCALAR
|
||||||
};
|
};
|
||||||
|
|
||||||
static int dir_err_to_errnum (qse_dir_errnum_t num)
|
static int dir_err_to_errnum (hawk_dir_errnum_t num)
|
||||||
{
|
{
|
||||||
switch (num)
|
switch (num)
|
||||||
{
|
{
|
||||||
@ -100,7 +100,7 @@ static int awk_err_to_errnum (hawk_errnum_t num)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#define __IMAP_NODE_T_DATA qse_dir_t* ctx;
|
#define __IMAP_NODE_T_DATA hawk_dir_t* ctx;
|
||||||
#define __IMAP_LIST_T_DATA int errnum;
|
#define __IMAP_LIST_T_DATA int errnum;
|
||||||
#define __IMAP_LIST_T dir_list_t
|
#define __IMAP_LIST_T dir_list_t
|
||||||
#define __IMAP_NODE_T dir_node_t
|
#define __IMAP_NODE_T dir_node_t
|
||||||
@ -111,7 +111,7 @@ static int awk_err_to_errnum (hawk_errnum_t num)
|
|||||||
static dir_node_t* new_dir_node (hawk_rtx_t* rtx, dir_list_t* list, const hawk_ooch_t* path, hawk_int_t flags)
|
static dir_node_t* new_dir_node (hawk_rtx_t* rtx, dir_list_t* list, const hawk_ooch_t* path, hawk_int_t flags)
|
||||||
{
|
{
|
||||||
dir_node_t* node;
|
dir_node_t* node;
|
||||||
qse_dir_errnum_t oe;
|
hawk_dir_errnum_t oe;
|
||||||
|
|
||||||
node = __new_dir_node(rtx, list);
|
node = __new_dir_node(rtx, list);
|
||||||
if (!node)
|
if (!node)
|
||||||
@ -120,7 +120,7 @@ static dir_node_t* new_dir_node (hawk_rtx_t* rtx, dir_list_t* list, const hawk_o
|
|||||||
return HAWK_NULL;
|
return HAWK_NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
node->ctx = qse_dir_open(hawk_rtx_getmmgr(rtx), 0, path, flags, &oe);
|
node->ctx = hawk_dir_open(hawk_rtx_getmmgr(rtx), 0, path, flags, &oe);
|
||||||
if (!node->ctx)
|
if (!node->ctx)
|
||||||
{
|
{
|
||||||
list->errnum = dir_err_to_errnum(oe);
|
list->errnum = dir_err_to_errnum(oe);
|
||||||
@ -135,7 +135,7 @@ static void free_dir_node (hawk_rtx_t* rtx, dir_list_t* list, dir_node_t* node)
|
|||||||
{
|
{
|
||||||
if (node->ctx)
|
if (node->ctx)
|
||||||
{
|
{
|
||||||
qse_dir_close(node->ctx);
|
hawk_dir_close(node->ctx);
|
||||||
node->ctx = HAWK_NULL;
|
node->ctx = HAWK_NULL;
|
||||||
}
|
}
|
||||||
__free_dir_node (rtx, list, node);
|
__free_dir_node (rtx, list, node);
|
||||||
@ -160,9 +160,9 @@ static int reset_byid (hawk_rtx_t* rtx, dir_list_t* list, hawk_int_t id, const h
|
|||||||
{
|
{
|
||||||
if (id >= 0 && id < list->map.high && list->map.tab[id])
|
if (id >= 0 && id < list->map.high && list->map.tab[id])
|
||||||
{
|
{
|
||||||
if (qse_dir_reset(list->map.tab[id]->ctx, path) <= -1)
|
if (hawk_dir_reset(list->map.tab[id]->ctx, path) <= -1)
|
||||||
{
|
{
|
||||||
list->errnum = dir_err_to_errnum (qse_dir_geterrnum (list->map.tab[id]->ctx));
|
list->errnum = dir_err_to_errnum (hawk_dir_geterrnum (list->map.tab[id]->ctx));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
@ -179,13 +179,13 @@ static int read_byid (hawk_rtx_t* rtx, dir_list_t* list, hawk_int_t id, hawk_val
|
|||||||
if (id >= 0 && id < list->map.high && list->map.tab[id])
|
if (id >= 0 && id < list->map.high && list->map.tab[id])
|
||||||
{
|
{
|
||||||
int y;
|
int y;
|
||||||
qse_dir_ent_t ent;
|
hawk_dir_ent_t ent;
|
||||||
hawk_val_t* tmp;
|
hawk_val_t* tmp;
|
||||||
|
|
||||||
y = qse_dir_read(list->map.tab[id]->ctx, &ent);
|
y = hawk_dir_read(list->map.tab[id]->ctx, &ent);
|
||||||
if (y <= -1)
|
if (y <= -1)
|
||||||
{
|
{
|
||||||
list->errnum = dir_err_to_errnum(qse_dir_geterrnum (list->map.tab[id]->ctx));
|
list->errnum = dir_err_to_errnum(hawk_dir_geterrnum (list->map.tab[id]->ctx));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -456,7 +456,7 @@ static int query (hawk_mod_t* mod, hawk_t* awk, const hawk_ooch_t* name, hawk_mo
|
|||||||
{
|
{
|
||||||
mid = left + (right - left) / 2;
|
mid = left + (right - left) / 2;
|
||||||
|
|
||||||
n = qse_strcmp (fnctab[mid].name, name);
|
n = hawk_strcmp (fnctab[mid].name, name);
|
||||||
if (n > 0) right = mid - 1;
|
if (n > 0) right = mid - 1;
|
||||||
else if (n < 0) left = mid + 1;
|
else if (n < 0) left = mid + 1;
|
||||||
else
|
else
|
||||||
@ -472,7 +472,7 @@ static int query (hawk_mod_t* mod, hawk_t* awk, const hawk_ooch_t* name, hawk_mo
|
|||||||
{
|
{
|
||||||
mid = left + (right - left) / 2;
|
mid = left + (right - left) / 2;
|
||||||
|
|
||||||
n = qse_strcmp (inttab[mid].name, name);
|
n = hawk_strcmp (inttab[mid].name, name);
|
||||||
if (n > 0) right = mid - 1;
|
if (n > 0) right = mid - 1;
|
||||||
else if (n < 0) left = mid + 1;
|
else if (n < 0) left = mid + 1;
|
||||||
else
|
else
|
||||||
|
@ -88,7 +88,7 @@ static int trim (hawk_rtx_t* rtx, int flags)
|
|||||||
hawk_ooch_t* npath;
|
hawk_ooch_t* npath;
|
||||||
path.ptr = hawk_rtx_getvaloocstr(rtx, a0, &path.len);
|
path.ptr = hawk_rtx_getvaloocstr(rtx, a0, &path.len);
|
||||||
if (!path.ptr) return -1;
|
if (!path.ptr) return -1;
|
||||||
/* because qse_strxtrmx() returns the pointer and the length without
|
/* because hawk_strxtrmx() returns the pointer and the length without
|
||||||
* affecting the string given, it's safe to pass the original value.
|
* affecting the string given, it's safe to pass the original value.
|
||||||
* hawk_rtx_getvaloocstr() doesn't duplicate the value if it's of
|
* hawk_rtx_getvaloocstr() doesn't duplicate the value if it's of
|
||||||
* the string type. */
|
* the string type. */
|
||||||
@ -371,7 +371,7 @@ static int fnc_frommbs (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
|
|||||||
a1 = hawk_rtx_getarg(rtx, 1);
|
a1 = hawk_rtx_getarg(rtx, 1);
|
||||||
enc.ptr = hawk_rtx_getvaloocstr(rtx, a1, &enc.len);
|
enc.ptr = hawk_rtx_getvaloocstr(rtx, a1, &enc.len);
|
||||||
if (!enc.ptr) return -1;
|
if (!enc.ptr) return -1;
|
||||||
/* if encoding name is an empty string, qse_Findcmgr() returns the default cmgr.
|
/* if encoding name is an empty string, hawk_findcmgr() returns the default cmgr.
|
||||||
* i don't want that behavior. */
|
* i don't want that behavior. */
|
||||||
cmgr = (enc.len > 0 && enc.len == hawk_count_oocstr(enc.ptr))? hawk_get_cmgr_by_name(enc.ptr): HAWK_NULL;
|
cmgr = (enc.len > 0 && enc.len == hawk_count_oocstr(enc.ptr))? hawk_get_cmgr_by_name(enc.ptr): HAWK_NULL;
|
||||||
hawk_rtx_freevaloocstr (rtx, a1, enc.ptr);
|
hawk_rtx_freevaloocstr (rtx, a1, enc.ptr);
|
||||||
@ -427,7 +427,7 @@ static int fnc_tombs (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
|
|||||||
a1 = hawk_rtx_getarg(rtx, 1);
|
a1 = hawk_rtx_getarg(rtx, 1);
|
||||||
enc.ptr = hawk_rtx_getvaloocstr(rtx, a1, &enc.len);
|
enc.ptr = hawk_rtx_getvaloocstr(rtx, a1, &enc.len);
|
||||||
if (!enc.ptr) return -1;
|
if (!enc.ptr) return -1;
|
||||||
/* if encoding name is an empty string, qse_Findcmgr() returns the default cmgr.
|
/* if encoding name is an empty string, hawk_findcmgr() returns the default cmgr.
|
||||||
* i don't want that behavior. */
|
* i don't want that behavior. */
|
||||||
cmgr = (enc.len > 0 && enc.len == hawk_count_oocstr(enc.ptr))? hawk_get_cmgr_by_name(enc.ptr): HAWK_NULL;
|
cmgr = (enc.len > 0 && enc.len == hawk_count_oocstr(enc.ptr))? hawk_get_cmgr_by_name(enc.ptr): HAWK_NULL;
|
||||||
hawk_rtx_freevaloocstr (rtx, a1, enc.ptr);
|
hawk_rtx_freevaloocstr (rtx, a1, enc.ptr);
|
||||||
|
Loading…
Reference in New Issue
Block a user