diff --git a/moo/lib/exec.c b/moo/lib/exec.c index aa42890..cda487a 100644 --- a/moo/lib/exec.c +++ b/moo/lib/exec.c @@ -3343,7 +3343,7 @@ static pf_t pftab[] = { "Apex_addToBeFinalized", { pf_add_to_be_finalized, 0, 0 } }, { "Apex_basicAt:", { moo_pf_basic_at, 1, 1 } }, { "Apex_basicAt:put:", { moo_pf_basic_at_put, 2, 2 } }, - { "Apex_basicFillFrom:with:count:", { moo_pf_basic_fill, 3, 3 } }, + { "Apex_basicFillFrom:with:count:", { moo_pf_basic_fill, 3, 3 } }, { "Apex_basicNew", { moo_pf_basic_new, 0, 0 } }, { "Apex_basicNew:", { moo_pf_basic_new, 1, 1 } }, { "Apex_basicShiftFrom:to:count:", { moo_pf_basic_shift, 3, 3 } }, diff --git a/moo/lib/utl.c b/moo/lib/utl.c index 9286255..ce01fd8 100644 --- a/moo/lib/utl.c +++ b/moo/lib/utl.c @@ -109,66 +109,52 @@ int moo_compucbcstr (const moo_uch_t* str1, const moo_bch_t* str2) int moo_compucharsucstr (const moo_uch_t* str1, moo_oow_t len, const moo_uch_t* str2) { + /* for "abc\0" of length 4 vs "abc", the fourth character + * of the first string is equal to the terminating null of + * the second string. the first string is still considered + * bigger */ const moo_uch_t* end = str1 + len; - while (str1 < end && *str2 != '\0' && *str1 == *str2) str1++, str2++; - - if (str1 == end) + while (str1 < end && *str2 != '\0') { - return (*str2 == '\0')? 0: -1; - } - else /* str1 < end */ - { - /* for "abc\0" of length 4 vs "abc", the fourth character - * of the first string is equal to the terminating null of - * the second string. the first string is still considered - * bigger */ - return (*str1 >= *str2)? 1: -1; + if (*str1 != *str2) return (*str1 > *str2)? 1: -1; + str1++; str2++; } + return (str1 < end)? 1: (*str2 == '\0'? 0: -1); } int moo_compucharsbcstr (const moo_uch_t* str1, moo_oow_t len, const moo_bch_t* str2) { const moo_uch_t* end = str1 + len; - while (str1 < end && *str2 != '\0' && *str1 == *str2) str1++, str2++; - if (str1 == end) + while (str1 < end && *str2 != '\0') { - return (*str2 == '\0')? 0: -1; - } - else /* str1 < end */ - { - return (*str1 >= *str2)? 1: -1; + if (*str1 != *str2) return (*str1 > *str2)? 1: -1; + str1++; str2++; } + return (str1 < end)? 1: (*str2 == '\0'? 0: -1); } int moo_compbcharsbcstr (const moo_bch_t* str1, moo_oow_t len, const moo_bch_t* str2) { const moo_bch_t* end = str1 + len; - while (str1 < end && *str2 != '\0' && *str1 == *str2) str1++, str2++; - if (str1 == end) + while (str1 < end && *str2 != '\0') { - return (*str2 == '\0')? 0: -1; - } - else - { - return (*str1 >= *str2)? 1: -1; + if (*str1 != *str2) return (*str1 > *str2)? 1: -1; + str1++; str2++; } + return (str1 < end)? 1: (*str2 == '\0'? 0: -1); } int moo_compbcharsucstr (const moo_bch_t* str1, moo_oow_t len, const moo_uch_t* str2) { const moo_bch_t* end = str1 + len; - while (str1 < end && *str2 != '\0' && *str1 == *str2) str1++, str2++; - if (str1 == end) + while (str1 < end && *str2 != '\0') { - return (*str2 == '\0')? 0: -1; - } - else - { - return (*str1 >= *str2)? 1: -1; + if (*str1 != *str2) return (*str1 > *str2)? 1: -1; + str1++; str2++; } + return (str1 < end)? 1: (*str2 == '\0'? 0: -1); } - void moo_copyuchars (moo_uch_t* dst, const moo_uch_t* src, moo_oow_t len) { /* take note of no forced null termination */