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 |
1.1 --- a/test/main.c Mon Jul 07 11:54:55 2014 +0200 1.2 +++ b/test/main.c Mon Jul 14 12:45:48 2014 +0200 1.3 @@ -118,7 +118,7 @@ 1.4 1.5 /* sstring Tests */ 1.6 ucx_test_register(suite, test_sstr); 1.7 - ucx_test_register(suite, test_sstr_len_cat); 1.8 + ucx_test_register(suite, test_sstr_len); 1.9 ucx_test_register(suite, test_sstrcmp); 1.10 ucx_test_register(suite, test_sstrcasecmp); 1.11 ucx_test_register(suite, test_sstrchr_sstrrchr);
2.1 --- a/test/string_tests.c Mon Jul 07 11:54:55 2014 +0200 2.2 +++ b/test/string_tests.c Mon Jul 14 12:45:48 2014 +0200 2.3 @@ -40,33 +40,18 @@ 2.4 UCX_TEST_END 2.5 } 2.6 2.7 -UCX_TEST(test_sstr_len_cat) { 2.8 +UCX_TEST(test_sstr_len) { 2.9 sstr_t s1 = ST("1234"); 2.10 sstr_t s2 = ST(".:.:."); 2.11 sstr_t s3 = ST("X"); 2.12 2.13 size_t len = sstrnlen(3, s1, s2, s3); 2.14 - sstr_t cat; 2.15 - cat.ptr = (char*) malloc(16); 2.16 - cat.length = 16; 2.17 - cat = sstrncat(cat, 3, s1, s2, s3); 2.18 2.19 UCX_TEST_BEGIN 2.20 2.21 UCX_TEST_ASSERT(len == 10, "sstrnlen returned wrong size"); 2.22 - 2.23 - UCX_TEST_ASSERT(cat.ptr[0] == '1', "sstrncat, wrong content"); 2.24 - UCX_TEST_ASSERT(cat.ptr[1] == '2', "sstrncat, wrong content"); 2.25 - UCX_TEST_ASSERT(cat.ptr[2] == '3', "sstrncat, wrong content"); 2.26 - UCX_TEST_ASSERT(cat.ptr[3] == '4', "sstrncat, wrong content"); 2.27 - UCX_TEST_ASSERT(cat.ptr[4] == '.', "sstrncat, wrong content"); 2.28 - UCX_TEST_ASSERT(cat.ptr[8] == '.', "sstrncat, wrong content"); 2.29 - UCX_TEST_ASSERT(cat.ptr[9] == 'X', "sstrncat, wrong content"); 2.30 - UCX_TEST_ASSERT(cat.length == 10, "sstrncat, wrong length"); 2.31 - 2.32 + 2.33 UCX_TEST_END 2.34 - 2.35 - free(cat.ptr); 2.36 } 2.37 2.38 UCX_TEST(test_sstrchr_sstrrchr) {
3.1 --- a/test/string_tests.h Mon Jul 07 11:54:55 2014 +0200 3.2 +++ b/test/string_tests.h Mon Jul 14 12:45:48 2014 +0200 3.3 @@ -37,7 +37,7 @@ 3.4 #endif 3.5 3.6 UCX_TEST(test_sstr); 3.7 -UCX_TEST(test_sstr_len_cat); 3.8 +UCX_TEST(test_sstr_len); 3.9 UCX_TEST(test_sstrcmp); 3.10 UCX_TEST(test_sstrcasecmp); 3.11 UCX_TEST(test_sstrchr_sstrrchr);
4.1 --- a/ucx/string.c Mon Jul 07 11:54:55 2014 +0200 4.2 +++ b/ucx/string.c Mon Jul 14 12:45:48 2014 +0200 4.3 @@ -61,35 +61,6 @@ 4.4 return size; 4.5 } 4.6 4.7 -sstr_t sstrncat(sstr_t s, size_t n, sstr_t c1, ...) { 4.8 - va_list ap; 4.9 - va_start(ap, c1); 4.10 - s.ptr[0] = 0; 4.11 - 4.12 - size_t len = s.length; 4.13 - size_t cplen = c1.length > len ? len : c1.length; 4.14 - char *ptr = s.ptr; 4.15 - 4.16 - memcpy(ptr, c1.ptr, cplen); 4.17 - len -= cplen; 4.18 - ptr += cplen; 4.19 - for (size_t i = 1 ; i < n ; i++) { 4.20 - sstr_t str = va_arg (ap, sstr_t); 4.21 - cplen = str.length > len ? len : str.length; 4.22 - if(cplen <= 0) { 4.23 - va_end(ap); 4.24 - return s; 4.25 - } 4.26 - memcpy(ptr, str.ptr, cplen); 4.27 - len -= cplen; 4.28 - ptr += cplen; 4.29 - } 4.30 - va_end(ap); 4.31 - s.length = ptr - s.ptr; 4.32 - 4.33 - return s; 4.34 -} 4.35 - 4.36 sstr_t sstrsubs(sstr_t s, size_t start) { 4.37 return sstrsubsl (s, start, s.length-start); 4.38 }
5.1 --- a/ucx/string.h Mon Jul 07 11:54:55 2014 +0200 5.2 +++ b/ucx/string.h Mon Jul 14 12:45:48 2014 +0200 5.3 @@ -119,40 +119,6 @@ 5.4 */ 5.5 size_t sstrnlen(size_t count, sstr_t string, ...); 5.6 5.7 - 5.8 -/** 5.9 - * Concatenates strings. 5.10 - * 5.11 - * At least one string must be specified and there must be enough memory 5.12 - * available referenced by the destination sstr_t.ptr for this function to 5.13 - * successfully concatenate all specified strings. 5.14 - * 5.15 - * The sstr_t.length of the destination string specifies the capacity and 5.16 - * should match the total memory available referenced by the destination 5.17 - * sstr_t.ptr. This function <i>never</i> copies data beyond the capacity and 5.18 - * does not modify any of the source strings. 5.19 - * 5.20 - * <b>Attention:</b> 5.21 - * <ul> 5.22 - * <li>Any content in the destination string will be overwritten</li> 5.23 - * <li>The destination sstr_t.ptr is <b>NOT</b> 5.24 - * <code>NULL</code>-terminated</li> 5.25 - * <li>The destination sstr_t.length is set to the total length of the 5.26 - * concatenated strings</li> 5.27 - * <li><i>Hint:</i> get a <code>NULL</code>-terminated string by performing 5.28 - * <code>mystring.ptr[mystring.length]='\0'</code> after calling this 5.29 - * function</li> 5.30 - * </ul> 5.31 - * 5.32 - * @param dest new sstr_t with capacity information and allocated memory 5.33 - * @param count the total number of strings to concatenate 5.34 - * @param src the first string 5.35 - * @param ... all other strings 5.36 - * @return the argument for <code>dest</code> is returned 5.37 - */ 5.38 -sstr_t sstrncat(sstr_t dest, size_t count, sstr_t src, ...); 5.39 - 5.40 - 5.41 /** 5.42 * Returns a substring starting at the specified location. 5.43 *