[seed] Fix Bug #733393 - Fails to run on GNU/Hurd
- From: Alan Knowles <alank src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [seed] Fix Bug #733393 - Fails to run on GNU/Hurd
- Date: Mon, 4 Aug 2014 08:22:58 +0000 (UTC)
commit deba4fc2da293ee8f6cf6cb372737d59ca7614d1
Author: Pino Toscano <toscano pino tiscali it>
Date: Mon Aug 4 16:20:16 2014 +0800
Fix Bug #733393 - Fails to run on GNU/Hurd
reverts BSD changes to use realpath with NULL (which allocates the path)
Patch by Pino Toscano
libseed/seed-importer.c | 19 +++++--------------
modules/os/seed-os.c | 14 ++------------
2 files changed, 7 insertions(+), 26 deletions(-)
---
diff --git a/libseed/seed-importer.c b/libseed/seed-importer.c
index 37959d4..7ba98c8 100644
--- a/libseed/seed-importer.c
+++ b/libseed/seed-importer.c
@@ -713,9 +713,8 @@ seed_importer_handle_file (JSContextRef ctx,
JSValueRef js_file_dirname;
JSObjectRef global, c_global;
JSStringRef file_contents, file_name;
- gchar *contents, *walk, *file_path, *canonical, *absolute_path, *normalp;
- gchar *normalized_path;
- gsize path_max;
+ gchar *contents, *walk, *file_path, *canonical, *absolute_path;
+ char *normalized_path;
file_path = g_build_filename (dir, file, NULL);
canonical = seed_importer_canonicalize_path (file_path);
@@ -769,17 +768,9 @@ seed_importer_handle_file (JSContextRef ctx,
g_path_get_dirname (file_path), NULL);
}
-#ifdef PATH_MAX
- path_max = PATH_MAX;
-#else
- path_max = pathconf (absolute_path, _PC_PATH_MAX);
- if (path_max <= 0)
- path_max = 4096;
-#endif
- normalized_path = (gchar *) g_malloc (path_max);
- normalp = realpath (absolute_path, normalized_path);
-
- js_file_dirname = seed_value_from_string (ctx, normalp, NULL);
+ normalized_path = realpath (absolute_path, NULL);
+
+ js_file_dirname = seed_value_from_string (ctx, normalized_path, NULL);
seed_object_set_property (nctx, global, "__script_path__", js_file_dirname);
diff --git a/modules/os/seed-os.c b/modules/os/seed-os.c
index 1d56c32..bc327e5 100644
--- a/modules/os/seed-os.c
+++ b/modules/os/seed-os.c
@@ -66,26 +66,16 @@ seed_os_realpath (SeedContext ctx,
SeedValue sv;
gchar *arg;
gchar *resolved_path;
- gchar *ret;
- gsize path_max;
if (argument_count != 1)
{
EXPECTED_EXCEPTION("os.realpath", "1 argument");
}
arg = seed_value_to_string (ctx, arguments[0], exception);
-#ifdef PATH_MAX
- path_max = PATH_MAX;
-#else
- path_max = pathconf (arg, _PC_PATH_MAX);
- if (path_max <= 0)
- path_max = 4096;
-#endif
- resolved_path = (gchar *) g_malloc (path_max);
- ret = realpath(arg, resolved_path);
+ resolved_path = realpath (arg, NULL);
g_free (arg);
- sv = seed_value_from_string (ctx, ret, exception);
+ sv = seed_value_from_string (ctx, resolved_path, exception);
g_free (resolved_path);
return sv;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]