fixed a wrong field name that caused a compilation error on solaris 8.

make some builtin string functiosn available under str::
This commit is contained in:
hyung-hwan 2014-05-27 14:13:12 +00:00
parent ffe3bd3207
commit fdad26bba1
4 changed files with 58 additions and 50 deletions

View File

@ -24,7 +24,6 @@ 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_length (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi);
static int fnc_substr (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_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_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_toupper (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi);
@ -67,11 +66,11 @@ static qse_awk_fnc_t sysfnctab[] =
/* string functions */ /* string functions */
{ {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}, 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}, 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")}, fnc_split, 0 }, QSE_NULL},
{ {QSE_T("tolower"), 7}, 0, { {1, 1, QSE_NULL}, 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}, 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},
{ {QSE_T("sub"), 3}, 0, { {2, 3, QSE_T("xvr")}, fnc_sub, 0 }, QSE_NULL}, { {QSE_T("sub"), 3}, 0, { {2, 3, QSE_T("xvr")}, fnc_sub, 0 }, QSE_NULL},
{ {QSE_T("match"), 5}, 0, { {2, 3, QSE_T("vxv")}, fnc_match, 0 }, QSE_NULL}, { {QSE_T("match"), 5}, 0, { {2, 3, QSE_T("vxv")}, fnc_match, 0 }, QSE_NULL},
@ -468,7 +467,7 @@ static int fnc_index (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi)
return 0; return 0;
} }
static int 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)
{ {
qse_size_t nargs; qse_size_t nargs;
qse_awk_val_t* v; qse_awk_val_t* v;
@ -512,7 +511,7 @@ static int fnc_length (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi)
return 0; return 0;
} }
static int 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)
{ {
qse_size_t nargs; qse_size_t nargs;
qse_awk_val_t* a0, * a1, * a2, * r; qse_awk_val_t* a0, * a1, * a2, * r;
@ -772,7 +771,7 @@ oops:
return -1; return -1;
} }
static int 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)
{ {
qse_size_t nargs; qse_size_t nargs;
qse_size_t i; qse_size_t i;
@ -801,7 +800,7 @@ static int fnc_tolower (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi)
return 0; return 0;
} }
static int 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)
{ {
qse_size_t nargs; qse_size_t nargs;
qse_size_t i; qse_size_t i;

View File

@ -42,6 +42,11 @@ extern "C" {
qse_awk_fnc_t* qse_awk_findfnc (qse_awk_t* awk, const qse_cstr_t* name); 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_substr (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);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View File

@ -22,6 +22,7 @@
#include <qse/cmn/str.h> #include <qse/cmn/str.h>
#include <qse/cmn/chr.h> #include <qse/cmn/chr.h>
#include "../cmn/mem.h" #include "../cmn/mem.h"
#include "fnc.h"
static int fnc_normspace (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi) static int fnc_normspace (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi)
{ {
@ -165,7 +166,6 @@ static int fnc_rindex (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi)
return index_or_rindex (rtx, 1); return index_or_rindex (rtx, 1);
} }
static int is_class (qse_awk_rtx_t* rtx, qse_ctype_t ctype) static int is_class (qse_awk_rtx_t* rtx, qse_ctype_t ctype)
{ {
qse_awk_val_t* a0; qse_awk_val_t* a0;
@ -310,10 +310,14 @@ static fnctab_t fnctab[] =
{ 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("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("tolower"), { { 1, 1, QSE_NULL }, qse_awk_fnc_tolower, 0 } },
{ QSE_T("toupper"), { { 1, 1, QSE_NULL }, qse_awk_fnc_toupper, 0 } },
{ QSE_T("trim"), { { 1, 1, QSE_NULL }, fnc_trim, 0 } }, { QSE_T("trim"), { { 1, 1, QSE_NULL }, fnc_trim, 0 } },
{ QSE_T("value"), { { 1, 1, QSE_NULL }, fnc_value, 0 } } { QSE_T("value"), { { 1, 1, QSE_NULL }, fnc_value, 0 } }
}; };

View File

@ -428,7 +428,7 @@ static int fnc_sleep (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi)
#elif defined(HAVE_SELECT) #elif defined(HAVE_SELECT)
struct timeval req; struct timeval req;
req.tv_sec = (qse_awk_int_t)fv; req.tv_sec = (qse_awk_int_t)fv;
req.tv_nsec = QSE_SEC_TO_USEC(fv - req.tv_sec); req.tv_usec = QSE_SEC_TO_USEC(fv - req.tv_sec);
rx = select (0, QSE_NULL, QSE_NULL, QSE_NULL, &req); rx = select (0, QSE_NULL, QSE_NULL, QSE_NULL, &req);
#else #else
/* no high-resolution sleep() is available */ /* no high-resolution sleep() is available */