Display and control your Android device
Remove confusing sc_str_truncate()
Romain Vimont137d2c97914f
diff --git a/app/src/util/str.c b/app/src/util/str.cindex 2d67f816..d78aa9d7 100644--- a/app/src/util/str.c+++ b/app/src/util/str.c@@ -297,14 +297,6 @@ error:return NULL;}-size_t-sc_str_truncate(char *data, size_t len, const char *endchars) {- data[len - 1] = '\0';- size_t idx = strcspn(data, endchars);- data[idx] = '\0';- return idx;-}-ssize_tsc_str_index_of_column(const char *s, unsigned col, const char *seps) {size_t colidx = 0;diff --git a/app/src/util/str.h b/app/src/util/str.hindex dfe0cb30..1736bd95 100644--- a/app/src/util/str.h+++ b/app/src/util/str.h@@ -103,17 +103,6 @@ sc_str_from_wchars(const wchar_t *s);char *sc_str_wrap_lines(const char *input, unsigned columns, unsigned indent);-/**- * Truncate the data after any of the characters from `endchars`- *- * An '\0' is always written at the end of the data string, even if no- * character from `endchars` is encountered.- *- * Return the size of the resulting string (as strlen() would return).- */-size_t-sc_str_truncate(char *data, size_t len, const char *endchars);-/*** Find the start of a column in a string*diff --git a/app/tests/test_str.c b/app/tests/test_str.cindex cc3039e7..4fe8a1df 100644--- a/app/tests/test_str.c+++ b/app/tests/test_str.c@@ -338,32 +338,6 @@ static void test_wrap_lines(void) {free(formatted);}-static void test_truncate(void) {- char s[] = "hello\nworld\n!";- size_t len = sc_str_truncate(s, sizeof(s), "\n");-- assert(len == 5);- assert(!strcmp("hello", s));-- char s2[] = "hello\r\nworkd\r\n!";- len = sc_str_truncate(s2, sizeof(s2), "\n\r");-- assert(len == 5);- assert(!strcmp("hello", s));-- char s3[] = "hello world\n!";- len = sc_str_truncate(s3, sizeof(s3), " \n\r");-- assert(len == 5);- assert(!strcmp("hello", s3));-- char s4[] = "hello ";- len = sc_str_truncate(s4, sizeof(s4), " \n\r");-- assert(len == 5);- assert(!strcmp("hello", s4));-}-static void test_index_of_column(void) {assert(sc_str_index_of_column("a bc d", 0, " ") == 0);assert(sc_str_index_of_column("a bc d", 1, " ") == 2);@@ -417,7 +391,6 @@ int main(int argc, char *argv[]) {test_parse_integer_with_suffix();test_strlist_contains();test_wrap_lines();- test_truncate();test_index_of_column();test_remove_trailing_cr();return 0;