summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2018-06-02 17:52:07 +0200
committerSven Eden <yamakuzure@gmx.net>2018-08-24 16:47:08 +0200
commitf39f1b81b67bbe5137bdc87e76076407bd77f0c3 (patch)
tree9514d00c40fcb9334d0624894ae8ee89ea1c3278
parenta35a95b092b411179028c94fee69139a4afeedfd (diff)
basic/string-util: make ellipsize() inline
Once the redundant check is removed, it's a very simple wrapper around ellipsize_mem().
-rw-r--r--src/basic/string-util.c7
-rw-r--r--src/basic/string-util.h5
2 files changed, 4 insertions, 8 deletions
diff --git a/src/basic/string-util.c b/src/basic/string-util.c
index cb6428e8a..bdaa42084 100644
--- a/src/basic/string-util.c
+++ b/src/basic/string-util.c
@@ -611,13 +611,6 @@ char *ellipsize_mem(const char *s, size_t old_length, size_t new_length, unsigne
return e;
}
-char *ellipsize(const char *s, size_t length, unsigned percent) {
- if (length == (size_t) -1)
- return strdup(s);
-
- return ellipsize_mem(s, strlen(s), length, percent);
-}
-
char *cellescape(char *buf, size_t len, const char *s) {
/* Escape and ellipsize s into buffer buf of size len. Only non-control ASCII
* characters are copied as they are, everything else is escaped. The result
diff --git a/src/basic/string-util.h b/src/basic/string-util.h
index 7ee9aef70..1671697a0 100644
--- a/src/basic/string-util.h
+++ b/src/basic/string-util.h
@@ -164,7 +164,10 @@ static inline bool _pure_ in_charset(const char *s, const char* charset) {
bool string_has_cc(const char *p, const char *ok) _pure_;
char *ellipsize_mem(const char *s, size_t old_length_bytes, size_t new_length_columns, unsigned percent);
-char *ellipsize(const char *s, size_t length, unsigned percent);
+static inline char *ellipsize(const char *s, size_t length, unsigned percent) {
+ return ellipsize_mem(s, strlen(s), length, percent);
+}
+
char *cellescape(char *buf, size_t len, const char *s);
/* This limit is arbitrary, enough to give some idea what the string contains */