touched up code
This commit is contained in:
111
stix/lib/stix.c
111
stix/lib/stix.c
@ -208,117 +208,6 @@ stix_size_t stix_hashuchars (const stix_uch_t* ptr, stix_size_t len)
|
||||
return stix_hashbytes ((const stix_byte_t *)ptr, len * STIX_SIZEOF(*ptr));
|
||||
}
|
||||
|
||||
int stix_equalchars (const stix_uch_t* str1, const stix_uch_t* str2, stix_size_t len)
|
||||
{
|
||||
stix_size_t i;
|
||||
|
||||
for (i = 0; i < len; i++)
|
||||
{
|
||||
if (str1[i] != str2[i]) return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int stix_compucstr (const stix_uch_t* str1, const stix_uch_t* str2)
|
||||
{
|
||||
while (*str1 == *str2)
|
||||
{
|
||||
if (*str1 == '\0') return 0;
|
||||
str1++, str2++;
|
||||
}
|
||||
|
||||
return (*str1 > *str2)? 1: -1;
|
||||
}
|
||||
|
||||
int stix_compbcstr (const stix_bch_t* str1, const stix_bch_t* str2)
|
||||
{
|
||||
while (*str1 == *str2)
|
||||
{
|
||||
if (*str1 == '\0') return 0;
|
||||
str1++, str2++;
|
||||
}
|
||||
|
||||
return (*str1 > *str2)? 1: -1;
|
||||
}
|
||||
|
||||
int stix_compucbcstr (const stix_uch_t* str1, const stix_bch_t* str2)
|
||||
{
|
||||
while (*str1 == *str2)
|
||||
{
|
||||
if (*str1 == '\0') return 0;
|
||||
str1++, str2++;
|
||||
}
|
||||
|
||||
return (*str1 > *str2)? 1: -1;
|
||||
}
|
||||
|
||||
int stix_compucxbcstr (const stix_uch_t* str1, stix_size_t len, const stix_bch_t* str2)
|
||||
{
|
||||
const stix_uch_t* end = str1 + len;
|
||||
while (str1 < end && *str2 != '\0' && *str1 == *str2) str1++, str2++;
|
||||
if (str1 == end && *str2 == '\0') return 0;
|
||||
if (*str1 == *str2) return (str1 < end)? 1: -1;
|
||||
return (*str1 > *str2)? 1: -1;
|
||||
}
|
||||
|
||||
void stix_copyuchars (stix_uch_t* dst, const stix_uch_t* src, stix_size_t len)
|
||||
{
|
||||
stix_size_t i;
|
||||
for (i = 0; i < len; i++) dst[i] = src[i];
|
||||
}
|
||||
|
||||
void stix_copybchtouchars (stix_uch_t* dst, const stix_bch_t* src, stix_size_t len)
|
||||
{
|
||||
stix_size_t i;
|
||||
for (i = 0; i < len; i++) dst[i] = src[i];
|
||||
}
|
||||
|
||||
stix_size_t stix_copyucstr (stix_uch_t* dst, stix_size_t len, const stix_uch_t* src)
|
||||
{
|
||||
stix_uch_t* p, * p2;
|
||||
|
||||
p = dst; p2 = dst + len - 1;
|
||||
|
||||
while (p < p2)
|
||||
{
|
||||
if (*src == '\0') break;
|
||||
*p++ = *src++;
|
||||
}
|
||||
|
||||
if (len > 0) *p = '\0';
|
||||
return p - dst;
|
||||
}
|
||||
|
||||
stix_size_t stix_copybcstr (stix_bch_t* dst, stix_size_t len, const stix_bch_t* src)
|
||||
{
|
||||
stix_bch_t* p, * p2;
|
||||
|
||||
p = dst; p2 = dst + len - 1;
|
||||
|
||||
while (p < p2)
|
||||
{
|
||||
if (*src == '\0') break;
|
||||
*p++ = *src++;
|
||||
}
|
||||
|
||||
if (len > 0) *p = '\0';
|
||||
return p - dst;
|
||||
}
|
||||
|
||||
stix_uch_t* stix_findchar (const stix_uch_t* ptr, stix_size_t len, stix_uch_t c)
|
||||
{
|
||||
const stix_uch_t* end;
|
||||
|
||||
end = ptr + len;
|
||||
while (ptr < end)
|
||||
{
|
||||
if (*ptr == c) return (stix_uch_t*)ptr;
|
||||
ptr++;
|
||||
}
|
||||
|
||||
return STIX_NULL;
|
||||
}
|
||||
|
||||
void* stix_allocmem (stix_t* stix, stix_size_t size)
|
||||
{
|
||||
|
Reference in New Issue
Block a user