renamed hawk_find_bchar() to hawk_find_bchar_in_bchars().

renamed similar function names in the same way.
updated sys::openlog() to accept a local log socket path with remote:// (e.g. remote:///dev/log/xxx)
This commit is contained in:
hyung-hwan 2020-12-16 15:13:29 +00:00
parent 607b66d4c9
commit 829ad9bdd0
6 changed files with 71 additions and 45 deletions

View File

@ -412,9 +412,9 @@ int HawkStd::setioattr (
ptr[1] = args[1].toStr(&l[1]); ptr[1] = args[1].toStr(&l[1]);
ptr[2] = args[2].toStr(&l[2]); ptr[2] = args[2].toStr(&l[2]);
if (hawk_find_oochar(ptr[0], l[0], HAWK_T('\0')) || if (hawk_find_oochar_in_oochars(ptr[0], l[0], '\0') ||
hawk_find_oochar(ptr[1], l[1], HAWK_T('\0')) || hawk_find_oochar_in_oochars(ptr[1], l[1], '\0') ||
hawk_find_oochar(ptr[2], l[2], HAWK_T('\0'))) hawk_find_oochar_in_oochars(ptr[2], l[2], '\0'))
{ {
return ret.setInt ((hawk_int_t)-1); return ret.setInt ((hawk_int_t)-1);
} }
@ -489,8 +489,8 @@ int HawkStd::getioattr (
int xx = -1; int xx = -1;
/* ionames must not contains a null character */ /* ionames must not contains a null character */
if (hawk_find_oochar(ptr[0], l[0], HAWK_T('\0')) == HAWK_NULL && if (hawk_find_oochar_in_oochars(ptr[0], l[0], '\0') == HAWK_NULL &&
hawk_find_oochar(ptr[1], l[1], HAWK_T('\0')) == HAWK_NULL) hawk_find_oochar_in_oochars(ptr[1], l[1], '\0') == HAWK_NULL)
{ {
ioattr_t* ioattr = get_ioattr(ptr[0], l[0]); ioattr_t* ioattr = get_ioattr(ptr[0], l[0]);
if (ioattr == HAWK_NULL) ioattr = &HawkStd::default_ioattr; if (ioattr == HAWK_NULL) ioattr = &HawkStd::default_ioattr;

View File

@ -593,25 +593,25 @@ HAWK_EXPORT void hawk_fill_bchars (
hawk_oow_t len hawk_oow_t len
); );
HAWK_EXPORT hawk_uch_t* hawk_find_uchar ( HAWK_EXPORT hawk_uch_t* hawk_find_uchar_in_uchars (
const hawk_uch_t* ptr, const hawk_uch_t* ptr,
hawk_oow_t len, hawk_oow_t len,
hawk_uch_t c hawk_uch_t c
); );
HAWK_EXPORT hawk_bch_t* hawk_find_bchar ( HAWK_EXPORT hawk_bch_t* hawk_find_bchar_in_bchars (
const hawk_bch_t* ptr, const hawk_bch_t* ptr,
hawk_oow_t len, hawk_oow_t len,
hawk_bch_t c hawk_bch_t c
); );
HAWK_EXPORT hawk_uch_t* hawk_rfind_uchar ( HAWK_EXPORT hawk_uch_t* hawk_rfind_uchar_in_uchars (
const hawk_uch_t* ptr, const hawk_uch_t* ptr,
hawk_oow_t len, hawk_oow_t len,
hawk_uch_t c hawk_uch_t c
); );
HAWK_EXPORT hawk_bch_t* hawk_rfind_bchar ( HAWK_EXPORT hawk_bch_t* hawk_rfind_bchar_in_bchars (
const hawk_bch_t* ptr, const hawk_bch_t* ptr,
hawk_oow_t len, hawk_oow_t len,
hawk_bch_t c hawk_bch_t c
@ -622,11 +622,21 @@ HAWK_EXPORT hawk_uch_t* hawk_find_uchar_in_ucstr (
hawk_uch_t c hawk_uch_t c
); );
HAWK_EXPORT hawk_uch_t* hawk_rfind_uchar_in_ucstr (
const hawk_uch_t* ptr,
hawk_uch_t c
);
HAWK_EXPORT hawk_bch_t* hawk_find_bchar_in_bcstr ( HAWK_EXPORT hawk_bch_t* hawk_find_bchar_in_bcstr (
const hawk_bch_t* ptr, const hawk_bch_t* ptr,
hawk_bch_t c hawk_bch_t c
); );
HAWK_EXPORT hawk_bch_t* hawk_rfind_bchar_in_bcstr (
const hawk_bch_t* ptr,
hawk_bch_t c
);
HAWK_EXPORT hawk_uch_t* hawk_find_uchars_in_uchars ( HAWK_EXPORT hawk_uch_t* hawk_find_uchars_in_uchars (
const hawk_uch_t* str, const hawk_uch_t* str,
hawk_oow_t strsz, hawk_oow_t strsz,
@ -799,9 +809,10 @@ HAWK_EXPORT hawk_oow_t hawk_subst_for_bcstr_to_bcstr (
# define hawk_count_oocstr_limited hawk_count_ucstr_limited # define hawk_count_oocstr_limited hawk_count_ucstr_limited
# define hawk_fill_oochars hawk_fill_uchars # define hawk_fill_oochars hawk_fill_uchars
# define hawk_find_oochar hawk_find_uchar # define hawk_find_oochar_in_oochars hawk_find_uchar_in_uchars
# define hawk_rfind_oochar hawk_rfind_uchar # define hawk_rfind_oochar_in_oochars hawk_rfind_uchar_in_uchars
# define hawk_find_oochar_in_oocstr hawk_find_uchar_in_ucstr # define hawk_find_oochar_in_oocstr hawk_find_uchar_in_ucstr
# define hawk_rfind_oochar_in_oocstr hawk_rfind_uchar_in_ucstr
# define hawk_find_oochars_in_oochars hawk_find_uchars_in_uchars # define hawk_find_oochars_in_oochars hawk_find_uchars_in_uchars
# define hawk_rfind_oochars_in_oochars hawk_rfind_uchars_in_uchars # define hawk_rfind_oochars_in_oochars hawk_rfind_uchars_in_uchars
@ -841,9 +852,10 @@ HAWK_EXPORT hawk_oow_t hawk_subst_for_bcstr_to_bcstr (
# define hawk_count_oocstr_limited hawk_count_bcstr_limited # define hawk_count_oocstr_limited hawk_count_bcstr_limited
# define hawk_fill_oochars hawk_fill_bchars # define hawk_fill_oochars hawk_fill_bchars
# define hawk_find_oochar hawk_find_bchar # define hawk_find_oochar_in_oochars hawk_find_bchar_in_bchars
# define hawk_rfind_oochar hawk_rfind_bchar # define hawk_rfind_oochar_in_oochars hawk_rfind_bchar_in_bchars
# define hawk_find_oochar_in_oocstr hawk_find_bchar_in_bcstr # define hawk_find_oochar_in_oocstr hawk_find_bchar_in_bcstr
# define hawk_rfind_oochar_in_oocstr hawk_rfind_bchar_in_bcstr
# define hawk_find_oochars_in_oochars hawk_find_bchars_in_bchars # define hawk_find_oochars_in_oochars hawk_find_bchars_in_bchars
# define hawk_rfind_oochars_in_oochars hawk_rfind_bchars_in_bchars # define hawk_rfind_oochars_in_oochars hawk_rfind_bchars_in_bchars

View File

@ -2720,7 +2720,7 @@ static int fnc_getenv (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
{ {
hawk_bch_t* val; hawk_bch_t* val;
if (hawk_find_bchar(var, len, '\0')) if (hawk_find_bchar_in_bchars(var, len, '\0'))
{ {
rx = set_error_on_sys_list(rtx, sys_list, HAWK_EINVAL, HAWK_NULL); rx = set_error_on_sys_list(rtx, sys_list, HAWK_EINVAL, HAWK_NULL);
hawk_rtx_freevalbcstr (rtx, a0, var); hawk_rtx_freevalbcstr (rtx, a0, var);
@ -2783,8 +2783,8 @@ static int fnc_setenv (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
} }
/* the target name contains a null character. */ /* the target name contains a null character. */
if (hawk_find_bchar(var, var_len, '\0') || if (hawk_find_bchar_in_bchars(var, var_len, '\0') ||
hawk_find_bchar(val, val_len, '\0')) hawk_find_bchar_in_bchars(val, val_len, '\0'))
{ {
rx = set_error_on_sys_list(rtx, sys_list, HAWK_EINVAL, HAWK_NULL); rx = set_error_on_sys_list(rtx, sys_list, HAWK_EINVAL, HAWK_NULL);
goto done; goto done;
@ -2824,7 +2824,7 @@ static int fnc_unsetenv (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
} }
/* the target name contains a null character. */ /* the target name contains a null character. */
if (hawk_find_bchar(str, len, '\0')) if (hawk_find_bchar_in_bchars(str, len, '\0'))
{ {
rx = set_error_on_sys_list(rtx, sys_list, HAWK_EINVAL, HAWK_NULL); rx = set_error_on_sys_list(rtx, sys_list, HAWK_EINVAL, HAWK_NULL);
goto done; goto done;
@ -2967,7 +2967,7 @@ static int fnc_system (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
} }
/* the target name contains a null character. make system return -1 */ /* the target name contains a null character. make system return -1 */
if (hawk_find_oochar(str, len, '\0')) if (hawk_find_oochar_in_oochars(str, len, '\0'))
{ {
rx = set_error_on_sys_list(rtx, sys_list, HAWK_EINVAL, HAWK_NULL); rx = set_error_on_sys_list(rtx, sys_list, HAWK_EINVAL, HAWK_NULL);
goto done; goto done;
@ -3036,7 +3036,7 @@ static int fnc_chroot (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
} }
/* the target name contains a null character. */ /* the target name contains a null character. */
if (hawk_find_bchar(str, len, '\0')) if (hawk_find_bchar_in_bchars(str, len, '\0'))
{ {
rx = set_error_on_sys_list(rtx, sys_list, HAWK_EINVAL, HAWK_NULL); rx = set_error_on_sys_list(rtx, sys_list, HAWK_EINVAL, HAWK_NULL);
goto done; goto done;
@ -3088,7 +3088,7 @@ static int fnc_chmod (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
} }
/* the target name contains a null character. */ /* the target name contains a null character. */
if (hawk_find_bchar(str, len, '\0')) if (hawk_find_bchar_in_bchars(str, len, '\0'))
{ {
rx = set_error_on_sys_list(rtx, sys_list, HAWK_EINVAL, HAWK_NULL); rx = set_error_on_sys_list(rtx, sys_list, HAWK_EINVAL, HAWK_NULL);
goto done; goto done;
@ -3133,7 +3133,7 @@ static int fnc_mkdir (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
} }
/* the target name contains a null character. */ /* the target name contains a null character. */
if (hawk_find_oochar(str, len, '\0')) if (hawk_find_oochar_in_oochars(str, len, '\0'))
{ {
rx = set_error_on_sys_list(rtx, sys_list, HAWK_EINVAL, HAWK_NULL); rx = set_error_on_sys_list(rtx, sys_list, HAWK_EINVAL, HAWK_NULL);
goto done; goto done;
@ -3157,7 +3157,7 @@ static int fnc_mkdir (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
} }
/* the target name contains a null character. */ /* the target name contains a null character. */
if (hawk_find_bchar(str, len, '\0')) if (hawk_find_bchar_in_bchars(str, len, '\0'))
{ {
rx = set_error_on_sys_list(rtx, sys_list, HAWK_EINVAL, HAWK_NULL); rx = set_error_on_sys_list(rtx, sys_list, HAWK_EINVAL, HAWK_NULL);
goto done; goto done;
@ -3209,7 +3209,7 @@ static int fnc_rmdir (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
} }
/* the target name contains a null character. */ /* the target name contains a null character. */
if (hawk_find_oochar(str, len, '\0')) if (hawk_find_oochar_in_oochars(str, len, '\0'))
{ {
rx = set_error_on_sys_list(rtx, sys_list, HAWK_EINVAL, HAWK_NULL); rx = set_error_on_sys_list(rtx, sys_list, HAWK_EINVAL, HAWK_NULL);
goto done; goto done;
@ -3233,7 +3233,7 @@ static int fnc_rmdir (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
} }
/* the target name contains a null character. */ /* the target name contains a null character. */
if (hawk_find_bchar(str, len, '\0')) if (hawk_find_bchar_in_bchars(str, len, '\0'))
{ {
rx = set_error_on_sys_list(rtx, sys_list, HAWK_EINVAL, HAWK_NULL); rx = set_error_on_sys_list(rtx, sys_list, HAWK_EINVAL, HAWK_NULL);
goto done; goto done;
@ -3287,7 +3287,7 @@ static int fnc_unlink (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
} }
/* the target name contains a null character. */ /* the target name contains a null character. */
if (hawk_find_oochar(str, len, '\0')) if (hawk_find_oochar_in_oochars(str, len, '\0'))
{ {
rx = set_error_on_sys_list(rtx, sys_list, HAWK_EINVAL, HAWK_NULL); rx = set_error_on_sys_list(rtx, sys_list, HAWK_EINVAL, HAWK_NULL);
goto done; goto done;
@ -3311,7 +3311,7 @@ static int fnc_unlink (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
} }
/* the target name contains a null character. */ /* the target name contains a null character. */
if (hawk_find_bchar(str, len, '\0')) if (hawk_find_bchar_in_bchars(str, len, '\0'))
{ {
rx = set_error_on_sys_list(rtx, sys_list, HAWK_EINVAL, HAWK_NULL); rx = set_error_on_sys_list(rtx, sys_list, HAWK_EINVAL, HAWK_NULL);
goto done; goto done;
@ -3370,7 +3370,7 @@ static int fnc_symlink (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
goto done; goto done;
} }
if (hawk_find_bchar(str1, len1, '\0') || hawk_find_bchar(str2, len2, '\0')) if (hawk_find_bchar_in_bchars(str1, len1, '\0') || hawk_find_bchar_in_bchars(str2, len2, '\0'))
{ {
rx = set_error_on_sys_list(rtx, sys_list, HAWK_EINVAL, HAWK_NULL); rx = set_error_on_sys_list(rtx, sys_list, HAWK_EINVAL, HAWK_NULL);
goto done; goto done;
@ -3422,7 +3422,7 @@ static int fnc_stat (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
goto done; goto done;
} }
if (hawk_find_bchar(str1, len1, '\0')) if (hawk_find_bchar_in_bchars(str1, len1, '\0'))
{ {
rx = set_error_on_sys_list(rtx, sys_list, HAWK_EINVAL, HAWK_NULL); rx = set_error_on_sys_list(rtx, sys_list, HAWK_EINVAL, HAWK_NULL);
hawk_rtx_freevalbcstr (rtx, a0, str1); hawk_rtx_freevalbcstr (rtx, a0, str1);
@ -3591,7 +3591,7 @@ static int fnc_utime (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
} }
/* the target name contains a null character. */ /* the target name contains a null character. */
if (hawk_find_bchar(str, len, '\0')) if (hawk_find_bchar_in_bchars(str, len, '\0'))
{ {
rx = set_error_on_sys_list(rtx, sys_list, HAWK_EINVAL, HAWK_NULL); rx = set_error_on_sys_list(rtx, sys_list, HAWK_EINVAL, HAWK_NULL);
goto done; goto done;
@ -4490,12 +4490,16 @@ done:
sys::openlog("remote://192.168.1.23:1234/test", sys::LOG_OPT_PID | sys::LOG_OPT_NDELAY, sys::LOG_FAC_LOCAL0); sys::openlog("remote://192.168.1.23:1234/test", sys::LOG_OPT_PID | sys::LOG_OPT_NDELAY, sys::LOG_FAC_LOCAL0);
for (i = 0; i < 10; i++) sys::writelog(sys::LOG_PRI_DEBUG, "hello world " i); for (i = 0; i < 10; i++) sys::writelog(sys::LOG_PRI_DEBUG, "hello world " i);
sys::closelog(); sys::closelog();
local://xxx opens the local syslog using the openlog() call in the libc library.
openlog() affects the entire process.
to open /dev/log on the local system for the current running context,
you can specify the remote:// with /dev/log.
sys::openlog("remote:///dev/log/xxx", sys::LOG_OPT_PID | sys::LOG_OPT_NDELAY, sys::LOG_FAC_LOCAL0);
*/ */
static void open_remote_log_socket (hawk_rtx_t* rtx, mod_ctx_t* mctx) static void open_remote_log_socket (hawk_rtx_t* rtx, mod_ctx_t* mctx)
{ {
#if defined(_WIN32)
/* TODO: implement this */
#else
int sck, flags; int sck, flags;
int domain = hawk_skad_family(&mctx->log.skad); int domain = hawk_skad_family(&mctx->log.skad);
int type = SOCK_DGRAM; int type = SOCK_DGRAM;
@ -4538,8 +4542,6 @@ open_socket:
done: done:
mctx->log.sck = sck; mctx->log.sck = sck;
#endif
} }
static int fnc_openlog (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi) static int fnc_openlog (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
@ -4547,7 +4549,7 @@ static int fnc_openlog (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
hawk_int_t rx = ERRNUM_TO_RC(HAWK_EOTHER); hawk_int_t rx = ERRNUM_TO_RC(HAWK_EOTHER);
hawk_int_t opt, fac; hawk_int_t opt, fac;
hawk_ooch_t* ident = HAWK_NULL, * actual_ident; hawk_ooch_t* ident = HAWK_NULL, * actual_ident;
hawk_oow_t ident_len; hawk_oow_t ident_len, actual_ident_len;
hawk_bch_t* mbs_ident; hawk_bch_t* mbs_ident;
mod_ctx_t* mctx = (mod_ctx_t*)fi->mod->ctx; mod_ctx_t* mctx = (mod_ctx_t*)fi->mod->ctx;
hawk_skad_t skad; hawk_skad_t skad;
@ -4564,7 +4566,7 @@ static int fnc_openlog (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
/* the target name contains a null character. /* the target name contains a null character.
* make system return -1 */ * make system return -1 */
if (hawk_find_oochar(ident, ident_len, '\0')) if (hawk_find_oochar_in_oochars(ident, ident_len, '\0'))
{ {
rx = set_error_on_sys_list(rtx, sys_list, HAWK_EINVAL, HAWK_T("invalid identifier of length %zu containing '\\0'"), ident_len); rx = set_error_on_sys_list(rtx, sys_list, HAWK_EINVAL, HAWK_T("invalid identifier of length %zu containing '\\0'"), ident_len);
goto done; goto done;
@ -4580,7 +4582,8 @@ static int fnc_openlog (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
log_type = SYSLOG_REMOTE; log_type = SYSLOG_REMOTE;
actual_ident = ident + 9; actual_ident = ident + 9;
slash = hawk_find_oochar_in_oocstr(actual_ident, '/'); actual_ident_len = ident_len - 9;
slash = hawk_rfind_oochar_in_oochars(actual_ident, actual_ident_len, '/');
if (!slash) if (!slash)
{ {
rx = set_error_on_sys_list(rtx, sys_list, HAWK_EINVAL, HAWK_T("invalid identifier '%js' with remote address"), ident); rx = set_error_on_sys_list(rtx, sys_list, HAWK_EINVAL, HAWK_T("invalid identifier '%js' with remote address"), ident);
@ -4733,7 +4736,7 @@ static int fnc_writelog (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
msg = hawk_rtx_getvaloocstr(rtx, hawk_rtx_getarg(rtx, 1), &msglen); msg = hawk_rtx_getvaloocstr(rtx, hawk_rtx_getarg(rtx, 1), &msglen);
if (!msg) goto fail; if (!msg) goto fail;
if (hawk_find_oochar(msg, msglen, '\0')) if (hawk_find_oochar_in_oochars(msg, msglen, '\0'))
{ {
rx = set_error_on_sys_list(rtx, sys_list, HAWK_EINVAL, HAWK_NULL); rx = set_error_on_sys_list(rtx, sys_list, HAWK_EINVAL, HAWK_NULL);
goto done; goto done;

View File

@ -3072,7 +3072,7 @@ static int fnc_setioattr (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
goto done; goto done;
} }
if (hawk_find_oochar(ptr[i], len[i], HAWK_T('\0'))) if (hawk_find_oochar_in_oochars(ptr[i], len[i], '\0'))
{ {
fret = -1; fret = -1;
goto done; goto done;
@ -3194,7 +3194,7 @@ static int fnc_getioattr (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
goto done; goto done;
} }
if (hawk_find_oochar(ptr[i], len[i], HAWK_T('\0'))) goto done; if (hawk_find_oochar_in_oochars(ptr[i], len[i], '\0')) goto done;
} }
ioattr = get_ioattr(&rxtn->cmgrtab, ptr[0], len[0]); ioattr = get_ioattr(&rxtn->cmgrtab, ptr[0], len[0]);

View File

@ -213,7 +213,7 @@ tre_tnfa_run_parallel(hawk_gem_t* gem, const tre_tnfa_t *tnfa, const void *strin
int first = tnfa->first_char; int first = tnfa->first_char;
if (len >= 0) if (len >= 0)
str_byte = hawk_find_bchar(orig_str, (size_t)len, first); str_byte = hawk_find_bchar_in_bchars(orig_str, (size_t)len, first);
else else
str_byte = hawk_find_bchar_in_bcstr(orig_str, first); str_byte = hawk_find_bchar_in_bcstr(orig_str, first);
if (str_byte == NULL) if (str_byte == NULL)

View File

@ -508,7 +508,7 @@ void hawk_fill_bchars (hawk_bch_t* dst, hawk_bch_t ch, hawk_oow_t len)
/* ------------------------------------------------------------------------ */ /* ------------------------------------------------------------------------ */
hawk_uch_t* hawk_find_uchar (const hawk_uch_t* ptr, hawk_oow_t len, hawk_uch_t c) hawk_uch_t* hawk_find_uchar_in_uchars (const hawk_uch_t* ptr, hawk_oow_t len, hawk_uch_t c)
{ {
const hawk_uch_t* end; const hawk_uch_t* end;
@ -522,7 +522,7 @@ hawk_uch_t* hawk_find_uchar (const hawk_uch_t* ptr, hawk_oow_t len, hawk_uch_t c
return HAWK_NULL; return HAWK_NULL;
} }
hawk_bch_t* hawk_find_bchar (const hawk_bch_t* ptr, hawk_oow_t len, hawk_bch_t c) hawk_bch_t* hawk_find_bchar_in_bchars (const hawk_bch_t* ptr, hawk_oow_t len, hawk_bch_t c)
{ {
const hawk_bch_t* end; const hawk_bch_t* end;
@ -536,7 +536,7 @@ hawk_bch_t* hawk_find_bchar (const hawk_bch_t* ptr, hawk_oow_t len, hawk_bch_t c
return HAWK_NULL; return HAWK_NULL;
} }
hawk_uch_t* hawk_rfind_uchar (const hawk_uch_t* ptr, hawk_oow_t len, hawk_uch_t c) hawk_uch_t* hawk_rfind_uchar_in_uchars (const hawk_uch_t* ptr, hawk_oow_t len, hawk_uch_t c)
{ {
const hawk_uch_t* cur; const hawk_uch_t* cur;
@ -550,7 +550,7 @@ hawk_uch_t* hawk_rfind_uchar (const hawk_uch_t* ptr, hawk_oow_t len, hawk_uch_t
return HAWK_NULL; return HAWK_NULL;
} }
hawk_bch_t* hawk_rfind_bchar (const hawk_bch_t* ptr, hawk_oow_t len, hawk_bch_t c) hawk_bch_t* hawk_rfind_bchar_in_bchars (const hawk_bch_t* ptr, hawk_oow_t len, hawk_bch_t c)
{ {
const hawk_bch_t* cur; const hawk_bch_t* cur;
@ -575,6 +575,11 @@ hawk_uch_t* hawk_find_uchar_in_ucstr (const hawk_uch_t* ptr, hawk_uch_t c)
return HAWK_NULL; return HAWK_NULL;
} }
hawk_uch_t* hawk_rfind_uchar_in_ucstr (const hawk_uch_t* ptr, hawk_uch_t c)
{
return hawk_rfind_uchar_in_uchars(ptr, hawk_count_ucstr(ptr), c);
}
hawk_bch_t* hawk_find_bchar_in_bcstr (const hawk_bch_t* ptr, hawk_bch_t c) hawk_bch_t* hawk_find_bchar_in_bcstr (const hawk_bch_t* ptr, hawk_bch_t c)
{ {
while (*ptr != '\0') while (*ptr != '\0')
@ -585,6 +590,12 @@ hawk_bch_t* hawk_find_bchar_in_bcstr (const hawk_bch_t* ptr, hawk_bch_t c)
return HAWK_NULL; return HAWK_NULL;
} }
hawk_bch_t* hawk_rfind_bchar_in_bcstr (const hawk_bch_t* ptr, hawk_bch_t c)
{
return hawk_rfind_bchar_in_bchars(ptr, hawk_count_bcstr(ptr), c);
}
/* ------------------------------------------------------------------------ */ /* ------------------------------------------------------------------------ */
hawk_uch_t* hawk_find_uchars_in_uchars (const hawk_uch_t* str, hawk_oow_t strsz, const hawk_uch_t* sub, hawk_oow_t subsz, int ignorecase) hawk_uch_t* hawk_find_uchars_in_uchars (const hawk_uch_t* str, hawk_oow_t strsz, const hawk_uch_t* sub, hawk_oow_t subsz, int ignorecase)