[gegl] gegl-serialize: strip leading space



commit c60080e8a0638103df5a797e23fe731e58b9aceb
Author: Øyvind Kolås <pippin gimp org>
Date:   Thu Apr 21 21:16:29 2016 +0100

    gegl-serialize: strip leading space

 gegl/gegl-serialize.c         |    9 ++++++++-
 tests/simple/test-serialize.c |   34 +++++++++++++++++-----------------
 2 files changed, 25 insertions(+), 18 deletions(-)
---
diff --git a/gegl/gegl-serialize.c b/gegl/gegl-serialize.c
index 0665f55..e4d01a2 100644
--- a/gegl/gegl-serialize.c
+++ b/gegl/gegl-serialize.c
@@ -693,10 +693,17 @@ static gchar *gegl_serialize2 (GeglNode *start, GeglNode *end, const char *basep
 gchar *gegl_serialize (GeglNode *start, GeglNode *end, const char *basepath)
 {
   gchar *ret;
+  gchar *ret2;
+
   GHashTable *ht = g_hash_table_new (g_direct_hash, g_direct_equal);
   ret = gegl_serialize2 (start, end, basepath, ht);
   g_hash_table_destroy (ht);
-  return ret;
+  ret2 = ret;
+  while (ret2[0] == ' ')
+    ret2++;
+  ret2 = g_strdup (ret2);
+  g_free (ret);
+  return ret2;
 }
 
 GeglNode *gegl_node_new_from_serialized (const gchar *xmldata,
diff --git a/tests/simple/test-serialize.c b/tests/simple/test-serialize.c
index c7dca63..ebd83f7 100644
--- a/tests/simple/test-serialize.c
+++ b/tests/simple/test-serialize.c
@@ -29,32 +29,32 @@ typedef struct TestCase {
 } TestCase;
 
 TestCase tests[] = {
-    {"invert",        " gegl:invert-linear",  ""},
-    {"invert a=b",    " gegl:invert-linear",  "gegl:invert has no a property."},
-    {"invert a=c",    " gegl:invert-linear",  "gegl:invert has no a property."},
-    {"gaussian-blur", " gegl:gaussian-blur",  ""},
-    {"over aux=[ text string='foo bar' ]",    " svg:src-over aux=[ gegl:text string='foo bar' width=35 
height=11 ]", ""},
-    {"over aux=[text string='foo bar' ]",     " svg:src-over aux=[ gegl:text string='foo bar' width=35 
height=11 ]", ""},
-    {"over aux= [ ",  " svg:src-over", "No such op 'gegl:['"}, 
+    {"invert",        "gegl:invert-linear",  ""},
+    {"invert a=b",    "gegl:invert-linear",  "gegl:invert has no a property."},
+    {"invert a=c",    "gegl:invert-linear",  "gegl:invert has no a property."},
+    {"gaussian-blur", "gegl:gaussian-blur",  ""},
+    {"over aux=[ text string='foo bar' ]",    "svg:src-over aux=[ gegl:text string='foo bar' width=35 
height=11 ]", ""},
+    {"over aux=[text string='foo bar' ]",     "svg:src-over aux=[ gegl:text string='foo bar' width=35 
height=11 ]", ""},
+    {"over aux= [ ",  "svg:src-over", "No such op 'gegl:['"}, 
     /* the following cause undesired warnings on console */
-    {"over aux=[ string='foo bar' ]",  " svg:src-over", ""},
+    {"over aux=[ string='foo bar' ]",  "svg:src-over", ""},
     /* the following should have error message */
-    {"over aux=[ ",   " svg:src-over", ""},
-    {"over aux=[ ]",  " svg:src-over", ""},
-    {"exposure foo=2"," gegl:exposure","gegl:exposure has no foo property, properties: 'exposure', 'offset', 
'gamma', "},
+    {"over aux=[ ",   "svg:src-over", ""},
+    {"over aux=[ ]",  "svg:src-over", ""},
+    {"exposure foo=2","gegl:exposure","gegl:exposure has no foo property, properties: 'exposure', 'offset', 
'gamma', "},
 
 
-    {"over aux=[text string='foo bar']",      " svg:src-over aux=[ gegl:text string='foo bar' width=35 
height=11 ]", ""},
-    {"over aux=[ load path=/ ]",    " svg:src-over aux=[ gegl:load path='/' ]", ""},
+    {"over aux=[text string='foo bar']",      "svg:src-over aux=[ gegl:text string='foo bar' width=35 
height=11 ]", ""},
+    {"over aux=[ load path=/ ]",    "svg:src-over aux=[ gegl:load path='/' ]", ""},
     {"inver",           "", "No such op 'gegl:inver' suggestions: gegl:invert-gamma gegl:invert-linear"},
 
-    {"over aux=[ load path=/abc ]", " svg:src-over aux=[ gegl:load path='/abc' ]", ""},
+    {"over aux=[ load path=/abc ]", "svg:src-over aux=[ gegl:load path='/abc' ]", ""},
 
 
-    {"id=foo over aux=[ ref=foo invert ]",  " id=foo svg:src-over aux=[ ref=foo gegl:invert-linear ]", ""},
-    {"id=bar id=foo over aux=[ ref=foo invert ]",  " id=foo svg:src-over aux=[ ref=foo gegl:invert-linear 
]", ""},
+    {"id=foo over aux=[ ref=foo invert ]",  "id=foo svg:src-over aux=[ ref=foo gegl:invert-linear ]", ""},
+    {"id=bar id=foo over aux=[ ref=foo invert ]",  "id=foo svg:src-over aux=[ ref=foo gegl:invert-linear ]", 
""},
 
-    {"over aux=[ text string={ 0='foo bar' } ]", " svg:src-over aux=[ gegl:text string='foo bar' width=35 
height=11 ]", ""},
+    {"over aux=[ text string={ 0='foo bar' } ]", "svg:src-over aux=[ gegl:text string='foo bar' width=35 
height=11 ]", ""},
 
     {NULL, NULL}
 };


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