[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] [PATCH] util: string: Avoid use of deprecated function index()



---
 src/util/virstring.c | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/src/util/virstring.c b/src/util/virstring.c
index 1cd4987..e48c29a 100644
--- a/src/util/virstring.c
+++ b/src/util/virstring.c
@@ -976,6 +976,21 @@ static const char control_chars[] =
     "\x10\x11\x12\x13\x14\x15\x16\x17"
     "\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F";

+
+static bool
+virStringIsControlChar(char c)
+{
+    const char *cch;
+
+    for (cch = control_chars; *cch; cch++) {
+        if (*cch == c)
+            return true;
+    }
+
+    return false;
+}
+
+
 bool
 virStringHasControlChars(const char *str)
 {
@@ -1003,7 +1018,7 @@ virStringStripControlChars(char *str)

     len = strlen(str);
     for (i = 0, j = 0; i < len; i++) {
-        if (index(control_chars, str[i]))
+        if (virStringIsControlChar(str[i]))
             continue;

         str[j++] = str[i];
-- 
2.3.5


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]