Mon, 14 Jul 2014 12:45:48 +0200
removed old sstrncat
test/main.c | file | annotate | diff | comparison | revisions | |
test/string_tests.c | file | annotate | diff | comparison | revisions | |
test/string_tests.h | file | annotate | diff | comparison | revisions | |
ucx/string.c | file | annotate | diff | comparison | revisions | |
ucx/string.h | file | annotate | diff | comparison | revisions |
--- a/test/main.c Mon Jul 07 11:54:55 2014 +0200 +++ b/test/main.c Mon Jul 14 12:45:48 2014 +0200 @@ -118,7 +118,7 @@ /* sstring Tests */ ucx_test_register(suite, test_sstr); - ucx_test_register(suite, test_sstr_len_cat); + ucx_test_register(suite, test_sstr_len); ucx_test_register(suite, test_sstrcmp); ucx_test_register(suite, test_sstrcasecmp); ucx_test_register(suite, test_sstrchr_sstrrchr);
--- a/test/string_tests.c Mon Jul 07 11:54:55 2014 +0200 +++ b/test/string_tests.c Mon Jul 14 12:45:48 2014 +0200 @@ -40,33 +40,18 @@ UCX_TEST_END } -UCX_TEST(test_sstr_len_cat) { +UCX_TEST(test_sstr_len) { sstr_t s1 = ST("1234"); sstr_t s2 = ST(".:.:."); sstr_t s3 = ST("X"); size_t len = sstrnlen(3, s1, s2, s3); - sstr_t cat; - cat.ptr = (char*) malloc(16); - cat.length = 16; - cat = sstrncat(cat, 3, s1, s2, s3); UCX_TEST_BEGIN UCX_TEST_ASSERT(len == 10, "sstrnlen returned wrong size"); - - UCX_TEST_ASSERT(cat.ptr[0] == '1', "sstrncat, wrong content"); - UCX_TEST_ASSERT(cat.ptr[1] == '2', "sstrncat, wrong content"); - UCX_TEST_ASSERT(cat.ptr[2] == '3', "sstrncat, wrong content"); - UCX_TEST_ASSERT(cat.ptr[3] == '4', "sstrncat, wrong content"); - UCX_TEST_ASSERT(cat.ptr[4] == '.', "sstrncat, wrong content"); - UCX_TEST_ASSERT(cat.ptr[8] == '.', "sstrncat, wrong content"); - UCX_TEST_ASSERT(cat.ptr[9] == 'X', "sstrncat, wrong content"); - UCX_TEST_ASSERT(cat.length == 10, "sstrncat, wrong length"); - + UCX_TEST_END - - free(cat.ptr); } UCX_TEST(test_sstrchr_sstrrchr) {
--- a/test/string_tests.h Mon Jul 07 11:54:55 2014 +0200 +++ b/test/string_tests.h Mon Jul 14 12:45:48 2014 +0200 @@ -37,7 +37,7 @@ #endif UCX_TEST(test_sstr); -UCX_TEST(test_sstr_len_cat); +UCX_TEST(test_sstr_len); UCX_TEST(test_sstrcmp); UCX_TEST(test_sstrcasecmp); UCX_TEST(test_sstrchr_sstrrchr);
--- a/ucx/string.c Mon Jul 07 11:54:55 2014 +0200 +++ b/ucx/string.c Mon Jul 14 12:45:48 2014 +0200 @@ -61,35 +61,6 @@ return size; } -sstr_t sstrncat(sstr_t s, size_t n, sstr_t c1, ...) { - va_list ap; - va_start(ap, c1); - s.ptr[0] = 0; - - size_t len = s.length; - size_t cplen = c1.length > len ? len : c1.length; - char *ptr = s.ptr; - - memcpy(ptr, c1.ptr, cplen); - len -= cplen; - ptr += cplen; - for (size_t i = 1 ; i < n ; i++) { - sstr_t str = va_arg (ap, sstr_t); - cplen = str.length > len ? len : str.length; - if(cplen <= 0) { - va_end(ap); - return s; - } - memcpy(ptr, str.ptr, cplen); - len -= cplen; - ptr += cplen; - } - va_end(ap); - s.length = ptr - s.ptr; - - return s; -} - sstr_t sstrsubs(sstr_t s, size_t start) { return sstrsubsl (s, start, s.length-start); }
--- a/ucx/string.h Mon Jul 07 11:54:55 2014 +0200 +++ b/ucx/string.h Mon Jul 14 12:45:48 2014 +0200 @@ -119,40 +119,6 @@ */ size_t sstrnlen(size_t count, sstr_t string, ...); - -/** - * Concatenates strings. - * - * At least one string must be specified and there must be enough memory - * available referenced by the destination sstr_t.ptr for this function to - * successfully concatenate all specified strings. - * - * The sstr_t.length of the destination string specifies the capacity and - * should match the total memory available referenced by the destination - * sstr_t.ptr. This function <i>never</i> copies data beyond the capacity and - * does not modify any of the source strings. - * - * <b>Attention:</b> - * <ul> - * <li>Any content in the destination string will be overwritten</li> - * <li>The destination sstr_t.ptr is <b>NOT</b> - * <code>NULL</code>-terminated</li> - * <li>The destination sstr_t.length is set to the total length of the - * concatenated strings</li> - * <li><i>Hint:</i> get a <code>NULL</code>-terminated string by performing - * <code>mystring.ptr[mystring.length]='\0'</code> after calling this - * function</li> - * </ul> - * - * @param dest new sstr_t with capacity information and allocated memory - * @param count the total number of strings to concatenate - * @param src the first string - * @param ... all other strings - * @return the argument for <code>dest</code> is returned - */ -sstr_t sstrncat(sstr_t dest, size_t count, sstr_t src, ...); - - /** * Returns a substring starting at the specified location. *