[seed] libseed: make seed_value_from_filename return "null" if passed "NULL"



commit f2e49562301df3c9f50ba865eb8b0b407a2883b2
Author: Tim Horton <hortont424 gmail com>
Date:   Sun Nov 1 00:06:18 2009 -0400

    libseed: make seed_value_from_filename return "null" if passed "NULL"

 libseed/seed-types.c |   28 ++++++++++++++++------------
 1 files changed, 16 insertions(+), 12 deletions(-)
---
diff --git a/libseed/seed-types.c b/libseed/seed-types.c
index 5452e04..f30bf70 100644
--- a/libseed/seed-types.c
+++ b/libseed/seed-types.c
@@ -2118,22 +2118,26 @@ seed_value_from_filename (JSContextRef ctx,
 {
   GError *e = NULL;
   gchar *utf8;
-
-  utf8 = g_filename_to_utf8 (val, -1, NULL, NULL, &e);
-
-  if (e)
+  
+  if (val == NULL)
+    return JSValueMakeNull (ctx);
+  else
     {
-      seed_make_exception_from_gerror (ctx, exception, e);
-      g_error_free (e);
-      // TODO: FIXMEShould be JS Null maybe?
-      return NULL;
-    }
+      utf8 = g_filename_to_utf8 (val, -1, NULL, NULL, &e);
 
-  JSValueRef valstr = seed_value_from_string (ctx, utf8, exception);
+      if (e)
+        {
+          seed_make_exception_from_gerror (ctx, exception, e);
+          g_error_free (e);
+          return JSValueMakeNull (ctx);
+        }
 
-  g_free (utf8);
+      JSValueRef valstr = seed_value_from_string (ctx, utf8, exception);
 
-  return valstr;
+      g_free (utf8);
+
+      return valstr;
+    }
 }
 
 /**



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