On Thu, Apr 23, 2015 at 10:48:06AM +0200, Peter Krempa wrote:
---
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]))
Why not simply s/index/strchr/ which is the recommended POSIX
replacement ?
Regards,
Daniel
--
|:
http://berrange.com -o-
http://www.flickr.com/photos/dberrange/ :|
|:
http://libvirt.org -o-
http://virt-manager.org :|
|:
http://autobuild.org -o-
http://search.cpan.org/~danberr/ :|
|:
http://entangle-photo.org -o-
http://live.gnome.org/gtk-vnc :|