Forked from takaokouji/dot_bundle_instead_of_dot_so.patch
Created
September 17, 2011 08:46
-
-
Save Watson1978/1223764 to your computer and use it in GitHub Desktop.
Indeed .bundle from .so in MacRuby
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/load.c b/load.c | |
index 06ca712..92ae5d7 100644 | |
--- a/load.c | |
+++ b/load.c | |
@@ -267,6 +267,21 @@ rb_require_safe(VALUE fname, int safe) | |
{ | |
FilePathValue(fname); | |
+ char *p = strrchr(RSTRING_PTR(fname), '.'); | |
+ if (p != NULL && strcmp(p + 1, "so") == 0) { | |
+ const char *ext = "bundle"; | |
+ const long ext_len = strlen(ext); | |
+ const long len = p - RSTRING_PTR(fname); | |
+ | |
+ if (PATH_MAX > len + ext_len + 1) { | |
+ char buf[PATH_MAX]; | |
+ strncpy(buf, RSTRING_PTR(fname), PATH_MAX); | |
+ strcpy(buf + len + 1, ext); | |
+ buf[PATH_MAX - 1] = '\0'; | |
+ fname = rb_str_new2(buf); | |
+ } | |
+ } | |
+ | |
// Immediately, check out if we have an AOT feature for this. | |
if (rb_vm_aot_feature_load(RSTRING_PTR(fname))) { | |
rb_provide_feature(fname); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment