[Pkg-libvirt-commits] [libguestfs] 09/29: Modify the function: analyze_line, make it more flexible

Hilko Bengen bengen at moszumanska.debian.org
Sun Nov 1 17:14:15 UTC 2015


This is an automated email from the git hooks/post-receive script.

bengen pushed a commit to annotated tag upstream/1.29.48
in repository libguestfs.

commit 68ed6dd88ab30b482b70854452b41ee2768ce03e
Author: Cao jin <caoj.fnst at cn.fujitsu.com>
Date:   Tue Jun 23 18:38:19 2015 +0800

    Modify the function: analyze_line, make it more flexible
    
    Modify the function from a fixed delimiter to a variable. So,
    it can be used in more APIs later. Also modified the existing
    callers
    
    Signed-off-by: Cao jin <caoj.fnst at cn.fujitsu.com>
---
 daemon/btrfs.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/daemon/btrfs.c b/daemon/btrfs.c
index 306cade..20e5e6b 100644
--- a/daemon/btrfs.c
+++ b/daemon/btrfs.c
@@ -853,11 +853,10 @@ do_btrfs_fsck (const char *device, int64_t superblock, int repair)
  * returns the next position following \n.
  */
 static char *
-analyze_line (char *line, char **key, char **value)
+analyze_line (char *line, char **key, char **value, char delimiter)
 {
   char *p = line;
   char *next = NULL;
-  char delimiter = ':';
   char *del_pos = NULL;
 
   if (!line || *line == '\0') {
@@ -964,7 +963,7 @@ do_btrfs_subvolume_show (const char *subvolume)
    *                                 snapshots/test3
    *
    */
-  p = analyze_line(out, &key, &value);
+  p = analyze_line(out, &key, &value, ':');
   if (!p) {
     reply_with_error ("truncated output: %s", out);
     return NULL;
@@ -984,7 +983,7 @@ do_btrfs_subvolume_show (const char *subvolume)
   }
 
   /* Read the lines and split into "key: value". */
-  p = analyze_line(p, &key, &value);
+  p = analyze_line(p, &key, &value, ':');
   while (key) {
     /* snapshot is special, see the output above */
     if (STREQLEN (key, "Snapshot(s)", sizeof ("Snapshot(s)") - 1)) {
@@ -994,7 +993,7 @@ do_btrfs_subvolume_show (const char *subvolume)
       if (add_string (&ret, key) == -1)
         return NULL;
 
-      p = analyze_line(p, &key, &value);
+      p = analyze_line(p, &key, &value, ':');
 
       while (key && !value) {
           ss = realloc (ss, ss_len + strlen (key) + 1);
@@ -1008,7 +1007,7 @@ do_btrfs_subvolume_show (const char *subvolume)
           ss_len += strlen (key);
           ss[ss_len] = '\0';
 
-          p = analyze_line(p, &key, &value);
+          p = analyze_line(p, &key, &value, ':');
       }
 
       if (ss) {
@@ -1031,7 +1030,7 @@ do_btrfs_subvolume_show (const char *subvolume)
           return NULL;
       }
 
-      p = analyze_line(p, &key, &value);
+      p = analyze_line(p, &key, &value, ':');
     }
   }
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-libvirt/libguestfs.git



More information about the Pkg-libvirt-commits mailing list