bim: Different approach to finding kuroko search paths
This commit is contained in:
parent
200573230f
commit
a9e6d0ad12
40
apps/bim.c
40
apps/bim.c
@ -11467,21 +11467,31 @@ void initialize(void) {
|
|||||||
|
|
||||||
krk_startModule("<bim-syntax>");
|
krk_startModule("<bim-syntax>");
|
||||||
|
|
||||||
#ifdef __toaru__
|
/* Try to import the shared object 'os' module. If we can't, try adjusting the module_paths to find it. */
|
||||||
# define KUROKO_SEARCH_PATH "/lib/kuroko/"
|
const char * potential_search_paths[] = {"/usr/lib/kuroko/","/usr/local/lib/kuroko/","/lib/kuroko/",NULL};
|
||||||
#else
|
const char ** next = potential_search_paths;
|
||||||
# define KUROKO_SEARCH_PATH "/usr/lib/kuroko/"
|
while (*next) {
|
||||||
#endif
|
KrkValue result = krk_interpret(
|
||||||
|
"try:\n"
|
||||||
/* Try to import the shared object 'os' module. If we can't,
|
" import os\n"
|
||||||
* try adjusting the module_paths to find it. */
|
" return True\n"
|
||||||
krk_interpret(
|
"except:\n"
|
||||||
"try:\n"
|
" return False\n", "<bim-syntax>");
|
||||||
" import os\n"
|
if (IS_BOOLEAN(result) && AS_BOOLEAN(result)) break;
|
||||||
"except:\n"
|
if (!access(*next, R_OK)) {
|
||||||
" import kuroko\n"
|
char snippet[1000];
|
||||||
" if '" KUROKO_SEARCH_PATH "' not in kuroko.module_paths:\n"
|
snprintf(snippet, 1000,
|
||||||
" kuroko.module_paths.append('" KUROKO_SEARCH_PATH "')", "<bim-syntax>");
|
"try:\n"
|
||||||
|
" import kuroko\n"
|
||||||
|
" if '%s' not in kuroko.module_paths:\n"
|
||||||
|
" kuroko.module_paths.append('%s')\n"
|
||||||
|
"except:\n"
|
||||||
|
" pass",
|
||||||
|
*next, *next);
|
||||||
|
krk_interpret(snippet, "<bim-syntax>");
|
||||||
|
}
|
||||||
|
next++;
|
||||||
|
}
|
||||||
|
|
||||||
import_directory("syntax");
|
import_directory("syntax");
|
||||||
krk_startModule("<bim-themes>");
|
krk_startModule("<bim-themes>");
|
||||||
|
Loading…
Reference in New Issue
Block a user