Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Watson1978/1223764 to your computer and use it in GitHub Desktop.
Save Watson1978/1223764 to your computer and use it in GitHub Desktop.
Indeed .bundle from .so in MacRuby
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