[Xfce4-commits] <libxfce4util:master> Fix XfceRc group parsing with brackets in name (bug #8150).

Nick Schermer noreply at xfce.org
Sat Jan 7 12:00:01 CET 2012


Updating branch refs/heads/master
         to 97f0ec4fac9199655aa59a6981c6bce39b2a350d (commit)
       from 3f6782718ed1cb43a40e228631197b898e71ae42 (commit)

commit 97f0ec4fac9199655aa59a6981c6bce39b2a350d
Author: Nick Schermer <nick at xfce.org>
Date:   Sat Jan 7 11:57:19 2012 +0100

    Fix XfceRc group parsing with brackets in name (bug #8150).
    
    Groups names like:
    
    [file[1].c]
    row=8
    col=11
    
    were not read property because the first close bracket
    was matched. Reverse search to fix this.

 libxfce4util/xfce-rc-simple.c |   19 ++++++++-----------
 1 files changed, 8 insertions(+), 11 deletions(-)

diff --git a/libxfce4util/xfce-rc-simple.c b/libxfce4util/xfce-rc-simple.c
index 929138f..dd6050b 100644
--- a/libxfce4util/xfce-rc-simple.c
+++ b/libxfce4util/xfce-rc-simple.c
@@ -327,10 +327,8 @@ simple_parse_line (gchar  *line,
 
   if (*p == '[')
     {
-      for (q = ++p; *q != '\0' && *q != ']'; ++q)
-        ;
-
-      if (G_LIKELY (*q == ']'))
+      q = strrchr (++p, ']');
+      if (G_LIKELY (q != NULL))
         {
           *section = p;
           *q = '\0';
@@ -339,9 +337,8 @@ simple_parse_line (gchar  *line,
     }
   else
     {
-      for (q = p + 1; *q != '=' && *q != '\0'; ++q)
-        ;
-      if (G_UNLIKELY (*q != '='))
+      q = strchr (p + 1, '=');
+      if (G_UNLIKELY (q == NULL))
         return FALSE;
 
       r = q + 1;
@@ -803,10 +800,10 @@ _xfce_rc_simple_get_groups (const XfceRc *rc)
   for (group = simple->gfirst; group != NULL; group = group->next)
     {
       if (pos == size)
-  {
-    size *= 2;
-    result = g_realloc (result, (size + 1) * sizeof (*result));
-  }
+        {
+          size *= 2;
+          result = g_realloc (result, (size + 1) * sizeof (*result));
+        }
       result[pos] = g_strdup (group->name);
       ++pos;
     }


More information about the Xfce4-commits mailing list