13 #define IS_RBEXT(e) (strcmp((e), ".rb") == 0)
14 #define IS_SOEXT(e) (strcmp((e), ".so") == 0 || strcmp((e), ".o") == 0)
16 #define IS_DLEXT(e) (strcmp((e), DLEXT) == 0 || strcmp((e), DLEXT2) == 0)
18 #define IS_DLEXT(e) (strcmp((e), DLEXT) == 0)
63 return GET_VM()->loaded_features;
69 return GET_VM()->loading_table;
80 if(vlen < len)
return 0;
81 if (!strncmp(name+(vlen-len),feature,len)){
82 plen = vlen - len - 1;
84 for (e = name + vlen; name != e && *e !=
'.' && *e !=
'/'; --e);
87 strncmp(e-len,feature,len) )
89 plen = e - name - len - 1;
96 if (n != plen )
continue;
97 if (n && (strncmp(name, s, n) || name[n] !=
'/'))
continue;
123 const char *s = (
const char *)v;
133 rb_feature_p(
const char *feature,
const char *ext,
int rb,
int expanded,
const char **fn)
137 long i,
len, elen, n;
145 len =
strlen(feature) - elen;
146 type = rb ?
'r' :
's';
158 if (strncmp(f, feature, len) != 0) {
159 if (expanded)
continue;
166 if (!*(e = f + len)) {
170 if (*e !=
'.')
continue;
174 if ((rb || !ext) && (
IS_RBEXT(e))) {
189 if ((f = fs.result) != 0) {
195 if (fn) *fn = (
const char*)data;
197 if (!ext)
return 'u';
204 if (ext && *ext)
return 0;
207 MEMCPY(buf, feature,
char, len);
212 if (fn) *fn = (
const char*)data;
213 return i ?
's' :
'r';
231 const char *ext =
strrchr(feature,
'.');
232 volatile VALUE fullpath = 0;
234 if (*feature ==
'.' &&
235 (feature[1] ==
'/' || strncmp(feature+1,
"./", 2) == 0)) {
239 if (ext && !
strchr(ext,
'/')) {
259 "$LOADED_FEATURES is frozen; cannot append feature");
279 volatile int loaded =
FALSE;
280 volatile int mild_compile_error;
375 VALUE fname, wrap, path;
403 return (
char *)ftptr;
406 rb_warning(
"loading in progress, circular require considered harmful - %s", ftptr);
420 if (
st_delete(loading_tbl, &key, &data)) {
498 if (ext && !
strchr(ext,
'/')) {
572 return type ?
's' :
'r';
600 char *
volatile ftptr = 0;
663 (*(void (*)(void))
arg)();
768 #define rb_intern(str) rb_intern2((str), strlen(str))
770 static const char var_load_path[] =
"$:";
771 ID id_load_path =
rb_intern2(var_load_path,
sizeof(var_load_path)-1);
#define RSTRING_LEN(string)
static VALUE get_loaded_features(void)
void rb_load_protect(VALUE fname, int wrap, int *state)
size_t strlen(const char *)
void rb_define_virtual_variable(const char *, VALUE(*)(ANYARGS), void(*)(ANYARGS))
NORETURN(static void load_failed(VALUE))
VALUE rb_barrier_new(void)
static void rb_load_internal(VALUE fname, int wrap)
static void rb_provide_feature(VALUE feature)
int rb_provided(const char *feature)
void rb_autoload(VALUE, ID, const char *)
static VALUE load_ext(VALUE path)
VALUE rb_file_expand_path_fast(VALUE, VALUE)
VALUE rb_ary_push(VALUE ary, VALUE item)
void rb_vm_jump_tag_but_local_jump(int state, VALUE val)
int st_get_key(st_table *, st_data_t, st_data_t *)
#define RSTRING_PTR(string)
void rb_raise(VALUE exc, const char *fmt,...)
VALUE rb_f_require_relative(VALUE obj, VALUE fname)
RUBY_FUNC_EXPORTED void ruby_init_ext(const char *name, void(*init)(void))
#define RARRAY_LEN(ARRAY)
VALUE rb_get_load_path(void)
void rb_define_global_function(const char *name, VALUE(*func)(ANYARGS), int argc)
Defines a global function.
VALUE rb_str_tmp_new(long)
static int rb_feature_p(const char *feature, const char *ext, int rb, int expanded, const char **fn)
VALUE rb_f_require(VALUE obj, VALUE fname)
static const char *const loadable_ext[]
static char * load_lock(const char *ftptr)
void * rb_load_file(const char *)
void rb_exc_raise(VALUE mesg)
VALUE rb_find_file(VALUE path)
char * ruby_strdup(const char *)
VALUE rb_require(const char *fname)
VALUE rb_class_real(VALUE)
VALUE rb_str_cat2(VALUE, const char *)
static VALUE load_path_getter(ID id, rb_vm_t *vm)
VALUE rb_iseq_new_top(NODE *node, VALUE name, VALUE filename, VALUE filepath, VALUE parent)
static VALUE loaded_feature_path(const char *name, long vlen, const char *feature, long len, int type, VALUE load_path)
static VALUE init_ext_call(VALUE arg)
VALUE rb_barrier_wait(VALUE self)
static VALUE rb_f_autoload(VALUE obj, VALUE sym, VALUE file)
RUBY_EXTERN VALUE rb_cModule
void rb_gc_register_mark_object(VALUE obj)
#define RUBY_FUNC_EXPORTED
#define MEMCPY(p1, p2, type, n)
void rb_provide(const char *feature)
VALUE rb_barrier_release(VALUE self)
VALUE rb_find_file_safe(VALUE path, int safe_level)
static st_table * get_loading_table(void)
VALUE rb_file_absolute_path(VALUE fname, VALUE dname)
VALUE rb_str_resize(VALUE, long)
VALUE rb_vm_call_cfunc(VALUE recv, VALUE(*func)(VALUE), VALUE arg, const rb_block_t *blockptr, VALUE filename)
VALUE rb_str_subseq(VALUE, long, long)
void rb_alias_variable(ID, ID)
#define RB_GC_GUARD(object)
VALUE rb_file_dirname(VALUE fname)
int rb_scan_args(int argc, const VALUE *argv, const char *fmt,...)
unsigned char buf[MIME_BUF_SIZE]
void rb_load(VALUE fname, int wrap)
static int loaded_feature_path_i(st_data_t v, st_data_t b, st_data_t f)
static VALUE rb_mod_autoload_p(VALUE mod, VALUE sym)
VALUE rb_iseq_eval(VALUE iseqval)
char * strchr(char *, char)
void rb_extend_object(VALUE obj, VALUE module)
static VALUE rb_f_load(int argc, VALUE *argv)
register unsigned int len
RUBY_EXTERN size_t strlcpy(char *, const char *, size_t)
#define RARRAY_PTR(ARRAY)
void * dln_load(const char *file)
void rb_define_hooked_variable(const char *, VALUE *, VALUE(*)(ANYARGS), void(*)(ANYARGS))
VALUE rb_str_freeze(VALUE)
void rb_set_safe_level_force(int)
VALUE rb_usascii_str_new2(const char *)
VALUE rb_realpath_internal(VALUE basedir, VALUE path, int strict)
static VALUE rb_mod_autoload(VALUE mod, VALUE sym, VALUE file)
VALUE rb_module_new(void)
VALUE rb_exc_new3(VALUE etype, VALUE str)
VALUE rb_str_buf_new_cstr(const char *)
void rb_gvar_readonly_setter(VALUE val, ID id, void *data, struct rb_global_variable *gvar)
VALUE rb_ary_new2(long capa)
VALUE rb_filesystem_str_new_cstr(const char *)
int rb_feature_provided(const char *feature, const char **loading)
int rb_find_file_ext_safe(VALUE *filep, const char *const *ext, int safe_level)
int rb_file_load_ok(const char *path)
#define StringValuePtr(v)
static int search_required(VALUE fname, volatile VALUE *path, int safe_level)
VALUE rb_get_expanded_load_path(void)
static void load_failed(VALUE fname)
void rb_warning(const char *fmt,...)
VALUE rb_current_realfilepath(void)
static VALUE rb_f_autoload_p(VALUE obj, VALUE sym)
VALUE rb_obj_freeze(VALUE)
ID rb_intern2(const char *name, long len)
static void load_unlock(const char *ftptr, int done)
VALUE rb_barrier_destroy(VALUE self)
void rb_define_method(VALUE klass, const char *name, VALUE(*func)(ANYARGS), int argc)
VALUE rb_str_append(VALUE, VALUE)
VALUE rb_str_new2(const char *)
VALUE rb_obj_clone(VALUE)
VALUE rb_require_safe(VALUE fname, int safe)
char * strrchr(const char *, const char)
VALUE rb_autoload_p(VALUE, ID)