[libvirt PATCH 1/2] util: virSkipToDigit()

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

 



This function skips over the beginning of a string until it reaches a
decimal digit (0-9) or the NULL at the end of the string. The original
pointer is modified in place (similar to virSkipSpaces()).

Signed-off-by: Laine Stump <laine@xxxxxxxxxx>
---
 src/libvirt_private.syms |  1 +
 src/util/virstring.c     | 18 ++++++++++++++++++
 src/util/virstring.h     |  1 +
 3 files changed, 20 insertions(+)

diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index c67bd2504a..c325040b60 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -3217,6 +3217,7 @@ virStorageFileBackendRegister;
 virSkipSpaces;
 virSkipSpacesAndBackslash;
 virSkipSpacesBackwards;
+virSkipToDigit;
 virStrcpy;
 virStringBufferIsPrintable;
 virStringFilterChars;
diff --git a/src/util/virstring.c b/src/util/virstring.c
index 5578a5545b..521f2de3f6 100644
--- a/src/util/virstring.c
+++ b/src/util/virstring.c
@@ -752,6 +752,24 @@ virSkipSpacesAndBackslash(const char **str)
     *str = cur;
 }
 
+
+/**
+ * virSkipToDigit:
+ * @str: pointer to the char pointer used
+ *
+ * Skip over any character that is not 0-9
+ */
+void
+virSkipToDigit(const char **str)
+{
+    const char *cur = *str;
+
+    while (*cur && !g_ascii_isdigit(*cur))
+        cur++;
+    *str = cur;
+}
+
+
 /**
  * virTrimSpaces:
  * @str: string to modify to remove all trailing spaces
diff --git a/src/util/virstring.h b/src/util/virstring.h
index 210e43a953..55547b040a 100644
--- a/src/util/virstring.h
+++ b/src/util/virstring.h
@@ -110,6 +110,7 @@ int virDoubleToStr(char **strp, double number)
 
 void virSkipSpaces(const char **str) ATTRIBUTE_NONNULL(1);
 void virSkipSpacesAndBackslash(const char **str) ATTRIBUTE_NONNULL(1);
+void virSkipToDigit(const char **str) ATTRIBUTE_NONNULL(1);
 void virTrimSpaces(char *str, char **endp) ATTRIBUTE_NONNULL(1);
 void virSkipSpacesBackwards(const char *str, char **endp)
     ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
-- 
2.29.2




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux