Index: parrot/src/library.c =================================================================== --- parrot/src/library.c (revision 37327) +++ parrot/src/library.c (working copy) @@ -710,7 +710,65 @@ } /* +=item C +Returns a STRING that contains the specified path, separated by colons (:). + +The C is one or more of the types defined in +F. + +=cut + +*/ + +PARROT_EXPORT +PARROT_WARN_UNUSED_RESULT +PARROT_CAN_RETURN_NULL +STRING* +Parrot_path_str(PARROT_INTERP, enum_runtime_ft type) +{ + ASSERT_ARGS(Parrot_path_str) + STRING *prefix; + STRING *full_path; + PMC *paths; + INTVAL i, n; + +/* TODO: Get the real separator, not this hacked-together stuff */ +#ifdef WIN32 + STRING * const envpathsep = CONST_STRING(interp, ";"); +#else + STRING * const envpathsep = CONST_STRING(interp, ":"); +#endif + + if (type & PARROT_RUNTIME_FT_DYNEXT) + paths = get_search_paths(interp, PARROT_LIB_PATH_DYNEXT); + else if (type & (PARROT_RUNTIME_FT_PBC | PARROT_RUNTIME_FT_SOURCE)) + paths = get_search_paths(interp, PARROT_LIB_PATH_LIBRARY); + else + paths = get_search_paths(interp, PARROT_LIB_PATH_INCLUDE); + + prefix = Parrot_get_runtime_path(interp); + n = VTABLE_elements(interp, paths); + + for (i = 0; i < n; ++i) { + STRING * const path = VTABLE_get_string_keyed_int(interp, paths, i); + STRING *found_name; + + if ( 0 == i ) { + full_path = Parrot_str_copy(interp, path); + } else { + if(path) { + full_path = Parrot_str_append(interp, full_path, envpathsep); + full_path = Parrot_str_append(interp, full_path, path); + } + } + } + + return full_path; +} + +/* + =item C Return a malloced C-string for the runtime prefix. The calling function Index: parrot/src/dynext.c =================================================================== --- parrot/src/dynext.c (revision 37327) +++ parrot/src/dynext.c (working copy) @@ -615,8 +615,18 @@ /* * XXX Parrot_ex_throw_from_c_args? return PMCNULL? * PMC Undef seems convenient, because it can be queried with get_bool() + * -- + * Changed to Parrot_ex_throw_from_c_args because silently continuing and + * giving weird errors later is not a cool look - wayland/Tim Nelson */ - return pmc_new(interp, enum_class_Undef); + /* return pmc_new(interp, enum_class_Undef); */ + + path = Parrot_path_str(interp, PARROT_RUNTIME_FT_DYNEXT); + + Parrot_ex_throw_from_c_args(interp, NULL, + EXCEPTION_LIBRARY_ERROR, + "Parrot VM: Can't load library '%s'; searched path %s\n", + wo_ext->strstart, path->strstart); } return run_init_lib(interp, handle, lib_name, wo_ext); Index: parrot/include/parrot/library.h =================================================================== --- parrot/include/parrot/library.h (revision 37327) +++ parrot/include/parrot/library.h (working copy) @@ -74,6 +74,13 @@ __attribute__nonnull__(2) FUNC_MODIFIES(*file); +PARROT_EXPORT +PARROT_WARN_UNUSED_RESULT +PARROT_CAN_RETURN_NULL +STRING* Parrot_path_str(PARROT_INTERP, + enum_runtime_ft type) + __attribute__nonnull__(1); + void parrot_init_library_paths(PARROT_INTERP) __attribute__nonnull__(1);