From 597cce4785251edaf86c2ccc30589d083e9b7cb2 Mon Sep 17 00:00:00 2001 From: Eric Koegel Date: Mon, 14 Nov 2011 22:53:28 +0300 Subject: [PATCH] Modified simple_parse_line to get the last occurrence of the ] delimiter so it's the most inclusive match --- libxfce4util/xfce-rc-simple.c | 20 ++++++++++++++++---- 1 files changed, 16 insertions(+), 4 deletions(-) diff --git a/libxfce4util/xfce-rc-simple.c b/libxfce4util/xfce-rc-simple.c index 929138f..6391854 100644 --- a/libxfce4util/xfce-rc-simple.c +++ b/libxfce4util/xfce-rc-simple.c @@ -327,13 +327,25 @@ simple_parse_line (gchar *line, if (*p == '[') { - for (q = ++p; *q != '\0' && *q != ']'; ++q) - ; + q = ++p; + while (*q != '\0') + { + /* Search for the last occurrence of ] so + * that it's the most inclusive match */ + for (; *q != '\0' && *q != ']'; ++q) + ; + + if (G_LIKELY(*q == ']')) + { + r = q; + ++q; + } + } - if (G_LIKELY (*q == ']')) + if (G_LIKELY (*r == ']')) { *section = p; - *q = '\0'; + *r = '\0'; return TRUE; } } -- 1.7.5.4