enhanced the test case to detect the bug found in hawk_copy_bcstr_to_bchars()
This commit is contained in:
parent
63f94ddb44
commit
03adf78a76
@ -375,7 +375,7 @@ hawk_oow_t hawk_copy_bchars_to_bcstr_unlimited (hawk_bch_t* dst, const hawk_bch_
|
|||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
hawk_oow_t hawk_copy_ucstr_to_uchars (hawk_uch_t* dst, hawk_oow_t dlen, const hawk_uch_t* src)
|
hawk_oow_t hawk_copy_ucstr_to_uchars (hawk_uch_t* dst, hawk_oow_t dlen, const hawk_uch_t* src)
|
||||||
{
|
{
|
||||||
/* no null termination */
|
/* no null termination */
|
||||||
hawk_uch_t* p, * p2;
|
hawk_uch_t* p, * p2;
|
||||||
@ -391,7 +391,7 @@ hawk_oow_t hawk_copy_ucstr_to_uchars (hawk_uch_t* dst, hawk_oow_t dlen, const h
|
|||||||
return p - dst;
|
return p - dst;
|
||||||
}
|
}
|
||||||
|
|
||||||
hawk_oow_t hawk_copy_bcstr_to_bchars (hawk_bch_t* dst, hawk_oow_t dlen, const hawk_bch_t* src)
|
hawk_oow_t hawk_copy_bcstr_to_bchars (hawk_bch_t* dst, hawk_oow_t dlen, const hawk_bch_t* src)
|
||||||
{
|
{
|
||||||
/* no null termination */
|
/* no null termination */
|
||||||
hawk_bch_t* p, * p2;
|
hawk_bch_t* p, * p2;
|
||||||
|
@ -86,13 +86,15 @@ hawk_bch_t* subst (hawk_bch_t* buf, hawk_oow_t bsz, const hawk_bcs_t* ident, voi
|
|||||||
return buf + ((buf == HAWK_SUBST_NOBUF)? 3: hawk_copy_bcstr_to_bchars(buf, bsz, "sam"));
|
return buf + ((buf == HAWK_SUBST_NOBUF)? 3: hawk_copy_bcstr_to_bchars(buf, bsz, "sam"));
|
||||||
}
|
}
|
||||||
else if (hawk_comp_bchars_bcstr(ident->ptr, ident->len, "GROUP") == 0)
|
else if (hawk_comp_bchars_bcstr(ident->ptr, ident->len, "GROUP") == 0)
|
||||||
|
{
|
||||||
return buf + ((buf == HAWK_SUBST_NOBUF)? 6: hawk_copy_bcstr_to_bchars(buf, bsz, "coders"));
|
return buf + ((buf == HAWK_SUBST_NOBUF)? 6: hawk_copy_bcstr_to_bchars(buf, bsz, "coders"));
|
||||||
|
}
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int test3 (void)
|
static int test3 (void)
|
||||||
{
|
{
|
||||||
hawk_bch_t buf[25], * ptr;
|
hawk_bch_t buf[512], * ptr;
|
||||||
hawk_oow_t n;
|
hawk_oow_t n;
|
||||||
n = hawk_subst_for_bcstr_to_bcstr (buf, HAWK_COUNTOF(buf), "user=${USER},group=${GROUP}", subst, HAWK_NULL);
|
n = hawk_subst_for_bcstr_to_bcstr (buf, HAWK_COUNTOF(buf), "user=${USER},group=${GROUP}", subst, HAWK_NULL);
|
||||||
T_ASSERT0 (n == 21);
|
T_ASSERT0 (n == 21);
|
||||||
|
Loading…
Reference in New Issue
Block a user