added str::splita()

This commit is contained in:
hyung-hwan 2020-11-13 15:09:29 +00:00
parent 166c18c7d0
commit daf7377403
4 changed files with 11 additions and 2 deletions

View File

@ -64,6 +64,7 @@ HAWK_EXPORT int hawk_fnc_length (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi);
HAWK_EXPORT int hawk_fnc_match (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi);
HAWK_EXPORT int hawk_fnc_rindex (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi);
HAWK_EXPORT int hawk_fnc_split (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi);
HAWK_EXPORT int hawk_fnc_splita (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi);
HAWK_EXPORT int hawk_fnc_sprintf (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi);
HAWK_EXPORT int hawk_fnc_sub (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi);
HAWK_EXPORT int hawk_fnc_substr (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi);

View File

@ -1001,10 +1001,14 @@ oops:
int hawk_fnc_split (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
{
/*return fnc_split(rtx, fi, 1);*/
return fnc_split(rtx, fi, 0);
}
int hawk_fnc_splita (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
{
return fnc_split(rtx, fi, 1);
}
int hawk_fnc_tolower (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
{
hawk_oow_t i;

View File

@ -574,6 +574,7 @@ static fnctab_t fnctab[] =
{ HAWK_T("rindex"), { { 2, 3, HAWK_NULL }, hawk_fnc_rindex, 0 } },
{ HAWK_T("rtrim"), { { 1, 1, HAWK_NULL }, fnc_rtrim, 0 } },
{ HAWK_T("split"), { { 2, 3, HAWK_T("vrx") }, hawk_fnc_split, 0 } },
{ HAWK_T("splita"), { { 2, 3, HAWK_T("vrx") }, hawk_fnc_splita, 0 } }, /* split to array. asplit is not a good name for this */
{ HAWK_T("sub"), { { 2, 3, HAWK_T("xvr") }, hawk_fnc_sub, 0 } },
{ HAWK_T("substr"), { { 2, 3, HAWK_NULL }, hawk_fnc_substr, 0 } },
{ HAWK_T("tocharcode"), { { 1, 2, HAWK_NULL }, fnc_tocharcode, 0 } },

View File

@ -311,6 +311,9 @@ function main()
ensure (a[4] === @b"Da:ta", 1, @SCRIPTNAME, @SCRIPTLINE);
ensure (split("Here===Is=Some=====Data", a, ""), 23, @SCRIPTNAME, @SCRIPTLINE);
ensure (hawk::typename(a), "map", @SCRIPTNAME, @SCRIPTLINE);
ensure (str::splita("Here===Is=Some=====Data", a, ""), 23, @SCRIPTNAME, @SCRIPTLINE);
ensure (hawk::typename(a), "array",@SCRIPTNAME, @SCRIPTLINE);
ensure (split("Here Is Some Data", a, / /), 7, @SCRIPTNAME, @SCRIPTLINE);
ensure (split("Here Is Some Data", a, " "), 4, @SCRIPTNAME, @SCRIPTLINE);