chiark / gitweb /
strv: drop strv_join_quoted() (#8057)
authorYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 1 Feb 2018 09:11:02 +0000 (18:11 +0900)
committerSven Eden <yamakuzure@gmx.net>
Wed, 30 May 2018 05:58:45 +0000 (07:58 +0200)
The function `strv_join_quoted()` is now not used, and has a bug
in the buffer size calculation when the strings needs to escaped,
as reported in #8056.
So, let's remove the function.

Closes #8056.

src/basic/strv.c
src/basic/strv.h

index 0d46addbc00e55bc3e44e8a561458a1368e37cd0..f3bb6965abc8a1f9208b33a6903aec60d403dead 100644 (file)
@@ -398,43 +398,7 @@ char *strv_join(char **l, const char *separator) {
 }
 
 #if 0 /// UNNEEDED by elogind
-char *strv_join_quoted(char **l) {
-        char *buf = NULL;
-        char **s;
-        size_t allocated = 0, len = 0;
-
-        STRV_FOREACH(s, l) {
-                /* assuming here that escaped string cannot be more
-                 * than twice as long, and reserving space for the
-                 * separator and quotes.
-                 */
-                _cleanup_free_ char *esc = NULL;
-                size_t needed;
-
-                if (!GREEDY_REALLOC(buf, allocated,
-                                    len + strlen(*s) * 2 + 3))
-                        goto oom;
-
-                esc = cescape(*s);
-                if (!esc)
-                        goto oom;
-
-                needed = snprintf(buf + len, allocated - len, "%s\"%s\"",
-                                  len > 0 ? " " : "", esc);
-                assert(needed < allocated - len);
-                len += needed;
-        }
-
-        if (!buf)
-                buf = malloc0(1);
-
-        return buf;
-
- oom:
-        return mfree(buf);
-}
 #endif // 0
-
 int strv_push(char ***l, char *value) {
         char **c;
         unsigned n, m;
index 32cd6ccd51c4625d3e6f866ccf8e57d98c62b333..489be2f7749430bfeb42a87ada95a3015d02acf6 100644 (file)
@@ -97,7 +97,6 @@ int strv_split_extract(char ***t, const char *s, const char *separators, Extract
 
 char *strv_join(char **l, const char *separator);
 #if 0 /// UNNEEDED by elogind
-char *strv_join_quoted(char **l);
 #endif // 0
 
 char **strv_parse_nulstr(const char *s, size_t l);