rev 180 - trunk/src
SVN User <[email protected]>
| Newsgroups | gmane.comp.lang.prothon.cvs |
|---|---|
| Message-ID | <[email protected]> |
Author: bcollins
Date: 2004-03-28 08:55:13 -0500 (Sun, 28 Mar 2004)
New Revision: 180
Modified:
trunk/src/interp.c
Log:
Cleanup module loading a bit. Get's rid of one large buffer off the stack.
Modified: trunk/src/interp.c
===================================================================
--- trunk/src/interp.c 2004-03-28 13:09:22 UTC (rev 179)
+++ trunk/src/interp.c 2004-03-28 13:55:13 UTC (rev 180)
@@ -351,32 +351,40 @@
int store_local, obj_p alias, int return_mod ){
int i, llen, pkg_depth = 1;
obj_p dest_module, module_symbol, dmod;
- char ch, full_path[APR_PATH_MAX], pkg_path[APR_PATH_MAX], temp_str[APR_PATH_MAX],
- *module_name = NULL;
+ char ch, full_path[APR_PATH_MAX], pkg_path[APR_PATH_MAX];
+ char *module_name = NULL;
obj_p path_list = get_sys_path_list();
apr_finfo_t finfo;
- module_symbol = fr_data(param-1);
+ module_symbol = fr_data(param - 1);
module_name = symch(ist, module_symbol);
- if (alias) ch = *symch(ist, alias);
- else ch = *module_name;
+
+ if (alias)
+ ch = *symch(ist, alias);
+ else
+ ch = *module_name;
+
if (store_local) {
if (ch >= 'A' && ch <= 'Z')
- dest_module = frame->globals;
- else dest_module = frame->locals;
- } else dest_module = NULL;
+ dest_module = frame->globals;
+ else
+ dest_module = frame->locals;
+ } else
+ dest_module = NULL;
+
llen = list_len(ist, path_list);
pkg_path[0] = 0;
- for(i=0; i < llen; i++) {
- apr_snprintf(temp_str, sizeof(temp_str), "%s/%s",
+
+ for (i = 0; i < llen; i++) {
+ apr_snprintf(full_path, sizeof(full_path), "%s/%s/__init__.pr",
strch(list_item(ist, path_list, i)),
symch(ist, fr_data(pkg_depth)));
- apr_snprintf(full_path, sizeof(full_path), "%s/__init__.pr",
- temp_str);
if (apr_stat(&finfo, full_path, APR_FINFO_TYPE, get_pr_head_pool()) ==
APR_SUCCESS && finfo.filetype == APR_REG) {
- apr_cpystrn(pkg_path, temp_str, sizeof(pkg_path));
+ apr_snprintf(pkg_path, sizeof(pkg_path), "%s/%s",
+ strch(list_item(ist, path_list, i)),
+ symch(ist, fr_data(pkg_depth)));
if (alias && pkg_depth < param-1)
dmod = NULL;
@@ -392,17 +400,19 @@
pkg_depth++;
while (pkg_depth < param) {
- apr_snprintf(temp_str, sizeof(temp_str), "%s/%s",
- pkg_path, symch(ist, fr_data(pkg_depth)));
- apr_snprintf(full_path, sizeof(full_path), "%s/__init__.pr",
- temp_str);
+ apr_snprintf(full_path, sizeof(full_path), "%s/%s/__init__.pr",
+ pkg_path, symch(ist, fr_data(pkg_depth)));
if (apr_stat(&finfo, full_path, APR_FINFO_TYPE,
get_pr_head_pool()) == APR_SUCCESS &&
finfo.filetype == APR_REG) {
- apr_cpystrn(pkg_path, temp_str, sizeof(pkg_path));
+ apr_size_t len = strlen(pkg_path);
- if (alias && pkg_depth < param-1)
+ apr_cpystrn(pkg_path + len,
+ symch(ist, fr_data(pkg_depth)),
+ sizeof(pkg_path) - len);
+
+ if (alias && pkg_depth < param - 1)
dmod = NULL;
else
dmod = dest_module;
@@ -416,14 +426,14 @@
dest_module = get_attr(ist, OBJ(MODULES),
fr_data(pkg_depth));
pkg_depth++;
- } else
+ } else
break;
}
break;
}
}
- if (pkg_depth < param-1) {
+ if (pkg_depth < param - 1) {
raise_exception(ist, OBJ(INTERPRETER_EXC), "Package %s not found",
symch(ist, fr_data(pkg_depth)));
return NULL;
@@ -440,13 +450,16 @@
goto success;
if_exc_return NULL;
} else {
- for(i = 0; i < llen; i++) {
- apr_snprintf(full_path, sizeof(full_path), "%s/",
- strch(list_item(ist, path_list, i)));
- if (!alias)
- alias = module_symbol;
+ if (!alias)
+ alias = module_symbol;
+
+ for (i = 0; i < llen; i++) {
+ apr_cpystrn(full_path, strch(list_item(ist, path_list, i)),
+ sizeof(full_path));
+
if (load_dll_module(ist, full_path, module_name, dest_module, alias))
goto success;
+
if_exc_return NULL;
}
}