diff options
author | marcus <marcus@df743ca5-7f9a-e211-a948-0013205c9059> | 2009-08-23 02:46:03 +0800 |
---|---|---|
committer | marcus <marcus@df743ca5-7f9a-e211-a948-0013205c9059> | 2009-08-23 02:46:03 +0800 |
commit | 3c295ca877066fadc2b0fc0944a225aa11afc2d9 (patch) | |
tree | 0fb4b800cb3b46be825eb6d1ad883e77ea84fe0d /devel | |
parent | a43aefbd8b8a356fc1890d8f240f76d9e2fb2f6c (diff) | |
download | marcuscom-ports-3c295ca877066fadc2b0fc0944a225aa11afc2d9.tar marcuscom-ports-3c295ca877066fadc2b0fc0944a225aa11afc2d9.tar.gz marcuscom-ports-3c295ca877066fadc2b0fc0944a225aa11afc2d9.tar.bz2 marcuscom-ports-3c295ca877066fadc2b0fc0944a225aa11afc2d9.tar.lz marcuscom-ports-3c295ca877066fadc2b0fc0944a225aa11afc2d9.tar.xz marcuscom-ports-3c295ca877066fadc2b0fc0944a225aa11afc2d9.tar.zst marcuscom-ports-3c295ca877066fadc2b0fc0944a225aa11afc2d9.zip |
Use a more Linuxy approach to realpath(). This seems to be safe on FreeBSD.
git-svn-id: svn://creme-brulee.marcuscom.com/ports/trunk@12677 df743ca5-7f9a-e211-a948-0013205c9059
Diffstat (limited to 'devel')
-rw-r--r-- | devel/seed/files/patch-libseed_seed-importer.c | 33 | ||||
-rw-r--r-- | devel/seed/files/patch-modules_os_seed-os.c | 39 |
2 files changed, 51 insertions, 21 deletions
diff --git a/devel/seed/files/patch-libseed_seed-importer.c b/devel/seed/files/patch-libseed_seed-importer.c index fb4f5d246..c216fa88c 100644 --- a/devel/seed/files/patch-libseed_seed-importer.c +++ b/devel/seed/files/patch-libseed_seed-importer.c @@ -1,32 +1,38 @@ ---- libseed/seed-importer.c.orig 2009-08-22 14:10:19.000000000 -0400 -+++ libseed/seed-importer.c 2009-08-22 14:17:07.000000000 -0400 -@@ -20,8 +20,10 @@ - // TODO: Don't use GNU libc extension canonicalize_file_name, don't use realpath? - #define _GNU_SOURCE +--- libseed/seed-importer.c.orig 2009-08-10 16:23:35.000000000 -0400 ++++ libseed/seed-importer.c 2009-08-22 14:36:00.000000000 -0400 +@@ -22,6 +22,8 @@ -+#include <sys/param.h> #include <gio/gio.h> #include <string.h> +#include <stdlib.h> ++#include <unistd.h> #include "seed-private.h" -@@ -637,8 +639,8 @@ seed_importer_handle_file (JSContextRef +@@ -637,8 +639,9 @@ seed_importer_handle_file (JSContextRef JSValueRef js_file_dirname; JSObjectRef global, c_global; JSStringRef file_contents, file_name; - gchar *contents, *walk, *file_path, *canonical, *absolute_path; -- gchar *normalized_path; + gchar *contents, *walk, *file_path, *canonical, *absolute_path, *normalp; -+ gchar normalized_path[PATH_MAX]; + gchar *normalized_path; ++ gsize path_max; file_path = g_build_filename (dir, file, NULL); canonical = seed_importer_canonicalize_path (file_path); -@@ -692,9 +694,9 @@ seed_importer_handle_file (JSContextRef +@@ -692,15 +695,24 @@ seed_importer_handle_file (JSContextRef g_path_get_dirname (file_path), NULL); } - normalized_path = canonicalize_file_name (absolute_path); ++#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, normalized_path, NULL); @@ -34,3 +40,10 @@ seed_object_set_property (nctx, global, "__script_path__", js_file_dirname); + g_hash_table_insert (file_imports, canonical, global); + g_free (file_path); + g_free (absolute_path); ++ g_free (normalized_path); + + JSEvaluateScript (nctx, file_contents, NULL, file_name, 0, exception); + diff --git a/devel/seed/files/patch-modules_os_seed-os.c b/devel/seed/files/patch-modules_os_seed-os.c index 4ca80d346..1aec71b71 100644 --- a/devel/seed/files/patch-modules_os_seed-os.c +++ b/devel/seed/files/patch-modules_os_seed-os.c @@ -1,35 +1,52 @@ --- modules/os/seed-os.c.orig 2009-08-10 16:23:35.000000000 -0400 -+++ modules/os/seed-os.c 2009-08-22 14:18:53.000000000 -0400 -@@ -30,7 +30,11 @@ - #include <sys/stat.h> ++++ modules/os/seed-os.c 2009-08-22 14:43:42.000000000 -0400 +@@ -31,6 +31,10 @@ #include <sys/utsname.h> -+#include <sys/param.h> #include <sys/types.h> +#include <sys/ioctl.h> +#include <termios.h> +#include <libutil.h> ++#include <unistd.h> #include <fcntl.h> -@@ -55,6 +59,7 @@ seed_os_realpath (SeedContext ctx, +@@ -54,18 +58,32 @@ seed_os_realpath (SeedContext ctx, + const SeedValue arguments[], SeedException * exception) { ++ SeedValue sv; gchar *arg; -+ gchar resolved_path[PATH_MAX]; ++ gchar *resolved_path; gchar *ret; ++ gsize path_max; if (argument_count != 1) -@@ -62,7 +67,7 @@ seed_os_realpath (SeedContext ctx, + { EXPECTED_EXCEPTION("os.realpath", "1 argument"); } arg = seed_value_to_string (ctx, arguments[0], exception); - ret = canonicalize_file_name(arg); ++#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); g_free (arg); - return seed_value_from_string (ctx, ret, exception); -@@ -702,6 +707,7 @@ seed_os_fdatasync (SeedContext ctx, +- return seed_value_from_string (ctx, ret, exception); ++ sv = seed_value_from_string (ctx, ret, exception); ++ g_free (resolved_path); ++ ++ return sv; + } + + SeedValue +@@ -702,6 +720,7 @@ seed_os_fdatasync (SeedContext ctx, const SeedValue arguments[], SeedException * exception) { @@ -37,7 +54,7 @@ gint fd; if (argument_count != 1) -@@ -711,6 +717,10 @@ seed_os_fdatasync (SeedContext ctx, +@@ -711,6 +730,10 @@ seed_os_fdatasync (SeedContext ctx, fd = seed_value_to_int (ctx, arguments[0], exception); return seed_value_from_int (ctx, fdatasync (fd), exception); @@ -48,7 +65,7 @@ } SeedValue -@@ -1112,7 +1122,9 @@ seed_module_init(SeedEngine * eng) +@@ -1112,7 +1135,9 @@ seed_module_init(SeedEngine * eng) #if defined (O_DIRECT) OS_DEFINE_QUICK_ENUM (O_DIRECT); #endif |