exposed str::split()

This commit is contained in:
hyung-hwan 2014-05-27 14:26:04 +00:00
parent fdad26bba1
commit b75630a8bb
3 changed files with 27 additions and 29 deletions

View File

@ -23,10 +23,6 @@
static int fnc_close (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi); static int fnc_close (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi);
static int fnc_fflush (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi); static int fnc_fflush (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi);
static int fnc_index (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi); static int fnc_index (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi);
static int fnc_length (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi);
static int fnc_split (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi);
static int fnc_tolower (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi);
static int fnc_toupper (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi);
static int fnc_gsub (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi); static int fnc_gsub (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi);
static int fnc_sub (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi); static int fnc_sub (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi);
static int fnc_match (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi); static int fnc_match (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi);
@ -68,7 +64,7 @@ static qse_awk_fnc_t sysfnctab[] =
{ {QSE_T("index"), 5}, 0, { {2, 3, QSE_NULL}, fnc_index, 0 }, QSE_NULL}, { {QSE_T("index"), 5}, 0, { {2, 3, QSE_NULL}, fnc_index, 0 }, QSE_NULL},
{ {QSE_T("substr"), 6}, 0, { {2, 3, QSE_NULL}, qse_awk_fnc_substr, 0 }, QSE_NULL}, { {QSE_T("substr"), 6}, 0, { {2, 3, QSE_NULL}, qse_awk_fnc_substr, 0 }, QSE_NULL},
{ {QSE_T("length"), 6}, 1, { {0, 1, QSE_NULL}, qse_awk_fnc_length, 0 }, QSE_NULL}, { {QSE_T("length"), 6}, 1, { {0, 1, QSE_NULL}, qse_awk_fnc_length, 0 }, QSE_NULL},
{ {QSE_T("split"), 5}, 0, { {2, 3, QSE_T("vrx")}, fnc_split, 0 }, QSE_NULL}, { {QSE_T("split"), 5}, 0, { {2, 3, QSE_T("vrx")}, qse_awk_fnc_split, 0 }, QSE_NULL},
{ {QSE_T("tolower"), 7}, 0, { {1, 1, QSE_NULL}, qse_awk_fnc_tolower, 0 }, QSE_NULL}, { {QSE_T("tolower"), 7}, 0, { {1, 1, QSE_NULL}, qse_awk_fnc_tolower, 0 }, QSE_NULL},
{ {QSE_T("toupper"), 7}, 0, { {1, 1, QSE_NULL}, qse_awk_fnc_toupper, 0 }, QSE_NULL}, { {QSE_T("toupper"), 7}, 0, { {1, 1, QSE_NULL}, qse_awk_fnc_toupper, 0 }, QSE_NULL},
{ {QSE_T("gsub"), 4}, 0, { {2, 3, QSE_T("xvr")}, fnc_gsub, 0 }, QSE_NULL}, { {QSE_T("gsub"), 4}, 0, { {2, 3, QSE_T("xvr")}, fnc_gsub, 0 }, QSE_NULL},
@ -570,7 +566,7 @@ int qse_awk_fnc_substr (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi)
return 0; return 0;
} }
static int fnc_split (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi) int qse_awk_fnc_split (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi)
{ {
qse_size_t nargs; qse_size_t nargs;
qse_awk_val_t* a0, * a1, * a2, * t1, * t2; qse_awk_val_t* a0, * a1, * a2, * t1, * t2;

View File

@ -44,6 +44,7 @@ qse_awk_fnc_t* qse_awk_findfnc (qse_awk_t* awk, const qse_cstr_t* name);
int qse_awk_fnc_length (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi); int qse_awk_fnc_length (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi);
int qse_awk_fnc_substr (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi); int qse_awk_fnc_substr (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi);
int qse_awk_fnc_split (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi);
int qse_awk_fnc_tolower (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi); int qse_awk_fnc_tolower (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi);
int qse_awk_fnc_toupper (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi); int qse_awk_fnc_toupper (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi);

View File

@ -297,29 +297,30 @@ struct fnctab_t
static fnctab_t fnctab[] = static fnctab_t fnctab[] =
{ {
/* keep this table sorted for binary search in query(). */ /* keep this table sorted for binary search in query(). */
{ QSE_T("index"), { { 2, 3, QSE_NULL }, fnc_index, 0 } }, { QSE_T("index"), { { 2, 3, QSE_NULL }, fnc_index, 0 } },
{ QSE_T("isalnum"), { { 1, 1, QSE_NULL }, fnc_isalnum, 0 } }, { QSE_T("isalnum"), { { 1, 1, QSE_NULL }, fnc_isalnum, 0 } },
{ QSE_T("isalpha"), { { 1, 1, QSE_NULL }, fnc_isalpha, 0 } }, { QSE_T("isalpha"), { { 1, 1, QSE_NULL }, fnc_isalpha, 0 } },
{ QSE_T("isblank"), { { 1, 1, QSE_NULL }, fnc_isblank, 0 } }, { QSE_T("isblank"), { { 1, 1, QSE_NULL }, fnc_isblank, 0 } },
{ QSE_T("iscntrl"), { { 1, 1, QSE_NULL }, fnc_iscntrl, 0 } }, { QSE_T("iscntrl"), { { 1, 1, QSE_NULL }, fnc_iscntrl, 0 } },
{ QSE_T("isdigit"), { { 1, 1, QSE_NULL }, fnc_isdigit, 0 } }, { QSE_T("isdigit"), { { 1, 1, QSE_NULL }, fnc_isdigit, 0 } },
{ QSE_T("isgraph"), { { 1, 1, QSE_NULL }, fnc_isgraph, 0 } }, { QSE_T("isgraph"), { { 1, 1, QSE_NULL }, fnc_isgraph, 0 } },
{ QSE_T("islower"), { { 1, 1, QSE_NULL }, fnc_islower, 0 } }, { QSE_T("islower"), { { 1, 1, QSE_NULL }, fnc_islower, 0 } },
{ QSE_T("isprint"), { { 1, 1, QSE_NULL }, fnc_isprint, 0 } }, { QSE_T("isprint"), { { 1, 1, QSE_NULL }, fnc_isprint, 0 } },
{ QSE_T("ispunct"), { { 1, 1, QSE_NULL }, fnc_ispunct, 0 } }, { QSE_T("ispunct"), { { 1, 1, QSE_NULL }, fnc_ispunct, 0 } },
{ QSE_T("isspace"), { { 1, 1, QSE_NULL }, fnc_isspace, 0 } }, { QSE_T("isspace"), { { 1, 1, QSE_NULL }, fnc_isspace, 0 } },
{ QSE_T("isupper"), { { 1, 1, QSE_NULL }, fnc_isupper, 0 } }, { QSE_T("isupper"), { { 1, 1, QSE_NULL }, fnc_isupper, 0 } },
{ QSE_T("isxdigit"), { { 1, 1, QSE_NULL }, fnc_isxdigit, 0 } }, { QSE_T("isxdigit"), { { 1, 1, QSE_NULL }, fnc_isxdigit, 0 } },
{ QSE_T("length"), { { 1, 1, QSE_NULL }, qse_awk_fnc_length, 0 } }, { QSE_T("length"), { { 1, 1, QSE_NULL }, qse_awk_fnc_length, 0 } },
{ QSE_T("ltrim"), { { 1, 1, QSE_NULL }, fnc_ltrim, 0 } }, { QSE_T("ltrim"), { { 1, 1, QSE_NULL }, fnc_ltrim, 0 } },
{ QSE_T("normspace"), { { 1, 1, QSE_NULL }, fnc_normspace, 0 } }, { QSE_T("normspace"), { { 1, 1, QSE_NULL }, fnc_normspace, 0 } },
{ QSE_T("rindex"), { { 2, 3, QSE_NULL }, fnc_rindex, 0 } }, { QSE_T("rindex"), { { 2, 3, QSE_NULL }, fnc_rindex, 0 } },
{ QSE_T("rtrim"), { { 1, 1, QSE_NULL }, fnc_rtrim, 0 } }, { QSE_T("rtrim"), { { 1, 1, QSE_NULL }, fnc_rtrim, 0 } },
{ QSE_T("substr"), { { 2, 3, QSE_NULL }, qse_awk_fnc_substr, 0 } }, { QSE_T("split"), { { 2, 3, QSE_T("vrx") }, qse_awk_fnc_split, 0 } },
{ QSE_T("tolower"), { { 1, 1, QSE_NULL }, qse_awk_fnc_tolower, 0 } }, { QSE_T("substr"), { { 2, 3, QSE_NULL }, qse_awk_fnc_substr, 0 } },
{ QSE_T("toupper"), { { 1, 1, QSE_NULL }, qse_awk_fnc_toupper, 0 } }, { QSE_T("tolower"), { { 1, 1, QSE_NULL }, qse_awk_fnc_tolower, 0 } },
{ QSE_T("trim"), { { 1, 1, QSE_NULL }, fnc_trim, 0 } }, { QSE_T("toupper"), { { 1, 1, QSE_NULL }, qse_awk_fnc_toupper, 0 } },
{ QSE_T("value"), { { 1, 1, QSE_NULL }, fnc_value, 0 } } { QSE_T("trim"), { { 1, 1, QSE_NULL }, fnc_trim, 0 } },
{ QSE_T("value"), { { 1, 1, QSE_NULL }, fnc_value, 0 } }
}; };
static int query (qse_awk_mod_t* mod, qse_awk_t* awk, const qse_char_t* name, qse_awk_mod_sym_t* sym) static int query (qse_awk_mod_t* mod, qse_awk_t* awk, const qse_char_t* name, qse_awk_mod_sym_t* sym)