[gegl] bin: treat files where first non-whitespace char is < as xml



commit f3519e8baa947f3d2251a93d12aed547cc011443
Author: Øyvind Kolås <pippin gimp org>
Date:   Tue Apr 4 21:39:48 2017 +0200

    bin: treat files where first non-whitespace char is < as xml

 bin/gegl.c |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletions(-)
---
diff --git a/bin/gegl.c b/bin/gegl.c
index f0fa224..9867867 100644
--- a/bin/gegl.c
+++ b/bin/gegl.c
@@ -81,7 +81,15 @@ static gboolean file_is_gegl_xml (const gchar *path)
 
 static gboolean is_xml_fragment (const char *data)
 {
-  return strchr (data, '>') && strchr (data, '<'); //XXX: this should be better
+  int i;
+  for (i = 0; data && data[i]; i++)
+    switch (data[i])
+    {
+      case ' ':case '\t':case '\n':case '\r': break;
+      case '<': return TRUE;
+      default: return FALSE;
+    }
+  return FALSE;
 }
 
 int mrg_ui_main (int argc, char **argv, char **ops);


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