]> xenbits.xensource.com Git - libvirt.git/commitdiff
util: buf: Remove virBufferEscapeN
authorPeter Krempa <pkrempa@redhat.com>
Thu, 21 Feb 2019 15:29:40 +0000 (16:29 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Fri, 22 Feb 2019 09:05:45 +0000 (10:05 +0100)
The function was used only in the tests, remove it.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
src/libvirt_private.syms
src/util/virbuffer.c
src/util/virbuffer.h
tests/virbuftest.c

index b720acdc939d74f5d6c349eb893bc184b4f93b2c..aa1b2c77bef543eb8d1a9b0c5802912dfdf76122 100644 (file)
@@ -1488,7 +1488,6 @@ virBufferContentAndReset;
 virBufferCurrentContent;
 virBufferError;
 virBufferEscape;
-virBufferEscapeN;
 virBufferEscapeRegex;
 virBufferEscapeSexpr;
 virBufferEscapeShell;
index 7399bdcdfeac356e376b86c00771a5317c8f65c1..12bdd13d394e45d0af43f7f993437134fe3982a3 100644 (file)
@@ -643,99 +643,6 @@ virBufferEscape(virBufferPtr buf, char escape, const char *toescape,
 }
 
 
-struct virBufferEscapePair {
-    char escape;
-    char *toescape;
-};
-
-
-/**
- * virBufferEscapeN:
- * @buf: the buffer to append to
- * @format: a printf like format string but with only one %s parameter
- * @str: the string argument which needs to be escaped
- * @...: the variable list of escape pairs
- *
- * The variable list of arguments @... must be composed of
- * 'char escape, char *toescape' pairs followed by NULL.
- *
- * This has the same functionality as virBufferEscape with the extension
- * that allows to specify multiple pairs of chars that needs to be escaped.
- */
-void
-virBufferEscapeN(virBufferPtr buf,
-                 const char *format,
-                 const char *str,
-                 ...)
-{
-    int len;
-    size_t i;
-    VIR_AUTOFREE(char *) escaped = NULL;
-    char *out;
-    const char *cur;
-    struct virBufferEscapePair escapeItem;
-    struct virBufferEscapePair *escapeList = NULL;
-    size_t nescapeList = 0;
-    va_list ap;
-
-    if ((format == NULL) || (buf == NULL) || (str == NULL))
-        return;
-
-    if (buf->error)
-        return;
-
-    len = strlen(str);
-
-    va_start(ap, str);
-
-    while ((escapeItem.escape = va_arg(ap, int))) {
-        if (!(escapeItem.toescape = va_arg(ap, char *))) {
-            virBufferSetError(buf, errno);
-            goto cleanup;
-        }
-
-        if (strcspn(str, escapeItem.toescape) == len)
-            continue;
-
-        if (VIR_APPEND_ELEMENT_QUIET(escapeList, nescapeList, escapeItem) < 0) {
-            virBufferSetError(buf, errno);
-            goto cleanup;
-        }
-    }
-
-    if (nescapeList == 0) {
-        virBufferAsprintf(buf, format, str);
-        goto cleanup;
-    }
-
-    if (xalloc_oversized(2, len) ||
-        VIR_ALLOC_N_QUIET(escaped, 2 * len + 1) < 0) {
-        virBufferSetError(buf, errno);
-        goto cleanup;
-    }
-
-    cur = str;
-    out = escaped;
-    while (*cur != 0) {
-        for (i = 0; i < nescapeList; i++) {
-            if (strchr(escapeList[i].toescape, *cur)) {
-                *out++ = escapeList[i].escape;
-                break;
-            }
-        }
-        *out++ = *cur;
-        cur++;
-    }
-    *out = 0;
-
-    virBufferAsprintf(buf, format, escaped);
-
- cleanup:
-    va_end(ap);
-    VIR_FREE(escapeList);
-}
-
-
 /**
  * virBufferURIEncodeString:
  * @buf: the buffer to append to
index 1c8e182064a24f098c565a05502fa73a6661971a..7e4e7645dfc9b9d48e8f2f93899e58b20ec17232 100644 (file)
@@ -84,8 +84,6 @@ void virBufferStrcatVArgs(virBufferPtr buf, va_list ap);
 
 void virBufferEscape(virBufferPtr buf, char escape, const char *toescape,
                      const char *format, const char *str);
-void virBufferEscapeN(virBufferPtr buf, const char *format,
-                      const char *str, ...);
 void virBufferEscapeString(virBufferPtr buf, const char *format,
                            const char *str);
 void virBufferEscapeSexpr(virBufferPtr buf, const char *format,
index 547438c6465beaa61b2b2f3e14bc55533a7ab8fe..bdb0a5e934ddc4619fe04871e6ffc86245dfc3e4 100644 (file)
@@ -372,35 +372,6 @@ testBufEscapeStr(const void *opaque ATTRIBUTE_UNUSED)
 }
 
 
-static int
-testBufEscapeN(const void *opaque)
-{
-    const struct testBufAddStrData *data = opaque;
-    virBuffer buf = VIR_BUFFER_INITIALIZER;
-    char *actual;
-    int ret = -1;
-
-    virBufferEscapeN(&buf, "%s", data->data, '\\', "=", ',', ",", NULL);
-
-    if (!(actual = virBufferContentAndReset(&buf))) {
-        VIR_TEST_DEBUG("testBufEscapeN: buf is empty");
-        goto cleanup;
-    }
-
-    if (STRNEQ_NULLABLE(actual, data->expect)) {
-        VIR_TEST_DEBUG("testBufEscapeN: Strings don't match:\n");
-        virTestDifference(stderr, data->expect, actual);
-        goto cleanup;
-    }
-
-    ret = 0;
-
- cleanup:
-    VIR_FREE(actual);
-    return ret;
-}
-
-
 static int
 testBufEscapeRegex(const void *opaque)
 {
@@ -506,18 +477,6 @@ mymain(void)
     DO_TEST_ESCAPE("\x01\x01\x02\x03\x05\x08",
                    "<c>\n  <el></el>\n</c>");
 
-#define DO_TEST_ESCAPEN(data, expect) \
-    do { \
-        struct testBufAddStrData info = { data, expect }; \
-        if (virTestRun("Buf: EscapeN", testBufEscapeN, &info) < 0) \
-            ret = -1; \
-    } while (0)
-
-    DO_TEST_ESCAPEN("noescape", "noescape");
-    DO_TEST_ESCAPEN("comma,escape", "comma,,escape");
-    DO_TEST_ESCAPEN("equal=escape", "equal\\=escape");
-    DO_TEST_ESCAPEN("comma,equal=escape", "comma,,equal\\=escape");
-
 #define DO_TEST_ESCAPE_REGEX(data, expect) \
     do { \
         struct testBufAddStrData info = { data, expect }; \